public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>, <tglx@linutronix.de>,
	<mingo@redhat.com>, <bp@alien8.de>, <dave.hansen@linux.intel.com>,
	<x86@kernel.org>, <hpa@zytor.com>, <aruna.ramakrishna@oracle.com>,
	<pbonzini@redhat.com>, <levymitchell0@gmail.com>,
	<attofari@amazon.de>, <linux-kernel@vger.kernel.org>,
	<CobeChen@zhaoxin.com>, <TimGuo@zhaoxin.com>,
	<LeoLiu-oc@zhaoxin.com>, Lyle Li <LyleLi@zhaoxin.com>
Subject: Re: [PATCH] x86/fpu: Fix the os panic issue caused by the XGETBV instruction
Date: Fri, 17 Jan 2025 15:24:25 -0800	[thread overview]
Message-ID: <331a04dc-60df-47ad-8ba6-53a605d9f472@intel.com> (raw)
In-Reply-To: <Z4rVORZR2mBoRqjl@google.com>

On 1/17/2025 2:10 PM, Sean Christopherson wrote:
> 
> I don't see anything in the SDM that suggests this is a misconfigured CPU.  Intel
> might not have plans to ship such CPUs, but AFAICT it's not a violation of the
> architecture as defined in the SDM.
> 
> The SDM even explicitly says that protection keys can exist and be used without
> PKU state being supported in XSAVE at all, at which point assuming the existence
> of XGETBV1 is rather nonsensical.
> 
>    XCR0[9] is associated with PKRU state (see Section 13.5.7). Software can use
>    the XSAVE feature set to manage PKRU state only if XCR0[9] = 1. The value of
>    XCR0[9] in no way determines whether software can use protection keys or execute
>    other instructions that access PKRU state (these instructions can be executed even
>    if XCR0[9] = 0).
> 
>    XCR0[9] is 0 coming out of RESET. As noted in Section 13.2, a processor allows
>    software to set XCR0[9] if and only if CPUID.(EAX=0DH,ECX=0):EAX[9] = 1.

Yeah, right.

Furthermore, looking further at the update_pkru_in_sigframe() change, I 
doubt the xfeatures_in_use() invocation is really necessary.

The change seems to always write the PKRU state in the signal frame and 
set the PKRU bit. Since XSAVE has already been performed, the latter 
could be something like this:

	__get_user(xstate_bv, &buf->header.xfeatures);
	xstate_bv |= XFEATURE_MASK_PKRU;
	__put_user(xstate_bv, &buf->header.xfeatures);

A similar code is already there for FP/SSE bits in the 
save_xstate_epilog() function:
	https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/fpu/signal.c#n139

Thanks,
Chang



  reply	other threads:[~2025-01-17 23:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-02  7:54 [PATCH] x86/fpu: Fix the os panic issue caused by the XGETBV instruction Tony W Wang-oc
2025-01-15 18:39 ` Chang S. Bae
2025-01-17 22:10   ` Sean Christopherson
2025-01-17 23:24     ` Chang S. Bae [this message]
2025-01-18  3:13     ` H. Peter Anvin

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=331a04dc-60df-47ad-8ba6-53a605d9f472@intel.com \
    --to=chang.seok.bae@intel.com \
    --cc=CobeChen@zhaoxin.com \
    --cc=LeoLiu-oc@zhaoxin.com \
    --cc=LyleLi@zhaoxin.com \
    --cc=TimGuo@zhaoxin.com \
    --cc=TonyWWang-oc@zhaoxin.com \
    --cc=aruna.ramakrishna@oracle.com \
    --cc=attofari@amazon.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=levymitchell0@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox