lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <efc9f54b-a145-4ff5-bb8a-84b9970bc51e@linux.intel.com>
Date: Fri, 12 Apr 2024 13:44:07 +0800
From: "Zhang, Xiong Y" <xiong.y.zhang@...ux.intel.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: pbonzini@...hat.com, peterz@...radead.org, mizhang@...gle.com,
 kan.liang@...el.com, zhenyuw@...ux.intel.com, dapeng1.mi@...ux.intel.com,
 jmattson@...gle.com, kvm@...r.kernel.org, linux-perf-users@...r.kernel.org,
 linux-kernel@...r.kernel.org, zhiyuan.lv@...el.com, eranian@...gle.com,
 irogers@...gle.com, samantha.alt@...el.com, like.xu.linux@...il.com,
 chao.gao@...el.com, Xiong Zhang <xiong.y.zhang@...el.com>
Subject: Re: [RFC PATCH 05/41] KVM: x86/pmu: Register PMI handler for
 passthrough PMU



On 4/12/2024 3:07 AM, Sean Christopherson wrote:
> On Fri, Jan 26, 2024, Xiong Zhang wrote:
>> From: Xiong Zhang <xiong.y.zhang@...el.com>
>>
>> Add function to register/unregister PMI handler at KVM module
>> initialization and destroy time. This allows the host PMU with passthough
>> capability enabled switch PMI handler at PMU context switch time.
>>
>> Signed-off-by: Xiong Zhang <xiong.y.zhang@...el.com>
>> Signed-off-by: Mingwei Zhang <mizhang@...gle.com>
>> ---
>>  arch/x86/kvm/x86.c | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index 2c924075f6f1..4432e736129f 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -10611,6 +10611,18 @@ void __kvm_request_immediate_exit(struct kvm_vcpu *vcpu)
>>  }
>>  EXPORT_SYMBOL_GPL(__kvm_request_immediate_exit);
>>  
>> +void kvm_passthrough_pmu_handler(void)
> 
> s/pmu/pmi, and this needs a verb.  Maybe kvm_handle_guest_pmi()?  Definitely
> open to other names.
kvm_handle_guest_pmi() is ok. 
> 
>> +{
>> +	struct kvm_vcpu *vcpu = kvm_get_running_vcpu();
>> +
>> +	if (!vcpu) {
>> +		pr_warn_once("%s: no running vcpu found!\n", __func__);
> 
> Unless I misunderstand the code, this can/should be a full WARN_ON_ONCE.  If a
> PMI skids all the way past vcpu_put(), we've got big problems.
yes, it is big problems and user should be noticed.
>  
>> +		return;
>> +	}
>> +
>> +	kvm_make_request(KVM_REQ_PMI, vcpu);
>> +}
>> +
>>  /*
>>   * Called within kvm->srcu read side.
>>   * Returns 1 to let vcpu_run() continue the guest execution loop without
>> @@ -13815,6 +13827,7 @@ static int __init kvm_x86_init(void)
>>  {
>>  	kvm_mmu_x86_module_init();
>>  	mitigate_smt_rsb &= boot_cpu_has_bug(X86_BUG_SMT_RSB) && cpu_smt_possible();
>> +	kvm_set_vpmu_handler(kvm_passthrough_pmu_handler);
> 
> Hmm, a few patches late, but the "kvm" scope is weird.  This calls a core x86
> function, not a KVM function.
> 
> And to reduce exports and copy+paste, what about something like this?
> 
> void x86_set_kvm_irq_handler(u8 vector, void (*handler)(void))
> {
> 	if (!handler)
> 		handler = dummy_handler;
> 
> 	if (vector == POSTED_INTR_WAKEUP_VECTOR)
> 		kvm_posted_intr_wakeup_handler = handler;
> 	else if (vector == KVM_GUEST_PMI_VECTOR)
> 		kvm_guest_pmi_handler = handler;
> 	else
> 		WARN_ON_ONCE(1);
> 
> 	if (handler == dummy_handler)
> 		synchronize_rcu();
> }
> EXPORT_SYMBOL_GPL(x86_set_kvm_irq_handler);
Good suggestion. Follow it in next version.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ