From patchwork Wed Feb 25 16:02:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 5881691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 932D19F269 for ; Wed, 25 Feb 2015 16:23:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7C172034A for ; Wed, 25 Feb 2015 16:23:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D0753202E9 for ; Wed, 25 Feb 2015 16:23:18 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YQeh7-0001BI-Sb; Wed, 25 Feb 2015 16:20:17 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YQeQm-0001sA-7a for linux-arm-kernel@bombadil.infradead.org; Wed, 25 Feb 2015 16:03:24 +0000 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155] helo=socrates.bennee.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YQeQh-00045Z-Su for linux-arm-kernel@lists.infradead.org; Wed, 25 Feb 2015 16:03:20 +0000 Received: from localhost ([127.0.0.1] helo=zen.linaroharston) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1YQfO5-0007hX-DR; Wed, 25 Feb 2015 18:04:41 +0100 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH 1/6] target-arm: kvm: save/restore mp state Date: Wed, 25 Feb 2015 16:02:33 +0000 Message-Id: <1424880159-29348-2-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1424880159-29348-1-git-send-email-alex.bennee@linaro.org> References: <1424880159-29348-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150225_110320_357700_7452C1FA X-CRM114-Status: GOOD ( 11.41 ) X-Spam-Score: -1.2 (-) Cc: Peter Maydell , kvm@vger.kernel.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds the saving and restore of the current Multi-Processing state of the machine. While the KVM_GET/SET_MP_STATE API exposes a number of potential states for x86 we only use two for ARM. Either the process is running or not. Signed-off-by: Alex Bennée diff --git a/target-arm/kvm.c b/target-arm/kvm.c index 23cefe9..8732854 100644 --- a/target-arm/kvm.c +++ b/target-arm/kvm.c @@ -25,6 +25,7 @@ #include "hw/arm/arm.h" const KVMCapabilityInfo kvm_arch_required_capabilities[] = { + KVM_CAP_INFO(MP_STATE), KVM_CAP_LAST_INFO }; diff --git a/target-arm/machine.c b/target-arm/machine.c index 9446e5a..70b1bc4 100644 --- a/target-arm/machine.c +++ b/target-arm/machine.c @@ -161,6 +161,34 @@ static const VMStateInfo vmstate_cpsr = { .put = put_cpsr, }; +#if defined CONFIG_KVM +static int get_mpstate(QEMUFile *f, void *opaque, size_t size) +{ + ARMCPU *cpu = opaque; + struct kvm_mp_state mp_state = { .mp_state = qemu_get_be32(f)}; + return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MP_STATE, &mp_state); +} + +static void put_mpstate(QEMUFile *f, void *opaque, size_t size) +{ + ARMCPU *cpu = opaque; + struct kvm_mp_state mp_state; + int ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MP_STATE, &mp_state); + if (ret) { + fprintf(stderr, "%s: failed to get MP_STATE %d/%s\n", + __func__, ret, strerror(ret)); + abort(); + } + qemu_put_be32(f, mp_state.mp_state); +} + +static const VMStateInfo vmstate_mpstate = { + .name = "mpstate", + .get = get_mpstate, + .put = put_mpstate, +}; +#endif + static void cpu_pre_save(void *opaque) { ARMCPU *cpu = opaque; @@ -244,6 +272,16 @@ const VMStateDescription vmstate_arm_cpu = { VMSTATE_UINT32_ARRAY(env.regs, ARMCPU, 16), VMSTATE_UINT64_ARRAY(env.xregs, ARMCPU, 32), VMSTATE_UINT64(env.pc, ARMCPU), +#if defined CONFIG_KVM + { + .name = "mp_state", + .version_id = 0, + .size = sizeof(uint32_t), + .info = &vmstate_mpstate, + .flags = VMS_SINGLE, + .offset = 0, + }, +#endif { .name = "cpsr", .version_id = 0,