mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 10:33:41 +02:00
KVM: x86: Fold WRMSR fastpath helpers into the main handler
Fold the per-MSR WRMSR fastpath helpers into the main handler now that the IPI path in particular is relatively tiny. In addition to eliminating a decent amount of boilerplate, this removes the ugly -errno/1/0 => bool conversion (which is "necessitated" by kvm_x2apic_icr_write_fast()). Opportunistically drop the comment about IPIs, as the purpose of the fastpath is hopefully self-evident, and _if_ it needs more documentation, the documentation (and rules!) should be placed in a more central location. No functional change intended. Link: https://lore.kernel.org/r/20250805190526.1453366-9-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
aa2e4f0293
commit
d618fb4e43
|
|
@ -2134,48 +2134,24 @@ static inline bool kvm_vcpu_exit_request(struct kvm_vcpu *vcpu)
|
|||
kvm_request_pending(vcpu) || xfer_to_guest_mode_work_pending();
|
||||
}
|
||||
|
||||
/*
|
||||
* The fast path for frequent and performance sensitive wrmsr emulation,
|
||||
* i.e. the sending of IPI, sending IPI early in the VM-Exit flow reduces
|
||||
* the latency of virtual IPI by avoiding the expensive bits of transitioning
|
||||
* from guest to host, e.g. reacquiring KVM's SRCU lock. In contrast to the
|
||||
* other cases which must be called after interrupts are enabled on the host.
|
||||
*/
|
||||
static int handle_fastpath_set_x2apic_icr_irqoff(struct kvm_vcpu *vcpu, u64 data)
|
||||
{
|
||||
if (!lapic_in_kernel(vcpu) || !apic_x2apic_mode(vcpu->arch.apic))
|
||||
return 1;
|
||||
|
||||
return kvm_x2apic_icr_write_fast(vcpu->arch.apic, data);
|
||||
}
|
||||
|
||||
static int handle_fastpath_set_tscdeadline(struct kvm_vcpu *vcpu, u64 data)
|
||||
{
|
||||
kvm_set_lapic_tscdeadline_msr(vcpu, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fastpath_t handle_fastpath_set_msr_irqoff(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
u64 data = kvm_read_edx_eax(vcpu);
|
||||
u32 msr = kvm_rcx_read(vcpu);
|
||||
bool handled;
|
||||
int r;
|
||||
|
||||
switch (msr) {
|
||||
case APIC_BASE_MSR + (APIC_ICR >> 4):
|
||||
handled = !handle_fastpath_set_x2apic_icr_irqoff(vcpu, data);
|
||||
if (!lapic_in_kernel(vcpu) || !apic_x2apic_mode(vcpu->arch.apic) ||
|
||||
kvm_x2apic_icr_write_fast(vcpu->arch.apic, data))
|
||||
return EXIT_FASTPATH_NONE;
|
||||
break;
|
||||
case MSR_IA32_TSC_DEADLINE:
|
||||
handled = !handle_fastpath_set_tscdeadline(vcpu, data);
|
||||
kvm_set_lapic_tscdeadline_msr(vcpu, data);
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!handled)
|
||||
return EXIT_FASTPATH_NONE;
|
||||
}
|
||||
|
||||
kvm_vcpu_srcu_read_lock(vcpu);
|
||||
r = kvm_skip_emulated_instruction(vcpu);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user