Skip to content

Commit ea60229

Browse files
committed
KVM: x86: Dedup fastpath MSR post-handling logic
Now that the WRMSR fastpath for x2APIC_ICR and TSC_DEADLINE are identical, ignoring the backend MSR handling, consolidate the common bits of skipping the instruction and setting the return value. No functional change intended. Link: https://lore.kernel.org/r/20240802195120.325560-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 0dd45f2 commit ea60229

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

arch/x86/kvm/x86.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,31 +2186,32 @@ fastpath_t handle_fastpath_set_msr_irqoff(struct kvm_vcpu *vcpu)
21862186
{
21872187
u32 msr = kvm_rcx_read(vcpu);
21882188
u64 data;
2189-
fastpath_t ret = EXIT_FASTPATH_NONE;
2189+
fastpath_t ret;
2190+
bool handled;
21902191

21912192
kvm_vcpu_srcu_read_lock(vcpu);
21922193

21932194
switch (msr) {
21942195
case APIC_BASE_MSR + (APIC_ICR >> 4):
21952196
data = kvm_read_edx_eax(vcpu);
2196-
if (!handle_fastpath_set_x2apic_icr_irqoff(vcpu, data)) {
2197-
kvm_skip_emulated_instruction(vcpu);
2198-
ret = EXIT_FASTPATH_REENTER_GUEST;
2199-
}
2197+
handled = !handle_fastpath_set_x2apic_icr_irqoff(vcpu, data);
22002198
break;
22012199
case MSR_IA32_TSC_DEADLINE:
22022200
data = kvm_read_edx_eax(vcpu);
2203-
if (!handle_fastpath_set_tscdeadline(vcpu, data)) {
2204-
kvm_skip_emulated_instruction(vcpu);
2205-
ret = EXIT_FASTPATH_REENTER_GUEST;
2206-
}
2201+
handled = !handle_fastpath_set_tscdeadline(vcpu, data);
22072202
break;
22082203
default:
2204+
handled = false;
22092205
break;
22102206
}
22112207

2212-
if (ret != EXIT_FASTPATH_NONE)
2208+
if (handled) {
2209+
kvm_skip_emulated_instruction(vcpu);
2210+
ret = EXIT_FASTPATH_REENTER_GUEST;
22132211
trace_kvm_msr_write(msr, data);
2212+
} else {
2213+
ret = EXIT_FASTPATH_NONE;
2214+
}
22142215

22152216
kvm_vcpu_srcu_read_unlock(vcpu);
22162217

0 commit comments

Comments
 (0)