From patchwork Mon Jun 3 13:47:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 17477 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EE7BE238F2 for ; Mon, 3 Jun 2013 13:47:29 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id ha11sf4299496vcb.8 for ; Mon, 03 Jun 2013 06:47:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to: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=NNQa74NaC2CzcCgdyb1qgY6Grgi+F/BlQ2ch+o2L5H64jTbvjgf0ILF8kF1fV7hHKW x4G+YV7Y/bgYWpDKZx82Zwxzlk4eAsL1vBfp6E7T443N1cN+14PDhkIMWLne4ZqcoJId 0fG4qO/+/3wtu0z18cb5ZeUZriCMZw21PibCYwjO11avJeSRPG3T6OR9C3thjS3drqjs ZqdbsAjmvhZMzVtEWc3HX11wBXwFCVb2orZ6wErQXPGa8B7u6Ge6CsRXVU6ehf5tJFp/ 4PIaxrRq5mFVp84+V/VCw59+V3iss/JmesSbP0rh1TWY+LWoAIL9RdroteYKsQPr7KwF Osdg== X-Received: by 10.236.135.168 with SMTP id u28mr788146yhi.36.1370267249716; Mon, 03 Jun 2013 06:47:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.88.42 with SMTP id bd10ls1728861qeb.16.gmail; Mon, 03 Jun 2013 06:47:29 -0700 (PDT) X-Received: by 10.52.170.148 with SMTP id am20mr14308932vdc.75.1370267249549; Mon, 03 Jun 2013 06:47:29 -0700 (PDT) Received: from mail-vb0-x22d.google.com (mail-vb0-x22d.google.com [2607:f8b0:400c:c02::22d]) by mx.google.com with ESMTPS id p8si35382833vdv.70.2013.06.03.06.47.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Jun 2013 06:47:29 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22d 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::22d; Received: by mail-vb0-f45.google.com with SMTP id 12so2647099vbf.32 for ; Mon, 03 Jun 2013 06:47:29 -0700 (PDT) X-Received: by 10.52.36.115 with SMTP id p19mr14250972vdj.8.1370267249226; Mon, 03 Jun 2013 06:47:29 -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.10.206 with SMTP id pb14csp79338vcb; Mon, 3 Jun 2013 06:47:28 -0700 (PDT) X-Received: by 10.14.122.70 with SMTP id s46mr13760014eeh.100.1370267247584; Mon, 03 Jun 2013 06:47:27 -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 i44si6879771eew.7.2013.06.03.06.47.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Jun 2013 06:47:27 -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 1UjV6U-0006iJ-4S; Mon, 03 Jun 2013 14:47:18 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Juan Quintela , Andre Przywara , kvmarm@lists.cs.columbia.edu, Christoffer Dall , kvm@vger.kernel.org Subject: [PATCH v2 6/7] target-arm: Reinitialize all KVM VCPU registers on reset Date: Mon, 3 Jun 2013 14:47:16 +0100 Message-Id: <1370267237-25772-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1370267237-25772-1-git-send-email-peter.maydell@linaro.org> References: <1370267237-25772-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQk/S+HYZ/k1UaHlhVZPELFYoqoDeEOineoak46wIqPgDoLAxypm0eDEO5uJldAbrarf03op X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22d 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)