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: <aItGzjhpfzIbG+Op@intel.com>
Date: Thu, 31 Jul 2025 18:34:54 +0800
From: Chao Gao <chao.gao@...el.com>
To: "Xin Li (Intel)" <xin@...or.com>
CC: <linux-kernel@...r.kernel.org>, <kvm@...r.kernel.org>,
	<pbonzini@...hat.com>, <seanjc@...gle.com>, <tglx@...utronix.de>,
	<mingo@...hat.com>, <bp@...en8.de>, <dave.hansen@...ux.intel.com>,
	<x86@...nel.org>, <hpa@...or.com>
Subject: Re: [PATCH v1 2/4] KVM: x86: Introduce MSR read/write emulation
 helpers

>-fastpath_t handle_fastpath_set_msr_irqoff(struct kvm_vcpu *vcpu)
>+static fastpath_t handle_set_msr_irqoff(struct kvm_vcpu *vcpu, u32 msr, int reg)

How about __handle_fastpath_set_msr_irqoff()? It's better to keep
"fastpath" in the function name to convey that this function is for
fastpath only.

> {
>-	u32 msr = kvm_rcx_read(vcpu);
> 	u64 data;
> 	fastpath_t ret;
> 	bool handled;
>@@ -2174,11 +2190,19 @@ fastpath_t handle_fastpath_set_msr_irqoff(struct kvm_vcpu *vcpu)
> 
> 	switch (msr) {
> 	case APIC_BASE_MSR + (APIC_ICR >> 4):
>-		data = kvm_read_edx_eax(vcpu);
>+		if (reg == VCPU_EXREG_EDX_EAX)
>+			data = kvm_read_edx_eax(vcpu);
>+		else
>+			data = kvm_register_read(vcpu, reg);

...

>+
> 		handled = !handle_fastpath_set_x2apic_icr_irqoff(vcpu, data);
> 		break;
> 	case MSR_IA32_TSC_DEADLINE:
>-		data = kvm_read_edx_eax(vcpu);
>+		if (reg == VCPU_EXREG_EDX_EAX)
>+			data = kvm_read_edx_eax(vcpu);
>+		else
>+			data = kvm_register_read(vcpu, reg);
>+

Hoist this chunk out of the switch clause to avoid duplication.

> 		handled = !handle_fastpath_set_tscdeadline(vcpu, data);
> 		break;
> 	default:
>@@ -2200,6 +2224,11 @@ fastpath_t handle_fastpath_set_msr_irqoff(struct kvm_vcpu *vcpu)
> 
> 	return ret;
> }
>+
>+fastpath_t handle_fastpath_set_msr_irqoff(struct kvm_vcpu *vcpu)
>+{
>+	return handle_set_msr_irqoff(vcpu, kvm_rcx_read(vcpu), VCPU_EXREG_EDX_EAX);
>+}
> EXPORT_SYMBOL_GPL(handle_fastpath_set_msr_irqoff);
> 
> /*
>-- 
>2.50.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ