[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220322080710.51727-10-gshan@redhat.com>
Date: Tue, 22 Mar 2022 16:06:57 +0800
From: Gavin Shan <gshan@...hat.com>
To: kvmarm@...ts.cs.columbia.edu
Cc: linux-kernel@...r.kernel.org, eauger@...hat.com,
shannon.zhaosl@...il.com, maz@...nel.org,
Jonathan.Cameron@...wei.com, will@...nel.org, pbonzini@...hat.com,
james.morse@....com, mark.rutland@....com, drjones@...hat.com,
vkuznets@...hat.com, shan.gavin@...il.com
Subject: [PATCH v5 09/22] KVM: arm64: Support SDEI_EVENT_GET_INFO hypercall
This supports SDEI_EVENT_GET_INFO hypercall. It's used by the guest
to retrieve various information about the exposed or registered event,
including type, signaled, routing mode and affinity. The routing
mode and affinity information is only valid to the shared and
registered event.
Signed-off-by: Gavin Shan <gshan@...hat.com>
---
arch/arm64/kvm/sdei.c | 73 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c
index 5c43c8912ea1..4f26e5f70bff 100644
--- a/arch/arm64/kvm/sdei.c
+++ b/arch/arm64/kvm/sdei.c
@@ -494,6 +494,77 @@ static unsigned long hypercall_status(struct kvm_vcpu *vcpu)
return ret;
}
+static unsigned long hypercall_info(struct kvm_vcpu *vcpu)
+{
+ struct kvm *kvm = vcpu->kvm;
+ struct kvm_sdei_kvm *ksdei = kvm->arch.sdei;
+ struct kvm_sdei_exposed_event *exposed_event = NULL;
+ struct kvm_sdei_registered_event *registered_event = NULL;
+ unsigned long event_num = smccc_get_arg1(vcpu);
+ unsigned long event_info = smccc_get_arg2(vcpu);
+ int index;
+ unsigned long ret = SDEI_SUCCESS;
+
+ if (!kvm_sdei_is_supported(event_num)) {
+ ret = SDEI_INVALID_PARAMETERS;
+ goto out;
+ }
+
+ spin_lock(&ksdei->lock);
+
+ /*
+ * Retrieve the information from the registered event if it exists.
+ * Otherwise, we turn into the exposed event if needed.
+ */
+ registered_event = find_registered_event(kvm, event_num);
+ exposed_event = registered_event ? registered_event->exposed_event :
+ find_exposed_event(kvm, event_num);
+ if (!exposed_event) {
+ ret = SDEI_INVALID_PARAMETERS;
+ goto unlock;
+ }
+
+ /* Retrieve the requested information */
+ switch (event_info) {
+ case SDEI_EVENT_INFO_EV_TYPE:
+ ret = exposed_event->state.type;
+ break;
+ case SDEI_EVENT_INFO_EV_SIGNALED:
+ ret = exposed_event->state.signaled;
+ break;
+ case SDEI_EVENT_INFO_EV_PRIORITY:
+ ret = exposed_event->state.priority;
+ break;
+ case SDEI_EVENT_INFO_EV_ROUTING_MODE:
+ case SDEI_EVENT_INFO_EV_ROUTING_AFF:
+ if (!kvm_sdei_is_shared(exposed_event->state.type)) {
+ ret = SDEI_INVALID_PARAMETERS;
+ break;
+ }
+
+ index = kvm_sdei_vcpu_index(vcpu, exposed_event);
+ if (!registered_event ||
+ !kvm_sdei_is_registered(registered_event, index)) {
+ ret = SDEI_DENIED;
+ break;
+ }
+
+ if (event_info == SDEI_EVENT_INFO_EV_ROUTING_MODE)
+ ret = registered_event->state.route_mode;
+ else
+ ret = registered_event->state.route_affinity;
+
+ break;
+ default:
+ ret = SDEI_INVALID_PARAMETERS;
+ }
+
+unlock:
+ spin_unlock(&ksdei->lock);
+out:
+ return ret;
+}
+
int kvm_sdei_hypercall(struct kvm_vcpu *vcpu)
{
struct kvm *kvm = vcpu->kvm;
@@ -543,6 +614,8 @@ int kvm_sdei_hypercall(struct kvm_vcpu *vcpu)
ret = hypercall_status(vcpu);
break;
case SDEI_1_0_FN_SDEI_EVENT_GET_INFO:
+ ret = hypercall_info(vcpu);
+ break;
case SDEI_1_0_FN_SDEI_EVENT_ROUTING_SET:
case SDEI_1_0_FN_SDEI_PE_MASK:
case SDEI_1_0_FN_SDEI_PE_UNMASK:
--
2.23.0
Powered by blists - more mailing lists