Re: [RFC PATCH v1 26/38] KVM: arm64: Add exit handler related to device assignment

Jonathan Cameron
2025-07-30T14:35:16Z

On Mon, 28 Jul 2025 19:22:03 +0530
"Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org> wrote:

> Different RSI calls related to DA result in REC exits. Add a facility to
> register handlers for handling these REC exits.
>
> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>

> diff --git a/arch/arm64/include/asm/rmi_smc.h b/arch/arm64/include/asm/rmi_smc.h
> index c6e16ab608e1..a5ef68b62bc0 100644
> --- a/arch/arm64/include/asm/rmi_smc.h
> +++ b/arch/arm64/include/asm/rmi_smc.h

> diff --git a/arch/arm64/kvm/rme-exit.c b/arch/arm64/kvm/rme-exit.c
> index 1a8ca7526863..25948207fc5b 100644
> --- a/arch/arm64/kvm/rme-exit.c
> +++ b/arch/arm64/kvm/rme-exit.c

> +static int rec_exit_dev_mem_map(struct kvm_vcpu *vcpu)
> +{
> + int ret;
> + struct realm_rec *rec = &vcpu->arch.rec;
> +
> + if (realm_exit_dev_mem_map_handler) {
> + ret = (*realm_exit_dev_mem_map_handler)(rec);
> + } else {
> + kvm_pr_unimpl("Unsupported exit reason: %u\n",
> + rec->run->exit.exit_reason);
> + vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
> + ret = 0;

I guess maybe this gets more complex later, but right now
return 0;

And maybe return in the if branch as well.
Same for other similar code in this patch.

> + }
> + return ret;
> +}
> +
> static void update_arch_timer_irq_lines(struct kvm_vcpu *vcpu)
> {
> struct realm_rec *rec = &vcpu->arch.rec;
> @@ -198,6 +252,12 @@ int handle_rec_exit(struct kvm_vcpu *vcpu, int rec_run_ret)
> return rec_exit_ripas_change(vcpu);
> case RMI_EXIT_HOST_CALL:
> return rec_exit_host_call(vcpu);
> + case RMI_EXIT_VDEV_REQUEST:
> + return rec_exit_vdev_request(vcpu);
> + case RMI_EXIT_VDEV_COMM:
> + return rec_exit_vdev_communication(vcpu);
> + case RMI_EXIT_DEV_MEM_MAP:
> + return rec_exit_dev_mem_map(vcpu);
> }
>
> kvm_pr_unimpl("Unsupported exit reason: %u\n",