linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/fpu: Fix get_xsave_addr which returns error pointer to KVM
@ 2015-11-06  9:00 Huaitong Han
  2015-11-10 22:40 ` Dave Hansen
  2015-11-12 13:28 ` [tip:x86/urgent] x86/fpu: Fix get_xsave_addr() behavior under virtualization tip-bot for Huaitong Han
  0 siblings, 2 replies; 3+ messages in thread
From: Huaitong Han @ 2015-11-06  9:00 UTC (permalink / raw)
  To: tglx, mingo, hpa; +Cc: dave.hansen, x86, linux-kernel, Huaitong Han

when KVM uses the get_xsave_addr, xsave parameter belongs to guest vcpu, if
xsave is replaced with current task (host) xsave, get_xsave_addr will return error
xsave addr to KVM.

Signed-off-by: Huaitong Han <huaitong.han@intel.com>
---
 arch/x86/kernel/fpu/xstate.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 62fc001..2c4ac07 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -402,7 +402,6 @@ void *get_xsave_addr(struct xregs_state *xsave, int xstate_feature)
 	if (!boot_cpu_has(X86_FEATURE_XSAVE))
 		return NULL;
 
-	xsave = &current->thread.fpu.state.xsave;
 	/*
 	 * We should not ever be requesting features that we
 	 * have not enabled.  Remember that pcntxt_mask is
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/fpu: Fix get_xsave_addr which returns error pointer to KVM
  2015-11-06  9:00 [PATCH] x86/fpu: Fix get_xsave_addr which returns error pointer to KVM Huaitong Han
@ 2015-11-10 22:40 ` Dave Hansen
  2015-11-12 13:28 ` [tip:x86/urgent] x86/fpu: Fix get_xsave_addr() behavior under virtualization tip-bot for Huaitong Han
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Hansen @ 2015-11-10 22:40 UTC (permalink / raw)
  To: Huaitong Han, tglx, mingo, hpa; +Cc: x86, linux-kernel

On 11/06/2015 01:00 AM, Huaitong Han wrote:
> when KVM uses the get_xsave_addr, xsave parameter belongs to guest vcpu, if
> xsave is replaced with current task (host) xsave, get_xsave_addr will return error
> xsave addr to KVM.
> 
> Signed-off-by: Huaitong Han <huaitong.han@intel.com>

Looks good to me.  It was completely bogus that we passed 'xsave' in
there and then just wrote over it.

Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:x86/urgent] x86/fpu: Fix get_xsave_addr() behavior under virtualization
  2015-11-06  9:00 [PATCH] x86/fpu: Fix get_xsave_addr which returns error pointer to KVM Huaitong Han
  2015-11-10 22:40 ` Dave Hansen
@ 2015-11-12 13:28 ` tip-bot for Huaitong Han
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Huaitong Han @ 2015-11-12 13:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, oleg, linux-kernel, huaitong.han, luto, tglx, peterz, stable,
	pbonzini, quentin.casasnovas, torvalds, fenghua.yu, mingo,
	dave.hansen, bp

Commit-ID:  a05917b6ba9dc9a95fc42bdcbe3a875e8ad83935
Gitweb:     http://git.kernel.org/tip/a05917b6ba9dc9a95fc42bdcbe3a875e8ad83935
Author:     Huaitong Han <huaitong.han@intel.com>
AuthorDate: Fri, 6 Nov 2015 17:00:23 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 12 Nov 2015 09:34:58 +0100

x86/fpu: Fix get_xsave_addr() behavior under virtualization

KVM uses the get_xsave_addr() function in a different fashion from
the native kernel, in that the 'xsave' parameter belongs to guest vcpu,
not the currently running task.

But 'xsave' is replaced with current task's (host) xsave structure, so
get_xsave_addr() will incorrectly return the bad xsave address to KVM.

Fix it so that the passed in 'xsave' address is used - as intended
originally.

Signed-off-by: Huaitong Han <huaitong.han@intel.com>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: <stable@vger.kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: dave.hansen@intel.com
Link: http://lkml.kernel.org/r/1446800423-21622-1-git-send-email-huaitong.han@intel.com
[ Tidied up the changelog. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/fpu/xstate.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 6454f27..70fc312 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -694,7 +694,6 @@ void *get_xsave_addr(struct xregs_state *xsave, int xstate_feature)
 	if (!boot_cpu_has(X86_FEATURE_XSAVE))
 		return NULL;
 
-	xsave = &current->thread.fpu.state.xsave;
 	/*
 	 * We should not ever be requesting features that we
 	 * have not enabled.  Remember that pcntxt_mask is

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-12 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-06  9:00 [PATCH] x86/fpu: Fix get_xsave_addr which returns error pointer to KVM Huaitong Han
2015-11-10 22:40 ` Dave Hansen
2015-11-12 13:28 ` [tip:x86/urgent] x86/fpu: Fix get_xsave_addr() behavior under virtualization tip-bot for Huaitong Han

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).