From: Magnus Kulke <magnuskulke@linux.microsoft.com>
To: "Doru Blânzeanu" <dblanzeanu@linux.microsoft.com>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Wei Liu" <wei.liu@kernel.org>,
"Magnus Kulke" <magnuskulke@microsoft.com>,
"Doru Blânzeanu" <dblanzeanu@microsoft.com>,
"Wei Liu" <liuwe@microsoft.com>
Subject: Re: [PATCH 2/5] target/i386/mshv: abort when hv_vp_register_page setup fails
Date: Wed, 8 Jul 2026 18:38:52 +0200 [thread overview]
Message-ID: <ak59HPl7k27F6Ts5@example.com> (raw)
In-Reply-To: <20260707221645.24557-3-dblanzeanu@linux.microsoft.com>
On Wed, Jul 08, 2026 at 01:16:42AM +0300, Doru Blânzeanu wrote:
> In case the call to mmap fails, we log an error and abort to signal
> there is something wrong with the system.
> Check the register page version and compare with the expected version and
> abort in case of a mismatch.
>
> Fixes: a173f8f170
> Signed-off-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com>
> ---
> target/i386/mshv/mshv-cpu.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c
> index 1c433c408c..c782715497 100644
> --- a/target/i386/mshv/mshv-cpu.c
> +++ b/target/i386/mshv/mshv-cpu.c
> @@ -2049,6 +2049,7 @@ void mshv_arch_init_vcpu(CPUState *cpu)
> CPUX86State *env = &x86_cpu->env;
> AccelCPUState *state = cpu->accel;
> size_t page = HV_HYP_PAGE_SIZE, xsave_len;
> + void *regs_page;
> void *mem = qemu_memalign(page, 2 * page);
> int ret;
> X86XSaveHeader *header;
> @@ -2060,15 +2061,20 @@ void mshv_arch_init_vcpu(CPUState *cpu)
> > HV_HYP_PAGE_SIZE));
>
> /* mmap the registers page */
> - void *rp = mmap(NULL, page, PROT_READ | PROT_WRITE,
> + regs_page = mmap(NULL, page, PROT_READ | PROT_WRITE,
> MAP_SHARED, mshv_vcpufd(cpu),
> MSHV_VP_MMAP_OFFSET_REGISTERS * page);
> - if (rp == MAP_FAILED) {
> - warn_report("register page mmap failed, falling back to hypercalls: %s",
> - strerror(errno));
> - env->regs_page = NULL;
> - } else {
> - env->regs_page = (struct hv_vp_register_page *) rp;
> + if (regs_page == MAP_FAILED) {
> + /* This shouldn't fail, so we treat it as a fatal error */
> + error_report("register page mmap failed: %s", strerror(errno));
> + abort();
> + }
> + env->regs_page = (struct hv_vp_register_page *) regs_page;
> +
> + if (env->regs_page->version != HV_VP_REGISTER_PAGE_VERSION_1) {
> + error_report("register page version mismatch: got %u, expected %u",
> + env->regs_page->version, HV_VP_REGISTER_PAGE_VERSION_1);
> + abort();
> }
>
> state->hvcall_args.base = mem;
> --
> 2.53.0
Reviewed-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
next prev parent reply other threads:[~2026-07-08 16:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 22:16 [PATCH 0/5] Fix register page use for guests using mshv accel Doru Blânzeanu
2026-07-07 22:16 ` [PATCH 1/5] include/hw/hyperv: move hv_vp_register_page struct definition Doru Blânzeanu
2026-07-08 16:36 ` Magnus Kulke
2026-07-07 22:16 ` [PATCH 2/5] target/i386/mshv: abort when hv_vp_register_page setup fails Doru Blânzeanu
2026-07-08 16:37 ` Magnus Kulke
2026-07-08 16:38 ` Magnus Kulke [this message]
2026-07-07 22:16 ` [PATCH 3/5] target/i386/mshv: remove fallback for register page get registers Doru Blânzeanu
2026-07-08 16:49 ` Magnus Kulke
2026-07-07 22:16 ` [PATCH 4/5] target/i386/mshv: remove fallback for register page set registers Doru Blânzeanu
2026-07-08 16:44 ` Magnus Kulke
2026-07-07 22:16 ` [PATCH 5/5] target/i386/mshv: fix pio handlers clobbering device-modified registers Doru Blânzeanu
2026-07-08 16:50 ` Magnus Kulke
-- strict thread matches above, loose matches on Subject: below --
2026-07-07 8:25 [PATCH 0/5] Fix register page use for guests using mshv accel Doru Blânzeanu
2026-07-07 8:25 ` [PATCH 2/5] target/i386/mshv: abort when hv_vp_register_page setup fails Doru Blânzeanu
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=ak59HPl7k27F6Ts5@example.com \
--to=magnuskulke@linux.microsoft.com \
--cc=dblanzeanu@linux.microsoft.com \
--cc=dblanzeanu@microsoft.com \
--cc=liuwe@microsoft.com \
--cc=magnuskulke@microsoft.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wei.liu@kernel.org \
/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.