From patchwork Mon Feb 11 01:08:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 157964 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2069849jaa; Sun, 10 Feb 2019 17:32:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IboJ1IPvS0TwtNaWiDqY64cW5/gwQExFhXdjOljSGJYnzBc1fJEOqqpa4aPTx/+qZMhXrSY X-Received: by 2002:adf:f848:: with SMTP id d8mr27066081wrq.178.1549848754383; Sun, 10 Feb 2019 17:32:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549848754; cv=none; d=google.com; s=arc-20160816; b=T3GU8u5NAWzYr5mgCeTmA3N1jg9N4s5xkLZ+CdmKYOqqpm5e1sUSqrZdXEpPJJrvoc 6vt5FRKRuDWrdLi/AV/+Ers4Tx9h2iMNIX3ovv2PL36Fd+cCRyqyEPMEiZOmRu1wdlnl aBRQq+49RKIFpkb4vk4zSscd5/+7XZhyMwOD+q9gzUtou6fY3An/pnQiGZhQTiwWOFJT Kme0gBFBvUwInmjLLpA5R0hAuyGrf/+DjhjtblRlUk6BrUQ0s+MaDnwzRtVY/17GNg1e 9jts8D8A9ORnxmA6Le9lpV+J8J/p+JXHAiOghcIRkUF5m/2qXvX7rC8qwPXYBlpD9OL0 SeMg== 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=1ThSYlTjjjdful+PEa+IzVjavr7hehgRai0NxwGpzTA=; b=K3R7rXQlYmcm6JuvkcNeQ2u/ZQPobtJN5sw2a+DYUfzuYA2DEOIdERyofS6z/SXvpV QHkPW/Y3CehKw6e+d9vjf2qpURhJ6+wM+nODSINFq1SIgbfUjIyTZ2VxCn8PzL3Z5bOO mif4cFqEhtHawrx4/Pucf6K7Bm4sq4PEZam+UjiwjQXXtvW57UoXx8AnsD8WTGpeFy2x 4SYNQSKvrBN+t2QYa5WQEURMusEM16dpF5FuAl3wnfCp+m7zSJ3+2JWW8eNtp3GKarFc 6Gw0IUCHqOKp5hEL5HhcfaibjWYNln95uFbESgjtmzJZDVmRfCZurbwwK0PCEuw7b1nB z70w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lb8pLBzY; 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 p17si6147416wmc.93.2019.02.10.17.32.34 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 10 Feb 2019 17:32:34 -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=lb8pLBzY; 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]:42450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gt0SX-00078M-9s for patch@linaro.org; Sun, 10 Feb 2019 20:32:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gt05z-000611-DO for qemu-devel@nongnu.org; Sun, 10 Feb 2019 20:09:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gt05t-0000CE-E9 for qemu-devel@nongnu.org; Sun, 10 Feb 2019 20:09:15 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:37846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gt05s-0008KR-Vi for qemu-devel@nongnu.org; Sun, 10 Feb 2019 20:09:09 -0500 Received: by mail-pl1-x643.google.com with SMTP id b5so4516159plr.4 for ; Sun, 10 Feb 2019 17:08:56 -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=1ThSYlTjjjdful+PEa+IzVjavr7hehgRai0NxwGpzTA=; b=lb8pLBzY99qbbnUezoxVC8+N1IJ7AAi2fNowxzt9sV/FSUWgss64EUFGWgDrW3176P 7AU9xlHugcY9U+JJhBHxw0gL96iVsAmdi+QWAGXIGSdhO29dPUuwcUTTrfQ5a7DPYGLV dPdWLruaK4KfivPHZ35kyGllIEAJhoa8CGGt665Ae9wrnVcJ6MkmjwGokxhEfjaQZrXa cory593DEWqeNGx17URLtv7Ej0nnNwK0d9r02xxyz/gVQyHoEaTdnFHGTmcABGk5bwz1 UzJ+tcfRahzgTzozABie++4bZo0XL8EsGrCKTy4MBTu+2II9sEMd02Unqw1roPAkVY/k deYw== 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=1ThSYlTjjjdful+PEa+IzVjavr7hehgRai0NxwGpzTA=; b=kjLXM/Iw1Z3M6jj9/V6ple5F+tLb4Vz1316Pi5OGMFr+rQFIThAGwoeBfYkSJ6h5wU AdFKd69zYBZBmnwpHFU3GyQZ43AMHMcLvSL/Od9fYvmIUadykpZe83Z3+f39a2/TJd1e 8Rtosf36fnf10tQSbxHnuc1BvfZEgnWHz13ng7ptwsWpNjGYx9yubI172tYtX0kQhzvp TjLatW74NOWhV0q6CgKfai0Hi1CeRxrF2PEfYuUxRiQybxJwiCfMOCIAb21qPye+42Yo IRSQTcFQ3fki1whhhVvc7RxFEAgP710btsl7pxJpA5KVMYS0tSjqYkMr7esFPiTJAVIG NZow== X-Gm-Message-State: AHQUAuadS3GwHo0d276AmUqx3/ugK1MjDY61H3Nab+ClVBjlmBiIH7YK IrgvJq3hjvQzR+JmGnOcFHVStUihZOA= X-Received: by 2002:a17:902:8bc6:: with SMTP id r6mr34676795plo.67.1549847335170; Sun, 10 Feb 2019 17:08:55 -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 g14sm17177630pfg.27.2019.02.10.17.08.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Feb 2019 17:08:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 10 Feb 2019 17:08:21 -0800 Message-Id: <20190211010829.29869-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190211010829.29869-1-richard.henderson@linaro.org> References: <20190211010829.29869-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::643 Subject: [Qemu-devel] [PATCH v2 18/26] 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. --- target/arm/cpu.h | 4 +++- target/arm/helper-a64.h | 1 + target/arm/helper.c | 16 ++++++++++++++++ target/arm/mte_helper.c | 26 ++++++++++++++++++++++++++ target/arm/translate-a64.c | 9 +++++++++ 5 files changed, 55 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 a00364fb4c..4ad900d36e 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -113,3 +113,4 @@ DEF_HELPER_FLAGS_2(stg, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_2(st2g, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_2(stg_parallel, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_2(st2g_parallel, TCG_CALL_NO_WG, i64, env, 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 74bace81e4..9fac3628e5 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5820,6 +5820,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 13befdbf86..93f7cccee2 100644 --- a/target/arm/mte_helper.c +++ b/target/arm/mte_helper.c @@ -386,3 +386,29 @@ uint64_t HELPER(st2g_parallel)(CPUARMState *env, uint64_t ptr) { return do_st2g(env, ptr, GETPC(), store_tag1_parallel); } + +void HELPER(dc_gva)(CPUARMState *env, uint64_t ptr) +{ + ARMCPU *cpu = arm_env_get_cpu(env); + int el = arm_current_el(env); + uint64_t sctlr = arm_sctlr(env, el); + size_t blocklen = 4 << cpu->dcz_blocksize; + 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. */ + if (!mem || !allocation_tag_access_enabled(env, el, sctlr)) { + return; + } + + rtag = allocation_tag_from_addr(ptr); + rtag |= rtag << 4; + + assert(blocklen % (2 << LOG2_TAG_GRANULE) == 0); + memset(mem, rtag, blocklen / (2 << LOG2_TAG_GRANULE)); +} diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 9bd68d522c..a3bd2e27ef 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1811,6 +1811,15 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, tcg_rt = cpu_reg(s, rt); gen_helper_dc_zva(cpu_env, tcg_rt); return; + case ARM_CP_DC_GVA: + tcg_rt = cpu_reg(s, rt); + gen_helper_dc_gva(cpu_env, tcg_rt); + return; + case ARM_CP_DC_GZVA: + tcg_rt = cpu_reg(s, rt); + gen_helper_dc_zva(cpu_env, tcg_rt); + gen_helper_dc_gva(cpu_env, tcg_rt); + return; default: break; }