Messages in this thread | | | Subject | Re: [RFC PATCH 22/35] KVM: SVM: Add support for CR0 write traps for an SEV-ES guest | From | Paolo Bonzini <> | Date | Mon, 30 Nov 2020 19:15:33 +0100 |
| |
On 15/09/20 00:13, Sean Christopherson wrote: >> +static void kvm_post_set_cr0(struct kvm_vcpu *vcpu, unsigned long old_cr0, >> + unsigned long cr0) > What about using __kvm_set_cr*() instead of kvm_post_set_cr*()? That would > show that __kvm_set_cr*() is a subordinate of kvm_set_cr*(), and from the > SVM side would provide the hint that the code is skipping the front end of > kvm_set_cr*().
No, kvm_post_set_cr0 is exactly the right name because it doesn't set any state. __kvm_set_cr0 tells me that it is a (rarely used) way to set CR0, which this function isn't.
Sorry Tom for not catching this earlier.
Paolo
>> +{ >> + unsigned long update_bits = X86_CR0_PG | X86_CR0_WP; >> + >> + if ((cr0 ^ old_cr0) & X86_CR0_PG) { >> + kvm_clear_async_pf_completion_queue(vcpu); >> + kvm_async_pf_hash_reset(vcpu); >> + } >> + >> + if ((cr0 ^ old_cr0) & update_bits) >> + kvm_mmu_reset_context(vcpu); >> + >> + if (((cr0 ^ old_cr0) & X86_CR0_CD) && >> + kvm_arch_has_noncoherent_dma(vcpu->kvm) && >> + !kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_CD_NW_CLEARED)) >> + kvm_zap_gfn_range(vcpu->kvm, 0, ~0ULL); >> +} >> + >> int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) >> { >> unsigned long old_cr0 = kvm_read_cr0(vcpu); >> unsigned long pdptr_bits = X86_CR0_CD | X86_CR0_NW | X86_CR0_PG; >> - unsigned long update_bits = X86_CR0_PG | X86_CR0_WP; >> >> cr0 |= X86_CR0_ET; >> >> @@ -842,22 +860,23 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) >> >> kvm_x86_ops.set_cr0(vcpu, cr0); >> >> - if ((cr0 ^ old_cr0) & X86_CR0_PG) { >> - kvm_clear_async_pf_completion_queue(vcpu); >> - kvm_async_pf_hash_reset(vcpu); >> - } >> + kvm_post_set_cr0(vcpu, old_cr0, cr0);
| |