[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aE9/ayZNEXoA/ZEE@intel.com>
Date: Mon, 16 Jun 2025 10:20:27 +0800
From: Chao Gao <chao.gao@...el.com>
To: "Mi, Dapeng" <dapeng1.mi@...ux.intel.com>
CC: <linux-kernel@...r.kernel.org>, <kvm@...r.kernel.org>,
<seanjc@...gle.com>, <pbonzini@...hat.com>
Subject: Re: [PATCH 1/2] KVM: x86: Deduplicate MSR interception enabling and
disabling
>> --- a/arch/x86/kvm/vmx/vmx.h
>> +++ b/arch/x86/kvm/vmx/vmx.h
>> @@ -388,21 +388,13 @@ void vmx_ept_load_pdptrs(struct kvm_vcpu *vcpu);
>>
>> void vmx_disable_intercept_for_msr(struct kvm_vcpu *vcpu, u32 msr, int type);
>> void vmx_enable_intercept_for_msr(struct kvm_vcpu *vcpu, u32 msr, int type);
>> +void vmx_set_intercept_for_msr(struct kvm_vcpu *vcpu, u32 msr, int type, bool enable);
>>
>> u64 vmx_get_l2_tsc_offset(struct kvm_vcpu *vcpu);
>> u64 vmx_get_l2_tsc_multiplier(struct kvm_vcpu *vcpu);
>>
>> gva_t vmx_get_untagged_addr(struct kvm_vcpu *vcpu, gva_t gva, unsigned int flags);
>>
>> -static inline void vmx_set_intercept_for_msr(struct kvm_vcpu *vcpu, u32 msr,
>> - int type, bool value)
>> -{
>> - if (value)
>> - vmx_enable_intercept_for_msr(vcpu, msr, type);
>> - else
>> - vmx_disable_intercept_for_msr(vcpu, msr, type);
>> -}
>> -
>> void vmx_update_cpu_dirty_logging(struct kvm_vcpu *vcpu);
>>
>> /*
>
>The change looks good to me.
>
>Reviewed-by: Dapeng Mi <dapeng1.mi@...ux.intel.com>
Thanks.
>
>Just curious, is there a preference on using these 3 interfaces? When
>should we use the disable/enable interfaces? When should be we use the set
>interface? or no preference?
I think the set API is to reduce boilerplate code. So, use the set API when
you need to perform conditional logic, such as
if (/*check guest/host caps*/)
//disable intercept
else
//enable intercept
otherwise, use the disable/enable APIs.
Powered by blists - more mailing lists