* [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
@ 2017-01-23 22:54 Yu-cheng Yu
2017-01-24 8:09 ` Ingo Molnar
2017-01-24 8:46 ` [tip:x86/urgent] " tip-bot for Yu-cheng Yu
0 siblings, 2 replies; 9+ messages in thread
From: Yu-cheng Yu @ 2017-01-23 22:54 UTC (permalink / raw)
To: x86, H. Peter Anvin, Thomas Gleixner, Ingo Molnar, linux-kernel,
Andy Lutomirski, Borislav Petkov, Dave Hansen, Fenghua Yu,
Joakim Tjernlund, Ravi V. Shankar, haokexin
Cc: Yu-cheng Yu
The compacted-format XSAVES area is determined at boot time and
never changed after. The field xsave.header.xcomp_bv indicates
which components are in the fixed XSAVES format.
In fpstate_init() we did not set xcomp_bv to reflect the XSAVES
format since at the time there is no valid data.
However, after we do copy_init_fpstate_to_fpregs() in fpu__clear(),
as in commit: b22cbe404a9cc3c7949e380fa1861e31934c8978, and when
__fpu_restore_sig() does fpu__restore() for a COMPAT-mode app,
a #GP occurs. This can be easily triggered by doing valgrind on
a COMPAT-mode "Hello World," as reported by Joakim Tjernlund and
others:
https://bugzilla.kernel.org/show_bug.cgi?id=190061
Fix it by setting xcomp_bv correctly.
Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Reported-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
---
arch/x86/kernel/fpu/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index c289e2f..e540dc1 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -9,6 +9,7 @@
#include <asm/fpu/regset.h>
#include <asm/fpu/signal.h>
#include <asm/fpu/types.h>
+#include <asm/fpu/xstate.h>
#include <asm/traps.h>
#include <linux/hardirq.h>
@@ -235,7 +236,8 @@ void fpstate_init(union fpregs_state *state)
* it will #GP. Make sure it is replaced after the memset().
*/
if (static_cpu_has(X86_FEATURE_XSAVES))
- state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT;
+ state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT |
+ xfeatures_mask;
if (static_cpu_has(X86_FEATURE_FXSR))
fpstate_init_fxstate(&state->fxsave);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
2017-01-23 22:54 [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header Yu-cheng Yu
@ 2017-01-24 8:09 ` Ingo Molnar
2017-02-02 20:18 ` Joakim Tjernlund
2017-01-24 8:46 ` [tip:x86/urgent] " tip-bot for Yu-cheng Yu
1 sibling, 1 reply; 9+ messages in thread
From: Ingo Molnar @ 2017-01-24 8:09 UTC (permalink / raw)
To: Yu-cheng Yu
Cc: x86, H. Peter Anvin, Thomas Gleixner, Ingo Molnar, linux-kernel,
Andy Lutomirski, Borislav Petkov, Dave Hansen, Fenghua Yu,
Joakim Tjernlund, Ravi V. Shankar, haokexin
* Yu-cheng Yu <yu-cheng.yu@intel.com> wrote:
> The compacted-format XSAVES area is determined at boot time and
> never changed after. The field xsave.header.xcomp_bv indicates
> which components are in the fixed XSAVES format.
>
> In fpstate_init() we did not set xcomp_bv to reflect the XSAVES
> format since at the time there is no valid data.
>
> However, after we do copy_init_fpstate_to_fpregs() in fpu__clear(),
> as in commit: b22cbe404a9cc3c7949e380fa1861e31934c8978, and when
> __fpu_restore_sig() does fpu__restore() for a COMPAT-mode app,
> a #GP occurs. This can be easily triggered by doing valgrind on
> a COMPAT-mode "Hello World," as reported by Joakim Tjernlund and
> others:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=190061
>
> Fix it by setting xcomp_bv correctly.
>
> Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
> Reported-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
> ---
> arch/x86/kernel/fpu/core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
> index c289e2f..e540dc1 100644
> --- a/arch/x86/kernel/fpu/core.c
> +++ b/arch/x86/kernel/fpu/core.c
> @@ -9,6 +9,7 @@
> #include <asm/fpu/regset.h>
> #include <asm/fpu/signal.h>
> #include <asm/fpu/types.h>
> +#include <asm/fpu/xstate.h>
> #include <asm/traps.h>
>
> #include <linux/hardirq.h>
> @@ -235,7 +236,8 @@ void fpstate_init(union fpregs_state *state)
> * it will #GP. Make sure it is replaced after the memset().
> */
> if (static_cpu_has(X86_FEATURE_XSAVES))
> - state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT;
> + state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT |
> + xfeatures_mask;
Ok, I have applied this - but it would be cleaner to go one step further and add a
fpstate_init_xstate() method that does this in xstate.c and hides the details from
arch/x86/kernel/fpu/core.c.
Similar to how the FX-state initialization is done today:
> if (static_cpu_has(X86_FEATURE_FXSR))
> fpstate_init_fxstate(&state->fxsave);
Thanks,
Ingo
^ permalink raw reply [flat|nested] 9+ messages in thread
* [tip:x86/urgent] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
2017-01-23 22:54 [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header Yu-cheng Yu
2017-01-24 8:09 ` Ingo Molnar
@ 2017-01-24 8:46 ` tip-bot for Yu-cheng Yu
2017-02-14 21:26 ` Yu-cheng Yu
1 sibling, 1 reply; 9+ messages in thread
From: tip-bot for Yu-cheng Yu @ 2017-01-24 8:46 UTC (permalink / raw)
To: linux-tip-commits
Cc: dave.hansen, tglx, haokexin, Joakim.Tjernlund, peterz, mingo,
ravi.v.shankar, linux-kernel, torvalds, hpa, fenghua.yu, luto,
bp, yu-cheng.yu
Commit-ID: dffba9a31c7769be3231c420d4b364c92ba3f1ac
Gitweb: http://git.kernel.org/tip/dffba9a31c7769be3231c420d4b364c92ba3f1ac
Author: Yu-cheng Yu <yu-cheng.yu@intel.com>
AuthorDate: Mon, 23 Jan 2017 14:54:44 -0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 24 Jan 2017 09:04:48 +0100
x86/fpu/xstate: Fix xcomp_bv in XSAVES header
The compacted-format XSAVES area is determined at boot time and
never changed after. The field xsave.header.xcomp_bv indicates
which components are in the fixed XSAVES format.
In fpstate_init() we did not set xcomp_bv to reflect the XSAVES
format since at the time there is no valid data.
However, after we do copy_init_fpstate_to_fpregs() in fpu__clear(),
as in commit:
b22cbe404a9c x86/fpu: Fix invalid FPU ptrace state after execve()
and when __fpu_restore_sig() does fpu__restore() for a COMPAT-mode
app, a #GP occurs. This can be easily triggered by doing valgrind on
a COMPAT-mode "Hello World," as reported by Joakim Tjernlund and
others:
https://bugzilla.kernel.org/show_bug.cgi?id=190061
Fix it by setting xcomp_bv correctly.
This patch also moves the xcomp_bv initialization to the proper
place, which was in copyin_to_xsaves() as of:
4c833368f0bf x86/fpu: Set the xcomp_bv when we fake up a XSAVES area
which fixed the bug too, but it's more efficient and cleaner to
initialize things once per boot, not for every signal handling
operation.
Reported-by: Kevin Hao <haokexin@gmail.com>
Reported-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi V. Shankar <ravi.v.shankar@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: haokexin@gmail.com
Link: http://lkml.kernel.org/r/1485212084-4418-1-git-send-email-yu-cheng.yu@intel.com
[ Combined it with 4c833368f0bf. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/fpu/core.c | 4 +++-
arch/x86/kernel/fpu/xstate.c | 1 -
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index e4e97a5..de72344 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -9,6 +9,7 @@
#include <asm/fpu/regset.h>
#include <asm/fpu/signal.h>
#include <asm/fpu/types.h>
+#include <asm/fpu/xstate.h>
#include <asm/traps.h>
#include <linux/hardirq.h>
@@ -183,7 +184,8 @@ void fpstate_init(union fpregs_state *state)
* it will #GP. Make sure it is replaced after the memset().
*/
if (static_cpu_has(X86_FEATURE_XSAVES))
- state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT;
+ state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT |
+ xfeatures_mask;
if (static_cpu_has(X86_FEATURE_FXSR))
fpstate_init_fxstate(&state->fxsave);
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index e287b90..1d77704 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1070,7 +1070,6 @@ int copyin_to_xsaves(const void *kbuf, const void __user *ubuf,
* Add back in the features that came in from userspace:
*/
xsave->header.xfeatures |= xfeatures;
- xsave->header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT | xsave->header.xfeatures;
return 0;
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
2017-01-24 8:09 ` Ingo Molnar
@ 2017-02-02 20:18 ` Joakim Tjernlund
0 siblings, 0 replies; 9+ messages in thread
From: Joakim Tjernlund @ 2017-02-02 20:18 UTC (permalink / raw)
To: mingo, yu-cheng.yu
Cc: linux-kernel, bp, tglx, dave.hansen, fenghua.yu, x86, hpa, mingo,
luto, ravi.v.shankar, haokexin
On Tue, 2017-01-24 at 09:09 +0100, Ingo Molnar wrote:
> * Yu-cheng Yu <yu-cheng.yu@intel.com> wrote:
This needs to go to stable too, 4.8 and 4.9
Jocke
>
> > The compacted-format XSAVES area is determined at boot time and
> > never changed after. The field xsave.header.xcomp_bv indicates
> > which components are in the fixed XSAVES format.
> >
> > In fpstate_init() we did not set xcomp_bv to reflect the XSAVES
> > format since at the time there is no valid data.
> >
> > However, after we do copy_init_fpstate_to_fpregs() in fpu__clear(),
> > as in commit: b22cbe404a9cc3c7949e380fa1861e31934c8978, and when
> > __fpu_restore_sig() does fpu__restore() for a COMPAT-mode app,
> > a #GP occurs. This can be easily triggered by doing valgrind on
> > a COMPAT-mode "Hello World," as reported by Joakim Tjernlund and
> > others:
> >
> > https://bugzilla.kernel.org/show_bug.cgi?id=190061
> >
> > Fix it by setting xcomp_bv correctly.
> >
> > Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
> > Reported-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
> > ---
> > arch/x86/kernel/fpu/core.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
> > index c289e2f..e540dc1 100644
> > --- a/arch/x86/kernel/fpu/core.c
> > +++ b/arch/x86/kernel/fpu/core.c
> > @@ -9,6 +9,7 @@
> > #include <asm/fpu/regset.h>
> > #include <asm/fpu/signal.h>
> > #include <asm/fpu/types.h>
> > +#include <asm/fpu/xstate.h>
> > #include <asm/traps.h>
> >
> > #include <linux/hardirq.h>
> > @@ -235,7 +236,8 @@ void fpstate_init(union fpregs_state *state)
> > * it will #GP. Make sure it is replaced after the memset().
> > */
> > if (static_cpu_has(X86_FEATURE_XSAVES))
> > - state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT;
> > + state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT |
> > + xfeatures_mask;
>
> Ok, I have applied this - but it would be cleaner to go one step further and add a
> fpstate_init_xstate() method that does this in xstate.c and hides the details from
> arch/x86/kernel/fpu/core.c.
>
> Similar to how the FX-state initialization is done today:
>
> > if (static_cpu_has(X86_FEATURE_FXSR))
> > fpstate_init_fxstate(&state->fxsave);
>
> Thanks,
>
> Ingo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [tip:x86/urgent] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
2017-01-24 8:46 ` [tip:x86/urgent] " tip-bot for Yu-cheng Yu
@ 2017-02-14 21:26 ` Yu-cheng Yu
2017-02-14 22:53 ` Greg Kroah-Hartman
2017-02-16 17:51 ` Greg Kroah-Hartman
0 siblings, 2 replies; 9+ messages in thread
From: Yu-cheng Yu @ 2017-02-14 21:26 UTC (permalink / raw)
To: dave.hansen, linux-kernel, ravi.v.shankar, torvalds, haokexin,
tglx, Joakim.Tjernlund, mingo, peterz, hpa, fenghua.yu, luto, bp,
Greg Kroah-Hartman, stable
On Tue, Jan 24, 2017 at 12:46:17AM -0800, tip-bot for Yu-cheng Yu wrote:
> Commit-ID: dffba9a31c7769be3231c420d4b364c92ba3f1ac
> Gitweb: http://git.kernel.org/tip/dffba9a31c7769be3231c420d4b364c92ba3f1ac
> Author: Yu-cheng Yu <yu-cheng.yu@intel.com>
> AuthorDate: Mon, 23 Jan 2017 14:54:44 -0800
> Committer: Ingo Molnar <mingo@kernel.org>
> CommitDate: Tue, 24 Jan 2017 09:04:48 +0100
>
> x86/fpu/xstate: Fix xcomp_bv in XSAVES header
>
> The compacted-format XSAVES area is determined at boot time and
> never changed after. The field xsave.header.xcomp_bv indicates
> which components are in the fixed XSAVES format.
>
> In fpstate_init() we did not set xcomp_bv to reflect the XSAVES
> format since at the time there is no valid data.
>
> However, after we do copy_init_fpstate_to_fpregs() in fpu__clear(),
> as in commit:
>
> b22cbe404a9c x86/fpu: Fix invalid FPU ptrace state after execve()
>
> and when __fpu_restore_sig() does fpu__restore() for a COMPAT-mode
> app, a #GP occurs. This can be easily triggered by doing valgrind on
> a COMPAT-mode "Hello World," as reported by Joakim Tjernlund and
> others:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=190061
>
> Fix it by setting xcomp_bv correctly.
>
Please consider pulling this into the stable tree because my previous
patch in commit:
b22cbe404a9c x86/fpu: Fix invalid FPU ptrace state after execve()
exposes the same issue in the stable tree.
Thanks,
Yu-cheng
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [tip:x86/urgent] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
2017-02-14 21:26 ` Yu-cheng Yu
@ 2017-02-14 22:53 ` Greg Kroah-Hartman
2017-02-16 17:51 ` Greg Kroah-Hartman
1 sibling, 0 replies; 9+ messages in thread
From: Greg Kroah-Hartman @ 2017-02-14 22:53 UTC (permalink / raw)
To: Yu-cheng Yu
Cc: dave.hansen, linux-kernel, ravi.v.shankar, torvalds, haokexin,
tglx, Joakim.Tjernlund, mingo, peterz, hpa, fenghua.yu, luto, bp,
stable
On Tue, Feb 14, 2017 at 01:26:41PM -0800, Yu-cheng Yu wrote:
> On Tue, Jan 24, 2017 at 12:46:17AM -0800, tip-bot for Yu-cheng Yu wrote:
> > Commit-ID: dffba9a31c7769be3231c420d4b364c92ba3f1ac
> > Gitweb: http://git.kernel.org/tip/dffba9a31c7769be3231c420d4b364c92ba3f1ac
> > Author: Yu-cheng Yu <yu-cheng.yu@intel.com>
> > AuthorDate: Mon, 23 Jan 2017 14:54:44 -0800
> > Committer: Ingo Molnar <mingo@kernel.org>
> > CommitDate: Tue, 24 Jan 2017 09:04:48 +0100
> >
> > x86/fpu/xstate: Fix xcomp_bv in XSAVES header
> >
> > The compacted-format XSAVES area is determined at boot time and
> > never changed after. The field xsave.header.xcomp_bv indicates
> > which components are in the fixed XSAVES format.
> >
> > In fpstate_init() we did not set xcomp_bv to reflect the XSAVES
> > format since at the time there is no valid data.
> >
> > However, after we do copy_init_fpstate_to_fpregs() in fpu__clear(),
> > as in commit:
> >
> > b22cbe404a9c x86/fpu: Fix invalid FPU ptrace state after execve()
> >
> > and when __fpu_restore_sig() does fpu__restore() for a COMPAT-mode
> > app, a #GP occurs. This can be easily triggered by doing valgrind on
> > a COMPAT-mode "Hello World," as reported by Joakim Tjernlund and
> > others:
> >
> > https://bugzilla.kernel.org/show_bug.cgi?id=190061
> >
> > Fix it by setting xcomp_bv correctly.
> >
>
> Please consider pulling this into the stable tree because my previous
> patch in commit:
>
> b22cbe404a9c x86/fpu: Fix invalid FPU ptrace state after execve()
>
> exposes the same issue in the stable tree.
Ah, thanks, I'll do that for the next round of stable releases after the
ones that happen tomorrow.
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [tip:x86/urgent] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
2017-02-14 21:26 ` Yu-cheng Yu
2017-02-14 22:53 ` Greg Kroah-Hartman
@ 2017-02-16 17:51 ` Greg Kroah-Hartman
2017-02-16 17:51 ` Yu-cheng Yu
1 sibling, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2017-02-16 17:51 UTC (permalink / raw)
To: Yu-cheng Yu
Cc: dave.hansen, linux-kernel, ravi.v.shankar, torvalds, haokexin,
tglx, Joakim.Tjernlund, mingo, peterz, hpa, fenghua.yu, luto, bp,
stable
On Tue, Feb 14, 2017 at 01:26:41PM -0800, Yu-cheng Yu wrote:
> On Tue, Jan 24, 2017 at 12:46:17AM -0800, tip-bot for Yu-cheng Yu wrote:
> > Commit-ID: dffba9a31c7769be3231c420d4b364c92ba3f1ac
> > Gitweb: http://git.kernel.org/tip/dffba9a31c7769be3231c420d4b364c92ba3f1ac
> > Author: Yu-cheng Yu <yu-cheng.yu@intel.com>
> > AuthorDate: Mon, 23 Jan 2017 14:54:44 -0800
> > Committer: Ingo Molnar <mingo@kernel.org>
> > CommitDate: Tue, 24 Jan 2017 09:04:48 +0100
> >
> > x86/fpu/xstate: Fix xcomp_bv in XSAVES header
> >
> > The compacted-format XSAVES area is determined at boot time and
> > never changed after. The field xsave.header.xcomp_bv indicates
> > which components are in the fixed XSAVES format.
> >
> > In fpstate_init() we did not set xcomp_bv to reflect the XSAVES
> > format since at the time there is no valid data.
> >
> > However, after we do copy_init_fpstate_to_fpregs() in fpu__clear(),
> > as in commit:
> >
> > b22cbe404a9c x86/fpu: Fix invalid FPU ptrace state after execve()
> >
> > and when __fpu_restore_sig() does fpu__restore() for a COMPAT-mode
> > app, a #GP occurs. This can be easily triggered by doing valgrind on
> > a COMPAT-mode "Hello World," as reported by Joakim Tjernlund and
> > others:
> >
> > https://bugzilla.kernel.org/show_bug.cgi?id=190061
> >
> > Fix it by setting xcomp_bv correctly.
> >
>
> Please consider pulling this into the stable tree because my previous
> patch in commit:
>
> b22cbe404a9c x86/fpu: Fix invalid FPU ptrace state after execve()
>
> exposes the same issue in the stable tree.
I just tried to apply this, and it does not apply at all. Can you
please provide a backported version that you have verified will work, so
that I can apply it?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [tip:x86/urgent] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
2017-02-16 17:51 ` Greg Kroah-Hartman
@ 2017-02-16 17:51 ` Yu-cheng Yu
0 siblings, 0 replies; 9+ messages in thread
From: Yu-cheng Yu @ 2017-02-16 17:51 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: dave.hansen, linux-kernel, ravi.v.shankar, torvalds, haokexin,
tglx, Joakim.Tjernlund, mingo, peterz, hpa, fenghua.yu, luto, bp,
stable
On Thu, Feb 16, 2017 at 09:51:12AM -0800, Greg Kroah-Hartman wrote:
> On Tue, Feb 14, 2017 at 01:26:41PM -0800, Yu-cheng Yu wrote:
> > On Tue, Jan 24, 2017 at 12:46:17AM -0800, tip-bot for Yu-cheng Yu wrote:
> > > Commit-ID: dffba9a31c7769be3231c420d4b364c92ba3f1ac
> > > Gitweb: http://git.kernel.org/tip/dffba9a31c7769be3231c420d4b364c92ba3f1ac
> > > Author: Yu-cheng Yu <yu-cheng.yu@intel.com>
> > > AuthorDate: Mon, 23 Jan 2017 14:54:44 -0800
> > > Committer: Ingo Molnar <mingo@kernel.org>
> > > CommitDate: Tue, 24 Jan 2017 09:04:48 +0100
> > >
> > > x86/fpu/xstate: Fix xcomp_bv in XSAVES header
> I just tried to apply this, and it does not apply at all. Can you
> please provide a backported version that you have verified will work, so
> that I can apply it?
I will do that.
Thanks,
Yu-cheng
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
@ 2017-02-16 22:14 Yu-cheng Yu
0 siblings, 0 replies; 9+ messages in thread
From: Yu-cheng Yu @ 2017-02-16 22:14 UTC (permalink / raw)
To: linux-kernel, x86, H. Peter Anvin, Thomas Gleixner, Ingo Molnar,
stable, Borislav Petkov, Dave Hansen, haokexin, Fenghua Yu,
Ravi V. Shankar, peterz, Andy Lutomirski, Joakim Tjernlund,
torvalds, Greg Kroah-Hartman
Cc: Yu-cheng Yu
This is essentially the same patch as:
commit dffba9a31c77 ("x86/fpu/xstate: Fix xcomp_bv in XSAVES header")
in the upstream tree, rebased and tested for the stable tree.
This can be applied to both linux-stable-rc/linux-4.9.y and
linux-stable-rc/linux-4.8.y if desired.
The compacted-format XSAVES area is determined at boot time and
never changed after. The field xsave.header.xcomp_bv indicates
which components are in the fixed XSAVES format.
In fpstate_init() we did not set xcomp_bv to reflect the XSAVES
format since at the time there is no valid data.
However, after we do copy_init_fpstate_to_fpregs() in fpu__clear(),
as in commit
b22cbe404a9c ("x86/fpu: Fix invalid FPU ptrace state after execve()")
and when __fpu_restore_sig() does fpu__restore() for a COMPAT-mode
app, a #GP occurs. This can be easily triggered by doing valgrind on
a COMPAT-mode "Hello World," as reported by Joakim Tjernlund and
others:
https://bugzilla.kernel.org/show_bug.cgi?id=190061
Fix it by setting xcomp_bv correctly.
Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Reported-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
---
arch/x86/kernel/fpu/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index ebb4e95..96d80df 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -236,7 +236,8 @@ void fpstate_init(union fpregs_state *state)
* it will #GP. Make sure it is replaced after the memset().
*/
if (static_cpu_has(X86_FEATURE_XSAVES))
- state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT;
+ state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT |
+ xfeatures_mask;
if (static_cpu_has(X86_FEATURE_FXSR))
fpstate_init_fxstate(&state->fxsave);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-02-16 22:20 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-23 22:54 [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header Yu-cheng Yu
2017-01-24 8:09 ` Ingo Molnar
2017-02-02 20:18 ` Joakim Tjernlund
2017-01-24 8:46 ` [tip:x86/urgent] " tip-bot for Yu-cheng Yu
2017-02-14 21:26 ` Yu-cheng Yu
2017-02-14 22:53 ` Greg Kroah-Hartman
2017-02-16 17:51 ` Greg Kroah-Hartman
2017-02-16 17:51 ` Yu-cheng Yu
2017-02-16 22:14 [PATCH] " Yu-cheng Yu
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).