All of lore.kernel.org
 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>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Arjan van de Ven <arjan@linux.intel.com>,
	kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: [patch 6/8] x86/fpu: Mop up xfeatures_mask_uabi()
Date: Fri, 15 Oct 2021 01:09:37 +0200 (CEST)	[thread overview]
Message-ID: <20211014230739.408879849@linutronix.de> (raw)
In-Reply-To: 20211014225711.615197738@linutronix.de

Use the new fpu_user_cfg to retrieve the information instead of
xfeatures_mask_uabi() which will be not longer correct when dynamically
enabled features become available.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/fpu/xstate.h |    9 ---------
 arch/x86/kernel/fpu/core.c        |    4 ++--
 arch/x86/kernel/fpu/signal.c      |    2 +-
 arch/x86/kernel/fpu/xstate.c      |    6 +++---
 4 files changed, 6 insertions(+), 15 deletions(-)

--- a/arch/x86/include/asm/fpu/xstate.h
+++ b/arch/x86/include/asm/fpu/xstate.h
@@ -84,15 +84,6 @@ static inline u64 xfeatures_mask_supervi
 }
 
 /*
- * The xfeatures which are enabled in XCR0 and expected to be in ptrace
- * buffers and signal frames.
- */
-static inline u64 xfeatures_mask_uabi(void)
-{
-	return fpu_kernel_cfg.max_features & XFEATURE_MASK_USER_SUPPORTED;
-}
-
-/*
  * The xfeatures which are restored by the kernel when returning to user
  * mode. This is not necessarily the same as xfeatures_mask_uabi() as the
  * kernel does not manage all XCR0 enabled features via xsave/xrstor as
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -237,7 +237,7 @@ int fpu_copy_kvm_uabi_to_fpstate(struct
 	}
 
 	/* Ensure that XCOMP_BV is set up for XSAVES */
-	xstate_init_xcomp_bv(&kstate->regs.xsave, xfeatures_mask_uabi());
+	xstate_init_xcomp_bv(&kstate->regs.xsave, fpu_user_cfg.max_features);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(fpu_copy_kvm_uabi_to_fpstate);
@@ -333,7 +333,7 @@ void fpstate_init_user(struct fpstate *f
 		return;
 	}
 
-	xstate_init_xcomp_bv(&fpstate->regs.xsave, xfeatures_mask_uabi());
+	xstate_init_xcomp_bv(&fpstate->regs.xsave, fpu_user_cfg.max_features);
 
 	if (cpu_feature_enabled(X86_FEATURE_FXSR))
 		fpstate_init_fxstate(fpstate);
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -530,7 +530,7 @@ void __init fpu__init_prepare_fx_sw_fram
 
 	fx_sw_reserved.magic1 = FP_XSTATE_MAGIC1;
 	fx_sw_reserved.extended_size = size;
-	fx_sw_reserved.xfeatures = xfeatures_mask_uabi();
+	fx_sw_reserved.xfeatures = fpu_user_cfg.default_features;
 	fx_sw_reserved.xstate_size = fpu_user_cfg.default_size;
 
 	if (IS_ENABLED(CONFIG_IA32_EMULATION) ||
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -770,7 +770,7 @@ void __init fpu__init_system_xstate(unsi
 	cpuid_count(XSTATE_CPUID, 1, &eax, &ebx, &ecx, &edx);
 	fpu_kernel_cfg.max_features |= ecx + ((u64)edx << 32);
 
-	if ((xfeatures_mask_uabi() & XFEATURE_MASK_FPSSE) != XFEATURE_MASK_FPSSE) {
+	if ((fpu_kernel_cfg.max_features & XFEATURE_MASK_FPSSE) != XFEATURE_MASK_FPSSE) {
 		/*
 		 * This indicates that something really unexpected happened
 		 * with the enumeration.  Disable XSAVE and try to continue
@@ -815,7 +815,7 @@ void __init fpu__init_system_xstate(unsi
 	 * supervisor xstates:
 	 */
 	update_regset_xstate_info(fpu_user_cfg.max_size,
-				  xfeatures_mask_uabi());
+				  fpu_user_cfg.max_features);
 
 	fpu__init_prepare_fx_sw_frame();
 	setup_init_fpu_buf();
@@ -853,7 +853,7 @@ void fpu__resume_cpu(void)
 	 * Restore XCR0 on xsave capable CPUs:
 	 */
 	if (cpu_feature_enabled(X86_FEATURE_XSAVE))
-		xsetbv(XCR_XFEATURE_ENABLED_MASK, xfeatures_mask_uabi());
+		xsetbv(XCR_XFEATURE_ENABLED_MASK, fpu_user_cfg.max_features);
 
 	/*
 	 * Restore IA32_XSS. The same CPUID bit enumerates support


  parent reply	other threads:[~2021-10-14 23:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 23:09 [patch 0/8] x86/fpu: Consolidate the size and feature information (part 3) Thomas Gleixner
2021-10-14 23:09 ` [patch 1/8] x86/fpu: Provide struct fpu_config Thomas Gleixner
2021-10-22 19:56   ` [tip: x86/fpu] " tip-bot2 for Thomas Gleixner
2021-10-14 23:09 ` [patch 2/8] x86/fpu: Cleanup fpu__init_system_xstate_size_legacy() Thomas Gleixner
2021-10-22 19:56   ` [tip: x86/fpu] " tip-bot2 for Thomas Gleixner
2021-10-14 23:09 ` [patch 3/8] x86/fpu/xstate: Cleanup size calculations Thomas Gleixner
2021-10-22 19:56   ` [tip: x86/fpu] " tip-bot2 for Thomas Gleixner
2021-10-14 23:09 ` [patch 4/8] x86/fpu: Move xstate size to fpu_*_cfg Thomas Gleixner
2021-10-22 19:56   ` [tip: x86/fpu] " tip-bot2 for Thomas Gleixner
2021-10-14 23:09 ` [patch 5/8] x86/fpu: Move xstate feature masks " Thomas Gleixner
2021-10-22 19:56   ` [tip: x86/fpu] " tip-bot2 for Thomas Gleixner
2021-10-14 23:09 ` Thomas Gleixner [this message]
2021-10-22 19:56   ` [tip: x86/fpu] x86/fpu: Mop up xfeatures_mask_uabi() tip-bot2 for Thomas Gleixner
2021-10-14 23:09 ` [patch 7/8] x86/fpu: Rework restore_regs_from_fpstate() Thomas Gleixner
2021-10-22 19:56   ` [tip: x86/fpu] " tip-bot2 for Thomas Gleixner
2021-10-14 23:09 ` [patch 8/8] x86/fpu/xstate: Move remaining xfeature helpers to core Thomas Gleixner
2021-10-22 19:56   ` [tip: x86/fpu] " tip-bot2 for Thomas Gleixner

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=20211014230739.408879849@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=arjan@linux.intel.com \
    --cc=chang.seok.bae@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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 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.