Re: [RFC v2 01/17] x86/apic: Add new driver for Secure AVIC

From: Thomas Gleixner
Date: Fri Mar 21 2025 - 08:53:59 EST


On Wed, Feb 26 2025 at 14:35, Neeraj Upadhyay wrote:
> +static void x2apic_savic_send_IPI(int cpu, int vector)
> +{
> + u32 dest = per_cpu(x86_cpu_to_apicid, cpu);
> +
> + /* x2apic MSRs are special and need a special fence: */
> + weak_wrmsr_fence();
> + __x2apic_send_IPI_dest(dest, vector, APIC_DEST_PHYSICAL);
> +}
> +
> +static void
> +__send_IPI_mask(const struct cpumask *mask, int vector, int apic_dest)
> +{
> + unsigned long query_cpu;
> + unsigned long this_cpu;
> + unsigned long flags;
> +
> + /* x2apic MSRs are special and need a special fence: */
> + weak_wrmsr_fence();
> +
> + local_irq_save(flags);
> +
> + this_cpu = smp_processor_id();
> + for_each_cpu(query_cpu, mask) {
> + if (apic_dest == APIC_DEST_ALLBUT && this_cpu == query_cpu)
> + continue;
> + __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
> + vector, APIC_DEST_PHYSICAL);
> + }
> + local_irq_restore(flags);
> +}
> +
> +static void x2apic_savic_send_IPI_mask(const struct cpumask *mask, int vector)
> +{
> + __send_IPI_mask(mask, vector, APIC_DEST_ALLINC);
> +}
> +
> +static void x2apic_savic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
> +{
> + __send_IPI_mask(mask, vector, APIC_DEST_ALLBUT);
> +}

The above are identical copies (aside of the names) of the functions in
x2apic_phys.c.

Why can't this simply share the code ?

Thanks,

tglx