lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c5947e5d-7164-45ff-997f-b36565412b86@amd.com>
Date: Fri, 21 Mar 2025 19:30:36 +0530
From: Neeraj Upadhyay <Neeraj.Upadhyay@....com>
To: Thomas Gleixner <tglx@...utronix.de>, linux-kernel@...r.kernel.org
Cc: bp@...en8.de, mingo@...hat.com, dave.hansen@...ux.intel.com,
 Thomas.Lendacky@....com, nikunj@....com, Santosh.Shukla@....com,
 Vasant.Hegde@....com, Suravee.Suthikulpanit@....com, David.Kaplan@....com,
 x86@...nel.org, hpa@...or.com, peterz@...radead.org, seanjc@...gle.com,
 pbonzini@...hat.com, kvm@...r.kernel.org, kirill.shutemov@...ux.intel.com,
 huibo.wang@....com, naveen.rao@....com
Subject: Re: [RFC v2 03/17] x86/apic: Populate .read()/.write() callbacks of
 Secure AVIC driver



On 3/21/2025 7:08 PM, Thomas Gleixner wrote:
> 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 for suggesting this!

- Neeraj

> Thanks,
> 
>         tglx


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ