Received: by 2002:a19:f015:0:0:0:0:0 with SMTP id p21csp2173930lfc; Fri, 13 Mar 2020 07:00:55 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvL4ODXwNOfHjNn5k5wFwy4Wb/FYO9/fFnA9CZNiq6RgaHEVmb36ZkdcmfUZRnLK9NciB27 X-Received: by 2002:a05:6214:b23:: with SMTP id w3mr12743615qvj.181.1584108054949; Fri, 13 Mar 2020 07:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584108054; cv=none; d=google.com; s=arc-20160816; b=OKC4vi0Onp6PDq65Bz6KjqAf1/WK6+wafegYiWu3N3Tr3fZFOpX7qjit7IMWgPGIWl ai+lPjgdu889tSBPrwBC0DcAvtRrM17K8eAglRC5zDODAFaUesuRUD2Bbn7u+8mdwt2L oRdJIONcBJf44M3ZJcEs0nVAVPanpbWZskXx9ESHNn7/IKsatdMpqi3IceeyL33bW/f7 9au3pUUYf0RERbJE3rZ7wuajvFtAXh3N+4NdnDXCGj/2Wn4lwfKfl5+IwfnB7PeoBtRb hDotJrl1kZRmxjwwCQiT68MF/Qwzw0/kEpPMNZtsWR1EhefL4TI9nhH+2idPMb+5aNAd LeVA== 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:content-transfer-encoding :mime-version:message-id:date:subject:to:from; bh=swlkJa/C/Z/SKR0JYjONLLCfcw0Yn4XHRV7dX2+LlXw=; b=buMEWWWJ1xE67Hsfc7hVFIhrJy3pMQnHo2X5fuw6Q/3sHUoWB+B7Pz07XdDQSrpoCJ DH/vuLYW/erQD+WBHIGbxeuANcaoZZ6mUUwQDC0+Wfn6lGxmNa4bMxIsyCEnti41Q9zd HfaPF8dxpHc0HMNLy4IlI74CEj4FdoLHdb35MMlFj+QqX4OaIeQOCHRHDqwd9eDYqvpK G1ND348kE0JZvqEzmyaowwJHZoU69Ggn6E4yQoE8mMh9GWy7YuCn5qbtsXQ6BPgEsrJr 67uDkjb0kKVD2SdaNEH5fNXWEbxE3WWFyFpv2R5KWBvZzLMm/5IfsRnXXid6XeyroGju Mpew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g7si2117225qtr.388.2020.03.13.07.00.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Mar 2020 07:00:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1]:59318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCkru-0005bv-9H for alex.bennee@linaro.org; Fri, 13 Mar 2020 10:00:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42703) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCkrX-0005Xf-Cq for qemu-arm@nongnu.org; Fri, 13 Mar 2020 10:00:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCkrV-0000ls-TV for qemu-arm@nongnu.org; Fri, 13 Mar 2020 10:00:31 -0400 Received: from poy.remlab.net ([2001:41d0:2:5a1a::]:49728 helo=ns207790.ip-94-23-215.eu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jCkrV-0000fY-K3; Fri, 13 Mar 2020 10:00:29 -0400 Received: from basile.remlab.net (ip6-localhost [IPv6:::1]) by ns207790.ip-94-23-215.eu (Postfix) with ESMTP id 0419B5FDA7; Fri, 13 Mar 2020 15:00:24 +0100 (CET) From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= To: qemu-arm@nongnu.org Subject: [PATCH 4/5] target/arm: MTE privileged system mode assembly Date: Fri, 13 Mar 2020 16:00:22 +0200 Message-Id: <20200313140023.83844-4-remi@remlab.net> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:41d0:2:5a1a:: X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: HAFPLmQ/ABJv From: R=C3=A9mi Denis-Courmont This adds all remaining MTE instructions for EL1, EL2 and EL3 on a processor with ID_AA64PFR1_EL1.MTE =3D=3D 1. Signed-off-by: R=C3=A9mi Denis-Courmont --- target/arm/cpu64.c | 8 +++--- target/arm/helper.c | 19 ++++++++++++++ target/arm/translate-a64.c | 52 +++++++++++++++++++++++++++++++++++--- 3 files changed, 71 insertions(+), 8 deletions(-) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index a72dfd3d98..749eb93872 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -665,13 +665,11 @@ static void aarch64_max_initfn(Object *obj) =20 t =3D cpu->isar.id_aa64pfr1; t =3D FIELD_DP64(t, ID_AA64PFR1, BT, 1); -#ifdef CONFIG_USER_ONLY - /* All MTE instructions and processor states are supported for u= ser - * mode. This corresponds to feature field value 1 (field value = 2 - * implies MemTag memory support). + /* All MTE instructions and processor states are supported. This + * corresponds to feature field value 1 (field value 2 implies M= emTag + * memory support). */ t =3D FIELD_DP64(t, ID_AA64PFR1, MTE, 1); -#endif cpu->isar.id_aa64pfr1 =3D t; =20 t =3D cpu->isar.id_aa64mmfr1; diff --git a/target/arm/helper.c b/target/arm/helper.c index dd64fcb4ef..630dc04302 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6906,10 +6906,29 @@ static const ARMCPRegInfo mte_reginfo[] =3D { .opc0 =3D 1, .opc1 =3D 3, .crn =3D 7, .crm =3D 14, .opc2 =3D 5, .access =3D PL0_W, .type =3D ARM_CP_NOP, .accessfn =3D aa64_cacheop_poc_access }, + { .name =3D "RGSR_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 1, .crm =3D 0, .opc2 =3D 5, + .access =3D PL1_RW, .fieldoffset =3D offsetof(CPUARMState, rgsr_el= 1) }, + { .name =3D "GCR_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 1, .crm =3D 0, .opc2 =3D 6, + .access =3D PL1_RW, .fieldoffset =3D offsetof(CPUARMState, gcr_el1= ) }, { .name =3D "TCO", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 3, .crn =3D 4, .crm =3D 2, .opc2 =3D 7, .access =3D PL0_RW, .type =3D ARM_CP_NO_RAW, .readfn =3D tco_read, .writefn =3D tco_write }, + { .name =3D "TFSR_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 6, .crm =3D 5, .opc2 =3D 0, + .access =3D PL1_RW, .fieldoffset =3D offsetof(CPUARMState, tfsr_el= [1]) }, + { .name =3D "TFSR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .crn =3D 6, .crm =3D 5, .opc2 =3D 0, + .access =3D PL2_RW, .type =3D ARM_CP_ALIAS, + .fieldoffset =3D offsetof(CPUARMState, tfsr_el[1]) }, + { .name =3D "TFSR_EL3", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 6, .crn =3D 6, .crm =3D 5, .opc2 =3D 0, + .access =3D PL3_RW, .fieldoffset =3D offsetof(CPUARMState, tfsr_el= [3]) }, + { .name =3D "TFSRE0_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .crn =3D 6, .crm =3D 6, .opc2 =3D 1, + .access =3D PL1_RW, .fieldoffset =3D offsetof(CPUARMState, tfsre0_= el1) }, REGINFO_SENTINEL }; #endif diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 6d86480043..9382f53794 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -2716,6 +2716,38 @@ static void disas_ld_lit(DisasContext *s, uint32_t= insn) tcg_temp_free_i64(clean_addr); } =20 +#ifndef CONFIG_USER_ONLY +static void disas_ldst_memtag_vec(DisasContext *s, int rn, int rt, + bool is_load) +{ + TCGv_i64 tcg_addr; + + if (rn =3D=3D rt) { + return; + } + + if (rn =3D=3D 31) { + gen_check_sp_alignment(s); + } + + /* The starting point between the specified address and the aligned + * address is implementation defined. We start at the aligned addres= s. + */ + tcg_addr =3D tcg_temp_new_i64(); + tcg_gen_andi_i64(tcg_addr, cpu_reg_sp(s, rn), + ~((16 * ARM_TAG_GRANULE) - 1)); + + /* In principles, memory access permissions should be checked here. = */ + if (is_load) { + tcg_gen_movi_i64(cpu_reg(s, rt), 0); + } + + tcg_gen_addi_i64(cpu_reg_sp(s, rn), tcg_addr, 16 * ARM_TAG_GRANULE); + + tcg_temp_free_i64(tcg_addr); +} +#endif + /* LDG, LDGV(EL1), ST(Z)(2)G, STGV */ static void disas_ldst_memtag(DisasContext *s, uint32_t insn) { @@ -2736,9 +2768,23 @@ static void disas_ldst_memtag(DisasContext *s, uin= t32_t insn) return; } =20 - if (op2 =3D=3D 0 && opc !=3D 1) { - unallocated_encoding(s); - return; + if (op2 =3D=3D 0) { + switch (opc) { + case 1: + break; +#ifndef CONFIG_USER_ONLY + case 2: + case 3: + if (s->current_el > 0 && offset =3D=3D 0) { + disas_ldst_memtag_vec(s, rn, rt, opc & 1); + return; + } +#endif + /* fall through */ + default: + unallocated_encoding(s); + return; + } } =20 if (rn =3D=3D 31) { --=20 2.25.1