Re: [PATCH v16 21/45] KVM: arm64: CCA: Handle realm enter/exit

Steven Price <[email protected]>
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]>
On 04/08/2026 14:36, Aneesh Kumar K.V wrote:
> 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);
>>
> 
> I'm also wondering whether we can move the kvm_make_request() call until
> after the PSCI/HOST_CALL handling is complete. I tried a quick hack, but
> it did not look particularly clean, since we would end up adding
> RMM-specific checks in handle_hvc():
> 
> ret = kvm_smccc_call_handler(vcpu);
> 
> if (vcpu_is_rec(vcpu) &&
>     (vcpu->arch.rec.run->exit.exit_reason == RMI_EXIT_PSCI ||
>      vcpu->arch.rec.run->exit.exit_reason == RMI_EXIT_HOST_CALL))
> 	kvm_make_request(KVM_REQ_RMI, vcpu);
> 
> That said, having rec_exit_hvc(vcpu) and kvm_make_request() back-to-back
> is also somewhat confusing. Perhaps we could at least add a comment
> explaining why the request must always be made here.

Agreed, a comment would make it clearer what's going on. I'll add that.
As you say I'm not convinced trying to delay the kvm_make_request() call
is the answer because it ends up with an ugly RMM-specific check.

Thanks,
Steve

> 
>> +		return ARM_EXCEPTION_TRAP;
>> +	case RMI_EXIT_RIPAS_CHANGE:
>> +		rec_exit_hvc(vcpu);
>> +		return ARM_EXCEPTION_TRAP;
>> +	}
>> +
>> +	return rec_exit_fatal(vcpu, "Unsupported Realm exit reason",
>> +			      rec->run->exit.exit_reason);
>> +}
> 
> -aneesh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.