Re: [RFC v2 03/17] x86/apic: Populate .read()/.write() callbacks of Secure AVIC driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 26 2025 at 14:35, Neeraj Upadhyay wrote:

> +static inline u32 get_reg(char *page, int reg)
> +{
> +	return READ_ONCE(*((u32 *)(page + reg)));

This type casting is disgusting. First you cast the void pointer of the
per CPU backing page implicitely into a signed character pointer and
then cast that to a u32 pointer. Seriously?

struct apic_page {
	union {
		u32	regs[NR_APIC_REGS];
                u8	bytes[PAGE_SIZE];
	};
};                

and the per CPU allocation of apic_page makes this:

static __always_inline u32 get_reg(unsigned int offset)
{
        return READ_ONCE(this_cpu_ptr(apic_page)->regs[offset >> 2]));
}

which avoids the whole pointer indirection of your backing page construct.

Thanks,

        tglx




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux