From patchwork Fri Sep 1 20:31:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 719518 Delivered-To: patch@linaro.org Received: by 2002:adf:d08b:0:b0:31d:da82:a3b4 with SMTP id y11csp462950wrh; Fri, 1 Sep 2023 13:32:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAvX/2g1mj3arCjtOGySPLxF86+yiWTYXqQII5XjXm3kT2MFaj4XzYNNEz0hsmWRsO4N3r X-Received: by 2002:a05:620a:199d:b0:76d:83ae:fdcd with SMTP id bm29-20020a05620a199d00b0076d83aefdcdmr4079095qkb.57.1693600346630; Fri, 01 Sep 2023 13:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693600346; cv=none; d=google.com; s=arc-20160816; b=JYkwbcUzcycutKOv0Fyeqst4D+Ju4D9D0v56wcO5FiCCg1MZ4NsgMniP5apR93cCeQ FTK18NMZnXrEf5apWs2qrRElEbXRuZ+Q5oUK1yy9QnzQ+sn2NwuGXOOF5KVCREzdcN/9 C0Db13SfquhMS5EFbjUhSvMBUqTRY8Uc9d2oTsmoQw2Ou3eqKsqekIABOiDiUwxdwEbl S4fABEJicJWapny50X10z+NnxmEUKivec8Q5DvYOlzSg/lpxGzQcLioWmimHyh9eN5b/ gdfB7LWOMNRER3l1yBn+W7FVIrvKESWbwJcUesgyMzfgH6HV/qqStx8cGUH19LThQmWj OrVQ== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=VN6l2cROyOIJzFYTqk3mQSzHqtpIGQeP6fwa2uvMk5I=; fh=9Ev+QBUhk6P6vR3LT1wYeDLexozsz44nqjfoyPajZCc=; b=fRFDUuLamk8pU+cCxhi+eebxShO9emZb03rr5mdK9HPXsY7dg9XkagPfrKoxZe+lJF glnMGahWS9r9zRish2G5d7GGn+55jmddDwWloMW8jb+APaWIT9csDoqTeiu0mFoPpWhc nk2f9AkuNgorzym/vEXO6QPdW7E7G90xrN8qxyCIMjOoW/C26+9aiFOxAmKw3WTUARNg Xx3eeZfuATjrVMcSfCfUSFk4K9eSQg7FQ674BiWlko5VHLkdkIsqKDJEv+gz6AqFxNY+ R0vdCYI48VVoMRVcokhOZLvvZisOHKWWj79tMFyv4zQmMQ522m1kmcNuy1OwakCiLS/1 Hgbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mlkChalY; 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 g21-20020a05620a279500b007683249ea20si3094141qkp.218.2023.09.01.13.32.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Sep 2023 13:32:26 -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=mlkChalY; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcAnR-00088n-L3; Fri, 01 Sep 2023 16:31:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcAnO-00086z-Cv for qemu-devel@nongnu.org; Fri, 01 Sep 2023 16:31:10 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcAnK-0005Pb-U5 for qemu-devel@nongnu.org; Fri, 01 Sep 2023 16:31:10 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c0d5b16aacso19508065ad.1 for ; Fri, 01 Sep 2023 13:31:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693600265; x=1694205065; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=VN6l2cROyOIJzFYTqk3mQSzHqtpIGQeP6fwa2uvMk5I=; b=mlkChalYArBHuLVyfUFLhw5KKbAHJ5U58eCXE/J2sbxFSKqJhP7HhlS3nwbk0tDk3a T4ggddBQRA+xuTi2z6mmBpU/ZnX/DVVccrjRqfYb17X89xUvN0Q6MuJW5V6obvaQRd09 IkoZeIYkx3ygKr7uRlXpgk+SxIn0KzkOtxaH4ASB0QObp1FML+ER6ZcpP8ldMLC7AzFY ebiLwTsEHm74/fXQpryImO7wUKBFHhxugmYBZf3F++kevkLjkrx1Gc0vXqLoL1Mjt2op qZoN4WQVpnh7V4ebdulZ9OortXWalrMOkMe8UBWIkpIHgZVfytnH/RZe/18hP8UFTWeY O8pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693600265; x=1694205065; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VN6l2cROyOIJzFYTqk3mQSzHqtpIGQeP6fwa2uvMk5I=; b=HHIOX+fwe39bQpe/VZhsJlgvE2swO9AnZGh1kJghjPdPEW+iGtfi/ABJiCOTzmUKsY Ve0u47UrWKqQH7evZ+yq47+y6orTJHHzxM0yszCUaUmtVJeYXiytoV0CnjflPhgvjmuM 9p86PoOnzNEZSsuoFfQZjSbWJ7+K149R4SNq14u2b4w2au5BP4QoVEzurT/Uy9bhhIGy naKm3cRUvjNu7KtLw30YkQnWQHPurdXvyGqMc3txGlgLvfBArjmYYn/VUsawgchZsn1X hi+4A4VaolqqwFxAyS9xmameTwDQNQDGfUlw4ovw6infyI4Tmv16/TposNvSDYOKNKtA jl5w== X-Gm-Message-State: AOJu0Yzj81BiE5d3QBlz3nSFo8A0UNAunpXi3jMBO992PiUKHY6TkOoq +0UAUkFYyfQI5B3vcF1Y19vR+C208YkK6VOrNKI= X-Received: by 2002:a17:90b:150:b0:269:7eea:d7f6 with SMTP id em16-20020a17090b015000b002697eead7f6mr2917655pjb.49.1693600264674; Fri, 01 Sep 2023 13:31:04 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id 14-20020a17090a190e00b00262ca945cecsm5360373pjg.54.2023.09.01.13.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 13:31:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v2] target/arm: Do not use gen_mte_checkN in trans_STGP Date: Fri, 1 Sep 2023 13:31:03 -0700 Message-Id: <20230901203103.136408-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.com 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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org STGP writes to tag memory, it does not check it. This happened to work because we wrote tag memory first so that the check always succeeded. Signed-off-by: Richard Henderson --- target/arm/tcg/translate-a64.c | 41 +++++++++++++--------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 0b77c92437..c5de176b8b 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -3020,37 +3020,17 @@ static bool trans_STGP(DisasContext *s, arg_ldstpair *a) tcg_gen_addi_i64(dirty_addr, dirty_addr, offset); } - if (!s->ata) { - /* - * TODO: We could rely on the stores below, at least for - * system mode, if we arrange to add MO_ALIGN_16. - */ - gen_helper_stg_stub(cpu_env, dirty_addr); - } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { - gen_helper_stg_parallel(cpu_env, dirty_addr, dirty_addr); - } else { - gen_helper_stg(cpu_env, dirty_addr, dirty_addr); - } - - mop = finalize_memop(s, MO_64); - clean_addr = gen_mte_checkN(s, dirty_addr, true, false, 2 << MO_64, mop); - + clean_addr = clean_data_tbi(s, dirty_addr); tcg_rt = cpu_reg(s, a->rt); tcg_rt2 = cpu_reg(s, a->rt2); /* - * STGP is defined as two 8-byte memory operations and one tag operation. - * We implement it as one single 16-byte memory operation for convenience. - * Rebuild mop as for STP. - * TODO: The atomicity with LSE2 is stronger than required. - * Need a form of MO_ATOM_WITHIN16_PAIR that never requires - * 16-byte atomicity. + * STGP is defined as two 8-byte memory operations, aligned to TAG_GRANULE, + * and one tag operation. We implement it as one single aligned 16-byte + * memory operation for convenience. Note that the alignment ensures + * MO_ATOM_IFALIGN_PAIR produces 8-byte atomicity for the memory store. */ - mop = MO_128; - if (s->align_mem) { - mop |= MO_ALIGN_8; - } - mop = finalize_memop_pair(s, mop); + mop = finalize_memop_atom(s, MO_128 | MO_ALIGN, MO_ATOM_IFALIGN_PAIR); tmp = tcg_temp_new_i128(); if (s->be_data == MO_LE) { @@ -3060,6 +3040,15 @@ static bool trans_STGP(DisasContext *s, arg_ldstpair *a) } tcg_gen_qemu_st_i128(tmp, clean_addr, get_mem_index(s), mop); + /* Perform the tag store, if tag access enabled. */ + if (s->ata) { + if (tb_cflags(s->base.tb) & CF_PARALLEL) { + gen_helper_stg_parallel(cpu_env, dirty_addr, dirty_addr); + } else { + gen_helper_stg(cpu_env, dirty_addr, dirty_addr); + } + } + op_addr_ldstpair_post(s, a, dirty_addr, offset); return true; }