From: Ingo Molnar <mingo@kernel.org>
To: Ard Biesheuvel <ardb+git@google.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
Ard Biesheuvel <ardb@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [RFC PATCH v2 4/6] x86/boot: Set 5-level paging CPU cap before entering C code
Date: Wed, 14 May 2025 10:15:35 +0200 [thread overview]
Message-ID: <aCRRJ_ahL2IRXxcj@gmail.com> (raw)
In-Reply-To: <20250513111157.717727-12-ardb+git@google.com>
* Ard Biesheuvel <ardb+git@google.com> wrote:
> diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
> index ad4ea6fb3b6c..6259b474073b 100644
> --- a/arch/x86/kernel/asm-offsets.c
> +++ b/arch/x86/kernel/asm-offsets.c
> @@ -33,6 +33,14 @@
>
> static void __used common(void)
> {
> + OFFSET(CPUINFO_x86, cpuinfo_x86, x86);
> + OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor);
> + OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model);
> + OFFSET(CPUINFO_x86_stepping, cpuinfo_x86, x86_stepping);
> + OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level);
> + OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability);
> + OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id);
> +
> BLANK();
> OFFSET(TASK_threadsp, task_struct, thread.sp);
> #ifdef CONFIG_STACKPROTECTOR
> diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
> index 2b411cd00a4e..e0a292db97b2 100644
> --- a/arch/x86/kernel/asm-offsets_32.c
> +++ b/arch/x86/kernel/asm-offsets_32.c
> @@ -12,15 +12,6 @@ void foo(void);
>
> void foo(void)
> {
> - OFFSET(CPUINFO_x86, cpuinfo_x86, x86);
> - OFFSET(CPUINFO_x86_vendor, cpuinfo_x86, x86_vendor);
> - OFFSET(CPUINFO_x86_model, cpuinfo_x86, x86_model);
> - OFFSET(CPUINFO_x86_stepping, cpuinfo_x86, x86_stepping);
> - OFFSET(CPUINFO_cpuid_level, cpuinfo_x86, cpuid_level);
> - OFFSET(CPUINFO_x86_capability, cpuinfo_x86, x86_capability);
> - OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id);
> - BLANK();
> -
This is needed so that we can run (well, build) the setup_force_cpu_cap
macro on x86-64 too, right?
Could you please split out this portion into a separate patch, to
simplify the more dangerous half of the patch?
> - if (IS_ENABLED(CONFIG_X86_5LEVEL) && (native_read_cr4() & X86_CR4_LA57))
> - setup_force_cpu_cap(X86_FEATURE_5LEVEL_PAGING);
> +#ifdef CONFIG_X86_5LEVEL
> + /*
> + * Set the X86_FEATURE_5LEVEL_PAGING capability before calling into the
> + * C code, so that it is guaranteed to have a consistent view of any
> + * global pseudo-constants that are derived from pgtable_l5_enabled().
> + */
> + mov %cr4, %rax
> + btl $X86_CR4_LA57_BIT, %eax
> + jnc 0f
> +
> + setup_force_cpu_cap X86_FEATURE_5LEVEL_PAGING
> +0:
> +#endif
Nice!
Thanks,
Ingo
next prev parent reply other threads:[~2025-05-14 8:15 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-13 11:11 [RFC PATCH v2 0/6] x86: Robustify pgtable_l5_enabled() Ard Biesheuvel
2025-05-13 11:11 ` [RFC PATCH v2 1/6] x86/boot: Defer initialization of VM space related global variables Ard Biesheuvel
2025-05-14 8:15 ` [tip: x86/core] " tip-bot2 for Ard Biesheuvel
2025-05-13 11:12 ` [RFC PATCH v2 2/6] x86/cpu: Use a new feature flag for 5 level paging Ard Biesheuvel
2025-05-13 19:49 ` Linus Torvalds
2025-05-14 7:32 ` Kirill A. Shutemov
2025-05-14 8:04 ` Ingo Molnar
2025-05-14 8:14 ` Ard Biesheuvel
2025-05-14 8:21 ` Kirill A. Shutemov
2025-05-14 8:31 ` Ingo Molnar
2025-05-14 8:39 ` Ingo Molnar
2025-05-14 8:19 ` Kirill A. Shutemov
2025-05-14 8:33 ` Ingo Molnar
2025-05-13 11:12 ` [RFC PATCH v2 3/6] x86/cpu: Allow caps to be set arbitrarily early Ard Biesheuvel
2025-05-13 18:37 ` Brian Gerst
2025-05-14 8:17 ` Ingo Molnar
2025-05-14 9:49 ` Ard Biesheuvel
2025-05-21 13:22 ` Ard Biesheuvel
2025-05-13 11:12 ` [RFC PATCH v2 4/6] x86/boot: Set 5-level paging CPU cap before entering C code Ard Biesheuvel
2025-05-14 8:15 ` Ingo Molnar [this message]
2025-05-14 8:18 ` Ard Biesheuvel
2025-05-14 8:37 ` Ingo Molnar
2025-05-14 8:40 ` Ard Biesheuvel
2025-05-13 11:12 ` [RFC PATCH v2 5/6] x86/boot: Drop the early variant of pgtable_l5_enabled() Ard Biesheuvel
2025-05-13 11:12 ` [RFC PATCH v2 6/6] x86/boot: Drop 5-level paging related variables and early updates Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aCRRJ_ahL2IRXxcj@gmail.com \
--to=mingo@kernel.org \
--cc=ardb+git@google.com \
--cc=ardb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.