From patchwork Thu Mar 12 19:42:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 184527 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp961552ile; Thu, 12 Mar 2020 12:54:36 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsdJdZa+pR42E3edv6EgKJoC/6J3kmp9qsw4+WzJK3+lX2RTA/IwlQuzvzS3ov+/eFwXLIG X-Received: by 2002:a37:9a88:: with SMTP id c130mr9485733qke.416.1584042876162; Thu, 12 Mar 2020 12:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584042876; cv=none; d=google.com; s=arc-20160816; b=Pjec7ndcs9RIbAFlk2SgJ7BJD3Mw7hnDqjeiJzvmjZNSyeN5PQ1izstQ5hideyy1mR jv+iUcsrPybTrJL0vqCGVy5UWiN4ct4L/iQ8K3sUpnxRxxplzB9NHTBgzU0DZHuvGtHK CgqA+kGej4Nd/oWAEOTfvglPVuKyhXh+DjEHI/8o36drCkRgspqoA4u6FxTbjZG03yRc IcjDt2YD+mq7FIcPVsHQZOv2kZ/Dko9uF9YX8vX+aydiu6RFlUsRPMpZvutcGyPG1fKg 3VoUE5kEHHB/p+PPDr0ENz5LmA77M99eY1amvEKWS2Z8DehImaG9VBJWkzEj9b9ExVF8 jWiw== 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:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FqxgWRxNaOrIo80/rd7EvP+ZqoigJ+ge9JbM5ILrh50=; b=XvIcOJJ6zUFwsHASzF/31m7drqrdqdF8xYbqvkuN4yacd8PdvyV9blhEW9gNIV8vOc UDbhPBaQ0iLmxPfu1MmWg/vLIjoe5VYpGBe/R2a3ivKX4I4fLAG2T7kc2ez3AjGZxdA6 Ir+lindio0Hbrmu1Vs8bRHIVTkUHMZfLIZ5NP/oeQxAcVJZZtYabdTyKFmSQdMxJ2nO9 aR31ZMxT+mZe0GvDwa0xXcq/4uaD3L77X+JzlAl01UzQZJYEHVvSDWZ+xQV5msMNQn5O jGVLH7XxvXMFpzygruzS/7WTqBhsGRrxn9hmCkwU2InorzqljUxa0O0Fi6A0SM3tSBCg GooQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K/7RAi1Q"; 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=pass (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 z10si3500851qkf.202.2020.03.12.12.54.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Mar 2020 12:54:36 -0700 (PDT) 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=pass header.i=@linaro.org header.s=google header.b="K/7RAi1Q"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCTud-0007zD-LZ for patch@linaro.org; Thu, 12 Mar 2020 15:54:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46078) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCTji-0006vp-9A for qemu-devel@nongnu.org; Thu, 12 Mar 2020 15:43:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCTjh-0002RE-4Z for qemu-devel@nongnu.org; Thu, 12 Mar 2020 15:43:18 -0400 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:53603) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jCTjg-0002QI-VM for qemu-devel@nongnu.org; Thu, 12 Mar 2020 15:43:17 -0400 Received: by mail-pj1-x1044.google.com with SMTP id l36so2968185pjb.3 for ; Thu, 12 Mar 2020 12:43:16 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=FqxgWRxNaOrIo80/rd7EvP+ZqoigJ+ge9JbM5ILrh50=; b=K/7RAi1QturA2wu+mnUAiJRDSFP6ttUS8ps8kO5kEbQcYbkkfdpiLl/sqCvp1CffMB LXFC1b95ipYR3Iq0L7trKv1BI7MZyioDSvX8Y6druJ6mBm5Sq5TEkH1QXM8ORL4b5iZg TX6vpF8s4RzuzRA2nYUO3zWV13axJExKtOEKTYqOxrSbOtzwH5lWZTlehNHJ3uJ+WRtr h3jEC/pptA3Zo4ME6xJ1gaEKbslG30rDF6Emp3yPr5MOQULRunwUSRyqSacJOR8Og4Tf ZMM2Zl6NC16F23k5rhMzU3aWodvdAPgA3Jn9NeC07HhHYo+Tem8iN/WO7+f8u2daSKEE mX6A== 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:mime-version:content-transfer-encoding; bh=FqxgWRxNaOrIo80/rd7EvP+ZqoigJ+ge9JbM5ILrh50=; b=S4kO/SFhd+G+YuNrRQWZAeA6Wcs04QKPzUvWSKTkuEy/lKaY6jJvhJB/FiGq2DB3Ph hxhTEBV1BD8bsa555KSzq7RdoOIPm9Sd65L/OAHcD2MkKhG05/W334aAvEQMHltG8nng RBY0elHy5reBCpkZQAZzalTxWiTeKI+HzEmAPnsIHQHCRMDVIbetlaZjgxEuurFs6OLt AoLR34Iey3euvFiWSr8zFoR/p650zsiQkbwa944Y1lfg3nliws3D9B914I2u3PemwXC0 ly3zeL1VdpMyakDiWdgYiObuIdG9eqKUgJKeg2gala/NcUy4BfIdYROvXOJ8TlPo41x5 RdVg== X-Gm-Message-State: ANhLgQ2UzU5Ay6FBFhO585JtB/MLdBUcLFG+Jz3KPK5jFjdq8p/OPsO9 CrjokRBcbJbxQwAuQSx5jgtXPbpQOdw= X-Received: by 2002:a17:902:7298:: with SMTP id d24mr9600552pll.134.1584042194660; Thu, 12 Mar 2020 12:43:14 -0700 (PDT) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id g69sm6824842pje.34.2020.03.12.12.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 12:43:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 40/42] target/arm: Cache the Tagged bit for a page in MemTxAttrs Date: Thu, 12 Mar 2020 12:42:17 -0700 Message-Id: <20200312194219.24406-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200312194219.24406-1-richard.henderson@linaro.org> References: <20200312194219.24406-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1044 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This "bit" is a particular value of the page's MemAttr. Signed-off-by: Richard Henderson --- v6: Test HCR_EL2.{DC,DCT}; test Stage2 attributes. --- target/arm/helper.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index b38dc74733..c272c48467 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10785,6 +10785,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, uint64_t descaddrmask; bool aarch64 = arm_el_is_aa64(env, el); bool guarded = false; + uint8_t memattr; /* TODO: * This code does not handle the different format TCR for VTCR_EL2. @@ -11013,17 +11014,32 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, txattrs->target_tlb_bit0 = true; } - if (cacheattrs != NULL) { + if (mmu_idx == ARMMMUIdx_Stage2) { + memattr = convert_stage2_attrs(env, extract32(attrs, 0, 4)); + } else { + /* Index into MAIR registers for cache attributes */ + uint64_t mair = env->cp15.mair_el[el]; + memattr = extract64(mair, extract32(attrs, 0, 3) * 8, 8); + } + + /* When MTE is enabled, remember Tagged Memory in IOTLB. */ + if (aarch64 && cpu_isar_feature(aa64_mte, cpu)) { if (mmu_idx == ARMMMUIdx_Stage2) { - cacheattrs->attrs = convert_stage2_attrs(env, - extract32(attrs, 0, 4)); + /* + * Require Normal, I+O Shareable, WB, NT, RA, WA (0xff). + * If not, squash stage1 tagged normal setting. + */ + if (memattr != 0xff) { + txattrs->target_tlb_bit1 = false; + } } else { - /* Index into MAIR registers for cache attributes */ - uint8_t attrindx = extract32(attrs, 0, 3); - uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)]; - assert(attrindx <= 7); - cacheattrs->attrs = extract64(mair, attrindx * 8, 8); + /* Tagged Normal Memory (0xf0). */ + txattrs->target_tlb_bit1 = (memattr == 0xf0); } + } + + if (cacheattrs != NULL) { + cacheattrs->attrs = memattr; cacheattrs->shareability = extract32(attrs, 6, 2); } @@ -11978,6 +11994,17 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, *phys_ptr = address; *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; *page_size = TARGET_PAGE_SIZE; + + /* Stage1 translations are Tagged or Untagged based on HCR_DCT. */ + if (cpu_isar_feature(aa64_mte, env_archcpu(env)) + && (mmu_idx == ARMMMUIdx_Stage1_E0 || + mmu_idx == ARMMMUIdx_Stage1_E1 || + mmu_idx == ARMMMUIdx_Stage1_E1_PAN)) { + uint64_t hcr = arm_hcr_el2_eff(env); + if ((hcr & (HCR_DC | HCR_DCT)) == (HCR_DC | HCR_DCT)) { + attrs->target_tlb_bit1 = true; + } + } return 0; }