From patchwork Mon Jul 18 10:01:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 591455 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp2848940max; Mon, 18 Jul 2022 03:03:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vbktD7+/gIksypXwqrlFt/ejfTNS+2g56YFgvDm9qcz61dTHqdUn59Sf25l/ndmwsXAS1M X-Received: by 2002:a05:620a:2614:b0:6b5:618d:2949 with SMTP id z20-20020a05620a261400b006b5618d2949mr16961841qko.759.1658138582575; Mon, 18 Jul 2022 03:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658138582; cv=none; d=google.com; s=arc-20160816; b=RHazpj4c9IC/tkfuKIaU0p6S4eOS6/OCr6PH75/sqMm/4jE4ZMSPJIhaHdiFoweXEC uq5xH39dAS/6Q7IAWpltSTMIUjF853iQQRhvk0Dph3r/udpfAepwVTU8Xura6NcaG6a8 13JG7zwNHSeiN/LMwlq7LrM+98BQgkr2BTMBQRX/7x5/a/641qbuNRf60698He73prOp +/ubdix6F51ME2L8eKQWkf2Ql7lm1LqrhUVrJVV+siimULFlJ2vMcdJoEUCRY+qa/RYn C3IvDjeBicn2KA0FSpQ4o6lcxX+aO+0hkuqbP0erObRkG4WfZJFHuqUUyUz/b+AdSlsW OaOw== 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=LADKvz6NGwtTpJM5NpBVGy0mPvkc4sq8YRH/zAnJtNo=; b=KQAYZGUt2lWa6umNH984QpvH9CRWZ8QPE955lDYqABldPM2tkx3sVV2FGY40S6a3t3 IgFgtRrmBIXv9nOtHzdwa82szcD8iiA7I59ZzBib8gEh4sPtOT3E6HRosZlU4pkGUnDf XiJsRNTZMpjlV64XAXRMgJZBg37+gcyGwNEIUWE6CNV40GPj890XbPXYwHcJnJTOBXDe AZ+1CLo/m5XlOKGhVVv1mHuFXiqLsEC5smBokLaKHGoMkkk7u5c5PW5hftU+9uJ51OaT fVUQLI/4TvUGNIgB4CYiTyYvA5pviWmjdtzFEqqbDgo32KdIdXKGQMH1XdbT/30izUIG fOdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sD30wY8b; 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 l16-20020a05620a28d000b006af0db03077si6702053qkp.319.2022.07.18.03.03.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jul 2022 03:03:02 -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=sD30wY8b; 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]:57164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDNag-0001bB-79 for patch@linaro.org; Mon, 18 Jul 2022 06:03:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDNZW-0001ZA-Di for qemu-devel@nongnu.org; Mon, 18 Jul 2022 06:01:50 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:40812) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDNZU-00054h-V5 for qemu-devel@nongnu.org; Mon, 18 Jul 2022 06:01:50 -0400 Received: by mail-wm1-x336.google.com with SMTP id ay11-20020a05600c1e0b00b003a3013da120so7467993wmb.5 for ; Mon, 18 Jul 2022 03:01:47 -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:mime-version :content-transfer-encoding; bh=LADKvz6NGwtTpJM5NpBVGy0mPvkc4sq8YRH/zAnJtNo=; b=sD30wY8bZN83brGu8oFmRrq+oAKISV2fydR2wdGzyxa1cxOXfvchvA4ZPYnelyjDjm GdWhwfQ9aeZHeJN6LMp63KwczQ+VM/3CtTq250ctTlXdyG8QAWK0utmVtPa1kapOseTP A29QeF7s7XGsMciBHaD2hd4f+dOANOOOzjvcpj12OfH2pZ4bZT8+ErDnpbV+bk7WQcYQ Sb06qv5DZNO+v7A/Ouzf57q5kXMBYI8UlYicPgcgaN10stMyBEr1bnhWmquz5ugVVTIH PfqDN8E8getvQjhS42kRszl+HTqf3gL4p5y1jtiP4FDWl6kcvKXCvpTYNj0eNH91Xqky tKFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LADKvz6NGwtTpJM5NpBVGy0mPvkc4sq8YRH/zAnJtNo=; b=HsfBP5IQPL1UZ2+FM5q8Ssira5dzwb2/kv/lOV+L0fYpXQvzfl7w+04Ndh7waoHU7u ZLVsZtGyZxqSNmOB4LhJDl/T7j42ik3M5GrJh6AHxoCej8zmVzMGcFVYt3uQ6VkReHO6 g7y2kcy6dy95Mj9wMUW0o0RVP0udO+WIvrWs5KnF4Ej6MBONYw30jDM2cT9RXJATO1av YV9fAtABWKcF9HlBP/ClfuCzisaKSviGF3WKflohRjfhmquQTu6nzWe0mu6qno+8u0y0 ayvnLxtqqZAyiNTU6BdMU5dg3RBmpiaSsF8Oh4OwZPk5pAAXpd5kn8/s38QZshZ3uy9A xiZg== X-Gm-Message-State: AJIora/6qFV5AO0aOZhwGs7QAmJXAr7MrRqlMZmckGz3/zmOLVy7ZLVp m/FlbjzxVTASFb4AwuvfUrqsNw== X-Received: by 2002:a05:600c:3b07:b0:3a3:1433:10b5 with SMTP id m7-20020a05600c3b0700b003a3143310b5mr8683144wms.129.1658138506135; Mon, 18 Jul 2022 03:01:46 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c15-20020adfef4f000000b0021d6f03b524sm10251990wrp.48.2022.07.18.03.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 03:01:45 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PATCH] target/arm: Add MO_128 entry to pred_esz_masks[] Date: Mon, 18 Jul 2022 11:01:44 +0100 Message-Id: <20220718100144.3248052-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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" In commit 7390e0e9ab8475, we added support for SME loads and stores. Unlike SVE loads and stores, these include handling of 128-bit elements. The SME load/store functions call down into the existing sve_cont_ldst_elements() function, which uses the element size MO_* value as an index into the pred_esz_masks[] array. Because this code path now has to handle MO_128, we need to add an extra element to the array. This bug was spotted by Coverity because it meant we were reading off the end of the array. Resolves: Coverity CID 1490539, 1490541, 1490543, 1490544, 1490545, 1490546, 1490548, 1490549, 1490550, 1490551, 1490555, 1490557, 1490558, 1490560, 1490561, 1490563 Fixes: 7390e0e9ab8475 ("target/arm: Implement SME LD1, ST1") Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/cpu.h | 2 +- target/arm/translate-sve.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1e36a839ee4..3123488014d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3374,7 +3374,7 @@ static inline uint64_t *aa64_vfp_qreg(CPUARMState *env, unsigned regno) } /* Shared between translate-sve.c and sve_helper.c. */ -extern const uint64_t pred_esz_masks[4]; +extern const uint64_t pred_esz_masks[5]; /* Helper for the macros below, validating the argument type. */ static inline MemTxAttrs *typecheck_memtxattrs(MemTxAttrs *x) diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c index 41f8b12259e..621a2abb22f 100644 --- a/target/arm/translate-sve.c +++ b/target/arm/translate-sve.c @@ -529,9 +529,10 @@ static void do_predtest(DisasContext *s, int dofs, int gofs, int words) } /* For each element size, the bits within a predicate word that are active. */ -const uint64_t pred_esz_masks[4] = { +const uint64_t pred_esz_masks[5] = { 0xffffffffffffffffull, 0x5555555555555555ull, - 0x1111111111111111ull, 0x0101010101010101ull + 0x1111111111111111ull, 0x0101010101010101ull, + 0x0001000100010001ull, }; static bool trans_INVALID(DisasContext *s, arg_INVALID *a)