From patchwork Mon Jun 3 13:47:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 17479 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5839F238F2 for ; Mon, 3 Jun 2013 13:47:33 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id e15sf565201vbg.4 for ; Mon, 03 Jun 2013 06:47:33 -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=xHNJD6iMX1rbx8kVZ9BdjUCByw4Ty8uZ132H3Eqk7V4=; b=dryZW37WTlu435RqpBYO5LJFpWUmFKjYT4TbYr8BGkwYHsRpqSLTRcZtirz2QHspCz gRO7aJJdg34vXpwowhaeYG48SU2oBr6uIazRcB4YBhUygAZmWR6bFHGeO6YLKK+4cRUC vXppxd3rHipYHMLBmVFpreeMXY4EKELDLZgY1bcWeyAksSf+4TNuxRgAGpdCIOXk9mji VEQmXxe+GGlNDQbXO0/HtHdw3cCg1ce4yoK++dhRufcTEYA1P9xlSI5JyBRjUQjOe1Th lTRANbLC0ADh7SuzR7+QBSlk/Jmy6uHppi4hn4cEDUA6RRfoGktpNXH5oDA18WWw1Fc6 zSEw== X-Received: by 10.236.231.10 with SMTP id k10mr12846170yhq.30.1370267253133; Mon, 03 Jun 2013 06:47:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.133 with SMTP id u5ls2189435qef.3.gmail; Mon, 03 Jun 2013 06:47:33 -0700 (PDT) X-Received: by 10.52.101.163 with SMTP id fh3mr14150427vdb.107.1370267252975; Mon, 03 Jun 2013 06:47:32 -0700 (PDT) Received: from mail-vb0-x232.google.com (mail-vb0-x232.google.com [2607:f8b0:400c:c02::232]) by mx.google.com with ESMTPS id d4si35382869vcl.20.2013.06.03.06.47.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Jun 2013 06:47:32 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::232 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::232; Received: by mail-vb0-f50.google.com with SMTP id w16so529804vbb.37 for ; Mon, 03 Jun 2013 06:47:32 -0700 (PDT) X-Received: by 10.58.106.77 with SMTP id gs13mr17040667veb.22.1370267252859; Mon, 03 Jun 2013 06:47:32 -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 pb14csp79343vcb; Mon, 3 Jun 2013 06:47:32 -0700 (PDT) X-Received: by 10.180.212.3 with SMTP id ng3mr13004206wic.22.1370267247796; 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 w7si9622768wie.31.2013.06.03.06.47.25 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 1UjV6T-0006iB-UW; Mon, 03 Jun 2013 14:47:17 +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 2/7] target-arm: Add raw_readfn and raw_writefn to ARMCPRegInfo Date: Mon, 3 Jun 2013 14:47:12 +0100 Message-Id: <1370267237-25772-3-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: ALoCoQltijzLuHSY8E/BtQeDr5lc3Jg1H0B+gAp+UL7Rks2YG3oXM4S4hMH5ekIME/GCpAO1MOjb X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::232 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: , For reading and writing register values from the kernel for KVM, we need to provide accessor functions which are guaranteed to succeed and don't impose access checks, mask out unwritable bits, etc. Define new fields raw_readfn and raw_writefn for this purpose; these only need to be provided if there is a readfn or writefn already and it is not suitable. Signed-off-by: Peter Maydell --- target-arm/cpu.h | 18 +++++++++++++++++- target-arm/helper.c | 13 +++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 737c00c..1d8eba5 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -434,19 +434,22 @@ void armv7m_nvic_complete_irq(void *opaque, int irq); * a register definition to override a previous definition for the * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the * old must have the OVERRIDE bit set. + * NO_MIGRATE indicates that this register should be ignored for migration; + * (eg because any state is accessed via some other coprocessor register). */ #define ARM_CP_SPECIAL 1 #define ARM_CP_CONST 2 #define ARM_CP_64BIT 4 #define ARM_CP_SUPPRESS_TB_END 8 #define ARM_CP_OVERRIDE 16 +#define ARM_CP_NO_MIGRATE 32 #define ARM_CP_NOP (ARM_CP_SPECIAL | (1 << 8)) #define ARM_CP_WFI (ARM_CP_SPECIAL | (2 << 8)) #define ARM_LAST_SPECIAL ARM_CP_WFI /* Used only as a terminator for ARMCPRegInfo lists */ #define ARM_CP_SENTINEL 0xffff /* Mask of only the flag bits in a type field */ -#define ARM_CP_FLAG_MASK 0x1f +#define ARM_CP_FLAG_MASK 0x3f /* Return true if cptype is a valid type field. This is used to try to * catch errors where the sentinel has been accidentally left off the end @@ -562,6 +565,19 @@ struct ARMCPRegInfo { * by fieldoffset. */ CPWriteFn *writefn; + /* Function for doing a "raw" read; used when we need to copy + * coprocessor state to the kernel for KVM or out for + * migration. This only needs to be provided if there is also a + * readfn and it makes an access permission check. + */ + CPReadFn *raw_readfn; + /* Function for doing a "raw" write; used when we need to copy KVM + * kernel coprocessor state into userspace, or for inbound + * migration. This only needs to be provided if there is also a + * writefn and it makes an access permission check or masks out + * "unwritable" bits or has write-one-to-clear or similar behaviour. + */ + CPWriteFn *raw_writefn; /* Function for resetting the register. If NULL, then reset will be done * by writing resetvalue to the field specified in fieldoffset. If * fieldoffset is 0 then no reset will be done. diff --git a/target-arm/helper.c b/target-arm/helper.c index fd055e8..2585d59 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -1392,6 +1392,19 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, r2->crm = crm; r2->opc1 = opc1; r2->opc2 = opc2; + /* By convention, for wildcarded registers only the first + * entry is used for migration; the others are marked as + * NO_MIGRATE so we don't try to transfer the register + * multiple times. Special registers (ie NOP/WFI) are + * never migratable. + */ + if ((r->type & ARM_CP_SPECIAL) || + ((r->crm == CP_ANY) && crm != 0) || + ((r->opc1 == CP_ANY) && opc1 != 0) || + ((r->opc2 == CP_ANY) && opc2 != 0)) { + r2->type |= ARM_CP_NO_MIGRATE; + } + /* Overriding of an existing definition must be explicitly * requested. */