From patchwork Fri May 17 13:23:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 17028 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f70.google.com (mail-qe0-f70.google.com [209.85.128.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 34ACE238F0 for ; Fri, 17 May 2013 13:24:50 +0000 (UTC) Received: by mail-qe0-f70.google.com with SMTP id b10sf5717228qen.1 for ; Fri, 17 May 2013 06:24:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=CVnogwF3uXoXhFfjWpTJFApVOzySu0qePMvnTSrmVd4=; b=POUUAbNE3i77fjO6pbfuCWxnHQ0Mu4XoQ3mTiE5dImQFvzt7LboVfAXfLCNZE8MBBL CG+GABGN5fGc2A5GHrKOpdqmLZsV9SF1KuuFnxlOWG3cqDhccXMdAnvO4Q9MM1pky49o SMUY146RdzbzUt3HsfOCaMOsOf/0eTKtw8wzf2TVC15DDOUwVHfvwC991li/aYGkye+S Yd4PKt3YfXHx+dNKDYZhd+I3+Zgfbof6uTekkLxZbPnHHB79L0/TI1zDDJKz9gyIEgel g/9QazZ+ayvb22j4Cx+WZJ99X5fuKPYz0ognARygWkAmuu6sKbl0gTUWvUyEmKaoiWj2 py9A== X-Received: by 10.224.217.195 with SMTP id hn3mr28111884qab.5.1368797048664; Fri, 17 May 2013 06:24:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.70.195 with SMTP id o3ls1587003qeu.14.gmail; Fri, 17 May 2013 06:24:08 -0700 (PDT) X-Received: by 10.220.145.15 with SMTP id b15mr30060044vcv.59.1368797048527; Fri, 17 May 2013 06:24:08 -0700 (PDT) Received: from mail-vb0-x22c.google.com (mail-vb0-x22c.google.com [2607:f8b0:400c:c02::22c]) by mx.google.com with ESMTPS id s1si5832629vcc.44.2013.05.17.06.24.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 May 2013 06:24:08 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22c is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22c; Received: by mail-vb0-f44.google.com with SMTP id e13so2296631vbg.3 for ; Fri, 17 May 2013 06:24:08 -0700 (PDT) X-Received: by 10.220.238.4 with SMTP id kq4mr5684860vcb.73.1368797048321; Fri, 17 May 2013 06:24:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.126.138 with SMTP id c10csp109541vcs; Fri, 17 May 2013 06:24:07 -0700 (PDT) X-Received: by 10.60.116.99 with SMTP id jv3mr23332907oeb.7.1368797044042; Fri, 17 May 2013 06:24:04 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id yw5si6693988obb.92.2013.05.17.06.24.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 17 May 2013 06:24:03 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UdKda-00071j-0a; Fri, 17 May 2013 14:23:58 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Juan Quintela , Andre Przywara , kvmarm@lists.cs.columbia.edu Subject: [PATCH 6/7] target-arm: Reinitialize all KVM VCPU registers on reset Date: Fri, 17 May 2013 14:23:56 +0100 Message-Id: <1368797037-26976-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1368797037-26976-1-git-send-email-peter.maydell@linaro.org> References: <1368797037-26976-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQmnjgdcnafC0WimX6zhXrFWeRbjDW9vbCX31bs8rJ2RCaErOGj9zATg9I0eZ76Ed3xpE5tr X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22c is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Since the ARM KVM API doesn't include a "reset this VCPU" ioctl, we have to capture the initial values of every register it knows about so that we can reset the VCPU by feeding those values back again. Signed-off-by: Peter Maydell --- target-arm/cpu-qom.h | 6 +++++- target-arm/kvm.c | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h index 2242eee..25239b8 100644 --- a/target-arm/cpu-qom.h +++ b/target-arm/cpu-qom.h @@ -72,7 +72,11 @@ typedef struct ARMCPU { uint64_t *cpreg_indexes; /* Values of the registers (cpreg_indexes[i]'s value is cpreg_values[i]) */ uint64_t *cpreg_values; - /* Length of the indexes, values arrays */ + /* When using KVM, keeps a copy of the initial state of the VCPU, + * so that on reset we can feed the reset values back into the kernel. + */ + uint64_t *cpreg_reset_values; + /* Length of the indexes, values, reset_values arrays */ int32_t cpreg_array_len; /* These are used only for migration: incoming data arrives in * these fields and is sanity checked in post_load before copying diff --git a/target-arm/kvm.c b/target-arm/kvm.c index 746ae02..f4a835d 100644 --- a/target-arm/kvm.c +++ b/target-arm/kvm.c @@ -162,6 +162,13 @@ int kvm_arch_init_vcpu(CPUState *cs) goto out; } + /* Save a copy of the initial register values so that we can + * feed it back to the kernel on VCPU reset. + */ + cpu->cpreg_reset_values = g_memdup(cpu->cpreg_values, + cpu->cpreg_array_len * + sizeof(cpu->cpreg_values[0])); + out: g_free(rlp); return ret; @@ -603,6 +610,15 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) void kvm_arch_reset_vcpu(CPUState *cs) { + /* Feed the kernel back its initial register state */ + ARMCPU *cpu = ARM_CPU(cs); + + memmove(cpu->cpreg_values, cpu->cpreg_reset_values, + cpu->cpreg_array_len * sizeof(cpu->cpreg_values[0])); + + if (!write_list_to_kvmstate(cpu)) { + abort(); + } } bool kvm_arch_stop_on_emulation_error(CPUState *cs)