From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Fuad Tabba <fuad.tabba@linux.dev>, kvm@vger.kernel.org
Cc: kvmarm@lists.linux.dev, Will Deacon <will@kernel.org>,
Julien Thierry <julien.thierry.kdev@gmail.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Andre Przywara <andre.przywara@arm.com>,
Oliver Upton <oliver.upton@linux.dev>,
Marc Zyngier <maz@kernel.org>, Fuad Tabba <tabba@google.com>
Subject: Re: [PATCH kvmtool 1/5] arm64: Do not abort on register-dump failures
Date: Sat, 12 Sep 2026 08:33:08 +0100 [thread overview]
Message-ID: <3bb3d57a-1862-4645-a5e2-789d70e9fc73@arm.com> (raw)
In-Reply-To: <20260831192406.1341841-2-fuad.tabba@linux.dev>
On 31/08/2026 20:24, Fuad Tabba wrote:
> kvm_cpu__show_registers() and kvm_cpu__show_code() read the vCPU's core
> registers with KVM_GET_ONE_REG, and die() if the ioctl fails. Both are
> diagnostics. They run from the KVM_EXIT_DEBUG case in kvm_cpu__start(),
> from the "lkvm debug -d" dump path in handle_sigusr1(), and from the
> panic dump in kvm_cpu_thread().
>
> Once a protected vCPU has run, its registers belong to the guest and
> KVM_GET_ONE_REG returns -EPERM. Dying on that turns a diagnostic into a
> VMM abort.
Marc once suggested that these could always succeed with junk values for
protected/Realm VMs. Do you think that is an option for pKVM ?
If we go with this approach :
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>
> Report that the register state is unavailable, with the errno, and
> return instead of dying.
>
> Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
> ---
> arm64/kvm-cpu.c | 36 ++++++++++++++++++++++++------------
> 1 file changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/arm64/kvm-cpu.c b/arm64/kvm-cpu.c
> index 3aa7684..c58d61f 100644
> --- a/arm64/kvm-cpu.c
> +++ b/arm64/kvm-cpu.c
> @@ -476,15 +476,19 @@ void kvm_cpu__show_code(struct kvm_cpu *vcpu)
>
> dprintf(debug_fd, "\n*pc:\n");
> reg.id = ARM64_CORE_REG(regs.pc);
> - if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
> - die("KVM_GET_ONE_REG failed (show_code @ PC)");
> + if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0) {
> + pr_err("register state unavailable (pc): %s", strerror(errno));
> + return;
> + }
>
> kvm__dump_mem(vcpu->kvm, data, 32, debug_fd);
>
> dprintf(debug_fd, "\n*lr:\n");
> reg.id = ARM64_CORE_REG(regs.regs[30]);
> - if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
> - die("KVM_GET_ONE_REG failed (show_code @ LR)");
> + if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0) {
> + pr_err("register state unavailable (lr): %s", strerror(errno));
> + return;
> + }
>
> kvm__dump_mem(vcpu->kvm, data, 32, debug_fd);
> }
> @@ -499,23 +503,31 @@ void kvm_cpu__show_registers(struct kvm_cpu *vcpu)
> dprintf(debug_fd, "\n Registers:\n");
>
> reg.id = ARM64_CORE_REG(regs.pc);
> - if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
> - die("KVM_GET_ONE_REG failed (pc)");
> + if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0) {
> + pr_err("register state unavailable (pc): %s", strerror(errno));
> + return;
> + }
> dprintf(debug_fd, " PC: 0x%lx\n", data);
>
> reg.id = ARM64_CORE_REG(regs.pstate);
> - if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
> - die("KVM_GET_ONE_REG failed (pstate)");
> + if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0) {
> + pr_err("register state unavailable (pstate): %s", strerror(errno));
> + return;
> + }
> dprintf(debug_fd, " PSTATE: 0x%lx\n", data);
>
> reg.id = ARM64_CORE_REG(sp_el1);
> - if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
> - die("KVM_GET_ONE_REG failed (sp_el1)");
> + if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0) {
> + pr_err("register state unavailable (sp_el1): %s", strerror(errno));
> + return;
> + }
> dprintf(debug_fd, " SP_EL1: 0x%lx\n", data);
>
> reg.id = ARM64_CORE_REG(regs.regs[30]);
> - if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0)
> - die("KVM_GET_ONE_REG failed (lr)");
> + if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, ®) < 0) {
> + pr_err("register state unavailable (lr): %s", strerror(errno));
> + return;
> + }
> dprintf(debug_fd, " LR: 0x%lx\n", data);
> }
>
next prev parent reply other threads:[~2026-09-12 7:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 19:24 [PATCH kvmtool 0/5] Fix diagnostics and capability probes for protected VMs Fuad Tabba
2026-08-31 19:24 ` [PATCH kvmtool 1/5] arm64: Do not abort on register-dump failures Fuad Tabba
2026-09-12 7:33 ` Suzuki K Poulose [this message]
2026-09-12 13:54 ` Fuad Tabba
2026-09-12 14:02 ` Fuad Tabba
2026-09-12 19:36 ` Suzuki K Poulose
2026-08-31 19:24 ` [PATCH kvmtool 2/5] kvm: Bound-check the exit-reason string lookup Fuad Tabba
2026-09-12 7:35 ` Suzuki K Poulose
2026-08-31 19:24 ` [PATCH kvmtool 3/5] kvm: Name every exit reason the UAPI header defines Fuad Tabba
2026-09-12 7:35 ` Suzuki K Poulose
2026-08-31 19:24 ` [PATCH kvmtool 4/5] arm64: Query steal-time support on the VM fd Fuad Tabba
2026-09-12 7:28 ` Suzuki K Poulose
2026-08-31 19:24 ` [PATCH kvmtool 5/5] arm64: Query counter-offset " Fuad Tabba
2026-09-12 7:29 ` Suzuki K Poulose
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=3bb3d57a-1862-4645-a5e2-789d70e9fc73@arm.com \
--to=suzuki.poulose@arm.com \
--cc=alexandru.elisei@arm.com \
--cc=andre.przywara@arm.com \
--cc=fuad.tabba@linux.dev \
--cc=julien.thierry.kdev@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=tabba@google.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.