[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210209032733.99996-12-gshan@redhat.com>
Date: Tue, 9 Feb 2021 11:27:23 +0800
From: Gavin Shan <gshan@...hat.com>
To: kvmarm@...ts.cs.columbia.edu
Cc: linux-kernel@...r.kernel.org, pbonzini@...hat.com, maz@...nel.org,
james.morse@....com, Jonathan.Cameron@...wei.com,
mark.rutland@....com, will@...nel.org, shan.gavin@...il.com
Subject: [PATCH v2 11/21] KVM: arm64: Support SDEI_PE_{MASK, UNMASK} hypercall
This supports SDEI_PE_{MASK, UNMASK} hypercall. They are used by
the guest to stop the specific vCPU from receiving SDEI events.
Signed-off-by: Gavin Shan <gshan@...hat.com>
---
arch/arm64/kvm/sdei.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c
index 458695c2394f..3fb33258b494 100644
--- a/arch/arm64/kvm/sdei.c
+++ b/arch/arm64/kvm/sdei.c
@@ -551,6 +551,37 @@ static unsigned long kvm_sdei_hypercall_route(struct kvm_vcpu *vcpu)
return ret;
}
+static unsigned long kvm_sdei_hypercall_mask(struct kvm_vcpu *vcpu,
+ bool mask)
+{
+ struct kvm *kvm = vcpu->kvm;
+ struct kvm_sdei_kvm *ksdei = kvm->arch.sdei;
+ struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei;
+ unsigned long ret = SDEI_SUCCESS;
+
+ /* Sanity check */
+ if (!(ksdei && vsdei)) {
+ ret = SDEI_NOT_SUPPORTED;
+ goto out;
+ }
+
+ spin_lock(&vsdei->lock);
+
+ /* Check the state */
+ if (mask == vsdei->state.masked) {
+ ret = SDEI_DENIED;
+ goto unlock;
+ }
+
+ /* Update the state */
+ vsdei->state.masked = mask ? 1 : 0;
+
+unlock:
+ spin_unlock(&vsdei->lock);
+out:
+ return ret;
+}
+
int kvm_sdei_hypercall(struct kvm_vcpu *vcpu)
{
u32 func = smccc_get_function(vcpu);
@@ -588,7 +619,11 @@ int kvm_sdei_hypercall(struct kvm_vcpu *vcpu)
ret = kvm_sdei_hypercall_route(vcpu);
break;
case SDEI_1_0_FN_SDEI_PE_MASK:
+ ret = kvm_sdei_hypercall_mask(vcpu, true);
+ break;
case SDEI_1_0_FN_SDEI_PE_UNMASK:
+ ret = kvm_sdei_hypercall_mask(vcpu, false);
+ break;
case SDEI_1_0_FN_SDEI_INTERRUPT_BIND:
case SDEI_1_0_FN_SDEI_INTERRUPT_RELEASE:
case SDEI_1_0_FN_SDEI_PRIVATE_RESET:
--
2.23.0
Powered by blists - more mailing lists