All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Akihiro Suda <suda.kyoto@gmail.com>
Cc: Linux Regressions <regressions@lists.linux.dev>,
	Linux x86 <x86@kernel.org>,
	aruna.ramakrishna@oracle.com, tglx@linutronix.de
Subject: Re: [REGRESSION][BISECTED] x86: kernel 6.12 crashes during get_xsave_addr_user on Apple Virtualization
Date: Fri, 14 Mar 2025 08:07:06 -0700	[thread overview]
Message-ID: <09401d9f-6a5f-40d7-ac3c-e149ef57bcfd@intel.com> (raw)
In-Reply-To: <CAG8fp8S92hXFxMKQtMBkGqk1sWGu7pdHYDowsYbmurt0BGjfww@mail.gmail.com>

On 3/13/25 23:22, Akihiro Suda wrote:
>> The warning here seems to be because the kernel thinks protections keys
>> is enabled (X86_FEATURE_OSPKE) but also thinks XSAVE management of
>> protection keys is _dis_abled. That's a valid hardware configuration,
>> but it's a configuration the kernel never expects to see.
> Right.
> The VM seems missing XSAVE feature 0x200: 'Protection Keys User
> registers', while it has ospke in cpuinfo.
> This configuration seems still weird, as both features seem missing on
> the macOS host.
> (See `physical-macos-host.txt`)

Yeah, so the CPU is enumerating support for protection keys but missing
XSAVE support for managing PKRU. We've envisioned the _reverse_
situation before, but not this specific scenario.

One option is to do nothing. Throw up our hands and declare the VMM so
broken that it's silly to go chasing a fix.

Another way to fix it is to throw this hunk in somewhere:

	if (!fpu_kernel_cfg.max_features & XFEATURE_PKRU) {
		setup_clear_cpu_cap(X86_FEATURE_PKU);
		setup_clear_cpu_cap(X86_FEATURE_OSPKE);
	}

but that's PKU-specific.

There are other features that would have similar issues if the VMM did
something similar for them, like:

        [XFEATURE_PASID]                        = X86_FEATURE_ENQCMD,
        [XFEATURE_CET_USER]                     = X86_FEATURE_SHSTK,

which kinda calls for a more generic solution like:

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 0bab497c94369..a358d45c781ec 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -800,6 +800,10 @@ void __init fpu__init_system_xstate(unsigned int
legacy_size)
 		/* Careful: X86_FEATURE_FPU is 0! */
 		if ((i != XFEATURE_FP && !cid) || !boot_cpu_has(cid))
 			fpu_kernel_cfg.max_features &= ~BIT_ULL(i);
+
+		if (!(fpu_kernel_cfg.max_features & BIT_ULL(i)) &&
+		    boot_cpu_has(cid))
+			setup_clear_cpu_cap(cid);
 	}

 	if (!cpu_feature_enabled(X86_FEATURE_XFD))

Which leads me back to thinking that doing nothing may be the best
approach here.

Let me noodle on it a bit more.

  parent reply	other threads:[~2025-03-14 15:07 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11 14:35 [REGRESSION][BISECTED] x86: kernel 6.12 crashes during get_xsave_addr_user on Apple Virtualization Akihiro Suda
2025-03-11 18:25 ` Aruna Ramakrishna
2025-03-12  5:57   ` Akihiro Suda
2025-03-12  6:18     ` Akihiro Suda
2025-03-12  9:31       ` [PATCH] x86: disable PKU when running " Akihiro Suda
2025-03-12  9:32       ` Akihiro Suda
2025-03-12 10:09       ` [PATCH v2] " Akihiro Suda
2025-03-12 10:21         ` Greg KH
2025-03-13 17:02         ` Ingo Molnar
2025-03-13 23:59           ` Akihiro Suda
2025-03-13 17:11         ` [tip: x86/urgent] x86/pkeys: Disable " tip-bot2 for Akihiro Suda
2025-03-14  6:26         ` [PATCH v2] x86: disable " kernel test robot
2025-03-14  6:26         ` kernel test robot
2025-03-13 17:58 ` [REGRESSION][BISECTED] x86: kernel 6.12 crashes during get_xsave_addr_user " Dave Hansen
2025-03-13 18:01   ` Ingo Molnar
2025-03-14  6:22   ` Akihiro Suda
2025-03-14  8:48     ` [PATCH] x86/pkeys: Disable PKU when XFEATURE_PKRU is missing Akihiro Suda
2025-03-14  8:49       ` kernel test robot
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: x86/urgent] x86/pkeys: Add quirk to disable " tip-bot2 for Akihiro Suda
2025-03-14 15:07     ` Dave Hansen [this message]
2025-03-15 13:09       ` [REGRESSION][BISECTED] x86: kernel 6.12 crashes during get_xsave_addr_user on Apple Virtualization Akihiro Suda
2025-03-15 13:48         ` Borislav Petkov
2025-03-15 15:10           ` Akihiro Suda
2025-03-15 19:02             ` Borislav Petkov
2025-03-15 18:45         ` Dave Hansen

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=09401d9f-6a5f-40d7-ac3c-e149ef57bcfd@intel.com \
    --to=dave.hansen@intel.com \
    --cc=aruna.ramakrishna@oracle.com \
    --cc=regressions@lists.linux.dev \
    --cc=suda.kyoto@gmail.com \
    --cc=tglx@linutronix.de \
    --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.