Skip to content

Commit 4422829

Browse files
committed
kvm: fix previous commit for 32-bit builds
array_index_nospec does not work for uint64_t on 32-bit builds. However, the size of a memory slot must be less than 20 bits wide on those system, since the memory slot must fit in the user address space. So just store it in an unsigned long. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent da27a83 commit 4422829

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/linux/kvm_host.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,8 +1191,8 @@ __gfn_to_hva_memslot(const struct kvm_memory_slot *slot, gfn_t gfn)
11911191
* table walks, do not let the processor speculate loads outside
11921192
* the guest's registered memslots.
11931193
*/
1194-
unsigned long offset = array_index_nospec(gfn - slot->base_gfn,
1195-
slot->npages);
1194+
unsigned long offset = gfn - slot->base_gfn;
1195+
offset = array_index_nospec(offset, slot->npages);
11961196
return slot->userspace_addr + offset * PAGE_SIZE;
11971197
}
11981198

0 commit comments

Comments
 (0)