[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220403153911.12332-10-gshan@redhat.com>
Date: Sun, 3 Apr 2022 23:39:02 +0800
From: Gavin Shan <gshan@...hat.com>
To: kvmarm@...ts.cs.columbia.edu
Cc: linux-kernel@...r.kernel.org, eauger@...hat.com, oupton@...gle.com,
Jonathan.Cameron@...wei.com, vkuznets@...hat.com, will@...nel.org,
shannon.zhaosl@...il.com, james.morse@....com,
mark.rutland@....com, maz@...nel.org, pbonzini@...hat.com,
shan.gavin@...il.com
Subject: [PATCH v6 09/18] KVM: arm64: Support SDEI_EVENT_GET_INFO hypercall
This supports SDEI_EVENT_GET_INFO hypercall. It's used by guest
to retrieve various information about the event: type, signaled,
priority, routing mode and affinity. SDEI_INVALID_PARAMETERS is
returned for the requests about routing mode and affinity as
they are only valid for the shared event, which isn't supported.
Signed-off-by: Gavin Shan <gshan@...hat.com>
---
arch/arm64/kvm/sdei.c | 54 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c
index b847c6028b74..9e642d01e303 100644
--- a/arch/arm64/kvm/sdei.c
+++ b/arch/arm64/kvm/sdei.c
@@ -289,6 +289,57 @@ static unsigned long hypercall_status(struct kvm_vcpu *vcpu)
return ret;
}
+static unsigned long hypercall_info(struct kvm_vcpu *vcpu)
+{
+ struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei;
+ struct kvm_sdei_exposed_event *exposed_event;
+ struct kvm_sdei_event *event;
+ unsigned int num = smccc_get_arg(vcpu, 1);
+ unsigned long info = smccc_get_arg(vcpu, 2);
+ unsigned long ret = SDEI_SUCCESS;
+
+ if (!kvm_sdei_is_supported(num)) {
+ ret = SDEI_INVALID_PARAMETERS;
+ goto out;
+ }
+
+ spin_lock(&vsdei->lock);
+
+ /* Check if the event exists */
+ event = find_event(vcpu, num);
+ if (!event) {
+ ret = SDEI_INVALID_PARAMETERS;
+ goto unlock;
+ }
+
+ /*
+ * Retrieve the requested information. The shared events aren't
+ * supported yet. So the requests to retrieve routing mode and
+ * affinity should fail for now.
+ */
+ exposed_event = event->exposed_event;
+ switch (info) {
+ case SDEI_EVENT_INFO_EV_TYPE:
+ ret = exposed_event->type;
+ break;
+ case SDEI_EVENT_INFO_EV_SIGNALED:
+ ret = exposed_event->signaled;
+ break;
+ case SDEI_EVENT_INFO_EV_PRIORITY:
+ ret = exposed_event->priority;
+ break;
+ case SDEI_EVENT_INFO_EV_ROUTING_MODE:
+ case SDEI_EVENT_INFO_EV_ROUTING_AFF:
+ default:
+ ret = SDEI_INVALID_PARAMETERS;
+ }
+
+unlock:
+ spin_unlock(&vsdei->lock);
+out:
+ return ret;
+}
+
int kvm_sdei_call(struct kvm_vcpu *vcpu)
{
struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei;
@@ -328,6 +379,9 @@ int kvm_sdei_call(struct kvm_vcpu *vcpu)
case SDEI_1_0_FN_SDEI_EVENT_STATUS:
ret = hypercall_status(vcpu);
break;
+ case SDEI_1_0_FN_SDEI_EVENT_GET_INFO:
+ ret = hypercall_info(vcpu);
+ break;
default:
ret = SDEI_NOT_SUPPORTED;
}
--
2.23.0
Powered by blists - more mailing lists