[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z9m1rtmlk1PxGIQA@gmail.com>
Date: Tue, 18 Mar 2025 19:04:30 +0100
From: Ingo Molnar <mingo@...nel.org>
To: "H. Peter Anvin" <hpa@...or.com>
Cc: linux-kernel@...r.kernel.org, Juergen Gross <jgross@...e.com>,
Stefano Stabellini <sstabellini@...nel.org>,
"Ahmed S . Darwish" <darwi@...utronix.de>,
Andrew Cooper <andrew.cooper3@...rix.com>,
John Ogness <john.ogness@...utronix.de>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>,
Borislav Petkov <bp@...en8.de>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH 0/5] x86/cpu: Introduce <asm/cpuid/types.h> and
<asm/cpuid/api.h> and clean them up
* H. Peter Anvin <hpa@...or.com> wrote:
> It would be nice to get rid of the bleacherous use of *eax and *ecx
> as input-output operands. The use of four separate pointers is just
> barely tolerable because the compiler can remove them when the asm is
> inlined.
So we have a nice structure of:
struct cpuid_regs {
u32 eax;
u32 ebx;
u32 ecx;
u32 edx;
};
So instead of:
static inline void cpuid_count(unsigned int op, int count,
unsigned int *eax, unsigned int *ebx,
unsigned int *ecx, unsigned int *edx)
... we could have:
static inline void cpuid_count(unsigned int op, int count, struct cpuid_regs *cregs)
or so?
plus we could implement the main CPUID call as:
static inline void native_cpuid(struct cpuid_regs *cregs)
{
/* ecx is often an input as well as an output. */
asm volatile("cpuid"
: "=a" (cregs->eax),
"=b" (cregs->ebx),
"=c" (cregs->ecx),
"=d" (cregs->edx)
: "0" (cregs->eax), "2" (cregs->ecx)
: "memory");
}
and thus we give the asm() statement only a single pointer in essence,
'cregs'?
Or do you mean something else?
Thanks,
Ingo
Powered by blists - more mailing lists