Skip to content

Commit 96308b0

Browse files
babumogerbonzini
authored andcommitted
KVM: SVM: Update cr3_lm_rsvd_bits for AMD SEV guests
For AMD SEV guests, update the cr3_lm_rsvd_bits to mask the memory encryption bit in reserved bits. Signed-off-by: Babu Moger <[email protected]> Message-Id: <160521948301.32054.5783800787423231162.stgit@bmoger-ubuntu> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 0107973 commit 96308b0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3741,6 +3741,7 @@ static u64 svm_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio)
37413741
static void svm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
37423742
{
37433743
struct vcpu_svm *svm = to_svm(vcpu);
3744+
struct kvm_cpuid_entry2 *best;
37443745

37453746
vcpu->arch.xsaves_enabled = guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) &&
37463747
boot_cpu_has(X86_FEATURE_XSAVE) &&
@@ -3753,6 +3754,13 @@ static void svm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
37533754
/* Check again if INVPCID interception if required */
37543755
svm_check_invpcid(svm);
37553756

3757+
/* For sev guests, the memory encryption bit is not reserved in CR3. */
3758+
if (sev_guest(vcpu->kvm)) {
3759+
best = kvm_find_cpuid_entry(vcpu, 0x8000001F, 0);
3760+
if (best)
3761+
vcpu->arch.cr3_lm_rsvd_bits &= ~(1UL << (best->ebx & 0x3f));
3762+
}
3763+
37563764
if (!kvm_vcpu_apicv_active(vcpu))
37573765
return;
37583766

0 commit comments

Comments
 (0)