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: <e9620899cc52cd45c090c939898be8787ff84df6.camel@infradead.org>
Date: Mon, 18 Aug 2025 16:52:30 +0100
From: David Woodhouse <dwmw2@...radead.org>
To: Dave Hansen <dave.hansen@...el.com>, "Ahmed S. Darwish"
	 <darwi@...utronix.de>, Borislav Petkov <bp@...en8.de>, Ingo Molnar
	 <mingo@...hat.com>, Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Andrew Cooper
 <andrew.cooper3@...rix.com>, "H. Peter Anvin" <hpa@...or.com>, Sean
 Christopherson <seanjc@...gle.com>, Peter Zijlstra <peterz@...radead.org>,
 Sohil Mehta <sohil.mehta@...el.com>,  John Ogness
 <john.ogness@...utronix.de>, x86@...nel.org, x86-cpuid@...ts.linux.dev,
 LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 28/34] x86/cacheinfo: Use parsed CPUID(0x80000005)
 and CPUID(0x80000006)

On Fri, 2025-08-15 at 08:25 -0700, Dave Hansen wrote:
> On 8/15/25 00:02, Ahmed S. Darwish wrote:
> > +static void legacy_amd_cpuid4(struct cpuinfo_x86 *c, int index,
> > struct leaf_0x4_0 *regs)
> >   {
> > -	unsigned int dummy, line_size, lines_per_tag, assoc,
> > size_in_kb;
> > -	union l1_cache l1i, l1d, *l1;
> > -	union l2_cache l2;
> > -	union l3_cache l3;
> > +	const struct leaf_0x80000005_0 *el5 = cpuid_leaf(c,
> > 0x80000005);
> > +	const struct leaf_0x80000006_0 *el6 = cpuid_leaf(c,
> > 0x80000006);
> > +	const struct cpuid_regs *el5_raw = (const struct
> > cpuid_regs *)el5;
> 
> Is there any way we could get rid of the casts? The lack of type
> safety
> on those always worries me. Maybe a helper like this:
> 
>     const struct cpuid_regs *el5_raw = cpuid_leaf_raw(c, 0x80000006);
> 
> (although that would probably just do casts internally). The other
> way
> would be to rig the macros up so that each 'struct leaf_$FOO' had a:
> 
> 	union {
> 		struct leaf_0x80000005_0 l;
> 		struct cpuid_regs raw;
> 	};
> 
> and then the macros just selected one of the two.

How about automatically building the cast into the macro invocation...

#define cpuid_leaf(c, l) ((struct cpuid_leaf_ ## l *)__cpuid_leaf(c, l)
#define cpuid_lead_index(c, l, i) ((struct cpuid_leaf_ ## l ## _ ## i) __cpuid_leaf_index(c, l, i)

That's a bit ugly unless we can canonicalise the leaf and index values
though. It even forces us to use raw numbers instead of names. Can we
come up with something that works... ?


Download attachment "smime.p7s" of type "application/pkcs7-signature" (5069 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ