This supports SDEI_1_0_FN_SDEI_EVENT_CONTEXT hypercall by implementing kvm_sdei_hypercall_context(). If there is valid context on the current vCPU and the register index isn't out of scope, the register values are returned. Otherwise, errno is returned. Signed-off-by: Gavin Shan <gshan@xxxxxxxxxx> --- arch/arm64/kvm/sdei.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index cf6908e87edd..0c5a16e8cbac 100644 --- a/arch/arm64/kvm/sdei.c +++ b/arch/arm64/kvm/sdei.c @@ -590,6 +590,35 @@ static unsigned long kvm_sdei_hypercall_enable(struct kvm_vcpu *vcpu, return ret; } +static unsigned long kvm_sdei_hypercall_context(struct kvm_vcpu *vcpu) +{ + struct user_pt_regs *regs; + unsigned long index = smccc_get_arg1(vcpu); + unsigned long ret = SDEI_SUCCESS; + + if (index > 17) { + ret = SDEI_INVALID_PARAMETERS; + goto out; + } + + spin_lock(&vcpu->arch.sdei_lock); + + if (vcpu->arch.sdei_critical_event) { + regs = &vcpu->arch.sdei_critical_regs; + } else if (vcpu->arch.sdei_normal_event) { + regs = &vcpu->arch.sdei_normal_regs; + } else { + ret = SDEI_DENIED; + goto unlock; + } + + ret = regs->regs[index]; +unlock: + spin_unlock(&vcpu->arch.sdei_lock); +out: + return ret; +} + static unsigned long kvm_sdei_hypercall_complete(struct kvm_vcpu *vcpu, bool resume) { @@ -1075,7 +1104,7 @@ int kvm_sdei_hypercall(struct kvm_vcpu *vcpu) ret = kvm_sdei_hypercall_enable(vcpu, false); break; case SDEI_1_0_FN_SDEI_EVENT_CONTEXT: - ret = SDEI_NOT_SUPPORTED; + ret = kvm_sdei_hypercall_context(vcpu); break; case SDEI_1_0_FN_SDEI_EVENT_COMPLETE: has_result = false; -- 2.23.0 _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm