Skip to content

Commit f85c758

Browse files
Dan Carpenterrkrcmar
authored andcommitted
KVM: x86: masking out upper bits
kvm_read_cr3() returns an unsigned long and gfn is a u64. We intended to mask out the bottom 5 bits but because of the type issue we mask the top 32 bits as well. I don't know if this is a real problem, but it causes static checker warnings. Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Radim Krčmář <[email protected]>
1 parent 5771a8c commit f85c758

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/x86/kvm/x86.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ bool pdptrs_changed(struct kvm_vcpu *vcpu)
597597
(unsigned long *)&vcpu->arch.regs_avail))
598598
return true;
599599

600-
gfn = (kvm_read_cr3(vcpu) & ~31u) >> PAGE_SHIFT;
601-
offset = (kvm_read_cr3(vcpu) & ~31u) & (PAGE_SIZE - 1);
600+
gfn = (kvm_read_cr3(vcpu) & ~31ul) >> PAGE_SHIFT;
601+
offset = (kvm_read_cr3(vcpu) & ~31ul) & (PAGE_SIZE - 1);
602602
r = kvm_read_nested_guest_page(vcpu, gfn, pdpte, offset, sizeof(pdpte),
603603
PFERR_USER_MASK | PFERR_WRITE_MASK);
604604
if (r < 0)

0 commit comments

Comments
 (0)