From patchwork Fri Jun 26 15:14:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 191858 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp597712ilg; Fri, 26 Jun 2020 08:38:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvUKc87vGhRzWYS/ZLeu4mQw3xC3LB2RnLrqgL8drsLRwoeS72DoGEfi7J8RcB72DfMF5k X-Received: by 2002:a5b:d0a:: with SMTP id y10mr5983788ybp.32.1593185896302; Fri, 26 Jun 2020 08:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593185896; cv=none; d=google.com; s=arc-20160816; b=Jp0Z75diCcUNqI8joFBVBOsrkEva92OVN6S0rst+FP+kSiiWt7a0c4EAkmOlVVa0Zj DOAWnoVxBH0xdOxZFpXh3/ymh1mTBVydL9++qXAiNyISIMkykXQ6g1josfOm4pmsbHZi PN8KEA4sjrHBZnrxn+/mRDLlp+tnfVDaCjXbQxyDVkIlfDjaKy9oeiYxs+3Vxw1DDcRr iLJJFiN0PeTrkRkbnUYEGykOmgCyaNp9J5bwEa6GC/IdcL3KXSbXXFGIjXGnA7jhWJhu 2kU9nz+XRLdIUOq0i02WZuTZVIcSDP45P9orCNbt5o2MI9agxxlPmPNk+QRVqWnIFlq6 DEgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=0oVfTOhMQ6Tde7hKNa/ourLtYXrK2B3QeNm/nMxWem8=; b=XIoyJoJ6PMsHPnd8nD/Bmmip+UqzyxCSvNO25r1h9G0WAyLVf2+j5jXoUGC+rCv0aQ d+xtWLGCvBRaZwWJd06d+s9s1ds8g1BSZ8j9KaxN9nlkLxIPI59rRUZIGUYWvTIvWh80 h8hHUGSXU4GhqIJ68IbGKObgsSxVl/nTnRbpxmpd8vL1pqEP8d9SUtQmd+/FxS+qBoN4 U7A1bKUGEB2ZNTGnZcYDMpiMAtKbqbFnk4OOt1Lvs6fK3ELRkuYkFQt90BczNNBpuJHn UH6tWU5pzWfX1VRXQahC5iGtTXoNq3tET7Q4tNE614s8jpt37hwapqbAOQeFjJFIYPMz zoKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qkqfW5DW; 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 p1si24398867ybm.466.2020.06.26.08.38.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jun 2020 08:38:16 -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=qkqfW5DW; 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]:58452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joqQh-00013w-Jv for patch@linaro.org; Fri, 26 Jun 2020 11:38:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joq4g-0003KZ-Gl for qemu-devel@nongnu.org; Fri, 26 Jun 2020 11:15:30 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:46453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1joq4e-0006jp-Kc for qemu-devel@nongnu.org; Fri, 26 Jun 2020 11:15:30 -0400 Received: by mail-wr1-x42c.google.com with SMTP id r12so9805957wrj.13 for ; Fri, 26 Jun 2020 08:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0oVfTOhMQ6Tde7hKNa/ourLtYXrK2B3QeNm/nMxWem8=; b=qkqfW5DWWVce1lt2gMkWTq63P2U/IlsJCEsJ+9vfWvJqhzA712wi57+DXM0ky4yZmF k7Rmwj8ojD2TeI0FKBIZJHmroIvyTEJ26BZjETbVSaG8rOFDJltxjbmFQmBeX7cZFG0g LSPUxyrCWag8gN6JqmRjSJEGOep+XQypwyUigkYYuJ9BVryveQHmgnz69Z7lK+Y5bEqn TM69nYosX1he6vXjnp5oH6QRFhcKcmGNqG67gk62nuOBinrWWX+rOUi4g/ToeoD/v7Na pGktQgXe94INIKwcnrWPU8iXmCHe0R0EHIfPwx2YZEU19etkhU0LeZkwTx1JHQlDr4lC fRIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0oVfTOhMQ6Tde7hKNa/ourLtYXrK2B3QeNm/nMxWem8=; b=gRhRB8YxqcJXdB61h64QMwahGkD68YCCkoXfUNBdVgoJkynoUAO7JmCX50S09SUJ8L D2BZ7Utgt2TVj+aRnyDXwDGkP27YlWYp9TY5YetbgAL4I0RIMCmTRZKJ16tR8ltR+qi3 4hbtVQqs2arJ/1/nOSzHWWlnKKK3uwtEiuOLBJGUIQBIos4BfIz+AvkTbmgo4j4fqHlr vsF27Qfyxa+tLD0v4xbjx4FTITX3aAaTOSlSr7DvJCwfpBvFwgipyhvwt7Qp5eaqpLbJ TmgAzhUWvzKXlHO480Lt4j4jVwNpJ+WoJmrhpJvvmUzWFECxDeoEBeYQZlqOry+nGIJ1 afYQ== X-Gm-Message-State: AOAM532NXToViRbBmbFIn6ZHBv02cQMdRE2wn3SOFSVpnYvh5pTSkqlG u8/OTbRR9DIrZENke1w7VsLRPfoOF9J8Yg== X-Received: by 2002:adf:de01:: with SMTP id b1mr4163979wrm.305.1593184526971; Fri, 26 Jun 2020 08:15:26 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id w13sm37838852wrr.67.2020.06.26.08.15.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 08:15:26 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 50/57] target/arm: Complete TBI clearing for user-only for SVE Date: Fri, 26 Jun 2020 16:14:17 +0100 Message-Id: <20200626151424.30117-51-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200626151424.30117-1-peter.maydell@linaro.org> References: <20200626151424.30117-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson There are a number of paths by which the TBI is still intact for user-only in the SVE helpers. Because we currently always set TBI for user-only, we do not need to pass down the actual TBI setting from above, and we can remove the top byte in the inner-most primitives, so that none are forgotten. Moreover, this keeps the "dirty" pointer around at the higher levels, where we need it for any MTE checking. Since the normal case, especially for user-only, goes through RAM, this clearing merely adds two insns per page lookup, which will be completely in the noise. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20200626033144.790098-39-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.c | 3 +++ target/arm/sve_helper.c | 19 +++++++++++++++++-- target/arm/translate-a64.c | 5 +++++ 3 files changed, 25 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d9876337c05..afe81e9b6c0 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -203,6 +203,9 @@ static void arm_cpu_reset(DeviceState *dev) * Enable TBI0 and TBI1. While the real kernel only enables TBI0, * turning on both here will produce smaller code and otherwise * make no difference to the user-level emulation. + * + * In sve_probe_page, we assume that this is set. + * Do not modify this without other changes. */ env->cp15.tcr_el[1].raw_tcr = (3ULL << 37); #else diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index ad974c2cc57..382fa82bc8a 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -3966,14 +3966,16 @@ static void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \ target_ulong addr, uintptr_t ra) \ { \ - *(TYPEE *)(vd + H(reg_off)) = (TYPEM)TLB(env, addr, ra); \ + *(TYPEE *)(vd + H(reg_off)) = \ + (TYPEM)TLB(env, useronly_clean_ptr(addr), ra); \ } #define DO_ST_TLB(NAME, H, TYPEE, TYPEM, TLB) \ static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \ target_ulong addr, uintptr_t ra) \ { \ - TLB(env, addr, (TYPEM)*(TYPEE *)(vd + H(reg_off)), ra); \ + TLB(env, useronly_clean_ptr(addr), \ + (TYPEM)*(TYPEE *)(vd + H(reg_off)), ra); \ } #define DO_LD_PRIM_1(NAME, H, TE, TM) \ @@ -4091,6 +4093,19 @@ static bool sve_probe_page(SVEHostPage *info, bool nofault, int flags; addr += mem_off; + + /* + * User-only currently always issues with TBI. See the comment + * above useronly_clean_ptr. Usually we clean this top byte away + * during translation, but we can't do that for e.g. vector + imm + * addressing modes. + * + * We currently always enable TBI for user-only, and do not provide + * a way to turn it off. So clean the pointer unconditionally here, + * rather than look it up here, or pass it down from above. + */ + addr = useronly_clean_ptr(addr); + flags = probe_access_flags(env, addr, access_type, mmu_idx, nofault, &info->host, retaddr); info->flags = flags; diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index e46c4a49e00..c20af6ee9d0 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -14634,6 +14634,11 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->features = env->features; dc->dcz_blocksize = arm_cpu->dcz_blocksize; +#ifdef CONFIG_USER_ONLY + /* In sve_probe_page, we assume TBI is enabled. */ + tcg_debug_assert(dc->tbid & 1); +#endif + /* Single step state. The code-generation logic here is: * SS_ACTIVE == 0: * generate code with no special handling for single-stepping (except