Skip to content

Commit 84ad4d8

Browse files
stellarhoppersean-jc
authored andcommitted
KVM: VMX: Move vt_apicv_pre_state_restore() to posted_intr.c and tweak name
In preparation for a cleanup of the kvm_x86_ops struct for TDX, all vt_* functions are expected to act as glue functions that route to either tdx_* or vmx_* based on the VM type. Specifically, the pattern is: vt_abc: if (is_td()) return tdx_abc(); return vmx_abc(); But vt_apicv_pre_state_restore() does not follow this pattern. To facilitate that cleanup, rename and move vt_apicv_pre_state_restore() into posted_intr.c. Opportunistically turn vcpu_to_pi_desc() back into a static function, as the only reason it was exposed outside of posted_intr.c was for vt_apicv_pre_state_restore(). No functional change intended. Suggested-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/kvm/Z6v9yjWLNTU6X90d@google.com/ Cc: Sean Christopherson <seanjc@google.com> Cc: Rick Edgecombe <rick.p.edgecombe@intel.com> Reviewed-by: Binbin Wu <binbin.wu@linxu.intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Link: https://lore.kernel.org/r/20250318-vverma7-cleanup_x86_ops-v2-2-701e82d6b779@intel.com [sean: apply Chao's suggestions, massage shortlog] Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent f2d7993 commit 84ad4d8

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

arch/x86/kvm/vmx/main.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,6 @@ static void vt_set_virtual_apic_mode(struct kvm_vcpu *vcpu)
315315
return vmx_set_virtual_apic_mode(vcpu);
316316
}
317317

318-
static void vt_apicv_pre_state_restore(struct kvm_vcpu *vcpu)
319-
{
320-
struct pi_desc *pi = vcpu_to_pi_desc(vcpu);
321-
322-
pi_clear_on(pi);
323-
memset(pi->pir, 0, sizeof(pi->pir));
324-
}
325-
326318
static void vt_hwapic_isr_update(struct kvm_vcpu *vcpu, int max_isr)
327319
{
328320
if (is_td_vcpu(vcpu))
@@ -983,7 +975,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
983975
.set_apic_access_page_addr = vt_set_apic_access_page_addr,
984976
.refresh_apicv_exec_ctrl = vt_refresh_apicv_exec_ctrl,
985977
.load_eoi_exitmap = vt_load_eoi_exitmap,
986-
.apicv_pre_state_restore = vt_apicv_pre_state_restore,
978+
.apicv_pre_state_restore = pi_apicv_pre_state_restore,
987979
.required_apicv_inhibits = VMX_REQUIRED_APICV_INHIBITS,
988980
.hwapic_isr_update = vt_hwapic_isr_update,
989981
.sync_pir_to_irr = vt_sync_pir_to_irr,

arch/x86/kvm/vmx/posted_intr.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static DEFINE_PER_CPU(raw_spinlock_t, wakeup_vcpus_on_cpu_lock);
3434

3535
#define PI_LOCK_SCHED_OUT SINGLE_DEPTH_NESTING
3636

37-
struct pi_desc *vcpu_to_pi_desc(struct kvm_vcpu *vcpu)
37+
static struct pi_desc *vcpu_to_pi_desc(struct kvm_vcpu *vcpu)
3838
{
3939
return &(to_vt(vcpu)->pi_desc);
4040
}
@@ -264,6 +264,14 @@ void __init pi_init_cpu(int cpu)
264264
raw_spin_lock_init(&per_cpu(wakeup_vcpus_on_cpu_lock, cpu));
265265
}
266266

267+
void pi_apicv_pre_state_restore(struct kvm_vcpu *vcpu)
268+
{
269+
struct pi_desc *pi = vcpu_to_pi_desc(vcpu);
270+
271+
pi_clear_on(pi);
272+
memset(pi->pir, 0, sizeof(pi->pir));
273+
}
274+
267275
bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu)
268276
{
269277
struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);

arch/x86/kvm/vmx/posted_intr.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
#include <linux/bitmap.h>
66
#include <asm/posted_intr.h>
77

8-
struct pi_desc *vcpu_to_pi_desc(struct kvm_vcpu *vcpu);
9-
108
void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu);
119
void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu);
1210
void pi_wakeup_handler(void);
1311
void __init pi_init_cpu(int cpu);
12+
void pi_apicv_pre_state_restore(struct kvm_vcpu *vcpu);
1413
bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu);
1514
int vmx_pi_update_irte(struct kvm *kvm, unsigned int host_irq,
1615
uint32_t guest_irq, bool set);

0 commit comments

Comments
 (0)