From patchwork Mon Feb 11 23:52:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 158053 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3212336jaa; Mon, 11 Feb 2019 16:10:00 -0800 (PST) X-Google-Smtp-Source: AHgI3IbgWY+i/0/bt4SRX4REUfEE0wZrHolJ40swP2IuWBs6a0t2p/wSvSInR/sZHHDl3fdJrMEi X-Received: by 2002:a25:258f:: with SMTP id l137mr694324ybl.416.1549930200559; Mon, 11 Feb 2019 16:10:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549930200; cv=none; d=google.com; s=arc-20160816; b=He/iF6Mfiu0LIJQcmz7ZTlZExfoFKHL0DPBJI2tpHaB13tPs7cSrbyVxFGhvkNeXWP LYRBhTPUSSwJuaRbf25WqHUIEq8Mg08+A+aHC0YkRBF4udSvdxNqZiCVowVqEACrdI5I cDzARkeesefuFqwunrXsmZ2BXMuDzpcBON39Jy/gRvCMN7pA2G2gyjLopzHTFoZuEefc zETwfnhcZU57P89WvubkXSSwU/CLfOK1qdZva7WyTIaSkmvPQpDJ3hYqSep9/z28rmGY zasU1PgaJ2C9eFpyCnc3NZrNeKNpVL3ghHfLmcgeBlXUB3hl+O7mDq8Em9B1wn7vh+H0 X2mQ== 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; bh=u1cP8m0OoSVsqCjKblIhCfU4wnhzJWGLVFK+17Qjpco=; b=dQP5g2k7biQHXniadH3NgNUfwxj8uLaQiuEZOR+YTIG9WCBBtSVqb/atYpWxnhZSsB f5EK1uDaKGOJYF1IZ0/DniZPNshCkudJ+VCY9o2fQU5aXAU+2xnD5kzDE79PfxZTlkDH 1h9HUk6xk3ed8EwfN5vYfckOTGLkk04tt433KgCcMZo8kL8EESqGm9q+4Yrk8gqQ5Wwo y6eIvk0zAtzG62xQIdg+ZL8c0sA2i1sIlPDVSPHxIdmxxXPdtRNIWhXA2gCXdu+r6z8t h4GnjoZQUT8h1kKCRXiXTwHPa2zbw99GwpSwJ4Z+2+CKoy89XdNBGKqnPnFhyKM8FA3Z Fgaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ljZlRPnZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id x6si6589647ybj.112.2019.02.11.16.10.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Feb 2019 16:10:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ljZlRPnZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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 ([127.0.0.1]:58376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtLeB-0000Qm-TL for patch@linaro.org; Mon, 11 Feb 2019 19:09:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtLOc-0005lL-2t for qemu-devel@nongnu.org; Mon, 11 Feb 2019 18:53:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtLOK-0004jO-JV for qemu-devel@nongnu.org; Mon, 11 Feb 2019 18:53:43 -0500 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:45169) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtLOJ-0004Y1-BB for qemu-devel@nongnu.org; Mon, 11 Feb 2019 18:53:35 -0500 Received: by mail-pg1-x541.google.com with SMTP id y4so303176pgc.12 for ; Mon, 11 Feb 2019 15:53:28 -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=u1cP8m0OoSVsqCjKblIhCfU4wnhzJWGLVFK+17Qjpco=; b=ljZlRPnZc5Xgga4f/oPdQ6fhBQ0dMP0lxj4VVVKhm12mdJCPwVmg3RWl5ny5GFhvSG 262eKQRoIcwwx7Y/qQWzpZvpCktIh6faDX5jRettMV0MY+8smzJH/RvqlwyeJ/8OdsHj ZYGKMXA6G0swuF38J+NlXS8UixfzfQjyMB5rz0pBGv6HLplEURn09tjNJgVfBo3l2U7v uPBQ8Ssbje1FjD7uoZBsdIXf3hESSulH0dxQlLB45UrjJi8Yhc744o6cok6k/JbMUA5j bmoZ0nGtNFsjyqUQcogqiypMWHAiU7uuBaiM1e+GDuE5/iz/2piNP2HvTADx7o+EH0Uc ogcQ== 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=u1cP8m0OoSVsqCjKblIhCfU4wnhzJWGLVFK+17Qjpco=; b=IZC/qyo9DLkAX7PAJsixakIFOuQmcL0aZkUGKIOpcN/8Ne/ItilFl8wP0ALFbVAvYW XZWU75V8V1zD6uMab8qWhNTrv8pizfe1RSW4HcW2AHKHuqwf2tNjw2oDUIZaE0I8DEby Hm9Sp1HhwJYHfUwRRx9iJnCZSJRx1JYOVjby2OWphUc4omS6tIL+GSGZbvYLe6ZQEZyA fkpCGPlYwRQf1q5HrgeN7VOKzNRE5w/hoC8ayWzRCt9QR9vv6uaPYdDz9NRNlLMkj/2v nD9ozsSJ4fDRLveM+ixziMjbgDKb6gU1CSSVtpwwTCKanPO7QYrLhFYHtzXanOhLCzN1 S19w== X-Gm-Message-State: AHQUAub5QkhvvkBSm2BCJo8BbzXZ47C8Ao8pXd2tIxpDj2+DV7QUjf6e wm+T8WYlE4/h7RiB51/J0oifcMiMCVI= X-Received: by 2002:a63:f412:: with SMTP id g18mr852785pgi.262.1549929207334; Mon, 11 Feb 2019 15:53:27 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-188-82.tukw.qwest.net. [97.113.188.82]) by smtp.gmail.com with ESMTPSA id c4sm11861031pgq.85.2019.02.11.15.53.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Feb 2019 15:53:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 15:52:50 -0800 Message-Id: <20190211235258.542-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190211235258.542-1-richard.henderson@linaro.org> References: <20190211235258.542-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v3 20/28] target/arm: Implement data cache set allocation tags 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" This is DC GVA and DC GZVA. Signed-off-by: Richard Henderson --- v2: Use allocation_tag_mem + memset. v3: Require pre-cleaned addresses. --- target/arm/cpu.h | 4 +++- target/arm/helper-a64.h | 1 + target/arm/helper.c | 16 ++++++++++++++++ target/arm/mte_helper.c | 28 ++++++++++++++++++++++++++++ target/arm/translate-a64.c | 9 +++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) -- 2.17.2 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 74633a7a78..ca32939483 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2160,7 +2160,9 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) #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_DC_GVA (ARM_CP_SPECIAL | 0x0600) +#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) +#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA #define ARM_CP_FPU 0x1000 #define ARM_CP_SVE 0x2000 #define ARM_CP_NO_GDB 0x4000 diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 5bcdfcf81b..ec4e7f7cf5 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -117,3 +117,4 @@ DEF_HELPER_FLAGS_3(st2g_parallel, TCG_CALL_NO_WG, void, env, i64, i64) DEF_HELPER_FLAGS_2(ldgm, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_3(stgm, TCG_CALL_NO_WG, void, env, i64, i64) DEF_HELPER_FLAGS_3(stzgm, TCG_CALL_NO_WG, void, env, i64, i64) +DEF_HELPER_FLAGS_2(dc_gva, TCG_CALL_NO_RWG, void, env, i64) diff --git a/target/arm/helper.c b/target/arm/helper.c index ed1b258497..f17e045706 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5841,6 +5841,22 @@ static const ARMCPRegInfo mte_reginfo[] = { { .name = "CIGDVAC", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 5, .type = ARM_CP_NOP, .access = PL1_W }, + { .name = "GVA", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 4, .opc2 = 3, + .access = PL0_W, .type = ARM_CP_DC_GVA, +#ifndef CONFIG_USER_ONLY + /* Avoid overhead of an access check that always passes in user-mode */ + .accessfn = aa64_zva_access, +#endif + }, + { .name = "GZVA", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 4, .opc2 = 4, + .access = PL0_W, .type = ARM_CP_DC_GZVA, +#ifndef CONFIG_USER_ONLY + /* Avoid overhead of an access check that always passes in user-mode */ + .accessfn = aa64_zva_access, +#endif + }, REGINFO_SENTINEL }; #endif diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c index afa4c26535..6d0f82eb99 100644 --- a/target/arm/mte_helper.c +++ b/target/arm/mte_helper.c @@ -473,3 +473,31 @@ void HELPER(stzgm)(CPUARMState *env, uint64_t ptr, uint64_t val) } } } + +void HELPER(dc_gva)(CPUARMState *env, uint64_t ptr) +{ + ARMCPU *cpu = arm_env_get_cpu(env); + size_t blocklen = 4 << cpu->dcz_blocksize; + int el; + uint64_t sctlr; + uint8_t *mem; + int rtag; + + ptr = QEMU_ALIGN_DOWN(ptr, blocklen); + + /* Trap if accessing an invalid page. */ + mem = allocation_tag_mem(env, ptr, true, GETPC()); + + /* No action if page does not support tags, or if access is disabled. */ + el = arm_current_el(env); + sctlr = arm_sctlr(env, el); + if (!mem || !allocation_tag_access_enabled(env, el, sctlr)) { + return; + } + + rtag = allocation_tag_from_addr(ptr); + rtag |= rtag << 4; + + assert(QEMU_IS_ALIGNED(blocklen, 2 * TAG_GRANULE)); + memset(mem, rtag, blocklen / (2 * TAG_GRANULE)); +} diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 9e7afa571d..1bab7ea211 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1818,6 +1818,15 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, tcg_rt = clean_data_tbi(s, cpu_reg(s, rt), false); gen_helper_dc_zva(cpu_env, tcg_rt); return; + case ARM_CP_DC_GVA: + tcg_rt = clean_data_tbi(s, cpu_reg(s, rt), false); + gen_helper_dc_gva(cpu_env, tcg_rt); + return; + case ARM_CP_DC_GZVA: + tcg_rt = clean_data_tbi(s, cpu_reg(s, rt), false); + gen_helper_dc_zva(cpu_env, tcg_rt); + gen_helper_dc_gva(cpu_env, tcg_rt); + return; default: break; }