Re: [PATCH v1 2/4] KVM: x86: Introduce MSR read/write emulation helpers

From: Xin Li
Date: Thu Jul 31 2025 - 21:36:31 EST


+
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.

Can you hold off on doing anything with this series? Mostly to save your time.

Sure.


Long story short, I unexpectedly dove into the fastpath code this week while sorting
out an issue with the mediated PMU series, and I ended up with a series of patches
to clean things up for both the mediated PMU series and for this series.

With luck, I'll get the cleanups, the mediated PMU series, and a v2 of this series
posted tomorrow (I also have some feedback on VCPU_EXREG_EDX_EAX; we can avoid it
entirely without much fuss).


Will wait and take a look when you post them.