Re: [PATCH v12 01/24] KVM: x86: Rename kvm_{g,s}et_msr()* to show that they emulate guest accesses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 01, 2025, Xiaoyao Li wrote:
> On 8/12/2025 10:55 AM, Chao Gao wrote:
> 
> ...
> 
> > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> > index f19a76d3ca0e..86e4d0b8469b 100644
> > --- a/arch/x86/include/asm/kvm_host.h
> > +++ b/arch/x86/include/asm/kvm_host.h
> > @@ -2149,11 +2149,11 @@ void kvm_prepare_event_vectoring_exit(struct kvm_vcpu *vcpu, gpa_t gpa);
> >   void kvm_enable_efer_bits(u64);
> >   bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer);
> > -int kvm_get_msr_with_filter(struct kvm_vcpu *vcpu, u32 index, u64 *data);
> > -int kvm_set_msr_with_filter(struct kvm_vcpu *vcpu, u32 index, u64 data);
> > +int kvm_emulate_msr_read(struct kvm_vcpu *vcpu, u32 index, u64 *data);
> > +int kvm_emulate_msr_write(struct kvm_vcpu *vcpu, u32 index, u64 data);
> ...
> > -int kvm_get_msr(struct kvm_vcpu *vcpu, u32 index, u64 *data);
> > -int kvm_set_msr(struct kvm_vcpu *vcpu, u32 index, u64 data);
> > +int __kvm_emulate_msr_read(struct kvm_vcpu *vcpu, u32 index, u64 *data);
> > +int __kvm_emulate_msr_write(struct kvm_vcpu *vcpu, u32 index, u64 data);
> 
> I dislike the rename, it loses the information of filter.
> 
> can we keep the filer information and make them as below?
> 
>   kvm_get_msr_with_filter() -> kvm_emulate_msr_read_with_filter()
>   kvm_get_msr() -> kvm_emulate_msr_read()
>   kvm_set_msr_with_filter() -> kvm_emulate_msr_write_with_filter()
>   kvm_set_msr() -> kvm_emulate_msr_write()

Sorry, no.  I detest the "with_filter".  Requiring developers to add "with_filter"
suggests that emulating an access _with_ the filter is somehow exceptional.  That's
the exact opposite of the truth: emulating MSR accesses _without_ the filter should
only be done in very rare situations, e.g. when loading guest state as part of a
complex transition (RSM, SMI, VM-Enter, VM-Exit).

And if we keep "with_filter", the relationship between kvm_emulate_msr_{read,write}()
and __kvm_emulate_msr_{read,write}() will be non-obvious.




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux