From nobody Sat Sep 26 21:36:27 2026 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1788485014; cv=none; d=zohomail.com; s=zohoarc; b=F1kViuiTnWk4pxP+rjf2eJR6p1CEFG2vm6g4Q3y0pg20yI8eHgILHXvbPUjMJtIQN0RN8xEQ2omL61S/VoeenHLbDlcizuBAnVMO5dom2fgeFcXxMmgLpedYAlZerDSfSw6gXRGN8qfOJ2TjiAMcTCnRXqEHZK3twvJI4cIYpUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788485014; h=Content-Type: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=k+TohD5bx2HhycXesAHlop/DzWBoRKT6Njidelnyb0U=; b=Q/MBBKTAadKKpAg8FNEKOoK8xNYRoft/cHSYi73a8VofPbwy4dZc+wtO7Oyx5vsenT5sQhOm5uthY7cKC7eRmJn3Wr1yM+SdauenCUD/QYV0UEEnHA8hKC7lGhStydcioq1Zfu2mx1So2CQB/+LNhZkpyBqGSbsL2cI3oa/YgQA= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788485014297799.332656765475; Thu, 3 Sep 2026 18:23:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x2Idh-00079X-7Q; Thu, 03 Sep 2026 21:22:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2Idg-00079C-8w for qemu-devel@nongnu.org; Thu, 03 Sep 2026 21:22:44 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2Idd-0005J1-Hj for qemu-devel@nongnu.org; Thu, 03 Sep 2026 21:22:44 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 683NbXaR1948201 for ; Fri, 4 Sep 2026 01:22:38 GMT Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gfdyxhfvu-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 04 Sep 2026 01:22:38 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-39af92138f9so724478a91.0 for ; Thu, 03 Sep 2026 18:22:37 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3339885ca07sm2573234eec.1.2026.09.03.18.22.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 18:22:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= k+TohD5bx2HhycXesAHlop/DzWBoRKT6Njidelnyb0U=; b=Th+aD/jCRR+fqlR2 IOtffBW/Vzbf6W/kVHJadjhBDzpf0aoYVM5bOrgsyvNK5Zl6d0wUmk8K1ESAseyv mkaCQpf3jVSCPWWz5WY4tz8huYUcYPutPIfzsf7wisB7YtUihLZS9xqtY1AS+e34 sI3W372iiSKdUL5HdnVSQomoG9CSnMUCYlUuB4un45w5jCGNSk8aebASrp4gYVbU gHzkx1A9MISi8UBSM+zUAhFVN+a4jp4ZzhvIfoQhJuY267oL/CGNPx6amTqlNEQ3 0lYB1+Cz1ZHUh3FT+jxAD65OhbBINEJN8NAzPEZlJswpuzWXr3GVbw6hoCt9EAIm cL3ofg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788484957; x=1789089757; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=k+TohD5bx2HhycXesAHlop/DzWBoRKT6Njidelnyb0U=; b=PeqSbuQsAS7B3bgsdRCX6+UL8Qovq0oGJzZ7UKuOKDt9cFQhUGqI517wYW6vN/zafu PRJ23u3PpmVGKVodTNAu06BPP4qQPMJmS56X+q25X6Upt3ViYez02InTG7mVNAz9LDnT NLy45bDpjXRXJX/foBm4vRJWwcA93zJbvD6dH63Do7hwQXh9LMGmrUDHD2FYqxxp3xlZ dNsBeJGcJz48+yazYrX+EsHXrs9ID4JOmGRE/DPrskLj+im8CmhBtE4tdQXdy0mW+Gf6 LnhvDhHXInktxDKeqJwfa0Kp5X8ndWQ+5Xcd8shF3FsSYlWCdMk00iEUcFoDmw3qKN55 /Trg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788484957; x=1789089757; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=k+TohD5bx2HhycXesAHlop/DzWBoRKT6Njidelnyb0U=; b=SHWgsZqRGTT7dWtp7xvrKlD1CJJH6NlqjC02SB/OSFYSwkBur5ytEqURYqy01Eaw01 x52Bu7n2cU7V5YfwtmNJmyoBnXEmihg+I+Hz33A8y0f63+ciFugN173fBHA/I3vsAaO6 9CtiT/aG+8gXZyA8KLFthe/Vt4jGlh3qMCilneMW4vlqLshDYMqcmJEr5bZZUw5sOjML x3/p6AmCtqW68/bQmpsWsQ9yFJ+JYy4xOC3QAQggoPiK4EUAsUS2QyKk7HbZd5CsXgeS b39FNZb04GNtHegzpq6aBQTJeIoZWZ8JmK+vmvkVgbND3Wd9UUxRouQy7TMtrPkzPTqL 0R2w== X-Gm-Message-State: AFuF++myeeCTpnhW10oORIkpm9oUPw6UukjStK12e918l6j8r2Nn7EwQ GFSBfQe7EqnP8FhCEbhVezXV45HnygXu7STPGEbbmjRGR5ATAqkIw7z2icdOmgnqNnz2ATWYdId zgGmigp9kICblrQcb4MLz5Ya7hn4M/w408kZE292sDm/TPwY7uRd5tx8alZxp/q5GPQ== X-Gm-Gg: AYBFou1DAnU0R3ms3ZMtMkAUH0Bh7EqIluqVUtBt66INVIpKEOGuNgSToLUh0bqWkP/ uIOB/m5ExaL548gMuNdeFEfLFQa9rcFj4RkDg1bei/tHs0TkDIK3c6xWICYJRo90fL1o+W/Q19D Ihe+MrFeZ3e79IKrebSqA8OJDww/7MGMuqJVBZWxtDKCGKD1/ZT/tH6Bz3geNp0pyGghe+LoMFz KubscvTII4y0TxYTwaNcEuntX1Pxpah+sZA+Ib+sMSgS/xLdJ60VWteYKobHDCVEKXMV+TdGZsz rUVSkcN1/CIywWXu5Oyp61g+QcDxXvpM8KAAIWytonC8wk7YDYnbs0S9YApzJkLXmJ/ALjh+dj+ IY6j3RlnZJSoI3pJ8d8OLuGD2xM2Y6uOKiLqdaRG+0TYfyOUb X-Received: by 2002:a17:90b:35cf:b0:398:9beb:a2bc with SMTP id 98e67ed59e1d1-39b0881d765mr11014208a91.30.1788484957233; Thu, 03 Sep 2026 18:22:37 -0700 (PDT) X-Received: by 2002:a17:90b:35cf:b0:398:9beb:a2bc with SMTP id 98e67ed59e1d1-39b0881d765mr11014161a91.30.1788484956690; Thu, 03 Sep 2026 18:22:36 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: Brian Cain , Pierrick Bouvier , Anton Johansson , Matheus Tavares Bernardino Subject: [PATCH v3 1/5] target/hexagon: fix HVX big-endian byte access Date: Thu, 3 Sep 2026 18:22:29 -0700 Message-Id: <20260904012233.3607547-2-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com> References: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: xL2lbt8w93KRXF8BAasL1ZpJCNv8Gr3b X-Proofpoint-Spam-Info: AW1haW4tMjYwOTA0MDAxMCBTYWx0ZWRfX/ODI7wNJtj24 fZNBjheogkos7znbPeQIYW0naLq5Zye8i2FOoLJ7G0E0yQ/rTrfqfvAAA6qrYwXWwXtc3tnJBTp 4+dBqC4XckMBsxsMB8xclSoRVYLZ9cw= X-Proofpoint-GUID: xL2lbt8w93KRXF8BAasL1ZpJCNv8Gr3b X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTA0MDAxMCBTYWx0ZWRfX+ziqjQ5PqgSE 7d93FAEXZOseFFXgRgNIbAGq0gIlFA24zvDQ4BZZM4ttoYLYArAdNcQg6xQyL+jJFqiWfqnrJr5 6tH3kMrw+lGU5mkqMkM85yfUooAj9e5FidnBf9SmoT93XrpTm8s8fzK3E6LamZA7egEqjcDlsjy 3B5cW4MWh71Y98xCvxEUYz01P14hfncBgQP9QM5zljIEk+O40VPWsHtq7tKzpohizVWNC2nyLsh 1N+tTRjjFex/s3hGceVEQRNKUuzwJA3vJVHnMMgAEoz923UCq2K/KQCBybr/VbgXQ1UJYqlwgay IUjuifvrjlwoga6vV4MGkvUlh3t0iviabOgWBAoe/cyT/9EQb98KArNHViSDS0F2n98XqzgRSnw 5ojKUnIT8Pgr9MT5vmzF/rle7NREh3ZNX7vq/0JQ9g+FiVpOZks1gBbj2oAnShiDOcRFrIBB73d 1aLx5n+LikMDhhxf0Lw== X-Authority-Analysis: v=2.4 cv=X9Zi7mTe c=1 sm=1 tr=0 ts=6a9a1d5e cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=vUhCv2GA6jJ6UuKgImsA:9 a=QEXdDO2ut3YA:10 a=mQ_c8vxmzFEMiUWkPHU9:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-03_07,2026-09-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609040010 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1788485016901158500 Keep HVX lanes host-native while converting byte indexes at memory and helper boundaries. Also place vector comparison predicate bytes according to host word order. Suggested-by: Anton Johansson Reviewed-by: Anton Johansson Reviewed-by: Matheus Tavares Bernardino Signed-off-by: Brian Cain --- target/hexagon/mmvec/macros.h | 23 +++++++++++++++-------- target/hexagon/mmvec/mmvec.h | 18 ++++++++++++++++++ target/hexagon/cpu.c | 17 +++++++++++------ target/hexagon/genptr.c | 3 ++- target/hexagon/mmvec/system_ext_mmvec.c | 2 +- target/hexagon/op_helper.c | 17 ++++++++++++----- 6 files changed, 59 insertions(+), 21 deletions(-) diff --git a/target/hexagon/mmvec/macros.h b/target/hexagon/mmvec/macros.h index b36f833b1de..e85beed3387 100644 --- a/target/hexagon/mmvec/macros.h +++ b/target/hexagon/mmvec/macros.h @@ -53,7 +53,7 @@ =20 #define LOG_VTCM_BYTE(VA, MASK, VAL, IDX) \ do { \ - env->vtcm_log.data.ub[IDX] =3D (VAL); \ + hexagon_mmvec_set_byte(&env->vtcm_log.data, IDX, VAL); \ if (MASK) { \ set_bit((IDX), env->vtcm_log.mask); \ } else { \ @@ -133,7 +133,8 @@ target_ulong va_high =3D EA + LEN; \ for (int i0 =3D 0; i0 < 4; i0++) { \ log_byte =3D (va + i0) <=3D va_high; \ - LOG_VTCM_BYTE(va + i0, log_byte, INC. ub[4 * IDX + i0], \ + LOG_VTCM_BYTE(va + i0, log_byte, \ + hexagon_mmvec_get_byte(&(INC), 4 * IDX + i0), \ 4 * IDX + i0); \ } \ } while (0) @@ -144,7 +145,8 @@ target_ulong va_high =3D EA + LEN; \ for (int i0 =3D 0; i0 < 2; i0++) { \ log_byte =3D (va + i0) <=3D va_high; \ - LOG_VTCM_BYTE(va + i0, log_byte, INC.ub[2 * IDX + i0], \ + LOG_VTCM_BYTE(va + i0, log_byte, \ + hexagon_mmvec_get_byte(&(INC), 2 * IDX + i0), \ 2 * IDX + i0); \ } \ } while (0) @@ -157,7 +159,8 @@ target_ulong va_high =3D EA + LEN; \ for (int i0 =3D 0; i0 < 2; i0++) { \ log_byte =3D (va + i0) <=3D va_high; \ - LOG_VTCM_BYTE(va + i0, log_byte, INC.ub[2 * IDX + i0], \ + LOG_VTCM_BYTE(va + i0, log_byte, \ + hexagon_mmvec_get_byte(&(INC), 2 * IDX + i0), \ 2 * IDX + i0); \ } \ } while (0) @@ -174,7 +177,8 @@ log_byte =3D ((va + i0) <=3D va_high) && QVAL; \ uint8_t B; \ B =3D cpu_ldub_data_ra(env, EA + i0, ra); \ - env->tmp_VRegs[0].ub[ELEMENT_SIZE * IDX + i0] =3D B; \ + hexagon_mmvec_set_byte(&env->tmp_VRegs[0], \ + ELEMENT_SIZE * IDX + i0, B); \ LOG_VTCM_BYTE(va + i0, log_byte, B, ELEMENT_SIZE * IDX + i0); \ } \ } while (0) @@ -216,9 +220,10 @@ uint8_t val; \ val =3D cpu_ldub_data_ra(env, env->vtcm_log.va[i + j],= ra); \ dst |=3D val << (8 * j); \ - inc |=3D env->vtcm_log.data.ub[j + i] << (8 * j); \ + inc |=3D hexagon_mmvec_get_byte(&env->vtcm_log.data, j= + i) \ + << (8 * j); \ clear_bit(j + i, env->vtcm_log.mask); \ - env->vtcm_log.data.ub[j + i] =3D 0; \ + hexagon_mmvec_set_byte(&env->vtcm_log.data, j + i, 0);= \ } \ dst +=3D inc; \ for (int j =3D 0; j < sizeof(TYPE); j++) { \ @@ -249,7 +254,9 @@ int log_byte =3D 0; \ for (i0 =3D 0; i0 < ELEM_SIZE; i0++) { \ log_byte =3D ((va + i0) <=3D va_high) && QVAL; \ - LOG_VTCM_BYTE(va + i0, log_byte, IN.ub[ELEM_SIZE * IDX + i0], \ + LOG_VTCM_BYTE(va + i0, log_byte, \ + hexagon_mmvec_get_byte(&(IN), \ + ELEM_SIZE * IDX + i0),= \ ELEM_SIZE * IDX + i0); \ } \ } while (0) diff --git a/target/hexagon/mmvec/mmvec.h b/target/hexagon/mmvec/mmvec.h index 8e72f2f6ae7..662f9d1597e 100644 --- a/target/hexagon/mmvec/mmvec.h +++ b/target/hexagon/mmvec/mmvec.h @@ -20,6 +20,7 @@ =20 #include "exec/target_long.h" #include "qemu/bitmap.h" +#include "qemu/bitops.h" =20 #define MAX_VEC_SIZE_LOGBYTES 7 #define MAX_VEC_SIZE_BYTES (1 << MAX_VEC_SIZE_LOGBYTES) @@ -69,6 +70,23 @@ typedef union { int8_t b[MAX_VEC_SIZE_BYTES / 1 / 8]; } MMQReg; =20 +static inline uint8_t hexagon_mmvec_get_byte(const MMVector *v, size_t ind= ex) +{ + return extract64(v->ud[index / 8], (index % 8) * 8, 8); +} + +static inline void hexagon_mmvec_set_byte(MMVector *v, size_t index, + uint8_t value) +{ + v->ud[index / 8] =3D deposit64(v->ud[index / 8], (index % 8) * 8, 8, + value); +} + +static inline uint8_t hexagon_mmqreg_get_byte(const MMQReg *q, size_t inde= x) +{ + return extract32(q->uw[index / 4], (index % 4) * 8, 8); +} + typedef struct { MMVector data; DECLARE_BITMAP(mask, MAX_VEC_SIZE_BYTES); diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 4a7b76e3bcc..ac5821a1e44 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -182,7 +182,7 @@ static void print_vreg(FILE *f, CPUHexagonState *env, i= nt regnum, if (skip_if_zero) { bool nonzero_found =3D false; for (int i =3D 0; i < MAX_VEC_SIZE_BYTES; i++) { - if (env->VRegs[regnum].ub[i] !=3D 0) { + if (hexagon_mmvec_get_byte(&env->VRegs[regnum], i) !=3D 0) { nonzero_found =3D true; break; } @@ -193,9 +193,12 @@ static void print_vreg(FILE *f, CPUHexagonState *env, = int regnum, } =20 qemu_fprintf(f, " v%d =3D ( ", regnum); - qemu_fprintf(f, "0x%02x", env->VRegs[regnum].ub[MAX_VEC_SIZE_BYTES - 1= ]); + qemu_fprintf(f, "0x%02x", + hexagon_mmvec_get_byte(&env->VRegs[regnum], + MAX_VEC_SIZE_BYTES - 1)); for (int i =3D MAX_VEC_SIZE_BYTES - 2; i >=3D 0; i--) { - qemu_fprintf(f, ", 0x%02x", env->VRegs[regnum].ub[i]); + qemu_fprintf(f, ", 0x%02x", + hexagon_mmvec_get_byte(&env->VRegs[regnum], i)); } qemu_fprintf(f, " )\n"); } @@ -211,7 +214,7 @@ static void print_qreg(FILE *f, CPUHexagonState *env, i= nt regnum, if (skip_if_zero) { bool nonzero_found =3D false; for (int i =3D 0; i < MAX_VEC_SIZE_BYTES / 8; i++) { - if (env->QRegs[regnum].ub[i] !=3D 0) { + if (hexagon_mmqreg_get_byte(&env->QRegs[regnum], i) !=3D 0) { nonzero_found =3D true; break; } @@ -223,9 +226,11 @@ static void print_qreg(FILE *f, CPUHexagonState *env, = int regnum, =20 qemu_fprintf(f, " q%d =3D ( ", regnum); qemu_fprintf(f, "0x%02x", - env->QRegs[regnum].ub[MAX_VEC_SIZE_BYTES / 8 - 1]); + hexagon_mmqreg_get_byte(&env->QRegs[regnum], + MAX_VEC_SIZE_BYTES / 8 - 1)); for (int i =3D MAX_VEC_SIZE_BYTES / 8 - 2; i >=3D 0; i--) { - qemu_fprintf(f, ", 0x%02x", env->QRegs[regnum].ub[i]); + qemu_fprintf(f, ", 0x%02x", + hexagon_mmqreg_get_byte(&env->QRegs[regnum], i)); } qemu_fprintf(f, " )\n"); } diff --git a/target/hexagon/genptr.c b/target/hexagon/genptr.c index 1f109d44de8..cfcbd77d47a 100644 --- a/target/hexagon/genptr.c +++ b/target/hexagon/genptr.c @@ -1557,7 +1557,8 @@ static void vec_to_qvec(size_t size, intptr_t dstoff,= intptr_t srcoff) tcg_gen_deposit_i64(mask, mask, bits, j, size); } =20 - tcg_gen_st8_i64(mask, tcg_env, dstoff + i); + tcg_gen_st8_i64(mask, tcg_env, + dstoff + (i ^ (HOST_BIG_ENDIAN ? 3 : 0))); } } =20 diff --git a/target/hexagon/mmvec/system_ext_mmvec.c b/target/hexagon/mmvec= /system_ext_mmvec.c index 8351f2cc01b..081cadd814a 100644 --- a/target/hexagon/mmvec/system_ext_mmvec.c +++ b/target/hexagon/mmvec/system_ext_mmvec.c @@ -26,7 +26,7 @@ void mem_gather_store(CPUHexagonState *env, target_ulong = vaddr, int slot) env->vstore_pending[slot] =3D 1; env->vstore[slot].va =3D vaddr; env->vstore[slot].size =3D size; - memcpy(&env->vstore[slot].data.ub[0], &env->tmp_VRegs[0], size); + memcpy(&env->vstore[slot].data, &env->tmp_VRegs[0], size); =20 /* On a gather store, overwrite the store mask to emulate dropped gath= ers */ bitmap_copy(env->vstore[slot].mask, env->vtcm_log.mask, size); diff --git a/target/hexagon/op_helper.c b/target/hexagon/op_helper.c index 71555a7ba36..d74faebc582 100644 --- a/target/hexagon/op_helper.c +++ b/target/hexagon/op_helper.c @@ -168,7 +168,10 @@ void HELPER(commit_hvx_stores)(CPUHexagonState *env) int size =3D env->vstore[i].size; for (int j =3D 0; j < size; j++) { if (test_bit(j, env->vstore[i].mask)) { - cpu_stb_data_ra(env, va + j, env->vstore[i].data.ub[j]= , ra); + cpu_stb_data_ra(env, va + j, + hexagon_mmvec_get_byte(&env->vstore[i]= .data, + j), + ra); } } } @@ -191,9 +194,11 @@ void HELPER(commit_hvx_stores)(CPUHexagonState *env) for (int i =3D 0; i < sizeof(MMVector); i++) { if (test_bit(i, env->vtcm_log.mask)) { cpu_stb_data_ra(env, env->vtcm_log.va[i], - env->vtcm_log.data.ub[i], ra); + hexagon_mmvec_get_byte(&env->vtcm_log= .data, + i), + ra); clear_bit(i, env->vtcm_log.mask); - env->vtcm_log.data.ub[i] =3D 0; + hexagon_mmvec_set_byte(&env->vtcm_log.data, i, 0); } =20 } @@ -1404,7 +1409,8 @@ void HELPER(vhist)(CPUHexagonState *env) =20 for (int lane =3D 0; lane < 8; lane++) { for (int i =3D 0; i < sizeof(MMVector) / 8; ++i) { - unsigned char value =3D input->ub[(sizeof(MMVector) / 8) * lan= e + i]; + unsigned char value =3D hexagon_mmvec_get_byte(input, + (sizeof(MMVector) / 8) * lane + i); unsigned char regno =3D value >> 3; unsigned char element =3D value & 7; =20 @@ -1419,7 +1425,8 @@ void HELPER(vhistq)(CPUHexagonState *env) =20 for (int lane =3D 0; lane < 8; lane++) { for (int i =3D 0; i < sizeof(MMVector) / 8; ++i) { - unsigned char value =3D input->ub[(sizeof(MMVector) / 8) * lan= e + i]; + unsigned char value =3D hexagon_mmvec_get_byte(input, + (sizeof(MMVector) / 8) * lane + i); unsigned char regno =3D value >> 3; unsigned char element =3D value & 7; =20 --=20 2.34.1 From nobody Sat Sep 26 21:36:27 2026 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1788485043; cv=none; d=zohomail.com; s=zohoarc; b=cThaGdg/WaU3sTZ1oHbkZv3AmLQMNQdfysuQp+W0zxol5XbWJudrsVdLqXb1IJpfehkfZid63lkxE3KcIUq0vzOIxk9W++shLiYvOcbJB0DnVZGiEe7G6m5RPiAhXmEnnXVkfJLjRRbvPVgKUeMZLrEdFGuFMns4e/UGOHOX7gI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788485043; h=Content-Type: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=juq5ZinBhPzOSKDUGTfqthO6Pp9zsRWNDrQ54Ur55pQ=; b=aiJVyAd8RZ20guhtspyESA7M/e9S9lqFBJV4fBhIYOc/nVo5Vqx/8JdeqyyewwE22r+MAcF9Yr150M8G2FSonWvRsAKXYf5ZbAyhEtEZPrB7aC8z0yY7WMBoRs3fT3GeCGwNqDN0ec9z/9Scor/GwhQh/5sC/qlSLW5KXgKNMhA= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788485043063582.0015799139186; Thu, 3 Sep 2026 18:24:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x2Idh-00079b-Bs; Thu, 03 Sep 2026 21:22:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2Idf-00078i-Df for qemu-devel@nongnu.org; Thu, 03 Sep 2026 21:22:43 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2Idd-0005J6-Nm for qemu-devel@nongnu.org; Thu, 03 Sep 2026 21:22:43 -0400 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 683NbdJu1260699 for ; Fri, 4 Sep 2026 01:22:39 GMT Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gfdyp1gcw-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 04 Sep 2026 01:22:38 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cc1c18c775eso1859713a12.0 for ; Thu, 03 Sep 2026 18:22:38 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3339885ca07sm2573234eec.1.2026.09.03.18.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 18:22:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= juq5ZinBhPzOSKDUGTfqthO6Pp9zsRWNDrQ54Ur55pQ=; b=pxcODZky5PRHALXr EQqAkpISmO0ju5ILXrN8HqMis7HrvBokWowPKARxQgMDA/NazvmyEqi+3q+Y80Wc 7KZGaEt0SKASqwMpglEYJJBdBLPYJX8/2GDAml/w0S0MpyUgckTBwSriB6GjzR0A My87pNByIl+HCW0jAfjDRdR/izZR+GmiMEa40zzMCsTQkhXUPcgYNpcpRcZ01B4B Ewpmnhrz5hf1Uc92vrmd0S6Ks4jV0tB61hmJiS59xZ3csAbIusoTnT0Y7qjizBA8 UZmrd1+LjRYSkGNlyzwlAVKYvyRuDely5d+mxLrTOxXxY4VuPW/jlF4/HZ/OI/cg bh/K3w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788484958; x=1789089758; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=juq5ZinBhPzOSKDUGTfqthO6Pp9zsRWNDrQ54Ur55pQ=; b=P2R0HSAImxu16JPCc8g0/fNnUWB2aYihO+NwM5qQGkZOLkj+5gyPg6fOHMwKvptubx HYLNNqrIkbcf3vQzOKzsFnoey76dlY53Ukfd+JhU+/GJcYSWl+0avU6EkCAKqWuTVZ2L viYbAI8E8Ta3fdy+QAyu8hIzLuH5mvwFuQoYl9sdI1yOSCnixeqjRv2DQ50g5y4QbURY MGRn0b/bTdH+WDuhUsuwBnOf5HVOI99ZT801t2KB5n+nryrY2k3j6p0sERxiQTFgrFNM UPhKUKMg9LJHnVN+vYfrZW4lod1i6JUPo8NHs3MxMjZ9PqXX3zi+0zflqn35niyg/eJK rZLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788484958; x=1789089758; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=juq5ZinBhPzOSKDUGTfqthO6Pp9zsRWNDrQ54Ur55pQ=; b=gcDpvM3i5pVlaHCznHUxgd2Lld+gtiTh6DuuMnrIMQFXtjrqpGfqG0Zihza2lzM115 skokwXcnVDaYuj1ueeFFa/TN46mtThwiW/8VkaYgl6/zEYg1EN2TyomCLXhhq+6geAuL gaTaHgIf7jAJ9RRn6PJMjJwurwi7RgDXRzTjs5/hL8uGCsoO01YSuHp0MIDmX5XoqqOV gijqrkyFgIl6ZpnJVonYb7VaFeQYHrfyt7QrlJ6JXzN/3kRTaf9hTlSfRsdwxSxtOiJi ZJajPOeuBLpgUFnyaxVDWGHlGBThIEQEFz4cWq34GLRsYyEGO4jGQ83z/Ig+iHXuwRp0 T4wQ== X-Gm-Message-State: AFuF++n4TgD7sFOCUxo/rixB86FFYiQHwo335Ybj9FI9nI3AT+FKHyQA i0Jct56XJCZpgewkbpeOYcnLloQsQ+XO66R05tKdUUNSHqM6aU/X7smRDHGjF6J9copVYZspgnw gWGN4jUtjnsxWfT/3zJ0+l8NYdW4j9XxlfNGPV/fVtWfBhk3deqjJQhKR1CLhkavZ3g== X-Gm-Gg: AYBFou07DUtQ3YRygTqNgDqgDEN6PVldrGOhrUovEOSFS+Iir4pv4aYbBFSztXhgcwH n4qFSLMbYnqz64MPfUXvinXaovOPjaucWPryOsm0T6jwoW3YGEm3buBVQt9Q3WMlZKL3JUse7kT RiAnoKarcwOnaHKXlx8Rya28dHCOuAqkDKHH8IcZwdPalYE1VZpOet63wFYMoOb4eqNhVBKXpQp 9i1RiHJcudGICytnZvRp96ZB6eLM97N8Jx9Y9ZljDvXRBnPlwfccbE7ktSCKDyuccfM2e7Z5EM9 pNcNjACjQuhRRcawSCWq+tqCjGgT/ab/wpA4nMmu7WwUtvoEm7DgOcvBXKVk04fG+JC7s47aR7u ryFJ19ZxEPYoemm9OJ4S6QRFiWOg/E8dmu1wIFlDLamzYVSgo X-Received: by 2002:a17:90a:ec84:b0:36b:b903:994 with SMTP id 98e67ed59e1d1-39b07f44dbdmr11643926a91.4.1788484958345; Thu, 03 Sep 2026 18:22:38 -0700 (PDT) X-Received: by 2002:a17:90a:ec84:b0:36b:b903:994 with SMTP id 98e67ed59e1d1-39b07f44dbdmr11643883a91.4.1788484957879; Thu, 03 Sep 2026 18:22:37 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: Brian Cain , Pierrick Bouvier , Matheus Tavares Bernardino Subject: [PATCH v3 2/5] target/hexagon: fix HVX scatter/gather region-length check Date: Thu, 3 Sep 2026 18:22:30 -0700 Message-Id: <20260904012233.3607547-3-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com> References: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: WQmAJuFTqN21GMz0VhIQIHe6aL-SEhQO X-Proofpoint-GUID: WQmAJuFTqN21GMz0VhIQIHe6aL-SEhQO X-Authority-Analysis: v=2.4 cv=Q5XiJY2a c=1 sm=1 tr=0 ts=6a9a1d5f cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=dpjYNSh0uHncNrtL9ygA:9 a=QEXdDO2ut3YA:10 a=_Vgx9l1VpLgwpw_dHYaR:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTA0MDAxMCBTYWx0ZWRfX0+KDpo5r7fe3 dg3Gppc1y+UapGfyXgIOdfwJDjZMzQ0btYgGXZ2iNC55DLeg9BPM5mRzQwYFWAZ9rRsvTT4556V vgz3Bx6XkE1la0epTSXl1i5KSaPeLUHibjLNHOXfVZVFHr8ahWZfTb/ik1PlT9rX4sVIIMorWtE xTHQmzpCq48wDOJq/pZKv1+gO6JfV2cQK2oXFsbUVyiPl87j033vqUE93xAC1lcDCsylGM+4LCS LbuOpVdD2tuMkJ8SSQU6x2Csxp82V5DKU+QhoOz6Lbm/ajg6RoScWmjeB5LE3qxmSKICq4wClN/ bZaNNewt7cpNnIsIHNy4SbUfsxqujZexICAomJtBANC8qN6fdPoTv1eDgA093sWXuYTd/mV+UZk Y3DH4+DOa7ILtqkxuk32YvRNSwEB3Fk5+MuPKl/MTpB81vN3ewdOsY3+pTdIg2iw4vd2FORAYdL rTQOz1XTsrIWLaXaGmw== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTA0MDAxMCBTYWx0ZWRfX/fqYvBATFWSe CMlJRQnEwbcRtMGtUKHbrvq91ZdohgkA8SuBQZkIBSJOn/SDZZc0MIrO9HWtxREadrn7XMPaVcg RlGMTuAHdPGCU6MKVQW4mcJ+JxJoXME= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-03_07,2026-09-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 impostorscore=0 adultscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609040010 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1788485046323158500 The region-length bounds check compared (EA + i0) <=3D (EA + LEN), which reduces to i0 <=3D LEN and never actually depends on the region base. This let vgather/vscatter keep elements whose offset was beyond the declared region instead of dropping them. Compare the offset to the region length directly instead. Only load bytes for gather lanes that are kept. A dropped or predicate-false lane must not access memory and raise an exception. Reviewed-by: Matheus Tavares Bernardino Signed-off-by: Brian Cain --- target/hexagon/mmvec/macros.h | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/target/hexagon/mmvec/macros.h b/target/hexagon/mmvec/macros.h index e85beed3387..858afd995d9 100644 --- a/target/hexagon/mmvec/macros.h +++ b/target/hexagon/mmvec/macros.h @@ -130,9 +130,9 @@ do { \ int log_byte =3D 0; \ target_ulong va =3D EA; \ - target_ulong va_high =3D EA + LEN; \ + int in_region =3D (OFFSET) <=3D (LEN); \ for (int i0 =3D 0; i0 < 4; i0++) { \ - log_byte =3D (va + i0) <=3D va_high; \ + log_byte =3D in_region; \ LOG_VTCM_BYTE(va + i0, log_byte, \ hexagon_mmvec_get_byte(&(INC), 4 * IDX + i0), \ 4 * IDX + i0); \ @@ -142,9 +142,9 @@ do { \ int log_byte =3D 0; \ target_ulong va =3D EA; \ - target_ulong va_high =3D EA + LEN; \ + int in_region =3D (OFFSET) <=3D (LEN); \ for (int i0 =3D 0; i0 < 2; i0++) { \ - log_byte =3D (va + i0) <=3D va_high; \ + log_byte =3D in_region; \ LOG_VTCM_BYTE(va + i0, log_byte, \ hexagon_mmvec_get_byte(&(INC), 2 * IDX + i0), \ 2 * IDX + i0); \ @@ -156,9 +156,9 @@ do { \ int log_byte =3D 0; \ target_ulong va =3D EA; \ - target_ulong va_high =3D EA + LEN; \ + int in_region =3D (OFFSET) <=3D (LEN); \ for (int i0 =3D 0; i0 < 2; i0++) { \ - log_byte =3D (va + i0) <=3D va_high; \ + log_byte =3D in_region; \ LOG_VTCM_BYTE(va + i0, log_byte, \ hexagon_mmvec_get_byte(&(INC), 2 * IDX + i0), \ 2 * IDX + i0); \ @@ -170,15 +170,18 @@ do { \ int i0; \ target_ulong va =3D EA; \ - target_ulong va_high =3D EA + LEN; \ uintptr_t ra =3D GETPC(); \ int log_byte =3D 0; \ + int in_region =3D (OFFSET) <=3D (LEN); \ for (i0 =3D 0; i0 < ELEMENT_SIZE; i0++) { \ - log_byte =3D ((va + i0) <=3D va_high) && QVAL; \ - uint8_t B; \ - B =3D cpu_ldub_data_ra(env, EA + i0, ra); \ - hexagon_mmvec_set_byte(&env->tmp_VRegs[0], \ - ELEMENT_SIZE * IDX + i0, B); \ + uint8_t B =3D 0; \ + \ + log_byte =3D in_region && QVAL; \ + if (log_byte) { \ + B =3D cpu_ldub_data_ra(env, va + i0, ra); \ + hexagon_mmvec_set_byte(&env->tmp_VRegs[0], \ + ELEMENT_SIZE * IDX + i0, B); \ + } \ LOG_VTCM_BYTE(va + i0, log_byte, B, ELEMENT_SIZE * IDX + i0); \ } \ } while (0) @@ -250,10 +253,10 @@ do { \ int i0; \ target_ulong va =3D EA; \ - target_ulong va_high =3D EA + LEN; \ int log_byte =3D 0; \ + int in_region =3D (OFFSET) <=3D (LEN); \ for (i0 =3D 0; i0 < ELEM_SIZE; i0++) { \ - log_byte =3D ((va + i0) <=3D va_high) && QVAL; \ + log_byte =3D in_region && QVAL; \ LOG_VTCM_BYTE(va + i0, log_byte, \ hexagon_mmvec_get_byte(&(IN), \ ELEM_SIZE * IDX + i0),= \ --=20 2.34.1 From nobody Sat Sep 26 21:36:27 2026 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1788485053; cv=none; d=zohomail.com; s=zohoarc; b=WeCDQq7+TZwCq8Sq9pCwRrkKVWVqma25QqNNCl5y0dROP2QOWFe+gazlDrzINX1q6q98iX+YqYXXBiObNLWKVw5Pj7bAzjsFT1/kcRiUS/iNSzogfZvsr5MvdlgpqmrWUrk1EnYkQFADsLZwSGhHdRJ693NFY6EKTYcM/aitahM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788485053; h=Content-Type: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=vafqYva72uUiSMNa6o58yvOC4e5NILuvByOVikcpC18=; b=CBFNGH3Seek+XkJ0Tf306Ki2Sf2dGoz3WLwPBEgDhAW4aiSMQVZ3b5R+ocVF0/do3OxXo9GYezY76y4tvCsNcnWK9AXZPas6OukiQekIRGb/sQoaQt/m+bAsl8ME9rOIj1AKJfgrB5gFmhXYue9g1QbMPjDACHosafNa6j10cDU= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788485053872979.1123607238112; Thu, 3 Sep 2026 18:24:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x2Idh-0007A2-PY; Thu, 03 Sep 2026 21:22:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2Idg-00078s-1a for qemu-devel@nongnu.org; Thu, 03 Sep 2026 21:22:44 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2Idd-0005JC-TO for qemu-devel@nongnu.org; Thu, 03 Sep 2026 21:22:43 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 683NbjAP1948371 for ; Fri, 4 Sep 2026 01:22:40 GMT Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gfdyxhfvy-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 04 Sep 2026 01:22:40 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-38e1118e4abso852309a91.0 for ; Thu, 03 Sep 2026 18:22:40 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3339885ca07sm2573234eec.1.2026.09.03.18.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 18:22:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= vafqYva72uUiSMNa6o58yvOC4e5NILuvByOVikcpC18=; b=eXNk3h8ZaDaU7GHW yJPbyEMEkEc/BVbNAdWo8i2zQX5wrWk8hIJNWmCSqU5zh/ZQ861H42Xh58v3r24y fZxIPggCkvJls5rT3bIrYGrFQABbGz1rpYVZ08Gg8k9PC6EbGlHdvFqRhTnJY/WL JUL0jJSAMEwSLA1dxgguuzsDykybESMn/WR2e5s76aLlCoBCKtsf+aPQIKwDgsQD H9IakQ3b4PkAvHN4896LvISx+T1cCWQ8DPinOnSH/B+p6JO+rsrMJZpXIvoL+uih 9fQ9Jx2+yvkwQWCCLseQqCbDtc/RVuEH0tLDNyyFBdHLPGqKgnZgZQnYwTF3NSD3 CelMLg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788484960; x=1789089760; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=vafqYva72uUiSMNa6o58yvOC4e5NILuvByOVikcpC18=; b=SUCvZInWby+ZnU2Uz0/FKPPeYy+xFpPnpJ15zXurYNBSxPpQvaFf0qx2D9UZSIDFcy K5GTHpEYzq3HuUnxn8t+/1gvdwlfdDHHYnsie2RQGDVXZH6UtB4drGT1vU6pMmbjH01P 6qfDcN5Z1t7uGTQCJplf1aVxfsOxw+vijDX5xG+D8+emq+vD04VF51d7hWzvDZsmMo2a o/xzzSIOh4qNNF440hEciIsKmCgmr8Lkk0N7G50oWNIbs4YYINXkR4dNzGCikmWiHBvL NULUmvRpcVFxD9b4eyOXMd3zfcQnATeyumgF2Y6U+/ubt6XzE5egSsPAajx5jRnu7pXn ArJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788484960; x=1789089760; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vafqYva72uUiSMNa6o58yvOC4e5NILuvByOVikcpC18=; b=hnBMJXBNxY2e1ZAH4Yk81NbO7TMJAa1UDMNzq/VOODHdbA5kOwbUdEZNGs6nTakjhY rSiGHrzJk2GUzcErnpnAlvRtxaP8q8phtSIoyHzrNiYbGI+Z5Z66gKZF0Vo7vEHO9tAI oiIW74XRNm56Y5Uh84NCCl9f4mg1JvNNQjKu4C5jDGx73awtKDdAwNGwDJWoDZspDkiC Mh0DbcWE1iGRB7fT6LCD4di/9tscKcL66MeZMnTYnUNq5btWD287234Cu7+qYFmURFM4 bzeUa+4pjDGdzq44GHZ60gjLKglZ19NZGhN/qMFozaRwLAUFiTejFEXw0lFbKOfp7eRh ipQQ== X-Gm-Message-State: AFuF++kZipXfXtbn4tmwPZ8eucxdnOw3hc70JbJ3G2blFIP3LQAKt/0F kzWbCiDoVcueOfF2b9nUPz/uHQqzKGeE90wGlyLd6JILEm177SYIuEajVvIjp4H8rFo7ggN5LMv U6PWGgSOKqF5ubQf2x15UhBs8eX7SXExxbMcSHkR9Ntvi07iknPkVTcpv8v52FUhU9Q== X-Gm-Gg: AYBFou2iuf6A1pVKSqGPLkU+xen1/+hC9eY5nOiMkZzY+TDrjwoMSGLnBT2vE6Qlca3 5wMVvKEYo2NmLfeLG3rtwBXSyVt8xc7vKaBkg3MgPJlYLV+hJCX+rCL8q32PXBBgzvrM2+D3j0Y B9y7usDIrKc9leMcucDNLIrOhYdkVaV0J4EhEPWyduWvojqohzMlu5lQCkn2gOzdChZJe7BVlMc sggyBpQjkw6p7ldXawNINz4epdVBog4gERhFbqNQ7ZB1AE5jX6M3s0eLkVnzEiwdgOrYVXmJF1Y WLsw/YNOGsWgy7ORgYTHcGGaoV/wdidAEtJS6IKxA5BEOr+KqWBe2rgh+5o8dyfESUXHTVQCzGZ SRHPS/YlnhEXFyRVspNRx7O+8QPJsbDKqLt0GoBxcqFoOh8XH X-Received: by 2002:a17:90a:d44b:b0:396:4cbf:45bc with SMTP id 98e67ed59e1d1-39b26203f11mr4107303a91.16.1788484959865; Thu, 03 Sep 2026 18:22:39 -0700 (PDT) X-Received: by 2002:a17:90a:d44b:b0:396:4cbf:45bc with SMTP id 98e67ed59e1d1-39b26203f11mr4107241a91.16.1788484959395; Thu, 03 Sep 2026 18:22:39 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: Brian Cain , Pierrick Bouvier Subject: [PATCH v3 3/5] tests/tcg/hexagon: add vgather/vscatter region-length tests Date: Thu, 3 Sep 2026 18:22:31 -0700 Message-Id: <20260904012233.3607547-4-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com> References: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 4w3CJq3aEOXojmGjM3OTO-e9pK9vPiCr X-Proofpoint-Spam-Info: AW1haW4tMjYwOTA0MDAxMCBTYWx0ZWRfX2+RLV/L5KnEz gkB2tsMMvTIHF0btGGpbwJ0Oj3pb+IPoG24hOGrDisRiIillCb7T14LytU1yjErpuVEGFwhHK1/ QLONGcEyeFuC2M9vDN41q5OgWnbPK2Y= X-Proofpoint-GUID: 4w3CJq3aEOXojmGjM3OTO-e9pK9vPiCr X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTA0MDAxMCBTYWx0ZWRfXwvzLPRcRgnbY S9gwp6RWw5P5PLDt0Z/bXzZiVxLTg6g/WmG2WjkNfSlMpPwktAcYrhtphNha+GYmWgCuoB3KOE3 7y0P/z7jkrhQQLxlasnEuukGlYSVdFsshM3RVvp1iMQ3WpyBnPVdR26T6bAMT+eBpRtmWNdbiFu rj0FzHjIprc2ksQdkP2w0iLv7PJzdHnjrNHiEJdfotQ4XjQVWWYZtWu/DBo5/qWDjsyY5sd2hW4 wU3+BVMxzuV9i6JeufV97igl9scSyHi8ZL+BVr/3MERgg8ZjB8/7tZvfzj+JG0JBGoAGUnDmWDQ WReMyIi4/uLtaaGm3J16MIEmyQubnySuUWagjXVfuVofi9EHpjcQsiHhFnu7A4+gXqBAWHVtJXp XisBO4JDdy9p34w+H/2pjid6qAHKGaOD9eNJKtApBRYVPisk9ba69FnKODdLdCDPXiZFH3N6GgN pCCO59+/Tgc46HPZyvQ== X-Authority-Analysis: v=2.4 cv=X9Zi7mTe c=1 sm=1 tr=0 ts=6a9a1d60 cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=0wXhRAlk9XZiN57P8QAA:9 a=QEXdDO2ut3YA:10 a=mQ_c8vxmzFEMiUWkPHU9:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-03_07,2026-09-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609040010 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1788485056226158500 Cover the case where an offset lies beyond the region length: it must be dropped rather than read/written. Place one dropped gather offset on a PROT_NONE page to verify that the instruction does not access memory for that lane. Signed-off-by: Brian Cain Reviewed-by: Pierrick Bouvier --- tests/tcg/hexagon/scatter_gather.c | 137 ++++++++++++++++++++++++++++- 1 file changed, 136 insertions(+), 1 deletion(-) diff --git a/tests/tcg/hexagon/scatter_gather.c b/tests/tcg/hexagon/scatter= _gather.c index bf8b5e03172..40f00cc6cf5 100644 --- a/tests/tcg/hexagon/scatter_gather.c +++ b/tests/tcg/hexagon/scatter_gather.c @@ -31,7 +31,11 @@ #include #include #include +#include #include +#include +#include +#include =20 typedef long HVX_Vector __attribute__((__vector_size__(128))) __attribute__((aligned(128))); @@ -85,6 +89,23 @@ unsigned int word_predicates[MATRIX_SIZE] __attribute_= _((aligned(128))); /* make this big enough for all the operations */ const size_t region_len =3D sizeof(vtcm); =20 +/* Mu (region length - 1); offset is kept iff offset <=3D Mu */ +#define REGION_LEN_TEST_MU 127 +#define GATHER_LEN_TEST_PAGE_SIZE 4096 +static unsigned char *gather_len_test_src; +static unsigned char gather_len_test_dst[128] __attribute__((aligned(128))= ); +static unsigned char gather_len_test_dst_ref[128]; + +/* The dropped offset must remain in the backing destination buffer. */ +#define SCATTER_LEN_TEST_DST_SIZE 512 +static unsigned char scatter_len_test_dst[SCATTER_LEN_TEST_DST_SIZE] + __attribute__((aligned(128))); +static unsigned char scatter_len_test_dst_ref[SCATTER_LEN_TEST_DST_SIZE]; +static unsigned short region_len_test_offsets[MATRIX_SIZE] + __attribute__((aligned(128))); +static unsigned short scatter_len_test_values[MATRIX_SIZE] + __attribute__((aligned(128))); + /* optionally add sync instructions */ #define SYNC_VECTOR 1 =20 @@ -96,7 +117,7 @@ static void sync_scatter(void *addr) * synchronization. Normally the dummy load would be deferred as * long as possible to minimize stalls. */ - asm volatile("vmem(%0 + #0):scatter_release\n" : : "r"(addr)); + asm volatile("vmem(%[addr] + #0):scatter_release\n" : : [addr] "r"(add= r)); /* use volatile to force the load */ volatile HVX_Vector vDummy =3D *(HVX_Vector *)addr; vDummy =3D vDummy; #endif @@ -855,6 +876,112 @@ void check_gather_16_32_masked(void) MATRIX_SIZE * sizeof(unsigned short)); } =20 +static void init_region_len_test_offsets(void) +{ + memset(region_len_test_offsets, 0, sizeof(region_len_test_offsets)); + region_len_test_offsets[0] =3D 0; /* in region */ + region_len_test_offsets[1] =3D REGION_LEN_TEST_MU - 1; /* in region */ + region_len_test_offsets[2] =3D REGION_LEN_TEST_MU; /* in region */ + region_len_test_offsets[3] =3D REGION_LEN_TEST_MU + 1; /* dropped */ + region_len_test_offsets[4] =3D 256; /* dropped */ +} + +/* vgather must drop elements whose offset is beyond the region */ +void create_gather_region_len_test(void) +{ + unsigned char *mapping; + + mapping =3D mmap(NULL, 2 * GATHER_LEN_TEST_PAGE_SIZE, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + assert(mapping !=3D MAP_FAILED); + assert(mprotect(mapping + GATHER_LEN_TEST_PAGE_SIZE, + GATHER_LEN_TEST_PAGE_SIZE, PROT_NONE) =3D=3D 0); + gather_len_test_src =3D mapping + GATHER_LEN_TEST_PAGE_SIZE - 256; + + for (int i =3D 0; i < 256; i++) { + gather_len_test_src[i] =3D (unsigned char)(13 + 7 * i); + } + init_region_len_test_offsets(); + memset(gather_len_test_dst, FILL_CHAR, sizeof(gather_len_test_dst)); +} + +/* gather with a region shorter than the source buffer, using HVX */ +void vector_gather_region_len(void) +{ + HVX_Vector voff =3D *(HVX_Vector *)region_len_test_offsets; + + Q6_vgather_ARMVh((HVX_Vector *)gather_len_test_dst, + (int)(uintptr_t)gather_len_test_src, + REGION_LEN_TEST_MU, voff); + + sync_gather(gather_len_test_dst); +} + +/* gather with a region shorter than the source buffer, using C */ +void scalar_gather_region_len(unsigned char *dst) +{ + for (int i =3D 0; i < MATRIX_SIZE; i++) { + unsigned short off =3D region_len_test_offsets[i]; + if (off <=3D REGION_LEN_TEST_MU) { + dst[2 * i] =3D gather_len_test_src[off]; + dst[2 * i + 1] =3D gather_len_test_src[off + 1]; + } + } +} + +void check_gather_region_len(void) +{ + memset(gather_len_test_dst_ref, FILL_CHAR, + sizeof(gather_len_test_dst_ref)); + scalar_gather_region_len(gather_len_test_dst_ref); + check_buffer(__func__, gather_len_test_dst, gather_len_test_dst_ref, + sizeof(gather_len_test_dst_ref)); +} + +/* vscatter must drop elements whose offset is beyond the region */ +void create_scatter_region_len_test(void) +{ + init_region_len_test_offsets(); + for (int i =3D 0; i < MATRIX_SIZE; i++) { + scatter_len_test_values[i] =3D 0x4100 + i; + } + memset(scatter_len_test_dst, FILL_CHAR, sizeof(scatter_len_test_dst)); +} + +/* scatter with a region shorter than the destination buffer, using HVX */ +void vector_scatter_region_len(void) +{ + HVX_Vector voff =3D *(HVX_Vector *)region_len_test_offsets; + HVX_Vector vval =3D *(HVX_Vector *)scatter_len_test_values; + + Q6_vscatter_RMVhV((int)(uintptr_t)scatter_len_test_dst, + REGION_LEN_TEST_MU, voff, vval); + + sync_scatter(scatter_len_test_dst); +} + +/* scatter with a region shorter than the destination buffer, using C */ +void scalar_scatter_region_len(unsigned char *dst) +{ + for (int i =3D 0; i < MATRIX_SIZE; i++) { + unsigned short off =3D region_len_test_offsets[i]; + if (off <=3D REGION_LEN_TEST_MU) { + memcpy(dst + off, &scatter_len_test_values[i], + sizeof(scatter_len_test_values[i])); + } + } +} + +void check_scatter_region_len(void) +{ + memset(scatter_len_test_dst_ref, FILL_CHAR, + sizeof(scatter_len_test_dst_ref)); + scalar_scatter_region_len(scatter_len_test_dst_ref); + check_buffer(__func__, scatter_len_test_dst, scatter_len_test_dst_ref, + sizeof(scatter_len_test_dst_ref)); +} + /* print scatter16 buffer */ void print_scatter16_buffer(void) { @@ -1035,6 +1162,14 @@ int main() print_scatter16_32_buffer(); check_scatter_16_32_masked(); =20 + create_gather_region_len_test(); + vector_gather_region_len(); + check_gather_region_len(); + + create_scatter_region_len_test(); + vector_scatter_region_len(); + check_scatter_region_len(); + puts(err ? "FAIL" : "PASS"); return err; } --=20 2.34.1 From nobody Sat Sep 26 21:36:27 2026 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1788485054; cv=none; d=zohomail.com; s=zohoarc; b=PS1SOMP7oNagTS4wV1v2eWKxd433biPbDMZAJyvTUumUWxcLgbFYL/In3Wvgv4PUmXKx0meYTIKPmFcoUQXIo5QcDeXl6DCMOiwQuGwp+HczEIkvRtTYovRFhPEaeUUOSKVcZFcv/Alyj0MCBFEbbRR00XQnTE5ZsfCAO/by2cM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788485054; h=Content-Type: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=a+CBXDO4Pm2yaldDRatlLKjTbgDEs6+OwEBymI4oKm8=; b=iJDPOIkCHqT1TYAAcceJKHrd4K9TLqWFvTbsdO6d6dNgUXvPaWlN5dbq4C8TFg7MNRBE7g0bLPWqi/7VIEzAXt13E9BgjT/+A1kKQP5RsIgVFy6iYt/vYjx2m91Ejnj8lBBDG+BfbKil/dPSE8s1+U8pd6XtOd6WNDyKqqA5PbM= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178848505448897.52208687835866; Thu, 3 Sep 2026 18:24:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x2Idj-0007AU-6X; Thu, 03 Sep 2026 21:22:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2Idg-00079M-N3 for qemu-devel@nongnu.org; Thu, 03 Sep 2026 21:22:44 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2Ide-0005JN-W8 for qemu-devel@nongnu.org; Thu, 03 Sep 2026 21:22:44 -0400 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 683Nbl6U2193162 for ; Fri, 4 Sep 2026 01:22:41 GMT Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gf6p73tqt-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 04 Sep 2026 01:22:41 +0000 (GMT) Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-6b1281dd14aso450435eaf.2 for ; Thu, 03 Sep 2026 18:22:41 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3339885ca07sm2573234eec.1.2026.09.03.18.22.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 18:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:content-type:date:from :in-reply-to:message-id:mime-version:references:subject:to; s= qcppdkim1; bh=a+CBXDO4Pm2yaldDRatlLKjTbgDEs6+OwEBymI4oKm8=; b=Jy H3JXDTVzrZoptV9Xaw+vjEc9diVx7XE1ItWpXHeHaPFXd+TUL4HcpKq7v2dvzlMm AVu3PbZFXWiIHEeYoN/RlCJI5N3Dv/wzcGs96/JxVgZ2XsW8/xK1s5r5AhR86D06 DxNM28uLsuf+Bldm8LU+oXT8J4YVTjbvRYaE98u0nHPPWfX0PNsmy9U5HBQKdFak 7QDaUc4nnFfuPSW0fBNYnUwgtiTajRAfgHYXZyBC4IPp5PlPWw+DDlY4rvzu1Mnv FwU1OsgUlx/oYoWx+xeUKaxZjoIfH+fYMNATSc9WBtu4NOI0tZgYqVkze2Ek4a3Q BFOvCv1VoqJYVAfZGdvg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788484961; x=1789089761; darn=nongnu.org; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to:content-type; bh=a+CBXDO4Pm2yaldDRatlLKjTbgDEs6+OwEBymI4oKm8=; b=IUgW24DQmyUlNBxXS5DbeVSxkzfU/ZqLM1RnD+3XzdowaNK4jxHwTTGy/8vRf0Emuv nLL3JvvSMsGUVYxpYZLJQTO/hmuHRXZ4TUdOqrCmyNQvgfaTU+xhQpGKW05eNiYP+/yA SESV2UWQ2RRgtYXMmCanKarhCALp0yfwlY90sZGCro1piUqMsabdzu48hyW1vtEQwa2E 6xDUTgK90BgLJXZJIUhuoYFfIgXvPaHaxo4RmAQXuEVMF7XyZPDSGVyoz2Z7XHbkSdYu /j0eivpK6iYHno7iXn+xGwmS+3Lwqd9QWTnRZQFlNdUFZHIpunXa3vrN9LxnY60Iqh9o rXUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788484961; x=1789089761; h=content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=a+CBXDO4Pm2yaldDRatlLKjTbgDEs6+OwEBymI4oKm8=; b=ddevtR33VnsLyvCGRK/fFcN0VMJKcMtcdbTmSq17+XoXAQGDyHKgb7lc3wKwtyyZiO QDyHro26cEbrORzwS/Y2qEWmg12RYsY5lvlLZkdqPFEPFwFzyiqoT9JY0wuLWJyVb3gh E2k51weech/JWirl8R8tWiiok2g4LwdgFWvo+SEKulwS5DBADmCSPQmUcyW25i79Nd3X tOHRN+F7AFombwgIMeVjyw69ZScfaHOKuZFPdvFQj4+TLBs2bmLKQDGh6zFiBf/PKOje U7tODokHuYVndzYsea2ufLM6AtpMSIfGSDwEqzCa5uEdZE6amngTLKK2S43ogS6QvSo6 YW+A== X-Gm-Message-State: AFuF++lneuJbojM/k7zm9PUyvSbZwGmMbQBdF5AL6y33IcGmpYbMK2/Y v8YeWKuaWWpqwdUIQEHk/13LRYMaBw+ZYeeBDuSYretgg6CiqA4RUzrEhTYx/8XOTokcY4VrDvU 6fuY8xEPwHWymYWoj4VmNnNCA8FeIYrm/VcntKXcyPreEFv7uzA3y4s3xfvmH8HIUXQ== X-Gm-Gg: AYBFou2aT4u7Nf2KcmtamwSHZhFaJv+xx34ke2QK4ag0O+zWxO0jb8xfE1ohGZ4NYrz y8/WQ6tUg2N6UhqPN78ToHcrTsBR1to8PEAL7gVZSGmqflvEcaDHMBJ/aePtgP4Edw0en3fDze+ PwokD0zTenX55dleg9nXjDnFWE3mSULIcbsvHvDulFxiXwwH9/ffLKzD7ml5S2DlrNI4j403ANO 2CiayfDh7AIGA1SLMbcH5uxMFSSbRney8zz89fV+7Yyh7HNgrnkFvB2V+yGHgFbG6irjE/zlXMr tP1lNUsoGe+6MNAG7ewRWbYHlzmmnUD4e0L/0FmglxEcWHwgRhfdZUl2nZI/k9KdPzkEgNbgIMI uhXcXuha9PuC4zwniUSR6UrUZC0/pesk4yLQVjudaEQOn4OIy X-Received: by 2002:a05:6820:1888:b0:6b7:46fc:1cb with SMTP id 006d021491bc7-6b746fc0236mr523047eaf.42.1788484961081; Thu, 03 Sep 2026 18:22:41 -0700 (PDT) X-Received: by 2002:a05:6820:1888:b0:6b7:46fc:1cb with SMTP id 006d021491bc7-6b746fc0236mr523026eaf.42.1788484960644; Thu, 03 Sep 2026 18:22:40 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: Brian Cain , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Matheus Tavares Bernardino Subject: [PATCH v3 4/5] target/hexagon: fix HVX predicate save size for histogram ops Date: Thu, 3 Sep 2026 18:22:32 -0700 Message-Id: <20260904012233.3607547-5-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com> References: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: mYiSfcNXzS4zOme25uDwZKJ8W34Dnfb_ X-Proofpoint-ORIG-GUID: mYiSfcNXzS4zOme25uDwZKJ8W34Dnfb_ X-Authority-Analysis: v=2.4 cv=OZyoyBTY c=1 sm=1 tr=0 ts=6a9a1d61 cx=c_pps a=lkkFf9KBb43tY3aOjL++dA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=iBrAFeRkQMIbT85dZ3EA:9 a=QEXdDO2ut3YA:10 a=k4UEASGLJojhI9HsvVT1:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTA0MDAxMCBTYWx0ZWRfX77RfprUFJFui FY2BKTkNfmLqBGaX+Kahg4Vufdu2Kkrgs02fu9kq9tykr+1HZdbHVJkLEmwBBcC21bssz0vYdi2 mjaP9Txuk/8ucWAp+p2QMAQDjk8RJU4= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTA0MDAxMCBTYWx0ZWRfX9DGmLO9jK1o2 M/5cpfRmfWqV2zccEl2zP6N+PsY0aKWPgSrXFMIwXI5BQkZEu3Loy4w+OP/flJdio2QragLN4I4 7QhY7hTEOXzaT1Q6cNf48FgOKT6Cki8CZmmi6eXwyJmJ7x3x5aWkxDJX0gMpw5JLTWEEw7jVHw/ kMEFBhbbAPkDsPjRoQtU2Oj5oFHeQtu0OuxAr9ZjZTi4OFe9psKhacIl4zF4axRJsx+3EkbImU6 BG40x8COgCUNV3/bIefPdIimy1wAK6SK/nAMPOOvWAdShBK8naQdYGKMDr2+uOw8mZeQUCV2HSr r2XiR6obRI+ONRx5HL1aXFS9M2cHPrFmx2ebwiCYgx18V+LRVTXKLmgYlg7hL2JWRUJcwc8PieQ BEvj3vHNaBbVgTQ3xXFBHjO8tSg0m/yMQra6OWo2NQuWOg9xpnZIk3UXp83fsAm3W54Ycwd9Pij MBoldWFv2FvS6MC1xuw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-03_07,2026-09-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 impostorscore=0 clxscore=1015 malwarescore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609040010 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1788485056217158501 Content-Type: text/plain; charset="utf-8" The masked histogram instructions save the predicate operand to the qtmp temporary with a gvec move sized sizeof(MMVector). Both source and destination are MMQReg, which is eight times smaller, so the move read 112 bytes past the predicate register and wrote them over the fields following qtmp in CPUHexagonState, that is vstore[0]. Use the size of the registers actually being copied. Fixes: 7ba7657bc93 ("Hexagon HVX helper overrides for histogram instructio= ns") Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Matheus Tavares Bernardino Signed-off-by: Brian Cain --- target/hexagon/gen_tcg_hvx.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/hexagon/gen_tcg_hvx.h b/target/hexagon/gen_tcg_hvx.h index 2a342cdee69..d3f2cc7bc62 100644 --- a/target/hexagon/gen_tcg_hvx.h +++ b/target/hexagon/gen_tcg_hvx.h @@ -50,7 +50,7 @@ static inline void assert_vhist_tmp(DisasContext *ctx) if (ctx->pre_commit) { \ intptr_t dstoff =3D offsetof(CPUHexagonState, qtmp); \ tcg_gen_gvec_mov(MO_64, dstoff, QvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + sizeof(MMQReg), sizeof(MMQReg)); \ } else { \ assert_vhist_tmp(ctx); \ gen_helper_vhistq(tcg_env); \ @@ -66,7 +66,7 @@ static inline void assert_vhist_tmp(DisasContext *ctx) if (ctx->pre_commit) { \ intptr_t dstoff =3D offsetof(CPUHexagonState, qtmp); \ tcg_gen_gvec_mov(MO_64, dstoff, QvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + sizeof(MMQReg), sizeof(MMQReg)); \ } else { \ assert_vhist_tmp(ctx); \ gen_helper_vwhist256q(tcg_env); \ @@ -82,7 +82,7 @@ static inline void assert_vhist_tmp(DisasContext *ctx) if (ctx->pre_commit) { \ intptr_t dstoff =3D offsetof(CPUHexagonState, qtmp); \ tcg_gen_gvec_mov(MO_64, dstoff, QvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + sizeof(MMQReg), sizeof(MMQReg)); \ } else { \ assert_vhist_tmp(ctx); \ gen_helper_vwhist256q_sat(tcg_env); \ @@ -98,7 +98,7 @@ static inline void assert_vhist_tmp(DisasContext *ctx) if (ctx->pre_commit) { \ intptr_t dstoff =3D offsetof(CPUHexagonState, qtmp); \ tcg_gen_gvec_mov(MO_64, dstoff, QvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + sizeof(MMQReg), sizeof(MMQReg)); \ } else { \ assert_vhist_tmp(ctx); \ gen_helper_vwhist128q(tcg_env); \ @@ -115,7 +115,7 @@ static inline void assert_vhist_tmp(DisasContext *ctx) if (ctx->pre_commit) { \ intptr_t dstoff =3D offsetof(CPUHexagonState, qtmp); \ tcg_gen_gvec_mov(MO_64, dstoff, QvV_off, \ - sizeof(MMVector), sizeof(MMVector)); \ + sizeof(MMQReg), sizeof(MMQReg)); \ } else { \ TCGv tcgv_uiV =3D tcg_constant_tl(uiV); \ assert_vhist_tmp(ctx); \ --=20 2.34.1 From nobody Sat Sep 26 21:36:27 2026 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=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1788485014; cv=none; d=zohomail.com; s=zohoarc; b=FeQ+UDr6B4yGcasfIbu6myrJdLGZ7MvMqfhIMbL6O5SU/u4KlYYjAuDA9EK6YxIQcpGpyZPasGySjSUMsGdxy0XPl5mSyWUtqb3+X3VGgnefuumdYiXq/g6gr3Mh0EXH7JUpRAK074wcAWEavmgpzMg2tsZZvg6oS4i55r0kQ3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788485014; h=Content-Type: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=VRaZktLH6FSYAnvGOw4//fv/Pl+ly6gy7uH+narcn0w=; b=joVCwnr1n2j9nBHq7E3FJRFLGbSRgaU8C3+v5Zb5qT6iiJLRBJENyJ8mjiLFE4HLiq98B8k2OfgVQoCd4fFgB6DDXTcSe0ZJOuMc6Ca1UyOJTmVt9hO/85B1F51c7QyNJm673RjPTXWd+1D14/LRWOvw45BkQ3APCDbjbA/9nM0= 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=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788485014242496.41505180859383; Thu, 3 Sep 2026 18:23:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x2Idk-0007B0-J2; Thu, 03 Sep 2026 21:22:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2Idi-0007AJ-IT for qemu-devel@nongnu.org; Thu, 03 Sep 2026 21:22:46 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x2Idg-0005Jl-SM for qemu-devel@nongnu.org; Thu, 03 Sep 2026 21:22:46 -0400 Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6840E4iO1472720 for ; Fri, 4 Sep 2026 01:22:43 GMT Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gfk9204wv-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 04 Sep 2026 01:22:43 +0000 (GMT) Received: by mail-oo1-f69.google.com with SMTP id 006d021491bc7-6b34d7f21d0so418517eaf.3 for ; Thu, 03 Sep 2026 18:22:43 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3339885ca07sm2573234eec.1.2026.09.03.18.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 18:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= VRaZktLH6FSYAnvGOw4//fv/Pl+ly6gy7uH+narcn0w=; b=UCucK8UKs3xaoQCV Qx4/cFagi52ienloyyzj2HOmhbUUYt7GGUWwG6G6KMoNo4jJz7i1sCzCz4sym3l2 eObyGNiTnttaKB0Y4yrPR+ijcF6zHD6XaMG+27AlLGwoiQ5SeEUk2lzJW1By90X8 IHNO7xV5Y4kil4MRaO1ksaYOcexx5O/JvW511QT9U21+XOT3rQb2IJ1A5cs/LCDO 5k6ANkFLeMVNJXbbMWbLunLfi35NbM1F+14Xn+K7AzOwXF7vlVn3QzLCKdv8MZxg QdTut/7H0qjB6Rb3S6MwdLNnrGqT5bBNH2J1DOA0aPjEp4hkWdnJI8sxULcHrYqt uLn5gw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788484962; x=1789089762; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=VRaZktLH6FSYAnvGOw4//fv/Pl+ly6gy7uH+narcn0w=; b=Nu4U0dGCZmxSZnD7013vJL5FuGXVc6iGWCSmlP7EAXAiNrNgy3xKL6c9s3ipjiDfE0 mMXmgiddYobOLwnrUmObGBj0+6amQC64jUCkHSrGcyPK+JyczarSy0g0HhpHv8pQNVnu gehX1d6qtGW9ZOlnQ0pGVJgXCOvx3OvmGNtsBz3zf+lZWzsR5191PeNE4LEAf5GEZW1S USE2MoGPxV8yzVKA4bPkqjw19IesBZ2lAJHgQq1U1qmucc3YIFr7IbkGJqVpLdG9Am08 ChSvQ4isPktbdGvnvM4GvY2fKe7lWoasJ0fax+pZw6Ok1Ddto62RL2KBmVe35dHvOc6h 0Cyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788484962; x=1789089762; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VRaZktLH6FSYAnvGOw4//fv/Pl+ly6gy7uH+narcn0w=; b=OeMdGNu2qfhD8GrVByWvYq2WVrtitlT+h+VnElA9IsP5D9aEBycMC6ru2aSWGILxFr fUdgABPS/nu9vFZr6OruobApMhc05JWV/dejAcI6DQHvNSLDVa6N/sSpygKkhJ99OUYs tvIkrxTPnW47Q4WJAgZhOIcq3hfm7ppbYoJ48nOfBaZE1ZZlNgwd0lOJXj0XHblIxddr pNqRqTBAvPb+j9LhHe72ZXoilM71/6a7bSvbGQJiK3QLGV9wh0+jeUT3D4nlVL+80erT L7riWhn5nPoOiwmmquO0KA8eBaeNlCAzmy0e8yNN+7kSDH0tIEiIsfU+/ShX3beGE5Od bLJg== X-Gm-Message-State: AFuF++k/64vvNcapoHROvmQWIPt/DvwMvC/3bHd5a8sZqwhkThzj7IFQ Ci2RlavEukSIJMG6I1zQgX7FQTeiJPDBTVdoy5QNVHfpsM/h7Dt30+9fsTK2iUsbnMVyPlej7UI 76WxDdJGNSnARkcdUFiZF4pgZam+LDBz+7BeXovOulS2XdSihtrPYymReq2KYXwFWeg== X-Gm-Gg: AYBFou1ssJ9Ih4iHpbUh/MeG8wS3wqFAblp89cKJcrO70CalW2+JwsFxdYAWpb3yGZi PQPcmkRMXhHDYieIa2BLbZPWG7tUSY94Pqzo9V+9vC+0acbNdb8RB40F7p1jjeaFnGF2pxLJ68m lzEhr+6PvoWkySghuOSFSJICRKPHwsJYYutSvykqftSl+PrfbRT8aEkD0PfVAfp4fUXF2ZXdcrk gTrf35q9q+3kEqNAoLtF9u7Q36MrZDR6ifEPVbspm2M91nTJqQjaY9pgr5nQoeNBX+K4eOtkr43 +qR7+XPqQ+/esmx8LgEMKXPKUlH4rWdaJ1qTqTjVQyri5kFvBhleNcBNO4TP2LDVzRM46ljnGGi yj9iwPHt+w2pM4gzzenLCnNVnF4TLeKKapDi2oF05Udf4TUcI X-Received: by 2002:a05:6820:4df7:b0:6a1:4507:3544 with SMTP id 006d021491bc7-6b6fd7c9e58mr1980965eaf.28.1788484962449; Thu, 03 Sep 2026 18:22:42 -0700 (PDT) X-Received: by 2002:a05:6820:4df7:b0:6a1:4507:3544 with SMTP id 006d021491bc7-6b6fd7c9e58mr1980948eaf.28.1788484961976; Thu, 03 Sep 2026 18:22:41 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: Brian Cain , Pierrick Bouvier Subject: [PATCH v3 5/5] tests/tcg/hexagon: check the two HVX predicate build paths agree Date: Thu, 3 Sep 2026 18:22:33 -0700 Message-Id: <20260904012233.3607547-6-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com> References: <20260904012233.3607547-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTA0MDAxMCBTYWx0ZWRfX6gYfbaYN8RKQ 39Ey5mH7pqsfj+FXKvCiZjKz4raIKC9MhZ2wSQM++2ZWrcij7BWr46n05j9ZWyIeDreVgdweKRz PotPRYWkuAML99V4dOQ1SOm3uVX25IcgSNk6UXodsuA/n+XzwGWFgtqoZxaRLqEFrul1r8tqQFW 28DEOZ6vEo74g1QFgiK+oOyQRnav8VOBnbDeMD0FUfJGkc6ITsX/VhJOYqdafd19sIwU0/HJF/l cIMlFe94hQjkf2KLZYhC0UAjoUePPWNuHX6Hq28KEBIx8N/QN2jX7c7JBB+Qo8qQ/pZbz70/W9B +2gB8dSswndwvafvLb3XMNJ7HSlTW1V7jHbwZi0XlBneuQGV7GDFBMw791RNjHfVLP0HNpYpics lxyzFKaSHGS3oMcyZef+T1nnmnusgr+SEOwSVMz4Azyb/T86XAQ2r6nhfo46HgY3dngvh94NBV/ mB7JSS0UxCGQOA1EMxQ== X-Authority-Analysis: v=2.4 cv=Oc2oyBTY c=1 sm=1 tr=0 ts=6a9a1d63 cx=c_pps a=lVi5GcDxkcJcfCmEjVJoaw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=jjHI2IJ3bfbFesgfRcwA:9 a=QEXdDO2ut3YA:10 a=rBiNkAWo9uy_4UTK5NWh:22 X-Proofpoint-ORIG-GUID: TxIGPlSUoBjz9ACEnTB1mnou9QToB3W3 X-Proofpoint-GUID: TxIGPlSUoBjz9ACEnTB1mnou9QToB3W3 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTA0MDAxMCBTYWx0ZWRfX/P4bBvJcEd1t jdSFiXk4e4D4YiAUC0AfAixMJonT78cKqfQ7IcT5LoU1GqVM5o9OXgW/5sztPc+13qEPaVHdr+k ymVjGdTbUdNCAJU3jdSTVjTgrvOO2LQ= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-03_07,2026-09-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 impostorscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 spamscore=0 clxscore=1015 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609040010 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=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development 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 @qualcomm.com) X-ZM-MESSAGEID: 1788485016931158500 A Q reg can be built by a vector compare or by vand(Vu, Rt), and those reach the predicate register through independent code paths. Check that both select the same byte lanes, so a byte-order mistake in either one is caught. The input alternates every eight lanes: a flatter pattern stays unchanged when predicate bytes are permuted and hides the bug. Signed-off-by: Brian Cain Reviewed-by: Pierrick Bouvier --- tests/tcg/hexagon/hvx_misc.c | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/tcg/hexagon/hvx_misc.c b/tests/tcg/hexagon/hvx_misc.c index 32a3661a86f..225666137c9 100644 --- a/tests/tcg/hexagon/hvx_misc.c +++ b/tests/tcg/hexagon/hvx_misc.c @@ -181,6 +181,50 @@ static void test_store_unaligned(void) check_output_w(__LINE__, 2); } =20 +/* + * A Q register can be built either by a vector compare or by vand(Vu, Rt). + * Those are two independent code paths onto the same predicate-register + * layout, so cross-check that they select exactly the same byte lanes. + * A byte-order mistake in either one shows up here as a mismatch. + * + * The input pattern has to vary across 8-lane blocks, otherwise a predica= te + * whose bytes are permuted still selects the same lanes and the mismatch = is + * invisible. + */ +static void test_qreg_alias(void) +{ + HVX_Vector *pcmp =3D (HVX_Vector *)&output[0]; + HVX_Vector *pand =3D (HVX_Vector *)&output[1]; + HVX_Vector input; + HVX_Vector ones; + HVX_VectorPred qcmp; + HVX_VectorPred qand; + + for (int i =3D 0; i < BUFSIZE; i++) { + /* + * Build 0/1 per byte, alternating every 8 lanes, so that "!=3D 0"= and + * "low bit set" describe the same lanes. Then form one predicate + * with a compare and the other with vand(Vu, Rt), store 0xff thro= ugh + * each, and require the two result vectors to be identical. + */ + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES; j++) { + expect[0].ub[j] =3D ((j >> 3) + i) & 1; + } + memcpy(&input, &expect[0], sizeof(MMVector)); + memset(output, 0, 2 * sizeof(MMVector)); + + ones =3D Q6_V_vsplat_R(0xffffffff); + qcmp =3D Q6_Q_vcmp_gt_VubVub(input, Q6_V_vzero()); + qand =3D Q6_Q_vand_VR(input, 0x01010101); + Q6_vmem_QRIV(qcmp, pcmp, ones); + Q6_vmem_QRIV(qand, pand, ones); + + for (int j =3D 0; j < MAX_VEC_SIZE_BYTES; j++) { + check(__LINE__, i, j, output[0].ub[j], output[1].ub[j]); + } + } +} + static void test_masked_store(bool invert) { void *p0 =3D buffer0; @@ -579,6 +623,7 @@ int main() test_store_unaligned(); test_masked_store(false); test_masked_store(true); + test_qreg_alias(); test_new_value_store(); test_max_temps(); =20 --=20 2.34.1