[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <00BA183C-4EE6-46AE-AEC8-94B612222373@zytor.com>
Date: Sun, 09 Jun 2024 04:47:51 -0700
From: "H. Peter Anvin" <hpa@...or.com>
To: Borislav Petkov <bp@...en8.de>,
Linus Torvalds <torvalds@...ux-foundation.org>
CC: Ingo Molnar <mingo@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
the arch/x86 maintainers <x86@...nel.org>,
linux-arch <linux-arch@...r.kernel.org>
Subject: Re: [PATCH] x86: add 'runtime constant' infrastructure
On June 9, 2024 4:22:40 AM PDT, Borislav Petkov <bp@...en8.de> wrote:
>On Sat, Jun 08, 2024 at 12:35:05PM -0700, Linus Torvalds wrote:
>> Ingo / Peter / Borislav - I enabled this for 32-bit x86 too, because it
>> was literally trivial (had to remove a "q" from "movq"). I did a
>> test-build and it looks find, but I didn't actually try to boot it.
>
>Will do once you have your final version. I still have an Atom, 32-bit
>only laptop lying around here.
>
>> +#define runtime_const_ptr(sym) ({ \
>> + typeof(sym) __ret; \
>> + asm("mov %1,%0\n1:\n" \
>> + ".pushsection runtime_ptr_" #sym ",\"a\"\n\t" \
>> + ".long 1b - %c2 - .\n\t" \
>> + ".popsection" \
>> + :"=r" (__ret) \
>> + :"i" ((unsigned long)0x0123456789abcdefull), \
>> + "i" (sizeof(long))); \
>> + __ret; })
>
>You might wanna use asm symbolic names for the operands so that it is
>more readable:
>
>#define runtime_const_ptr(sym) ({ \
> typeof(sym) __ret; \
> asm("mov %[constant] ,%[__ret]\n1:\n" \
> ".pushsection runtime_ptr_" #sym ",\"a\"\n\t" \
> ".long 1b - %c[sizeoflong] - .\n\t" \
> ".popsection" \
> : [__ret] "=r" (__ret) \
> : [constant] "i" ((unsigned long)0x0123456789abcdefull), \
> [sizeoflong] "i" (sizeof(long))); \
> __ret; })
>
>For example.
>
>> +// The 'typeof' will create at _least_ a 32-bit type, but
>> +// will happily also take a bigger type and the 'shrl' will
>> +// clear the upper bits
>
>Can we pls use the multiline comments, like you do below in the same
>file.
>
>Otherwise, it looks ok to me and it boots in a guest.
>
>I'll take the final version for a spin on real hw in a couple of days,
>once the review dust settles.
>
>Thx.
>
So the biggest difference versus what I had in progress was that I had the idea of basically doing "ro_after_init" behavior by doing memory references until alternatives are run.
I don't know if that was overthinking the problem...
Powered by blists - more mailing lists