From patchwork Fri May 17 13:23:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 17026 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 26389238F0 for ; Fri, 17 May 2013 13:24:48 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id a11sf5714809qen.4 for ; Fri, 17 May 2013 06:24:06 -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=xHNJD6iMX1rbx8kVZ9BdjUCByw4Ty8uZ132H3Eqk7V4=; b=NLhQ3IllLkTz8Afjlon0y+0E0cJaA61puv80EIvMbqmdpS+8oenyf1UDcJTqclPWeL X3SNFZdqhM8Pt3LZ4r4qiz1Tu8ECjhpv6uJTx6gD+R/k3WZGCjtfB4JpXjtoqOcgobu8 OiUPXNBkecdZFEBhm86WrfAVGA899UZ9RXUpH6AatPC/qR7MwVmduoYmQ6zFKyBral3r 449Wu/MJQoRjV5AZGDVHuA+tNrWwveHpMI/5SIvJ+q7dl1jBPEpCWzDa5KB/vWBOlCbR 9FxClLZS2ubJmMd2mFycNRdwbszwyV4PdhSCLFbmHoGFSGEw+SUflTJTd/aYE++N13qF erSA== X-Received: by 10.236.133.235 with SMTP id q71mr9492686yhi.13.1368797046710; Fri, 17 May 2013 06:24:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.120.193 with SMTP id le1ls662276qeb.66.gmail; Fri, 17 May 2013 06:24:06 -0700 (PDT) X-Received: by 10.58.173.36 with SMTP id bh4mr30159690vec.9.1368797046551; Fri, 17 May 2013 06:24:06 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id sa4si5826499vdc.88.2013.05.17.06.24.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 May 2013 06:24:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id ib11so537099vcb.36 for ; Fri, 17 May 2013 06:24:06 -0700 (PDT) X-Received: by 10.52.233.34 with SMTP id tt2mr25060603vdc.70.1368797046321; Fri, 17 May 2013 06:24:06 -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 c10csp109537vcs; Fri, 17 May 2013 06:24:05 -0700 (PDT) X-Received: by 10.204.186.67 with SMTP id cr3mr16198782bkb.14.1368797043142; Fri, 17 May 2013 06:24:03 -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 rl7si2958528bkb.6.2013.05.17.06.24.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 17 May 2013 06:24:02 -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 1UdKdZ-00071b-Ry; Fri, 17 May 2013 14:23:57 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Juan Quintela , Andre Przywara , kvmarm@lists.cs.columbia.edu Subject: [PATCH 2/7] target-arm: Add raw_readfn and raw_writefn to ARMCPRegInfo Date: Fri, 17 May 2013 14:23:52 +0100 Message-Id: <1368797037-26976-3-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: ALoCoQm/B/OKK79dN+GUF9bKQ4ZsVoVImFisMWSzhNnm7p8yaUIM+8pLKBZTZ0qWhi8rVh8syDjl X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.177 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. */