[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7af6dcf5-fbcd-4173-a588-38cf6c536282@zytor.com>
Date: Thu, 31 Jul 2025 09:40:41 -0700
From: Xin Li <xin@...or.com>
To: Chao Gao <chao.gao@...el.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
On 7/31/2025 3:34 AM, Chao Gao wrote:
>> -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.
This is now a static function with return type fastpath_t, so I guess
it's okay to remove fastpath from its name (It looks that Sean prefers
shorter function names if they contains enough information).
But if the protocol is to have "fastpath" in all fast path function
names, I can change it.
>
>> {
>> - 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.
I thought about it, but didn't do so because the original code doesn't
read the MSR data from registers when a MSR is not being handled in the
fast path, which saves some cycles in most cases.
Powered by blists - more mailing lists