From: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>
To: kvm@vger.kernel.org
Cc: 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>,
"Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>,
Alexandru Elisei <alexandru.elisei@arm.com>
Subject: [PATCH kvmtool v3 3/3] cpu: vmexit: Handle KVM_EXIT_UNKNOWN exit reason correctly
Date: Mon, 28 Apr 2025 17:27:45 +0530 [thread overview]
Message-ID: <20250428115745.70832-4-aneesh.kumar@kernel.org> (raw)
In-Reply-To: <20250428115745.70832-1-aneesh.kumar@kernel.org>
The return value for kernel VM exit handlers is confusing and has led to
errors in different kernel exit handlers. A return value of 0 indicates
a return to the VMM, whereas a return value of 1 indicates resuming
execution in the guest. Some handlers mistakenly return 0 to force a
return to the guest.
This worked in kvmtool because the exit_reason defaulted to
0 (KVM_EXIT_UNKNOWN), and kvmtool did not error out on an unknown exit
reason. However, forcing a VMM exit with error on KVM_EXIT_UNKNOWN
exit_reson would help catch these bugs early.
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
---
kvm-cpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kvm-cpu.c b/kvm-cpu.c
index 7abbdcebf075..a76dfee561ec 100644
--- a/kvm-cpu.c
+++ b/kvm-cpu.c
@@ -190,7 +190,7 @@ int kvm_cpu__start(struct kvm_cpu *cpu)
switch (cpu->kvm_run->exit_reason) {
case KVM_EXIT_UNKNOWN:
- break;
+ goto panic_kvm;
case KVM_EXIT_DEBUG:
kvm_cpu__show_registers(cpu);
kvm_cpu__show_code(cpu);
--
2.43.0
next prev parent reply other threads:[~2025-04-28 11:58 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
2025-04-28 11:57 ` Aneesh Kumar K.V (Arm) [this message]
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=20250428115745.70832-4-aneesh.kumar@kernel.org \
--to=aneesh.kumar@kernel.org \
--cc=Suzuki.Poulose@arm.com \
--cc=alexandru.elisei@arm.com \
--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.