Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3526655pxb; Mon, 4 Apr 2022 19:59:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2NFUy3K8ZAW5hc4ElpWqnYavLmEPm47mB+AxeStBvdEuxTrLJo7T5/e8PZep2pEvZcrHC X-Received: by 2002:a17:902:7c08:b0:156:b9fe:b865 with SMTP id x8-20020a1709027c0800b00156b9feb865mr1172981pll.164.1649127548809; Mon, 04 Apr 2022 19:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649127548; cv=none; d=google.com; s=arc-20160816; b=lwCVljVtTrRzYw1qTCgWJpqCr7bKpQ9P1vP6X+V5oJODKnte6LazKihR92zJeMnnfR cr0WTmhHYLQyLKarPAv/76A0hKjwj57sCu6NX7W8z4yFCiMVCReHitPGPUPr6HuOPz8l WXD2Gy2xSlH/tTsXW37cFl3+TA1XPms0kMPGu5tt5YKA2IdD/K41Ca+d+i/2yUQw+T56 8WtLwDEWhYpEAk7HoeNEM/wo/zANo0MwcXc2dtRJHV9pRms9TGbPBN8QTHQ0ugbPzm7O gn0A/63+oOdzB+nYnHVeiBCENLzy8puDfVHBR0HLhCM6odljuVuR1GyMPRKUgXYfpMhH Tnsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8gXYZwt3oa1TLxdRQmFVOYT1n1r/hpVr+I1ttZPkVUo=; b=u920n6ZOhsPxch//JUz+KqL1gvqzODtDZGwifFELexm9sd9oUDAzPcjjm725i2dgx+ 6Mt9Y5EVT/QAbhpIsFiDblbWqhegkLKBCIiDjFxmTR7As8iqAL0RlFsbqOaPFr3iqAyn rFaByvg9gq+igKaoWAep8bgNRPVURb7kuyReoMfPLH/9H2NRjBrPbZnzFWE93gUMcjls 6tXEVv27ZxlN0CGotLB4CuiSTNGzXi3TtJJz4rlivZ8Sj02GFwYegI5tVz+qPQ0IJ9q6 1vHgiVt6vD7+IHZd2DWHj+/AbjiC5HNFHD/j76nAgDFZtHhuIfVOVaQ+8ZGAsUVoQ8Uu 4RzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gfW6boiA; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h66-20020a636c45000000b00398ab411828si11241215pgc.604.2022.04.04.19.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:59:08 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gfW6boiA; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5774C190E87; Mon, 4 Apr 2022 18:23:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359234AbiDCPmc (ORCPT + 99 others); Sun, 3 Apr 2022 11:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359248AbiDCPm0 (ORCPT ); Sun, 3 Apr 2022 11:42:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5325C2BB26 for ; Sun, 3 Apr 2022 08:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649000431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8gXYZwt3oa1TLxdRQmFVOYT1n1r/hpVr+I1ttZPkVUo=; b=gfW6boiAd9aYhaCP4FhP2KrqOc8Ph/lxjcwnL4+vnDAH8Anw71DjSfJMMhf1HEeWGrlZWI O4phgMu0sEG2SXFZxTr2nieXdAYWturi8wKgXjlHXI+s6v/B2OOq80vb//mg0jvmqqmYT0 hCWqWVPD9Y90oTmGusuMrOf5kE8n4SM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-x_1FQuIINQis-IQ714WaUQ-1; Sun, 03 Apr 2022 11:40:27 -0400 X-MC-Unique: x_1FQuIINQis-IQ714WaUQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD0891C04B41; Sun, 3 Apr 2022 15:40:26 +0000 (UTC) Received: from gshan.redhat.com (ovpn-12-82.pek2.redhat.com [10.72.12.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0C354538D7; Sun, 3 Apr 2022 15:40:20 +0000 (UTC) From: Gavin Shan To: kvmarm@lists.cs.columbia.edu Cc: linux-kernel@vger.kernel.org, eauger@redhat.com, oupton@google.com, Jonathan.Cameron@huawei.com, vkuznets@redhat.com, will@kernel.org, shannon.zhaosl@gmail.com, james.morse@arm.com, mark.rutland@arm.com, maz@kernel.org, pbonzini@redhat.com, shan.gavin@gmail.com Subject: [PATCH v6 08/18] KVM: arm64: Support SDEI_EVENT_STATUS hypercall Date: Sun, 3 Apr 2022 23:39:01 +0800 Message-Id: <20220403153911.12332-9-gshan@redhat.com> In-Reply-To: <20220403153911.12332-1-gshan@redhat.com> References: <20220403153911.12332-1-gshan@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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