From nobody Wed Aug 26 13:54:00 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=linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; t=1785920838; cv=none; d=zohomail.com; s=zohoarc; b=QJ8s3S1vsX+Q37uG9ihzTyw0s2Xw77WYp/hu4yZtS+W2spD0Wet6d8zQ6gmQn6954sj3JpwYRJrbOjAlfAsAPYlqR5FQqG/17CnDBkvFf1V7OstXwj6Pon53oY3Nr44Eb18I9VZcO3H0IMnuJHM3/Mg1ciF9IcyMXPtWFR1vuBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785920838; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=i3irOm36/GdNF6XT8lXmJNv2qzdNmtgc69ELqnMSTQY=; b=Hy8kQmMIuIAZoCyBxnWzhInYo2swg46mMnP10bCD/S6mQEHo8v0PmS71yTCQ1yFFh7fuluNmPSPH7IxpN4OLLub0fyd0KEwWRl7xXO8E1/+h9TA6qei0Rvn2fGL0zbGAowPJ9we51Q/DH8MzBC8kDRFN5+Q3MZ2WH/qWo+9ncMU= 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 178592083848560.980686109216094; Wed, 5 Aug 2026 02:07:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrXaU-0008U1-Hu; Wed, 05 Aug 2026 05:06:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrXaQ-0008Ir-CN for qemu-devel@nongnu.org; Wed, 05 Aug 2026 05:06:55 -0400 Received: from [115.124.30.97] (helo=out30-97.freemail.mail.aliyun.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrXaI-0007zS-IO for qemu-devel@nongnu.org; Wed, 05 Aug 2026 05:06:54 -0400 Received: from U-92DF4J33-2338.local(mailfrom:zhengrong_li@linux.alibaba.com fp:SMTPD_---0X8QltOa_1785920782 cluster:ay36) by smtp.aliyun-inc.com; Wed, 05 Aug 2026 17:06:27 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1785920790; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; bh=i3irOm36/GdNF6XT8lXmJNv2qzdNmtgc69ELqnMSTQY=; b=AoKgHmywi4vojoRdvB5QCPoDN1XS/YVU23bBiw5tsWFlKT5YVRNoejdiWt3b4ELS6xa7jPlbVmiQRtP0jESll7Dl6bKb76IzEX87mJEXNGWdn74IVPuj7lBzg9jySyThPRb1e3Vc5H0UzMBMDI0URmNQJQZtbw3gMopTtg2e2wI= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R141e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033032089153; MF=zhengrong_li@linux.alibaba.com; NM=1; PH=DS; RN=4; SR=0; TI=SMTPD_---0X8QltOa_1785920782; From: Zhengrong Li To: qemu-devel@nongnu.org Cc: akihiko.odaki@daynix.com, viktor.prutyanov@phystech.edu, zhengrong_li@linux.alibaba.com Subject: [PATCH v2 1/3] runstate: set crash_occurred on guest crashloaded Date: Wed, 05 Aug 2026 17:05:58 +0800 Message-ID: <178592075881.15274.581512283969292515@linux.alibaba.com> In-Reply-To: <178592075881.15274.7510279315190894277@linux.alibaba.com> References: <178592075881.15274.7510279315190894277@linux.alibaba.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 115.124.30.97 (deferred) 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=115.124.30.97; envelope-from=zhengrong_li@linux.alibaba.com; helo=out30-97.freemail.mail.aliyun.com X-Spam_score_int: -166 X-Spam_score: -16.7 X-Spam_bar: ---------------- X-Spam_report: (-16.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=no 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 @linux.alibaba.com) X-ZM-MESSAGEID: 1785920840284158500 Windows pvpanic driver writes PVPANIC_CRASH_LOADED (bit 1) on bugcheck, not PVPANIC_PANICKED (bit 0). As a result, qemu_system_guest_panicked() is never called and crash_occurred stays false for Windows guests. Set crash_occurred in qemu_system_guest_crashloaded() as well, so the faulting CPU can be identified in the guest dump. Signed-off-by: Zhengrong Li --- system/runstate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/system/runstate.c b/system/runstate.c index 08acf801b0..c7961cc1df 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -724,6 +724,11 @@ void qemu_system_guest_panicked(GuestPanicInformation = *info) void qemu_system_guest_crashloaded(GuestPanicInformation *info) { qemu_log_mask(LOG_GUEST_ERROR, "Guest crash loaded"); + + if (current_cpu) { + current_cpu->crash_occurred =3D true; + } + qapi_event_send_guest_crashloaded(GUEST_PANIC_ACTION_RUN, info); qapi_free_GuestPanicInformation(info); } --=20 2.43.0 From nobody Wed Aug 26 13:54:00 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=linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; t=1785920827; cv=none; d=zohomail.com; s=zohoarc; b=jdDNdPRVIMJTUKLzhV4Fn52Q8LDbBYEQ+CZPTpT1cBwRGbuF90vt7MdnYFxs+OXG85G+BZhJNjSM4K3jYihruaJKgsjxUT/4nNbq7+8bkpzQ6nCUWfaO1L2J/H1BXom6wFQ0bToO6IqaWwel1yXLn5DWTMuaa6Syo+Lq4aVgfnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785920827; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sygwba2kjAC5Ez7zrabINvDmdl0Q24z0iBwvz7PqhoI=; b=B1gLE8OhxDI7m9ZUXv+6RwL2J6RPtHC5ESJ7zIv4yIVAvtIdv1E1rlOeM2CPm2AvALTl+tw1tQGjdsVsFtrNvqz5VVnMv/r6Z6aCGktYPGkAzdQguBLRVvVWmLPmPTVJukBuR4QCfLUW0wB7QRIJWWcJHzgN8kfIVkR2Ph3imOg= 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 1785920827012679.0341837579348; Wed, 5 Aug 2026 02:07:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrXaS-0008IG-2a; Wed, 05 Aug 2026 05:06:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrXaO-0008Dc-4m for qemu-devel@nongnu.org; Wed, 05 Aug 2026 05:06:52 -0400 Received: from [115.124.30.99] (helo=out30-99.freemail.mail.aliyun.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrXaJ-0007zx-7f for qemu-devel@nongnu.org; Wed, 05 Aug 2026 05:06:51 -0400 Received: from U-92DF4J33-2338.local(mailfrom:zhengrong_li@linux.alibaba.com fp:SMTPD_---0X8Qnhnk_1785920788 cluster:ay36) by smtp.aliyun-inc.com; Wed, 05 Aug 2026 17:06:33 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1785920794; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; bh=sygwba2kjAC5Ez7zrabINvDmdl0Q24z0iBwvz7PqhoI=; b=QAu048KZbswb/VVahFfTjxvxGgegr8uPAUNGQlc3+0oGM4zmZywKLr7U3XESZZ2/cI0I+YpIy+61ongzwOp1AU3dK1/0W5BmVUK4L3dnfqRwmpUtUNEZ/7DV5qwPpT3WJBbDGuzD3oAH+Z/usHUoYdgEVDUTf2gD8mXirk7xyRY= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R101e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033037026112; MF=zhengrong_li@linux.alibaba.com; NM=1; PH=DS; RN=4; SR=0; TI=SMTPD_---0X8Qnhnk_1785920788; From: Zhengrong Li To: qemu-devel@nongnu.org Cc: akihiko.odaki@daynix.com, viktor.prutyanov@phystech.edu, zhengrong_li@linux.alibaba.com Subject: [PATCH v2 2/3] dump: add crash_occurred flag to QEMUCPUState Date: Wed, 05 Aug 2026 17:05:58 +0800 Message-ID: <178592075881.15274.5708870107372539268@linux.alibaba.com> In-Reply-To: <178592075881.15274.7510279315190894277@linux.alibaba.com> References: <178592075881.15274.7510279315190894277@linux.alibaba.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 115.124.30.99 (deferred) 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=115.124.30.99; envelope-from=zhengrong_li@linux.alibaba.com; helo=out30-99.freemail.mail.aliyun.com X-Spam_score_int: -166 X-Spam_score: -16.7 X-Spam_bar: ---------------- X-Spam_report: (-16.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=no 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 @linux.alibaba.com) X-ZM-MESSAGEID: 1785920828233158500 Add is_crash_occurred_cpu field to QEMUCPUState so that dump-guest-memory can record which CPU triggered the guest panic. The new field is appended after kernel_gs_base, so existing tools that check the 'size' field can safely ignore it when reading older dumps. Changes since v1: - Revert QEMUCPUSTATE_VERSION bump (not needed, tools check size) - Move crash_occurred check outside #ifdef TARGET_X86_64 to fix -Werror=3Dunused-variable on i386 builds (reported by Akihiko Odaki) - Use linux.alibaba.com identity Signed-off-by: Zhengrong Li --- contrib/elf2dmp/qemu_elf.h | 2 ++ target/i386/arch_dump.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/contrib/elf2dmp/qemu_elf.h b/contrib/elf2dmp/qemu_elf.h index adc50238b4..3b28332e67 100644 --- a/contrib/elf2dmp/qemu_elf.h +++ b/contrib/elf2dmp/qemu_elf.h @@ -27,6 +27,8 @@ typedef struct QEMUCPUState { QEMUCPUSegment ldt, tr, gdt, idt; uint64_t cr[5]; uint64_t kernel_gs_base; + uint8_t is_crash_occurred_cpu; + uint8_t pad[7]; } QEMUCPUState; =20 int is_system(QEMUCPUState *s); diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c index 16e47c4747..8ce2c7e9bb 100644 --- a/target/i386/arch_dump.c +++ b/target/i386/arch_dump.c @@ -264,6 +264,8 @@ struct QEMUCPUState { * by checking 'size' field. */ uint64_t kernel_gs_base; + uint8_t is_crash_occurred_cpu; + uint8_t pad[7]; }; =20 typedef struct QEMUCPUState QEMUCPUState; @@ -279,6 +281,7 @@ static void copy_segment(QEMUCPUSegment *d, SegmentCach= e *s) =20 static void qemu_get_cpustate(QEMUCPUState *s, CPUX86State *env) { + CPUState *cs =3D env_cpu(env); memset(s, 0, sizeof(QEMUCPUState)); =20 s->version =3D QEMUCPUSTATE_VERSION; @@ -325,6 +328,9 @@ static void qemu_get_cpustate(QEMUCPUState *s, CPUX86St= ate *env) #ifdef TARGET_X86_64 s->kernel_gs_base =3D env->kernelgsbase; #endif + if (cs->crash_occurred) { + s->is_crash_occurred_cpu =3D 1; + } } =20 static inline int cpu_write_qemu_note(WriteCoreDumpFunction f, --=20 2.43.0 From nobody Wed Aug 26 13:54:00 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=linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; t=1785920833; cv=none; d=zohomail.com; s=zohoarc; b=M0stu1W3DS01t/2Dxa08tjOdX1OQqHRgf98JhrgUeauZe75uI1H54rdDZW+nHXymtl39962foDRa2uIZeO0sw6LONhgmypLSyDtyAL7QgS6jaY+8tfns+1NvsHj5ZVKAbnM7aw0NLKrIhOHtyMtQ9bC0QDqEKe7hZddkp6oYUcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785920833; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EaGp4W9RKlGFYKTpx8qq8KToNffaBaFnv14evpAAG4A=; b=dDu3jfPvow9rNzuU+JRRtbsISKjB4fIlOh+B5VtDuzGk/sv322rq7B2OeaX6kowzPZwS3Idf+KbxbJhsAvm4nwlSI/GrIOUyZ5Lz3KB5Ivk+WBkJs9jV6eBXbrqLKelliGtdka0ISyc4bDNhQdbsA1WDWRfvV/e28HZtpoNnmL4= 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 1785920833326450.92970691422204; Wed, 5 Aug 2026 02:07:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrXaT-0008QY-Jf; Wed, 05 Aug 2026 05:06:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrXaQ-0008Io-6Q for qemu-devel@nongnu.org; Wed, 05 Aug 2026 05:06:55 -0400 Received: from [115.124.30.113] (helo=out30-113.freemail.mail.aliyun.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wrXaM-000817-GY for qemu-devel@nongnu.org; Wed, 05 Aug 2026 05:06:53 -0400 Received: from U-92DF4J33-2338.local(mailfrom:zhengrong_li@linux.alibaba.com fp:SMTPD_---0X8QltRq_1785920794 cluster:ay36) by smtp.aliyun-inc.com; Wed, 05 Aug 2026 17:06:39 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1785920800; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; bh=EaGp4W9RKlGFYKTpx8qq8KToNffaBaFnv14evpAAG4A=; b=nGznCX1vLVrM+lhSdfmUsIErthKxi0/RJXHbeKwqr1/iMXiZcaBwv3f/ww9QQJqdbB5gvT8iteqRwtgVSzeExTUY6Wk+pFye41xokEkpilHFo5sq9ATlYzIbDHTSOm+hx+olKqySuHe9g82yOXTrEyXnU56Vofo1f5bQdKo6lxQ= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R111e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033045098064; MF=zhengrong_li@linux.alibaba.com; NM=1; PH=DS; RN=4; SR=0; TI=SMTPD_---0X8QltRq_1785920794; From: Zhengrong Li To: qemu-devel@nongnu.org Cc: akihiko.odaki@daynix.com, viktor.prutyanov@phystech.edu, zhengrong_li@linux.alibaba.com Subject: [PATCH v2 3/3] elf2dmp: fill ContextBuffer with faulting CPU context Date: Wed, 05 Aug 2026 17:05:58 +0800 Message-ID: <178592075881.15274.12721897603002325817@linux.alibaba.com> In-Reply-To: <178592075881.15274.7510279315190894277@linux.alibaba.com> References: <178592075881.15274.7510279315190894277@linux.alibaba.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 115.124.30.113 (deferred) 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=115.124.30.113; envelope-from=zhengrong_li@linux.alibaba.com; helo=out30-113.freemail.mail.aliyun.com X-Spam_score_int: -166 X-Spam_score: -16.7 X-Spam_bar: ---------------- X-Spam_report: (-16.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=no 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 @linux.alibaba.com) X-ZM-MESSAGEID: 1785920834368158500 When is_crash_occurred_cpu is set in QEMUCPUState, copy that CPU's context into WinDumpHeader64 ContextBuffer so WinDbg opens on the faulting CPU instead of CPU 0. Also extract KiBugCheckData from the guest kernel to populate BugcheckCode and BugcheckParameters in the dump header. Changes since v1: - Add size-based field detection in init_states() for forward compatibili= ty - Use has_is_crash_occurred_cpu flag instead of version check - Set header context before best-effort guest memory operations to avoid losing faulting CPU context on partial dump failures - Use LIVE_SYSTEM_DUMP when BugcheckCode is zero - Use PRIx32 for BugcheckCode format specifier - Use linux.alibaba.com identity Signed-off-by: Zhengrong Li --- contrib/elf2dmp/kdbg.h | 9 +++++++ contrib/elf2dmp/main.c | 50 ++++++++++++++++++++++++++++++++++++-- contrib/elf2dmp/qemu_elf.c | 20 +++++++++------ contrib/elf2dmp/qemu_elf.h | 1 + 4 files changed, 71 insertions(+), 9 deletions(-) diff --git a/contrib/elf2dmp/kdbg.h b/contrib/elf2dmp/kdbg.h index 002e3d0cd5..15e4fb1140 100644 --- a/contrib/elf2dmp/kdbg.h +++ b/contrib/elf2dmp/kdbg.h @@ -195,4 +195,13 @@ typedef struct KDDEBUGGER_DATA64 { uint16_t OffsetPrcbContext; } KDDEBUGGER_DATA64; =20 +typedef struct KIBUGCHECK_INFO { + uint32_t BugcheckCode; + uint32_t unused0; + uint64_t BugcheckParameter1; + uint64_t BugcheckParameter2; + uint64_t BugcheckParameter3; + uint64_t BugcheckParameter4; +} KIBUGCHECK_INFO; + #endif /* KDBG_H */ diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c index a62abadcc0..59ffc0f2e8 100644 --- a/contrib/elf2dmp/main.c +++ b/contrib/elf2dmp/main.c @@ -338,11 +338,26 @@ static bool fill_header(WinDumpHeader64 *hdr, struct = pa_space *ps, * A dump may still contain valuable information even if it lacks contexts= of * some CPUs due to dump corruption or a failure before starting CPUs. */ -static void fill_context(KDDEBUGGER_DATA64 *kdbg, +static void fill_context(WinDumpHeader64 *hdr, KDDEBUGGER_DATA64 *kdbg, struct va_space *vs, QEMU_Elf *qe) { int i; + int fault_cpu =3D -1; =20 + /* First pass: identify faulting CPU and set header context early */ + for (i =3D 0; i < qe->state_nr; i++) { + QEMUCPUState *s =3D qe->state[i]; + if (qe->has_is_crash_occurred_cpu && s->is_crash_occurred_cpu) { + WinContext64 ctx; + win_context_init_from_qemu_cpu_state(&ctx, s); + memcpy(hdr->ContextBuffer, &ctx, sizeof(ctx)); + fault_cpu =3D i; + printf("Faulting CPU identified: #%d\n", i); + break; + } + } + + /* Second pass: fill context for all CPUs (best-effort) */ for (i =3D 0; i < qe->state_nr; i++) { uint64_t Prcb; uint64_t Context; @@ -512,6 +527,7 @@ int main(int argc, char *argv[]) uint64_t KdVersionBlock; bool kernel_found =3D false; OMFSignatureRSDS rsds; + uint64_t KiBugCheckData; =20 if (argc !=3D 3) { eprintf("usage:\n\t%s elf_file dmp_file\n", argv[0]); @@ -611,7 +627,37 @@ int main(int argc, char *argv[]) goto out_kdbg; } =20 - fill_context(kdbg, &vs, &qemu_elf); + if (!SYM_RESOLVE(KernBase, &pdb, KiBugCheckData)) { + eprintf("Failed to get KiBugCheckData.\n"); + } else { + KIBUGCHECK_INFO data =3D { 0 }; + if (va_space_rw(&vs, KiBugCheckData, &data, sizeof(data), 0)) { + header.BugcheckCode =3D data.BugcheckCode; + header.BugcheckParameter1 =3D data.BugcheckParameter1; + header.BugcheckParameter2 =3D data.BugcheckParameter2; + header.BugcheckParameter3 =3D data.BugcheckParameter3; + header.BugcheckParameter4 =3D data.BugcheckParameter4; + + /* + * If BugcheckCode wasn't saved, we consider guest OS as alive. + */ + if (!header.BugcheckCode) { + header.BugcheckCode =3D LIVE_SYSTEM_DUMP; + } + + printf("KiBugCheckData: 0x%016" PRIx64 + ", BugcheckCode: 0x%08" PRIx32 ", Args:" + " 0x%016" PRIx64 " 0x%016" PRIx64 + " 0x%016" PRIx64 " 0x%016" PRIx64 "\n", + KiBugCheckData, header.BugcheckCode, + data.BugcheckParameter1, data.BugcheckParameter2, + data.BugcheckParameter3, data.BugcheckParameter4); + } else { + eprintf("Failed to va_space_rw KiBugCheckData.\n"); + } + } + + fill_context(&header, kdbg, &vs, &qemu_elf); =20 if (!write_dump(&ps, &header, argv[2])) { eprintf("Failed to save dump\n"); diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c index c9bad6e82c..8eb2654356 100644 --- a/contrib/elf2dmp/qemu_elf.c +++ b/contrib/elf2dmp/qemu_elf.c @@ -71,7 +71,8 @@ static bool init_states(QEMU_Elf *qe) return false; } =20 - qe->has_kernel_gs_base =3D 1; + qe->has_kernel_gs_base =3D 0; + qe->has_is_crash_occurred_cpu =3D 0; offset =3D phdr[0].p_offset; states =3D g_ptr_array_new(); =20 @@ -103,14 +104,19 @@ static bool init_states(QEMU_Elf *qe) nhdr->n_descsz >=3D offsetof(QEMUCPUState, kernel_gs_base)) { state_size =3D MIN(state->size, nhdr->n_descsz); =20 - if (state_size < sizeof(*state)) { + if (state_size >=3D offsetof(QEMUCPUState, kernel_gs_base) + + sizeof(state->kernel_gs_base)) { + qe->has_kernel_gs_base =3D 1; + } + + if (state_size >=3D offsetof(QEMUCPUState, is_crash_occurred_c= pu) + + sizeof(state->is_crash_occurred_cpu)) { + qe->has_is_crash_occurred_cpu =3D 1; + } + + if (state_size !=3D sizeof(*state)) { eprintf("CPU #%u: QEMU CPU state size %u doesn't match\n", states->len, state_size); - /* - * We assume either every QEMU CPU state has KERNEL_GS_BAS= E or - * no one has. - */ - qe->has_kernel_gs_base =3D 0; } g_ptr_array_add(states, state); } diff --git a/contrib/elf2dmp/qemu_elf.h b/contrib/elf2dmp/qemu_elf.h index 3b28332e67..120de4a2f4 100644 --- a/contrib/elf2dmp/qemu_elf.h +++ b/contrib/elf2dmp/qemu_elf.h @@ -42,6 +42,7 @@ typedef struct QEMU_Elf { QEMUCPUState **state; size_t state_nr; int has_kernel_gs_base; + int has_is_crash_occurred_cpu; } QEMU_Elf; =20 bool QEMU_Elf_init(QEMU_Elf *qe, const char *filename); --=20 2.43.0