From patchwork Tue Jul 30 17:55:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 18676 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A081A248EB for ; Tue, 30 Jul 2013 17:55:39 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id h10sf1970584vbh.1 for ; Tue, 30 Jul 2013 10:55:39 -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-removed-original-auth :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=fiIpVcWwPB4aZg53Gv8O9an+s+OmZGukHtYiEk/oot4=; b=j2IpSwr2bXADfgwNS6zpkzAtFuvCIeZ3HKIk/F1RM8h1HTc0G5eHafYsmTsmmpV94c 8KYmR8Rxzte5jjRa3/2SzCMStTitk14ViCM4+qU/D5zau0TcG736NvxE7NtBTbEnY/hU LHAYTvzc07MfgG1UyGqSRXxLBW87hvDJ59et7Wa9UFmwqtQ4EDosSWJSuabVRwyMmW9M BpLlXrjfUcr+5/8oIme8uLa55U48aMKYmjOfJ9pa6CYfcU64N+SeikHsfrCcrL1xyNFw USJEI6Mwb695g6vmXzqoq14GSvnBrEjWsYwKqspV/Zj6L0I9CAmaCZlcuEE34CpKcCmH AIew== X-Received: by 10.236.127.108 with SMTP id c72mr31425083yhi.16.1375206939290; Tue, 30 Jul 2013 10:55:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.1.78 with SMTP id 14ls296083qek.57.gmail; Tue, 30 Jul 2013 10:55:39 -0700 (PDT) X-Received: by 10.52.165.71 with SMTP id yw7mr10875689vdb.82.1375206939153; Tue, 30 Jul 2013 10:55:39 -0700 (PDT) Received: from mail-vb0-f51.google.com (mail-vb0-f51.google.com [209.85.212.51]) by mx.google.com with ESMTPS id xb6si19052266vdb.29.2013.07.30.10.55.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Jul 2013 10:55:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.51 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.51; Received: by mail-vb0-f51.google.com with SMTP id x16so2496567vbf.24 for ; Tue, 30 Jul 2013 10:55:39 -0700 (PDT) X-Received: by 10.220.173.195 with SMTP id q3mr10127343vcz.86.1375206939015; Tue, 30 Jul 2013 10:55:39 -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.11.8 with SMTP id pc8csp189222vcb; Tue, 30 Jul 2013 10:55:38 -0700 (PDT) X-Received: by 10.15.34.129 with SMTP id e1mr66023054eev.80.1375206935329; Tue, 30 Jul 2013 10:55:35 -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 47si6455004eea.181.2013.07.30.10.55.34 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 30 Jul 2013 10:55:35 -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.80) (envelope-from ) id 1V4E8z-0003vN-Gk; Tue, 30 Jul 2013 18:55:33 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH 2/4] target-arm: Support coprocessor registers which do I/O Date: Tue, 30 Jul 2013 18:55:31 +0100 Message-Id: <1375206933-15053-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1375206933-15053-1-git-send-email-peter.maydell@linaro.org> References: <1375206933-15053-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQl4zHTlAakUKRrjXsN6gettZZ+6GOuvIQyt/Qi3ZWI90xz529TyYs0sBpgiV94fP3S/1kQC X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.51 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: , Add an ARM_CP_IO flag which an ARMCPRegInfo definition can use to indicate that the register's implementation does I/O and thus its accesses need to be surrounded by gen_io_start()/gen_io_end() in order for icount to work. Most notably, cp registers which implement clocks or timers need this. Signed-off-by: Peter Maydell --- target-arm/cpu.h | 6 +++++- target-arm/translate.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index b2dc494..770a240 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -469,6 +469,9 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) * 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). + * IO indicates that this register does I/O and therefore its accesses + * need to be surrounded by gen_io_start()/gen_io_end(). In particular, + * registers which implement clocks or timers require this. */ #define ARM_CP_SPECIAL 1 #define ARM_CP_CONST 2 @@ -476,13 +479,14 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) #define ARM_CP_SUPPRESS_TB_END 8 #define ARM_CP_OVERRIDE 16 #define ARM_CP_NO_MIGRATE 32 +#define ARM_CP_IO 64 #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 0x3f +#define ARM_CP_FLAG_MASK 0x7f /* 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 diff --git a/target-arm/translate.c b/target-arm/translate.c index 6db4c50..d1e8538 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -6280,6 +6280,10 @@ static int disas_coproc_insn(CPUARMState * env, DisasContext *s, uint32_t insn) break; } + if (use_icount && (ri->type & ARM_CP_IO)) { + gen_io_start(); + } + if (isread) { /* Read */ if (is64) { @@ -6369,14 +6373,20 @@ static int disas_coproc_insn(CPUARMState * env, DisasContext *s, uint32_t insn) store_cpu_offset(tmp, ri->fieldoffset); } } + } + + if (use_icount && (ri->type & ARM_CP_IO)) { + /* I/O operations must end the TB here (whether read or write) */ + gen_io_end(); + gen_lookup_tb(s); + } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { /* We default to ending the TB on a coprocessor register write, * but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). */ - if (!(ri->type & ARM_CP_SUPPRESS_TB_END)) { - gen_lookup_tb(s); - } + gen_lookup_tb(s); } + return 0; }