Re: [PATCH 7/8] x86/vPMU: drop regs parameter from interrupt functions

2024-01-11 Thread Andrew Cooper
On 11/01/2024 7:36 am, Jan Beulich wrote:
> The vendor functions don't use the respective parameters at all. In
> vpmu_do_interrupt() there's only a very limited area where the
> outer context's state would be needed, retrievable by get_irq_regs().
>
> This is in preparation of dropping the register parameters from direct
> APIC vector handler functions.
>
> Signed-off-by: Jan Beulich 

Reviewed-by: Andrew Cooper 



[PATCH 7/8] x86/vPMU: drop regs parameter from interrupt functions

2024-01-10 Thread Jan Beulich
The vendor functions don't use the respective parameters at all. In
vpmu_do_interrupt() there's only a very limited area where the
outer context's state would be needed, retrievable by get_irq_regs().

This is in preparation of dropping the register parameters from direct
APIC vector handler functions.

Signed-off-by: Jan Beulich 

--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -1412,7 +1412,7 @@ static void cf_check error_interrupt(str
 static void cf_check pmu_interrupt(struct cpu_user_regs *regs)
 {
 ack_APIC_irq();
-vpmu_do_interrupt(regs);
+vpmu_do_interrupt();
 }
 
 void __init apic_intr_init(void)
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -158,7 +158,7 @@ static inline struct vcpu *choose_hwdom_
 return hardware_domain->vcpu[idx];
 }
 
-void vpmu_do_interrupt(struct cpu_user_regs *regs)
+void vpmu_do_interrupt(void)
 {
 struct vcpu *sampled = current, *sampling;
 struct vpmu_struct *vpmu;
@@ -239,6 +239,7 @@ void vpmu_do_interrupt(struct cpu_user_r
 else
 #endif
 {
+const struct cpu_user_regs *regs = get_irq_regs();
 struct xen_pmu_regs *r = >xenpmu_data->pmu.r.regs;
 
 if ( (vpmu_mode & XENPMU_MODE_SELF) )
@@ -301,7 +302,7 @@ void vpmu_do_interrupt(struct cpu_user_r
 /* We don't support (yet) HVM dom0 */
 ASSERT(sampling == sampled);
 
-if ( !alternative_call(vpmu_ops.do_interrupt, regs) ||
+if ( !alternative_call(vpmu_ops.do_interrupt) ||
  !is_vlapic_lvtpc_enabled(vlapic) )
 return;
 
--- a/xen/arch/x86/cpu/vpmu_amd.c
+++ b/xen/arch/x86/cpu/vpmu_amd.c
@@ -175,7 +175,7 @@ static void amd_vpmu_unset_msr_bitmap(st
 msr_bitmap_off(vpmu);
 }
 
-static int cf_check amd_vpmu_do_interrupt(struct cpu_user_regs *regs)
+static int cf_check amd_vpmu_do_interrupt(void)
 {
 return 1;
 }
--- a/xen/arch/x86/cpu/vpmu_intel.c
+++ b/xen/arch/x86/cpu/vpmu_intel.c
@@ -772,7 +772,7 @@ static void cf_check core2_vpmu_dump(con
 }
 }
 
-static int cf_check core2_vpmu_do_interrupt(struct cpu_user_regs *regs)
+static int cf_check core2_vpmu_do_interrupt(void)
 {
 struct vcpu *v = current;
 u64 msr_content;
--- a/xen/arch/x86/include/asm/vpmu.h
+++ b/xen/arch/x86/include/asm/vpmu.h
@@ -31,7 +31,7 @@ struct arch_vpmu_ops {
 int (*initialise)(struct vcpu *v);
 int (*do_wrmsr)(unsigned int msr, uint64_t msr_content);
 int (*do_rdmsr)(unsigned int msr, uint64_t *msr_content);
-int (*do_interrupt)(struct cpu_user_regs *regs);
+int (*do_interrupt)(void);
 void (*arch_vpmu_destroy)(struct vcpu *v);
 int (*arch_vpmu_save)(struct vcpu *v, bool to_guest);
 int (*arch_vpmu_load)(struct vcpu *v, bool from_guest);
@@ -99,7 +99,7 @@ static inline bool vpmu_are_all_set(cons
 
 void vpmu_lvtpc_update(uint32_t val);
 int vpmu_do_msr(unsigned int msr, uint64_t *msr_content, bool is_write);
-void vpmu_do_interrupt(struct cpu_user_regs *regs);
+void vpmu_do_interrupt(void);
 void vpmu_initialise(struct vcpu *v);
 void vpmu_destroy(struct vcpu *v);
 void vpmu_save(struct vcpu *v);