]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: Introduce cr3_lm_rsvd_bits in kvm_vcpu_arch
authorBabu Moger <babu.moger@amd.com>
Thu, 12 Nov 2020 22:17:56 +0000 (16:17 -0600)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 13 Nov 2020 11:28:37 +0000 (06:28 -0500)
commit4739c37c7d99d4ebdfe9e7fa0bec2ce4bc5e6188
treee252df8f6666d74cc55a265bbc6f3915000d2e9a
parent73902db27a12dd3253ab6907e61192ab688ad76b
KVM: x86: Introduce cr3_lm_rsvd_bits in kvm_vcpu_arch

SEV guests fail to boot on a system that supports the PCID feature.

While emulating the RSM instruction, KVM reads the guest CR3
and calls kvm_set_cr3(). If the vCPU is in the long mode,
kvm_set_cr3() does a sanity check for the CR3 value. In this case,
it validates whether the value has any reserved bits set. The
reserved bit range is 63:cpuid_maxphysaddr(). When AMD memory
encryption is enabled, the memory encryption bit is set in the CR3
value. The memory encryption bit may fall within the KVM reserved
bit range, causing the KVM emulation failure.

Introduce a new field cr3_lm_rsvd_bits in kvm_vcpu_arch which will
cache the reserved bits in the CR3 value. This will be initialized
to rsvd_bits(cpuid_maxphyaddr(vcpu), 63).

If the architecture has any special bits(like AMD SEV encryption bit)
that needs to be masked from the reserved bits, should be cleared
in vendor specific kvm_x86_ops.vcpu_after_set_cpuid handler.

Fixes: c95855f8a409f463 ("KVM: X86: Fix reserved bits check for MOV to CR3")
Signed-off-by: Babu Moger <babu.moger@amd.com>
Message-Id: <160521947657.32054.3264016688005356563.stgit@bmoger-ubuntu>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/cpuid.c
arch/x86/kvm/x86.c