summaryrefslogtreecommitdiffstats
path: root/KVM-x86-extend-struct-x86_emulate_ops-with-get_cpuid.patch
diff options
context:
space:
mode:
authorJosh Boyer <jwboyer@redhat.com>2012-01-13 11:18:16 -0500
committerJosh Boyer <jwboyer@redhat.com>2012-01-13 11:18:16 -0500
commit3aa57a610543086ee7c7bf9f0c455b49d6b2f0b0 (patch)
tree6cb8bf5379768e0eb193c1cd4ea64005de152689 /KVM-x86-extend-struct-x86_emulate_ops-with-get_cpuid.patch
parentfdb68da43b60ef7d2a19bbe2b56728d9db25566d (diff)
downloadkernel-3aa57a610543086ee7c7bf9f0c455b49d6b2f0b0.tar.gz
kernel-3aa57a610543086ee7c7bf9f0c455b49d6b2f0b0.tar.xz
kernel-3aa57a610543086ee7c7bf9f0c455b49d6b2f0b0.zip
CVE-2012-0045 kvm: syscall instruction induced guest panic (rhbz 773392)
Diffstat (limited to 'KVM-x86-extend-struct-x86_emulate_ops-with-get_cpuid.patch')
-rw-r--r--KVM-x86-extend-struct-x86_emulate_ops-with-get_cpuid.patch78
1 files changed, 78 insertions, 0 deletions
diff --git a/KVM-x86-extend-struct-x86_emulate_ops-with-get_cpuid.patch b/KVM-x86-extend-struct-x86_emulate_ops-with-get_cpuid.patch
new file mode 100644
index 000000000..f9dbaa014
--- /dev/null
+++ b/KVM-x86-extend-struct-x86_emulate_ops-with-get_cpuid.patch
@@ -0,0 +1,78 @@
+From 0769c5de24621141c953fbe1f943582d37cb4244 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stephan=20B=C3=A4rwolf?= <stephan.baerwolf@tu-ilmenau.de>
+Date: Thu, 12 Jan 2012 16:43:03 +0100
+Subject: [PATCH 1/2] KVM: x86: extend "struct x86_emulate_ops" with
+ "get_cpuid"
+
+In order to be able to proceed checks on CPU-specific properties
+within the emulator, function "get_cpuid" is introduced.
+With "get_cpuid" it is possible to virtually call the guests
+"cpuid"-opcode without changing the VM's context.
+
+[mtosatti: cleanup/beautify code]
+
+Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
+Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
+---
+ arch/x86/include/asm/kvm_emulate.h | 3 +++
+ arch/x86/kvm/x86.c | 23 +++++++++++++++++++++++
+ 2 files changed, 26 insertions(+), 0 deletions(-)
+
+diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
+index ab4092e..c8b2868 100644
+--- a/arch/x86/include/asm/kvm_emulate.h
++++ b/arch/x86/include/asm/kvm_emulate.h
+@@ -190,6 +190,9 @@ struct x86_emulate_ops {
+ int (*intercept)(struct x86_emulate_ctxt *ctxt,
+ struct x86_instruction_info *info,
+ enum x86_intercept_stage stage);
++
++ bool (*get_cpuid)(struct x86_emulate_ctxt *ctxt,
++ u32 *eax, u32 *ebx, u32 *ecx, u32 *edx);
+ };
+
+ typedef u32 __attribute__((vector_size(16))) sse128_t;
+diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
+index f0fa3fb..c95ca2d 100644
+--- a/arch/x86/kvm/x86.c
++++ b/arch/x86/kvm/x86.c
+@@ -4205,6 +4205,28 @@ static int emulator_intercept(struct x86_emulate_ctxt *ctxt,
+ return kvm_x86_ops->check_intercept(emul_to_vcpu(ctxt), info, stage);
+ }
+
++static bool emulator_get_cpuid(struct x86_emulate_ctxt *ctxt,
++ u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
++{
++ struct kvm_cpuid_entry2 *cpuid = NULL;
++
++ if (eax && ecx)
++ cpuid = kvm_find_cpuid_entry(emul_to_vcpu(ctxt),
++ *eax, *ecx);
++
++ if (cpuid) {
++ *eax = cpuid->eax;
++ *ecx = cpuid->ecx;
++ if (ebx)
++ *ebx = cpuid->ebx;
++ if (edx)
++ *edx = cpuid->edx;
++ return true;
++ }
++
++ return false;
++}
++
+ static struct x86_emulate_ops emulate_ops = {
+ .read_std = kvm_read_guest_virt_system,
+ .write_std = kvm_write_guest_virt_system,
+@@ -4236,6 +4258,7 @@ static struct x86_emulate_ops emulate_ops = {
+ .get_fpu = emulator_get_fpu,
+ .put_fpu = emulator_put_fpu,
+ .intercept = emulator_intercept,
++ .get_cpuid = emulator_get_cpuid,
+ };
+
+ static void cache_all_regs(struct kvm_vcpu *vcpu)
+--
+1.7.7.5
+