From patchwork Fri May 24 02:18:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 13672610 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 6C6D5C25B7E for ; Fri, 24 May 2024 02:18:53 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.728985.1134095 (Exim 4.92) (envelope-from ) id 1sAKW4-0004Oh-Qz; Fri, 24 May 2024 02:18:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 728985.1134095; Fri, 24 May 2024 02:18:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAKW4-0004OY-O3; Fri, 24 May 2024 02:18:44 +0000 Received: by outflank-mailman (input) for mailman id 728985; Fri, 24 May 2024 02:18:43 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sAKW3-0003tc-Aw for xen-devel@lists.xenproject.org; Fri, 24 May 2024 02:18:43 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20601.outbound.protection.outlook.com [2a01:111:f403:2412::601]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f02977bf-1973-11ef-90a1-e314d9c70b13; Fri, 24 May 2024 04:18:42 +0200 (CEST) Received: from MW4PR04CA0078.namprd04.prod.outlook.com (2603:10b6:303:6b::23) by PH7PR12MB9202.namprd12.prod.outlook.com (2603:10b6:510:2ef::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.19; Fri, 24 May 2024 02:18:37 +0000 Received: from CO1PEPF000075EF.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::5e) by MW4PR04CA0078.outlook.office365.com (2603:10b6:303:6b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22 via Frontend Transport; Fri, 24 May 2024 02:18:36 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000075EF.mail.protection.outlook.com (10.167.249.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Fri, 24 May 2024 02:18:36 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 23 May 2024 21:18:32 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 23 May 2024 21:18:31 -0500 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: f02977bf-1973-11ef-90a1-e314d9c70b13 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K+oOt94oKv7T9anVoojoQ2aQupFhYcyms6MN4ZJUxkgGKyV7SOeL1eoG1czNxiDCT3Wv41uE/WssM3QHtG1HYsJmBvxeXnRav7esw0ITS8cExVKmPsGyNGTAABMOEGv9JsOczd17BLY24gqdG8zlype73oh12aWAHfIX/mf79DrtEWoy37H+Gk+QFw2Gdqx9f9O7V2uYEtXw7chSTLSNcjcopqKJ2bvHUApbpFOpYFTCGm/WYJkorgHAiuYrTSNF+i9OcCyoPZ2PV29wAcfzjAY6tQogjuyDvT4+b6phGoyuPJPgOkr8C/A1q5bZeZ9vDFgEg1w0b2Vvj1PRuoOiTQ== 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=dUxLvykGPrn0TdFclj7NWwLQlt3XRena1NmCNYfl8WY=; b=kOHAkf8zFzgffGuktIgxoefAhdk7IO3sZwPyYyrQEZtfy6CphD985vHT2HIVG1Rve4b4cRcKdxQMJvbPDGDbiP7ZeGOUxItXDkulg1tjRDuVF8YMVBWczd55daSr5mzzWqtvr7P3ubKdyPIkHowD7B2HUx8esZSNRdgYvOCgcBr3eibBgnXPzYI53ow5wknpvp/rGAZnYJSNYs9G3bEpEq6qRVh+Dm5Iy+gG9hHrQWYhanWatm19yP6eKEpaSaiAYmuw4DN4F1V+C8oHyqpEbq/UbKDNArXv+0J0biTVT5Fjykh2ZnIoltmuNxmk6JGjsrCvvn4H5i7ed0vyc5BtQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dUxLvykGPrn0TdFclj7NWwLQlt3XRena1NmCNYfl8WY=; b=xNoUp4SBKWr0BOsbJwkmTaOnbTNp6wYpQjmn3AdCAvG08lon9xk40uOTwGl8f4DjnMzH4k/6jdLl10EiRXcIoGvscVRT4BJKLEVC82K4mD+oPk4Z91zjqsUSXH0y3u7pmZi7YSRl6oNs/oljEIkqxxrkAoIc0E/2Z2u6Ge8W3JM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C From: Stefano Stabellini To: CC: , , , , , , Henry Wang , "Stefano Stabellini" , Julien Grall Subject: [PATCH v5 4/7] xen/arm/gic: Allow adding interrupt to running VMs Date: Thu, 23 May 2024 19:18:11 -0700 Message-ID: <20240524021814.2666257-4-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075EF:EE_|PH7PR12MB9202:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ea84ffd-f719-4948-71b9-08dc7b97d1c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|376005|82310400017; X-Microsoft-Antispam-Message-Info: 5Kfs9OGs6EUji5agDbShs9dUhfuVFkFUkPASr4/FE9kDWmBylwHxf2AnAG2QEHxqTwSng8cZMvmoqbpdhMdSgX4httlMo9Kh8P0xU5Hhh1kM1LudrjUyjKrjCZyT72h8XUyLPFbQQeDGK5D6iQAuXd70FOtthS+r815pbM+e19tRslRO0b9ASThM2jNAbjPN0diH4p4JWInRcC2uEWTupT87amcXdDeCF6qefNBoDtJCQpuK6M8H7ms4/Ib/CGtKYBd9Cwd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FKCSkqoOcWUg3TfYjLxJwhXL3fr3WJUZqCO7vAGaPXMMwDcZSg+gfDim3Xv X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(1800799015)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 02:18:36.8123 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ea84ffd-f719-4948-71b9-08dc7b97d1c9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000075EF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9202 From: Henry Wang Currently, adding physical interrupts are only allowed at the domain creation time. For use cases such as dynamic device tree overlay addition, the adding of physical IRQ to running domains should be allowed. Drop the above-mentioned domain creation check. Since this will introduce interrupt state unsync issues for cases when the interrupt is active or pending in the guest, therefore for these cases we simply reject the operation. Do it for both new and old vGIC implementations. Signed-off-by: Henry Wang Signed-off-by: Stefano Stabellini Reviewed-by: Julien Grall --- xen/arch/arm/gic-vgic.c | 9 +++++++-- xen/arch/arm/gic.c | 8 -------- xen/arch/arm/vgic/vgic.c | 7 +++++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c index 56490dbc43..b99e287224 100644 --- a/xen/arch/arm/gic-vgic.c +++ b/xen/arch/arm/gic-vgic.c @@ -442,9 +442,14 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu *v, unsigned int virq, if ( connect ) { - /* The VIRQ should not be already enabled by the guest */ + /* + * The VIRQ should not be already enabled by the guest nor + * active/pending in the guest. + */ if ( !p->desc && - !test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) ) + !test_bit(GIC_IRQ_GUEST_ENABLED, &p->status) && + !test_bit(GIC_IRQ_GUEST_VISIBLE, &p->status) && + !test_bit(GIC_IRQ_GUEST_ACTIVE, &p->status) ) p->desc = desc; else ret = -EBUSY; diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 44c40e86de..b3467a76ae 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -135,14 +135,6 @@ int gic_route_irq_to_guest(struct domain *d, unsigned int virq, ASSERT(virq < vgic_num_irqs(d)); ASSERT(!is_lpi(virq)); - /* - * When routing an IRQ to guest, the virtual state is not synced - * back to the physical IRQ. To prevent get unsync, restrict the - * routing to when the Domain is been created. - */ - if ( d->creation_finished ) - return -EBUSY; - ret = vgic_connect_hw_irq(d, NULL, virq, desc, true); if ( ret ) return ret; diff --git a/xen/arch/arm/vgic/vgic.c b/xen/arch/arm/vgic/vgic.c index b9463a5f27..6cabd0496d 100644 --- a/xen/arch/arm/vgic/vgic.c +++ b/xen/arch/arm/vgic/vgic.c @@ -876,8 +876,11 @@ int vgic_connect_hw_irq(struct domain *d, struct vcpu *vcpu, if ( connect ) /* assign a mapped IRQ */ { - /* The VIRQ should not be already enabled by the guest */ - if ( !irq->hw && !irq->enabled ) + /* + * The VIRQ should not be already enabled by the guest nor + * active/pending in the guest. + */ + if ( !irq->hw && !irq->enabled && !irq->active && !irq->pending_latch ) { irq->hw = true; irq->hwintid = desc->irq;