mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, Rudi Horn <rudi.horn@oracle.com>,
	Joe Jin <joe.jin@oracle.com>
Subject: Re: [PATCH 2/2] x86/pkeys: Set XINUSE[PKRU] to 1 so that PKRU is XRSTOR'd correctly
Date: Wed, 13 Nov 2024 20:04:51 +0000	[thread overview]
Message-ID: <0522A1EE-211A-45E1-BAAD-002ABF47D0ED@oracle.com> (raw)
In-Reply-To: <5a98b9bf-8004-47e0-82e6-77da49419e0b@intel.com>



> On Nov 13, 2024, at 11:10 AM, Dave Hansen <dave.hansen@intel.com> wrote:
> 
> On 11/13/24 10:14, Aruna Ramakrishna wrote:
>> PKRU value is not XRSTOR'd from the XSAVE area if the corresponding
>> XINUSE[i] bit is 0. When PKRU value is set to 0, it sets XINUSE[PKRU]
>> to 0 on AMD systems, which means the value updated on the sigframe
>> later (after a wrpkru(0)) is ignored.
> 
> I think this is confusing XINUSE and XSTATE_BV.
> 
> XINUSE is really internal to the CPU and is partially exposed in
> xgetbv(1).  But XINUSE is monolithic; it includes user and supervisor state.
> 
> XSTATE_BV is the actual memory location in the XSAVE buffer.
> 
> So I think it's incorrect to say that XRSTOR behavior depends on XINUSE.
> XRSTOR behavior depends on XSTATE_BV.


You’re right; XSTATE_BV[i] is set during XSAVE based on XINUSE[i], and 
XRSTOR restores based on XSTATE_BV. I will reword that (and change the
variable name in update_pkru_in_sigframe()) for v2.

Thanks,
Aruna


      reply	other threads:[~2024-11-13 20:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-13 18:14 [PATCH 1/2] x86/pkeys: Change caller of update_pkru_in_sigframe() Aruna Ramakrishna
2024-11-13 18:14 ` [PATCH 2/2] x86/pkeys: Set XINUSE[PKRU] to 1 so that PKRU is XRSTOR'd correctly Aruna Ramakrishna
2024-11-13 19:10   ` Dave Hansen
2024-11-13 20:04     ` Aruna Ramakrishna [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=0522A1EE-211A-45E1-BAAD-002ABF47D0ED@oracle.com \
    --to=aruna.ramakrishna@oracle.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=joe.jin@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rudi.horn@oracle.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

all inboxes | Powered by JetHome®