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. Report that the register state is unavailable, with the errno, and return instead of dying. Signed-off-by: Fuad Tabba --- 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); } -- 2.39.5