From: "Alex Bennée" <alex.bennee@linaro.org>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>,
Xin Wang <wangxinxin.wang@huawei.com>
Subject: Re: [PATCH v2 001/281] target/i386: Add support for save/load of exception error code
Date: Fri, 05 Sep 2025 13:36:17 +0100 [thread overview]
Message-ID: <87a539vzy6.fsf@draig.linaro.org> (raw)
In-Reply-To: <20250904140844.5b670290@fedora> (Igor Mammedov's message of "Thu, 4 Sep 2025 14:08:44 +0200")
Igor Mammedov <imammedo@redhat.com> writes:
(trim the CC list somewhat)
> On Thu, 4 Sep 2025 09:06:35 +0100
> Alex Bennée <alex.bennee@linaro.org> wrote:
>
>> From: Xin Wang <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.
>
> this potentially will break migration between new/old QEMU versions
> due to presence new subsection. But then according to commit message
> the guest might panic (on dst) when resumed anyways.
>
> So patch changes how guest will fail
> (panic: old => old, old => new
> vs migration error: new => old ).
>
> Peter,
> do we care and do we need a compat knob to make existing
> machine type behave old way?
Igor,
So this patch is already in master, it was only posted in this series
because my master is never upto date with origin/master.
Apologies again for the noise.
>
>>
>> Signed-off-by: Xin Wang <wangxinxin.wang@huawei.com>
>> Link: https://lore.kernel.org/r/20250819145834.3998-1-wangxinxin.wang@huawei.com
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>> target/i386/machine.c | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>>
>> diff --git a/target/i386/machine.c b/target/i386/machine.c
>> index dd2dac1d443..45b7cea80aa 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,
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2025-09-05 12:37 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 8:06 [PATCH v2 000/281] arm_load_dtb cleanups Alex Bennée
2025-09-04 8:06 ` [PATCH v2 001/281] target/i386: Add support for save/load of exception error code Alex Bennée
2025-09-04 12:08 ` Igor Mammedov
2025-09-05 12:36 ` Alex Bennée [this message]
2025-09-04 8:06 ` [PATCH v2 002/281] scripts/minikconf.py: fix invalid attribute access Alex Bennée
2025-09-04 8:06 ` [PATCH v2 003/281] scripts/minikconf.py: s/Error/KconfigParserError Alex Bennée
2025-09-04 8:06 ` [PATCH v2 004/281] python: mkvenv: fix messages printed by mkvenv Alex Bennée
2025-09-04 8:06 ` [PATCH v2 005/281] MAINTAINERS: add a few more files to "Top Level Makefile and configure" Alex Bennée
2025-09-04 8:06 ` [PATCH v2 006/281] Update version for the v10.1.0 release Alex Bennée
2025-09-04 8:06 ` [PATCH v2 007/281] Open 10.2 development tree Alex Bennée
2025-09-04 8:06 ` [PATCH v2 008/281] hw: add compat machines for 10.2 Alex Bennée
2025-09-04 8:06 ` [PATCH v2 010/281] tests/functional/test_aarch64_virt_gpu: Skip test if EGL won't initialize Alex Bennée
2025-09-04 8:06 ` [PATCH v2 011/281] tests/functional: Fix reverse_debugging asset precaching Alex Bennée
2025-09-04 8:06 ` [PATCH v2 012/281] tests/functional: Use more fine-grained locking when looking for free ports Alex Bennée
2025-09-04 8:06 ` [PATCH v2 015/281] tests/functional/meson.build: Split timeout settings by target Alex Bennée
2025-09-04 8:06 ` [PATCH v2 016/281] tests/functional/meson.build: Allow tests to reside in subfolders Alex Bennée
2025-09-04 8:06 ` [PATCH v2 017/281] tests/functional: Move aarch64 tests into architecture specific folder Alex Bennée
2025-09-04 8:06 ` [PATCH v2 018/281] tests/functional: Move alpha " Alex Bennée
2025-09-04 8:06 ` [PATCH v2 021/281] tests/functional: Move hppa " Alex Bennée
2025-09-04 8:06 ` [PATCH v2 022/281] tests/functional: Move i386 " Alex Bennée
2025-09-04 8:06 ` [PATCH v2 024/281] tests/functional: Move m68k " Alex Bennée
2025-09-04 8:06 ` [PATCH v2 025/281] tests/functional: Move microblaze " Alex Bennée
2025-09-04 8:07 ` [PATCH v2 031/281] tests/functional: Move s390x tests into target-specific folders Alex Bennée
2025-09-04 8:07 ` [PATCH v2 032/281] tests/functional: Move sh4/sh4eb " Alex Bennée
2025-09-04 8:07 ` [PATCH v2 033/281] tests/functional: Move sparc/sparc64 " Alex Bennée
2025-09-04 8:07 ` [PATCH v2 034/281] tests/functional: Move x86_64 tests into target-specific folder Alex Bennée
2025-09-04 8:07 ` [PATCH v2 036/281] tests/functional: Move the generic tests to a subfolder Alex Bennée
2025-09-04 8:07 ` [PATCH v2 041/281] kvm/kvm-all: make kvm_park/unpark_vcpu local to kvm-all.c Alex Bennée
2025-09-04 8:07 ` [PATCH v2 045/281] rust/qemu-api-macros: make derive(Object) friendly when missing parent Alex Bennée
2025-09-04 8:07 ` [PATCH v2 047/281] rust: move dependencies to rust/Cargo.toml Alex Bennée
2025-09-04 8:07 ` [PATCH v2 048/281] semihosting: Retrieve stack top from image_info Alex Bennée
2025-09-04 8:07 ` [PATCH v2 049/281] semihosting: Initialize heap once per process Alex Bennée
2025-09-04 8:07 ` [PATCH v2 050/281] linux-user: Create target/elfload.c files Alex Bennée
2025-09-04 8:07 ` [PATCH v2 051/281] linux-user: Move ppc uabi/asm/elf.h workaround to osdep.h Alex Bennée
2025-09-04 8:07 ` [PATCH v2 054/281] linux-user: Move hwcap functions to {arm, aarch64}/elfload.c Alex Bennée
2025-09-04 8:07 ` [PATCH v2 055/281] linux-user: Move get_elf_hwcap to sparc/elfload.c Alex Bennée
2025-09-04 8:07 ` [PATCH v2 056/281] linux-user: Move hwcap functions to ppc/elfload.c Alex Bennée
2025-09-04 8:07 ` [PATCH v2 057/281] linux-user: Move get_elf_hwcap to loongarch64/elfload.c Alex Bennée
2025-09-04 8:07 ` [PATCH v2 058/281] linux-user: Move get_elf_hwcap to mips/elfload.c Alex Bennée
2025-09-04 8:07 ` [PATCH v2 059/281] linux-user: Move get_elf_hwcap to sh4/elfload.c Alex Bennée
2025-09-04 8:07 ` [PATCH v2 063/281] linux-user: Remove ELF_HWCAP2 Alex Bennée
2025-09-04 8:07 ` [PATCH v2 068/281] linux-user/hppa: Create get_elf_platform Alex Bennée
2025-09-04 8:07 ` [PATCH v2 069/281] linux-user: Remove ELF_PLATFORM Alex Bennée
2025-09-04 8:07 ` [PATCH v2 071/281] linux-user: Move target_cpu_copy_regs decl to qemu.h Alex Bennée
2025-09-04 8:07 ` [PATCH v2 076/281] linux-user/aarch64: Create init_main_thread Alex Bennée
2025-09-04 8:07 ` [PATCH v2 080/281] linux-user/mips: " Alex Bennée
2025-09-04 8:07 ` [PATCH v2 082/281] linux-user/openrisc: " Alex Bennée
2025-09-04 8:07 ` [PATCH v2 083/281] linux-user/sh4: " Alex Bennée
2025-09-04 8:07 ` [PATCH v2 084/281] linux-user/m68k: " Alex Bennée
2025-09-04 8:08 ` [PATCH v2 087/281] linux-user/riscv: " Alex Bennée
2025-09-04 8:08 ` [PATCH v2 088/281] linux-user/hppa: " Alex Bennée
2025-09-04 8:08 ` [PATCH v2 089/281] linux-user/xtensa: " Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a539vzy6.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wangxinxin.wang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.