From patchwork Thu Jun 26 17:16:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 32586 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EB7D7201EF for ; Thu, 26 Jun 2014 17:16:23 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf7399189yha.3 for ; Thu, 26 Jun 2014 10:16:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=WyZlE+yZcEnApRdIbSIl5qfLVtm1rtEiFJqhdXVchXs=; b=D8f8Kho9MQvXw/HSm1KpMwEXcIehboGwGtpfIiE+NkZInRIAydK6nWrX5PQjVjwzuL MubqHfFg3qGjkKwm7AEjl/O7t8Yk7DYibTwXpslYfI/eN7W7wNqF7lSrRhYs+uPBG71V f2qB7BK3XdSlc7xAnjk5NDntj6p6gt0ZvzU7EoWcSugJM9I4EQkSboxVoo9ACrY+5rKl yq5hzvHgk0zgPa43FQAIZ5iG94tNJqCPPnqkJ6Om9g99KiRyCcT95SkwtKlLd+fuC0b4 8FPGr9q+VIjFVp0JKcwtn6CVUYX4KuaNJ3lQioBX8P7d8LNpa2RzJK6op+DGRL79TOfy Jhhw== X-Gm-Message-State: ALoCoQkiugvQp7yUrLK4rkYXVxEpVo0AghRPncQzTtpx8FLfRqTlGHLr0lAFChxzoYxs90PF/sW9 X-Received: by 10.58.227.10 with SMTP id rw10mr8204828vec.39.1403802983710; Thu, 26 Jun 2014 10:16:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.70 with SMTP id q64ls298058qgd.50.gmail; Thu, 26 Jun 2014 10:16:23 -0700 (PDT) X-Received: by 10.52.129.232 with SMTP id nz8mr1406156vdb.94.1403802983600; Thu, 26 Jun 2014 10:16:23 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id wz8si4977550vdb.13.2014.06.26.10.16.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Jun 2014 10:16:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ij19so3919186vcb.9 for ; Thu, 26 Jun 2014 10:16:23 -0700 (PDT) X-Received: by 10.220.174.137 with SMTP id t9mr15115258vcz.12.1403802983428; Thu, 26 Jun 2014 10:16:23 -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.221.37.5 with SMTP id tc5csp45798vcb; Thu, 26 Jun 2014 10:16:22 -0700 (PDT) X-Received: by 10.180.77.167 with SMTP id t7mr5807210wiw.77.1403802982379; Thu, 26 Jun 2014 10:16:22 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id d5si10810780wjb.130.2014.06.26.10.16.18 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 26 Jun 2014 10:16:19 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1X0DHR-0005Qc-FW; Thu, 26 Jun 2014 18:16:13 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, kvmarm@lists.cs.columbia.edu, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Christoffer Dall Subject: [PATCH] target-arm: Implement vCPU reset via KVM_ARM_VCPU_INIT for 32-bit CPUs Date: Thu, 26 Jun 2014 18:16:13 +0100 Message-Id: <1403802973-20841-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@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.220.178 as permitted sender) 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: , Implement kvm_arm_vcpu_init() as a simple call to arm_arm_vcpu_init() (which uses the KVM_ARM_VCPU_INIT vcpu ioctl to tell the kernel to re-initialize the vCPU), rather than via the complicated code which saves a copy of the register state on first init and then writes it back to the kernel. This is much simpler and brings the 32-bit KVM code into line with the 64-bit code. Signed-off-by: Peter Maydell --- The kernel has always supported being able to call VCPU_INIT multiple times for this reset effect; I just didn't realize it was possible when I wrote the original reset code. When kvm64.c grows support for system registers we can probably coalesce the two kvm_arm_reset_cpu() functions into one. I also have a vague recollection that somebody reported that we had an actual bug in this area that this patch would fix; however I can't now find that in the mailing list archives :-( Testing appreciated: my ARMv7 box is being a bit flaky at the moment; I don't *think* the occasional weird stuff I see is the effect of this patch but it's hard to be certain. --- target-arm/cpu-qom.h | 4 ---- target-arm/kvm32.c | 19 +++++-------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h index eaee944..ee4fbb1 100644 --- a/target-arm/cpu-qom.h +++ b/target-arm/cpu-qom.h @@ -72,10 +72,6 @@ typedef struct ARMCPU { uint64_t *cpreg_indexes; /* Values of the registers (cpreg_indexes[i]'s value is cpreg_values[i]) */ uint64_t *cpreg_values; - /* 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 diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c index 068af7d..5ec4eb1 100644 --- a/target-arm/kvm32.c +++ b/target-arm/kvm32.c @@ -270,13 +270,6 @@ 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; @@ -518,11 +511,9 @@ int kvm_arch_get_registers(CPUState *cs) void kvm_arm_reset_vcpu(ARMCPU *cpu) { - /* Feed the kernel back its initial register state */ - memmove(cpu->cpreg_values, cpu->cpreg_reset_values, - cpu->cpreg_array_len * sizeof(cpu->cpreg_values[0])); - - if (!write_list_to_kvmstate(cpu)) { - abort(); - } + /* Re-init VCPU so that all registers are set to + * their respective reset values. + */ + kvm_arm_vcpu_init(CPU(cpu)); + write_kvmstate_to_list(cpu); }