From: Magnus Kulke <magnuskulke@linux.microsoft.com>
To: "Doru Blânzeanu" <dblanzeanu@linux.microsoft.com>
Cc: qemu-devel@nongnu.org, "Magnus Kulke" <magnuskulke@microsoft.com>,
"Wei Liu" <wei.liu@kernel.org>,
"Doru Blânzeanu" <doru.blanzeanu@microsoft.com>
Subject: Re: [PATCH] target/i386/mshv: fix vCPU run result contract
Date: Wed, 11 Nov 2026 20:24:05 +0100 [thread overview]
Message-ID: <avTA1SfSOhtmREGA@example.com> (raw)
In-Reply-To: <avRWIAZmm6kOlu2-@linux.microsoft.com>
On Wed, Nov 11, 2026 at 01:48:48PM +0200, Doru Blânzeanu wrote:
> On Thu, Oct 15, 2026 at 02:19:11PM +0200, Magnus Kulke wrote:
> > Currently the return semantics of mshv_run_vcpu() are broken. They
> > return a mix of int and exit_reason, ignoring the out param *exit.
> >
> > This change propagates errno's to the call site and sets the *exit value
> > accordingly. We also consider the case when an ioctl has return due to a
> > qemu-requested interruption of the call, this is a legitimate condition
> > that should not produce an error.
> >
> > Fixes: 6dec60528c4 (target/i386/mshv: Implement mshv_vcpu_run())
> > Signed-off-by: Magnus Kulke <magnuskulke@linux.microsoft.com>
> > ---
> > target/i386/mshv/mshv-cpu.c | 28 +++++++++++++++++-----------
> > 1 file changed, 17 insertions(+), 11 deletions(-)
> >
> > diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c
> > index 4df73bb497..e3c155da2e 100644
> > --- a/target/i386/mshv/mshv-cpu.c
> > +++ b/target/i386/mshv/mshv-cpu.c
> > @@ -2124,7 +2124,6 @@ static int arch_set_single_step(CPUState *cpu, bool enable)
> > int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *exit)
> > {
> > int ret;
> > - enum MshvVmExit exit_reason;
> > int cpu_fd = mshv_vcpufd(cpu);
> > bool single_step;
> >
> > @@ -2142,7 +2141,12 @@ int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *exit)
> >
> > ret = ioctl(cpu_fd, MSHV_RUN_VP, msg);
> > if (ret < 0) {
> > - return MshvVmExitShutdown;
> > + if (errno == EINTR) {
> > + *exit = MshvVmExitSpecial;
> > + return 0;
> > + }
> > + error_report("failed to run vCPU: %s", strerror(errno));
> > + return -errno;
> > }
> >
> > /* disable single stepping by flipping RFLAGS.TF */
> > @@ -2154,31 +2158,33 @@ int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *exit)
> >
> > switch (msg->header.message_type) {
> > case HVMSG_UNRECOVERABLE_EXCEPTION:
> > - return MshvVmExitShutdown;
> > + *exit = MshvVmExitShutdown;
> > + return 0;
> > case HVMSG_UNMAPPED_GPA:
> > case HVMSG_GPA_INTERCEPT:
> > - ret = handle_mmio(cpu, msg, &exit_reason);
> > + ret = handle_mmio(cpu, msg, exit);
> > if (ret < 0) {
> > error_report("failed to handle mmio");
> > - return -1;
> > + return ret;
> > }
> > - return exit_reason;
> > + return 0;
> > case HVMSG_X64_IO_PORT_INTERCEPT:
> > ret = handle_pio(cpu, msg);
> > if (ret < 0) {
> > - return MshvVmExitSpecial;
> > + error_report("failed to handle PIO");
> > + return ret;
> > }
> > - return MshvVmExitIgnore;
> > + *exit = MshvVmExitIgnore;
> > + return 0;
> > case HVMSG_X64_EXCEPTION_INTERCEPT:
> > bql_lock();
> > - ret = handle_exception_interrupt(cpu, msg, &exit_reason);
> > + ret = handle_exception_interrupt(cpu, msg, exit);
> > bql_unlock();
> > if (ret < 0) {
> > error_report("failed to handle exception intercept");
> > return -1;
> > }
> > - *exit = exit_reason;
> > - return exit_reason;
> > + return 0;
> > default:
> > break;
> > }
> > --
> > 2.34.1
>
> Reviewed-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com>
queued in pull-20261111
prev parent reply other threads:[~2026-11-11 19:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 12:19 [PATCH] target/i386/mshv: fix vCPU run result contract Magnus Kulke
2026-11-11 11:48 ` Doru Blânzeanu
2026-11-11 19:24 ` Magnus Kulke [this message]
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=avTA1SfSOhtmREGA@example.com \
--to=magnuskulke@linux.microsoft.com \
--cc=dblanzeanu@linux.microsoft.com \
--cc=doru.blanzeanu@microsoft.com \
--cc=magnuskulke@microsoft.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.