[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMj1kXHtovutcgJXbsCMA+cmrJgN+K-3Dk5ihuFMzgT9eEe7sA@mail.gmail.com>
Date: Tue, 6 May 2025 21:50:09 +0200
From: Ard Biesheuvel <ardb@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Ard Biesheuvel <ardb+git@...gle.com>, linux-kernel@...r.kernel.org, x86@...nel.org,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [RFC PATCH 3/3] x86/boot: Use alternatives based selector for
5-level paging constants
On Tue, 6 May 2025 at 21:42, Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> On Tue, 6 May 2025 at 12:15, Ard Biesheuvel <ardb@...nel.org> wrote:
> >
> > First of all, that would mean calling into even more C code from the
> > 1:1 mapping of memory,
>
> Not a lot, actually.
>
> When I did the runtime-const stuff, I refused to use the alternatives
> code, because it was called much too late and was much too
> complicated.
>
> So I just did an early fixup by hand - in the place where the variable
> was actually changed. Exactly so that you had *consistency*.
>
> It's literally four lines of code that gets inlined.
>
> See runtime_const_fixup().
>
> And I just checked. Those four lines of code generate seven *instructions*:
>
> .LBB80_4:
> movq $__start_runtime_ptr_dentry_hashtable, %rcx
> .LBB80_6: # =>This Inner Loop Header: Depth=1
> cmpq $__stop_runtime_ptr_dentry_hashtable, %rcx
> jae .LBB80_7
> # %bb.5: # in Loop: Header=BB80_6 Depth=1
> movslq (%rcx), %rdx
> movq %rax, (%rcx,%rdx)
> addq $4, %rcx
> jmp .LBB80_6
>
> that's literally what that
>
> runtime_const_init(ptr, dentry_hashtable);
>
> generates in dcache_init_early() for me.
>
> Seriously, this is *trivial*.
>
This looks trivial, yes - I thought you were talking about the
alternatives patching code, which seems rather complex, and either
pulling it into the startup code or writing an 'early' version of it
seem like a lot of work for little gain.
So yes, let's use this from the startup code, once we figure out which
of these constants are too costly to be expressed as
'pgtable_l5_enabled() ? foo : bar'
Powered by blists - more mailing lists