From nobody Mon Sep 28 01:13:03 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=1785997324; cv=none; d=zohomail.com; s=zohoarc; b=jDTYYY6QWFg0Wd781kIG9seDulSyH680UGI0ZV3mxU0x7GuxkBiUkdFSXiSsdojJmQ6FqbY6iUzXosrEUw1r6DNpn3KiV4i5u3ugSKXv/CkBcLumAH8MGr+5MY8lNrPmee1xdgiwmLbSjmJz0sPtO6Vz0qojngJgyg1K9UFaODw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785997324; 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=aVrtlsA7Jg/Ha9/qbJG0kFJ5A7fFXUivVpxYdndNPFs=; b=mpTmJQozypHoJ9ZpO9MxZzPbWQrxEo6n3U+odUYqzHBLLo9JrCjqrkrMllNmqzhNDNSIm/qiVfO07QMVMpeqpfkPDtTdLAk9KEbSvnKorCBdqYBeE1IMuhtkAes9uvzNBYasr9NcSzSUuze0mtzI/973kF6PxpFTm3nGOPefu8c= 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 1785997324731708.543649543079; Wed, 5 Aug 2026 23:22:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrrU6-0005Er-Ks; Thu, 06 Aug 2026 02:21:42 -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 1wrrU4-0005EJ-4D for qemu-devel@nongnu.org; Thu, 06 Aug 2026 02:21:40 -0400 Received: from [115.124.30.101] (helo=out30-101.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 1wrrU0-00007Y-Gt for qemu-devel@nongnu.org; Thu, 06 Aug 2026 02:21:39 -0400 Received: from U-92DF4J33-2338.local(mailfrom:zhengrong_li@linux.alibaba.com fp:SMTPD_---0X8T272f_1785997275 cluster:ay36) by smtp.aliyun-inc.com; Thu, 06 Aug 2026 14:21:21 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1785997281; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; bh=aVrtlsA7Jg/Ha9/qbJG0kFJ5A7fFXUivVpxYdndNPFs=; b=jbdto/FgOijlPpjvhEyGS7QMDrn4Pqoq0voYd1j2PAN4b6Y+2dPbf0yTQTy9ZiYCKgeayLFVOE2uxcH+1/ID0VEiDDQ2F4BuItsbINof7AMGcrX5dOD/YezKT+RBzMfbFSjtU6Fp5iEC5R/rtvzrRe9tP8UVQACfo6A+0JCRHw0= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R501e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam011083073210; MF=zhengrong_li@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0X8T272f_1785997275; From: Zhengrong Li To: qemu-devel@nongnu.org Cc: akihiko.odaki@gmail.com, philmd@qualcomm.com, pbonzini@redhat.com, viktor.prutyanov@phystech.edu, zhengrong_li@linux.alibaba.com Subject: [PATCH v3 1/3] runstate: set crash_occurred on guest crashloaded Date: Thu, 06 Aug 2026 14:20:59 +0800 Message-ID: <178599725914.10029.16439793637263128090@linux.alibaba.com> In-Reply-To: <178599725914.10029.4441302124415593392@linux.alibaba.com> References: <178599725914.10029.4441302124415593392@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.101 (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.101; envelope-from=zhengrong_li@linux.alibaba.com; helo=out30-101.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: 1785997326541158500 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 Mon Sep 28 01:13:03 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=1785997322; cv=none; d=zohomail.com; s=zohoarc; b=M4TvKhQ6J2DjSop3CCDsXGc4Ymht2pUGKGxm16N8Z4LFQOdchgeEnYZhNGIb6D3bgcM1VTMA6F8pNIdnItJxwWl0K/+RSHVFYV0YeyOjY+BPMO6yh+hD9uNuzc7peSOloRiMHC2nHckJuXqQAKOuVS+fOGodCoGn3X2LAIsA/aI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785997322; 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=386a66FsBwzQIFv2juxm9COckIHSiZZFZ+5xqyObths=; b=c7rXrM0SH/XWOXQK3G/5ott/+pMr/RqfMtIVrPcSVQrArZWCE6PMNlY93v0Z9hVpP5BXo0vU+GFYYEv2sazV4c6BJVA6xiva6LjDYsU55NWGha/8tKt6bIrFHVlSzngTOvpV6um31jAxxDpz8g1mrmWAP5pUC5Km4I09phIuGb8= 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 178599732242011.961757324658493; Wed, 5 Aug 2026 23:22:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrrU8-0005FX-DA; Thu, 06 Aug 2026 02:21:44 -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 1wrrU6-0005Ev-Ge for qemu-devel@nongnu.org; Thu, 06 Aug 2026 02:21:42 -0400 Received: from [115.124.30.112] (helo=out30-112.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 1wrrU3-00008u-LM for qemu-devel@nongnu.org; Thu, 06 Aug 2026 02:21:42 -0400 Received: from U-92DF4J33-2338.local(mailfrom:zhengrong_li@linux.alibaba.com fp:SMTPD_---0X8T274Y_1785997281 cluster:ay36) by smtp.aliyun-inc.com; Thu, 06 Aug 2026 14:21:27 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1785997287; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; bh=386a66FsBwzQIFv2juxm9COckIHSiZZFZ+5xqyObths=; b=Ur1jtcktZKrGaT+q14yoSYO1GMO5T4J3TU8YacFxWmMBQeWRp5ExNdwoElkNdxPoBKTu2vHFs3gYYM8cl/eyFu7D4UaA/Z73MSEeMqlEhgq1lyi7elL699GfuB3DCuPFBs47XrSmk5zPFpfp8C8iLifx/TPY94bs1L2IuYChhpg= 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=6; SR=0; TI=SMTPD_---0X8T274Y_1785997281; From: Zhengrong Li To: qemu-devel@nongnu.org Cc: akihiko.odaki@gmail.com, philmd@qualcomm.com, pbonzini@redhat.com, viktor.prutyanov@phystech.edu, zhengrong_li@linux.alibaba.com Subject: [PATCH v3 2/3] dump: add crash_occurred flag to QEMUCPUState Date: Thu, 06 Aug 2026 14:20:59 +0800 Message-ID: <178599725914.10029.14279751262185488168@linux.alibaba.com> In-Reply-To: <178599725914.10029.4441302124415593392@linux.alibaba.com> References: <178599725914.10029.4441302124415593392@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.112 (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.112; envelope-from=zhengrong_li@linux.alibaba.com; helo=out30-112.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: 1785997324880158500 Add is_crash_occurred_cpu field to QEMUCPUState so that dump-guest-memory can record which CPU triggered the guest panic. Bump QEMUCPUSTATE_VERSION to 2. 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. 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 Mon Sep 28 01:13:03 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=1785997326; cv=none; d=zohomail.com; s=zohoarc; b=NiiQIjJ7NokmY9c0ydOggjgRCsxA0bBoPv1nx2P2UvjG+kP6h+s0ZqHd8/KBKY7BD06Xs5vi8yNLi/ypsr4S6wbM8/2fk/rhfx0HKvJS6f+bhaHdssYb2xvwuoeTBJnD4XTDpMy5eJAmiI3+muYnUWqVFXfL6FXY/KOw7mjfA0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785997326; 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=UjEV9tcw19fCUQDoKga7WPfGMSjd3I/hTcdbM/8Ap08=; b=dwDnrtY3bLfFwRorvwpLoj8qSHgycURaKUju138XcWneGqSerUv5TfhUCNtEOC/pFkX9TuYmqWOTglBdQkqFNBpgKPg6cCeohZZcejS/Lxga4JYKJ1/553kWNmk+ONotYhfGWkidZJuxNqVr2BdVtI43B2afSHb/+L1wJBjtNK0= 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 1785997326267420.8258023227364; Wed, 5 Aug 2026 23:22:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wrrUE-0005GX-Gx; Thu, 06 Aug 2026 02:21:50 -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 1wrrUB-0005Fp-Fx for qemu-devel@nongnu.org; Thu, 06 Aug 2026 02:21:48 -0400 Received: from [115.124.30.118] (helo=out30-118.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 1wrrU8-0000Ai-3D for qemu-devel@nongnu.org; Thu, 06 Aug 2026 02:21:46 -0400 Received: from U-92DF4J33-2338.local(mailfrom:zhengrong_li@linux.alibaba.com fp:SMTPD_---0X8T1lpT_1785997287 cluster:ay36) by smtp.aliyun-inc.com; Thu, 06 Aug 2026 14:21:33 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1785997294; h=From:To:Subject:Date:Message-ID:Content-Type:MIME-Version; bh=UjEV9tcw19fCUQDoKga7WPfGMSjd3I/hTcdbM/8Ap08=; b=MNgp+hk9qXXG/TDR+WzobvAzaJI6J4GjNSeNv/f9uZ54PzPWCm/hk/jLj5823W/K6A6EbhsHBd3nOCR8L5nnZ/8U4dqQbYycp1F/3Vs669fRiGkbhPyU2bTtB0S8sG1eLpn7c6FDlX+v0RJjUXrIYZS55mLf7bJmIKVqzz7981I= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R131e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033045133197; MF=zhengrong_li@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0X8T1lpT_1785997287; From: Zhengrong Li To: qemu-devel@nongnu.org Cc: akihiko.odaki@gmail.com, philmd@qualcomm.com, pbonzini@redhat.com, viktor.prutyanov@phystech.edu, zhengrong_li@linux.alibaba.com Subject: [PATCH v3 3/3] elf2dmp: fill ContextBuffer with faulting CPU context Date: Thu, 06 Aug 2026 14:20:59 +0800 Message-ID: <178599725914.10029.4197199405670909732@linux.alibaba.com> In-Reply-To: <178599725914.10029.4441302124415593392@linux.alibaba.com> References: <178599725914.10029.4441302124415593392@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.118 (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.118; envelope-from=zhengrong_li@linux.alibaba.com; helo=out30-118.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: 1785997326758158500 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. A per-CPU size check ensures the field is present before reading, supporting heterogeneous dumps. Also extract KiBugCheckData from the guest kernel to populate BugcheckCode and BugcheckParameters in the dump header. Signed-off-by: Zhengrong Li --- contrib/elf2dmp/kdbg.h | 9 ++++++++ contrib/elf2dmp/main.c | 50 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 2 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..e25709b45d 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; =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 (s->size >=3D offsetof(QEMUCPUState, is_crash_occurred_cpu) + + sizeof(s->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)); + 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"); --=20 2.43.0