x86/fpu: Fix get_xsave_addr which returns error pointer to KVM
Subsystems (2)
PATCH 1/1 x86/fpu: Fix get_xsave_addr which returns error pointer to KVM
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.
--- arch/x86/kernel/fpu/xstate.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/kernel/fpu/xstate.c +0 -1
@@ -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 = ¤t->thread.fpu.state.xsave;/* * We should not ever be requesting features that we * have not enabled. Remember that pcntxt_mask is
Signature · 1 line
2.4.3
Quoted 5 lines · 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_addrwill return error xsave addr to KVM.Signed-off-by Huaitong Han <[email protected]>
Looks good to me. It was completely bogus that we passed 'xsave' in there and then just wrote over it.
tip-bot for Huaitong Han
merge bot[tip:x86/urgent] x86/fpu: Fix get_xsave_addr() behavior under virtualization
In reply to Huaitong Hanx86/fpu: Fix get_xsave_addr() behavior under virtualization
Commit-ID: a05917b6ba9dc9a95fc42bdcbe3a875e8ad83935 Gitweb: http://git.kernel.org/tip/a05917b6ba9dc9a95fc42bdcbe3a875e8ad83935 Author: Huaitong Han <[email protected]> AuthorDate: Fri, 6 Nov 2015 17:00:23 +0800 Committer: Ingo Molnar <[email protected]> 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.
--- arch/x86/kernel/fpu/xstate.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/kernel/fpu/xstate.c +0 -1
@@ -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 = ¤t->thread.fpu.state.xsave;/* * We should not ever be requesting features that we * have not enabled. Remember that pcntxt_mask is