All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Yu-cheng Yu" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Yu-cheng Yu" <yu-cheng.yu@intel.com>,
	Borislav Petkov <bp@suse.de>,
	Dave Hansen <dave.hansen@linux.intel.com>, x86 <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [tip: x86/fpu] x86/fpu/xstate: Update copy_kernel_to_xregs_err() for supervisor states
Date: Sat, 16 May 2020 15:10:17 -0000	[thread overview]
Message-ID: <158964181711.17951.16653133815092461493.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20200512145444.15483-8-yu-cheng.yu@intel.com>

The following commit has been merged into the x86/fpu branch of tip:

Commit-ID:     c95473e175dd1234b7440daa6eb2670ebf529653
Gitweb:        https://git.kernel.org/tip/c95473e175dd1234b7440daa6eb2670ebf529653
Author:        Yu-cheng Yu <yu-cheng.yu@intel.com>
AuthorDate:    Tue, 12 May 2020 07:54:41 -07:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Thu, 14 May 2020 16:46:43 +02:00

x86/fpu/xstate: Update copy_kernel_to_xregs_err() for supervisor states

The function copy_kernel_to_xregs_err() uses XRSTOR which can work with
standard or compacted format without supervisor xstates. However, when
supervisor xstates are present, XRSTORS must be used. Fix it by using
XRSTORS when supervisor state handling is enabled.

I also considered if there were additional cases where XRSTOR might be
mistakenly called instead of XRSTORS.  There are only three XRSTOR sites
in the kernel:

1. copy_kernel_to_xregs_booting(), already switches between XRSTOR and
   XRSTORS based on X86_FEATURE_XSAVES.

2. copy_user_to_xregs(), which *needs* XRSTOR because it is copying from
   userspace and must never copy supervisor state with XRSTORS.

3. copy_kernel_to_xregs_err() mistakenly used XRSTOR only.  Fix it.

 [ bp: Massage commit message. ]

Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lkml.kernel.org/r/20200512145444.15483-8-yu-cheng.yu@intel.com
---
 arch/x86/include/asm/fpu/internal.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
index a42fcb4..42159f4 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
@@ -400,7 +400,10 @@ static inline int copy_kernel_to_xregs_err(struct xregs_state *xstate, u64 mask)
 	u32 hmask = mask >> 32;
 	int err;
 
-	XSTATE_OP(XRSTOR, xstate, lmask, hmask, err);
+	if (static_cpu_has(X86_FEATURE_XSAVES))
+		XSTATE_OP(XRSTORS, xstate, lmask, hmask, err);
+	else
+		XSTATE_OP(XRSTOR, xstate, lmask, hmask, err);
 
 	return err;
 }

  reply	other threads:[~2020-05-16 15:10 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 14:54 [PATCH v4 00/10] Support XSAVES supervisor states Yu-cheng Yu
2020-05-12 14:54 ` [PATCH v4 01/10] x86/fpu/xstate: Rename validate_xstate_header() to validate_user_xstate_header() Yu-cheng Yu
2020-05-16 15:10   ` [tip: x86/fpu] " tip-bot2 for Fenghua Yu
2020-05-12 14:54 ` [PATCH v4 02/10] x86/fpu/xstate: Define new macros for supervisor and user xstates Yu-cheng Yu
2020-05-16 15:10   ` [tip: x86/fpu] " tip-bot2 for Fenghua Yu
2020-05-12 14:54 ` [PATCH v4 03/10] x86/fpu/xstate: Separate user and supervisor xfeatures mask Yu-cheng Yu
2020-05-16 15:10   ` [tip: x86/fpu] " tip-bot2 for Yu-cheng Yu
2020-05-12 14:54 ` [PATCH v4 04/10] x86/fpu/xstate: Introduce XSAVES supervisor states Yu-cheng Yu
2020-05-16 15:10   ` [tip: x86/fpu] " tip-bot2 for Yu-cheng Yu
2020-05-12 14:54 ` [PATCH v4 05/10] x86/fpu/xstate: Define new functions for clearing fpregs and xstates Yu-cheng Yu
2020-05-16 15:10   ` [tip: x86/fpu] " tip-bot2 for Fenghua Yu
2021-05-24 16:34     ` Andy Lutomirski
2021-05-25 17:44       ` Yu, Yu-cheng
2021-05-25 18:00         ` Thomas Gleixner
2022-11-29 11:19           ` Ivan Zahariev
2022-11-29 18:16             ` Dave Hansen
2022-12-01 12:58               ` Ivan Zahariev
2022-12-01 14:04                 ` Dave Hansen
2020-05-12 14:54 ` [PATCH v4 06/10] x86/fpu/xstate: Update sanitize_restored_xstate() for supervisor xstates Yu-cheng Yu
2020-05-16 15:10   ` [tip: x86/fpu] " tip-bot2 for Yu-cheng Yu
2020-05-12 14:54 ` [PATCH v4 07/10] x86/fpu/xstate: Update copy_kernel_to_xregs_err() for XSAVES supervisor states Yu-cheng Yu
2020-05-16 15:10   ` tip-bot2 for Yu-cheng Yu [this message]
2020-05-12 14:54 ` [PATCH v4 08/10] x86/fpu: Introduce copy_supervisor_to_kernel() Yu-cheng Yu
2020-05-16 15:10   ` [tip: x86/fpu] " tip-bot2 for Yu-cheng Yu
2020-05-12 14:54 ` [PATCH v4 09/10] x86/fpu/xstate: Preserve supervisor states for slow path of __fpu__restore_sig() Yu-cheng Yu
2020-05-16 15:10   ` [tip: x86/fpu] x86/fpu/xstate: Preserve supervisor states for the slow path in __fpu__restore_sig() tip-bot2 for Yu-cheng Yu
2020-05-12 14:54 ` [PATCH v4 10/10] x86/fpu/xstate: Restore supervisor states for signal return Yu-cheng Yu
2020-05-16 15:10   ` [tip: x86/fpu] " tip-bot2 for Yu-cheng 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=158964181711.17951.16653133815092461493.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=bp@suse.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=x86@kernel.org \
    --cc=yu-cheng.yu@intel.com \
    /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.