From nobody Tue Nov 26 16:25:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1707188891; cv=none; d=zohomail.com; s=zohoarc; b=JthJh4tzvQ9QGuR6OG3rEdgzI1e0Kb2T/7fch/5Sfp3IK6rWaXc5n4CdzU1uy1oSHfT1TH/cjqdGvpgBpiSNio4Wn/albCdBmRXp87jaNYmwuWSBkXLVkXKqgNbZjrmOm4VQu1kGirWOHl7QndTCNabKJcQ5eFRxnXfabRpHvAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707188891; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gHPXu0j0nAO0+SMsvMvHJ8lHzrBgl7Y3ITORBgFmLRk=; b=TiSXk2qqvVvUO/9VW75buH3qiZsexVczfAzk5ZawRnkXzbnixHWyEaV9Iz0owF/zfvcmhQ+ddEdm9cWQkOO2Nnkyw7rziXtzd73uoyEiWRgokZIHwUfT1DFrwjY0oSiyNEvSYhcY9ZxkbFZ9NG/5JvCctQGLLBzYlv1yIVQT5pU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170718889188831.554504857486336; Mon, 5 Feb 2024 19:08:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXBmX-0006xS-4P; Mon, 05 Feb 2024 22:05:57 -0500 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 1rXBmV-0006vh-BX for qemu-devel@nongnu.org; Mon, 05 Feb 2024 22:05:55 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXBmQ-0003G6-BE for qemu-devel@nongnu.org; Mon, 05 Feb 2024 22:05:55 -0500 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5d81b08d6f2so4802782a12.0 for ; Mon, 05 Feb 2024 19:05:42 -0800 (PST) Received: from stoup.. ([43.252.112.200]) by smtp.gmail.com with ESMTPSA id r14-20020a62e40e000000b006e025030700sm627478pfh.190.2024.02.05.19.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 19:05:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707188741; x=1707793541; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gHPXu0j0nAO0+SMsvMvHJ8lHzrBgl7Y3ITORBgFmLRk=; b=U8orwk48UD4w2FFG5jHnixYJ29TCV5RRo9Et6BUusFiBj6Y/amebwMS7gFzVsmJ+mN dGIFhp6w/KKanlFjBmiT1/lAX+6c10shyuyI+M/MZ1vNvLG2YfDQsCi3krS8nolQU16D ZvF73O59vKVPi6tMgxJTVI3lvqkJYYhxFjABUSQkySiFdPbz/muuiJkcgk8OcXe1tojz ugQAHZaNCM+Rd0ZbOkHB7s4lEINVmBZbRWVxjoNdz+XN9Rn+klKxeMtZeZLqmzbi9ySe YA4HIIt4009w3BHKzixvrItlR1wqx7rxZODAd8+ThzSOkXmKhfmZmf2IwcbFC1d2I80O 3OZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707188741; x=1707793541; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gHPXu0j0nAO0+SMsvMvHJ8lHzrBgl7Y3ITORBgFmLRk=; b=E8gOW3HY/hYrQvKFKRqL4ztSQ8bZDpQhjB15PmJ6HjetTKG8wF3izCXRPJba09/kUQ cvh+vO6YYHeQ1iYrjK1b+oMgevrV8L3lrneSnGlPi+gjLAc8JLOu53DghT6fqRJGEs6R QKVLUAC3jU3AJq72nkIJNS3FSL+jKJaAZR5sBTQ2FA7AcRWjRarnRwdFpDRMn7sEvVTg wsYv/D02GqfrISkgFkTgzvLXuUvryYe7VFwxSybevvZEx6BCmGT1pjH8RqS4ZMvP+rpZ XFsqLlD+v7Mit+s6OUtXMnBwLeE8WrpANyXZ+4unbVETwMY9j/Es07MNB++9NuXQHf3M cGGg== X-Gm-Message-State: AOJu0YzEk7U/BEMVtFuRZMM+03CouTeSEJrTz1l1ID+Q27XDFYDKaqyg /jJr85gkXefs2WruX+/QxeLpcTXTwaYzRdSVaV8QNopdYuAab+bHuRN/LsBORgBSApxn79t/1K9 vuhM= X-Google-Smtp-Source: AGHT+IHnyMLOLRWF69i5ATV9MfZhiLxkek8dWHa7GhoE4ZCazEaAoml3iTNYvEFOb2iKISlsD8/L4w== X-Received: by 2002:a05:6a20:7209:b0:19b:673d:824d with SMTP id y9-20020a056a20720900b0019b673d824dmr327389pzb.46.1707188741089; Mon, 05 Feb 2024 19:05:41 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUQ7tQ5Cubv0pchS/7CGd8F0TqpmNW3ud5JUcjf4DnVWODKV1G1Y796ss0PZHp738doxMf7t8HzvdkpyDdz2koAurvdHqLyOiuW From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, gustavo.romero@linaro.org Subject: [PATCH v2 3/6] target/arm: Adjust and validate mtedesc sizem1 Date: Tue, 6 Feb 2024 13:05:24 +1000 Message-Id: <20240206030527.169147-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240206030527.169147-1-richard.henderson@linaro.org> References: <20240206030527.169147-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707188894131100005 Content-Type: text/plain; charset="utf-8" When we added SVE_MTEDESC_SHIFT, we effectively limited the maximum size of MTEDESC. Adjust SIZEM1 to consume the remaining bits (32 - 10 - 5 - 12 =3D=3D 5). Assert that the data to be stored fits within the field (expecting 8 * 4 - 1 =3D=3D 31, exact fit). Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/internals.h | 2 +- target/arm/tcg/translate-sve.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index fc337fe40e..50bff44549 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1278,7 +1278,7 @@ FIELD(MTEDESC, TBI, 4, 2) FIELD(MTEDESC, TCMA, 6, 2) FIELD(MTEDESC, WRITE, 8, 1) FIELD(MTEDESC, ALIGN, 9, 3) -FIELD(MTEDESC, SIZEM1, 12, SIMD_DATA_BITS - 12) /* size - 1 */ +FIELD(MTEDESC, SIZEM1, 12, SIMD_DATA_BITS - SVE_MTEDESC_SHIFT - 12) /* si= ze - 1 */ =20 bool mte_probe(CPUARMState *env, uint32_t desc, uint64_t ptr); uint64_t mte_check(CPUARMState *env, uint32_t desc, uint64_t ptr, uintptr_= t ra); diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c index f50a426c98..2628ac2840 100644 --- a/target/arm/tcg/translate-sve.c +++ b/target/arm/tcg/translate-sve.c @@ -4443,17 +4443,18 @@ static void do_mem_zpa(DisasContext *s, int zt, int= pg, TCGv_i64 addr, { unsigned vsz =3D vec_full_reg_size(s); TCGv_ptr t_pg; + uint32_t sizem1; int desc =3D 0; =20 assert(mte_n >=3D 1 && mte_n <=3D 4); + sizem1 =3D (mte_n << dtype_msz(dtype)) - 1; + assert(sizem1 <=3D R_MTEDESC_SIZEM1_MASK >> R_MTEDESC_SIZEM1_SHIFT); if (s->mte_active[0]) { - int msz =3D dtype_msz(dtype); - desc =3D FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s)); desc =3D FIELD_DP32(desc, MTEDESC, TBI, s->tbid); desc =3D FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); desc =3D FIELD_DP32(desc, MTEDESC, WRITE, is_write); - desc =3D FIELD_DP32(desc, MTEDESC, SIZEM1, (mte_n << msz) - 1); + desc =3D FIELD_DP32(desc, MTEDESC, SIZEM1, sizem1); desc <<=3D SVE_MTEDESC_SHIFT; } else { addr =3D clean_data_tbi(s, addr); --=20 2.34.1