From: Gavin Shan <gshan@redhat.com>
To: kvmarm@lists.cs.columbia.edu
Cc: maz@kernel.org, shan.gavin@gmail.com, pbonzini@redhat.com
Subject: [PATCH 11/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_ROUTING_SET hypercall
Date: Mon, 17 Aug 2020 20:05:24 +1000 [thread overview]
Message-ID: <20200817100531.83045-12-gshan@redhat.com> (raw)
In-Reply-To: <20200817100531.83045-1-gshan@redhat.com>
This supports SDEI_1_0_FN_SDEI_EVENT_ROUTING_SET hypercall by adding
kvm_sdei_hypercall_route(). On success, the specified routing mode
and affinity is set. Otherwise, errno is returned. The route mode
or affinity is updated to the KVM SDEI event.
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
arch/arm64/kvm/sdei.c | 74 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c
index 529505c4f0cf..1e7291acea0d 100644
--- a/arch/arm64/kvm/sdei.c
+++ b/arch/arm64/kvm/sdei.c
@@ -585,6 +585,78 @@ static unsigned long kvm_sdei_hypercall_info(struct kvm_vcpu *vcpu)
return ret;
}
+static unsigned long kvm_sdei_hypercall_route(struct kvm_vcpu *vcpu)
+{
+ struct kvm *kvm = vcpu->kvm;
+ struct kvm_sdei_event *event = NULL;
+ struct kvm_sdei_kvm_event *kevent = NULL;
+ unsigned long event_num = smccc_get_arg1(vcpu);
+ unsigned long route_mode = smccc_get_arg2(vcpu);
+ unsigned long route_affinity = smccc_get_arg3(vcpu);
+ unsigned long event_type;
+ int index = 0;
+ unsigned long ret = SDEI_SUCCESS;
+
+ /* Validate the parameters */
+ if (!kvm_sdei_num_is_valid(event_num)) {
+ ret = SDEI_INVALID_PARAMETERS;
+ goto out;
+ }
+
+ if (!(kvm_sdei_data && kvm_sdei_data->supported) &&
+ kvm_sdei_num_is_virt(event_num)) {
+ ret = SDEI_INVALID_PARAMETERS;
+ goto out;
+ }
+
+ if (!(route_mode == SDEI_EVENT_REGISTER_RM_ANY ||
+ route_mode == SDEI_EVENT_REGISTER_RM_PE)) {
+ ret = SDEI_INVALID_PARAMETERS;
+ goto out;
+ }
+
+ /* Find the event */
+ spin_lock(&kvm_sdei_lock);
+ event = kvm_sdei_find_event(kvm, event_num, &kevent, NULL, NULL);
+ if (!kevent) {
+ ret = SDEI_INVALID_PARAMETERS;
+ goto unlock;
+ }
+
+ /* Sanity check */
+ spin_lock(&event->lock);
+ event_type = event->priv ? event->priv->type : event->event->type;
+ index = (event_type == SDEI_EVENT_TYPE_PRIVATE) ? vcpu->vcpu_idx : 0;
+ if (event_type != SDEI_EVENT_TYPE_SHARED) {
+ ret = SDEI_INVALID_PARAMETERS;
+ goto unlock_event;
+ }
+
+ if (!test_bit(index, kevent->registered) ||
+ test_bit(index, kevent->enabled) ||
+ kevent->users) {
+ ret = SDEI_DENIED;
+ goto unlock_event;
+ }
+
+ if (route_mode == kevent->route_mode &&
+ route_affinity == kevent->route_affinity) {
+ ret = SDEI_DENIED;
+ goto unlock_event;
+ }
+
+ /* Update status */
+ kevent->route_mode = route_mode;
+ kevent->route_affinity = route_affinity;
+
+unlock_event:
+ spin_unlock(&event->lock);
+unlock:
+ spin_unlock(&kvm_sdei_lock);
+out:
+ return ret;
+}
+
static unsigned long kvm_sdei_reset(struct kvm *kvm, unsigned int types)
{
struct kvm_sdei_event *e, *event = NULL;
@@ -680,6 +752,8 @@ int kvm_sdei_hypercall(struct kvm_vcpu *vcpu)
ret = kvm_sdei_hypercall_info(vcpu);
break;
case SDEI_1_0_FN_SDEI_EVENT_ROUTING_SET:
+ ret = kvm_sdei_hypercall_route(vcpu);
+ break;
case SDEI_1_0_FN_SDEI_PE_MASK:
case SDEI_1_0_FN_SDEI_PE_UNMASK:
case SDEI_1_0_FN_SDEI_INTERRUPT_BIND:
--
2.23.0
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next prev parent reply other threads:[~2020-08-17 10:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-17 10:05 [PATCH 00/18] Support SDEI Virtualization Gavin Shan
2020-08-17 10:05 ` [PATCH 01/18] drivers/firmware/sdei: Retrieve event signaled property on registration Gavin Shan
2020-08-17 10:05 ` [PATCH 02/18] drivers/firmware/sdei: Add sdei_event_get_info() Gavin Shan
2020-08-17 10:05 ` [PATCH 03/18] arm/smccc: Introduce template for inline functions Gavin Shan
2020-08-17 10:05 ` [PATCH 04/18] arm64/kvm: Add SDEI virtualization infrastructure Gavin Shan
2020-08-17 10:05 ` [PATCH 05/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_VERSION hypercall Gavin Shan
2020-08-17 10:05 ` [PATCH 06/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_REGISTER Gavin Shan
2020-08-17 10:05 ` [PATCH 07/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_{ENABLE, DISABLE} hypercall Gavin Shan
2020-08-17 10:05 ` [PATCH 08/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_UNREGISTER hypercall Gavin Shan
2020-08-17 10:05 ` [PATCH 09/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_STATUS hypercall Gavin Shan
2020-08-17 10:05 ` [PATCH 10/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_GET_INFO hypercall Gavin Shan
2020-08-17 10:05 ` Gavin Shan [this message]
2020-08-17 10:05 ` [PATCH 12/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_PE_{MASK, UNMASK} hypercall Gavin Shan
2020-08-17 10:05 ` [PATCH 13/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_{PRIVATE, SHARED}_RESET hypercall Gavin Shan
2020-08-17 10:05 ` [PATCH 14/18] arm64/kvm: Implement event handler Gavin Shan
2020-08-17 10:05 ` [PATCH 15/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_{COMPLETE, COMPLETE_AND_RESUME} hypercall Gavin Shan
2020-08-17 10:05 ` [PATCH 16/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_CONTEXT hypercall Gavin Shan
2020-08-17 10:05 ` [PATCH 17/18] arm64/kvm: Expose SDEI capability Gavin Shan
2020-08-17 10:05 ` [PATCH 18/18] kvm/selftests: Add SDEI test case Gavin Shan
2020-08-17 11:01 ` [PATCH 00/18] Support SDEI Virtualization Gavin Shan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200817100531.83045-12-gshan@redhat.com \
--to=gshan@redhat.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=maz@kernel.org \
--cc=pbonzini@redhat.com \
--cc=shan.gavin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).