Re: [PATCH v2 2/2] KVM:SVM: Update cr3_lm_rsvd_bits for AMD SEV guests

From: Paolo Bonzini
Date: Fri Nov 13 2020 - 06:32:28 EST


On 12/11/20 23:18, Babu Moger wrote:
+ /*
+ * For sev guests, update the cr3_lm_rsvd_bits to mask the memory
+ * encryption bit from reserved bits
+ */

Say why in the comment, don't repeat what the code already says (ok, technically the code didn't say that CPUID[0x8000001F].ebx hosts the memory encryption bit). I changed this to:

/* For sev guests, the memory encryption bit is not reserved in CR3. */

and queued the patches,

Paolo

+ if (sev_guest(vcpu->kvm)) {
+ best = kvm_find_cpuid_entry(vcpu, 0x8000001F, 0);
+ if (best)
+ vcpu->arch.cr3_lm_rsvd_bits &= ~(1UL << (best->ebx & 0x3f));
+ }
+