From nobody Sun Nov 29 02:11:44 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=none dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795811612; cv=none; d=zohomail.com; s=zohoarc; b=HicKsFKcRAEqD+LZHSow3NJ28NSDwRRF+s/0CBd0o9LYcteNqptzFjmWzlrL/iGNbnpMOBrMBQYQkXipkqm2hjSeZ/ZVcJ5EUFm1fIjPvTHrpnbU1rASewgZ9V+gwWWVw6J+J1J6s2ti4DAvA7CA4bulhe+vi7jhPzyac05RItg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795811612; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=df9cfNlMnw9ZDxfjVVxBY5p2J1NYnj6lKTgD1lzptuI=; b=J5QiuXJtT/BBmbazlHiK1jceXqprkqYmTNK/w7641xj6mDu2OaGK2pvna3U1XLB+PPLYQFmyvTOpkmqCRJv9hFuIacwV03x2D2rQRjwzy+Q+IRUJsMaJRX9gHPSq8mg30zkSqkJZnwg4Rn2+5Y9qCZUdRQduVTtc9wB8trRSbVU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795811612791390.7201881951429; Fri, 27 Nov 2026 12:33:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xX2cH-0002t1-8R; Fri, 27 Nov 2026 15:32:21 -0500 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 1xX2cC-0002r3-Ub for qemu-devel@nongnu.org; Fri, 27 Nov 2026 15:32:17 -0500 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 1xX2cA-0001V2-TA for qemu-devel@nongnu.org; Fri, 27 Nov 2026 15:32:16 -0500 Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ARJAvNJ1127678 for ; Fri, 27 Nov 2026 20:32:13 GMT Received: from mail-dl1-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j74g6tv9x-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 27 Nov 2026 20:32:13 +0000 (GMT) Received: by mail-dl1-f71.google.com with SMTP id a92af1059eb24-139b62317d0so5934770c88.0 for ; Fri, 27 Nov 2026 12:32:13 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55681301asm59248021c88.8.2026.11.27.12.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2026 12:32:11 -0800 (PST) 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= df9cfNlMnw9ZDxfjVVxBY5p2J1NYnj6lKTgD1lzptuI=; b=ZJqBcXuq9XOgNBnh tWN3gQ2aSi9v93+6MRHRr2MD255D5f021Mb/o6DwF8X0h4Qjdlr1AUHAazmvNlU1 PM+leSeOEMUrdJy2EoZALbIDf/4anda002SgPFSyxJw4efajIUOGi18OeslPHE5A aLx3MN+xFrOLeKhbz7weHFWlKUhg/tVjD0EuRCm4Vjfx5GJHmWocTykX7mJ8NTgb /0GUsxCDS3QTgxzkAVxhfsUeoUdCZOycop/Rac00CbBJzQtqGTr7ZoOjaIHPWLlv IuINOtZglovLpP9f5WSF3oMtCRSKleIES3TZemytVr0UPCPNEBtRT06oxAG7u9T2 uh4wTg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795811532; x=1796416332; 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=df9cfNlMnw9ZDxfjVVxBY5p2J1NYnj6lKTgD1lzptuI=; b=aEmwFfL30t+IoGl3va0pKA3QIfc6R2qNU5DDmrDusx48cHMDS8lbttoSAGM6gGWkS6 9AdpqxTHQgvhjE8TNJ9E4NCfbgp50HJOogLDsw1GORA+nsA/3kaeTcrb6vca+tTI4f01 dHjt8QIu2Ua9GGRJG6t3ghuVygugbPOYe7YQyHLoSHtJW7kWD3o15WA4gHQuJy04+Y9Q 6Ux/arpXjpzTwQffwpPRmyF+LEhJDf+Vha3zHPz0k4m8XtUPkfHQ9BYtkI/126Z/7NCu v0QP0U/x2Mg9bukWFNck7S26CLTzp0pSw9XilFGE1dSXtuPlpuSbrv1ucbVByaLcu753 4giQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795811532; x=1796416332; 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=df9cfNlMnw9ZDxfjVVxBY5p2J1NYnj6lKTgD1lzptuI=; b=rZXyy4X+vvZfXmDf9p+U2W58UAYlbt3K7W/anPJ+Y04fXG133AOuV2ajXbC036g7GP VVSjCBUUhNEVBJ1LZuoUezJ4Y0Gi/og6RUDQ2tPvIvN5HIyOmU6bBg9Eo072exF3WfzW GGsQCPSOoyvV4SCf9dNsdnzDZPV6l418lpFKxBL5YlWdhUxcwS7rE6OJcPQFrissv7vZ 1BeFvFO6kcvVRQuXvmIFs6winHVt8aFEmJiFqlIRRU6IK8a1i89JmmNDvXjCjyu8GRuu L3i+0cxtwDWKj++Q8jHgWOvombF7r4+6H3XqvXAP9xKnduUBkCL9os9kUnHPETvFftmB L/9g== X-Gm-Message-State: APuU4Z9yMPx4vKXggocaJk6ojPQMTKbi8yum+QbkHer7wGcljApXZb5s KfwCWTUnHeRCa2a+XbeviNQjygBoEumsYsISyQy8dsguwwT+XWpQRaJg0jxZuRkjajeLDEZLaqa ftmFwTL4v3X+mXjMDqq2DmItz1kx9ohEJaoiNSVaN03DUlnaGciKvq5rYCMVH4mNqVg== X-Gm-Gg: AZFdTZdGfnQUAc72oLeIq18pyV/ymuBl9WXwY/X9is9d26gg6H6TXekd0GRVZaSHeAA TJFmzifM36CUDvNVVUbJzKEJ9n52GJ62dz1EL7UOSngF5plbT9dgN7Ubb9D5IANSkd26XyVAs0X gNg0zcYx/grJISvOgedojAaBj97qzSBDkqUPhCKf2xsA2+HttMgMHtvtoAQtNfgyXXf4bkrLsvV FdwNBrePiemqPww33akeV/WFnONOHCiZ3Vi4OWItujmp1IMJMtv8dhTevkjz8DXS2UBlpPoMof1 9a/bCSRFaMpHTPzXjYkjbsCYBGaErupBBvabkkv0IMMbTriKW3/+eU58LD0w95OKExzdpgQHJQv QqS5yeHauz9q+/jx9Pd6q78i0/jVmE1t2h+4amOHNg2j/E2oMNcTXDIOrHr+euk7KiEBanE45jE 1opaiC3jDq4OyRK4WDYdRP X-Received: by 2002:a05:7022:5f08:b0:1b5:23eb:530b with SMTP id a92af1059eb24-1b5568de6e7mr28274549c88.23.1795811532201; Fri, 27 Nov 2026 12:32:12 -0800 (PST) X-Received: by 2002:a05:7022:5f08:b0:1b5:23eb:530b with SMTP id a92af1059eb24-1b5568de6e7mr28274527c88.23.1795811531670; Fri, 27 Nov 2026 12:32:11 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: Helge Deller , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pierrick Bouvier , Laurent Vivier , Ani Sinha , Brian Cain Subject: [PATCH for-12.0 v2 1/5] dump: fix e_ehsize in ELF core headers Date: Fri, 27 Nov 2026 12:32:05 -0800 Message-Id: <20261127203209.42752-2-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261127203209.42752-1-brian.cain@oss.qualcomm.com> References: <20261127203209.42752-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: Rt1dyzDpSICl93eqmtXtY558fdhT_S3L X-Authority-Analysis: v=2.4 cv=U5kHnuru c=1 sm=1 tr=0 ts=6b09e8cd cx=c_pps a=JYo30EpNSr/tUYqK9jHPoA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=YYXFeDNx8urxxFB-_bQA:9 a=QEXdDO2ut3YA:10 a=Fk4IpSoW4aLDllm1B1p-:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI3MDA4MSBTYWx0ZWRfX5+OaeWs6Rh46 WVGnpxpfbfEWwZSeJltKUhJD4s+ZDTw74egOeZuGo99aQ5EO+qNdyzXdArTuQ8nAc/HnLewR9sx L4YMUqC1Htwi86jglJLE1+4lL5DU5NY= X-Proofpoint-GUID: Rt1dyzDpSICl93eqmtXtY558fdhT_S3L X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTI3MDA4MSBTYWx0ZWRfX0fiBTiyyyGwl tC4013PDHYwAZnWRPL0Jm660/g5dsbnNqAjZ+ZKFDeemidELadGNXStJ3KNJmzzcwrkdwQhfrx2 Yn39Pm+qGizvOu/gnCreLnvfbvQ1YI0FQjO6TWpo8oYEyO6Asr3lraCDXTIh9GV8YS0cKCH4y8A ffNR4hnIMh48ekCyH186x9nO1vHVmKDM7/CurZ4yD5E+L5ImHekn7WjuSsmyLzSTUkXgs6XoII+ 3GPuSt/jPj0nqP1JJvc5OKCx7yozXltlU0nBJEO1dRBAQki5Eog3M2lmzInSIQYbh1W6N3G8evs 3VEykkcAQQ7w+MhAcTD5TiTrQbqewxKPyeJZKBJ50W2uMPWyzuLHaDVOaRjg6PBVSGVeENKBWcf KrScoCKW+b2yaPmwv0Emmw4/zDSSnjCPW46AkX9rIg6lbDhcOKCLAIRQU+Qcmn1QiwS2tJPGKXF hfJ69KLnQbqg9cBDWww== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-27_04,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 adultscore=0 suspectscore=0 malwarescore=0 priorityscore=1501 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611270081 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: 1795811614759158500 prepare_elf{32,64}_header() used the wrong size for the elf_header. e_ehsize field reads 8 on a typical host instead of 52/64 for ELF32,64. Use sizeof(*elf_header) instead. Fixes: 670e76998a6e ("dump: Split elf header functions into prepare and wri= te") Reviewed-by: Helge Deller Signed-off-by: Brian Cain --- dump/dump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index 23ac689907a..6b568516960 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -157,7 +157,7 @@ static void prepare_elf64_header(DumpState *s, Elf64_Eh= dr *elf_header) elf_header->e_type =3D cpu_to_dump16(s, ET_CORE); elf_header->e_machine =3D cpu_to_dump16(s, s->dump_info.d_machine); elf_header->e_version =3D cpu_to_dump32(s, EV_CURRENT); - elf_header->e_ehsize =3D cpu_to_dump16(s, sizeof(elf_header)); + elf_header->e_ehsize =3D cpu_to_dump16(s, sizeof(*elf_header)); elf_header->e_phoff =3D cpu_to_dump64(s, s->phdr_offset); elf_header->e_phentsize =3D cpu_to_dump16(s, sizeof(Elf64_Phdr)); elf_header->e_phnum =3D cpu_to_dump16(s, phnum); @@ -184,7 +184,7 @@ static void prepare_elf32_header(DumpState *s, Elf32_Eh= dr *elf_header) elf_header->e_type =3D cpu_to_dump16(s, ET_CORE); elf_header->e_machine =3D cpu_to_dump16(s, s->dump_info.d_machine); elf_header->e_version =3D cpu_to_dump32(s, EV_CURRENT); - elf_header->e_ehsize =3D cpu_to_dump16(s, sizeof(elf_header)); + elf_header->e_ehsize =3D cpu_to_dump16(s, sizeof(*elf_header)); elf_header->e_phoff =3D cpu_to_dump32(s, s->phdr_offset); elf_header->e_phentsize =3D cpu_to_dump16(s, sizeof(Elf32_Phdr)); elf_header->e_phnum =3D cpu_to_dump16(s, phnum); --=20 2.34.1 From nobody Sun Nov 29 02:11:44 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=none dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795811603; cv=none; d=zohomail.com; s=zohoarc; b=KrOaEVwie/sFiqZ49Omud5ons7/1J+z36Oo63IuVJYYLYBF2b/q9xMS0Of3vTK+6P+1R9lp4lYxtj9CqGTf5k/SQVID2Vgq2b3wKtu2OQzT2FKI9D9wZpBdCMU74RDCHAp5tymKhA7EdY3mIYy+eZt4Mfjj0Z+P8nmlRQat7T5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795811603; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Dycv0ffpOVX428w+MQqS97N3G7y1RWLQeTKAoLT43zs=; b=VG2LdqKEKHLDQ7vaBvOAXfkeYoBN1AKZdoI/KaKbcRpschdklVNAHUKsy37ZV51XOasM0pQEjV474cfZpZotdE7pfv4kqlecKxdlcJiYE8e/Uu2+DSs2ZUs3NrC9S9tr8gxsVAnyG5ZKlkiZCrzJbpeLO2v2sXrwSwR71h3o3l0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795811603830375.82759005951755; Fri, 27 Nov 2026 12:33:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xX2cH-0002tE-SM; Fri, 27 Nov 2026 15:32:21 -0500 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 1xX2cD-0002rV-Rn for qemu-devel@nongnu.org; Fri, 27 Nov 2026 15:32:17 -0500 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 1xX2cB-0001jj-Mk for qemu-devel@nongnu.org; Fri, 27 Nov 2026 15:32:17 -0500 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ARJBXGd2762926 for ; Fri, 27 Nov 2026 20:32:14 GMT Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j756kaqjf-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 27 Nov 2026 20:32:14 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-386df943355so1421676eec.1 for ; Fri, 27 Nov 2026 12:32:14 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55681301asm59248021c88.8.2026.11.27.12.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2026 12:32:12 -0800 (PST) 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= Dycv0ffpOVX428w+MQqS97N3G7y1RWLQeTKAoLT43zs=; b=JSToEpEEB+Pi5+Jc jAGyJywXtRfhhsWgNLt5rbxHtTt995Gc0qkKcD902aJNNm8/5KWKbF6qLzilDrx/ vmFA+IJGERwJmH/pmkTlmX0xWznruv/Bf8peHcH9oh6sNtfhQ+4BWK4lBs1nyeIx PLEhhlVFi0c77yFQ1dHGCOr0M1tZ/ZyyhlwN9OaiLVmXfF6hteEokK85wLgRJkUw vdVeGhVXGgPbeEWG4C6+mO3p0jMhNVqnVupFbzrOyTxIw9+Ruk8wNz7LrXlvV7In TFihPvlbnXMPgOM/47UKH8eMAxnZxel0msIWRDOx0KiPGfpRgkHqwG3nLyqS0mZw IiHKPw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795811534; x=1796416334; 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=Dycv0ffpOVX428w+MQqS97N3G7y1RWLQeTKAoLT43zs=; b=bIWkKy2RKeXOgmQDljSs0zfVa569EWVgePu7qbzsF5Ov2fF+ybiyWHsbkmd+CvW+Im tsYX+eWVl58F6YH8Lv0bVfhXi0TJMJwlNZWTozDdzV4Ie4nYER3drNycgb3y0C0TYbjz KMLEhW0bBIOhjBUFGzji1Tww9WIyrliIqHfu0DsPT99tq2LKfuymU/qZrPLE0QFYyoNh OMoQzI4b0CzW4FX3mOpuDWpdj+a91RY6E7bfxnU65AA7RIOCaAY6d3PKBPksIzS8QWNL 2+ZHL7u5Br7fnmMkTeDwLgHfRCvmSuFzY1dvDf5OU14gyY84PtrWxZvZ8ZgArsF7gp9A ojtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795811534; x=1796416334; 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=Dycv0ffpOVX428w+MQqS97N3G7y1RWLQeTKAoLT43zs=; b=nPMOgmZ61g1ClDayasHY5pOditEmSHpXpgbPTCy6ITmLqlfvIANMBP+NyhA+9tNiQq py1nPFFdgTqmcVaWjTFXz3ma5KiMuaVTQyBZTsRcX2qWQUp5kKsnpCU/d4scc+vog0AZ vebWHXRtp/n1bTCCGYnwdaqtaOYESDJVgoda4fE8XPvuSDS58m3S0Nkg2SxBSdMa2jbR 8dwPRqzip3gqlq+WiMZnigyhLFfdeMjc+zpOL3ghXYd6qmIMi6bCI7Hm4LFbDjHhD/It ADB0qZXwT1aqP+jh6G01Frq/Vhyfs5VgqPXgLGR++BoipMxdzKp1qklLYUXGUz5JbVrx bXiA== X-Gm-Message-State: APuU4Z9PoWQrFZ6fIimZWhU9OI6CxpwVHgF57jAOoE05k3p3rwUX7xBP KETWncUoxtcd1w8NQwh+CPNmW+hdX5YxqvG6dJepXG41cbzax3xeG29VBHpXXBZZuonphAkDL+u 2/jBuy+AO7p5MKv3R3lH66qjj5Fnzx3sdQ/ncNHYEa+57I4r7oP54IKK8YRVrXs6hUg== X-Gm-Gg: AZFdTZd+Xym2kjl7V3Ctq5SiQrnrzYtH6keqS+Zy0bLgQPnnFfieVXT3yoEwFV0Jqh/ ev+VuM9Z1NOD6k3kay5cnVJS9VzUt3jP2v2GHkrMooKGmtyemq8d0MqM8Iitg3SUQWk5XOeA1vz +6cq/pXpzU7csebPTv1Lh7aD4xnODTLIVk0amg1e/q5np/aq4CyTPMjW+8Ip0RGQhT6Q5JA45wL a1GnkaIO03AFqe513xZmOMZgz2fSJbvZt7ir87iFKcqEdceAyzorQixWRtnO9Kswkno2SQW/+3t ueYhloL3PDJ2+77KDI7W75lkZgPExhjUqzwaa3W7jEPXfV/34IV51TNrljPjO6sGutVjkH8J9nR ehiM6WzQD4vEbEr4hxkFoRH/ytq2rq29puz/nJue/Cr3pWzenxlv5Zxd2b91M8hvSWI4z67Mol7 wPIRLQKIkxee1VQzQ4qbwr X-Received: by 2002:a05:7022:7f19:b0:19f:cc98:f603 with SMTP id a92af1059eb24-1b5520d7d86mr23999572c88.1.1795811533606; Fri, 27 Nov 2026 12:32:13 -0800 (PST) X-Received: by 2002:a05:7022:7f19:b0:19f:cc98:f603 with SMTP id a92af1059eb24-1b5520d7d86mr23999546c88.1.1795811533088; Fri, 27 Nov 2026 12:32:13 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: Helge Deller , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pierrick Bouvier , Laurent Vivier , Ani Sinha , Brian Cain Subject: [PATCH for-12.0 v2 2/5] dump: let targets set e_flags in the ELF core header Date: Fri, 27 Nov 2026 12:32:06 -0800 Message-Id: <20261127203209.42752-3-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261127203209.42752-1-brian.cain@oss.qualcomm.com> References: <20261127203209.42752-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: AW1haW4tMjYxMTI3MDA4MSBTYWx0ZWRfX6ksR/KK8dOqB OWoz7rGZzfoSIDxAwu24KYsrTZSoqj1Czw1BHROjOl2+L+BgS6QlE60cnR00DxoOHrV01CY8D9k ZpqixPO1qSxDDun6ddf6pJm3YOx43NLtB/NeZ9cduhd9gBOnfS0VGc1Gg3s4D3mOfQTvh7sKBt0 7/RnYbN9gHOOZ3o/kaVr0ggCjSxaHqfsBZJUnYJvbdaP5VhL8Cs7tTyeqgKLMDnUVX8iW02vEB+ JHt73A6AP3pHSs/bFwEGnUIbGy4mXO8ZV4JBhS+m9GIF/1MLuNTDGpvanT/WcD1uRPao+O6DL/S Hz7b4nhE9jOS0Fim/GGy/P1UyzFvwo2+dE+LBHvTIqFjcsCU6GoCKrFLUebS6VBi6jwmZUTxE+O /UmViBtfwsDKrw1vO6ULueGh+TfoI0iSdaeauTSBRfC1ZmG8Y3TjHy4LsbPy69RSj757+cznuYL T8Rm+bcQxJZzOfUnqRQ== X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI3MDA4MSBTYWx0ZWRfXzyIYFf3znKWv HE6XkBEjtXzDLctZvUFzHP5xTCNwwqnRhatRMewVRsl4AdO+nq7VbghLnc5Ju9RUZdVimc/xPsO E0OrN+9jhIuGWIdOyzIC5leZYB7MwG0= X-Authority-Analysis: v=2.4 cv=ebWo7LEH c=1 sm=1 tr=0 ts=6b09e8ce cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=d927mnl5WceuBYyLXBcA:9 a=QEXdDO2ut3YA:10 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-GUID: 8Lepg9jDMavV7RupBEmaGK8nBOiWcorT X-Proofpoint-ORIG-GUID: 8Lepg9jDMavV7RupBEmaGK8nBOiWcorT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-27_04,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611270081 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: 1795811604516158500 Some targets encode machine details in the ELF header e_flags field, hexagon for example includs the ISA version. Add a d_flags member to ArchDumpInfo and emit it in the ELF{32,64} headers. Reviewed-by: Helge Deller Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/system/dump-arch.h | 1 + dump/dump.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/system/dump-arch.h b/include/system/dump-arch.h index 86b9ae15b6a..f42e0e48cf5 100644 --- a/include/system/dump-arch.h +++ b/include/system/dump-arch.h @@ -18,6 +18,7 @@ struct ArchDumpInfo { int d_machine; /* Architecture */ int d_endian; /* ELFDATA2LSB or ELFDATA2MSB */ int d_class; /* ELFCLASS32 or ELFCLASS64 */ + uint32_t d_flags; /* Machine-specific e_flags of the ELF header= */ uint32_t page_size; /* The target's page size. If it's variable a= nd * unknown, then this should be the maximum. = */ uint64_t phys_base; /* The target's physmem base. */ diff --git a/dump/dump.c b/dump/dump.c index 6b568516960..db2983c2463 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -157,6 +157,7 @@ static void prepare_elf64_header(DumpState *s, Elf64_Eh= dr *elf_header) elf_header->e_type =3D cpu_to_dump16(s, ET_CORE); elf_header->e_machine =3D cpu_to_dump16(s, s->dump_info.d_machine); elf_header->e_version =3D cpu_to_dump32(s, EV_CURRENT); + elf_header->e_flags =3D cpu_to_dump32(s, s->dump_info.d_flags); elf_header->e_ehsize =3D cpu_to_dump16(s, sizeof(*elf_header)); elf_header->e_phoff =3D cpu_to_dump64(s, s->phdr_offset); elf_header->e_phentsize =3D cpu_to_dump16(s, sizeof(Elf64_Phdr)); @@ -184,6 +185,7 @@ static void prepare_elf32_header(DumpState *s, Elf32_Eh= dr *elf_header) elf_header->e_type =3D cpu_to_dump16(s, ET_CORE); elf_header->e_machine =3D cpu_to_dump16(s, s->dump_info.d_machine); elf_header->e_version =3D cpu_to_dump32(s, EV_CURRENT); + elf_header->e_flags =3D cpu_to_dump32(s, s->dump_info.d_flags); elf_header->e_ehsize =3D cpu_to_dump16(s, sizeof(*elf_header)); elf_header->e_phoff =3D cpu_to_dump32(s, s->phdr_offset); elf_header->e_phentsize =3D cpu_to_dump16(s, sizeof(Elf32_Phdr)); --=20 2.34.1 From nobody Sun Nov 29 02:11:44 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=none dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795811620; cv=none; d=zohomail.com; s=zohoarc; b=KqEzrZ3Vgu8n2GHTA0kOvT0sCPv5Rf4kFCxVE97C7Eo0iDgrC5uqPbmBKwGA96xP1MV1HvxMY5KCAjuJC9GEV7TWbqIaODyu2wk8ft9PrYHhFSzoauVraCvh+D5HrU6FrUc0tp1y0fa6QNSSznuz1CJoeKM0YFLtR/ugEjdS1wI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795811620; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e2oOpjIR/volTF3ijNmt/u7efTWHN/46JPiG3ZB3Fmk=; b=ao7zcpEJLZS3jDctbPMAHXc+DJpUaFWwiloKeQ6flitidV5q1koIYi/hRS+ttrkArsyb94jU8RmiNvaUzvvJxWju5XDiPEDghh5//BKaezBBxkoztGJfZ/Pem3+d+Bd8W156GGaoiVYOQ/3S2pvIECpx6n3EWgnCTYAZab/YLgY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795811620691573.9544517966192; Fri, 27 Nov 2026 12:33:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xX2cI-0002tH-1e; Fri, 27 Nov 2026 15:32:22 -0500 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 1xX2cG-0002sm-K1 for qemu-devel@nongnu.org; Fri, 27 Nov 2026 15:32:20 -0500 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 1xX2cE-00025n-Ir for qemu-devel@nongnu.org; Fri, 27 Nov 2026 15:32:20 -0500 Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ARJCFL43984365 for ; Fri, 27 Nov 2026 20:32:16 GMT Received: from mail-dl1-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j7f6d8918-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 27 Nov 2026 20:32:16 +0000 (GMT) Received: by mail-dl1-f71.google.com with SMTP id a92af1059eb24-139b62317d0so5934900c88.0 for ; Fri, 27 Nov 2026 12:32:16 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55681301asm59248021c88.8.2026.11.27.12.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2026 12:32:13 -0800 (PST) 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= e2oOpjIR/volTF3ijNmt/u7efTWHN/46JPiG3ZB3Fmk=; b=TbVZL8OAHnZPaJJi DxIPmXtA30CLKgI+NwVfD24lE5jh25pmSTAWbvQ2GzNtDj4O9bomq+am4I7eegPs IHct/Gx5IL8lN99eUwtLiZ0GehVTvBXghonIuwUa08Cp8mNWxvcanXmqoDqnzcyh AboKy3BjdgatbXtso7a6edL1lnMSq/ULXKOWbJZUbOiUJKKYv+0x/QEqbh0urrFq JtjVtIb3334u1S7ibFC5WYzx+PQpvWeYEojYwc/4HF5se51MrvLvayHoCsxNpyoK nsN91X4VKCM6tjN7PD7m1yETH9oq7T7u04J6rgqePEESbXw7Tq97UsQmOXsSjrp+ DNXKjw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795811536; x=1796416336; 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=e2oOpjIR/volTF3ijNmt/u7efTWHN/46JPiG3ZB3Fmk=; b=RGRy9SBPP8JgdoLxj6omucnDLkU7NGI+i3XxhuhPF26kaeRZ+ai3mSCpBBUNifzbst RBGTLY1VXHLduyYyILxBUMEC87N+9hT1aXu6U+XGmo/IkaSnnJs88Km/FamJefOtGcNh 1jpHtvuC4QytYsCC1u7f4FgIPVvJcHbJnrt/BM9nVxkURihdFnOd5KS1yHqURaGwT/RV /uFOa3O/zhsRg/HkDb5peZ6RkkSOx6RsM7EKlvKsO6+fM+JXzZ7q7XpJm0l5XaVrJ05o 1Nizy7sTdhx10ewT4MKr+CuXr+hpvSy6Nhsi2GlYPJ/rYlU2pZZLHIVYhpSSPKLWZOVJ dCsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795811536; x=1796416336; 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=e2oOpjIR/volTF3ijNmt/u7efTWHN/46JPiG3ZB3Fmk=; b=DHKwUagUGfqCIb3XbCActXiODjT56BkFL3PpGQ3+n0DTpa0OwlMfqrxlg7Z1Xcq46z Zbhoj3ULzDi7nInZQWilCSb6GQkBDuIZKgj4tfWhh3/yVv5I2rcv3eG2oWN2KVBLs52D SunrfTVkaqGLy+h7Z2jdvRz+AJ1TG4tzy928j/RHnEgXZvPgrWQbfDwqDR8S8g7x3m4n eqtZruHd1yCiW7XQiBg0UEFHZDXPmvkVINs2lA6yAzi9S2lwtRHMUwrxI67ko4HGMU+7 AVQZqlF7rRimpihpjvFq+paj0EkBYupBWsqXg8nMHMh5HfssXQ/4qWCVdLRDnJzJ0IPN ph3A== X-Gm-Message-State: APuU4Z8lIGj55QsABFotou6GjR3POowr7bnz5789gEeK9qpLqA5PZnTl Pl80ejN3ZMqRTXivZ3Z+RJbJRNpKv3sVe+bkIrran0QM4RGSjZBuoeCYN4IajfE4Cc+Pco1+Hfy E4M2C7ytxV/1ocNbql+I95C0pCF+ZwhsAApSFSjfxCPo6fx2MP6tTrF/iWeuOHXkf8g== X-Gm-Gg: AZFdTZf4lKteP4AzzRKoimjYFOUWZ4WDJTNuqmLNHNa+pgYXNndqe0NrFztw/E/vtaX /UM7uSYc2+8JUyFZ/JPxBNVMwPkFQzhi/9t6NaVlT1YrwF0cqJaMCc7ENcAUbiVNc1Y9IpH+fOy ArDmt4cI0ml4O4Lt3j5wV2/ZX3wMeecD6sZ5riGf9ABLqZEGt9MR+DD8el62bAuuZmzREq2PFVZ cBIp3OdPgIV2O9Tzz/wGbAfqs+dqlBFcE3oyfIDQ+UB2omM+EscnCtOgRm+gyY/zrTqnCAQIjuM JPgi/o/vl8BnVLk8csE+JSTCvXqjkkYDMCFmaA6IgzS22E8lkoOEe44bDKidKoujtrRQ1jKXwJW Ip6/WP9SJLDWt+2ymLq+W6edPfsA6aacttQUuxK5OokUAeXP3TNZffm7jg6RnTtAZQFseOohVdJ enOikJQU36JpjJ/isefK7j X-Received: by 2002:a05:701a:cc84:10b0:1b5:709f:d510 with SMTP id a92af1059eb24-1b5709fd63fmr17893176c88.22.1795811535738; Fri, 27 Nov 2026 12:32:15 -0800 (PST) X-Received: by 2002:a05:701a:cc84:10b0:1b5:709f:d510 with SMTP id a92af1059eb24-1b5709fd63fmr17893151c88.22.1795811535260; Fri, 27 Nov 2026 12:32:15 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: Helge Deller , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pierrick Bouvier , Laurent Vivier , Ani Sinha , Brian Cain Subject: [PATCH for-12.0 v2 3/5] linux-user: let targets add notes to core dumps Date: Fri, 27 Nov 2026 12:32:07 -0800 Message-Id: <20261127203209.42752-4-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261127203209.42752-1-brian.cain@oss.qualcomm.com> References: <20261127203209.42752-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: RmHvsAc_XEwKEL1gDe2NVhIqH9QaTkwq X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI3MDA4MSBTYWx0ZWRfXynZ1Km5VylpD cfU+8XAXi07d/PDsos4cK4ynuHLAs+KNS4R+QBAbYkGllRZfPKAsyPIAR3tgkRGJ1M8w1wImIMb 5M55T08yxLNKtyF8gyBMEz0Eak32yIo= X-Authority-Analysis: v=2.4 cv=IKqXmQvG c=1 sm=1 tr=0 ts=6b09e8d0 cx=c_pps a=JYo30EpNSr/tUYqK9jHPoA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=QP29ThLKEn_V7VGjd4QA:9 a=QEXdDO2ut3YA:10 a=Fk4IpSoW4aLDllm1B1p-:22 X-Proofpoint-GUID: RmHvsAc_XEwKEL1gDe2NVhIqH9QaTkwq X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTI3MDA4MSBTYWx0ZWRfX9KEkHMX0CXIu UJhjObdRZ1n6C/G7+sx6Adwe9CKtXHbEXQtSKOMbjoxZrwqW8CfRw/75iB0hLj0RfjmnFyNtVYj cKFvPtM4/alrWNy9MrqxTGRqBjo4itY6RJQtw80Ne4l2WUr7borjN793GUQ3oSgekHTUdlPzqHs YPtvMYJJJz05staWG//7xaSzi0tnIa3FNU+ix4cYaGhklPqbgZi0JmHlOLrLRy6QfXYnKjZflRf TgLX7ymMEAPC0MZDNqoyMfPr3emPbn1unCwG0/ZkHk1PIqz8MSAuvnxLHRD/fjqIA9RLrn548pN 1AQD6mDxFsbUoXDfJ0WUD0NiXXXEp3ueCY205Hdxxm055VNdzHVWcDH+gHzngADM6aDss4i1SWK WFt5JHIwwurI2EbxaLVdUF6tN/gJab+EAJ+NSYiNv7oLVlSt76EGF/wQr1IMEBc5aI5D9Jop7xe oaPunb+7nvqYSwiRu3Q== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-27_04,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 bulkscore=0 suspectscore=0 phishscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611270081 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: 1795811622723158500 The linux-user core writer only emits NT_PRSTATUS and, for some targets, NT_FPREGSET for each thread. Targets with additional architectural state, such as vector coprocessor registers, have no way to include it. Add an optional HAVE_ELF_CORE_EXTRA_NOTES hook. This will be leveraged by hexagon in following commits. Reviewed-by: Helge Deller Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- linux-user/loader.h | 9 +++++++++ linux-user/elfload.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/linux-user/loader.h b/linux-user/loader.h index 5ddd140276c..c935d27d0a5 100644 --- a/linux-user/loader.h +++ b/linux-user/loader.h @@ -112,6 +112,15 @@ void elf_core_copy_regs(struct target_elf_gregset_t *,= const CPUArchState *); /* Only defined by a target whose target_elf.h sets HAVE_ELF_CORE_FPREGS. = */ struct target_elf_fpregset_t; void elf_core_copy_fpregs(struct target_elf_fpregset_t *, const CPUArchSta= te *); +/* + * Only defined by a target whose target_elf.h sets HAVE_ELF_CORE_EXTRA_NO= TES. + * The notes follow the thread's NT_PRSTATUS (and NT_FPREGSET) note. + * elf_core_extra_notes_size() returns the size in bytes of the complete, + * 4-byte aligned ELF notes that elf_core_fill_extra_notes() stores in the + * buffer for the same CPU. + */ +size_t elf_core_extra_notes_size(const CPUArchState *); +void elf_core_fill_extra_notes(void *buf, const CPUArchState *); =20 typedef struct { const uint8_t *image; diff --git a/linux-user/elfload.c b/linux-user/elfload.c index c188fa03c31..93bb8b0bb88 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1717,6 +1717,11 @@ int load_elf_binary(struct linux_binprm *bprm, struc= t image_info *info) * env - copy registers from here * * Example for ARM target is provided in this file. + * + * A target that has more per-thread state worth dumping can also define + * HAVE_ELF_CORE_EXTRA_NOTES and implement elf_core_extra_notes_size() and + * elf_core_fill_extra_notes(), to add notes of its own after each thread's + * NT_PRSTATUS note. */ =20 struct target_elf_siginfo { @@ -2183,6 +2188,11 @@ static int elf_core_dump(int signr, const CPUArchSta= te *env) offset +=3D size_note("CORE", sizeof(struct target_elf_prstatus)) * cp= us; #ifdef HAVE_ELF_CORE_FPREGS offset +=3D size_note("CORE", sizeof(target_elf_fpregset_t)) * cpus; +#endif +#ifdef HAVE_ELF_CORE_EXTRA_NOTES + CPU_FOREACH(cpu_iter) { + offset +=3D elf_core_extra_notes_size(cpu_env(cpu_iter)); + } #endif note_size =3D offset - note_offset; data_offset =3D TARGET_PAGE_ALIGN(offset); @@ -2245,6 +2255,10 @@ static int elf_core_dump(int signr, const CPUArchSta= te *env) dptr =3D fill_note(&hptr, NT_FPREGSET, "CORE", sizeof(target_elf_fpregset_t)); fill_fpregset_note(dptr, cpu_iter); +#endif +#ifdef HAVE_ELF_CORE_EXTRA_NOTES + elf_core_fill_extra_notes(hptr, cpu_env(cpu_iter)); + hptr +=3D elf_core_extra_notes_size(cpu_env(cpu_iter)); #endif } =20 --=20 2.34.1 From nobody Sun Nov 29 02:11:44 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=none dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795811596; cv=none; d=zohomail.com; s=zohoarc; b=CPagOWqYaMIFU4Ap/G/6ktwfRb6zhk+CdWfJ0PEXMODRHFhPe8kkVXNk1rAXZUCE2OmpgPxhuoOQIhRvL8c9gDSL2wT90RK/XShYEitJVy0+XhXDMttQw5x0jMtkYFhv6G0n2plEkTfDCZKJnqqeNgdHyQEsKUNHQVuSTlok1jQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795811596; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9kyqlox+ibqfw3qVeLQkGH1NeE2/vSq/qzSOmQhKtrs=; b=cE6dZWtDP6xtz0uSu5BHBw7E+Q+7AzOPQmeAeteLDx0TH7fo1LV0y89waixPRbvCeV/XSBxwAI9oUaWBFcRhw7WGeb1eknqUSP41QfWTAFQpecF7EISMariDToqc7RIqechhlCmDep6q76T+m40HSWognKSYh1QoRpmQrjEJcCg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795811596844148.62359415383958; Fri, 27 Nov 2026 12:33:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xX2cJ-0002tt-F9; Fri, 27 Nov 2026 15:32:23 -0500 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 1xX2cH-0002tF-RI for qemu-devel@nongnu.org; Fri, 27 Nov 2026 15:32:21 -0500 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 1xX2cF-0002JU-DJ for qemu-devel@nongnu.org; Fri, 27 Nov 2026 15:32:21 -0500 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6ARJB0K13134358 for ; Fri, 27 Nov 2026 20:32:18 GMT Received: from mail-dl1-f69.google.com (mail-dl1-f69.google.com [74.125.82.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j74gatuvn-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 27 Nov 2026 20:32:18 +0000 (GMT) Received: by mail-dl1-f69.google.com with SMTP id a92af1059eb24-1b56c696405so13299022c88.1 for ; Fri, 27 Nov 2026 12:32:18 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55681301asm59248021c88.8.2026.11.27.12.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2026 12:32:15 -0800 (PST) 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= 9kyqlox+ibqfw3qVeLQkGH1NeE2/vSq/qzSOmQhKtrs=; b=aGb+zJg7vtq63oGm L+Y24uHHwhr4A+F6EJCPC3oJxj6oj7DfbhOFbeF2qwQ7eeFKx/TMvWslli5CgHkf Wpvn2IQZCA7aCtM40kSSohMuB/8XuY7iaQsXTdD8iCHNnpX5P2aTpkGc3Bp4UqYG EhALwAduNpBd5QOJZcavHAaDUOv7T/LkAeeKMowPfZoBc25GfzXWKrPbNQSe6gcq rL7FnC9pij4Fg4louq2bZetrGy4OBpdzu8g+3s3AexLeRU/7r0SwiWdGzu/Pm11V ABka5aZrWLC0nI9lMyWvY6PcO+UEW4Z1Yos89Fn51QebqQCSM1Wm7VdZHB1x8V+l DyQV8Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795811537; x=1796416337; 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=9kyqlox+ibqfw3qVeLQkGH1NeE2/vSq/qzSOmQhKtrs=; b=abap0cMVB2u82XrjPxpXLz3uxT3B/gO78jaY+0MwUkFPj8eFhx84SpXQ29q2tv/Zo2 L7c97k87b+15qvO5OQp0AYCwQldoKidOmOj5wZ1fmTZafzGB3byF8z9n6cvxUv3mQGJO C5AfR7KAW6PpdoVo3RCNXvN0kDGlSpEUeojk6Wme5Ng2OchepW5BOSbrxQbm13cohdfd hic4MH52KiGDcJ8jJzIVucQn2R8r4H3hFOsVsxbC+vV0RAs099HGtNwiG3EM6qSSLoTV q4SLO7eWtLScK307fTOVhE3Efk04KyJ59j+yeKejIp+s2fD+9IvQjN8tlV91iyy+HkjS HzjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795811537; x=1796416337; 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=9kyqlox+ibqfw3qVeLQkGH1NeE2/vSq/qzSOmQhKtrs=; b=q6feKCLePupJsF7lUzDN2+OUbfgRQn8ZRsBtk+t6Nv7fmlhd1AVnutjypaJgioZoU1 Bkkk2+5qqX3xR7xh3wKihQeFF4Ra5bJOA7xr2v1b8j+CyDU/+/dumBCZKfuA2MS6kLXD 222PIzBaovtrE/oK3gq0VyA3riyTCq8j3ZjVBLgYnh5fZUceFYXwiZzzy42lkqvy5Gin yxFcpcBROqgr7d4RaO3FAv09ptsCEoNwm4LWhGVjLWEbcxCpWXimATI3PvFLXQ4FO9V6 uZ5EGP3b2QI4LwtXEWfuJQmds7aflnQ8torzGq+mdtyx9N9XH49V/TdxZI57bVkCyAOg FmQw== X-Gm-Message-State: APuU4Z8YrE9GotbRbULdgB8wROzvc3gHNIm02I27QikdKq8Fu3btRUr5 x/66unDb/5kxAQY7HNtd7TBU88yKb/D9XqxAOez18oTIr53eL+sRALQSCKCx/Qsj/JIf9fgBhDV KmcOOzpEVc0aGFUwB+pKjU1+XUDrMIdRjQtHdcY0owy06kteX2LvJ3cMNHD0sqSGkLA== X-Gm-Gg: AZFdTZdHog4BaW3elfBaQn/Uh4ousSaP2L1mv71T6Dlf3jYQQT+2V7msfnYkuKPLNVk 3ZArGA6nDb6TW2lbRlZqXJSY1yz2aPY4DoETJqG4NawoZk1lL5Z7rTMHvmfNwiJn8GxGiRWgB0j JiJB/wT8IMjsA4twFjNh7RpRURczBDCnC4ddqOjlDDd37wir1WkSOeiCSjhbmQu8OOwWhlsotaG bJrbieA8jycuElexmb5m15Iwu33a6BbhtOQ6QnKzlUcn31GlTtjreTozrG5RdISV/HM41KhgV4E zCv72gXThMSfD8lJMwV676siOzAjhDiUhpnMDEJVD7w2YasnO3wXvCjT1PNx68pgd1ZlJRpaSiF Q+KvwdYkDHm8SERqxQHbXanaM6/XEn42RRzPw1CXFt0/FMV38wRI56Z/42rnTqKfQj0VHkBNfif NWwUSn6Kj6CbqccpUJuOST X-Received: by 2002:a05:701b:42c6:10b0:1ac:91b6:8dfd with SMTP id a92af1059eb24-1b55690919bmr28775629c88.31.1795811537128; Fri, 27 Nov 2026 12:32:17 -0800 (PST) X-Received: by 2002:a05:701b:42c6:10b0:1ac:91b6:8dfd with SMTP id a92af1059eb24-1b55690919bmr28775602c88.31.1795811536588; Fri, 27 Nov 2026 12:32:16 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: Helge Deller , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pierrick Bouvier , Laurent Vivier , Ani Sinha , Brian Cain Subject: [PATCH for-12.0 v2 4/5] target/hexagon: support ELF core dumps Date: Fri, 27 Nov 2026 12:32:08 -0800 Message-Id: <20261127203209.42752-5-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261127203209.42752-1-brian.cain@oss.qualcomm.com> References: <20261127203209.42752-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: W68RO78L7U5Myev2nfcej8XQunqb45fF X-Proofpoint-GUID: W68RO78L7U5Myev2nfcej8XQunqb45fF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTI3MDA4MSBTYWx0ZWRfX1vtrcVeLokxf k8eaGd5MlLk7aiPY9FRNv9FJAMkgNn5Lpcf8WyMfKRu3zEvt2F4+QmEkdo3eG2CIRGluSJuAUQC vOPSZAeIrM//9/2SFK2CE1vPbLevMT/nuruSFSSxq0fzBy9oNRBFNmewAo5ezHuaJOQuk0atg/f B4CgoK3xdIs/p23IjAoX9QhNYPLiUpz5b9FT0d+W6Q/Kru6aqVj3/YBSJ7pMk8wLmSQeFTAW2rF 7T0CgUuf7gIyPCY6IDg41XCOo4wcWHwcPUnA8bhnMFqVRkZ26uhNxy5rrjKFfgYr+FRcoVME0u6 ZtG06Jsah00fIWSwvTI+bebomxMa8mAckOdAXRye2DOG55ZpGMP+pHKpA81PMynL6vgwToQydC5 aSlJMaA2RPnGkgPPUlf7knQ1ajdpd7Qtj9bb0GQsIog7JASG/3djtIS206OUrWqHN2eqiO7huGz QYKN3WeV4czKUvOfslA== X-Authority-Analysis: v=2.4 cv=I5bw19gg c=1 sm=1 tr=0 ts=6b09e8d2 cx=c_pps a=kVLUcbK0zfr7ocalXnG1qA==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=0nRkh3ypGcbDwTCxfF0A:9 a=QEXdDO2ut3YA:10 a=vr4QvYf-bLy2KjpDp97w:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI3MDA4MSBTYWx0ZWRfX6FrQXlTi/QeH t/NYVXKXXypNETVTdhwU2Dxze3EoJDRWgRa/aAt7jdiyxcWfYfWVP5URJ11ERxiS6GDa0HPkF2k cTI9LWA6lOjgWnsNTy+YlneIyHami+A= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-27_04,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611270081 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: 1795811598656158501 Write core files for Hexagon. For each hw thread, write a note w/ user_regs_struct layout from linux kernel. In system mode the cause register is filled from SSR, badva from the system register, and pr_pid is the CPU index. dump-guest-memory with paging requested relies on the CPU's get_memory_mapping and get_paging_enabled callbacks. Implement get_paging_enabled. Build the mappings from the valid TLB entries: for each CPU, consider global entries and those matching the CPU's current ASID. Reviewed-by: Helge Deller Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/hw/hexagon/hexagon_tlb.h | 10 +++ linux-user/hexagon/target_elf.h | 7 ++ target/hexagon/core-dump.h | 73 +++++++++++++++++++++ target/hexagon/internal.h | 8 +++ hw/hexagon/hexagon_tlb.c | 17 +++++ linux-user/hexagon/elfload.c | 4 ++ target/hexagon/arch_dump.c | 108 +++++++++++++++++++++++++++++++ target/hexagon/cpu.c | 13 ++++ target/hexagon/meson.build | 1 + 9 files changed, 241 insertions(+) create mode 100644 target/hexagon/core-dump.h create mode 100644 target/hexagon/arch_dump.c diff --git a/include/hw/hexagon/hexagon_tlb.h b/include/hw/hexagon/hexagon_= tlb.h index 355ba3888c0..938b80fbb2b 100644 --- a/include/hw/hexagon/hexagon_tlb.h +++ b/include/hw/hexagon/hexagon_tlb.h @@ -26,6 +26,16 @@ struct HexagonTLBState { QemuMutex lock; }; =20 +typedef struct HexagonTLBMapping { + uint64_t va; /* Start of the page, aligned to @size */ + uint64_t pa; /* Start of the physical page */ + uint64_t size; /* Page size in bytes */ + uint32_t asid; /* Valid only when !@global */ + bool global; /* Entry matches in every ASID */ +} HexagonTLBMapping; + +bool hexagon_tlb_decode_entry(uint64_t entry, HexagonTLBMapping *mapping); + uint64_t hexagon_tlb_read(HexagonTLBState *tlb, uint32_t index); uint64_t hexagon_tlb_write(HexagonTLBState *tlb, uint32_t index, uint64_t value); diff --git a/linux-user/hexagon/target_elf.h b/linux-user/hexagon/target_el= f.h index b1eb5ea5037..daaec521a76 100644 --- a/linux-user/hexagon/target_elf.h +++ b/linux-user/hexagon/target_elf.h @@ -23,6 +23,13 @@ =20 #define HAVE_ELF_HWCAP 1 =20 +#include "target/hexagon/core-dump.h" + +#define HAVE_ELF_CORE_DUMP 1 +#define elf_core_eflags(info) ((info)->elf_flags) + +typedef HexagonUserRegs target_elf_gregset_t; + enum { HWCAP_HEXAGON_ISA_MASK =3D 0x7F, HWCAP_HEXAGON_ISA_V2 =3D 1, diff --git a/target/hexagon/core-dump.h b/target/hexagon/core-dump.h new file mode 100644 index 00000000000..a14b495d04d --- /dev/null +++ b/target/hexagon/core-dump.h @@ -0,0 +1,73 @@ +/* + * Hexagon Linux ELF core register layout. + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HEXAGON_CORE_DUMP_H +#define HEXAGON_CORE_DUMP_H + +#include "cpu.h" +#include "qemu/bswap.h" + +/* Linux arch/hexagon/include/uapi/asm/user.h: struct user_regs_struct. */ +typedef struct target_elf_gregset_t { + uint32_t gpr[32]; + uint32_t sa0; + uint32_t lc0; + uint32_t sa1; + uint32_t lc1; + uint32_t m0; + uint32_t m1; + uint32_t usr; + uint32_t p3_0; + uint32_t gp; + uint32_t ugp; + uint32_t pc; + uint32_t cause; + uint32_t badva; + uint32_t cs0; + uint32_t cs1; + uint32_t pad; +} HexagonUserRegs; + +QEMU_BUILD_BUG_ON(sizeof(HexagonUserRegs) !=3D 48 * sizeof(uint32_t)); + +static inline void hexagon_core_copy_regs(HexagonUserRegs *regs, + const CPUHexagonState *env) +{ + uint32_t preds =3D 0; + + for (int i =3D 0; i < ARRAY_SIZE(regs->gpr); i++) { + regs->gpr[i] =3D cpu_to_le32(env->gpr[i]); + } + for (int i =3D 0; i < NUM_PREGS; i++) { + preds |=3D (env->pred[i] & 0xff) << (i * 8); + } + regs->sa0 =3D cpu_to_le32(env->gpr[HEX_REG_SA0]); + regs->lc0 =3D cpu_to_le32(env->gpr[HEX_REG_LC0]); + regs->sa1 =3D cpu_to_le32(env->gpr[HEX_REG_SA1]); + regs->lc1 =3D cpu_to_le32(env->gpr[HEX_REG_LC1]); + regs->m0 =3D cpu_to_le32(env->gpr[HEX_REG_M0]); + regs->m1 =3D cpu_to_le32(env->gpr[HEX_REG_M1]); + regs->usr =3D cpu_to_le32(env->gpr[HEX_REG_USR]); + regs->p3_0 =3D cpu_to_le32(preds); + regs->gp =3D cpu_to_le32(env->gpr[HEX_REG_GP]); + regs->ugp =3D cpu_to_le32(env->gpr[HEX_REG_UGP]); + regs->pc =3D cpu_to_le32(env->gpr[HEX_REG_PC]); +#ifdef CONFIG_USER_ONLY + regs->cause =3D cpu_to_le32(env->cause_code); + regs->badva =3D 0; +#else + regs->cause =3D cpu_to_le32(extract32(env->t_sreg[HEX_SREG_SSR], + reg_field_info[SSR_CAUSE].offset, + reg_field_info[SSR_CAUSE].width)); + regs->badva =3D cpu_to_le32(env->t_sreg[HEX_SREG_BADVA]); +#endif + regs->cs0 =3D cpu_to_le32(env->gpr[HEX_REG_CS0]); + regs->cs1 =3D cpu_to_le32(env->gpr[HEX_REG_CS1]); + regs->pad =3D 0; +} + +#endif /* HEXAGON_CORE_DUMP_H */ diff --git a/target/hexagon/internal.h b/target/hexagon/internal.h index 6def331a83a..1a5ff3daca2 100644 --- a/target/hexagon/internal.h +++ b/target/hexagon/internal.h @@ -60,6 +60,14 @@ void G_NORETURN do_raise_exception(CPUHexagonState *env, =20 #ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_hexagon_cpu; +int hexagon_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, + int cpuid, DumpState *s); +void hexagon_get_dump_info(const CPUState *cs, ArchDumpInfo *info, + const GuestPhysBlockList *guest_phys_blocks); +size_t hexagon_get_note_size(const CPUState *cs, int class, int machine, + int nr_cpus); +bool hexagon_cpu_get_memory_mapping(CPUState *cs, MemoryMappingList *list, + Error **errp); #endif =20 #endif diff --git a/hw/hexagon/hexagon_tlb.c b/hw/hexagon/hexagon_tlb.c index 07406cea35e..53b835cdd2b 100644 --- a/hw/hexagon/hexagon_tlb.c +++ b/hw/hexagon/hexagon_tlb.c @@ -302,6 +302,23 @@ static bool hex_tlb_is_match(uint64_t entry1, uint64_t= entry2, =20 /* Public API */ =20 +bool hexagon_tlb_decode_entry(uint64_t entry, HexagonTLBMapping *mapping) +{ + uint64_t size; + + if (!GET_PTE_V(entry)) { + return false; + } + + size =3D hex_tlb_page_size_bytes(entry); + mapping->size =3D size; + mapping->va =3D ROUND_DOWN(hex_tlb_virt_addr(entry), size); + mapping->pa =3D hex_tlb_phys_addr(entry); + mapping->global =3D GET_PTE_G(entry); + mapping->asid =3D GET_PTE_ASID(entry); + return true; +} + uint64_t hexagon_tlb_read(HexagonTLBState *tlb, uint32_t index) { g_assert(index < tlb->num_entries); diff --git a/linux-user/hexagon/elfload.c b/linux-user/hexagon/elfload.c index db0bf299cc0..dac8260b302 100644 --- a/linux-user/hexagon/elfload.c +++ b/linux-user/hexagon/elfload.c @@ -6,6 +6,10 @@ #include "target_elf.h" #include "target/hexagon/cpu.h" =20 +void elf_core_copy_regs(target_elf_gregset_t *regs, const CPUHexagonState = *env) +{ + hexagon_core_copy_regs(regs, env); +} =20 abi_ulong get_elf_hwcap(CPUState *cs) { diff --git a/target/hexagon/arch_dump.c b/target/hexagon/arch_dump.c new file mode 100644 index 00000000000..c1b2892e2ad --- /dev/null +++ b/target/hexagon/arch_dump.c @@ -0,0 +1,108 @@ +/* + * Hexagon system guest ELF core dumps. + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "elf.h" +#include "qemu/range.h" +#include "system/dump.h" +#include "system/memory_mapping.h" +#include "hw/hexagon/hexagon_tlb.h" +#include "internal.h" +#include "macros.h" +#include "sys_macros.h" +#include "core-dump.h" + +/* Linux include/linux/elfcore.h: struct elf_prstatus for the 32-bit ABI. = */ +typedef struct HexagonElfPrstatus { + uint8_t pad1[24]; + uint32_t pr_pid; + uint8_t pad2[44]; + HexagonUserRegs pr_reg; + uint32_t pr_fpvalid; +} QEMU_PACKED HexagonElfPrstatus; + +QEMU_BUILD_BUG_ON(offsetof(HexagonElfPrstatus, pr_reg) !=3D 72); +QEMU_BUILD_BUG_ON(sizeof(HexagonElfPrstatus) !=3D 268); + +typedef struct HexagonElfNote { + Elf32_Nhdr header; + char name[8]; /* "CORE" including NUL, padded to a 4-byte boundary. */ + HexagonElfPrstatus prstatus; +} QEMU_PACKED HexagonElfNote; + +int hexagon_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, + int cpuid, DumpState *s) +{ + HexagonElfNote note =3D { 0 }; + HexagonUserRegs regs; + + note.header.n_namesz =3D cpu_to_dump32(s, sizeof("CORE")); + note.header.n_descsz =3D cpu_to_dump32(s, sizeof(note.prstatus)); + note.header.n_type =3D cpu_to_dump32(s, NT_PRSTATUS); + memcpy(note.name, "CORE", sizeof("CORE")); + note.prstatus.pr_pid =3D cpu_to_dump32(s, cpuid); + hexagon_core_copy_regs(®s, cpu_env(cs)); + memcpy(¬e.prstatus.pr_reg, ®s, sizeof(regs)); + + return f(¬e, sizeof(note), s); +} + +void hexagon_get_dump_info(const CPUState *cs, ArchDumpInfo *info, + const GuestPhysBlockList *guest_phys_blocks) +{ + const HexagonCPU *cpu =3D HEXAGON_CPU(cs); + + info->d_machine =3D EM_HEXAGON; + info->d_class =3D ELFCLASS32; + info->d_endian =3D ELFDATA2LSB; + /* The values of HexagonVersion match the EF_HEXAGON_MACH_* flags. */ + info->d_flags =3D cpu->cfg.hex_def->hex_version; +} + +size_t hexagon_get_note_size(const CPUState *cs, int class, int machine, + int nr_cpus) +{ + return sizeof(HexagonElfNote) * nr_cpus; +} + +static bool hexagon_mapping_overlaps(const MemoryMappingList *list, + const HexagonTLBMapping *m) +{ + const MemoryMapping *other; + + QTAILQ_FOREACH(other, &list->head, next) { + if (ranges_overlap(other->virt_addr, other->length, m->va, m->size= )) { + return true; + } + } + return false; +} + +bool hexagon_cpu_get_memory_mapping(CPUState *cs, MemoryMappingList *list, + Error **errp) +{ + const HexagonCPU *cpu =3D HEXAGON_CPU(cs); + uint32_t asid =3D GET_SSR_FIELD(SSR_ASID, + cpu_env(cs)->t_sreg[HEX_SREG_SSR]); + uint32_t num_entries; + + g_assert(cpu->tlb); + + num_entries =3D hexagon_tlb_get_num_entries(cpu->tlb); + for (uint32_t i =3D 0; i < num_entries; i++) { + HexagonTLBMapping m; + + if (!hexagon_tlb_decode_entry(hexagon_tlb_read(cpu->tlb, i), &m) || + (!m.global && m.asid !=3D asid) || + hexagon_mapping_overlaps(list, &m)) { + continue; + } + memory_mapping_list_add_merge_sorted(list, m.pa, m.va, m.size); + } + return true; +} diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 3575b31d196..5f7f22fa2ea 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -870,9 +870,22 @@ static bool hexagon_tlb_fill(CPUState *cs, vaddr addre= ss, int size, =20 #include "hw/core/sysemu-cpu-ops.h" =20 +static bool hexagon_cpu_get_paging_enabled(const CPUState *cs) +{ + const HexagonCPU *cpu =3D HEXAGON_CPU(cs); + + return GET_SYSCFG_FIELD(SYSCFG_MMUEN, + hexagon_globalreg_read_syscfg_unlocked(cpu->globalregs)); +} + static const struct SysemuCPUOps hexagon_sysemu_ops =3D { .has_work =3D hexagon_cpu_has_work, + .get_memory_mapping =3D hexagon_cpu_get_memory_mapping, + .get_paging_enabled =3D hexagon_cpu_get_paging_enabled, .translate_for_debug =3D hexagon_cpu_translate_for_debug, + .write_elf32_note =3D hexagon_cpu_write_elf32_note, + .get_dump_info =3D hexagon_get_dump_info, + .get_note_size =3D hexagon_get_note_size, }; =20 static bool hexagon_cpu_exec_interrupt(CPUState *cs, int interrupt_request) diff --git a/target/hexagon/meson.build b/target/hexagon/meson.build index db65edcba54..b9b2a2d9740 100644 --- a/target/hexagon/meson.build +++ b/target/hexagon/meson.build @@ -314,6 +314,7 @@ hexagon_ss.add(files( )) =20 hexagon_softmmu_ss.add(files( + 'arch_dump.c', 'cpu_helper.c', 'hex_mmu.c', 'hex_interrupts.c', --=20 2.34.1 From nobody Sun Nov 29 02:11:44 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=none dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1795811597; cv=none; d=zohomail.com; s=zohoarc; b=RkUYtPajSGys+Z7KUy7V+06FM7ypkepv+l4N86l96YF9FPvG0ZwHapbchdrBFyA4hhS8hv00N8A8GHkAUTB+OdQEYTfRwwKtOwwEnYGhluNmBn6Bg9a7b0v0Ukg0YzOLq1OoYAu/Pt3AZ9KhmezqbsyX5elImCkukrrwJOZKA18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795811597; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gONCxHrhvvp5BSHmp7t+Ax3/Jt+o4/VyXQfDHM4EM7k=; b=j7ZY60HgQXtlRrKZfDnhL6CPl9u2s5y0TrRA3yTKwVtdNcfGRbS4ovkQhBuwempsAZRmZIa9YR2eFWm2fpPXd28Mh61QoCwXYSZ1O6usXGg+oX0TmFVdY4Mi7NBCtnHsWhpFiniq3ECzIMGGRVovtPXPr+Zjg+iuV//zpgjjkzg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795811597017925.3851023814414; Fri, 27 Nov 2026 12:33:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xX2cS-0002wo-Q1; Fri, 27 Nov 2026 15:32:32 -0500 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 1xX2cJ-0002tz-Nv for qemu-devel@nongnu.org; Fri, 27 Nov 2026 15:32:23 -0500 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 1xX2cH-0002Xi-4f for qemu-devel@nongnu.org; Fri, 27 Nov 2026 15:32:23 -0500 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 6ARJAuiV3038749 for ; Fri, 27 Nov 2026 20:32:19 GMT Received: from mail-dl1-f72.google.com (mail-dl1-f72.google.com [74.125.82.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j7e4ngf4c-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 27 Nov 2026 20:32:19 +0000 (GMT) Received: by mail-dl1-f72.google.com with SMTP id a92af1059eb24-1b587ffea77so1551346c88.1 for ; Fri, 27 Nov 2026 12:32:19 -0800 (PST) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55681301asm59248021c88.8.2026.11.27.12.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2026 12:32:17 -0800 (PST) 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= gONCxHrhvvp5BSHmp7t+Ax3/Jt+o4/VyXQfDHM4EM7k=; b=WnFDS3JL3klLz/w7 q2JVGetvn0G2exGfq6gM6OvtQNAmdW0CLCW5pAd2oJeOncgmCB89SN/d2NfuSIl9 nQJgv6576bC6tFqRuPx3swCCd7LnPMKCUE88tsqxyWYgjA2HFiln4ZRROAh6QXSg rzFL2twBOmUgL1WGLQl7lAllFpEssqsx7uG1dqbo0Bfrunn80xvZ8qGbxpu/2pHE quymu2mG3QNnxBsRX6FxR4EJvg5dqJoxOV0BVcm253gvjoXOQxveSOr5+QmuLs2Q 6DUcQ+n2lM/E/Adf6DVPzKW6RrmT/Nl1yt3gnaP9A7PP29E14IHauTQTBehYJOJj v9mM4A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1795811539; x=1796416339; 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=gONCxHrhvvp5BSHmp7t+Ax3/Jt+o4/VyXQfDHM4EM7k=; b=QhMztPOdUtxQZY+9QHGKJeY9SMYMQ1eT72f/y3iinc8pZdhaz0eT1Xj5drOvLf7Roa kwUqxNPgJ2YpaO9mCXvMIqQ1yClkDjV6SfY7WnCHczc01DIDkDVHzMR0FWN66Vf71Ep3 E82x2Gv/9abPDmRzQq83ke/qNU5vXc6OFfDhU7YgxbeYpUSNyuyR2HAZBNYGs8dlHaQr DoZnzijFpeFEWI8Nr38tU2LaxiNx+rcXnxDlwKc/IUt+gCuxX1OU6JGbzBbcqKQuGbxL 4TaJttbsI3akSzURJISkPKfK90rb+a9FJKReeXOXN+DZ6kN9IXUui+tj4Rrl7ksBrZhI epfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795811539; x=1796416339; 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=gONCxHrhvvp5BSHmp7t+Ax3/Jt+o4/VyXQfDHM4EM7k=; b=HNX7FLlPW2pJPWuNPtV64qk5iPqYgNFhiS+6k3k9a4cKn0IAq+juT0XFr/wrxxRJMt DjewC0FUcZaP8aLfuvI+R4jqorlfg+GqMivJ1iHs8aPO+efpYAjKX9QgtiMorPjepuqG MPKEglk0h/vaUObHOK3tFu6Ogtt9ztmkuaE6jriLymFSupjvVkWZwcWTgV9ccN3QvGnT ZW3Ucvq9boOWJIHAg2Qmo7qICxFGkHSJGlu+DA+o9QorSy69U71Z1RVdzBhlnJGMbNe5 MZUu1TxMK0jiIhx1xjjXjGFk/M556ZI3tBCkyfDaJEssVz2FY3muSRUs1/igVI9TNZ82 j0Ew== X-Gm-Message-State: APuU4Z+ny3yznajiM8Lf+3rUvYcd232a2ZBvu83PnZZkTb2uVzp7JDGk SXNLr9gewly/3J+C5yMEH1SLofU/yMp7FwGgg0M8PbrbywrDMISbGKdWTDm4yHjVmRtK1OCgfs8 YMeSu8dA9NPq0dYBHcrr7vxRqDUebycQIytivMy/g+jQ4OfHIapDFIZUsQfqbaxZKBw== X-Gm-Gg: AZFdTZfvEB3IyurJ3TYYp/TEMw5vI5+Em+r0j3F2auGx6JIyc6GZkKurO+3X4rKVT+l yLpoF+kH0zFNpKR1b/I0olfLC2APtNUbq6xEu79uii6nykI3Q01K5V3TiL4cpDOK68iqedH7ZeF xPuQIWKSdM0plXtQYTVhghUKyMtQevvg0OjBb29aEK2QSEJYgA7Kkkpoe2eD8HsKTfUb94Wy3+7 hmT7Z/IOLjLPzh33e4o1syjTY8CiL6zhXhLrjGmSrfOXsrpnK5Qw/bvpbWxhrwgkfAinS9KFJn2 jYdM6hwgtdVY6hxko9Y7OLHJMfbPunTZ1eLEXAcrF3YmT/WyVVUKPqsY46g0EGQQor9moL0PhR5 +dMJuQ6zLGOIeF1zIKF5WDguasis/4dfJQj4AbgvsosrZVF/RXVxpxJN44XELDYEL4S/XlLNX27 xPSf5uXSYJo12WDQ3M3c7S X-Received: by 2002:a05:701a:ca09:b0:176:2095:1ac4 with SMTP id a92af1059eb24-1b5568cf673mr27904413c88.18.1795811538677; Fri, 27 Nov 2026 12:32:18 -0800 (PST) X-Received: by 2002:a05:701a:ca09:b0:176:2095:1ac4 with SMTP id a92af1059eb24-1b5568cf673mr27904374c88.18.1795811538051; Fri, 27 Nov 2026 12:32:18 -0800 (PST) From: Brian Cain To: qemu-devel@nongnu.org Cc: Helge Deller , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Pierrick Bouvier , Laurent Vivier , Ani Sinha , Brian Cain Subject: [PATCH for-12.0 v2 5/5] target/hexagon: dump vector and sys regs in cores Date: Fri, 27 Nov 2026 12:32:09 -0800 Message-Id: <20261127203209.42752-6-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261127203209.42752-1-brian.cain@oss.qualcomm.com> References: <20261127203209.42752-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-Info: AW1haW4tMjYxMTI3MDA4MSBTYWx0ZWRfXz3FhdAFdyEC/ JvhoYUHjQtO17GVG+6O5dYmrgPUuAEerkAjz9wl4kpQntL2pCWUQ7LfUX9/LagPN2FGHo9dpwRP c06ObxiMBpEskeFzrFawlEFgHkzdAgM= X-Proofpoint-GUID: 5dZ2y6MUbl939kHt-0_3ZWsBi7Af5yRt X-Authority-Analysis: v=2.4 cv=LPLz05W9 c=1 sm=1 tr=0 ts=6b09e8d3 cx=c_pps a=bS7HVuBVfinNPG3f6cIo3Q==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=wnNOno2Xp4cc5XV_n-gA:9 a=cvMpSqd6pES9QWsW:21 a=QEXdDO2ut3YA:10 a=vBUdepa8ALXHeOFLBtFW:22 X-Proofpoint-ORIG-GUID: 5dZ2y6MUbl939kHt-0_3ZWsBi7Af5yRt X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTI3MDA4MSBTYWx0ZWRfXxzSjV25DpT/q A2i4fES4i4NM44/1pUg5LG9SSUzeNtn1xC2ZAdwzB5kI8uNjaITN6L8EzUxJ5IMI3Ieo1MmSw9x V2CkJMLPERVUEcK6wPNuL2LqLWIZWXBU/mifxvbqqNauzsk/RYhsWIGQfG8jP+UvE7IhVn2iSR3 gbAHZ0DYFCK/vCoKIlp8/UGWC2e4gQFmq/RX40LwPqRSm5pRlq9u5Lcw69hZc0rr5AcRecjBS4g yKy32FoicT2gmhwvrh/oWmQ0KWduS6whm56MDZYX5yTO+tnWZ2wNDpuc9sBK9tVOtdnSgJjxQYp LmxugPu1Xb3RkbzuZNYWPR60Y7OLLdjAQsemrEFfw1hRZmRgMBJOfSQ9XF2Od0uHPPSXINqrbTX Kv3V2xdDeSgn/7/z6R7xrixQA5fAs4QKUYK9gQJmtXAsUJ3q3trSLCapwJTnu9W9KW7IMGKqVMQ l5OF+mPAMzEMo9w1omA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-27_04,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611270081 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: 1795811598624158500 Add the HVX/HLX and system states to the core file as notes. HMX has no architectural state that software can read directly, so it is omitted. The global registers and the TLB are the same for every thread. They are repeated in each thread's notes so that a thread's notes are self-contained. Reviewed-by: Helge Deller Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- linux-user/hexagon/target_elf.h | 1 + target/hexagon/core-dump.h | 16 +++ target/hexagon/cpu.h | 2 +- linux-user/hexagon/elfload.c | 10 ++ target/hexagon/arch_dump.c | 23 ++- target/hexagon/core_notes.c | 243 ++++++++++++++++++++++++++++++++ target/hexagon/cpu.c | 4 +- target/hexagon/meson.build | 1 + 8 files changed, 294 insertions(+), 6 deletions(-) create mode 100644 target/hexagon/core_notes.c diff --git a/linux-user/hexagon/target_elf.h b/linux-user/hexagon/target_el= f.h index daaec521a76..73d4c1e815f 100644 --- a/linux-user/hexagon/target_elf.h +++ b/linux-user/hexagon/target_elf.h @@ -26,6 +26,7 @@ #include "target/hexagon/core-dump.h" =20 #define HAVE_ELF_CORE_DUMP 1 +#define HAVE_ELF_CORE_EXTRA_NOTES 1 #define elf_core_eflags(info) ((info)->elf_flags) =20 typedef HexagonUserRegs target_elf_gregset_t; diff --git a/target/hexagon/core-dump.h b/target/hexagon/core-dump.h index a14b495d04d..b0f7bf38d5d 100644 --- a/target/hexagon/core-dump.h +++ b/target/hexagon/core-dump.h @@ -34,6 +34,22 @@ typedef struct target_elf_gregset_t { =20 QEMU_BUILD_BUG_ON(sizeof(HexagonUserRegs) !=3D 48 * sizeof(uint32_t)); =20 +#define HEXAGON_CORE_NOTE_OWNER "QEMU" +#define HEXAGON_CORE_NOTE_VERSION 1 + +enum { + HEXAGON_NT_CTRL =3D 0x100, + HEXAGON_NT_HVX =3D 0x101, + HEXAGON_NT_HLX =3D 0x102, + HEXAGON_NT_SYSREGS =3D 0x103, + HEXAGON_NT_THREAD =3D 0x104, + HEXAGON_NT_TLB =3D 0x105, +}; + +size_t hexagon_core_notes_size(const CPUHexagonState *env); + +void hexagon_core_fill_notes(void *buf, const CPUHexagonState *env); + static inline void hexagon_core_copy_regs(HexagonUserRegs *regs, const CPUHexagonState *env) { diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h index 5739254f1f6..074e46d2a96 100644 --- a/target/hexagon/cpu.h +++ b/target/hexagon/cpu.h @@ -283,7 +283,7 @@ G_NORETURN void hexagon_raise_exception_err(CPUHexagonS= tate *env, * not stopped. */ bool hexagon_thread_is_enabled(const CPUHexagonState *thread_env); -uint32_t hexagon_greg_read(CPUHexagonState *env, uint32_t reg); +uint32_t hexagon_greg_read(const CPUHexagonState *env, uint32_t reg); void hexagon_greg_write(CPUHexagonState *env, uint32_t reg, uint32_t val); void hexagon_cpu_soft_reset(CPUHexagonState *env); #endif diff --git a/linux-user/hexagon/elfload.c b/linux-user/hexagon/elfload.c index dac8260b302..46232bae5d7 100644 --- a/linux-user/hexagon/elfload.c +++ b/linux-user/hexagon/elfload.c @@ -11,6 +11,16 @@ void elf_core_copy_regs(target_elf_gregset_t *regs, cons= t CPUHexagonState *env) hexagon_core_copy_regs(regs, env); } =20 +size_t elf_core_extra_notes_size(const CPUHexagonState *env) +{ + return hexagon_core_notes_size(env); +} + +void elf_core_fill_extra_notes(void *buf, const CPUHexagonState *env) +{ + hexagon_core_fill_notes(buf, env); +} + abi_ulong get_elf_hwcap(CPUState *cs) { HexagonCPUClass *mcc =3D HEXAGON_CPU_GET_CLASS(cs); diff --git a/target/hexagon/arch_dump.c b/target/hexagon/arch_dump.c index c1b2892e2ad..50911503cd9 100644 --- a/target/hexagon/arch_dump.c +++ b/target/hexagon/arch_dump.c @@ -38,18 +38,29 @@ typedef struct HexagonElfNote { int hexagon_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, DumpState *s) { + CPUHexagonState *env =3D cpu_env(cs); HexagonElfNote note =3D { 0 }; HexagonUserRegs regs; + g_autofree void *extra =3D NULL; + size_t extra_size =3D hexagon_core_notes_size(env); + int ret; =20 note.header.n_namesz =3D cpu_to_dump32(s, sizeof("CORE")); note.header.n_descsz =3D cpu_to_dump32(s, sizeof(note.prstatus)); note.header.n_type =3D cpu_to_dump32(s, NT_PRSTATUS); memcpy(note.name, "CORE", sizeof("CORE")); note.prstatus.pr_pid =3D cpu_to_dump32(s, cpuid); - hexagon_core_copy_regs(®s, cpu_env(cs)); + hexagon_core_copy_regs(®s, env); memcpy(¬e.prstatus.pr_reg, ®s, sizeof(regs)); =20 - return f(¬e, sizeof(note), s); + ret =3D f(¬e, sizeof(note), s); + if (ret < 0) { + return ret; + } + + extra =3D g_malloc(extra_size); + hexagon_core_fill_notes(extra, env); + return f(extra, extra_size, s); } =20 void hexagon_get_dump_info(const CPUState *cs, ArchDumpInfo *info, @@ -67,7 +78,13 @@ void hexagon_get_dump_info(const CPUState *cs, ArchDumpI= nfo *info, size_t hexagon_get_note_size(const CPUState *cs, int class, int machine, int nr_cpus) { - return sizeof(HexagonElfNote) * nr_cpus; + CPUState *cpu; + size_t size =3D 0; + + CPU_FOREACH(cpu) { + size +=3D sizeof(HexagonElfNote) + hexagon_core_notes_size(cpu_env= (cpu)); + } + return size; } =20 static bool hexagon_mapping_overlaps(const MemoryMappingList *list, diff --git a/target/hexagon/core_notes.c b/target/hexagon/core_notes.c new file mode 100644 index 00000000000..848c2ed1ebe --- /dev/null +++ b/target/hexagon/core_notes.c @@ -0,0 +1,243 @@ +/* + * Hexagon ELF core dump notes owned by "QEMU". + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "hw/hexagon/hexagon_hlx.h" +#include "mmvec/mmvec_qfloat.h" +#ifndef CONFIG_USER_ONLY +#include "hw/hexagon/hexagon_globalreg.h" +#include "hw/hexagon/hexagon_tlb.h" +#include "cpu_helper.h" +#endif +#include "core-dump.h" + +typedef struct NoteCursor { + uint8_t *buf; /* NULL to only measure */ + size_t len; +} NoteCursor; + +typedef void (*NoteFill)(NoteCursor *c, const CPUHexagonState *env); + +static void put_bytes(NoteCursor *c, const void *data, size_t size) +{ + if (c->buf) { + memcpy(c->buf + c->len, data, size); + } + c->len +=3D size; +} + +static void put_zeros(NoteCursor *c, size_t size) +{ + if (c->buf) { + memset(c->buf + c->len, 0, size); + } + c->len +=3D size; +} + +static void put_u32(NoteCursor *c, uint32_t val) +{ + uint32_t le =3D cpu_to_le32(val); + + put_bytes(c, &le, sizeof(le)); +} + +static void put_u64(NoteCursor *c, uint64_t val) +{ + uint64_t le =3D cpu_to_le64(val); + + put_bytes(c, &le, sizeof(le)); +} + +static void put_note(NoteCursor *c, uint32_t type, NoteFill fill, + const CPUHexagonState *env) +{ + NoteCursor desc =3D { }; + + fill(&desc, env); + + put_u32(c, sizeof(HEXAGON_CORE_NOTE_OWNER)); + put_u32(c, desc.len); + put_u32(c, type); + put_bytes(c, HEXAGON_CORE_NOTE_OWNER, sizeof(HEXAGON_CORE_NOTE_OWNER)); + put_zeros(c, ROUND_UP(sizeof(HEXAGON_CORE_NOTE_OWNER), 4) - + sizeof(HEXAGON_CORE_NOTE_OWNER)); + fill(c, env); + put_zeros(c, ROUND_UP(desc.len, 4) - desc.len); +} + +/* + * Layout: version, FRAMELIMIT, FRAMEKEY, VFRAMELIMIT, VSP. + */ +static void fill_ctrl(NoteCursor *c, const CPUHexagonState *env) +{ + put_u32(c, HEXAGON_CORE_NOTE_VERSION); + put_u32(c, env->gpr[HEX_REG_FRAMELIMIT]); + put_u32(c, env->gpr[HEX_REG_FRAMEKEY]); + put_u32(c, env->gpr[HEX_REG_VFRAMELIMIT]); + put_u32(c, env->gpr[HEX_REG_VSP]); +} + +static const HexagonHVXContext *note_hvx_ctx(const CPUHexagonState *env) +{ +#ifdef CONFIG_USER_ONLY + return &env->hvx_ctx; +#else + return env->hvx; +#endif +} + +/* + * Layout: version, vlen (the size of a vector register in bytes), nvregs, + * nqregs and ext, then the nvregs vector registers, then the nqregs predi= cate + * registers of vlen / 8 bytes each. If ext is 1, which it is where qfloat + * has extension bits, V79 and later, the vlen / 4 bytes of extension bits= of + * each vector register follow. + */ +static void fill_hvx(NoteCursor *c, const CPUHexagonState *env) +{ + const HexagonHVXContext *hvx =3D note_hvx_ctx(env); + + put_u32(c, HEXAGON_CORE_NOTE_VERSION); + put_u32(c, sizeof_field(MMVector, ub)); + put_u32(c, NUM_VREGS); + put_u32(c, NUM_QREGS); + put_u32(c, qfloat_is_extended(env)); + + for (int i =3D 0; i < NUM_VREGS; i++) { + for (int j =3D 0; j < ARRAY_SIZE(hvx->VRegs[i].ud); j++) { + put_u64(c, hvx->VRegs[i].ud[j]); + } + } + for (int i =3D 0; i < NUM_QREGS; i++) { + for (int j =3D 0; j < ARRAY_SIZE(hvx->QRegs[i].ud); j++) { + put_u64(c, hvx->QRegs[i].ud[j]); + } + } + if (qfloat_is_extended(env)) { + for (int i =3D 0; i < NUM_VREGS; i++) { + put_bytes(c, hvx->VRegs[i].ext, sizeof(hvx->VRegs[i].ext)); + } + } +} + +/* + * Layout: version, vlen (the size of an HLX register in bytes), nlregs and + * zero, then the nlregs registers. + */ +static void fill_hlx(NoteCursor *c, const CPUHexagonState *env) +{ + const HexagonHLXContext *hlx =3D env->hlx_ctx; + + put_u32(c, HEXAGON_CORE_NOTE_VERSION); + put_u32(c, HLX_VEC_SIZE_BYTES); + put_u32(c, NUM_LREGS); + put_u32(c, 0); + + for (int i =3D 0; i < NUM_LREGS; i++) { + for (int j =3D 0; j < ARRAY_SIZE(hlx->LRegs[i].ud); j++) { + put_u64(c, hlx->LRegs[i].ud[j]); + } + } +} + +#ifndef CONFIG_USER_ONLY +/* + * Layout: version, nsregs, ngregs and zero, then the nsregs system regist= ers + * by register number, with the thread's own ones below HEX_SREG_GLB_START + * and the global ones from there on, then the ngregs guest registers. + */ +static void fill_sysregs(NoteCursor *c, const CPUHexagonState *env) +{ + const HexagonCPU *cpu =3D env_archcpu(env); + + put_u32(c, HEXAGON_CORE_NOTE_VERSION); + put_u32(c, NUM_SREGS); + put_u32(c, NUM_GREGS); + put_u32(c, 0); + + for (int i =3D 0; i < NUM_SREGS; i++) { + if (i < HEX_SREG_GLB_START) { + put_u32(c, env->t_sreg[i]); + } else { + put_u32(c, cpu->globalregs ? + hexagon_globalreg_read(cpu->globalregs, i, + env->threadId) : 0); + } + } + for (int i =3D 0; i < NUM_GREGS; i++) { + put_u32(c, hexagon_greg_read(env, i)); + } +} + +/* + * Layout: version, the thread number, the CPU mode (HEX_CPU_MODE_*), the = TLB + * lock state and count, and the K0 lock state and count. + */ +static void fill_thread(NoteCursor *c, const CPUHexagonState *env) +{ + put_u32(c, HEXAGON_CORE_NOTE_VERSION); + put_u32(c, env->threadId); + put_u32(c, get_cpu_mode(env)); + put_u32(c, env->tlb_lock_state); + put_u32(c, env->tlb_lock_count); + put_u32(c, env->k0_lock_state); + put_u32(c, env->k0_lock_count); +} + +/* + * Layout: version, the number of entries and two zeroes, then the entries= as + * the 64-bit values that tlbw takes. + */ +static void fill_tlb(NoteCursor *c, const CPUHexagonState *env) +{ + HexagonTLBState *tlb =3D env_archcpu(env)->tlb; + uint32_t num_entries =3D hexagon_tlb_get_num_entries(tlb); + + put_u32(c, HEXAGON_CORE_NOTE_VERSION); + put_u32(c, num_entries); + put_u32(c, 0); + put_u32(c, 0); + + for (uint32_t i =3D 0; i < num_entries; i++) { + put_u64(c, hexagon_tlb_read(tlb, i)); + } +} +#endif + +static void put_all_notes(NoteCursor *c, const CPUHexagonState *env) +{ + const HexagonCPU *cpu =3D env_archcpu(env); + + put_note(c, HEXAGON_NT_CTRL, fill_ctrl, env); + if (note_hvx_ctx(env) && cpu->cfg.hex_def->hex_version >=3D HEX_VER_V6= 0) { + put_note(c, HEXAGON_NT_HVX, fill_hvx, env); + } + if (env->hlx_ctx && cpu->cfg.hex_def->hex_version >=3D HEX_VER_V85) { + put_note(c, HEXAGON_NT_HLX, fill_hlx, env); + } +#ifndef CONFIG_USER_ONLY + put_note(c, HEXAGON_NT_SYSREGS, fill_sysregs, env); + put_note(c, HEXAGON_NT_THREAD, fill_thread, env); + put_note(c, HEXAGON_NT_TLB, fill_tlb, env); +#endif +} + +size_t hexagon_core_notes_size(const CPUHexagonState *env) +{ + NoteCursor c =3D { }; + + put_all_notes(&c, env); + return c.len; +} + +void hexagon_core_fill_notes(void *buf, const CPUHexagonState *env) +{ + NoteCursor c =3D { .buf =3D buf }; + + put_all_notes(&c, env); +} diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 5f7f22fa2ea..a9e3f93c3c9 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -990,11 +990,11 @@ static void hexagon_cpu_class_init(ObjectClass *c, co= nst void *data) } =20 #ifndef CONFIG_USER_ONLY -uint32_t hexagon_greg_read(CPUHexagonState *env, uint32_t reg) +uint32_t hexagon_greg_read(const CPUHexagonState *env, uint32_t reg) { uint32_t ssr =3D env->t_sreg[HEX_SREG_SSR]; int ssr_ce =3D GET_SSR_FIELD(SSR_CE, ssr); - HexagonCPU *cpu =3D env_archcpu(env); + const HexagonCPU *cpu =3D env_archcpu(env); =20 if (reg <=3D HEX_GREG_G3) { return env->greg[reg]; diff --git a/target/hexagon/meson.build b/target/hexagon/meson.build index b9b2a2d9740..23fa3f65fdb 100644 --- a/target/hexagon/meson.build +++ b/target/hexagon/meson.build @@ -292,6 +292,7 @@ hexagon_softmmu_ss =3D ss.source_set() =20 hexagon_ss.add(files( 'cpu.c', + 'core_notes.c', 'translate.c', 'op_helper.c', 'gdbstub.c', --=20 2.34.1