On 15/09/20 00:16, Sean Christopherson wrote:
+int kvm_track_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) +{ + unsigned long old_cr4 = kvm_read_cr4(vcpu); + unsigned long pdptr_bits = X86_CR4_PGE | X86_CR4_PSE | X86_CR4_PAE | + X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_PKE; + + if (kvm_x86_ops.set_cr4(vcpu, cr4)) + return 1;Pretty much all the same comments as EFER and CR0, e.g. call svm_set_cr4() directly instead of bouncing through kvm_x86_ops. And with that, this can be called __kvm_set_cr4() to be consistent with __kvm_set_cr0().
I agree with calling svm_set_cr4 directly, but then this should be kvm_post_set_cr4.
Paolo
+ + if (((cr4 ^ old_cr4) & pdptr_bits) || + (!(cr4 & X86_CR4_PCIDE) && (old_cr4 & X86_CR4_PCIDE))) + kvm_mmu_reset_context(vcpu); + + if ((cr4 ^ old_cr4) & (X86_CR4_OSXSAVE | X86_CR4_PKE)) + kvm_update_cpuid_runtime(vcpu); + + return 0; +}

