[PATCH v16 35/45] KVM: arm64: CCA: Support RSI_HOST_CALL

From: Steven Price

Date: Mon Aug 03 2026 - 10:16:58 EST


From: Joey Gouly <joey.gouly@xxxxxxx>

Realm VMs can talk to the hypervisor using the RSI_HOST_CALL SMC. The
RMM forwards this to the host and KVM handles them as regular
hypercalls.

Signed-off-by: Joey Gouly <joey.gouly@xxxxxxx>
Signed-off-by: Steven Price <steven.price@xxxxxxx>
---
Changes since v15:
* Adapt to new exit handling.
Changes since v7:
* Avoid turning a negative return from kvm_smccc_call_handler() into a
error response to the guest. Instead propagate the error back to user
space.
Changes since v4:
* Setting GPRS is now done by kvm_rec_enter() rather than
rec_exit_host_call() (see previous patch - arm64: RME: Handle realm
enter/exit). This fixes a bug where the registers set by user space
were being ignored.
---
arch/arm64/kvm/rmi-exit.c | 1 +
arch/arm64/kvm/rmi.c | 4 ++++
2 files changed, 5 insertions(+)

diff --git a/arch/arm64/kvm/rmi-exit.c b/arch/arm64/kvm/rmi-exit.c
index 1749cde2edff..7cde820bb77b 100644
--- a/arch/arm64/kvm/rmi-exit.c
+++ b/arch/arm64/kvm/rmi-exit.c
@@ -164,6 +164,7 @@ int kvm_rec_exit(struct kvm_vcpu *vcpu, int rec_run_ret)
case RMI_EXIT_SERROR:
return ARM_EXCEPTION_EL1_SERROR;
case RMI_EXIT_PSCI:
+ case RMI_EXIT_HOST_CALL:
rec_exit_hvc(vcpu);
kvm_make_request(KVM_REQ_RMI, vcpu);
return ARM_EXCEPTION_TRAP;
diff --git a/arch/arm64/kvm/rmi.c b/arch/arm64/kvm/rmi.c
index 3f31ad25680f..904df7c7245d 100644
--- a/arch/arm64/kvm/rmi.c
+++ b/arch/arm64/kvm/rmi.c
@@ -1203,6 +1203,10 @@ int kvm_rec_handle_request(struct kvm_vcpu *vcpu)
return kvm_rec_complete_psci(vcpu);
case RMI_EXIT_RIPAS_CHANGE:
return kvm_complete_ripas_change(vcpu);
+ case RMI_EXIT_HOST_CALL:
+ for (int i = 0; i < REC_RUN_GPRS; i++)
+ rec->run->enter.gprs[i] = vcpu_get_reg(vcpu, i);
+ break;
default:
KVM_BUG(1, vcpu->kvm, "Unhandled realm exit_reason");
return -ENXIO;
--
2.43.0