Patchwork [uq/master,8/9] kvm: validate context for kvm cpu get/put operations

login
register
mail settings
Submitter Marcelo Tosatti
Date May 4, 2010, 12:45 p.m.
Message ID <20100504124634.572348443@redhat.com>
Download mbox | patch
Permalink /patch/51610/
State New
Headers show

Comments

Marcelo Tosatti - May 4, 2010, 12:45 p.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

Validate that KVM vcpu state is only read/written from cpu thread itself
or that cpu is stopped.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Patch

Index: qemu/target-i386/kvm.c
===================================================================
--- qemu.orig/target-i386/kvm.c
+++ qemu/target-i386/kvm.c
@@ -949,6 +949,8 @@  int kvm_arch_put_registers(CPUState *env
 {
     int ret;
 
+    assert(cpu_is_stopped(env) || qemu_cpu_self(env));
+
     ret = kvm_getput_regs(env, 1);
     if (ret < 0)
         return ret;
@@ -991,6 +993,8 @@  int kvm_arch_get_registers(CPUState *env
 {
     int ret;
 
+    assert(cpu_is_stopped(env) || qemu_cpu_self(env));
+
     ret = kvm_getput_regs(env, 0);
     if (ret < 0)
         return ret;