From patchwork Sun Feb 11 20:58:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 127914 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2622840ljc; Sun, 11 Feb 2018 13:05:25 -0800 (PST) X-Google-Smtp-Source: AH8x226cf8Q7n5P3VgPe2pUH/k7w3xAY/v/nXa6cnPLQrp+26ZXBo0svcCaSEhdNTkbkZ8vDRpfb X-Received: by 10.129.57.7 with SMTP id g7mr6466154ywa.300.1518383125042; Sun, 11 Feb 2018 13:05:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518383125; cv=none; d=google.com; s=arc-20160816; b=sRjcDOiDzPr8RziAGCFS3mLqfVlrQgT9UzDNHPSO2CcFoIEyQPfJxXRjMGeoluVEbJ O2O4eHr/fcmH1ZBFKvUM3ErqzsDoEpuP6h50MI0f8ijT2gxmX5375YPKmVfFwJhdboZo T+UDi6+zTN0rXTvYN/76rCRv8bfYQ/4i7h26bk+gU0/sAfKQX3JKQujZ1nXzF7GZJG2w Hg6SYOqPzaERLY+ECbl4ELaI9fAoR3kTsgnc3mY//4QFCZ7M4kLkjEg9LdZgcDnBHcCo rFYnDTFtXYVRIvP3fHHmUXxxfX9WkYUmHww+x3nlH7O7gY80nGAbAtCtYqjscNn0aRYT Zl1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=db7o6VMgdo08ugsOkXJ4Br6qKJbdNpL9zH2Gp3+8vaw=; b=vOI146JojOy8cWMkgquie6FDz4qlSwdTK1hnF9239UkpYLle+/Ut5Cni615/2cskRL /11YFhaQVVxHDqoktSPMC4EypzKPZ4xEbaOlVOcXNfeJtpwXLu874FUpqY/+R1K+kHFY YDr6stn5fimAXy5uEk3C4VLjs+WjnGESaIoa2PsFj8lbD/aLcX52XMjAYnn/DGvidEci N2y9DdUu1YL8qj10+AuIVN8nUZ1BZu/0qsG2hy4D+N+AJ6yi0o4zTFvsR/PvLcmo+CIF 97L7nc6hTDRfLZKxnoLLaVD4jXcikE3DQ4XmYjTVDIkqrbXbGgXG3NANeY+gS/f9LKZs RWWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dF1sML3v; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j129si1286893ywe.198.2018.02.11.13.05.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 11 Feb 2018 13:05:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dF1sML3v; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekyoO-0002mp-GF for patch@linaro.org; Sun, 11 Feb 2018 16:05:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ekyi9-0006l0-Cu for qemu-devel@nongnu.org; Sun, 11 Feb 2018 15:58:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ekyi7-0004Af-NL for qemu-devel@nongnu.org; Sun, 11 Feb 2018 15:58:57 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:36566) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ekyi7-00048l-GU for qemu-devel@nongnu.org; Sun, 11 Feb 2018 15:58:55 -0500 Received: by mail-pg0-x243.google.com with SMTP id j9so5072929pgv.3 for ; Sun, 11 Feb 2018 12:58:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=db7o6VMgdo08ugsOkXJ4Br6qKJbdNpL9zH2Gp3+8vaw=; b=dF1sML3vr/csfHJSssQQ0cB9ZccsJgvF75xdElASwiNpLIwcXEpzU+h7wlf8InzN0I sGNElnWxT7oQ2D9RsrdFUZUpEuY8rdsyAhmtbvBF6rtimblY7g6+Gw8SICzqrGRowlCY nfLl32aqy2MyBsezfYt+tYwJqNoxYFuHFrkJI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=db7o6VMgdo08ugsOkXJ4Br6qKJbdNpL9zH2Gp3+8vaw=; b=J/Z5Y4Tr5hpoyY66J4JyRiE8ywP6uDvLI2vEBixcXK7gtrqXoL60wg/KsXqZip/e5o lNPIpbUsg2qDmkX76j7MxxoHE3+v8oDtUh+7WZCHAw90NIJaEyme8kK4gYT3nyrikzG0 OoqLOZgzO8cKXnCC5fJ2WPMug38/Pljf7JHcxWcDKp6ivPfxjURVlQpEBSQq2bG6nlv7 wdLIiA8QUYLpT2v3Y5BDDxilV1oSXvJwTOSu1bj3izyz/fQgWDPQCdlB6DYz49JDKCcG QO/IDgSdbKDztRiQBb3a2VuFCd3T+zN5O2wkNQZn7SdcwofeUZ1CtyrN+3XK57lINyO0 Wl8Q== X-Gm-Message-State: APf1xPAczcuRi3CZY+V6LP2oN+iBckBbWoESrhmNquBV03ELU+SZVJhn c+AcVPAuyEurbQ6Yul3Pr3U3Z9mA+iY= X-Received: by 10.99.147.72 with SMTP id w8mr7417602pgm.300.1518382733941; Sun, 11 Feb 2018 12:58:53 -0800 (PST) Received: from cloudburst.twiddle.net (174-21-6-47.tukw.qwest.net. [174.21.6.47]) by smtp.gmail.com with ESMTPSA id y129sm8850354pgb.27.2018.02.11.12.58.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 11 Feb 2018 12:58:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 11 Feb 2018 12:58:43 -0800 Message-Id: <20180211205848.4568-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180211205848.4568-1-richard.henderson@linaro.org> References: <20180211205848.4568-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v2 2/7] target/arm: Enforce FP access to FPCR/FPSR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/cpu.h | 35 ++++++++++++++++++----------------- target/arm/helper.c | 6 ++++-- target/arm/translate-a64.c | 3 +++ 3 files changed, 25 insertions(+), 19 deletions(-) -- 2.14.3 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 521444a5a1..e966a57f8a 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1714,7 +1714,7 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) } /* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a - * special-behaviour cp reg and bits [15..8] indicate what behaviour + * special-behaviour cp reg and bits [11..8] indicate what behaviour * it has. Otherwise it is a simple cp reg, where CONST indicates that * TCG can assume the value to be constant (ie load at translate time) * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END @@ -1735,24 +1735,25 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) * 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 -#define ARM_CP_64BIT 4 -#define ARM_CP_SUPPRESS_TB_END 8 -#define ARM_CP_OVERRIDE 16 -#define ARM_CP_ALIAS 32 -#define ARM_CP_IO 64 -#define ARM_CP_NO_RAW 128 -#define ARM_CP_NOP (ARM_CP_SPECIAL | (1 << 8)) -#define ARM_CP_WFI (ARM_CP_SPECIAL | (2 << 8)) -#define ARM_CP_NZCV (ARM_CP_SPECIAL | (3 << 8)) -#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | (4 << 8)) -#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | (5 << 8)) -#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA +#define ARM_CP_SPECIAL 0x0001 +#define ARM_CP_CONST 0x0002 +#define ARM_CP_64BIT 0x0004 +#define ARM_CP_SUPPRESS_TB_END 0x0008 +#define ARM_CP_OVERRIDE 0x0010 +#define ARM_CP_ALIAS 0x0020 +#define ARM_CP_IO 0x0040 +#define ARM_CP_NO_RAW 0x0080 +#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) +#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) +#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) +#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) +#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) +#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA +#define ARM_CP_FPU 0x1000 /* Used only as a terminator for ARMCPRegInfo lists */ -#define ARM_CP_SENTINEL 0xffff +#define ARM_CP_SENTINEL 0xffff /* Mask of only the flag bits in a type field */ -#define ARM_CP_FLAG_MASK 0xff +#define ARM_CP_FLAG_MASK 0x10ff /* Valid values for ARMCPRegInfo state field, indicating which of * the AArch32 and AArch64 execution states this register is visible in. diff --git a/target/arm/helper.c b/target/arm/helper.c index 4b102ec356..d41fb8371f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3356,10 +3356,12 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .writefn = aa64_daif_write, .resetfn = arm_cp_reset_ignore }, { .name = "FPCR", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .opc2 = 0, .crn = 4, .crm = 4, - .access = PL0_RW, .readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write }, + .access = PL0_RW, .type = ARM_CP_FPU, + .readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write }, { .name = "FPSR", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 4, .crm = 4, - .access = PL0_RW, .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write }, + .access = PL0_RW, .type = ARM_CP_FPU, + .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write }, { .name = "DCZID_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .opc2 = 7, .crn = 0, .crm = 0, .access = PL0_R, .type = ARM_CP_NO_RAW, diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index fb1a4cb532..89f50558a7 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1631,6 +1631,9 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, default: break; } + if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) { + return; + } if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { gen_io_start();