From patchwork Tue May 4 12:45:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 51610 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 65084B7BEE for ; Wed, 5 May 2010 00:27:15 +1000 (EST) Received: from localhost ([127.0.0.1]:40763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9IeT-0006y0-E3 for incoming@patchwork.ozlabs.org; Tue, 04 May 2010 09:59:09 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O9IVf-000298-3F for qemu-devel@nongnu.org; Tue, 04 May 2010 09:50:03 -0400 Received: from [140.186.70.92] (port=53031 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9IVY-0001za-Ui for qemu-devel@nongnu.org; Tue, 04 May 2010 09:50:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O9IVU-000449-9c for qemu-devel@nongnu.org; Tue, 04 May 2010 09:49:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59754) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9IVU-00043q-2K for qemu-devel@nongnu.org; Tue, 04 May 2010 09:49:52 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o44DnpHw020505 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 May 2010 09:49:51 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o44DbLmg000317; Tue, 4 May 2010 09:49:50 -0400 Received: from amt.cnet (vpn2-10-150.ams2.redhat.com [10.36.10.150]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o44CwRJe023279; Tue, 4 May 2010 09:00:13 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id C4EE068A9C8; Tue, 4 May 2010 09:55:03 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o44Ct24X016606; Tue, 4 May 2010 09:55:02 -0300 Message-Id: <20100504124634.572348443@redhat.com> User-Agent: quilt/0.47-1 Date: Tue, 04 May 2010 09:45:26 -0300 From: Marcelo Tosatti To: kvm@vger.kernel.org, qemu-devel@nongnu.org References: <20100504124518.979470863@redhat.com> Content-Disposition: inline; filename=assert-get-regs X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Marcelo Tosatti Subject: [Qemu-devel] [patch uq/master 8/9] kvm: validate context for kvm cpu get/put operations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka Validate that KVM vcpu state is only read/written from cpu thread itself or that cpu is stopped. Signed-off-by: Marcelo Tosatti 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;