From nobody Mon Feb 9 16:47:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1569339697; cv=none; d=zoho.com; s=zohoarc; b=KXM+rmLU4fmD0uLNm0ZdPxuqzzIS3Zgz6/wpoFRKcO1DAqqlRPACR2baLTIXQVLcF7Amztuqk+kdVScKM45DAnDafChRsg6b/uaHtZo5F9UeBbgjjXbG7Cp3AD0ssCfLck/PqM9LpuzEX1dWSITosQl562gD+ToXbW/3cm2lIz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569339697; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oBwbCPZ7ugU3LWovtaW5F6O/qYDn5839tEDOf4EdNXo=; b=mk9JrSK1vDD2K+ze341TFBaXtT7wPxAHA6UXt+kusUlXMePv2nGYONvZiKgdXMNkEfWyXKwd6E2zdk5CDH7UhETpNOsbneu2mQYAstcKkqB7+kSsigRqYC4XPZIFEblFZwMcfEYCuBBsDnxiuTstGl2WW/a1yUcB0lzUWZwHfpQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156933969702891.76646465805561; Tue, 24 Sep 2019 08:41:37 -0700 (PDT) Received: from localhost ([::1]:47312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCmwT-0001GH-Q5 for importer@patchew.org; Tue, 24 Sep 2019 11:41:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48379) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCmfD-0001Q0-Tw for qemu-devel@nongnu.org; Tue, 24 Sep 2019 11:23:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCmfB-0006nk-Va for qemu-devel@nongnu.org; Tue, 24 Sep 2019 11:23:39 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:46724 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCmf4-0006hR-LV; Tue, 24 Sep 2019 11:23:31 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 5EA36BE9A1306E7B3A53; Tue, 24 Sep 2019 23:23:27 +0800 (CST) Received: from linux-Bxxcye.huawei.com (10.175.104.222) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Tue, 24 Sep 2019 23:23:17 +0800 From: Heyi Guo To: , , , Subject: [RFC PATCH 05/12] arm/sdei: add support to trigger event by GIC interrupt ID Date: Tue, 24 Sep 2019 23:21:44 +0800 Message-ID: <1569338511-3572-6-git-send-email-guoheyi@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1569338511-3572-1-git-send-email-guoheyi@huawei.com> References: <1569338511-3572-1-git-send-email-guoheyi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.104.222] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.35 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Peter Maydell , Marc Zyngier , James Morse , Heyi Guo , wanghaibin.wang@huawei.com, Dave Martin Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add an external interface to trigger an SDEI event bound to an interrupt by providing GIC interrupt ID. Signed-off-by: Heyi Guo Cc: Peter Maydell Cc: Dave Martin Cc: Marc Zyngier Cc: Mark Rutland Cc: James Morse --- target/arm/sdei.c | 38 ++++++++++++++++++++++++++++++++++++++ target/arm/sdei.h | 7 +++++++ 2 files changed, 45 insertions(+) diff --git a/target/arm/sdei.c b/target/arm/sdei.c index f9a1208..088ed76 100644 --- a/target/arm/sdei.c +++ b/target/arm/sdei.c @@ -453,6 +453,29 @@ static int64_t sdei_version(QemuSDEState *s, CPUState = *cs, struct kvm_run *run) (0ULL << SDEI_VERSION_MINOR_SHIFT); } =20 +static bool inject_event(QemuSDEState *s, CPUState *cs, + int32_t event, int irq) +{ + QemuSDE *sde; + + if (event < 0) { + return false; + } + sde =3D get_sde_no_check(s, event, cs); + if (sde->event_id =3D=3D SDEI_INVALID_EVENT_ID) { + put_sde(sde, cs); + return false; + } + if (irq > 0 && sde->prop->interrupt !=3D irq) { + /* Someone unbinds the interrupt! */ + put_sde(sde, cs); + return false; + } + sde->pending =3D true; + dispatch_single(s, sde, cs); + return true; +} + static int64_t unregister_single_sde(QemuSDEState *s, int32_t event, CPUState *cs, bool force) { @@ -1033,6 +1056,21 @@ void sdei_handle_request(CPUState *cs, struct kvm_ru= n *run) } } =20 +bool trigger_sdei_by_irq(int cpu, int irq) +{ + QemuSDEState *s =3D sde_state; + + if (!s || irq >=3D ARRAY_SIZE(s->irq_map)) { + return false; + } + + if (s->irq_map[irq] =3D=3D SDEI_INVALID_EVENT_ID) { + return false; + } + + return inject_event(s, arm_get_cpu_by_id(cpu), s->irq_map[irq], irq); +} + static void qemu_shared_sde_init(QemuSDEState *s) { int i; diff --git a/target/arm/sdei.h b/target/arm/sdei.h index a69a0e4..a61e788 100644 --- a/target/arm/sdei.h +++ b/target/arm/sdei.h @@ -31,4 +31,11 @@ =20 void sdei_handle_request(CPUState *cs, struct kvm_run *run); =20 +/* + * Trigger an SDEI event bound to an interrupt. + * Return true if event has been triggered successfully. + * Return false if event has not been triggered for some reason. + */ +bool trigger_sdei_by_irq(int cpu, int irq); + #endif --=20 1.8.3.1