lkml.org 
[lkml]   [2022]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v6 08/18] KVM: arm64: Support SDEI_EVENT_STATUS hypercall
    Date
    This supports SDEI_EVENT_STATUS hypercall. It's used by guest
    to retrieve the status about the specified event. A bitmap is
    returned to indicate the corresponding status: registration,
    enablement and servicing state.

    Signed-off-by: Gavin Shan <gshan@redhat.com>
    ---
    arch/arm64/kvm/sdei.c | 45 +++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 45 insertions(+)

    diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c
    index f774f2cf0ac7..b847c6028b74 100644
    --- a/arch/arm64/kvm/sdei.c
    +++ b/arch/arm64/kvm/sdei.c
    @@ -247,6 +247,48 @@ static unsigned long hypercall_unregister(struct kvm_vcpu *vcpu)
    return ret;
    }

    +static unsigned long hypercall_status(struct kvm_vcpu *vcpu)
    +{
    + struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei;
    + struct kvm_sdei_vcpu_context *context;
    + struct kvm_sdei_exposed_event *exposed_event;
    + struct kvm_sdei_event *event;
    + unsigned int num = smccc_get_arg(vcpu, 1);
    + unsigned long ret = 0;
    +
    + if (!kvm_sdei_is_supported(num)) {
    + ret = SDEI_INVALID_PARAMETERS;
    + goto out;
    + }
    +
    + spin_lock(&vsdei->lock);
    +
    + /*
    + * Check if the event exists. None of the flags will be set
    + * if it doesn't exist.
    + */
    + event = find_event(vcpu, num);
    + if (!event)
    + goto unlock;
    +
    + if (kvm_sdei_is_registered(event))
    + ret |= (1UL << SDEI_EVENT_STATUS_REGISTERED);
    + if (kvm_sdei_is_enabled(event))
    + ret |= (1UL << SDEI_EVENT_STATUS_ENABLED);
    +
    + exposed_event = event->exposed_event;
    + context = kvm_sdei_is_critical(exposed_event->priority) ?
    + &vsdei->context[SDEI_EVENT_PRIORITY_CRITICAL] :
    + &vsdei->context[SDEI_EVENT_PRIORITY_NORMAL];
    + if (context->event == event)
    + ret |= (1UL << SDEI_EVENT_STATUS_RUNNING);
    +
    +unlock:
    + spin_unlock(&vsdei->lock);
    +out:
    + return ret;
    +}
    +
    int kvm_sdei_call(struct kvm_vcpu *vcpu)
    {
    struct kvm_sdei_vcpu *vsdei = vcpu->arch.sdei;
    @@ -283,6 +325,9 @@ int kvm_sdei_call(struct kvm_vcpu *vcpu)
    case SDEI_1_0_FN_SDEI_EVENT_UNREGISTER:
    ret = hypercall_unregister(vcpu);
    break;
    + case SDEI_1_0_FN_SDEI_EVENT_STATUS:
    + ret = hypercall_status(vcpu);
    + break;
    default:
    ret = SDEI_NOT_SUPPORTED;
    }
    --
    2.23.0
    \
     
     \ /
      Last update: 2022-04-03 17:41    [W:2.548 / U:0.040 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site