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]
Date: Thu, 15 Feb 2024 16:07:05 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>, x86@...nel.org, Tom Lendacky
 <thomas.lendacky@....com>, Andrew Cooper <andrew.cooper3@...rix.com>,
 Arjan van de Ven <arjan@...ux.intel.com>, Huang Rui <ray.huang@....com>,
 Juergen Gross <jgross@...e.com>, Dimitri Sivanich
 <dimitri.sivanich@....com>, Sohil Mehta <sohil.mehta@...el.com>, K Prateek
 Nayak <kprateek.nayak@....com>, Kan Liang <kan.liang@...ux.intel.com>,
 Zhang Rui <rui.zhang@...el.com>, "Paul E. McKenney" <paulmck@...nel.org>,
 Feng Tang <feng.tang@...el.com>, Andy Shevchenko <andy@...radead.org>,
 Michael Kelley <mhklinux@...look.com>, "Peter Zijlstra (Intel)"
 <peterz@...radead.org>, Wang Wendy <wendy.wang@...el.com>
Subject: Re: [patch V6a 01/19] x86/cpu: Provide cpuid_read() et al.

On Thu, Feb 15 2024 at 10:49, Andy Shevchenko wrote:

> On Wed, Feb 14, 2024 at 10:29 PM Thomas Gleixner <tglx@...utronixde> wrote:
>>
>> Provide a few helper functions to read CPUID leafs or individual registers
>> into a data structure without requiring unions.
>
> ...
>
>> +#define cpuid_subleaf(leaf, subleaf, regs) {           \
>> +       BUILD_BUG_ON(sizeof(*(regs)) != 16);            \
>> +       __cpuid_read(leaf, subleaf, (u32 *)(regs));     \
>> +}
>> +
>> +#define cpuid_leaf(leaf, regs) {                       \
>> +       BUILD_BUG_ON(sizeof(*(regs)) != 16);            \
>> +       __cpuid_read(leaf, 0, (u32 *)(regs));           \
>> +}
>
> ...
>
>> +#define cpuid_subleaf_reg(leaf, subleaf, regidx, reg) {                \
>> +       BUILD_BUG_ON(sizeof(*(reg)) != 4);                      \
>> +       __cpuid_read_reg(leaf, subleaf, regidx, (u32 *)(reg));  \
>> +}
>> +
>> +#define cpuid_leaf_reg(leaf, regidx, reg) {                    \
>> +       BUILD_BUG_ON(sizeof(*(reg)) != 4);                      \
>> +       __cpuid_read_reg(leaf, 0, regidx, (u32 *)(reg));        \
>> +}
>
> I'm wondering if we can use static_assert() instead of BUILD_BUG_ON()
> in the above macros.

Probably.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ