* [PATCH] target/i386: Add support save/load exception error_code
@ 2025-08-19 14:58 Wang Xin via
2025-08-19 15:28 ` Paolo Bonzini
2025-08-20 10:05 ` Zhao Liu
0 siblings, 2 replies; 5+ messages in thread
From: Wang Xin via @ 2025-08-19 14:58 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, zhao1.liu, weidong.huang, WangXin, Tuo Xie
From: WangXin <wangxinxin.wang@huawei.com>
For now, qemu save/load CPU exception info(such as exception_nr and
has_error_code), while the exception error_code is ignored. This will
cause the dest hypervisor reinject a vCPU exception with error_code(0),
potentially causing a guest kernel panic.
For instance, if src VM stopped with an user-mode write #PF (error_code 6),
the dest hypervisor will reinject an #PF with error_code(0) when vCPU resume,
then guest kernel panic as:
BUG: unable to handle page fault for address: 00007f80319cb010
#PF: supervisor read access in user mode
#PF: error_code(0x0000) - not-present page
RIP: 0033:0x40115d
To fix it, support save/load exception error_code.
Signed-off-by: Xin Wang <wangxinxin.wang@huawei.com>
Signed-off-by: Tuo Xie <xietuo@huawei.com>
diff --git a/target/i386/machine.c b/target/i386/machine.c
index dd2dac1d44..45b7cea80a 100644
--- a/target/i386/machine.c
+++ b/target/i386/machine.c
@@ -462,6 +462,24 @@ static const VMStateDescription vmstate_exception_info = {
}
};
+static bool cpu_errcode_needed(void *opaque)
+{
+ X86CPU *cpu = opaque;
+
+ return cpu->env.has_error_code != 0;
+}
+
+static const VMStateDescription vmstate_error_code = {
+ .name = "cpu/error_code",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = cpu_errcode_needed,
+ .fields = (const VMStateField[]) {
+ VMSTATE_INT32(env.error_code, X86CPU),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
/* Poll control MSR enabled by default */
static bool poll_control_msr_needed(void *opaque)
{
@@ -1746,6 +1764,7 @@ const VMStateDescription vmstate_x86_cpu = {
},
.subsections = (const VMStateDescription * const []) {
&vmstate_exception_info,
+ &vmstate_error_code,
&vmstate_async_pf_msr,
&vmstate_async_pf_int_msr,
&vmstate_pv_eoi_msr,
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] target/i386: Add support save/load exception error_code
2025-08-19 14:58 [PATCH] target/i386: Add support save/load exception error_code Wang Xin via
@ 2025-08-19 15:28 ` Paolo Bonzini
2025-08-20 2:18 ` Wangxin (Alexander) via
2025-08-20 10:05 ` Zhao Liu
1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2025-08-19 15:28 UTC (permalink / raw)
To: Wang Xin via; +Cc: pbonzini, zhao1.liu, weidong.huang, WangXin, Tuo Xie
Queued, thanks. But please let me know what's the correct signed off by chain;
either Tuo created the patch, and then you should have "--author" for him and
his SoB first; or you did, and then Tuo's SoB is unnecessary.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] target/i386: Add support save/load exception error_code
2025-08-19 15:28 ` Paolo Bonzini
@ 2025-08-20 2:18 ` Wangxin (Alexander) via
2025-08-20 10:16 ` zhao1.liu
0 siblings, 1 reply; 5+ messages in thread
From: Wangxin (Alexander) via @ 2025-08-20 2:18 UTC (permalink / raw)
To: Paolo Bonzini, Wang Xin via; +Cc: zhao1.liu@intel.com, Huangweidong (C), xietuo
>
> Queued, thanks. But please let me know what's the correct signed off by chain;
> either Tuo created the patch, and then you should have "--author" for him and
> his SoB first; or you did, and then Tuo's SoB is unnecessary.
>
> Paolo
>
The author is me, should I resend this patch?
Thanks,
Xin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] target/i386: Add support save/load exception error_code
2025-08-20 2:18 ` Wangxin (Alexander) via
@ 2025-08-20 10:16 ` zhao1.liu
0 siblings, 0 replies; 5+ messages in thread
From: zhao1.liu @ 2025-08-20 10:16 UTC (permalink / raw)
To: Wangxin (Alexander); +Cc: Paolo Bonzini, Wang Xin via, Huangweidong (C), xietuo
On Wed, Aug 20, 2025 at 02:18:21AM +0000, Wangxin (Alexander) wrote:
> Date: Wed, 20 Aug 2025 02:18:21 +0000
> From: "Wangxin (Alexander)" <wangxinxin.wang@huawei.com>
> Subject: RE: [PATCH] target/i386: Add support save/load exception error_code
>
> >
> > Queued, thanks. But please let me know what's the correct signed off by chain;
> > either Tuo created the patch, and then you should have "--author" for him and
> > his SoB first; or you did, and then Tuo's SoB is unnecessary.
> >
> > Paolo
> >
>
> The author is me,
But if Tuo co-worked with you, his SoB is also necessary to keep:
"git commits will usually be expected to have a ``Signed-off-by``
line for each contributor involved in creation of the patch."
In this case, “Co-developed-by” is not necessary for now.
I think the reason of confusion is, as the person sending the patch,
you'd have put your SoB on the last line.
Thanks,
Zhao
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] target/i386: Add support save/load exception error_code
2025-08-19 14:58 [PATCH] target/i386: Add support save/load exception error_code Wang Xin via
2025-08-19 15:28 ` Paolo Bonzini
@ 2025-08-20 10:05 ` Zhao Liu
1 sibling, 0 replies; 5+ messages in thread
From: Zhao Liu @ 2025-08-20 10:05 UTC (permalink / raw)
To: Wang Xin; +Cc: qemu-devel, pbonzini, weidong.huang, Tuo Xie
On Tue, Aug 19, 2025 at 10:58:34PM +0800, Wang Xin wrote:
> Date: Tue, 19 Aug 2025 22:58:34 +0800
> From: Wang Xin <wangxinxin.wang@huawei.com>
> Subject: [PATCH] target/i386: Add support save/load exception error_code
> X-Mailer: git-send-email 2.50.1.windows.1
>
> From: WangXin <wangxinxin.wang@huawei.com>
>
> For now, qemu save/load CPU exception info(such as exception_nr and
> has_error_code), while the exception error_code is ignored. This will
> cause the dest hypervisor reinject a vCPU exception with error_code(0),
> potentially causing a guest kernel panic.
>
> For instance, if src VM stopped with an user-mode write #PF (error_code 6),
> the dest hypervisor will reinject an #PF with error_code(0) when vCPU resume,
> then guest kernel panic as:
> BUG: unable to handle page fault for address: 00007f80319cb010
> #PF: supervisor read access in user mode
> #PF: error_code(0x0000) - not-present page
> RIP: 0033:0x40115d
>
> To fix it, support save/load exception error_code.
>
> Signed-off-by: Xin Wang <wangxinxin.wang@huawei.com>
> Signed-off-by: Tuo Xie <xietuo@huawei.com>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-20 9:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-19 14:58 [PATCH] target/i386: Add support save/load exception error_code Wang Xin via
2025-08-19 15:28 ` Paolo Bonzini
2025-08-20 2:18 ` Wangxin (Alexander) via
2025-08-20 10:16 ` zhao1.liu
2025-08-20 10:05 ` Zhao Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.