Re: [PATCH v16 21/45] KVM: arm64: CCA: Handle realm enter/exit
Aneesh Kumar K.V <[email protected]> Tue, 04 Aug 2026 14:27:03 +0530
| Newsgroups | dev.linux.lists.kvmarm,dev.linux.lists.linux-coco,org.infradead.lists.linux-arm-kernel,org.kernel.vger.kvm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Steven Price <[email protected]> writes: > + switch (rec->run->exit.exit_reason) { > + case RMI_EXIT_SYNC: > + /* > + * HPFAR_EL2_NS is hijacked to indicate a valid HPFAR value, > + * see __get_fault_info() > + */ > + vcpu->arch.fault.hpfar_el2 = rec->run->exit.hpfar | HPFAR_EL2_NS; > + rec_exit_sync(vcpu); > + return ARM_EXCEPTION_TRAP; > + case RMI_EXIT_IRQ: > + case RMI_EXIT_FIQ: > + return ARM_EXCEPTION_IRQ; > + case RMI_EXIT_SERROR: > + return ARM_EXCEPTION_EL1_SERROR; > + case RMI_EXIT_PSCI: > + rec_exit_hvc(vcpu); > + kvm_make_request(KVM_REQ_RMI, vcpu); > + return ARM_EXCEPTION_TRAP; > + case RMI_EXIT_RIPAS_CHANGE: > + rec_exit_hvc(vcpu); > + return ARM_EXCEPTION_TRAP; > + } Should we handle RMI_EXIT_RIPAS_CHANGE differently? Currently, the call path is: kvm_rec_exit() -> RMI_EXIT_RIPAS_CHANGE -> handle_hvc() -> kvm_rec_handle_hvc() -> kvm_prepare_memory_fault_exit() Could we instead treat RMI_EXIT_RIPAS_CHANGE as a special case and avoid redirecting it through handle_hvc()? The completion part of the RIPAS change could still be handled by kvm_rec_handle_request(). -bool kvm_rec_handle_hvc(struct kvm_vcpu *vcpu, int *ret) +static int rec_exit_ripas_change(struct kvm_vcpu *vcpu) { - struct realm_rec *rec; + struct realm_rec *rec = &vcpu->arch.rec; struct realm *realm; unsigned long base; unsigned long ripas; unsigned long top; - if (!vcpu_is_rec(vcpu)) - return false; - - rec = &vcpu->arch.rec; - if (rec->run->exit.exit_reason != RMI_EXIT_RIPAS_CHANGE) - return false; - realm = &vcpu->kvm->arch.realm; base = rec->run->exit.ripas_base; top = rec->run->exit.ripas_top; @@ -89,8 +83,7 @@ bool kvm_rec_handle_hvc(struct kvm_vcpu *vcpu, int *ret) base, top, ripas); /* Set RMI_REJECT bit */ rec->run->enter.flags = REC_ENTER_FLAG_RIPAS_RESPONSE; - *ret = -EINVAL; - return true; + return -EINVAL; } /* Exit to VMM, the actual RIPAS change is done on next entry */ @@ -102,8 +95,7 @@ bool kvm_rec_handle_hvc(struct kvm_vcpu *vcpu, int *ret) * KVM_EXIT_MEMORY_FAULT requires a return code of -EFAULT, see the * API documentation */ - *ret = -EFAULT; - return true; + return -EFAULT; } int kvm_rec_exit(struct kvm_vcpu *vcpu, int rec_run_ret) @@ -169,8 +161,7 @@ int kvm_rec_exit(struct kvm_vcpu *vcpu, int rec_run_ret) kvm_make_request(KVM_REQ_RMI, vcpu); return ARM_EXCEPTION_TRAP; case RMI_EXIT_RIPAS_CHANGE: - rec_exit_hvc(vcpu); - return ARM_EXCEPTION_TRAP; + return rec_exit_ripas_change(vcpu); } return rec_exit_fatal(vcpu, "Unsupported Realm exit reason", -aneesh