xen: fix multicall debug feature
Subsystems (2)
Juergen Gross
maintainerPATCH 1/1 xen: fix multicall debug feature
Initializing a percpu variable with the address of a struct tagged as .initdata is breaking the build with CONFIG_SECTION_MISMATCH_WARN_ONLY not set to "y".
Fix that by using an access function instead returning the .initdata struct address if the percpu space of the struct hasn't been allocated yet.
--- arch/x86/xen/multicalls.c | 26 ++++++++++++++------------ arch/x86/xen/smp_pv.c | 1 - arch/x86/xen/xen-ops.h | 3 --- 3 files changed, 14 insertions(+), 16 deletions(-)
arch/x86/xen/multicalls.c +14 -12
@@ -54,14 +54,20 @@ struct mc_debug_data { static DEFINE_PER_CPU(struct mc_buffer, mc_buffer);static struct mc_debug_data mc_debug_data_early__initdata ; -static DEFINE_PER_CPU(struct mc_debug_data *, mc_debug_data) = - &mc_debug_data_early;static struct mc_debug_data __percpu *mc_debug_data_ptr; DEFINE_PER_CPU(unsigned long, xen_mc_irq_flags);static struct static_key mc_debug__ro_after_init ;static bool mc_debug_enabled__initdata ; +static struct mc_debug_data *__ref get_mc_debug (void ) +{ +if (!mc_debug_data_ptr) +return &mc_debug_data_early; + +return this_cpu_ptr (mc_debug_data_ptr); +} +static int __init xen_parse_mc_debug (char *arg) { mc_debug_enabled = true;
@@ -71,20 +77,16 @@ static int __init xen_parse_mc_debug(char *arg) }early_param ("xen_mc_debug" , xen_parse_mc_debug); -void mc_percpu_init (unsigned int cpu) -{ -per_cpu (mc_debug_data, cpu) =per_cpu_ptr (mc_debug_data_ptr, cpu); -} -static int __init mc_debug_enable (void ) {unsigned long flags; +struct mc_debug_data __percpu *mcdb;if (!mc_debug_enabled)return 0 ; - mc_debug_data_ptr = alloc_percpu(struct mc_debug_data); -if (!mc_debug_data_ptr) { + mcdb = alloc_percpu(struct mc_debug_data); +if (!mcdb) {pr_err ("xen_mc_debug inactive\n" );static_key_slow_dec (&mc_debug);return -ENOMEM ;
@@ -93,7 +95,7 @@ static int __init mc_debug_enable(void)/* Be careful when switching to percpu debug data. */ local_irq_save (flags);xen_mc_flush (); -mc_percpu_init (0 ); + mc_debug_data_ptr = mcdb;local_irq_restore (flags);pr_info ("xen_mc_debug active\n" );
@@ -155,7 +157,7 @@ void xen_mc_flush(void)trace_xen_mc_flush (b->mcidx, b->argidx, b->cbidx);if (static_key_false (&mc_debug)) { - mcdb =__this_cpu_read (mc_debug_data); + mcdb =get_mc_debug ();memcpy (mcdb->entries, b->entries, b->mcidx *sizeof (struct multicall_entry )); }
@@ -235,7 +237,7 @@ struct multicall_space __xen_mc_entry(size_t args) ret.mc = &b->entries[b->mcidx];if (static_key_false (&mc_debug)) { -struct mc_debug_data *mcdb =__this_cpu_read (mc_debug_data); +struct mc_debug_data *mcdb =get_mc_debug (); mcdb->caller[b->mcidx] =__builtin_return_address (0 ); mcdb->argsz[b->mcidx] = args;
arch/x86/xen/smp_pv.c +0 -1
@@ -305,7 +305,6 @@ static int xen_pv_kick_ap(unsigned int cpu, struct task_struct *idle)return rc;xen_pmu_init (cpu); -mc_percpu_init (cpu);/* * Why is this a BUG? If the hypercall fails then everything can be
arch/x86/xen/xen-ops.h +0 -3
@@ -261,9 +261,6 @@ void xen_mc_callback(void (*fn)(void *), void *data);*/ struct multicall_space xen_mc_extend_args (unsigned long op,size_t arg_size); -/* Do percpu data initialization for multicalls. */ -void mc_percpu_init (unsigned int cpu); -extern bool is_xen_pmu;irqreturn_t xen_pmu_irq_handler (int irq,void *dev_id);
Signature · 1 line
2.43.0
Quoted 11 lines · Juergen Gross
Initializing a percpu variable with the address of a struct tagged as .initdata is breaking the build with
CONFIG_SECTION_MISMATCH_WARN_ONLYnot set to "y".Fix that by using an access function instead returning the .initdata struct address if the percpu space of the struct hasn't been allocated yet.
Fixes 368990a7fe30 ("xen: fix multicall debug data referencing")Reported-by Borislav Petkov<[email protected]>Signed-off-by Juergen Gross<[email protected]>
Quoted 8 lines · Juergen Gross
Initializing a percpu variable with the address of a struct tagged as .initdata is breaking the build with
CONFIG_SECTION_MISMATCH_WARN_ONLYnot set to "y".Fix that by using an access function instead returning the .initdata struct address if the percpu space of the struct hasn't been allocated yet.
Quoted 8 lines
Fixes 368990a7fe30 ("xen: fix multicall debug data referencing")Reported-by Borislav Petkov <[email protected]>Signed-off-by Juergen Gross <[email protected]>--- arch/x86/xen/multicalls.c | 26 ++++++++++++++------------ arch/x86/xen/smp_pv.c | 1 - arch/x86/xen/xen-ops.h | 3 --- 3 files changed, 14 insertions(+), 16 deletions(-)
Looks good, doesn't fire here anymore.
Thx!
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette