From: "tip-bot2 for Akihiro Suda" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>,
Ingo Molnar <mingo@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: x86/urgent] x86/pkeys: Add quirk to disable PKU when XFEATURE_PKRU is missing
Date: Wed, 19 Mar 2025 22:11:52 -0000 [thread overview]
Message-ID: <174242231316.14745.5519157342087381003.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250314084818.2826-1-akihiro.suda.cz@hco.ntt.co.jp>
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: 86049b4cf7a41cc5b33a556fc25772cc325f474f
Gitweb: https://git.kernel.org/tip/86049b4cf7a41cc5b33a556fc25772cc325f474f
Author: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
AuthorDate: Fri, 14 Mar 2025 17:48:18 +09:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 19 Mar 2025 22:37:32 +01:00
x86/pkeys: Add quirk to disable PKU when XFEATURE_PKRU is missing
Even when X86_FEATURE_PKU and X86_FEATURE_OSPKE are available,
XFEATURE_PKRU can be missing on some popular VM environments
such as Apple Virtualization.
In such a case, pkeys has to be disabled to avoid a boot time hang:
WARNING: CPU: 0 PID: 1 at arch/x86/kernel/fpu/xstate.c:1003 get_xsave_addr_user+0x28/0x40
(...)
Call Trace:
<TASK>
? get_xsave_addr_user+0x28/0x40
? __warn.cold+0x8e/0xea
? get_xsave_addr_user+0x28/0x40
? report_bug+0xff/0x140
? handle_bug+0x3b/0x70
? exc_invalid_op+0x17/0x70
? asm_exc_invalid_op+0x1a/0x20
? get_xsave_addr_user+0x28/0x40
copy_fpstate_to_sigframe+0x1be/0x380
? __put_user_8+0x11/0x20
get_sigframe+0xf1/0x280
x64_setup_rt_frame+0x67/0x2c0
arch_do_signal_or_restart+0x1b3/0x240
syscall_exit_to_user_mode+0xb0/0x130
do_syscall_64+0xab/0x1a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Tested with MacOS 13.5.2 running on MacBook Pro 2020 with
Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz.
[ mingo: Issue a boot time warning to give VMs a chance to fix this. ]
Fixes: 70044df250d0 ("x86/pkeys: Update PKRU to enable all pkeys before XSAVE")
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250314084818.2826-1-akihiro.suda.cz@hco.ntt.co.jp
---
arch/x86/kernel/cpu/common.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 7cce91b..4e6cf0b 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -519,6 +519,17 @@ static __always_inline void setup_pku(struct cpuinfo_x86 *c)
if (c == &boot_cpu_data) {
if (pku_disabled || !cpu_feature_enabled(X86_FEATURE_PKU))
return;
+ if (!cpu_has_xfeatures(XFEATURE_PKRU, NULL)) {
+ /*
+ * Missing XFEATURE_PKRU is not really a valid
+ * configuration at this point, but apparently
+ * Apple Virtualization is affected by this,
+ * so return with a FW warning instead of crashing
+ * the bootup:
+ */
+ WARN_ONCE(1, FW_BUG "Invalid XFEATURE_PKRU configuration.\n");
+ return;
+ }
/*
* Setting CR4.PKE will cause the X86_FEATURE_OSPKE cpuid
* bit to be set. Enforce it.
prev parent reply other threads:[~2025-03-19 22:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAG8fp8S92hXFxMKQtMBkGqk1sWGu7pdHYDowsYbmurt0BGjfww@mail.gmail.com>
2025-03-14 8:48 ` [PATCH] x86/pkeys: Disable " Akihiro Suda
2025-03-19 21:00 ` [tip: x86/urgent] x86/pkeys: Add quirk to disable " tip-bot2 for Akihiro Suda
2025-03-19 21:39 ` [PATCH] x86/pkeys: Disable " Ingo Molnar
2025-03-20 14:21 ` Akihiro Suda
2025-03-20 15:11 ` Borislav Petkov
2025-03-20 19:46 ` Ingo Molnar
2025-03-19 22:11 ` tip-bot2 for Akihiro Suda [this message]
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=174242231316.14745.5519157342087381003.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=akihiro.suda.cz@hco.ntt.co.jp \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®