summaryrefslogtreecommitdiff
path: root/arch/x86/kvm/mmu.h
diff options
context:
space:
mode:
authorYu Zhang <yu.c.zhang@linux.intel.com>2017-08-24 20:27:53 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2017-08-24 18:09:16 +0200
commitd1cd3ce9004412949163bfaa062a4df98fe75a98 (patch)
tree2e1f466ee6a60218518586f64058f23a0b3fb68f /arch/x86/kvm/mmu.h
parente911eb3b3414e62cbd9853e0a91c124f4a545c0f (diff)
KVM: MMU: check guest CR3 reserved bits based on its physical address width.
Currently, KVM uses CR3_L_MODE_RESERVED_BITS to check the reserved bits in CR3. Yet the length of reserved bits in guest CR3 should be based on the physical address width exposed to the VM. This patch changes CR3 check logic to calculate the reserved bits at runtime. Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu.h')
-rw-r--r--arch/x86/kvm/mmu.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index 3ed6192d93b1..67e7ec2eb7e0 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -48,6 +48,9 @@
static inline u64 rsvd_bits(int s, int e)
{
+ if (e < s)
+ return 0;
+
return ((1ULL << (e - s + 1)) - 1) << s;
}