peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame qemu-fix-msr-count-potential-segfault.patch

Mark McLoughlin 5df474
From 7834349cfcc68b946c0d241ffd99c598857e489b Mon Sep 17 00:00:00 2001
Mark McLoughlin 5df474
From: Eduardo Habkost <ehabkost@redhat.com>
Mark McLoughlin 5df474
Date: Wed, 14 Oct 2009 15:02:27 -0300
Mark McLoughlin 5df474
Subject: [PATCH] fix MSR_COUNT for kvm_arch_save_regs()
Mark McLoughlin 5df474
Mark McLoughlin 5df474
A new register was added to the load/save list on commit
Mark McLoughlin 5df474
d283d5a65a2bdcc570065267be21848bd6fe3d78, but MSR_COUNT was not updated, leading
Mark McLoughlin 5df474
to potential stack corruption on kvm_arch_save_regs().
Mark McLoughlin 5df474
Mark McLoughlin 5df474
The following registers are saved by kvm_arch_save_regs():
Mark McLoughlin 5df474
Mark McLoughlin 5df474
 1) MSR_IA32_SYSENTER_CS
Mark McLoughlin 5df474
 2) MSR_IA32_SYSENTER_ESP
Mark McLoughlin 5df474
 3) MSR_IA32_SYSENTER_EIP
Mark McLoughlin 5df474
 4) MSR_STAR
Mark McLoughlin 5df474
 5) MSR_IA32_TSC
Mark McLoughlin 5df474
 6) MSR_VM_HSAVE_PA
Mark McLoughlin 5df474
 7) MSR_CSTAR (x86_64 only)
Mark McLoughlin 5df474
 8) MSR_KERNELGSBASE (x86_64 only)
Mark McLoughlin 5df474
 9) MSR_FMASK (x86_64 only)
Mark McLoughlin 5df474
10) MSR_LSTAR (x86_64 only)
Mark McLoughlin 5df474
Mark McLoughlin 5df474
(cherry picked from commit e7e5448ba387adc20be1cf08411a5b526d684299)
Mark McLoughlin 5df474
Mark McLoughlin 5df474
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Mark McLoughlin 5df474
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Mark McLoughlin 5df474
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Mark McLoughlin 5df474
Fedora-patch: qemu-fix-msr-count-potential-segfault.patch
Mark McLoughlin 5df474
---
Mark McLoughlin 5df474
 qemu-kvm-x86.c |    6 ++++--
Mark McLoughlin 5df474
 1 files changed, 4 insertions(+), 2 deletions(-)
Mark McLoughlin 5df474
Mark McLoughlin 5df474
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
Mark McLoughlin 5df474
index 492dbc5..d5436b6 100644
Mark McLoughlin 5df474
--- a/qemu-kvm-x86.c
Mark McLoughlin 5df474
+++ b/qemu-kvm-x86.c
Mark McLoughlin 5df474
@@ -847,9 +847,9 @@ static int get_msr_entry(struct kvm_msr_entry *entry, CPUState *env)
Mark McLoughlin 5df474
 }
Mark McLoughlin 5df474
 
Mark McLoughlin 5df474
 #ifdef TARGET_X86_64
Mark McLoughlin 5df474
-#define MSR_COUNT 9
Mark McLoughlin 5df474
+#define MSR_COUNT 10
Mark McLoughlin 5df474
 #else
Mark McLoughlin 5df474
-#define MSR_COUNT 5
Mark McLoughlin 5df474
+#define MSR_COUNT 6
Mark McLoughlin 5df474
 #endif
Mark McLoughlin 5df474
 
Mark McLoughlin 5df474
 static void set_v8086_seg(struct kvm_segment *lhs, const SegmentCache *rhs)
Mark McLoughlin 5df474
@@ -991,6 +991,7 @@ void kvm_arch_load_regs(CPUState *env)
Mark McLoughlin 5df474
 
Mark McLoughlin 5df474
     /* msrs */
Mark McLoughlin 5df474
     n = 0;
Mark McLoughlin 5df474
+    /* Remember to increase MSR_COUNT if you add new registers below */
Mark McLoughlin 5df474
     set_msr_entry(&msrs[n++], MSR_IA32_SYSENTER_CS,  env->sysenter_cs);
Mark McLoughlin 5df474
     set_msr_entry(&msrs[n++], MSR_IA32_SYSENTER_ESP, env->sysenter_esp);
Mark McLoughlin 5df474
     set_msr_entry(&msrs[n++], MSR_IA32_SYSENTER_EIP, env->sysenter_eip);
Mark McLoughlin 5df474
@@ -1166,6 +1167,7 @@ void kvm_arch_save_regs(CPUState *env)
Mark McLoughlin 5df474
 
Mark McLoughlin 5df474
     /* msrs */
Mark McLoughlin 5df474
     n = 0;
Mark McLoughlin 5df474
+    /* Remember to increase MSR_COUNT if you add new registers below */
Mark McLoughlin 5df474
     msrs[n++].index = MSR_IA32_SYSENTER_CS;
Mark McLoughlin 5df474
     msrs[n++].index = MSR_IA32_SYSENTER_ESP;
Mark McLoughlin 5df474
     msrs[n++].index = MSR_IA32_SYSENTER_EIP;
Mark McLoughlin 5df474
-- 
Mark McLoughlin 5df474
1.6.2.5
Mark McLoughlin 5df474