From patchwork Sun Jan 14 10:01:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mykyta Poturai X-Patchwork-Id: 13519131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48B38C47258 for ; Sun, 14 Jan 2024 10:02:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.667096.1038110 (Exim 4.92) (envelope-from ) id 1rOxJm-0006Do-KG; Sun, 14 Jan 2024 10:02:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 667096.1038110; Sun, 14 Jan 2024 10:02:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rOxJm-0006DS-E8; Sun, 14 Jan 2024 10:02:14 +0000 Received: by outflank-mailman (input) for mailman id 667096; Sun, 14 Jan 2024 10:02:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rOxJk-0006AA-M9 for xen-devel@lists.xenproject.org; Sun, 14 Jan 2024 10:02:12 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id faad8ca0-b2c3-11ee-9b0f-b553b5be7939; Sun, 14 Jan 2024 11:02:09 +0100 (CET) Received: from pps.filterd (m0174681.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40E29Aas013393; Sun, 14 Jan 2024 10:01:56 GMT Received: from eur05-am6-obe.outbound.protection.outlook.com (mail-am6eur05lp2104.outbound.protection.outlook.com [104.47.18.104]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3vkmj1hsv6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 14 Jan 2024 10:01:55 +0000 (GMT) Received: from AS2PR03MB10110.eurprd03.prod.outlook.com (2603:10a6:20b:57a::22) by AM9PR03MB7725.eurprd03.prod.outlook.com (2603:10a6:20b:41e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.23; Sun, 14 Jan 2024 10:01:53 +0000 Received: from AS2PR03MB10110.eurprd03.prod.outlook.com ([fe80::9640:139b:8daa:fc9e]) by AS2PR03MB10110.eurprd03.prod.outlook.com ([fe80::9640:139b:8daa:fc9e%3]) with mapi id 15.20.7181.022; Sun, 14 Jan 2024 10:01:52 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: faad8ca0-b2c3-11ee-9b0f-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=az7Pllc578GTJzSzL8AZ/0iYuGnobWL2iagFKGcP3xT9JiMIFeodAWViF9R2k66FsAFPBY2jbKdfNSySCLX3kZQRKmCX1eWY0BSW68NPQq6iQeY6Tfm6piGkuzabCRTTZfWiaBxDiue0YuX1s0byCjwKkccfSwksaFCFRnTZhy4KtPpOq+yRR8Khg7bTm8+VeT1HlLUlfJMqOQ3fD8EmsCLIpv1mnU4omaTLMfpqzvhk1pxRmdfsR5eZjiPa7nDzb8JxsBem1jSaZdJnge1inf0LYHTPeKZsXsywmFZTCw8g18Zj9nqEmWkpCLe850TQc1yWuZDhNWBSqsJbfXDaiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=baf0t9FWoP6jlnYrKU9AwSGWPTgwixnTUwKMBjpqAJQ=; b=HIpxxNZu9gArgo3iXeT9IWzwOFwZA/qLsGxUkNHvzrmHmWIg0KLKq+GeW7d/mG2xC2ofaeJsgercVopvgLl7z7IM92I7GqF8TuzoyLK/1ofBLqHqEBVDWcvP6se9HDXZ/cZsckMXs2OTB1iKCatA8mC9WLzePCnDO5oy9xQrvMjE1YKZC6f12yzT+/CG9/CcMCnpnCqMLQHsE+o0Y9bSZb2r8gHBZFJR0whCPb7iE3wmLW1WzD5e/MjSOtD4bL2waaOOAoxIHDIc3ZB9Mq2ljbc8uiObrJmDR9ZpsZNLT1cC0O5CpambEH5Ev79XfZ0Mde1VOMNDiIh/5y4ItFKXLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=baf0t9FWoP6jlnYrKU9AwSGWPTgwixnTUwKMBjpqAJQ=; b=dm1aaQ0jWjFsUR3PRzp/9xfLm39j7V8yUAjNjzakCR0nQDlQx5gKvsRKP8/rLgN0KdxZzS1BpCGoWFKA8NhRTR/BzpjqI+4ndpbF7pI8Q3VudoKukvRmIZKqpAlvHvuRWblsl2crSRvZFTx+yu0P/w+Hnmqt+/CK0C76skEg0Xv6i8Qkd4qG6GmqIKiZ66edjjzOfVYxe0uDDJjzxnMhBsIyB22rQZ0zv8gOWMXAh8TCpckDqcZ/5/13DFAh9ZIZE9dPMMG6rGEBD0dpA3rUJxEvvjP1CqIv3AmB+vSxn8dNKp1DaG1mbNNpckAo8xhzMo+lOZK1S2mJrXplaHUDew== From: Mykyta Poturai To: "xen-devel@lists.xenproject.org" CC: Mykyta Poturai , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH 1/2] arm: vgic: Add the ability to trigger MSIs from the Hypervisor Thread-Topic: [PATCH 1/2] arm: vgic: Add the ability to trigger MSIs from the Hypervisor Thread-Index: AQHaRtCyuPXvgfJKsESPEkC3vc4pGw== Date: Sun, 14 Jan 2024 10:01:52 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS2PR03MB10110:EE_|AM9PR03MB7725:EE_ x-ms-office365-filtering-correlation-id: 1fd52959-07ed-4437-f492-08dc14e7d4d4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0eTX8mrXON6rqetiij/MU0Tt/ziBqJBqk34KFyMqVXbiGw04NlZGxPddDy6esNbvmv2qrFFzjhB25lMKaHJPyFy1yydC3P6kIecMcDmNvtCQfJPvk9ZQaqHM2rFfitRdP5Ezntr5zmYFLbPOCAbKDyVyXujLK9Z+Bobrij08XbYSLUIBmbVL/I3Ws1oOd++UU6yGXMbmsSEp0sJcCIi/dqwH8jcKpEf+SGDLFDJHE4hjV+HhEH0BdbuYnSdxwmRgbGP85+NnSQ2p8XN4/1QPV5knKosiJBW5TN4IeicuGnbBhkcbh+HLXV5WfmsukPEAG5rx8yx30HEYVxmZx8zQN/t0S2B9W1L+20wpzMV3r3zW8Eml4KzAMan7W2WgZgG5bjR7lP7nA1YRQtg+vHY0+WvCq3dFH9xNc/xxHaU67be2onFsIBSZZGNrwjfP46St/BmS188jDIQ88z9xQP27LsBLUsDKSs8GvuekQVpu+/BtAFDh8R4lRe91VAGdH8/McLfnA4oKs5zMW7g6fUJbjwOOQ3DbqxzZX7P+JLuER0K1aSO+lzaOfq4BrfEvUTsYSZU0k4ZndcTb9qT3uTM55mKa75RH/8p0QJKFQw3xE+T4KgQGVtDKeFqVdUuvmAtJ x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS2PR03MB10110.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(366004)(136003)(39860400002)(396003)(376002)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(6512007)(316002)(8936002)(8676002)(91956017)(71200400001)(66476007)(64756008)(66446008)(54906003)(6916009)(6506007)(66556008)(478600001)(66946007)(6486002)(76116006)(2616005)(107886003)(83380400001)(26005)(5660300002)(4326008)(41300700001)(2906002)(38070700009)(36756003)(122000001)(38100700002)(86362001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?ZVJ5LMZrRC2xBpJifxCotKk?= =?iso-8859-1?q?BUNgbqmP5md1clL3Onw5ocIb0ba9lznlBcs11N9/eMkSvMRfyeIBv0cO5PX8?= =?iso-8859-1?q?okgyGlcEUd2iCMpJpceD4ETxeGglTlOWgSn+83uug0KqmY4x0XfrvYV26pj/?= =?iso-8859-1?q?XcvkG2eRiRkQMHFx0afBKBlqgQ6S1CUwEox8yED84GOvP3cDyUk8M3w36PhK?= =?iso-8859-1?q?WR2caXX4RB6ebD/h5rhr075Y0ey2twQT5yumKBWlyP5gDTguBVhAbDJNpr2e?= =?iso-8859-1?q?M+DGUrUy8hSLwM9emQ5xWHzDr4x6NbW34Yni7Q7YOs1fKfDIO+hce9yC6Oye?= =?iso-8859-1?q?T3kfXsiL9xdTcOGORbhTSgIaAw81GdJMKC1SY3g1fxksS7+E2duLK94qZ3xh?= =?iso-8859-1?q?x+IO60cDKw9sHowssVgg0qUBuGX5RYq+DBrvuLhaVs8bDu+KCthWcHN+6JgY?= =?iso-8859-1?q?Wbv/CDXFRHFscHDS1eAaFfoxAoaWrh9uhQgOQJo7iqXu+kD9cYtIcRV/yw9n?= =?iso-8859-1?q?ISusVxvKuxdFU/Yto9ea69gt/AqTegY5Y5Y/W2nnx/gs4LW8ta4vQSdRv7/o?= =?iso-8859-1?q?RjLFbO21FyprOxfTOZ81wygzoqAG7fO6shdvsA/MdnqPfMGLA0xlmXBClA8B?= =?iso-8859-1?q?VQ8p0ylgYH4wNnifFfXed25ZbNvb8sjr3QWFmHF8tr9NsH4Z0tclwKIibhZz?= =?iso-8859-1?q?aI+MG3KKPw4b1IwhMStycZeoWmJLx4u0wrhye0IBF3Fh4Tg+yWIYKyZvqygD?= =?iso-8859-1?q?N2igAkCKcfBJIce9hOw8y8uAGAdLdJEtgsqitlxt1vakNty9cuX02DfzPoXU?= =?iso-8859-1?q?hFUm2EmRUYZ8HjZtBUB2+wmO6JOwyWsSPQa3c7jbr39PvI9EX7qLx5NzRABL?= =?iso-8859-1?q?HH4CClNXfYk0ipSWfvdXM6dadKLsf2FlmzNxiOK8DNztARo9y1woOgTWrZ/Z?= =?iso-8859-1?q?4UvsDH2zfiYv2IRnHZ6jtDbMjqTGrWfoQTuXcPT0dhqfzgX/4MB5k7XAKG9y?= =?iso-8859-1?q?jqnqQOsqrbZsUDCItztzoQsOHo95/HCQBqgN+YnGOZCFNbbR/2lqsmc7zqF1?= =?iso-8859-1?q?iyTayGByiX/Gvb9PAO3GO/EzlQjca/ANZLHnEpwg98MG5gDZA4NmDx02TUju?= =?iso-8859-1?q?PGHCU+fFuXSS6GHGc/x0X7GVDFcaax3xPXLcr6KKjYtVhz9XANStjNOLtSB9?= =?iso-8859-1?q?ZojC+rnUDUUiGUCsrh8gJlOfleTt7zTlm0LJsIbj2jKCB8riDwL21Evx6dlK?= =?iso-8859-1?q?J2C3y3Sbb/c3xJ7HV7WZdAA04EznsVVjwMxIhJQuGnSxiqk2nsHSNJSFabT2?= =?iso-8859-1?q?aTBvCMTXDJ2lVq6qL4m2l6PNKW0V/P/otBS8dGCRJenN5nZZ5TtiOxHNMNIP?= =?iso-8859-1?q?aUFgX8aSAvdqpehXuHq2Ip5cS6HJflyvL6REb6MxZ2UfEqmWO5+j3+VTzzUX?= =?iso-8859-1?q?u3N55waMrMsCqHPL0C70p1gvs72jZNREFZPUtopqEUdwWY/Q5VRqY8ctg35G?= =?iso-8859-1?q?wHO8hAmCubNQx2lo49JsBJkAyrr5E8nk1JKdq4oRK+q1/u3kE9LdXb5Cohh+?= =?iso-8859-1?q?Jzh/ZkzOBEkXZBossTPy2LyCSQyfo/8kTVXwpsCgONpohOIEaph+kD86wPj4?= =?iso-8859-1?q?DOvtcGrbYxcmr1Xv0KhS//3453UcCV/h3vPamHw=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS2PR03MB10110.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1fd52959-07ed-4437-f492-08dc14e7d4d4 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jan 2024 10:01:52.0356 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: tp5mkFgci2DsqNasRSLr1t0NHI3IG//GRCWB0lMcQOogjKgbLEjp0zGAtKDNiH6Qpo3hbhc5KYRKFLpS2Zy53g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR03MB7725 X-Proofpoint-GUID: 4ySXo3ywPZaZD4uk7qmNZ_U2SSVffQo9 X-Proofpoint-ORIG-GUID: 4ySXo3ywPZaZD4uk7qmNZ_U2SSVffQo9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=946 suspectscore=0 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 mlxscore=0 phishscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401140078 Add the vgic_its_trigger_msi() function to the vgic interface. This function allows to inject MSIs from the Hypervisor to the guest. Which is useful for userspace PCI backend drivers. Signed-off-by: Mykyta Poturai --- xen/arch/arm/include/asm/vgic.h | 11 +++++++++++ xen/arch/arm/vgic-v3-its.c | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/xen/arch/arm/include/asm/vgic.h b/xen/arch/arm/include/asm/vgic.h index 922779ce14..4695743848 100644 --- a/xen/arch/arm/include/asm/vgic.h +++ b/xen/arch/arm/include/asm/vgic.h @@ -317,6 +317,17 @@ extern bool vgic_migrate_irq(struct vcpu *old, struct vcpu *new, unsigned int ir extern void vgic_check_inflight_irqs_pending(struct domain *d, struct vcpu *v, unsigned int rank, uint32_t r); +#ifdef CONFIG_HAS_ITS +int vgic_its_trigger_msi(struct domain *d, paddr_t doorbell_address, + u32 devid, u32 eventid); +#else +static inline int vgic_its_trigger_msi(struct domain *d, paddr_t doorbell_address, + u32 devid, u32 eventid) +{ + return -EOPNOTSUPP; +} +#endif /* CONFIG_HAS_ITS */ + #endif /* !CONFIG_NEW_VGIC */ /*** Common VGIC functions used by Xen arch code ****/ diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c index 70b5aeb822..683a378f6e 100644 --- a/xen/arch/arm/vgic-v3-its.c +++ b/xen/arch/arm/vgic-v3-its.c @@ -1484,6 +1484,41 @@ static int vgic_v3_its_init_virtual(struct domain *d, paddr_t guest_addr, return 0; } +int vgic_its_trigger_msi(struct domain *d, paddr_t doorbell_address, + u32 devid, u32 eventid) +{ + struct vcpu *vcpu; + struct virt_its *pos, *temp; + struct virt_its *its = NULL; + uint32_t vlpi; + bool ret; + + list_for_each_entry_safe( pos, temp, &d->arch.vgic.vits_list, vits_list ) + { + if ( pos->doorbell_address == doorbell_address ) + { + its = pos; + break; + } + } + + if ( !its ) + return -EINVAL; + + spin_lock(&its->its_lock); + ret = read_itte(its, devid, eventid, &vcpu, &vlpi); + spin_unlock(&its->its_lock); + if ( !ret ) + return -1; + + if ( vlpi == INVALID_LPI ) + return -1; + + vgic_vcpu_inject_lpi(its->d, vlpi); + + return 0; +} + unsigned int vgic_v3_its_count(const struct domain *d) { struct host_its *hw_its; From patchwork Sun Jan 14 10:01:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mykyta Poturai X-Patchwork-Id: 13519130 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00C79C47077 for ; Sun, 14 Jan 2024 10:02:35 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.667097.1038118 (Exim 4.92) (envelope-from ) id 1rOxJn-0006QF-1c; Sun, 14 Jan 2024 10:02:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 667097.1038118; Sun, 14 Jan 2024 10:02:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rOxJm-0006Ox-Sd; Sun, 14 Jan 2024 10:02:14 +0000 Received: by outflank-mailman (input) for mailman id 667097; Sun, 14 Jan 2024 10:02:13 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rOxJl-0006AA-I9 for xen-devel@lists.xenproject.org; Sun, 14 Jan 2024 10:02:13 +0000 Received: from mx0b-0039f301.pphosted.com (mx0b-0039f301.pphosted.com [148.163.137.242]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fab47a89-b2c3-11ee-9b0f-b553b5be7939; Sun, 14 Jan 2024 11:02:09 +0100 (CET) Received: from pps.filterd (m0174681.ppops.net [127.0.0.1]) by mx0b-0039f301.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40E29Aat013393; Sun, 14 Jan 2024 10:01:56 GMT Received: from eur05-am6-obe.outbound.protection.outlook.com (mail-am6eur05lp2104.outbound.protection.outlook.com [104.47.18.104]) by mx0b-0039f301.pphosted.com (PPS) with ESMTPS id 3vkmj1hsv6-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 14 Jan 2024 10:01:56 +0000 (GMT) Received: from AS2PR03MB10110.eurprd03.prod.outlook.com (2603:10a6:20b:57a::22) by AM9PR03MB7725.eurprd03.prod.outlook.com (2603:10a6:20b:41e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.23; Sun, 14 Jan 2024 10:01:53 +0000 Received: from AS2PR03MB10110.eurprd03.prod.outlook.com ([fe80::9640:139b:8daa:fc9e]) by AS2PR03MB10110.eurprd03.prod.outlook.com ([fe80::9640:139b:8daa:fc9e%3]) with mapi id 15.20.7181.022; Sun, 14 Jan 2024 10:01:53 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fab47a89-b2c3-11ee-9b0f-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O/7D4F8abhHtlI6G7CfJL4BhRaISN31KPe1cUJllSW6m8Sqo2/xHmiYj3JnOuj9TQ1461yptmmYOxJ9dzluvEVG1MtC+QX/FuFykqn5HsTWLj543KtMWT1GlD7LEefDB+cPEiQ0StwuImHHyBI/PY/4SDstAJpgGxHUkr5hlnaOGfGjyHyYQEFVmfwaN9Uob0UM8dSv9/Vi0W5c7q0tFaQDMPpYq2f3JRK98DdGA78y9yAdcX42IluitEMwR4lyhEXC6V309ZuSJOt3abRZzWPW/0F460MYuafw63vpmFzwRQfin6EDRZPA95ocwj/Um02RJ+qe8UWVozfd3CLU4UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i5WrO4pORRjJwySMRAgFI+4Dm/wKfZdXFK/o0SQScYM=; b=FaS3dCkE5myn+5jTghZV5jr4gX44LBYSMd7DMRqRLWpl4tovV/a6SD6HCn7Jb99ywjrGF1gZe00h0EDt0pH6D3yRIAjZipYO725FsPaTO8cDEbNbiDrBXw5WltDBuW1EtIWD0/hELm+y/11ZMfgSgFy4/WcNyyBMz+iBSgGbGNPQK9rnwlvCGeL/DAqYH8WbQbtOdueN7aK9tnXhvKXjy6n72fO4ReAjeW/id1e3q7irEbGF++AJ2Xmp+cDHF+Vn+ELxWysLEGpUIgYwlNzI3w8EP0KVdw7sZj4A2yGQyMB23CnzUVmIRpsbk7PoAQxsB90BqGBBcTHoONDgDPUSPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=epam.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i5WrO4pORRjJwySMRAgFI+4Dm/wKfZdXFK/o0SQScYM=; b=Qbcf0iPYz+OVMFfLBwbkEp+YZ+O3M87YIRq7cfyYPL91F+hj6E/iXrFCP+LP69KOYq/oRBd934BgRMi6Oj1qscpNhIAltQcGwrHA75VKqRV9f7ZBFHxzxgKX66oWbA20/fXgL8REJTSyEbNEH0VIZK72lmtYEPz2KdGJ1pFt5lXO46seMaWV3IHjbBnvFT06nsCIGOzlam3nZOEGK35pbxT0uQfP3h2cJ1RuAmPnNOHqN0g5whI4Ie2HeRqcnGJMj0DesGOjtrHYMJ8EVqBTyl+xwsZP5W0jbfn89hVqD0rCTY+VKOwsNjsFVMzAAOeg/I8Gq4hUUspqjrQzabebcA== From: Mykyta Poturai To: "xen-devel@lists.xenproject.org" CC: Mykyta Poturai , Wei Liu , Anthony PERARD , Juergen Gross , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , =?iso-8859-1?q?Roger_Pau_Mo?= =?iso-8859-1?q?nn=E9?= Subject: [PATCH 2/2] xen/dm: arm: Introduce inject_msi2 DM op Thread-Topic: [PATCH 2/2] xen/dm: arm: Introduce inject_msi2 DM op Thread-Index: AQHaRtCzsHPhy+CQVkWhqLuVBID2ow== Date: Sun, 14 Jan 2024 10:01:53 +0000 Message-ID: <6c551b03796fbf091b22fcde96d894cd5308ff91.1705066642.git.mykyta_poturai@epam.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS2PR03MB10110:EE_|AM9PR03MB7725:EE_ x-ms-office365-filtering-correlation-id: ed95b25e-b022-4a46-f393-08dc14e7d58d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Ea9yoJKoqsLJSU9J8I0z8B5ifPEwTrfLoS9K+IujV+Zq66+ma+rSEzZ7zMuPgJd8S3pFGOgt2fxYZgmfj5W5J9nRktA6Pezl4DRJj+dKhce1FhF8m3haqAxvATG0Tp2kJnZ2ISIPlFgcKlYOfs9/DwDyutf7kYeP5iNqZq6LrJ33a3yx++n03nD1jtM3WayN5fiMBMld9qK5Ez/ijfv2Y35rdB42gqeg20Yli7iQycuUyukaThv13XZZgp6k9sKpMNbFowpzTnw3JT5cncBjlQ+gI07pG0srUxB4iW9zDqqZIkZNu4/Sl3O1pgAH4GfnAsWYMiR1uN/96xSlkpZNeQ5OxsZZIgIxAh2L6WUhYVU9zFtniDMmGUO0kNRTLeoSn4M41V44nVytM2PN5TkVjbQwwUAbjDT89B7E6sIrGq/4yZvA1N6Sg0SSlB9/2yjOI4zZBVQEBpzzVVu3cWN6QiR8t7i0rXBklN/w7fwsd7042Z6u+qNAYGDc/9eqxfROKrrI4BffuSnAC4gsPPPVnl7vGFUSax1gI4jwVufvv9WSd5t/PR3XGZZacEXtPA0RrAl7Vu5Dl4XYQREjvDKvw4Nd/SOZ0F4JVhWkuwBp4FxhsttV7QypWeFfile5jQcWUxYeYodi/id8BmN9BNr9JXgaBdI17VLIJ3h9pX3kvF4= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS2PR03MB10110.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(366004)(136003)(39860400002)(396003)(376002)(230922051799003)(230273577357003)(230173577357003)(186009)(64100799003)(451199024)(1800799012)(6512007)(316002)(8936002)(8676002)(91956017)(71200400001)(66476007)(64756008)(66446008)(54906003)(6916009)(6506007)(66556008)(478600001)(66946007)(6486002)(76116006)(2616005)(83380400001)(26005)(7416002)(5660300002)(4326008)(41300700001)(2906002)(38070700009)(36756003)(122000001)(38100700002)(86362001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?QUkjUWLzNTvo60Su71ifnBp?= =?iso-8859-1?q?rbNKBcUy8SxtV2HgFIYcac7rkYzsdK+COILDETEdvScbTJazhUD0O5NqnBOO?= =?iso-8859-1?q?n4QPBhA6+tsD/rdx+UMV+BMKgMx9hpF8b4Mp/H0Wo6BIFJRkhM4bTgL/mLBj?= =?iso-8859-1?q?V7VEZhJnmR3+g5i2pSScp84oekp99Ax3PU/zTjq4n+sBr3yxInLvRdsVZu9j?= =?iso-8859-1?q?04eAAcp1weex2Si3gXpe80upuPyHifb7xyd8qwRp1FReqX9P7movoa7R15RC?= =?iso-8859-1?q?XM8i5h3kS/zvVR+qzpKoQN9DmMPOkUFiVGrGwov1S2iLdTT2H6n+h7aPygI7?= =?iso-8859-1?q?C1iRA2O+MV0qsKYGZeyuzKnbj7Ua4mtAKhjw/7McLaT5epdDl5O4PpbwTXFF?= =?iso-8859-1?q?DTZYNXcZPprp3bGcc9SOmtW1BPCKLoqoWYi/gd48iXLiQLMp5i4cV8EsSh+v?= =?iso-8859-1?q?BtYA6VEkJD4rEBQOwMPxf4yv/THVU7dYHDXZRyV2EJfgHAGd8x4rhl9V3DNk?= =?iso-8859-1?q?NTbvKTpVbDDMVQT0J47YJ8LdEPdW8E/jkiOezYVZnq2v2JfH8u0VHNK6vG/E?= =?iso-8859-1?q?WrtGvz32GzHUfvxO92HPGT43ImPDOFYN5E4AoLa/BeKi78WuB3/TVH8+w/sX?= =?iso-8859-1?q?KeIVFtmH8I7gVVZsDYmF1FgVmX/gFqFbkOTpPvUnNPAwV/aOW0qqpKFW0zKi?= =?iso-8859-1?q?81lUzSZttYBDoaCX0DGXgIJU1uobveUKzvWlfu7FVT6n0bW5Dj7hjrTvcCxx?= =?iso-8859-1?q?bCOUbZsCF0spc1JiXP4pGXmBNFU/lLUJPRGyDeBsMdVOwk3xryvVIhjO33ph?= =?iso-8859-1?q?N5+oE2kKcgNUkTE+IqH5IhU/5WKivqJh13VByTf8xdIxxufUI22vWmJP2+Oe?= =?iso-8859-1?q?vEoNrOQnv6Xjpoh4C5JXa4zUjiHibb52ObHrO+RD8ZRHgh/yNFtqaeEESV+J?= =?iso-8859-1?q?5duprDLSFvAnNMAS4dovh+gdIDZsaN0DvfaC0pjn1LTdvmIPTMxq6eCHDxk/?= =?iso-8859-1?q?FKpxZHjIx0FQp3UQq0GXWnHJE9W6IfEAnHkN/FNmq4xxakJSVMDYP+okn4dG?= =?iso-8859-1?q?8xnBEoKF/j559VFz8Bh/l2tE12XhRKlpiGqqL1JI39mbwMG4QA5nCS+BKhuc?= =?iso-8859-1?q?WDvLfzugZBl+M3pVyolljKRaXaDF+voOgJJPwg6curEmyBoe0bdJmyjf+rVk?= =?iso-8859-1?q?x9uiZsAFubAIA9+g4B1/jGKaA14jwwwu7MwTXHy9HX+GZeCw/zAvmtvGKkOT?= =?iso-8859-1?q?Cgi1/NdTh9BvSgXC4wPdD1VTU/HHZulUaj05Mem47h1URtBucNMfVFmljAgE?= =?iso-8859-1?q?3VYe9/Yj9EK7//xphUW5vAvResoadl72Cn+rZgHUeMzzuHIE0i2KMpN7AZ0w?= =?iso-8859-1?q?fWh6f0prXFv4oifWRKL+pYJhVf9Kixsn7M7PybqXYAgd0iTUTk2TlFItVHwh?= =?iso-8859-1?q?YKqwx42JIL/HGCZAgbHVwz+65VfFcsDMyCWYyFHRC0UYZGIrgusuza19/iBa?= =?iso-8859-1?q?EAzi8eNGmg5XdtrFNK8if6QFOM8TP7bXP2EfGHLuT4IWKx4sPN8qJzOvAT57?= =?iso-8859-1?q?lTAkJ1XW3uc/DrKxEeLccz0cERk7GcNhvGXfBl+l0OuGTAk17mjCIkKY08If?= =?iso-8859-1?q?W6gSrggfkdHi27TII/dzT8pLOnzbq2rkQDw4TvA=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: epam.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS2PR03MB10110.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed95b25e-b022-4a46-f393-08dc14e7d58d X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jan 2024 10:01:53.2011 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b41b72d0-4e9f-4c26-8a69-f949f367c91d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: n7+BZ3Vt6JSG0z60/FMUKVanqYJ2ZnI/1fZPsDirWVQgtRCZEs0aHjGrLKFZgSJaCoif1A49EvZOXwVFt1MrhA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR03MB7725 X-Proofpoint-GUID: mzJhV2cR_4FNwPYKjX505Xu2OmZkY671 X-Proofpoint-ORIG-GUID: mzJhV2cR_4FNwPYKjX505Xu2OmZkY671 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=707 suspectscore=0 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 mlxscore=0 phishscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401140078 Add the second version of inject_msi DM op, which allows to specify the source_id of an MSI interrupt. This is needed for correct MSI injection on ARM. It would not be safe to include the source_id in the original inject_msi in the pad field, because we have no way to know if it is set or not. Signed-off-by: Mykyta Poturai --- tools/include/xendevicemodel.h | 14 +++++++++++++ tools/libs/devicemodel/core.c | 22 ++++++++++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 5 +++++ xen/arch/arm/dm.c | 15 +++++++++++++ xen/arch/x86/hvm/dm.c | 13 ++++++++++++ xen/include/public/hvm/dm_op.h | 12 +++++++++++ 6 files changed, 81 insertions(+) diff --git a/tools/include/xendevicemodel.h b/tools/include/xendevicemodel.h index 797e0c6b29..4833e55bce 100644 --- a/tools/include/xendevicemodel.h +++ b/tools/include/xendevicemodel.h @@ -236,6 +236,20 @@ int xendevicemodel_inject_msi( xendevicemodel_handle *dmod, domid_t domid, uint64_t msi_addr, uint32_t msi_data); +/** + * This function injects an MSI into a guest. + * + * @parm dmod a handle to an open devicemodel interface. + * @parm domid the domain id to be serviced + * @parm msi_addr the MSI address (0xfeexxxxx) + * @parm source_id the PCI SBDF of the source device + * @parm msi_data the MSI data + * @return 0 on success, -1 on failure. +*/ +int xendevicemodel_inject_msi2( + xendevicemodel_handle *dmod, domid_t domid, uint64_t msi_addr, uint32_t source_id, + uint32_t msi_data, unsigned int source_id_valid); + /** * This function enables tracking of changes in the VRAM area. * diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c index 8e619eeb0a..17ad00c5d9 100644 --- a/tools/libs/devicemodel/core.c +++ b/tools/libs/devicemodel/core.c @@ -448,6 +448,28 @@ int xendevicemodel_set_irq_level( return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op)); } +int xendevicemodel_inject_msi2( + xendevicemodel_handle *dmod, domid_t domid, uint64_t msi_addr, uint32_t source_id, + uint32_t msi_data, unsigned int source_id_valid) +{ + struct xen_dm_op op; + struct xen_dm_op_inject_msi2 *data; + + memset(&op, 0, sizeof(op)); + + op.op = XEN_DMOP_inject_msi2; + data = &op.u.inject_msi2; + + data->addr = msi_addr; + data->data = msi_data; + if ( source_id_valid ) { + data->source_id = source_id; + data->flags = XEN_DMOP_MSI_SOURCE_ID_VALID; + } + + return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op)); +} + int xendevicemodel_set_pci_link_route( xendevicemodel_handle *dmod, domid_t domid, uint8_t link, uint8_t irq) { diff --git a/tools/libs/devicemodel/libxendevicemodel.map b/tools/libs/devicemodel/libxendevicemodel.map index f7f9e3d932..aa05768642 100644 --- a/tools/libs/devicemodel/libxendevicemodel.map +++ b/tools/libs/devicemodel/libxendevicemodel.map @@ -44,3 +44,8 @@ VERS_1.4 { xendevicemodel_set_irq_level; xendevicemodel_nr_vcpus; } VERS_1.3; + +VERS_1.5 { + global: + xendevicemodel_inject_msi2; +} VERS_1.4; diff --git a/xen/arch/arm/dm.c b/xen/arch/arm/dm.c index 5569efa121..c45e196561 100644 --- a/xen/arch/arm/dm.c +++ b/xen/arch/arm/dm.c @@ -27,6 +27,7 @@ int dm_op(const struct dmop_args *op_args) [XEN_DMOP_set_ioreq_server_state] = sizeof(struct xen_dm_op_set_ioreq_server_state), [XEN_DMOP_destroy_ioreq_server] = sizeof(struct xen_dm_op_destroy_ioreq_server), [XEN_DMOP_set_irq_level] = sizeof(struct xen_dm_op_set_irq_level), + [XEN_DMOP_inject_msi2] = sizeof(struct xen_dm_op_inject_msi2), [XEN_DMOP_nr_vcpus] = sizeof(struct xen_dm_op_nr_vcpus), }; @@ -112,6 +113,20 @@ int dm_op(const struct dmop_args *op_args) break; } + case XEN_DMOP_inject_msi2: + { + const struct xen_dm_op_inject_msi2 *data = + &op.u.inject_msi2; + + if ( !(data->flags & XEN_DMOP_MSI_SOURCE_ID_VALID) ) + { + rc = -EINVAL; + break; + } + rc = vgic_its_trigger_msi(d, data->addr, data->source_id, data->data); + break; + + } case XEN_DMOP_nr_vcpus: { struct xen_dm_op_nr_vcpus *data = &op.u.nr_vcpus; diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c index 462691f91d..a4a0e3dff9 100644 --- a/xen/arch/x86/hvm/dm.c +++ b/xen/arch/x86/hvm/dm.c @@ -344,6 +344,7 @@ int dm_op(const struct dmop_args *op_args) [XEN_DMOP_set_mem_type] = sizeof(struct xen_dm_op_set_mem_type), [XEN_DMOP_inject_event] = sizeof(struct xen_dm_op_inject_event), [XEN_DMOP_inject_msi] = sizeof(struct xen_dm_op_inject_msi), + [XEN_DMOP_inject_msi2] = sizeof(struct xen_dm_op_inject_msi2), [XEN_DMOP_map_mem_type_to_ioreq_server] = sizeof(struct xen_dm_op_map_mem_type_to_ioreq_server), [XEN_DMOP_remote_shutdown] = sizeof(struct xen_dm_op_remote_shutdown), [XEN_DMOP_relocate_memory] = sizeof(struct xen_dm_op_relocate_memory), @@ -539,6 +540,18 @@ int dm_op(const struct dmop_args *op_args) break; } + case XEN_DMOP_inject_msi2: + { + const struct xen_dm_op_inject_msi2 *data = + &op.u.inject_msi2; + + if ( !(data->flags & XEN_DMOP_MSI_SOURCE_ID_VALID) ) + printk(XENLOG_WARNING "XEN_DMOP_inject_msi2: source_id is ignored\n"); + + rc = hvm_inject_msi(d, data->addr, data->data); + break; + } + case XEN_DMOP_remote_shutdown: { const struct xen_dm_op_remote_shutdown *data = diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h index fa98551914..da2ce4a7f7 100644 --- a/xen/include/public/hvm/dm_op.h +++ b/xen/include/public/hvm/dm_op.h @@ -444,6 +444,17 @@ struct xen_dm_op_nr_vcpus { }; typedef struct xen_dm_op_nr_vcpus xen_dm_op_nr_vcpus_t; +#define XEN_DMOP_inject_msi2 21 +#define XEN_DMOP_MSI_SOURCE_ID_VALID (1u << 0) + +struct xen_dm_op_inject_msi2 { + uint64_aligned_t addr; + uint32_t data; + uint32_t source_id; /* PCI SBDF */ + uint32_t flags; +}; +typedef struct xen_dm_op_inject_msi2 xen_dm_op_inject_msi2_t; + struct xen_dm_op { uint32_t op; uint32_t pad; @@ -463,6 +474,7 @@ struct xen_dm_op { xen_dm_op_set_mem_type_t set_mem_type; xen_dm_op_inject_event_t inject_event; xen_dm_op_inject_msi_t inject_msi; + xen_dm_op_inject_msi2_t inject_msi2; xen_dm_op_map_mem_type_to_ioreq_server_t map_mem_type_to_ioreq_server; xen_dm_op_remote_shutdown_t remote_shutdown; xen_dm_op_relocate_memory_t relocate_memory;