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: 45088 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CAD8A2142A for ; Wed, 25 Feb 2015 16:05:24 +0000 (UTC) Received: by lbiw7 with SMTP id w7sf3658606lbi.0 for ; Wed, 25 Feb 2015 08:05:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding:cc :subject:precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=mLNxYFf5zf3tg/3hmKjG8TE3RKOIzb4/xiW3VhTtQQc=; b=iLAFkIAbhDhIhMwLX9cBW66GYNrRzJGzK7Z1ynHBElio0z1swQRvm6Mv3dwTHXJRN6 Il0jwEPxm/4UuCT3ZD+clJm+FYg6v13QR2XwuDlyzS2lORK7wL4RsuvO6JHhuNqHZqwo jP+KqZBpQmzlWj6epLiUKj/28RTwa4HbInaM79Jsa/tJzBL+9kTKmVEcSZOTX8NW2hEX YCZ7ooSz1ldv6QqdYbEeEhDypDX8eTy0AxvhPlCBymHoyqfH81a+MLu1CxY2FZ/aIEqF PVoNkPkrubMRBVNf28jgsLc34mWo2nDvghnJTu0nqcCfXd/5zAa54OtTI5Q6QiMp0JbC z18Q== X-Gm-Message-State: ALoCoQndu+4wvwb0CDXjSmQTyrpmFbWvSH8SVkTClnYRErNvvS7OMptF1+otRx2V5+uZgX6MrprV X-Received: by 10.152.28.137 with SMTP id b9mr607190lah.8.1424880323808; Wed, 25 Feb 2015 08:05:23 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.6 with SMTP id iy6ls756510lac.38.gmail; Wed, 25 Feb 2015 08:05:23 -0800 (PST) X-Received: by 10.112.166.170 with SMTP id zh10mr3503096lbb.62.1424880323661; Wed, 25 Feb 2015 08:05:23 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id m11si16071995laa.159.2015.02.25.08.05.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 08:05:23 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labgm9 with SMTP id gm9so4919940lab.2 for ; Wed, 25 Feb 2015 08:05:23 -0800 (PST) X-Received: by 10.152.22.67 with SMTP id b3mr3279742laf.117.1424880323558; Wed, 25 Feb 2015 08:05:23 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2713463lbj; Wed, 25 Feb 2015 08:05:22 -0800 (PST) X-Received: by 10.229.241.137 with SMTP id le9mr8596550qcb.20.1424880322367; Wed, 25 Feb 2015 08:05:22 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 18si34477444qhf.51.2015.02.25.08.05.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 25 Feb 2015 08:05:22 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:54770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQeSf-0006AD-F4 for patch@linaro.org; Wed, 25 Feb 2015 11:05:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQeQ9-0002PS-2t for qemu-devel@nongnu.org; Wed, 25 Feb 2015 11:02:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQeQ4-0006k8-9B for qemu-devel@nongnu.org; Wed, 25 Feb 2015 11:02:45 -0500 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:47112 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQeQ4-0006k2-3w for qemu-devel@nongnu.org; Wed, 25 Feb 2015 11:02:40 -0500 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 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-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 88.198.71.155 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 Subject: [Qemu-devel] [PATCH 1/6] target-arm: kvm: save/restore mp state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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,