[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <360f4fcc-8141-449c-a5fc-cd91182e0899@p183>
Date: Fri, 7 Mar 2025 19:19:52 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: Dave Hansen <dave.hansen@...el.com>
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/4] x86/asm: inline constant inputs in rdpkru(), wrpkru()
On Thu, Mar 06, 2025 at 01:35:01PM -0800, Dave Hansen wrote:
> On 3/6/25 13:07, Alexey Dobriyan wrote:
> > static inline void wrpkru(u32 pkru)
> > {
> > - u32 ecx = 0, edx = 0;
> > -
> > /*
> > * "wrpkru" instruction. Loads contents in EAX to PKRU,
> > * requires that ecx = edx = 0.
> > */
> > asm volatile(".byte 0x0f,0x01,0xef\n\t"
> > - : : "a" (pkru), "c"(ecx), "d"(edx));
> > + : : "a" (pkru), "c" (0), "d" (0));
> > }
>
> Hey Alexey,
>
> I appreciate the patch. But I do like how it's written currently. I
> honestly kinda wish it went even further and did:
>
> u32 eax = pkru;
I _think_ you can write "eax" (pkru) .
I don't like the comment either. It just reiterates the SDM.
Trailing \n\t too -- they don't do anything in one-liners.
The function is basically:
// wrpkru
asm volatile (
".byte 0x0f,0x01,0xef"
:
: "a" (pkru), "d" (0) , "c" (0)
);
Powered by blists - more mailing lists