Skip to content

Commit 4092f62

Browse files
Akihiro Sudaintel-lab-lkp
Akihiro Suda
authored andcommitted
x86: disable PKU when running on Apple Virtualization
OSPKE seems broken on Apple Virtualization. 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 on macOS 13.5.1 running on MacBook Pro 2020 with Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz. Fixes: 70044df ("x86/pkeys: Update PKRU to enable all pkeys before XSAVE") Link: https://lore.kernel.org/regressions/CAG8fp8QvH71Wi_y7b7tgFp7knK38rfrF7rRHh-gFKqeS0gxY6Q@mail.gmail.com/T/#u Link: lima-vm/lima#3334 Signed-off-by: Akihiro Suda <[email protected]>
1 parent 6d536ca commit 4092f62

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

arch/x86/kernel/cpu/common.c

+16
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/pgtable.h>
2727
#include <linux/stackprotector.h>
2828
#include <linux/utsname.h>
29+
#include <linux/acpi.h>
2930

3031
#include <asm/alternative.h>
3132
#include <asm/cmdline.h>
@@ -516,6 +517,21 @@ static bool pku_disabled;
516517

517518
static __always_inline void setup_pku(struct cpuinfo_x86 *c)
518519
{
520+
/*
521+
* OSPKE seems broken on Apple Virtualization.
522+
* https://lore.kernel.org/regressions/CAG8fp8QvH71Wi_y7b7tgFp7knK38rfrF7rRHh-gFKqeS0gxY6Q@mail.gmail.com/T/#u
523+
*
524+
* TODO: conditionally enable pku depending on the DMI BIOS version when Apple
525+
* fixes the issue.
526+
*
527+
* However, this would be still not enough because DMI is missing when vmlinuz
528+
* is directly loaded into VM.
529+
*/
530+
if (!memcmp(acpi_gbl_FADT.header.oem_table_id, "Apple Vz", 8)) {
531+
pr_info("pku: disabled on Apple Virtualization platform (Intel) due to a bug\n");
532+
pku_disabled = true;
533+
}
534+
519535
if (c == &boot_cpu_data) {
520536
if (pku_disabled || !cpu_feature_enabled(X86_FEATURE_PKU))
521537
return;

0 commit comments

Comments
 (0)