Re: [PATCH v3 01/11] KVM: x86: Get active PCID only when writing a CR3 value

From: Paolo Bonzini
Date: Wed Jan 27 2021 - 12:36:06 EST


On 27/10/20 22:23, Sean Christopherson wrote:

+static void svm_load_mmu_pgd(struct kvm_vcpu *vcpu, hpa_t root_hpa,
int root_level)
{
struct vcpu_svm *svm = to_svm(vcpu);
unsigned long cr3;
- cr3 = __sme_set(root);
+ cr3 = __sme_set(root_hpa) | kvm_get_active_pcid(vcpu);
if (npt_enabled) {
svm->vmcb->control.nested_cr3 = cr3;

SVM uses the name "nested CR3" so this variable actually could represent an NPT value that does not need the PCID.

Therefore, this change must be done in an else branch, which I've done on applying the patch.

Paolo