From: Alexandru Elisei <alexandru.elisei@arm.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>
Cc: kvm@vger.kernel.org, Suzuki K Poulose <Suzuki.Poulose@arm.com>,
Steven Price <steven.price@arm.com>,
Will Deacon <will@kernel.org>,
Julien Thierry <julien.thierry.kdev@gmail.com>
Subject: Re: [PATCH kvmtool v3 2/3] cpu: vmexit: Retry KVM_RUN ioctl on EINTR and EAGAIN
Date: Tue, 29 Apr 2025 09:38:12 +0100 [thread overview]
Message-ID: <aBCP9MjXWDZFMoHW@arm.com> (raw)
In-Reply-To: <yq5abjsfvdsx.fsf@kernel.org>
Hi Anessh,
On Tue, Apr 29, 2025 at 09:07:02AM +0530, Aneesh Kumar K.V wrote:
> Alexandru Elisei <alexandru.elisei@arm.com> writes:
>
> > Hi Aneesh,
> >
> > Is this to fix Will's report that the series breaks boot on x86?
> >
>
> Yes.
>
> > On Mon, Apr 28, 2025 at 05:27:44PM +0530, Aneesh Kumar K.V (Arm) wrote:
> >> When KVM_RUN fails with EINTR or EAGAIN, we should retry the ioctl
> >> without checking kvm_run->exit_reason. These errors don't indicate a
> >> valid VM exit, hence exit_reason may contain stale or undefined values.
> >
> > EAGAIN is not documented in Documentation/virt/kvm/api.rst. So I'm going to
> > assume it's this code path that is causing the -EAGAIN return value [1].
> >
>
> IIUC, EAGAIN and EINTR are syscall return errno that indicates a system
> call need to be retried. Documentation/virt/kvm/api.rst do mention that
> exit_reason is value only with return value 0.
>
> __u32 exit_reason;
>
> When KVM_RUN has returned successfully (return value 0), this informs
> application code why KVM_RUN has returned.
Yeah, that makes sense. api.rst is a bit weird, because it doesn't document
all of the error codes, and they are documented in different places, like
-EFAULT which is under KVM_EXIT_MEMORY_FAULT, not under KVM_RUN.
Thanks for the explanation!
>
> >
> > If that's the case, how does retrying KVM_RUN solve the issue? Just trying to
> > get to the bottom of it, because there's not much detail in the docs.
> >
> > [1] https://elixir.bootlin.com/linux/v6.15-rc3/source/arch/x86/kvm/x86.c#L11532
> >
> >
>
> So in that code path vcpu will be in kvm_vcpu_block(vcpu) waiting for
> the IPI. On IPI kvm_apic_accept_events() will return 0 after setting the
> vcpu->arch.mp_state. Hence a KVM_RUN ioctl again will find the mp_state
> correctly updated.
I think that would be useful to have in the commit message.
Thanks,
Alex
>
> -aneesh
next prev parent reply other threads:[~2025-04-29 8:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-28 11:57 [PATCH kvmtool v3 0/3] cpu: vmexit: KVM_RUN ioctl error handling fixes Aneesh Kumar K.V (Arm)
2025-04-28 11:57 ` [PATCH kvmtool v3 1/3] cpu: vmexit: Handle KVM_EXIT_MEMORY_FAULT in KVM_RUN ioctl return Aneesh Kumar K.V (Arm)
2025-04-29 11:07 ` Suzuki K Poulose
2025-04-28 11:57 ` [PATCH kvmtool v3 2/3] cpu: vmexit: Retry KVM_RUN ioctl on EINTR and EAGAIN Aneesh Kumar K.V (Arm)
2025-04-28 13:37 ` Suzuki K Poulose
2025-04-29 3:31 ` Aneesh Kumar K.V
2025-04-28 15:22 ` Alexandru Elisei
2025-04-29 3:37 ` Aneesh Kumar K.V
2025-04-29 8:38 ` Alexandru Elisei [this message]
2025-04-28 11:57 ` [PATCH kvmtool v3 3/3] cpu: vmexit: Handle KVM_EXIT_UNKNOWN exit reason correctly Aneesh Kumar K.V (Arm)
2025-06-10 8:01 ` [PATCH kvmtool v3 0/3] cpu: vmexit: KVM_RUN ioctl error handling fixes Aneesh Kumar K.V
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=aBCP9MjXWDZFMoHW@arm.com \
--to=alexandru.elisei@arm.com \
--cc=Suzuki.Poulose@arm.com \
--cc=aneesh.kumar@kernel.org \
--cc=julien.thierry.kdev@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=steven.price@arm.com \
--cc=will@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.