From patchwork Wed Feb 7 02:52:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 770632 Delivered-To: patch@linaro.org Received: by 2002:a5d:40c1:0:b0:33b:4db1:f5b3 with SMTP id b1csp112221wrq; Tue, 6 Feb 2024 18:54:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcACfHtr7W+e+C6iC+wyuQKKAOZptaq18i2PWOymWpSz85aHRClCe2jmPZDR1/SuiALh19 X-Received: by 2002:ac8:4911:0:b0:42b:e6ad:b020 with SMTP id e17-20020ac84911000000b0042be6adb020mr5734172qtq.33.1707274446887; Tue, 06 Feb 2024 18:54:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707274446; cv=none; d=google.com; s=arc-20160816; b=HdPAfBxeZQNicjoD6epcbOWDi2ZMzSARwYZDHrgyaftg8p76bB1m9LxqYTGiZ15jQV gAQrCcfOCPuB+vfQlrg1MENKI0AFC9M1vHF0BMoAIW4Emacnu/6AHmiW1MyaR7s+QFSd q5hoZXx8TmO3GluXW+k9x0sB8w6uwbeWT7n7cSWYbEmhJzOgspFn60yFpJXBwJ+Wq7OS dUE+9GClXJP0csMi6BhE2ljS0zmIwoBa+7vUgbgs+Le8s/P+KtHGor+iHMBkYe0C+Mty u/lot5MRs/5KU/Yx+cUDgyZvBK/+089IZecpJsrAIuO9d+5XOCUjWHj3Ot23iccNPZBw 9pRg== 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:cc:to :from:dkim-signature; bh=TlKFEqZAqQ3pAY5dLOI6DMwcM/4p9lbYDIei9Bg0M3Q=; fh=MonbiymnRhszp4GbsuNsHb/plEmkvhf2Ne3X2nQpggo=; b=l0qUW6jEe+qhfN/J02pgiBImlLUxXDX1q0ADT5/0Vx9KPSv4ZCgHE/JokuamHaWz+f iYSVmTDzj96+OH6Td74A2K6fpTs+35nkSRoazAtNintFN/ZTZP3CbWp/ejyMxIvCw1DE 9OJrEFs+xTFQdDs9YApv2JHMwupf9O17aVV/z5fr0NwXEUEwEP9/ZzsIIjAAZQghCFTz U4N2tRPXK/UeAEWOlDTIEopYcBbbfqCMPH3TLRlDVdKjz7siCrNezpNi9cLHb5Ipq/GI 4605pvmuBcCKwWkIhYbkw4GuJ8mSnKRqbgMlh7bNU/eTIIQYJIU7Owd5QZAOOktKi8jU LiGA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OEIty088; 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 X-Forwarded-Encrypted: i=1; AJvYcCWu2Az+48PRqrFQrT/fOFLc7gmTyhJalOeY991u8YCCY9JNOoLuchQ358XVvEA4sgc5aldSkEcpl+DKsyBwaCGb Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v9-20020a05622a144900b0042beca41f7asi298870qtx.397.2024.02.06.18.54.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2024 18:54:06 -0800 (PST) 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=OEIty088; 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 1rXY37-0003FO-GN; Tue, 06 Feb 2024 21:52:33 -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 1rXY36-0003Eo-6n for qemu-devel@nongnu.org; Tue, 06 Feb 2024 21:52:32 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXY34-0000fr-Po for qemu-devel@nongnu.org; Tue, 06 Feb 2024 21:52:31 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d9b2400910so1415855ad.0 for ; Tue, 06 Feb 2024 18:52:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707274349; x=1707879149; 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=TlKFEqZAqQ3pAY5dLOI6DMwcM/4p9lbYDIei9Bg0M3Q=; b=OEIty088a7D36IEO+R5MgPgwJIIQ3+uCYUbjTCxIecylIh92NxRpSqSKSpjmZJN5io kEhpBdm/XetUZaR/WiL9tBLQnp7+FCcuwrVQRt/ZXa7oF0vdd9O1CV85/r3NfABFhYql HNpfnDWmSI6sd7scS5asTGUEcVOi1z089WE/Eyvpl5qdpc7ngR0dLaaGzTrCmvT3I4Wo 7Ev2RBZQwE43SX44rqhqEOL+IpB9aYvNFDPqv3K6Ldc2v7+YHe3P7yPRjC+Mt2jiRKNu QXDSd+t6UNJIGsR8sB2qZ1h0z7RPTlSgBQf+X/zI8IZvTI/TR9Xk7Ejr+4RnBDluER2b yRFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707274349; x=1707879149; 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=TlKFEqZAqQ3pAY5dLOI6DMwcM/4p9lbYDIei9Bg0M3Q=; b=GU59q+MAt97dTjk8Ijrao6UIIqGewXGzVUWdzzeLAzGCysoJRPywbK7LsKcUU4y7p+ GJ+Wh47LPZq/JHgggBTOPxNhphSezq7n0QHfEjlzR/a6fHPStytFxrSGfDaBsAt1keUC 3+yG+5lrfA7YRPfeKjM2zHFQqXqrBy4rbkOAitUg1CXfWa2ii8gj99nmBv48F2EplUNt jR4wNrNGJ7j1YOfAu3UkpMd47zyKETJr6eHpg31K77YO0JCVGBVURJ7XihOp8F81se85 mxXXKvMb3o+a5X9vV+VQRNDNzhAiBeeY9l/xZ8HXFMNPTH/juOqB6B7M3yZQ5ktqZPo7 fDig== X-Gm-Message-State: AOJu0YwY44OgyLGPy6CEuTZP8fnQsoU5G0phwpIhf4/23zzHtYKB4fzn 15hzgR2WqOPMCoymIw2KkZdWxbqisxzDRL91n1LmBQegti4Yyc1z7ZScnvCOwGkZTYoAbYBypIK Vk0s= X-Received: by 2002:a17:902:e802:b0:1d9:3edf:1e2 with SMTP id u2-20020a170902e80200b001d93edf01e2mr5648247plg.3.1707274349017; Tue, 06 Feb 2024 18:52:29 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV/9fEBvxZ179Rf5XzajD3RWE0SQCCajNCrcLVa3rq5LTAoZgPOW38YKYCJyhuvDjR7UBZu1RuofMr40qUAJ1NAwK0MDYdCrAFv9Y8/sanyn7tVQt0n01YzpFK4LVKMlVxmw0NbBb/IE//GrUaTxbZNDiVIHPFYrhVhTTY= Received: from stoup.. (60-242-98-186.static.tpgi.com.au. [60.242.98.186]) by smtp.gmail.com with ESMTPSA id kr8-20020a170903080800b001d8ef97de4asm255435plb.38.2024.02.06.18.52.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 18:52:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, gustavo.romero@linaro.org, qemu-stable@nongnu.org, Peter Maydell Subject: [PATCH v3 3/6] target/arm: Adjust and validate mtedesc sizem1 Date: Wed, 7 Feb 2024 12:52:07 +1000 Message-Id: <20240207025210.8837-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240207025210.8837-1-richard.henderson@linaro.org> References: <20240207025210.8837-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 == 5). Assert that the data to be stored fits within the field (expecting 8 * 4 - 1 == 31, exact fit). Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- 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) /* size - 1 */ 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 7108938251..a88e523cba 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 = vec_full_reg_size(s); TCGv_ptr t_pg; + uint32_t sizem1; int desc = 0; assert(mte_n >= 1 && mte_n <= 4); + sizem1 = (mte_n << dtype_msz(dtype)) - 1; + assert(sizem1 <= R_MTEDESC_SIZEM1_MASK >> R_MTEDESC_SIZEM1_SHIFT); if (s->mte_active[0]) { - int msz = dtype_msz(dtype); - desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s)); desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); - desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (mte_n << msz) - 1); + desc = FIELD_DP32(desc, MTEDESC, SIZEM1, sizem1); desc <<= SVE_MTEDESC_SHIFT; } else { addr = clean_data_tbi(s, addr);