[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220527080253.1562538-7-gshan@redhat.com>
Date: Fri, 27 May 2022 16:02:37 +0800
From: Gavin Shan <gshan@...hat.com>
To: kvmarm@...ts.cs.columbia.edu
Cc: maz@...nel.org, linux-kernel@...r.kernel.org, eauger@...hat.com,
oupton@...gle.com, Jonathan.Cameron@...wei.com,
pbonzini@...hat.com, vkuznets@...hat.com, will@...nel.org,
james.morse@....com, mark.rutland@....com,
shannon.zhaosl@...il.com, shijie@...eremail.onmicrosoft.com,
shan.gavin@...il.com
Subject: [PATCH v7 06/22] KVM: arm64: Support EVENT_CONTEXT hypercall
This supports EVENT_CONTEXT hypercall. It's called inside the event
handler to retrieve the specified register in the saved or preempted
context.
* The request is rejected if no running event handler exists or the
parameter ID is out of range.
Signed-off-by: Gavin Shan <gshan@...hat.com>
---
arch/arm64/kvm/sdei.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c
index a4046e7b21d8..2fec2dcd02b0 100644
--- a/arch/arm64/kvm/sdei.c
+++ b/arch/arm64/kvm/sdei.c
@@ -44,7 +44,7 @@ static unsigned long event_register(struct kvm_vcpu *vcpu)
static unsigned long event_enable(struct kvm_vcpu *vcpu, bool enable)
{
struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei;
- unsigned int num = smccc_get_arg(vcpu, 1);
+ int num = smccc_get_arg(vcpu, 1);
if (num >= KVM_NR_SDEI_EVENTS)
return SDEI_INVALID_PARAMETERS;
@@ -68,6 +68,23 @@ static unsigned long event_enable(struct kvm_vcpu *vcpu, bool enable)
return SDEI_SUCCESS;
}
+static unsigned long event_context(struct kvm_vcpu *vcpu)
+{
+ struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei;
+ struct kvm_sdei_event_context *ctxt = &vsdei->ctxt;
+ unsigned int param_id = smccc_get_arg(vcpu, 1);
+
+ /* Reject if event handler isn't running */
+ if (!vsdei->running)
+ return SDEI_DENIED;
+
+ /* Reject if the parameter ID is out of range */
+ if (param_id >= ARRAY_SIZE(ctxt->regs))
+ return SDEI_INVALID_PARAMETERS;
+
+ return ctxt->regs[param_id];
+}
+
int kvm_sdei_call(struct kvm_vcpu *vcpu)
{
struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei;
@@ -95,6 +112,9 @@ int kvm_sdei_call(struct kvm_vcpu *vcpu)
case SDEI_1_0_FN_SDEI_EVENT_DISABLE:
ret = event_enable(vcpu, false);
break;
+ case SDEI_1_0_FN_SDEI_EVENT_CONTEXT:
+ ret = event_context(vcpu);
+ break;
default:
ret = SDEI_NOT_SUPPORTED;
}
--
2.23.0
Powered by blists - more mailing lists