aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorXiaotian Feng <dfeng@redhat.com>2010-08-13 03:19:11 -0400
committerAvi Kivity <avi@redhat.com>2010-08-15 07:10:15 -0400
commitf45755b8346f1a089ca7957dce5f4c3c6cb26e6f (patch)
treef0b34312371aeaf88fed462857af0630a2c19af8 /arch/x86/kvm/x86.c
parent3cfc2c42c1cbc8e238bb9c0612c0df4565e3a8b4 (diff)
KVM: fix poison overwritten caused by using wrong xstate size
fpu.state is allocated from task_xstate_cachep, the size of task_xstate_cachep is xstate_size. xstate_size is set from cpuid instruction, which is often smaller than sizeof(struct xsave_struct). kvm is using sizeof(struct xsave_struct) to fill in/out fpu.state.xsave, as what we allocated for fpu.state is xstate_size, kernel will write out of memory and caused poison/redzone/padding overwritten warnings. Signed-off-by: Xiaotian Feng <dfeng@redhat.com> Reviewed-by: Sheng Yang <sheng@linux.intel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Suresh Siddha <suresh.b.siddha@intel.com> Cc: Brian Gerst <brgerst@gmail.com> Cc: Avi Kivity <avi@redhat.com> Cc: Robert Richter <robert.richter@amd.com> Cc: Sheng Yang <sheng@linux.intel.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Gleb Natapov <gleb@redhat.com> Cc: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 97aab036dabf..bb2347a69c07 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2387,7 +2387,7 @@ static void kvm_vcpu_ioctl_x86_get_xsave(struct kvm_vcpu *vcpu,
2387 if (cpu_has_xsave) 2387 if (cpu_has_xsave)
2388 memcpy(guest_xsave->region, 2388 memcpy(guest_xsave->region,
2389 &vcpu->arch.guest_fpu.state->xsave, 2389 &vcpu->arch.guest_fpu.state->xsave,
2390 sizeof(struct xsave_struct)); 2390 xstate_size);
2391 else { 2391 else {
2392 memcpy(guest_xsave->region, 2392 memcpy(guest_xsave->region,
2393 &vcpu->arch.guest_fpu.state->fxsave, 2393 &vcpu->arch.guest_fpu.state->fxsave,
@@ -2405,7 +2405,7 @@ static int kvm_vcpu_ioctl_x86_set_xsave(struct kvm_vcpu *vcpu,
2405 2405
2406 if (cpu_has_xsave) 2406 if (cpu_has_xsave)
2407 memcpy(&vcpu->arch.guest_fpu.state->xsave, 2407 memcpy(&vcpu->arch.guest_fpu.state->xsave,
2408 guest_xsave->region, sizeof(struct xsave_struct)); 2408 guest_xsave->region, xstate_size);
2409 else { 2409 else {
2410 if (xstate_bv & ~XSTATE_FPSSE) 2410 if (xstate_bv & ~XSTATE_FPSSE)
2411 return -EINVAL; 2411 return -EINVAL;