get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2195115/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2195115,
    "url": "http://patchwork.ozlabs.org/api/patches/2195115/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260210133355.16093-5-brian.cain@oss.qualcomm.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260210133355.16093-5-brian.cain@oss.qualcomm.com>",
    "list_archive_url": null,
    "date": "2026-02-10T13:33:54",
    "name": "[v3,4/4] target/hexagon: Detect register write conflicts with bitmap algorithm",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "ceb1f76d02fbe53caab45f4154d7241693c18ab8",
    "submitter": {
        "id": 89839,
        "url": "http://patchwork.ozlabs.org/api/people/89839/?format=api",
        "name": "Brian Cain",
        "email": "brian.cain@oss.qualcomm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260210133355.16093-5-brian.cain@oss.qualcomm.com/mbox/",
    "series": [
        {
            "id": 491673,
            "url": "http://patchwork.ozlabs.org/api/series/491673/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=491673",
            "date": "2026-02-10T13:33:53",
            "name": "Handle some invalid encodings",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/491673/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2195115/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2195115/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=a0KhVxby;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=CEpzUX2d;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4f9MxY1SC0z1xtr\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 11 Feb 2026 00:34:57 +1100 (AEDT)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vpnsx-0005fr-4m; Tue, 10 Feb 2026 08:34:35 -0500",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <brian.cain@oss.qualcomm.com>)\n id 1vpnsn-0005eT-Rp\n for qemu-devel@nongnu.org; Tue, 10 Feb 2026 08:34:27 -0500",
            "from mx0b-0031df01.pphosted.com ([205.220.180.131])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <brian.cain@oss.qualcomm.com>)\n id 1vpnsk-0001o6-7G\n for qemu-devel@nongnu.org; Tue, 10 Feb 2026 08:34:25 -0500",
            "from pps.filterd (m0279870.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 61A7jMlE1419505\n for <qemu-devel@nongnu.org>; Tue, 10 Feb 2026 13:34:21 GMT",
            "from mail-dy1-f197.google.com (mail-dy1-f197.google.com\n [74.125.82.197])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4c7rpvtjf2-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <qemu-devel@nongnu.org>; Tue, 10 Feb 2026 13:34:21 +0000 (GMT)",
            "by mail-dy1-f197.google.com with SMTP id\n 5a478bee46e88-2ba67282cabso6501011eec.1\n for <qemu-devel@nongnu.org>; Tue, 10 Feb 2026 05:34:21 -0800 (PST)",
            "from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com.\n [129.46.96.20]) by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2ba7e149c58sm2716162eec.26.2026.02.10.05.34.18\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 10 Feb 2026 05:34:18 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n cc:content-transfer-encoding:content-type:date:from:in-reply-to\n :message-id:mime-version:references:subject:to; s=qcppdkim1; bh=\n xbXi2oXZsKBH1Y/QXhqVGsr/9BWhgHx07lNx0z3p67k=; b=a0KhVxby59OU9hBm\n tmx5Z6Knj68rUN1ZP3J0O5G1E6hdNOIhiTjhad2IPFnvQUfjlLIO1sk9Cf5hrpoD\n RIIZVpGU9UhL2FhhzrGTdbdFvpBhE/ZjcQ08lrntzw1dgMqm1bXkQQnWawwtEWBR\n copu9njJhfCP+1eOgVRr+bh6YAeGcpCUSalQsvdNmWHktBwBQhm32yJNtY5c84v0\n w72QbaqS9jXVxRQgo3BvoqJ/pgCuOQ64EFwMIiReyIqAWX//BdEmHJ06f8JNMx1Z\n aqRxLIQ2jE11i+ClIbDx/czV66dKfT4UxYn6HSDEWNzJPqDNQh5xGUcc8lgoVA0k\n TSHiyw==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1770730460; x=1771335260; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=xbXi2oXZsKBH1Y/QXhqVGsr/9BWhgHx07lNx0z3p67k=;\n b=CEpzUX2d9aoK/fYMPbQMUYRp/++NeD8PEq4qyNCBGdK2e9cibJgy8P8aeyDRXT7tCE\n J+PAYdxHVZR6tYAuSxWpWghsMFVSn0pQ2itq1iwwUUiYsH+Frg82CWpn1/M16xfdhkqR\n 3ON9vOoh4dQ4/BTZP1oN25Ga/0tkqpUcm+ObPWZEJ93SfW92pCUXwzZ3wyiEVPGOY+uS\n egKHZJgNv7hkzWJaKha2sufTPluKXBiHBv1/3CcNkUaxu6V/EvIlTcflBo9EYiMjlClb\n w/Z4fjdpNHBiU6WhnS0f0saXP2j2wqH0wVI02ihtEjewEcYQuCDxibZhxPruhDAx9D3i\n HXxg=="
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1770730460; x=1771335260;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=xbXi2oXZsKBH1Y/QXhqVGsr/9BWhgHx07lNx0z3p67k=;\n b=gdIzUHsfB21IkZba7J4tR4UsmITIEaNimWW+IRcbcTWn/GdnaVcFIYKcPtA9Vwjgtl\n RoFlS9HlrhUYd81EnIl+pOPvgw9vcr9ZaZdEBen5OOtZL4gW09gilTb2BOtcBDPRLw9S\n Nk2jKKk3gCfWfYnaGquJL5mZHcvH7ipOlSk+gDKPjDcLcOt38PB2/WcmiTJ6VOlI2DC2\n 4s+Yt1PJQW3h+q0CASH2EtzO5UaSeGjbwkUaCHVfsXxoUzieLTGZ6IhqtxTPj8i0FNUc\n YPzN65AyWKlYL07GC9JNE5OqKQ/67+evUGpylrmPTuGzC5L1mtFfz7aDHR96OVU+MYXD\n hRHw==",
        "X-Gm-Message-State": "AOJu0YwhOp8lsJkIftS2Atvs8z2Bs4thVBGIs/Uq7p7wZkC6SxbndyvU\n k2LKiDPnP5+p03WMdxc4SVh9D1LU8meAc2/JB7xu0xfJx9Ceo+XNZldvpJEHxvYrj3YqbRApOjU\n f5pmNjlX1TWsHylGrXitAFk2GqCEEleEkRlMFaXVEMvmKhlar26BdgQ/TA2f75xwizg==",
        "X-Gm-Gg": "AZuq6aI12wbYzujx8u3VI4wQM4rsgUZV+I/8m3D0Vpb5W6/6iuqslKA4YOpCb/2IMbH\n jFgfxiF97Ov9jUAa4OU/SpKwrLbq0tKawFduqV751W5hGiAuGtzCb8SvMOptTPMbW6spGaS2vfg\n FfdM/8AzMGmQUTdBc5GmOrdpVrfR5+TLl/KFXgrIMFr3407NXv746gkSF4XbbSIIAZVKE82yDW2\n 0YSCUDyH2UgMOOFqPfO2zzZs1bSxCiQPsroUHg4uGwq21uJsWxeKXlpEvtdmYxGJxI7U/daqaKI\n +04VTR1tQSXiz0p1tF9ezF0lFnDFhW1j1R54BefhswDr27JxWl8iY3V9nUzLTidj1YatPCPeKX6\n aL9P3VaHBccqDE6set7OgUqyj3V8aybuupnObAmWKoMkXlkn6NzUQeybKg0dBtnrxxuVNwQ==",
        "X-Received": [
            "by 2002:a05:7300:3720:b0:2ba:956e:d26a with SMTP id\n 5a478bee46e88-2ba956ed77cmr117825eec.36.1770730459772;\n Tue, 10 Feb 2026 05:34:19 -0800 (PST)",
            "by 2002:a05:7300:3720:b0:2ba:956e:d26a with SMTP id\n 5a478bee46e88-2ba956ed77cmr117805eec.36.1770730459104;\n Tue, 10 Feb 2026 05:34:19 -0800 (PST)"
        ],
        "From": "Brian Cain <brian.cain@oss.qualcomm.com>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "brian.cain@oss.qualcomm.com, ltaylorsimpson@gmail.com, alex@alexrp.com,\n Laurent Vivier <laurent@vivier.eu>,\n Pierrick Bouvier <pierrick.bouvier@linaro.org>",
        "Subject": "[PATCH v3 4/4] target/hexagon: Detect register write conflicts with\n bitmap algorithm",
        "Date": "Tue, 10 Feb 2026 05:33:54 -0800",
        "Message-Id": "<20260210133355.16093-5-brian.cain@oss.qualcomm.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20260210133355.16093-1-brian.cain@oss.qualcomm.com>",
        "References": "<20260210133355.16093-1-brian.cain@oss.qualcomm.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "X-Proofpoint-Spam-Details-Enc": "AW1haW4tMjYwMjEwMDExNCBTYWx0ZWRfXwnESCry89Ee+\n 40woOtbmn7JLl5mpUtQO4GjGGaxRtA9fU9UPcalu5TXdf+UjVZyaoI2V62xw479z/JZSwPE8t9w\n B6Zobnd0K1uUC4ZOOvrZLV3CbT17lYg1gPuMf4nJNkzno8njCzNxjLpOMgLpyNWuQqmy5YK9nD3\n sVls0Q81E06QVE4MmI25UYwbOt4H0bkv69JRpvnf6QcvBppUQ6gv7nIFQsYDpakGqZcpBzsuOxx\n kmYyvZh9Id7vHu9vbfkGKd5YZYfgQxWsUT7M2mu0oZrIVsA5CNmFBJmOF7gg+CsgGE57WpVFMUv\n /CSDYKdsVtEQl5JzztJXtdC+tlip2n9LQw/ACTG2PCTUdYwq4ZwBWspr1EUoGX1siG3sgTz+XG4\n Tc6jasPxlCSA3XHrsxlxsvyczRGiYj5VGx79TTgtFCDubKuFMItAJV6z3vCnbh7Utf3e1s3iXae\n UaKugI+tqeCAVAMMWyg==",
        "X-Authority-Analysis": "v=2.4 cv=KKZXzVFo c=1 sm=1 tr=0 ts=698b33dd cx=c_pps\n a=Uww141gWH0fZj/3QKPojxA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17\n a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=s4-Qcg_JpJYA:10\n a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22\n a=p0WdMEafAAAA:8 a=EUspDBNiAAAA:8 a=JaF38Zb2HHyKl8zT_ZQA:9 a=QEXdDO2ut3YA:10\n a=PxkB5W3o20Ba91AHUih5:22",
        "X-Proofpoint-ORIG-GUID": "XPZItImDGrbtETHP0ERQVBQqiqswJGF2",
        "X-Proofpoint-GUID": "XPZItImDGrbtETHP0ERQVBQqiqswJGF2",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-02-10_01,2026-02-10_02,2025-10-01_01",
        "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n bulkscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 spamscore=0\n adultscore=0 malwarescore=0 priorityscore=1501 phishscore=0 clxscore=1015\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602100114",
        "Received-SPF": "pass client-ip=205.220.180.131;\n 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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,\n RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001,\n 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 <qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"
    },
    "content": "A conflict exists when any GPR is written by multiple instructions and\nat least one write is unconditional.  This catches (1) two unconditional\nwrites to the same GPR and (2) an unconditional write combined with a\npredicated write.\n\nAdd HEX_CAUSE_REG_WRITE_CONFLICT and map it to SIGILL.\n\nResolves: https://gitlab.com/qemu-project/qemu/-/issues/2696\nSigned-off-by: Brian Cain <brian.cain@oss.qualcomm.com>\n---\n target/hexagon/cpu_bits.h           |   1 +\n target/hexagon/insn.h               |   6 +\n linux-user/hexagon/cpu_loop.c       |   1 +\n target/hexagon/decode.c             |  43 +++++++\n target/hexagon/translate.c          |  21 +++-\n tests/tcg/hexagon/multiple-writes.c | 169 ++++++++++++++++++++++++++++\n target/hexagon/gen_trans_funcs.py   |  10 ++\n tests/tcg/hexagon/Makefile.target   |   1 +\n 8 files changed, 250 insertions(+), 2 deletions(-)\n create mode 100644 tests/tcg/hexagon/multiple-writes.c",
    "diff": "diff --git a/target/hexagon/cpu_bits.h b/target/hexagon/cpu_bits.h\nindex ff596e2a94..19beca81c0 100644\n--- a/target/hexagon/cpu_bits.h\n+++ b/target/hexagon/cpu_bits.h\n@@ -34,6 +34,7 @@ enum hex_cause {\n     HEX_CAUSE_FETCH_NO_UPAGE =  0x012,\n     HEX_CAUSE_INVALID_PACKET =  0x015,\n     HEX_CAUSE_INVALID_OPCODE =  0x015,\n+    HEX_CAUSE_REG_WRITE_CONFLICT = 0x01d,\n     HEX_CAUSE_PC_NOT_ALIGNED =  0x01e,\n     HEX_CAUSE_PRIV_NO_UREAD  =  0x024,\n     HEX_CAUSE_PRIV_NO_UWRITE =  0x025,\ndiff --git a/target/hexagon/insn.h b/target/hexagon/insn.h\nindex 5d59430da9..db4dbb728a 100644\n--- a/target/hexagon/insn.h\n+++ b/target/hexagon/insn.h\n@@ -41,6 +41,8 @@ struct Instruction {\n     uint32_t new_value_producer_slot:4;\n     int32_t new_read_idx;\n     int32_t dest_idx;\n+    bool dest_is_pair;\n+    bool dest_is_gpr;\n     bool has_pred_dest;\n \n     bool part1;              /*\n@@ -72,6 +74,10 @@ struct Packet {\n     bool pkt_has_hvx;\n     Insn *vhist_insn;\n \n+    /* Bitmaps for detecting duplicate GPR destination writes */\n+    DECLARE_BITMAP(wreg_mult_gprs, 32);   /* GPRs written by >1 insn */\n+    DECLARE_BITMAP(uncond_wreg_gprs, 32); /* GPRs written unconditionally */\n+\n     Insn insn[INSTRUCTIONS_MAX];\n };\n \ndiff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c\nindex c0e1098e3f..5711055aff 100644\n--- a/linux-user/hexagon/cpu_loop.c\n+++ b/linux-user/hexagon/cpu_loop.c\n@@ -65,6 +65,7 @@ void cpu_loop(CPUHexagonState *env)\n                             env->gpr[HEX_REG_R31]);\n             break;\n         case HEX_CAUSE_INVALID_PACKET:\n+        case HEX_CAUSE_REG_WRITE_CONFLICT:\n             force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC,\n                             env->gpr[HEX_REG_PC]);\n             break;\ndiff --git a/target/hexagon/decode.c b/target/hexagon/decode.c\nindex 33ad60c5b4..08b0fa2c8d 100644\n--- a/target/hexagon/decode.c\n+++ b/target/hexagon/decode.c\n@@ -655,6 +655,44 @@ decode_set_slot_number(Packet *pkt)\n     return has_valid_slot_assignment(pkt);\n }\n \n+/*\n+ * Build bitmaps of destination GPR writes across the packet.\n+ */\n+static void decode_mark_dest_regs(Packet *pkt)\n+{\n+    DECLARE_BITMAP(all_dest_gprs, 32) = { 0 };\n+\n+    for (int i = 0; i < pkt->num_insns; i++) {\n+        Insn *insn = &pkt->insn[i];\n+        int dest = insn->dest_idx;\n+\n+        if (dest < 0 || !insn->dest_is_gpr) {\n+            continue;\n+        }\n+\n+        int rnum = insn->regno[dest];\n+        bool is_uncond = !GET_ATTRIB(insn->opcode, A_CONDEXEC);\n+\n+        if (test_bit(rnum, all_dest_gprs)) {\n+            set_bit(rnum, pkt->wreg_mult_gprs);\n+        }\n+        set_bit(rnum, all_dest_gprs);\n+        if (is_uncond) {\n+            set_bit(rnum, pkt->uncond_wreg_gprs);\n+        }\n+\n+        if (insn->dest_is_pair) {\n+            if (test_bit(rnum + 1, all_dest_gprs)) {\n+                set_bit(rnum + 1, pkt->wreg_mult_gprs);\n+            }\n+            set_bit(rnum + 1, all_dest_gprs);\n+            if (is_uncond) {\n+                set_bit(rnum + 1, pkt->uncond_wreg_gprs);\n+            }\n+        }\n+    }\n+}\n+\n /*\n  * decode_packet\n  * Decodes packet with given words\n@@ -674,6 +712,10 @@ int decode_packet(DisasContext *ctx, int max_words, const uint32_t *words,\n \n     /* Initialize */\n     memset(pkt, 0, sizeof(*pkt));\n+    for (i = 0; i < INSTRUCTIONS_MAX; i++) {\n+        pkt->insn[i].dest_idx = -1;\n+        pkt->insn[i].new_read_idx = -1;\n+    }\n     /* Try to build packet */\n     while (!end_of_packet && (words_read < max_words)) {\n         Insn *insn = &pkt->insn[num_insns];\n@@ -737,6 +779,7 @@ int decode_packet(DisasContext *ctx, int max_words, const uint32_t *words,\n             /* Invalid packet */\n             return 0;\n         }\n+        decode_mark_dest_regs(pkt);\n     }\n     decode_fill_newvalue_regno(pkt);\n \ndiff --git a/target/hexagon/translate.c b/target/hexagon/translate.c\nindex 7fe8b35351..6e399bc2f2 100644\n--- a/target/hexagon/translate.c\n+++ b/target/hexagon/translate.c\n@@ -940,10 +940,21 @@ static void gen_commit_packet(DisasContext *ctx)\n     }\n }\n \n+/*\n+ * Check for register write conflicts in the packet.\n+ */\n+static bool pkt_has_write_conflict(Packet *pkt)\n+{\n+    DECLARE_BITMAP(conflict, 32);\n+\n+    bitmap_and(conflict, pkt->wreg_mult_gprs, pkt->uncond_wreg_gprs, 32);\n+    return !bitmap_empty(conflict, 32);\n+}\n+\n static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx)\n {\n     uint32_t words[PACKET_WORDS_MAX];\n-    int nwords;\n+    int nwords, words_read;\n     Packet pkt;\n     int i;\n \n@@ -954,8 +965,14 @@ static void decode_and_translate_packet(CPUHexagonState *env, DisasContext *ctx)\n     }\n \n     ctx->pkt = &pkt;\n-    if (decode_packet(ctx, nwords, words, &pkt, false) > 0) {\n+    words_read = decode_packet(ctx, nwords, words, &pkt, false);\n+    if (words_read > 0) {\n         pkt.pc = ctx->base.pc_next;\n+        if (pkt_has_write_conflict(&pkt)) {\n+            gen_exception_decode_fail(ctx, words_read,\n+                                      HEX_CAUSE_REG_WRITE_CONFLICT);\n+            return;\n+        }\n         gen_start_packet(ctx);\n         for (i = 0; i < pkt.num_insns; i++) {\n             ctx->insn = &pkt.insn[i];\ndiff --git a/tests/tcg/hexagon/multiple-writes.c b/tests/tcg/hexagon/multiple-writes.c\nnew file mode 100644\nindex 0000000000..8686317fdc\n--- /dev/null\n+++ b/tests/tcg/hexagon/multiple-writes.c\n@@ -0,0 +1,169 @@\n+/*\n+ * Test detection of multiple writes to the same register.\n+ *\n+ * Ported from the system test (tests/tcg/hexagon/system/multiple_writes.c).\n+ * In linux-user mode, duplicate GPR writes are detected at translate time\n+ * and raise SIGILL when at least one conflicting write is unconditional.\n+ * Purely predicated duplicate writes (e.g., complementary if/if-not) are\n+ * legal and are not flagged statically.\n+ *\n+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n+ * SPDX-License-Identifier: GPL-2.0-or-later\n+ */\n+\n+#include <assert.h>\n+#include <signal.h>\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <string.h>\n+#include <unistd.h>\n+\n+static void *resume_pc;\n+\n+static void handle_sigill(int sig, siginfo_t *info, void *puc)\n+{\n+    ucontext_t *uc = (ucontext_t *)puc;\n+\n+    if (sig != SIGILL) {\n+        _exit(EXIT_FAILURE);\n+    }\n+\n+    uc->uc_mcontext.r0 = SIGILL;\n+    uc->uc_mcontext.pc = (unsigned long)resume_pc;\n+}\n+\n+/*\n+ * Unconditional pair write overlapping a single write:\n+ *   { r1:0 = add(r3:2, r3:2);  r1 = add(r0, r1) }\n+ * R1 is written by both instructions.  This is invalid and must raise SIGILL.\n+ */\n+static int test_static_pair_overlap(void)\n+{\n+    int sig;\n+\n+    asm volatile(\n+        \"r0 = #0\\n\"\n+        \"r1 = ##1f\\n\"\n+        \"memw(%1) = r1\\n\"\n+        \".word 0xd30242e0\\n\"  /* r1:0 = add(r3:2, r3:2), parse=01 */\n+        \".word 0xf300c101\\n\"  /* r1 = add(r0, r1), parse=11 (end) */\n+        \"1:\\n\"\n+        \"%0 = r0\\n\"\n+        : \"=r\"(sig)\n+        : \"r\"(&resume_pc)\n+        : \"r0\", \"r1\", \"memory\");\n+\n+    return sig;\n+}\n+\n+/*\n+ * Two predicated writes under complementary predicates:\n+ *   { if (p0) r0 = r2;  if (!p0) r0 = r3 }\n+ * This is architecturally valid: only one write executes at runtime.\n+ * Must NOT raise SIGILL; the result should reflect the executed branch.\n+ */\n+static int test_legal_predicated(void)\n+{\n+    int result;\n+\n+    asm volatile(\n+        \"r0 = #0\\n\"\n+        \"r1 = ##1f\\n\"\n+        \"memw(%1) = r1\\n\"\n+        \"r2 = #7\\n\"\n+        \"r3 = #13\\n\"\n+        \"p0 = cmp.eq(r2, r2)\\n\"\n+        \"{\\n\"\n+        \"    if (p0) r0 = r2\\n\"\n+        \"    if (!p0) r0 = r3\\n\"\n+        \"}\\n\"\n+        \"1:\\n\"\n+        \"%0 = r0\\n\"\n+        : \"=r\"(result)\n+        : \"r\"(&resume_pc)\n+        : \"r0\", \"r1\", \"r2\", \"r3\", \"p0\", \"memory\");\n+\n+    return result;\n+}\n+\n+/*\n+ * Mixed: unconditional + predicated writes to the same register:\n+ *   { if (p0) r1 = add(r0, #0);  if (!p0) r1 = add(r0, #0);\n+ *     r1 = add(r0, #0) }\n+ * The unconditional write always conflicts with the predicated writes.\n+ * Must raise SIGILL.\n+ */\n+static int test_mixed_writes(void)\n+{\n+    int sig;\n+\n+    asm volatile(\n+        \"r0 = #0\\n\"\n+        \"r1 = ##1f\\n\"\n+        \"memw(%1) = r1\\n\"\n+        \"p0 = cmp.eq(r0, r0)\\n\"\n+        \".word 0x7e204021\\n\"  /* if (p0) r1 = add(r0, #0), parse=01 */\n+        \".word 0x7ea04021\\n\"  /* if (!p0) r1 = add(r0, #0), parse=01 */\n+        \".word 0x7800c021\\n\"  /* r1 = add(r0, #0), parse=11 (end) */\n+        \"1:\\n\"\n+        \"%0 = r0\\n\"\n+        : \"=r\"(sig)\n+        : \"r\"(&resume_pc)\n+        : \"r0\", \"r1\", \"p0\", \"memory\");\n+\n+    return sig;\n+}\n+\n+/*\n+ * Zero encoding (issue #2696):\n+ * The encoding 0x00000000 decodes as a duplex with parse bits\n+ * [15:14] = 0b00:\n+ *   slot1: SL1_loadri_io R0 = memw(R0+#0x0)\n+ *   slot0: SL1_loadri_io R0 = memw(R0+#0x0)\n+ *\n+ * Both sub-instructions write R0 unconditionally, which is an invalid\n+ * packet.  This tests what happens when we jump to zeroed memory.\n+ * Must raise SIGILL.\n+ */\n+static int test_zero(void)\n+{\n+    int sig;\n+\n+    asm volatile(\n+        \"r0 = #0\\n\"\n+        \"r1 = ##1f\\n\"\n+        \"memw(%1) = r1\\n\"\n+        \".word 0x00000000\\n\"\n+        \"1:\\n\"\n+        \"%0 = r0\\n\"\n+        : \"=r\"(sig)\n+        : \"r\"(&resume_pc)\n+        : \"r0\", \"r1\", \"memory\");\n+\n+    return sig;\n+}\n+\n+int main()\n+{\n+    struct sigaction act;\n+\n+    memset(&act, 0, sizeof(act));\n+    act.sa_sigaction = handle_sigill;\n+    act.sa_flags = SA_SIGINFO;\n+    assert(sigaction(SIGILL, &act, NULL) == 0);\n+\n+    /* Legal: complementary predicated writes must not raise SIGILL */\n+    assert(test_legal_predicated() == 7);\n+\n+    /* Illegal: unconditional pair + single overlap must raise SIGILL */\n+    assert(test_static_pair_overlap() == SIGILL);\n+\n+    /* Illegal: unconditional + predicated writes to same reg must SIGILL */\n+    assert(test_mixed_writes() == SIGILL);\n+\n+    /* Illegal: zero encoding = duplex with duplicate dest R0 */\n+    assert(test_zero() == SIGILL);\n+\n+    puts(\"PASS\");\n+    return EXIT_SUCCESS;\n+}\ndiff --git a/target/hexagon/gen_trans_funcs.py b/target/hexagon/gen_trans_funcs.py\nindex 45da1b7b5d..19c1f9fdea 100755\n--- a/target/hexagon/gen_trans_funcs.py\n+++ b/target/hexagon/gen_trans_funcs.py\n@@ -91,6 +91,8 @@ def gen_trans_funcs(f):\n         new_read_idx = -1\n         dest_idx = -1\n         dest_idx_reg_id = None\n+        dest_is_pair = \"false\"\n+        dest_is_gpr = \"false\"\n         has_pred_dest = \"false\"\n         for regno, (reg_type, reg_id, *_) in enumerate(regs):\n             reg = hex_common.get_register(tag, reg_type, reg_id)\n@@ -104,6 +106,12 @@ def gen_trans_funcs(f):\n                 if dest_idx_reg_id is None or reg_id < dest_idx_reg_id:\n                     dest_idx = regno\n                     dest_idx_reg_id = reg_id\n+                    dest_is_pair = (\"true\"\n+                                    if isinstance(reg, hex_common.Pair)\n+                                    else \"false\")\n+                    dest_is_gpr = (\"true\"\n+                                   if reg_type == \"R\"\n+                                   else \"false\")\n             if reg_type == \"P\" and reg.is_written() and not reg.is_read():\n                 has_pred_dest = \"true\"\n \n@@ -129,6 +137,8 @@ def gen_trans_funcs(f):\n         f.write(code_fmt(f\"\"\"\\\n             insn->new_read_idx = {new_read_idx};\n             insn->dest_idx = {dest_idx};\n+            insn->dest_is_pair = {dest_is_pair};\n+            insn->dest_is_gpr = {dest_is_gpr};\n             insn->has_pred_dest = {has_pred_dest};\n         \"\"\"))\n         f.write(textwrap.dedent(f\"\"\"\\\ndiff --git a/tests/tcg/hexagon/Makefile.target b/tests/tcg/hexagon/Makefile.target\nindex d64aeba090..f86f02bb31 100644\n--- a/tests/tcg/hexagon/Makefile.target\n+++ b/tests/tcg/hexagon/Makefile.target\n@@ -52,6 +52,7 @@ HEX_TESTS += hvx_misc\n HEX_TESTS += hvx_histogram\n HEX_TESTS += invalid-slots\n HEX_TESTS += invalid-encoding\n+HEX_TESTS += multiple-writes\n HEX_TESTS += unaligned_pc\n \n HEX_TESTS += test_abs\n",
    "prefixes": [
        "v3",
        "4/4"
    ]
}