linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: x86@kernel.org, "Chang S. Bae" <chang.seok.bae@intel.com>,
	Paolo Bonzini <bonzini@gnu.org>,
	Fenghua Yu <fenghua.yu@intel.com>,
	Tony Luck <tony.luck@intel.com>
Subject: [patch 6/7] x86/fpu/xstate: Handle supervisor states in XSTATE permissions
Date: Thu, 24 Mar 2022 14:47:14 +0100 (CET)	[thread overview]
Message-ID: <20220324134623.681768598@linutronix.de> (raw)
In-Reply-To: 20220324134548.432837672@linutronix.de

The size calculation in __xstate_request_perm() fails to take supervisor
states into account because the permission bitmap is only relevant for user
states.

Up to 5.17 this does not matter because there are no supervisor states
supported, but the (re)enabling of ENQCMD makes them available.

Fixes: 7c1ef59145f1 ("x86/cpufeatures: Re-enable ENQCMD")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Paolo Bonzini <bonzini@gnu.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
---
 arch/x86/kernel/fpu/xstate.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1566,6 +1566,9 @@ static int __xstate_request_perm(u64 per
 
 	/* Calculate the resulting kernel state size */
 	mask = permitted | requested;
+	/* Take supervisor states into account on the host */
+	if (!guest)
+		mask |= xfeatures_mask_supervisor();
 	ksize = xstate_calculate_size(mask, compacted);
 
 	/* Calculate the resulting user state size */


  parent reply	other threads:[~2022-03-24 13:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24 13:47 [patch 0/7] x86/fpu: Cure supervisor mode (ENQCMD) fallout Thomas Gleixner
2022-03-24 13:47 ` [patch 1/7] x86/fpu: Remove redundant XCOMP_BV initialization Thomas Gleixner
2022-03-31  9:01   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 2/7] x86/fpu: Remove unused supervisor only offsets Thomas Gleixner
2022-03-31  9:00   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 3/7] x86/fpu/xsave: Initialize offset/size cache early Thomas Gleixner
2022-03-31  9:00   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 4/7] x86/fpu: Cache xfeature flags from CPUID Thomas Gleixner
2022-03-31  9:00   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 5/7] x86/fpu/xsave: Handle compacted offsets correctly with supervisor states Thomas Gleixner
2022-03-31  9:00   ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` Thomas Gleixner [this message]
2022-03-31  9:00   ` [tip: x86/urgent] x86/fpu/xstate: Handle supervisor states in XSTATE permissions tip-bot2 for Thomas Gleixner
2022-03-24 13:47 ` [patch 7/7] x86/fpu/xstate: Consolidate size calculations Thomas Gleixner
2022-03-28 18:43   ` [patch V2 " Thomas Gleixner
2022-03-31  9:00     ` [tip: x86/urgent] " tip-bot2 for Thomas Gleixner
2022-03-28 12:39 ` [patch 0/7] x86/fpu: Cure supervisor mode (ENQCMD) fallout Chang S. Bae
2022-03-28 22:30 ` Fenghua Yu

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=20220324134623.681768598@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=bonzini@gnu.org \
    --cc=chang.seok.bae@intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    --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;
as well as URLs for NNTP newsgroup(s).