From patchwork Thu Apr 21 13:21:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12821618 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 896D8C433EF for ; Thu, 21 Apr 2022 13:22:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.310170.526850 (Exim 4.92) (envelope-from ) id 1nhWkw-0005Wh-Nc; Thu, 21 Apr 2022 13:21:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 310170.526850; Thu, 21 Apr 2022 13:21:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhWkw-0005Wa-Kb; Thu, 21 Apr 2022 13:21:58 +0000 Received: by outflank-mailman (input) for mailman id 310170; Thu, 21 Apr 2022 13:21:56 +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 1nhWku-0005Gk-Mb for xen-devel@lists.xenproject.org; Thu, 21 Apr 2022 13:21:56 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 029bfa40-c176-11ec-8fc2-03012f2f19d4; Thu, 21 Apr 2022 15:21:53 +0200 (CEST) Received: from mail-bn8nam12lp2168.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.168]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Apr 2022 09:21:54 -0400 Received: from DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) by BN7PR03MB3649.namprd03.prod.outlook.com (2603:10b6:406:c9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.13; Thu, 21 Apr 2022 13:21:53 +0000 Received: from DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e]) by DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e%4]) with mapi id 15.20.5186.015; Thu, 21 Apr 2022 13:21: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: 029bfa40-c176-11ec-8fc2-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650547315; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=3IGNZ+VfL0mt0x6amMhXSerxu1UgLXEzTKuf9OnMG/4=; b=Pbr2AQzLjRK3mzr6SgeNiYJk7Ti2dk5qwIUCeG1zIcCUruRrMRsMbw77 k6hDzqU7ZPtNIhUALuxjiCy3KxRGMj2JKCQrZKLfyw6xEx2SoEXmeQKXA Zfy/a+e41XPXeLNh3gxjBSxzSAvbMrh5LhPNU07spNH6j/+AxonhOFzB1 8=; X-IronPort-RemoteIP: 104.47.55.168 X-IronPort-MID: 69628147 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:wEJKo67y30ubgqHYVcnBbAxRtEzGchMFZxGqfqrLsTDasY5as4F+v mofXD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rHo6mt jFpBkte+x19nPqZ2mw5SDg3gHxuQxen0PK+Bu9uz/OsMb5TDU1B45qnoRCaCbU7EImoZVVzL 9L93jxjesZMTrw2ADGo/TYXRBjkUS55VA4l/QIsnBZWYwCLJdMsI0k+l9PGptoJlO31GkeKp guMCjg3ocXTbvDBEqp/VWHgebcE0jbJy32DHTr4aeuonprdHMQ9Tps+CVQpAZEyHsHceg02w 31CNUXqFhwdL5nUUsEPpZmfSKWMB27ffueChPlHbzYfJt3SE7lmtrQ3Igfwt2MVdgh8KYS8a 6xIm+w81RCMX7TNQ== X-IronPort-AV: E=Sophos;i="5.90,278,1643691600"; d="scan'208";a="69628147" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YuSE/ALZgipOcoubIbKMxWWpUa/cMFsdouIFYVcITL/ios4ZD9CfHQLLCyfUnwL8g1CEbjatrvOwdCEfuFpWLrVIATX6uTz6t3YCB2+kqOLs1CFbotSNBK0HGO5jfMZUjNXVHwnte5KXiAPU6bvMBjFqdwfT18I85mfwOUXekX6ePCOCBI1wkQT0QrUb0taYp8r2qulx/kSeIV8CDInoeXuUiLhIJ6FcCYv9LKgwmcInzgf930bN9D359U9WAkWYd7RNJcyucucqcbuGo+/a3bdF+BLovOVCWAsvW1+2Pa8ZY0EZE99m+wZ4V6DDB9C5bfLI1Qxmim1aX98D6uTA5g== 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=MplFUaOgPEc44piH8DIO1e3W6kPo2BvT4PdjJ9GUhPE=; b=jVeVuPjKTczt3lAsHs4Bpkw04JWa/WkcMeHXl7i4erFkPyLo8OXzA8QYjYfrpIFC2OGR4Vw3KQf3BzWXH4i5Rk9EatoT73GM8BJOp+1cM3pJUjkahXpnHwO5SooRaiK1BEaAOFkK9Lr4J5kp5xEITgcis783B9xk/Py9KlQtasPuh6+vaB0nIKYXJ0j74FszmRs9uF9ZJ7jaEjoX/zwhkphA4nQSN8QwGEv+J/gmQX3KiSVLSY48riYqlkl0E0RFTIZ+FEQcmFp7R45crmnxGH1UhCkMH9vkI5Q1SIqzTsd6lweOP2hiRVEk+5NFpX2De8KELWnjLsJFbDp5jFyOPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MplFUaOgPEc44piH8DIO1e3W6kPo2BvT4PdjJ9GUhPE=; b=ib4J47h2/pybrx8wO+E5fzgg++JuNGHDUjT4lY1TlCEtx2lRmkPjFnp08D3QG5sWCCTVhnEIC661TCn3WosTTPQTDavmoDBaeD1ku2JT3QjxVT1vh662KDBm5ZrdEdY8PAQJeB5vWuZHZ1tXMRlhel663R/Z2EBqt7vOxf1J5ug= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH RFC 1/6] x86/ioapic: set disable hook for masking edge interrupts Date: Thu, 21 Apr 2022 15:21:09 +0200 Message-Id: <20220421132114.35118-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220421132114.35118-1-roger.pau@citrix.com> References: <20220421132114.35118-1-roger.pau@citrix.com> X-ClientProxiedBy: MR2P264CA0170.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501::9) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 161fdfa6-5af9-4ded-dfd1-08da2399e645 X-MS-TrafficTypeDiagnostic: BN7PR03MB3649:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bGhWpL3wjHR52MNL7jnHfNnqzjjuQg7qlczAlmzRalkN3+Ew5ngFNFks9yy3VSwTfbBsrpsOFDy6iQApMk/InP4FDXQkdtqUSeoXTQmGaXfzjVDU0Vfi4XtGLq35/cmZjpc5ulkZc9smBFr/MhPDKMwPptedHHyXS/PRoLS0mIG1WOoVjLmcK49KpqwkyhfA45n98TtQrxwTGH+pUJct6TRJJjTQcWxSg1tgH/2sUpo+pVJb9JYofmX1QQ6TOWNo6roQvaQ+XMSNJnXYhF5udHPaTBXRSxaaeEfnIBJPm5Nhp9vHlfii8TVU79l3EoYyUuueYuO8JVFOb1ct7BSYvmzL9/3uhy3hvmx/xJgJo63GACWgl5vIsLsZwXvq0UjIvWQJ0miP2MB7UIyFzR6y7su175Ewsa8oFaPo5gqzigTzTPPrbVbHqK4v6l6e1m6ALBVgQejoRu4EpD/1UB+yoAosWWRfSFgxqj5j3xQRebL+Ei8LNgClEbhWvSswxBSR8DnxT4OnllOFJaLpcLX7LswA7atwJSYj9L1ZC9IyHPOyUVLI2tahoUfh0wWNCr1KzOS/VD7E5Af9V3DmvQMQdp/kJSC99KgBG7qakFwL98tuuRBPKS16RlDQAHnJlsvO2B5BUpm4RCO9J5F+gL6Sfg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(186003)(6666004)(1076003)(6512007)(316002)(26005)(36756003)(54906003)(6916009)(2616005)(2906002)(6506007)(8676002)(4326008)(83380400001)(38100700002)(82960400001)(8936002)(66476007)(66556008)(66946007)(86362001)(6486002)(5660300002)(508600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Z/onOe6vnoxJfGyojrhcN4ehyLUP?= =?utf-8?q?SpP5Bj3PuR/Z+8lX4foR3yP8bAeiXGxsfpj0JMjRqFPZedMQ0XJIwmtqoOLyf89+E?= =?utf-8?q?joS8W/D/zbQic4CBuHtKPp0xZKBXaEaryEJpOSGs5pCfwmRITrDnIhTFmW2hnnZ6K?= =?utf-8?q?ur8fV9zBxj0+0Khu72JbeipcUnmhVSFUyKP4xp7JaukYk+Wh0NEZzTytFFn6ZKUGp?= =?utf-8?q?/LbosV+G35wXH68EyduwJtzkP19awn9VQQalIOioVR73Ke1hLTlvu5r4emLN6VZ5Z?= =?utf-8?q?MP35yu3MlPDcndFY1HPtT66kWjQyUJFAGkL2Yfk7ixbBALIYINuFefZyrJAfywb9x?= =?utf-8?q?pxQ9NKALazO8kITFEDEdKp65FCyWIYF7GViuVavzPD2KGbWJGrMHl9fPd4nl2MUVU?= =?utf-8?q?pkhWWmShuZ55dXQbPi9szdZy9zH5UWY/twcEcsPJo+tHkEKwk0cwbNB3uLpi4HQHj?= =?utf-8?q?A4o/kSpMSDwmL7uUPwJ92094393d/E2qQQyZlOUUb7wDLyv47HwsXSwMSDSRvo1An?= =?utf-8?q?aJLOw/ALev6D9qzLugAOgBAPO3tAHV2RJXrS14UrOSgdG2+2/CgpAHeLBwYa4f8be?= =?utf-8?q?q2+XGQd+ZUoR+JtAGokzQDY71SjG46a80I/4DTUG4JR9RTdu0oIuSiv++YHIluzAj?= =?utf-8?q?4r38K5uwnufNKo5+JmasBbk/xDR7tMP6pQaCOp6FpJtS/9xWGXVvK38SIF0PmEfUF?= =?utf-8?q?LdW53eP8nwfxxtwoMR76QWX7A3VQDpHJ8x9xg5MWA3i8q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94lvKiFGfV4Sfk?= =?utf-8?q?KHCYPAwMvYFBKQkmrUmFrTeSD3A7lGztHUHqjzWWbFLyg938mPSiY=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 161fdfa6-5af9-4ded-dfd1-08da2399e645 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2022 13:21:52.9454 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cF16NhysOp9sAQaW14Y9M8OnJ0cZZzvZfHBSZhN90sdvHr8XAT1LHWF0re7NKCI9jGJ8M2UCfbWzJ1CdvPneyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR03MB3649 Allow disabling (masking) IO-APIC pins set to edge trigger mode. This is required in order to safely migrate such interrupts between CPUs, as the write to update the IO-APIC RTE (or the IRTE) is not done atomically, so there's a window where there's a mismatch between the destination CPU and the vector: (XEN) CPU1: No irq handler for vector b5 (IRQ -11, LAPIC) (XEN) IRQ10 a=0002[0002,0008] v=bd[b5] t=IO-APIC-edge s=00000030 The main risk with masking edge triggered interrupts is losing them, but getting them injected while in the process of updating the RTE is equally harmful as the interrupts gets lost anyway. Signed-off-by: Roger Pau Monné --- xen/arch/x86/io_apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index c086f40f63..2e5964640b 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -1782,7 +1782,7 @@ static hw_irq_controller ioapic_edge_type = { .startup = startup_edge_ioapic_irq, .shutdown = irq_shutdown_none, .enable = unmask_IO_APIC_irq, - .disable = irq_disable_none, + .disable = mask_IO_APIC_irq, .ack = ack_edge_ioapic_irq, .set_affinity = set_ioapic_affinity_irq, }; From patchwork Thu Apr 21 13:21:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12821619 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 3DFB2C433EF for ; Thu, 21 Apr 2022 13:22:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.310171.526861 (Exim 4.92) (envelope-from ) id 1nhWkz-0005nf-0Q; Thu, 21 Apr 2022 13:22:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 310171.526861; Thu, 21 Apr 2022 13:22:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhWky-0005nS-SR; Thu, 21 Apr 2022 13:22:00 +0000 Received: by outflank-mailman (input) for mailman id 310171; Thu, 21 Apr 2022 13:22:00 +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 1nhWky-0005Gk-73 for xen-devel@lists.xenproject.org; Thu, 21 Apr 2022 13:22:00 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 047f6c89-c176-11ec-8fc2-03012f2f19d4; Thu, 21 Apr 2022 15:21:57 +0200 (CEST) Received: from mail-bn8nam12lp2174.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.174]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Apr 2022 09:21:57 -0400 Received: from DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) by BN7PR03MB3649.namprd03.prod.outlook.com (2603:10b6:406:c9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.13; Thu, 21 Apr 2022 13:21:56 +0000 Received: from DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e]) by DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e%4]) with mapi id 15.20.5186.015; Thu, 21 Apr 2022 13:21:56 +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: 047f6c89-c176-11ec-8fc2-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650547318; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=rBuBPJq4cctWRyDQOnxPt77RLOb1g9ofZ5nVo86zj30=; b=QdoELDoFyDiU6D76i0oVUyTu8gW5zas6oyiWAV1YuMkU53or3bhMGwmu L4m7TVhI98YEMavxZkzRyTR8Yia3Nje3MFxJQsbsdOfMdTSbd3hPxL6HI YC/7D0HR3fLbXYlpiRDpWVyd1k82dP/CwU5P8XzBXDS+/TxeIlMFKnRRI w=; X-IronPort-RemoteIP: 104.47.55.174 X-IronPort-MID: 69628152 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort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t7WexgXH32HewpxKkJ/Ky8dFBuaLls8JQw+cwjqAVcBEYfmvrTo1qOag5BIDl8 TNmQ4pO4BJ53bYbgiO0G/Q8jil9Axrx27pyFeej3emi9f+XigGB81Igp8cWgfF6mI71esMn5 5j7ia8jd56HBnAlCPy65zjTBdxjHe5pnIkjKo6k2Ffa40Dc7VcxLZvsH+9KK1wXR4S1bpXUN WHVKrnlbVrmBKhHj3kV1BUsZKRti9ZJGbFfqAA0vblpgS+0koJinfw//Zv70voxKhNNaWs2N 60QpiA7Is+KPP+TZgNc9vpEvHHfFAkf3r3QRGvCGWiMp07EFTwjLOyyIkJxYiRCe41Jd0J6d 78bG8= X-IronPort-AV: E=Sophos;i="5.90,278,1643691600"; d="scan'208";a="69628152" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LqIbDiD/126uVBnMNLYUdgTHzjzQvvsXUWaM2bYsmfJ4Ov4bVdHwHGq31lvS3m+tFRFiBKtr+86nEgJAq9bvfhGBvyqULNdHcoIsjw0ZaPPdFcMLZVdln9DHIyyIT+BECeh/19issIBWrYYf1sWLz6RD1+ONwHKauZFY8jWSELdtOxnwpndd2o2wPeUS0Kg0lYUi7Z9x7ThQ2Ai4MqnVrdJzWWt0JUpQvN7zQPv12JfCD4f9bs3MElpXNAV06a7LPEJyf2Xti8MXzFwqJby6GFTxJfV6I9qzYGklq+JvyFHo4+IC+XFIFPEYlmjXeL8DF9Vuzy0+8VrfcX+fQ9x1RQ== 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=eiYpcvR4fTeX/RmTQ4OuGBZuZs0rA/Bk5WTNjAu5kLw=; b=RBRK5bkT/6FugdxcT9Qdcz5P6V9N2i43KFr2OWNvB1QEGipphggTUL630VanrnJLD0AqfUsTinuImIS3JVTigU0rbaPORr5NJbHWli5nKdKqIvFpmBZ58Yqidaf1E8dGB8iAjka4kzqSFRLQBWR9faBryE/wOSfgNdlnDcIvIxFln4cDT6lVmc3WJEo9e/egrKmH7LlEa8qVhhHVM74kPE5ikkWv3i4s1MOW0Ev8ahx+WL7OY2eZdsHPHFP14C83t70/VeJoYkFfijwuhf3rCoDLvM/Bz2dozzTXDO4GyosonEuXs3iLhnpBmT7KgWRFG1Ud/Rh4qDeO3rlQSZZH6A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eiYpcvR4fTeX/RmTQ4OuGBZuZs0rA/Bk5WTNjAu5kLw=; b=BZnR8j+wTbUSDmrMjx1v6jV8rrPxLDi26B5aucr9rECPaioUgEJMZrrwgPajEE8onlJXgyPeKaSqD1JXjTneCjW+aJI4pYqBzW5HnTcgEIUkrnhdLOEWM3Xv2G+0aYTnYkhiFr21ykTI48l+GPDdrccq0wYpzFhM6b/N9n3G6e4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH RFC 2/6] x86/ioapic: add a raw field to RTE struct Date: Thu, 21 Apr 2022 15:21:10 +0200 Message-Id: <20220421132114.35118-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220421132114.35118-1-roger.pau@citrix.com> References: <20220421132114.35118-1-roger.pau@citrix.com> X-ClientProxiedBy: MR2P264CA0078.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:32::18) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1f8a5b20-5181-49f1-393e-08da2399e882 X-MS-TrafficTypeDiagnostic: BN7PR03MB3649:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BIxTxl1TZLD0KfAr435cOtkIF8VQSB6smlc03bb5GFbKrNZqJtu0jZB7XPXOFtQkBlv6UIUMCpinETwgzZCrhfyJhs3WTMfzmNs3MOlBFOKwIIN9JciwJQX/mkvN9ofVw16EtyB4Spud9U7oKgwYe7BDFNBY6w5+sUcxfao/Ev9rPBuYJbOew9vfkGMp0Mxaxi21DxfBu8eDd+sGM6hgSPWp06Q3XAHYds2T971X3mCoJMDLeIFXZs1Bo/HIKug5/9KRqsN4H3pWozqApwPET/KXgjCtuO3ZQBgnTcA+c1ik4qXKDEFYjvwmzYZrbyS/VpQ8a7WbD4L7qkSrw4hjXnLMfX0pjPksViadyf/JTGMTQGYJN4Yg7goMk+cbYbouFyEZjmYIn5QOs/+aEfrIXm7oFEZJxg7oMpifu6SKjmxUaa03ScwzkNHS0gHWm5Y/C1LHxZk0Sm+1zYsluB1xlZH97v5I7B11xegti3coCBhoRPZiZ26GX3LX5/DQ1MRRQgD9RwWYYyiTtrwR8qbcQNYD99h/Be9PPCQc13m3ID71Jra+dOyTN7I/U551r1NAuE/n/gPEwI3ULI5jtiJeiDqP7Bg2R8o2kuFPSKx5Cthndj0qhQxTKBrgjmqcP9Wc+gwMm3nz5JSTYkfbj9USUg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(186003)(6666004)(1076003)(6512007)(316002)(26005)(36756003)(54906003)(6916009)(2616005)(2906002)(6506007)(8676002)(4326008)(83380400001)(38100700002)(82960400001)(8936002)(66476007)(66556008)(66946007)(86362001)(6486002)(5660300002)(508600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?N7vWnWsnvPBgTuR1GxnH2horrRtO?= =?utf-8?q?Isi7CBaoU06hJpV5H/9Sg2v9+5uQjVkalWyU3O+FH5NSOF7PAiHzww7Ebcb/+OGB/?= =?utf-8?q?EDxnhOcyKk0WFEJ/12O5DbUqeVxmHjkgfRbuh+EOzK9VKe/pWpiV5L7qL4Swpy4a/?= =?utf-8?q?D6H5ouGOFVWZzmAi419N0j6Zbc1m9DzeFygXKaePdJQBd4LB0dK0/XeDJUf6gNp8E?= =?utf-8?q?30r0K7JfvtkmHAu2GQIXe2rYCx2DVuiu/HO5hA9r4HqW+0ABo0JgG8lyqaRhNlh5b?= =?utf-8?q?4E4wOR6P+VXOIw7mSL+xPQ1Zdx1+wvbmkDYciIeX7pdxonFZmBPldX+jVM+OVefAD?= =?utf-8?q?zGhZsPTgvTvwHAs7L9ak0J+kA91oUS3G521NTRUsgWlf4bIp5shoP9edhHoIFQS59?= =?utf-8?q?pTKIsityWCuFkLrPWegfUoVpzBSb86dNSSnt4XorQPBtXAxxVnzRivUuQ4j3ZiRF2?= =?utf-8?q?h9LJTytCz16rjASxeDADtLQQFqDjv9KzdAo2c6EEXXvY2HMsGpirthIEQRevWg61d?= =?utf-8?q?ozEsmG4ti0TO96yTmp5Kqpnh246Q1KVnMypcnL75hFjT6JhVu+cBbyBWEL//vk+CP?= =?utf-8?q?umB4cvu+ImFh6P7A5+t+UsMhqHcmnVqmFpyzNtfryKDrRRX+yxQM+i90Q1gWEwf+j?= =?utf-8?q?z8aXo28PKJP3229vg16w6zoZcgIqxOkBWjFApOlmRbO2CgsGj9guJsnj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2uIo4NilqhY0A?= =?utf-8?q?Z9HLPjgC1XMBbopjT1SLbthRIHamTCNCB1JAitmizIHnn1lfUhFNg3KkAeKDrrgvQ?= =?utf-8?q?U6nIh5GcncVECvfK7nNNxoIgKlqVwHwt6WSr44+IceP+3E0t3Sth4=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f8a5b20-5181-49f1-393e-08da2399e882 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2022 13:21:56.5256 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YrJ4HswcJObdlM1qjxqQIKvi+hiCYD9/aBN4S4ECZO4pEwxmNsywssN5QibGjgvKA2s7rhs/rrL2Vk4qT5m4uQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR03MB3649 No functional change intended. Signed-off-by: Roger Pau Monné --- xen/arch/x86/include/asm/io_apic.h | 57 ++++++++++++++++-------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/include/asm/io_apic.h b/xen/arch/x86/include/asm/io_apic.h index ef0878b09e..a558bb063c 100644 --- a/xen/arch/x86/include/asm/io_apic.h +++ b/xen/arch/x86/include/asm/io_apic.h @@ -89,35 +89,38 @@ enum ioapic_irq_destination_types { }; struct IO_APIC_route_entry { - unsigned int vector:8; - unsigned int delivery_mode:3; /* - * 000: FIXED - * 001: lowest prio - * 111: ExtINT - */ - unsigned int dest_mode:1; /* 0: physical, 1: logical */ - unsigned int delivery_status:1; - unsigned int polarity:1; /* 0: low, 1: high */ - unsigned int irr:1; - unsigned int trigger:1; /* 0: edge, 1: level */ - unsigned int mask:1; /* 0: enabled, 1: disabled */ - unsigned int __reserved_2:15; - union { struct { - unsigned int __reserved_1:24; - unsigned int physical_dest:4; - unsigned int __reserved_2:4; - } physical; - - struct { - unsigned int __reserved_1:24; - unsigned int logical_dest:8; - } logical; - - /* used when Interrupt Remapping with EIM is enabled */ - unsigned int dest32; - } dest; + unsigned int vector:8; + unsigned int delivery_mode:3; /* + * 000: FIXED + * 001: lowest prio + * 111: ExtINT + */ + unsigned int dest_mode:1; /* 0: physical, 1: logical */ + unsigned int delivery_status:1; + unsigned int polarity:1; /* 0: low, 1: high */ + unsigned int irr:1; + unsigned int trigger:1; /* 0: edge, 1: level */ + unsigned int mask:1; /* 0: enabled, 1: disabled */ + unsigned int __reserved_2:15; + + union { + struct { + unsigned int __reserved_1:24; + unsigned int physical_dest:4; + unsigned int __reserved_2:4; + } physical; + + struct { + unsigned int __reserved_1:24; + unsigned int logical_dest:8; + } logical; + unsigned int dest32; + } dest; + }; + uint64_t raw; + }; }; /* From patchwork Thu Apr 21 13:21:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12821621 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 E1052C433F5 for ; Thu, 21 Apr 2022 13:22:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.310172.526872 (Exim 4.92) (envelope-from ) id 1nhWl7-0006Df-AM; Thu, 21 Apr 2022 13:22:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 310172.526872; Thu, 21 Apr 2022 13:22:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhWl7-0006DR-5p; Thu, 21 Apr 2022 13:22:09 +0000 Received: by outflank-mailman (input) for mailman id 310172; Thu, 21 Apr 2022 13:22:07 +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 1nhWl5-0005Gk-DJ for xen-devel@lists.xenproject.org; Thu, 21 Apr 2022 13:22:07 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0810eb34-c176-11ec-8fc2-03012f2f19d4; Thu, 21 Apr 2022 15:22:04 +0200 (CEST) Received: from mail-bn8nam12lp2171.outbound.protection.outlook.com (HELO NAM12-BN8-obe.outbound.protection.outlook.com) ([104.47.55.171]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Apr 2022 09:22:02 -0400 Received: from DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) by BN7PR03MB3649.namprd03.prod.outlook.com (2603:10b6:406:c9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.13; Thu, 21 Apr 2022 13:22:01 +0000 Received: from DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e]) by DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e%4]) with mapi id 15.20.5186.015; Thu, 21 Apr 2022 13:22:01 +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: 0810eb34-c176-11ec-8fc2-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650547325; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=CWJ3gYXTvrTAejdEzgkAoSP58R+z0deJo29UzhQr/fI=; b=DqMGwY7BH7Xu3wpefUB3/3Xd5/BwD5Y7nxYdgfusPwdk465TFyA2yCB2 iP6c4Gxs7tX0YKvpi7TlMS3nxV3IeVNY0HpWWL+RhifHHBBvxUPQ7rJX9 fXtgXG4QUrAIdo2BAJ+Z4Y0UDzTgN12q1v8PKRoQRrVV6GNEDIQZY3ipj E=; X-IronPort-RemoteIP: 104.47.55.171 X-IronPort-MID: 69007247 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:GH0sHaIDsVV6C8DTFE+RpZQlxSXFcZb7ZxGr2PjKsXjdYENSgjwHz zdOCDqDPPeKN2r9ed93boS+8E0EuJ/XyYVgHlZlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokf0/0vrav67xZVF/fngqoDUUYYoAQgsA148IMsdoUg7wbRh3tQx2YHR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 O1AhLKOaCEPArHJscQNCzNjDTp3MrITrdcrIVDn2SCS52vvViK2ht9IXAQxN4Be/ftrC2ZT8 /BeMCoKch2Im+OxxvS8V/VogcMgasLsOevzuFk5lW2fUalgHM2FGvqTjTNb9G5YasRmB/HRa tBfcTNyRB/BfwdOKhEcD5dWcOKA2CinK2IC9A39SawfxnXKzDIv85/WIv3TR9m6ZJlOvHy0n zeTl4j+KlRAXDCF8hKV/3TpiuLRkCfTXIMJCKb+5vNsmEeUxGEYFFsRT1TTifuzh1O6WtlfA 1cJ4Sdopq83nGS0SvHtUhv+p2SL1iPwQPJVGuw+rQuLmqzd5l/DAnBeF2EYLts7qMUxWDomk EeTmM/kDiBut7vTTm+B8rCTrnW5Pi19wXI+WBLohDAtu7HLyLzfRDqTJjq/OMZZVuHIJAw= IronPort-HdrOrdr: A9a23:+adrA6D/jRhC9MTlHeg+sceALOsnbusQ8zAXPh9KJCC9I/bzqy nxpp8mPH/P5wr5lktQ++xoX5PwO080lKQFmrX5WI3PYOCIghrNEGgP1+vfKnjbalTDH41mpN hdmtZFebrN5DFB5K6VgTVQUexQuOVvmJrY+ds2pE0dKD2CBZsQjDuQXW2gYzBLrUR9dNMEPa vZwvACiyureHwRYMj+Ln4ZX9Lbr9mOsJ79exYJCzMu9QHL1FqTmfXHOind+i1bfyJEwL8k/2 SAuwvl5p+7u/X+7hPHzWfc47lfhdOk4NpeA86njNQTN1zX+06VTbUkf4fHkCE+oemp5lpvuN 7Qoy04N8A20H/VdnHdm2qY5yDQlBIVr1Pyw16RhnXu5ebjQighNsZHjYVFNjPE9ksJprhHoe 129lPck6ASIQLLnSz76dSNfQptjFCIrX0rlvNWp2BDULEZdKRaoeUkjQ9o+a87bWPHAb0cYa lT5Jm23ocUTbraVQGVgoBX+q3jYpxpdS32AHTruaSuok1rdT5Cvg4lLfck7wY9HaIGOud5Dt v/Q9RVfcl1P6krhIJGdZA8qJiMexrwqSylChPgHX3XUIc6Blnql7nbpJ0I2cDCQu178HJ1ou WKbG9l X-IronPort-AV: E=Sophos;i="5.90,278,1643691600"; d="scan'208";a="69007247" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TgqzFhEMb3REGoM5kPrbozRoN85IkOtykfZYj8C7oQAu+5a3oYhQmH9wUu1eeoTwnVfpGUhMil389n7hHAyReAJFyQvxb7Sj8A9XnHMee3G6aRZC4gcYhGXpeuyB3pz4GV6jFKseQCdWnsbE5IpS83kKre/RYoY4IsupwtebnMPWhfAW+nagQjS1NU/kPe5+5PvJ2ekvfCbZ6To2/+kAczW9rYbCLKsU8vJh3CJjwpzRCqghAYouZ9sV3Dn1F0K4qFcyUSBiODcX1q6aTyakAbeBbcCMwj78VLGyP3tUT3dUJEeZ7GukrRKQyHcTWZh4NcqtPX2c7tlrP2Xvvd8J/Q== 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=fxFBazBOOa4h2EtJ6XIkMMGyor8r9knW0X4Tj/Qkz/w=; b=GXC7Hli8iMEYg4R+juHO5HSGW04cb2/O9XFja9NrOOTLnoBHLo3vhXufa7jWF1x0Rhe93RrgBWClcCOVrSO6UZCkLJKakFBTLQ9RfUB1PbFjpxuFhicHMrIP/H5xImTm28XgA5s6dl/fPCoeAZYMJ/VC62Fi4AYn//mvc4yiDT2J1RGeiaByiKOOaeDv9cKPwOpQx2r6aMdehJXa65rgI3I2X9t760evXnI73VFQa5ZQuJ6tU0Ztg0yU2Wtm6Wj7aYgy6EhCJ99+fKqnlHkNj+lHo4XD22R52rBKwlWCdbTslerdDRi3YND1wOrkAKoB87hiwG3afGoRcaSLu3C3gw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fxFBazBOOa4h2EtJ6XIkMMGyor8r9knW0X4Tj/Qkz/w=; b=pxPZZwsIJEHX4ag+xFGuRqtcRAC73Flpvb1vt5nRD9c4zJmNMuyt3ymaI56DkUtGR/ib8JKG2yEetq2hKQnaRIFf9MCvcnfDTty0Jh2CO+sKLwYya1PnCTYJ0e33zQQUWmG/G6dXr3Pgd8zfRKsuJ+BhIiiGsxyMq1+ANf8g05w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH RFC 3/6] x86/ioapic: RTE modifications must use ioapic_write_entry Date: Thu, 21 Apr 2022 15:21:11 +0200 Message-Id: <20220421132114.35118-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220421132114.35118-1-roger.pau@citrix.com> References: <20220421132114.35118-1-roger.pau@citrix.com> X-ClientProxiedBy: MR2P264CA0094.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:32::34) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8fc159d7-4677-41c1-b0fa-08da2399eb40 X-MS-TrafficTypeDiagnostic: BN7PR03MB3649:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E5TsDMUE/03yaWqirUV8gPSNx13m1xR5/GWs/twknhLFj2g0HdqAlZkWkMIYCMnRlG8gQjAHAfMqGDHXz4tOYrPtOqnuapoyadmFjSuoS7kE0T8ItUJovz/qg6c/ySrawLeAtXthXdlri57GoivJxCyHQxdkuGFy/oEz+JKXU7HZyca3gmy4HIR0Ft82r0ZqfxYV+RYcuAsmcim4D6c1Sd5BD5LrpC/+qkmlg2Fb7up95npII67k6dKdRwAG6GAsoNxPDnjhPihjXCuK+eDlWxrftfaxb1EcNklcoN4PS+VGfYxKVYOtZb+5NaeHXkielLi6N/k+RFiMuQ0U64b4YxTYrQy1WV7cT7Xv9dpnSSHLDVlamI5twMK5j7fQx5yYAUNTUm2EXsbMfc4mTaC8xJle1/V/hJnynytPtIpof6Q/0B6s9iq14D0suVC4XSlryLRo39c7k4edvQzv+mIyAH4j5MObhhUlRWfDnvRD/Hojy3XLaqAOCMgPk7VjD0DXSOHt4fR/UA8TqoS0CSVfgY03qZExo3wmcG5HEVXwMlVGMc7CMp9Z+FM6Zl9WmRbxOuytbA459UUmw4Pv7rRABnmbiAt+inekpGGTagykGdR+yHGJLQGM6x1ujIDKwGOVpvN9kct1wHvY9n+Ui+hsYQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(186003)(6666004)(1076003)(6512007)(316002)(26005)(36756003)(54906003)(6916009)(2616005)(2906002)(6506007)(8676002)(4326008)(83380400001)(38100700002)(82960400001)(8936002)(66476007)(66556008)(66946007)(86362001)(6486002)(5660300002)(508600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?HU5Zd7Y+YZybx4nJcXb3rWjy+mMU?= =?utf-8?q?gSzhFupOn8cHts8EQbaotqCAGw+rwJZm7wjMFJlPIAo4EVhFwB02xBdTTef5XWaV0?= =?utf-8?q?8scPJkj2Io6UaTWvhmTOb95eBKw9iKe+riMCLFESJQu+SZyhJBdtUF7gAhqLKm+uz?= =?utf-8?q?YZQeqMnh+dAOEgjliTB0hwbeYbA9rSlUc/lPPJ2WQEOVWaFdVYpxtRmdpB9up5Poo?= =?utf-8?q?RMqUIxIx73w3s5uuP11u1dmXoxPvssMijvRPHbzz5l3Tg2Cph6utIYpUjHIY5pC45?= =?utf-8?q?RgJ33KCeiTpP3pAAXrRtWWnAgo7WKYuE/8gou6gkDPwehcKD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aiW3amIYtxWIrCF3d2DrJCDyzFaVCkVjlv8xwUwdFqRQ5e+3+CnB9+t+XwRX73?= =?utf-8?q?lT20Tkt1nazbe9/sD+yhXbTwFiwxL9XMekNEwWGHCfaaYy9aWRgcolNyRIakc3vEP?= =?utf-8?q?bjmdPsmb3KwpAz1+38IoxWkGyY7BNLfRwu8TuRjybXDaanb3xeUwacNPCDdfD/RRV?= =?utf-8?q?NwDWxkTMOYBWdYSCovLRnJiJRfiUpf35HVgc3NPydZi1csk/sjfxjQpgWk+4zezJE?= =?utf-8?q?RGjOqiYfwtYHickKWzZBk7g3MX3xdiCp4CwucGv2P3WNfZN8X2T42lu+WReufarCG?= =?utf-8?q?0skC3lwV2fxCAKtSfXIDHRGh2dULiWI2f06DXEFTEoxrsFdmrI3jyENJxKDLnwgFH?= =?utf-8?q?WFRT/xwXUxh+oL2B55/9hdIUF59gCkUwj4ndDZuNJarUNLXSiVQSgEDOl5hSKJReU?= =?utf-8?q?62WxUuTf+WUZHQPDVc+GwYwXJN1j1lDxbYuUFOARvAP5s0nbB142s=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8fc159d7-4677-41c1-b0fa-08da2399eb40 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2022 13:22:01.2387 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Zqh+wgA+9lhq4jDd+rqVijPthwzHDjzLTvxyfLlEP4eFq7aBzPCQzaxTm421EPDuAojSPuKeR+N0P3ZKdT95Bg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR03MB3649 Do not allow to write to RTE registers using io_apic_write and instead require changes to RTE to be performed using ioapic_write_entry. This is in preparation for passing the full contents of the RTE to the IOMMU interrupt remapping handlers, so remapping entries for IO-APIC RTEs can be updated atomically when possible. Signed-off-by: Roger Pau Monné --- xen/arch/x86/include/asm/io_apic.h | 15 ++---------- xen/arch/x86/io_apic.c | 37 +++++++++++++++--------------- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/xen/arch/x86/include/asm/io_apic.h b/xen/arch/x86/include/asm/io_apic.h index a558bb063c..c26261aecb 100644 --- a/xen/arch/x86/include/asm/io_apic.h +++ b/xen/arch/x86/include/asm/io_apic.h @@ -161,22 +161,11 @@ static inline void __io_apic_write(unsigned int apic, unsigned int reg, unsigned static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value) { - if ( ioapic_reg_remapped(reg) ) - return iommu_update_ire_from_apic(apic, reg, value); + /* RTE writes must use ioapic_write_entry. */ + BUG_ON(reg >= 0x10); __io_apic_write(apic, reg, value); } -/* - * Re-write a value: to be used for read-modify-write - * cycles where the read already set up the index register. - */ -static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value) -{ - if ( ioapic_reg_remapped(reg) ) - return iommu_update_ire_from_apic(apic, reg, value); - *(IO_APIC_BASE(apic) + 4) = value; -} - /* 1 if "noapic" boot option passed */ extern bool skip_ioapic_setup; extern bool ioapic_ack_new; diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 2e5964640b..3a5e3b7872 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -269,15 +269,15 @@ void __ioapic_write_entry( { union entry_union eu = { .entry = e }; - if ( raw ) + if ( raw || !iommu_intremap ) { __io_apic_write(apic, 0x11 + 2 * pin, eu.w2); __io_apic_write(apic, 0x10 + 2 * pin, eu.w1); } else { - io_apic_write(apic, 0x11 + 2 * pin, eu.w2); - io_apic_write(apic, 0x10 + 2 * pin, eu.w1); + iommu_update_ire_from_apic(apic, 0x11 + 2 * pin, eu.w2); + iommu_update_ire_from_apic(apic, 0x10 + 2 * pin, eu.w1); } } @@ -433,16 +433,17 @@ static void modify_IO_APIC_irq(unsigned int irq, unsigned int enable, unsigned int disable) { struct irq_pin_list *entry = irq_2_pin + irq; - unsigned int pin, reg; for (;;) { - pin = entry->pin; + unsigned int pin = entry->pin; + struct IO_APIC_route_entry rte; + if (pin == -1) break; - reg = io_apic_read(entry->apic, 0x10 + pin*2); - reg &= ~disable; - reg |= enable; - io_apic_modify(entry->apic, 0x10 + pin*2, reg); + rte = __ioapic_read_entry(entry->apic, pin, false); + rte.raw &= ~(uint64_t)disable; + rte.raw |= enable; + __ioapic_write_entry(entry->apic, pin, false, rte); if (!entry->next) break; entry = irq_2_pin + entry->next; @@ -584,16 +585,16 @@ set_ioapic_affinity_irq(struct irq_desc *desc, const cpumask_t *mask) dest = SET_APIC_LOGICAL_ID(dest); entry = irq_2_pin + irq; for (;;) { - unsigned int data; + struct IO_APIC_route_entry rte; + pin = entry->pin; if (pin == -1) break; - io_apic_write(entry->apic, 0x10 + 1 + pin*2, dest); - data = io_apic_read(entry->apic, 0x10 + pin*2); - data &= ~IO_APIC_REDIR_VECTOR_MASK; - data |= MASK_INSR(desc->arch.vector, IO_APIC_REDIR_VECTOR_MASK); - io_apic_modify(entry->apic, 0x10 + pin*2, data); + rte = __ioapic_read_entry(entry->apic, pin, false); + rte.dest.dest32 = dest; + rte.vector = desc->arch.vector; + __ioapic_write_entry(entry->apic, pin, false, rte); if (!entry->next) break; @@ -2129,10 +2130,8 @@ void ioapic_resume(void) reg_00.bits.ID = mp_ioapics[apic].mpc_apicid; __io_apic_write(apic, 0, reg_00.raw); } - for (i = 0; i < nr_ioapic_entries[apic]; i++, entry++) { - __io_apic_write(apic, 0x11+2*i, *(((int *)entry)+1)); - __io_apic_write(apic, 0x10+2*i, *(((int *)entry)+0)); - } + for (i = 0; i < nr_ioapic_entries[apic]; i++, entry++) + __ioapic_write_entry(apic, i, true, *entry); } spin_unlock_irqrestore(&ioapic_lock, flags); } From patchwork Thu Apr 21 13:21:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12821622 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 377F4C433FE for ; Thu, 21 Apr 2022 13:22:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.310177.526883 (Exim 4.92) (envelope-from ) id 1nhWlE-0006ut-RX; Thu, 21 Apr 2022 13:22:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 310177.526883; Thu, 21 Apr 2022 13:22:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhWlE-0006ui-N6; Thu, 21 Apr 2022 13:22:16 +0000 Received: by outflank-mailman (input) for mailman id 310177; Thu, 21 Apr 2022 13:22:14 +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 1nhWlC-0006Vx-D9 for xen-devel@lists.xenproject.org; Thu, 21 Apr 2022 13:22:14 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0c927209-c176-11ec-a405-831a346695d4; Thu, 21 Apr 2022 15:22:12 +0200 (CEST) Received: from mail-bn8nam11lp2171.outbound.protection.outlook.com (HELO NAM11-BN8-obe.outbound.protection.outlook.com) ([104.47.58.171]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Apr 2022 09:22:08 -0400 Received: from DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) by DM6PR03MB3771.namprd03.prod.outlook.com (2603:10b6:5:4e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Thu, 21 Apr 2022 13:22:06 +0000 Received: from DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e]) by DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e%4]) with mapi id 15.20.5186.015; Thu, 21 Apr 2022 13:22:05 +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: 0c927209-c176-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650547332; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=7YRqHDhmiB+IydPusKoIgSDWAyO7QgBP+ELxznFDh5c=; b=JmIhSHxlm5qiBSlCKzebWCHqqMSLBEsut4GX5tUyCrnTnyWyd5w9ak4m mGbcRC/ZLKGlTMH0W/naa3FfLdw/c4wUlUVtYHRpo0vZ0GLK6vaeHJYxk k96n6cHoPSnXTKpDvc4iBiUlUPcwc/TuQ7/sH7gXrFLn6heOaHkppiSQJ c=; X-IronPort-RemoteIP: 104.47.58.171 X-IronPort-MID: 70011025 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:8RXj2q4tLis4+CHsbRL/UAxRtCjGchMFZxGqfqrLsTDasY5as4F+v mMeX2GGbPeKMDbxct11b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n9nKzMdFGaW3+4EoAwSprjztSJVqWrWEsjxwiOaz6GwymN 2JmBskN9Qb0QKlQkiF5T/WnyXw2jcn7HHvjXWCh2H4nMD/TDUmT+JcmINwaHLimgYdleA59J gO83OStpJRAx+Ftj/6/cL0WxZjkVfxiWY+kNQUk2dUXeIlGfJsRLQkjQ1o+ao7bWPHANhNKp gvMCic3ocdTbqiVQGXgoE1q+bcHUjaHX+9Mzo/U4KuonprdUtCvjQlLfwk7ws9Ha0GOud5Dp z/Q8JVfZF1P7srhPFGdZA8qfXeMB28fTv8dESvHH/AKIYrf1rwlr+f2sRH2AjtQu1C8KcP X-IronPort-AV: E=Sophos;i="5.90,278,1643691600"; d="scan'208";a="70011025" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yz8tz8/wYqnSSm2dd+E14l3meHqH+KAgQeatEidikiTeuMqdD3ItGR43OSSV2J6wQRQk7LhI9zoacsGtz3lQjjyM/LBwwbq0LQM3T5mhWS+SDIJo3f9HCbHgA/6r0Wuc3YmES/MUxsJm+Ozdw26BHphYE5u8ktSgCIlocx5fj9zsilotpSfKIaTzzSTehpJb8s6rRml9mDwLXjoRmGrp+zD/f7swEVEyzAoIAAajovOrfKTFy0x5CIYGHF4tcQTRK+QcdoySndS7MAmCWA487UoEh1vYgJdO8lxJrMw9a6QHrUEaazY1PoMPd0OUYdoj2OAtwvu0MZFTlO45jiN5TQ== 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=FOHBZEpDF09Hk8lNie+2sWfpJc6zb8jWHm0gVWptEBg=; b=FnaorujnPZQnF7NWlwqXyTvDuVwOd/BVXzGjkUUp6JKqNkfwaj7MXSNB/mtrIZuAAwiUIsjqCLD7ywk80tA7E27ltEMcRdxD75u0/gD57wkSoBIjaaeXgIahGIghI8E5ANUh/98RxfRlGbUF3po/KoveHOeS3Gzcizcx1eQaCgJxXHw0Xpd4bH9uQHSkMmMbw+AMviWE6bfBXiYrRQONu2DJk+vJiUZcVJtZDp+In1ryrfnOgDlUqwZVnZNJU+F11uX0VUP4DZ4IPa1O3MksTdjLZSvsYMGHJrcMhntC51f6FeCEnTBBYzmTt+1uQ/v056NOn+ClqELz73xMquKEHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FOHBZEpDF09Hk8lNie+2sWfpJc6zb8jWHm0gVWptEBg=; b=xctScZo3c4pVpyBuWmLr8XkWnV2xokWr9gqyXejnuejkrRtG20NicwpTD7vG5vMcfYY5zL9ZurLs7gEP4i1lV85Y2xHIEZGP2o+KNPiBm1SE3kk9VLdodciFFjWo4HFGoY6JKUgNRAELLZx5sUnYLUWSaZBvj96DRGE7MvI61K0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu , Kevin Tian , Paul Durrant Subject: [PATCH RFC 4/6] x86/iommu: pass full IO-APIC RTE for remapping table update Date: Thu, 21 Apr 2022 15:21:12 +0200 Message-Id: <20220421132114.35118-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220421132114.35118-1-roger.pau@citrix.com> References: <20220421132114.35118-1-roger.pau@citrix.com> X-ClientProxiedBy: MR2P264CA0082.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:32::22) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e04b4fd-75a6-4d76-19b7-08da2399ee05 X-MS-TrafficTypeDiagnostic: DM6PR03MB3771:EE_ X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gdR8h9qMAnOoKhH5lTxbtJ1I1ck2zoVcA0v0GL9WbW9JAG1Wu6IGNHTBTeLcMMZzDlCIzTkW7SMOrEghwq8H1FCmTShASSM9zDC1mKrAx2PSK+xmtIDSnfXIp/b0cDTZFuHmsxgb7Td3iKkkzQQIDTM57LDGwzg3dfQoaRc7bp+jik/fUDIcQ6ICI98OBEe0pUX5mjdFEC8PtaiyTVyxFtIG2ecKptEyd02gPRENLKDk1nBTIcVWm6htkWV8JOesPOfiKOV/QHo5No+BapHMQNliDDhs7O/l1tXrUTmGAFMBheInux6a5WX1Daupo6NaL1TOEJiHLhmZSv7FM+76f4lE1whxqQhJt9JNWfUqeQUL/hkDZil46EA6TxMcGotwGGzxcNVj1y4UDsB6yeVrS++DQ/GeeITqcGOsamWrTEaPSyce6E67R+Eufpgd0b/p/faI+DlbdAiUc46ivHBCYlqk4XyXkQAwinKS1/f86Y6Kqf1P+zxBfu6BlvWaTUOrKxgMEcJIY5OGFYgq5c4U3Rj3ko0XbHKnRaHoM8poLGhW/bURBSY7FX3nW2hrdcIFEp/mEjAu3RTugYj6axo95lHZzlYwzQS4aU3hwJ9hZS5E9LNeim2X0VxStxYvxnD36vgNaa0mo5VgkHQJVVwmgg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6666004)(82960400001)(316002)(186003)(2616005)(26005)(5660300002)(30864003)(83380400001)(2906002)(6512007)(4326008)(8936002)(15650500001)(66556008)(6506007)(86362001)(66476007)(38100700002)(1076003)(8676002)(508600001)(54906003)(6486002)(66946007)(6916009)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?4gnpUcwjolb/PRRa5zCZgXzWzCuJ?= =?utf-8?q?W7RGIXAWD8t8DgqpnkWWEmSquXpg5uUqeoM7kh9cbb0ozW0pVbRac/5J2gppqRVFt?= =?utf-8?q?ok8OM3cxn8iucdAjZG/zEIhupSUMGW7kGR2u+59iWTtmgMXGEDxZt28mpTuoaZc+h?= =?utf-8?q?T4631k14rDm8PD6PiFy1mGtBfnzIzVVObfCp8vPkqs1haFaLlYa5vVMbg1DQxOQ4k?= =?utf-8?q?TQzFwxZZ4vXtqVGBEZ2UWyIYO9GXTLUCXAV6t4J6tXzFWEy030/D/9lkpaR4mzgpF?= =?utf-8?q?I3MqHqlGS4Z2dX0ngOa+RMHgf5u0TDiKw2z7cPbHOdvzw/dLGXjK4eratK6QnJ0Ez?= =?utf-8?q?p5F5ZdJJW1k40P3xY83sMGdy2RGxAhmQp/NlzjB7hRHbJrjrVDN1UVgX06cprH9DW?= =?utf-8?q?ss+kpTfFUVCr1Wp98cSiE256kiEA4eoup1crKY9bgT1BN6Qeu7qirWIN6LnGR2CoG?= =?utf-8?q?1M6bJ1iF447euc1lkM01D/85vDG5MsT1w8NEIdf/LRQ/lLGA9DraUX+bGDP5o0mmg?= =?utf-8?q?BGMtotnMRgRAyn/vqNatXVQVLNP23K+sr5FBbn3tW/pE2Jdr6QHIpZEPUpOfczFrz?= =?utf-8?q?f/Z3Q9nyF10A0KdjGE5ErRUSyF0JfH2eq31eV8QvGD1xC/NhM9O2HnY5cq9zmruej?= =?utf-8?q?YTNdjfoQstzX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LeUQeG2vbAyAU9XgCWY4yu9AyRfe5Qc0xg+hVq?= =?utf-8?q?fIihjhBtft3FKBExln6yLVFAC+FqSUIMI4OR2XJAPfYyBV+ifIYwygHC51kI199X0?= =?utf-8?q?N2QK4ppxSvH7N8u+Cfw9r47FEQwZUdMN6p/+6cVRTUMYM8/KvkQ7I=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e04b4fd-75a6-4d76-19b7-08da2399ee05 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2022 13:22:05.8188 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: W21p7AyHntu1s7JnHXiU7DvFDxMC9fPryBvgwLWJuPagKFGoNj0f+kmPR0aC3SpXlPjiSWxgBLoMi41sxefL6Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB3771 So that the remapping entry can be updated atomically when possible. Doing such update atomically will avoid Xen having to mask the IO-APIC pin prior to performing any interrupt movements (ie: changing the destination and vector fields), as the interrupt remapping entry is always consistent. This also simplifies some of the logic on both VT-d and AMD-Vi implementations, as having the full RTE available instead of half of it avoids to possibly read and update the missing other half from hardware. While there remove the explicit zeroing of new_ire fields in ioapic_rte_to_remap_entry and initialize the variable at definition so all fields are zeroed. Note fields could be also initialized with final values at definition, but I found that likely too much to be done at this time. Signed-off-by: Roger Pau Monné --- There's some functional differences between VT-d and AMD-Vi that we might also want to address: the logic on failure from setting up the remap entry on VT-d unmasks the previous RTE, while on AMD-Vi the pin is left masked. Note that certain combination of changes to the RTE are impossible to handle atomically. For example changing the vector and/or destination fields together with the triggering mode is impossible to be performed atomically (as the destination and vector is set in the IRTE, but the triggering mode is set in the RTE). Xen doesn't attempt to perform such changes in a single update to the RTE anyway, so it's fine. Since the IOMMU code now also uses __ioapic_write_entry to update the RTE it might be helpful to introduce an explicit raw version of the function, as IOMMU always wants to write the provided raw value to the RTE. --- xen/arch/x86/include/asm/iommu.h | 3 +- xen/arch/x86/io_apic.c | 5 +- xen/drivers/passthrough/amd/iommu.h | 2 +- xen/drivers/passthrough/amd/iommu_intr.c | 84 ++------------- xen/drivers/passthrough/vtd/extern.h | 2 +- xen/drivers/passthrough/vtd/intremap.c | 125 +++++++++++------------ xen/drivers/passthrough/x86/iommu.c | 4 +- xen/include/xen/iommu.h | 3 +- 8 files changed, 80 insertions(+), 148 deletions(-) diff --git a/xen/arch/x86/include/asm/iommu.h b/xen/arch/x86/include/asm/iommu.h index 9ccf4f8bdd..1d62b42e17 100644 --- a/xen/arch/x86/include/asm/iommu.h +++ b/xen/arch/x86/include/asm/iommu.h @@ -97,7 +97,8 @@ struct iommu_init_ops { extern const struct iommu_init_ops *iommu_init_ops; -void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value); +void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, + uint64_t rte); unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg); int iommu_setup_hpet_msi(struct msi_desc *); diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 3a5e3b7872..f61e56f3d1 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -275,10 +275,7 @@ void __ioapic_write_entry( __io_apic_write(apic, 0x10 + 2 * pin, eu.w1); } else - { - iommu_update_ire_from_apic(apic, 0x11 + 2 * pin, eu.w2); - iommu_update_ire_from_apic(apic, 0x10 + 2 * pin, eu.w1); - } + iommu_update_ire_from_apic(apic, pin, e.raw); } static void ioapic_write_entry( diff --git a/xen/drivers/passthrough/amd/iommu.h b/xen/drivers/passthrough/amd/iommu.h index 64e4bbf33c..35df504406 100644 --- a/xen/drivers/passthrough/amd/iommu.h +++ b/xen/drivers/passthrough/amd/iommu.h @@ -298,7 +298,7 @@ int cf_check amd_iommu_free_intremap_table( unsigned int amd_iommu_intremap_table_order( const void *irt, const struct amd_iommu *iommu); void cf_check amd_iommu_ioapic_update_ire( - unsigned int apic, unsigned int reg, unsigned int value); + unsigned int apic, unsigned int pin, uint64_t raw); unsigned int cf_check amd_iommu_read_ioapic_from_ire( unsigned int apic, unsigned int reg); int cf_check amd_iommu_msi_msg_update_ire( diff --git a/xen/drivers/passthrough/amd/iommu_intr.c b/xen/drivers/passthrough/amd/iommu_intr.c index cebf9ceca7..feed1d1447 100644 --- a/xen/drivers/passthrough/amd/iommu_intr.c +++ b/xen/drivers/passthrough/amd/iommu_intr.c @@ -247,11 +247,6 @@ static void update_intremap_entry(const struct amd_iommu *iommu, } } -static inline int get_rte_index(const struct IO_APIC_route_entry *rte) -{ - return rte->vector | (rte->delivery_mode << 8); -} - static inline void set_rte_index(struct IO_APIC_route_entry *rte, int offset) { rte->vector = (u8)offset; @@ -267,7 +262,6 @@ static int update_intremap_entry_from_ioapic( int bdf, struct amd_iommu *iommu, struct IO_APIC_route_entry *rte, - bool_t lo_update, u16 *index) { unsigned long flags; @@ -315,31 +309,6 @@ static int update_intremap_entry_from_ioapic( spin_lock(lock); } - if ( fresh ) - /* nothing */; - else if ( !lo_update ) - { - /* - * Low half of incoming RTE is already in remapped format, - * so need to recover vector and delivery mode from IRTE. - */ - ASSERT(get_rte_index(rte) == offset); - if ( iommu->ctrl.ga_en ) - vector = entry.ptr128->full.vector; - else - vector = entry.ptr32->flds.vector; - /* The IntType fields match for both formats. */ - delivery_mode = entry.ptr32->flds.int_type; - } - else if ( x2apic_enabled ) - { - /* - * High half of incoming RTE was read from the I/O APIC and hence may - * not hold the full destination, so need to recover full destination - * from IRTE. - */ - dest = get_full_dest(entry.ptr128); - } update_intremap_entry(iommu, entry, vector, delivery_mode, dest_mode, dest); spin_unlock_irqrestore(lock, flags); @@ -350,23 +319,15 @@ static int update_intremap_entry_from_ioapic( } void cf_check amd_iommu_ioapic_update_ire( - unsigned int apic, unsigned int reg, unsigned int value) + unsigned int apic, unsigned int pin, uint64_t raw) { - struct IO_APIC_route_entry old_rte = { 0 }; - struct IO_APIC_route_entry new_rte = { 0 }; - unsigned int rte_lo = (reg & 1) ? reg - 1 : reg; - unsigned int pin = (reg - 0x10) / 2; + struct IO_APIC_route_entry new_rte = { .raw = raw }; + struct IO_APIC_route_entry old_rte = { }; int seg, bdf, rc; bool saved_mask, fresh = false; struct amd_iommu *iommu; unsigned int idx; - if ( !iommu_intremap ) - { - __io_apic_write(apic, reg, value); - return; - } - idx = ioapic_id_to_index(IO_APIC_ID(apic)); if ( idx == MAX_IO_APICS ) return; @@ -379,26 +340,14 @@ void cf_check amd_iommu_ioapic_update_ire( { AMD_IOMMU_WARN("failed to find IOMMU for IO-APIC @ %04x:%04x\n", seg, bdf); - __io_apic_write(apic, reg, value); + __ioapic_write_entry(apic, pin, true, new_rte); return; } /* save io-apic rte lower 32 bits */ - *((u32 *)&old_rte) = __io_apic_read(apic, rte_lo); + old_rte = __ioapic_read_entry(apic, pin, true); saved_mask = old_rte.mask; - if ( reg == rte_lo ) - { - *((u32 *)&new_rte) = value; - /* read upper 32 bits from io-apic rte */ - *(((u32 *)&new_rte) + 1) = __io_apic_read(apic, reg + 1); - } - else - { - *((u32 *)&new_rte) = *((u32 *)&old_rte); - *(((u32 *)&new_rte) + 1) = value; - } - if ( ioapic_sbdf[idx].pin_2_idx[pin] >= INTREMAP_MAX_ENTRIES ) { ASSERT(saved_mask); @@ -410,7 +359,7 @@ void cf_check amd_iommu_ioapic_update_ire( */ if ( new_rte.mask && !x2apic_enabled ) { - __io_apic_write(apic, reg, value); + __ioapic_write_entry(apic, pin, true, new_rte); return; } @@ -421,16 +370,14 @@ void cf_check amd_iommu_ioapic_update_ire( if ( !saved_mask ) { old_rte.mask = 1; - __io_apic_write(apic, rte_lo, *((u32 *)&old_rte)); + __ioapic_write_entry(apic, pin, true, old_rte); } /* Update interrupt remapping entry */ rc = update_intremap_entry_from_ioapic( - bdf, iommu, &new_rte, reg == rte_lo, + bdf, iommu, &new_rte, &ioapic_sbdf[idx].pin_2_idx[pin]); - __io_apic_write(apic, reg, ((u32 *)&new_rte)[reg != rte_lo]); - if ( rc ) { /* Keep the entry masked. */ @@ -439,20 +386,7 @@ void cf_check amd_iommu_ioapic_update_ire( return; } - /* For lower bits access, return directly to avoid double writes */ - if ( reg == rte_lo ) - return; - - /* - * Unmask the interrupt after we have updated the intremap table. Also - * write the low half if a fresh entry was allocated for a high half - * update in x2APIC mode. - */ - if ( !saved_mask || (x2apic_enabled && fresh) ) - { - old_rte.mask = saved_mask; - __io_apic_write(apic, rte_lo, *((u32 *)&old_rte)); - } + __ioapic_write_entry(apic, pin, true, new_rte); } unsigned int cf_check amd_iommu_read_ioapic_from_ire( diff --git a/xen/drivers/passthrough/vtd/extern.h b/xen/drivers/passthrough/vtd/extern.h index 39602d1f88..032a7c3b42 100644 --- a/xen/drivers/passthrough/vtd/extern.h +++ b/xen/drivers/passthrough/vtd/extern.h @@ -92,7 +92,7 @@ int cf_check intel_iommu_get_reserved_device_memory( unsigned int cf_check io_apic_read_remap_rte( unsigned int apic, unsigned int reg); void cf_check io_apic_write_remap_rte( - unsigned int apic, unsigned int reg, unsigned int value); + unsigned int apic, unsigned int ioapic_pin, uint64_t raw); struct msi_desc; struct msi_msg; diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index e6ba89591b..52058efe86 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -328,12 +328,11 @@ static int remap_entry_to_ioapic_rte( static int ioapic_rte_to_remap_entry(struct vtd_iommu *iommu, int apic, unsigned int ioapic_pin, struct IO_xAPIC_route_entry *old_rte, - unsigned int rte_upper, unsigned int value) + struct IO_xAPIC_route_entry new_rte) { struct iremap_entry *iremap_entry = NULL, *iremap_entries; - struct iremap_entry new_ire; + struct iremap_entry new_ire = { }; struct IO_APIC_route_remap_entry *remap_rte; - struct IO_xAPIC_route_entry new_rte; int index; unsigned long flags; bool init = false; @@ -364,48 +363,37 @@ static int ioapic_rte_to_remap_entry(struct vtd_iommu *iommu, new_ire = *iremap_entry; - if ( rte_upper ) - { - if ( x2apic_enabled ) - new_ire.remap.dst = value; - else - new_ire.remap.dst = (value >> 24) << 8; - } + if ( x2apic_enabled ) + new_ire.remap.dst = new_rte.dest.dest32; else - { - *(((u32 *)&new_rte) + 0) = value; - new_ire.remap.fpd = 0; - new_ire.remap.dm = new_rte.dest_mode; - new_ire.remap.tm = new_rte.trigger; - new_ire.remap.dlm = new_rte.delivery_mode; - /* Hardware require RH = 1 for LPR delivery mode */ - new_ire.remap.rh = (new_ire.remap.dlm == dest_LowestPrio); - new_ire.remap.avail = 0; - new_ire.remap.res_1 = 0; - new_ire.remap.vector = new_rte.vector; - new_ire.remap.res_2 = 0; - - set_ioapic_source_id(IO_APIC_ID(apic), &new_ire); - new_ire.remap.res_3 = 0; - new_ire.remap.res_4 = 0; - new_ire.remap.p = 1; /* finally, set present bit */ - - /* now construct new ioapic rte entry */ - remap_rte->vector = new_rte.vector; - remap_rte->delivery_mode = 0; /* has to be 0 for remap format */ - remap_rte->index_15 = (index >> 15) & 0x1; - remap_rte->index_0_14 = index & 0x7fff; - - remap_rte->delivery_status = new_rte.delivery_status; - remap_rte->polarity = new_rte.polarity; - remap_rte->irr = new_rte.irr; - remap_rte->trigger = new_rte.trigger; - remap_rte->mask = new_rte.mask; - remap_rte->reserved = 0; - remap_rte->format = 1; /* indicate remap format */ - } - - update_irte(iommu, iremap_entry, &new_ire, !init); + new_ire.remap.dst = (new_rte.dest.dest32 >> 24) << 8; + + new_ire.remap.dm = new_rte.dest_mode; + new_ire.remap.tm = new_rte.trigger; + new_ire.remap.dlm = new_rte.delivery_mode; + /* Hardware require RH = 1 for LPR delivery mode */ + new_ire.remap.rh = (new_ire.remap.dlm == dest_LowestPrio); + new_ire.remap.vector = new_rte.vector; + + set_ioapic_source_id(IO_APIC_ID(apic), &new_ire); + new_ire.remap.p = 1; /* finally, set present bit */ + + /* now construct new ioapic rte entry */ + remap_rte->vector = new_rte.vector; + remap_rte->delivery_mode = 0; /* has to be 0 for remap format */ + remap_rte->index_15 = (index >> 15) & 0x1; + remap_rte->index_0_14 = index & 0x7fff; + + remap_rte->delivery_status = new_rte.delivery_status; + remap_rte->polarity = new_rte.polarity; + remap_rte->irr = new_rte.irr; + remap_rte->trigger = new_rte.trigger; + remap_rte->mask = new_rte.mask; + remap_rte->reserved = 0; + remap_rte->format = 1; /* indicate remap format */ + + /* If cmpxchg16b is not available the caller must mask the IO-APIC pin. */ + update_irte(iommu, iremap_entry, &new_ire, !init && cpu_has_cx16); iommu_sync_cache(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); @@ -439,33 +427,44 @@ unsigned int cf_check io_apic_read_remap_rte( } void cf_check io_apic_write_remap_rte( - unsigned int apic, unsigned int reg, unsigned int value) + unsigned int apic, unsigned int ioapic_pin, uint64_t raw) { - unsigned int ioapic_pin = (reg - 0x10) / 2; - struct IO_xAPIC_route_entry old_rte = { 0 }; + struct IO_APIC_route_entry rte = { .raw = raw }; + struct IO_xAPIC_route_entry old_rte = { }; struct IO_APIC_route_remap_entry *remap_rte; - unsigned int rte_upper = (reg & 1) ? 1 : 0; struct vtd_iommu *iommu = ioapic_to_iommu(IO_APIC_ID(apic)); - int saved_mask; - - old_rte = __ioapic_read_entry(apic, ioapic_pin, true); + bool masked = true; + int rc; remap_rte = (struct IO_APIC_route_remap_entry *) &old_rte; - /* mask the interrupt while we change the intremap table */ - saved_mask = remap_rte->mask; - remap_rte->mask = 1; - __io_apic_write(apic, reg & ~1, *(u32 *)&old_rte); - remap_rte->mask = saved_mask; - - if ( ioapic_rte_to_remap_entry(iommu, apic, ioapic_pin, - &old_rte, rte_upper, value) ) + if ( !cpu_has_cx16 ) { - __io_apic_write(apic, reg, value); + /* + * Cannot atomically update the IRTE entry: mask the IO-APIC pin to + * avoid interrupts seeing an inconsistent IRTE entry. + */ + old_rte = __ioapic_read_entry(apic, ioapic_pin, true); + if ( !old_rte.mask ) + { + masked = false; + old_rte.mask = 1; + __ioapic_write_entry(apic, ioapic_pin, true, old_rte); + } + } - /* Recover the original value of 'mask' bit */ - if ( rte_upper ) - __io_apic_write(apic, reg & ~1, *(u32 *)&old_rte); + rc = ioapic_rte_to_remap_entry(iommu, apic, ioapic_pin, &old_rte, rte); + if ( rc ) + { + dprintk(XENLOG_ERR, + "failed to update IRTE for IO-APIC#%u pin %u: %d\n", + apic, ioapic_pin, rc); + if ( !masked ) + { + /* Recover the original value of 'mask' bit */ + old_rte.mask = 0; + __ioapic_write_entry(apic, ioapic_pin, true, old_rte); + } } else __ioapic_write_entry(apic, ioapic_pin, true, old_rte); diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c index d5bf4d3241..e0ad38a09d 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -133,9 +133,9 @@ int iommu_enable_x2apic(void) } void iommu_update_ire_from_apic( - unsigned int apic, unsigned int reg, unsigned int value) + unsigned int apic, unsigned int idx, uint64_t rte) { - iommu_vcall(&iommu_ops, update_ire_from_apic, apic, reg, value); + iommu_vcall(&iommu_ops, update_ire_from_apic, apic, idx, rte); } unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg) diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index 3a83981464..b619cd872b 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -262,7 +262,8 @@ struct iommu_ops { int (*enable_x2apic)(void); void (*disable_x2apic)(void); - void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value); + void (*update_ire_from_apic)(unsigned int apic, unsigned int idx, + uint64_t rte); unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg); int (*setup_hpet_msi)(struct msi_desc *); From patchwork Thu Apr 21 13:21:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12821623 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 15F3DC433EF for ; Thu, 21 Apr 2022 13:22:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.310180.526903 (Exim 4.92) (envelope-from ) id 1nhWlG-0007Rf-OG; Thu, 21 Apr 2022 13:22:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 310180.526903; Thu, 21 Apr 2022 13:22:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhWlG-0007Pg-Id; Thu, 21 Apr 2022 13:22:18 +0000 Received: by outflank-mailman (input) for mailman id 310180; Thu, 21 Apr 2022 13:22:17 +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 1nhWlF-0006Vx-2J for xen-devel@lists.xenproject.org; Thu, 21 Apr 2022 13:22:17 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0e89e0a7-c176-11ec-a405-831a346695d4; Thu, 21 Apr 2022 15:22:15 +0200 (CEST) Received: from mail-dm6nam12lp2176.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.176]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Apr 2022 09:22:12 -0400 Received: from DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) by SA2PR03MB5692.namprd03.prod.outlook.com (2603:10b6:806:11f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Thu, 21 Apr 2022 13:22:10 +0000 Received: from DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e]) by DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e%4]) with mapi id 15.20.5186.015; Thu, 21 Apr 2022 13:22:10 +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: 0e89e0a7-c176-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650547334; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=/bsTBjNEwz+nuNpaTcn/VhN1csiAX9NFexTx2XLkEJ8=; b=ebMfD7/QKD9+KFUyMEvQqog42ynyHsp+fyg3QVTPpA0x9lTqgKGX6I6P /dOhr+FFfdXoUR4GYHrn4jq6r3ttFMDvcmSUVWCydVpa0BQ5MBD9/HXd3 UaAQn4CIZcOBWdN5zVBPXkD8Smj19TQY8HtKthuT/SmALRC+TuqrFKtbR c=; X-IronPort-RemoteIP: 104.47.59.176 X-IronPort-MID: 69485236 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:HSJHLavrRg2Ypi4CTuzphcSXo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8 TNmQ4pO4BJ53bYbgiO0G7Q8jil9Axrx27pyFeej3emi9f+XigGB81Igp8cWgfF6mI71esMnJ 5j7ia8jd56HBnAlCPy65zjTBdxjHe5pnIkjKo6k2Ffa40Dc7VcxLZvsX+9KK1wUh4S1bpXUd WHVKrnlbZrmBKhHjrkV1BUsZORti9ZJGbEfqAA0vbloQS+0koJjXfw//Zv4UvoxKhNN6Ws2N 60TJiA7Is+KPP+TZgNcNvpEvHHfVAkf3r3QRKvCGWiMp07EFTwjLOyyIkJxYiRCe81Jd0J6d /8bG8= X-IronPort-AV: E=Sophos;i="5.90,278,1643691600"; d="scan'208";a="69485236" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hunWtmTAxBGjZ4ixWsT4WgPn3qWzJnhRJEr96b7kBCnllSqhPFXXkcaUO1HxKgkF7EjOWhRm5wWzYZKx2VXQcRdV6TxzbEkLg+T4+ZVTvzcr1l8qmzvt7l8oF0UGTTE+gInCs5xSV4dCasFtSffurRNswart/cK9TPhRiXIHiSmwds6p9Ooe+n7+nsQflKNxmz8ObKYvZauCDn4aG1hxIz3djnuVufRGV2rLDUy46uLH70d+q9qGREMuEHt0X8T2bm6HGLBJ91JlD/rmOt+3hMi6stvhef4g9MRtvowENr1W1yk0Mxo4ODYDI7isjDF3XCaeO1kj/YDBwtpnPMsjcQ== 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=rEx7VOG8mAayx6SJwjyMn32in/pxHdqc+RPxorUEmOM=; b=ikZqYrI9uw/se/mt8vbOE8ArzmNi2QVH99G67fFJ4yEUYtcjK5CJSHoIDTjIZNI56YBc3eH+0hJeYq4Nuurq7mwPF7Fgv8qabPOd3NQA5FM3ODROF76xjhilRXVoV7LEK6Daoom97rQeH5e9czd7COrO7NG9c8C0jXAZTK1S4hveogLZzezEYdSVbhSeMvv3ivudS+egyke8hKAeY7JnxQLML8EIWFMkkNlPM8r9Ngcmhb0DJ/bGyzs4U6kYTV575R4UNt+EArSNPDtq8hO76cL/ZapRl+HbqOhudYEH8FsV/mY7iFR3yEASSVlXKaZo0tAJuM7KvcPhalhmF/ku0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rEx7VOG8mAayx6SJwjyMn32in/pxHdqc+RPxorUEmOM=; b=t+98rKSaD+ls4CWZdV7YdtB7ZnyNGhqSVo/2yYEEEcbvXMm0eU8VBY1ODPDJKxdj+zrEWVOQm/aqftK7nGQW7o1Yv8gtz6/BJUZSKMm5tQHeJHD85Ba7MyjnpKcEgPHA5FPB5FB25w9jlJMsI0ZSN/YZxqwoy88G8fX/E+PBdJU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH RFC 5/6] amd/iommu: atomically update remapping entries when possible Date: Thu, 21 Apr 2022 15:21:13 +0200 Message-Id: <20220421132114.35118-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220421132114.35118-1-roger.pau@citrix.com> References: <20220421132114.35118-1-roger.pau@citrix.com> X-ClientProxiedBy: MR2P264CA0141.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:30::33) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e600cecd-38ad-49a0-159c-08da2399f0c7 X-MS-TrafficTypeDiagnostic: SA2PR03MB5692:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 792vfE659+TBeT8rEsuB30HQ5i2El93f3wqpRKzowcGtFU3G/QOcBDoWZewGzJeXqVcKHKhuF92XWFeraKgfYXItoxID7gqMpOAGjsR5tdE2Jid2iEtdw61VKcBIXz8T3Qhz1/nNFU1peCq2ndkK5orbw7LaP5bizGzb0EoR7SAy1oWvT/dO7MWnHvhtqO/3/R3EBbGiySbAzkA5gzYppvm/TJovi/g+vVQ39WHs6nU9Sg5E0TFH97sp5dYXdf0wSaTd2Pg31eVcit8LHz4M3jtKM72dHr3x5klXBCS3kkZoGJ7tcKq9LPUgNs4VgkKV3UDK0XoJZ0Lo6IEEUPPlLccQkKUv6pAXdewjyRAPD2ypH4ak9fS4c9nLTxGUm0SgcAgM8sAJifs4h1olrhaFL0rNDenxrY9hY4QFKovD6Bs814j+E3B9znSwW/obEiOxJ84y9odbbbQdP6A+FIzfusf6RcMaMg2gEA2OXfcC6tJgqH5Y5ekHlc5ChA2nqNNdR6TApNVDCRdkNiIreZIAnfQmGnRhBZCCeD/qFIGhVUuLMmSgI52C2WBYRjg0TeuUpRo0Is/5/R23hkf9XOfAn/LoN3NYwTIoqDBuEESyKN8uET72IMSqy5w6Mm+Ol+/SIuUMfu7jIrvU+bhX6mlHkA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(508600001)(54906003)(8936002)(5660300002)(83380400001)(107886003)(6916009)(36756003)(1076003)(316002)(86362001)(6486002)(6506007)(186003)(66476007)(66556008)(2906002)(2616005)(66946007)(8676002)(4326008)(6512007)(26005)(15650500001)(38100700002)(82960400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?msqCXIMrtCGHUtVzBdiV8LWBPg1l?= =?utf-8?q?GaSmcMUNLG3I7QZxEM7RjETsbMmZe9TF6+uiqhYsBxspAkLpPbJlS13z1WP1fbZDt?= =?utf-8?q?nApH9kDFvf545PdzsV0jNV8ySU+zkpMVv47C+DNPj6Pmv39muRVNIh5brfnfNgr6E?= =?utf-8?q?hZD+8R0rPHiffwoTHXbDUGWrOELLmh4EmX+D8qboZPce/0+sP3SY6a0fbjt9F2fLK?= =?utf-8?q?hx71FqsQ/bhGi+HNxeHT9wVbd/9FGaoFucTBnLFQX8GwWtJhWNNOTQoewSe/adENa?= =?utf-8?q?QCL2wSk3MVPp7LqC9ikf3n7ytGmVFX/xLlCehmQBVKmem2xwCqs+d8JwcLkwn2hIj?= =?utf-8?q?5nrKuQcZ/2JJDjM7nTr6AZVm+7gLD2n8/DQ0Pxe7av/G5wlxRDyNCL1LidaH44h6v?= =?utf-8?q?JRIm77CsArLmkLSoesv9yFgncG6SVV2KmeFLA1mWmY8SfCpe5okNDDN6tgYNUpuEr?= =?utf-8?q?1S2NtI4D7yEqRNFQTBFzLpnXaxxzHnkr+zu0iBaSxutHA1B1/Ui/bvwZ/lGJYLeuE?= =?utf-8?q?04JaTStZOorYYLemG+oV4iwxeO6/2DUQvoao8b1WXOm1Ain3qjprbsmdMx1u1USC7?= =?utf-8?q?mNAuSrYdSbhlPY9BdTYDOZZyjuWpY1wTHPuSv3U1D1KP2wscf93eT5Rk1X5sWW9zI?= =?utf-8?q?nAQLZZZM2FHr73+TJUAeteGeHSojYHxENMfccCtNDKH1CdKHlsoZ2v3Gj7EQuIkfy?= =?utf-8?q?iZj+AchFcfnFOgc/nr0i3FmMN6zxt+UR3QpiEUuuj/Fa0c7upQ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e3gFvp?= =?utf-8?q?kVGrfAwjB3H2sKrahbICc47opCEEvh3QIU6fXhYedFj3mE3hWr4wc=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: e600cecd-38ad-49a0-159c-08da2399f0c7 X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2022 13:22:10.4143 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bicqIca0jy0XNgX+NeCxIuK0nQs8Fm6RPimje78Fz8vJqqIIn+hkQ+DzfunnpbEwcITxwAv7wJ46sznvGRsNFA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR03MB5692 Doing so matches existing VT-d behavior, and does prevent having to disable the remapping entry or mask the IO-APIC pin prior to being updated, as the remap entry content is always consistent. Signed-off-by: Roger Pau Monné --- xen/drivers/passthrough/amd/iommu_intr.c | 31 +++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/xen/drivers/passthrough/amd/iommu_intr.c b/xen/drivers/passthrough/amd/iommu_intr.c index feed1d1447..b24e703c75 100644 --- a/xen/drivers/passthrough/amd/iommu_intr.c +++ b/xen/drivers/passthrough/amd/iommu_intr.c @@ -39,6 +39,7 @@ union irte32 { }; union irte128 { + __uint128_t raw128; uint64_t raw[2]; struct { bool remap_en:1; @@ -222,6 +223,21 @@ static void update_intremap_entry(const struct amd_iommu *iommu, }, }; + if ( cpu_has_cx16 ) + { + union irte128 old_irte = *entry.ptr128; + __uint128_t ret = cmpxchg16b(entry.ptr128, &old_irte, &irte); + + /* + * In the above, we use cmpxchg16 to atomically update the 128-bit + * IRTE, and the hardware cannot update the IRTE behind us, so + * the return value of cmpxchg16 should be the same as old_ire. + * This ASSERT validate it. + */ + ASSERT(ret == old_irte.raw128); + return; + } + ASSERT(!entry.ptr128->full.remap_en); entry.ptr128->raw[1] = irte.raw[1]; /* @@ -299,7 +315,8 @@ static int update_intremap_entry_from_ioapic( entry = get_intremap_entry(iommu, req_id, offset); /* The RemapEn fields match for all formats. */ - while ( iommu->enabled && entry.ptr32->flds.remap_en ) + while ( iommu->enabled && entry.ptr32->flds.remap_en && + !cpu_has_cx16 && iommu->ctrl.ga_en ) { entry.ptr32->flds.remap_en = false; spin_unlock(lock); @@ -366,8 +383,11 @@ void cf_check amd_iommu_ioapic_update_ire( fresh = true; } - /* mask the interrupt while we change the intremap table */ - if ( !saved_mask ) + /* + * Mask the interrupt while we change the intremap table if it can't be + * done atomically. + */ + if ( !saved_mask && !cpu_has_cx16 && iommu->ctrl.ga_en ) { old_rte.mask = 1; __ioapic_write_entry(apic, pin, true, old_rte); @@ -383,6 +403,11 @@ void cf_check amd_iommu_ioapic_update_ire( /* Keep the entry masked. */ printk(XENLOG_ERR "Remapping IO-APIC %#x pin %u failed (%d)\n", IO_APIC_ID(apic), pin, rc); + if ( !saved_mask && (cpu_has_cx16 || !iommu->ctrl.ga_en) ) + { + old_rte.mask = 1; + __ioapic_write_entry(apic, pin, true, old_rte); + } return; } From patchwork Thu Apr 21 13:21:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 12821624 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 BBEDDC433FE for ; Thu, 21 Apr 2022 13:22:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.310183.526915 (Exim 4.92) (envelope-from ) id 1nhWlJ-0007vo-5C; Thu, 21 Apr 2022 13:22:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 310183.526915; Thu, 21 Apr 2022 13:22:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhWlJ-0007vH-1H; Thu, 21 Apr 2022 13:22:21 +0000 Received: by outflank-mailman (input) for mailman id 310183; Thu, 21 Apr 2022 13:22:19 +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 1nhWlH-0005Gk-Dy for xen-devel@lists.xenproject.org; Thu, 21 Apr 2022 13:22:19 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 0f2121c8-c176-11ec-8fc2-03012f2f19d4; Thu, 21 Apr 2022 15:22:16 +0200 (CEST) Received: from mail-dm6nam11lp2171.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.171]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 21 Apr 2022 09:22:15 -0400 Received: from DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) by DM6PR03MB3771.namprd03.prod.outlook.com (2603:10b6:5:4e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5164.20; Thu, 21 Apr 2022 13:22:14 +0000 Received: from DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e]) by DS7PR03MB5608.namprd03.prod.outlook.com ([fe80::5df3:95ce:4dfd:134e%4]) with mapi id 15.20.5186.015; Thu, 21 Apr 2022 13:22:14 +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: 0f2121c8-c176-11ec-8fc2-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1650547337; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=t8julXlOoNYBqtFkpFb4nXUExQj90ge4lQC5Ly84gfg=; b=iXyEyQpdNrYDBFd5bP+PqsHVIvCoO3V2lWChOmOpZ8fAy3SdcBq7HUJk GmlVtWQE/LsVo1SUclYWnagLwXCtnzMCmDxeQ8+iU1ycGffgwuXl4WW9I e7FTiSGJrdYqNKLIePmKsLa7tA8Pl6vZYFeE7CcU5VqdZjQZ89x7+1Uvg E=; X-IronPort-RemoteIP: 104.47.57.171 X-IronPort-MID: 69007273 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:QYDs6qsTWUENs+y4/n18U5bdb+fnVCJfMUV32f8akzHdYApBsoF/q tZmKT/Saf2LZmPzeY1yboS2/E0Av8Tcztc1TwVrr3wzEC4V+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZhSAgk/nOHNIQMcacUsxLbVYMpBwJ1FQyw4bVvqYy2YLjW1/X4 IuryyHiEATNNwBcYzp8B52r8HuDjNyq0N/PlgVjDRzjlAa2e0g9VPrzF4noR5fLatA88tqBb /TC1NmEElbxpH/BPD8HfoHTKSXmSpaKVeSHZ+E/t6KK2nCurQRquko32WZ1he66RFxlkvgoo Oihu6BcRi8lFPDlt99FECBeGh5gbaJ3pYb7C1ug5Jn7I03uKxMAwt1IJWRvZMg037gyBmtDs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ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lX2SthwrUQ/YIADe5wZ0yXXTWPCtgLF1RH2dAeo+TITMiwhQPE7y0Obm/vp5otIPpfVvrEnr7Fq2A/S3tHYav6f6s9j7kWkq2S/wTvhP1PSXvD5o2o1vbQW3TCrRux+Mol4i0d6IUhp7Nn+/3UAgvHEdpUmoX94xzFm1/EPIOqHMZwzIQ87sFaymIslg7CFo8PF8PqvuYKOp+0/zvhDFos7yDaY9KctbKMeJ8yisJLQ94rB25S4P8joGCN6ZLjjMP+vtJwgkv/kNnToI1qfe553GBcri6ILZmIN/Xj0nwTO14FvAZLvU8QrsaeSkQo6Jz5ZLJsqmTcyGfHotbo1T5w== 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=726ON294pXNt7c/3gsJ1Z+Ba/nN1vU6Da+G2qEPvwDg=; b=InHwxIemJPfVUmwg1QUudFLEgbO9AyoQoBY3PX21CtPT6J+KU9jvl+cYovnfIY4o8raD6Xwc0MRgma/+rJNPuzQrwwGBhDHPSilY8wbci+LN73/FUWGUimLaYdA5EDDjblBiHNbjA5N2SlRdRJI1r1jA1ayuqpN3ZCHfK8EuSvy0yIuORkZRbb6U+6P8mgJiN4gw1im2Q4gjMP0I0StEBQNCh3TXooi3r9q6vR+TMqliXaW51poqlmHuHL51tGBeTkfLX/pbbQJzJDP+KE6gBoEwBimAYFHcu/5Bozcz081wFMl8hGHF1dIAjrRtaNUInHdlK872LXGRfLm8ITxwSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.onmicrosoft.com; s=selector2-citrix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=726ON294pXNt7c/3gsJ1Z+Ba/nN1vU6Da+G2qEPvwDg=; b=ep2ptWBSGhvmUNG5k//D2107BLtD80ac7BUM+4w97PyJfz3aW+QDL07vPJhqCvgGpZa4eyp1fURp4gd5VJkHi//jo7UTHP6kVUVDD0uMoY0NyUuW6aQPOxJKHHhRhO8val9F+zYpqcXhT/CKk+7ZSnngWlesaStgCIfmGRmoGao= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH RFC 6/6] x86/ioapic: mask entry while updating Date: Thu, 21 Apr 2022 15:21:14 +0200 Message-Id: <20220421132114.35118-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220421132114.35118-1-roger.pau@citrix.com> References: <20220421132114.35118-1-roger.pau@citrix.com> X-ClientProxiedBy: MR2P264CA0143.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:30::35) To DS7PR03MB5608.namprd03.prod.outlook.com (2603:10b6:5:2c9::18) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3b82e05-6ed6-4f41-b84f-08da2399f2fc X-MS-TrafficTypeDiagnostic: DM6PR03MB3771:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hReYVgCXeBfLRRYWkepBFYpuFUQA0kEkR8OeIulKXfFr8KAxEeZDe84BDIa2xFck/FjPS2JcF6oGhJTvSDIqoILtZaTOeyMu4uW8l9TDCbOR7Vk+d4lyPlKyBN1utjWsSkktIj/LNxnxBKwbj83rTZ22qIrg2yr8OKTL1PNOOWensgvM5CmWP/+jnYKRtDt/YlMFEvuYbvsN2Gpn1LqZOV4o+FEV0v3+9T8sLbMqyXsqDWnfJKcKxC86A97ubZv/sre85ma40PKZNrW9bIgEajnBS1KMZ9OgiWAyS6EQs7ylGW7Vi3XfE5ZuDFFwH27aqPOV+iuz2mm2ITm71ryVZx5jRW3mFHhSv/470pY17TAO3+/0qjPca1bjI4yK5XbgQFZRVje8/lTbPNcYX0WRvyWwUbyXNRRy8+HqceAJy4NxP+BBf/1YG2R+CZX9NRIm6855MZR/yGAgGi8k9FzPinbOjPmqR/PKhyxaZ2FDeoQNCvLhG2y24JKXDxGIzvFj45qPihRlTIXLSRHQTvQfpb59zu5gBgPVqnNzKQUvA3KpaHR+8WFXREVYX5t8Pod26kz1PJJ6YCqUFuDuNaPMwoTz1Bkvq1gUlnCTaWyHaG+WQx1VDeit4o8ODSDNuxsZl7+2V4iQuURWEFroULXKRw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR03MB5608.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(82960400001)(316002)(186003)(2616005)(26005)(5660300002)(83380400001)(2906002)(6512007)(4326008)(8936002)(66556008)(6506007)(86362001)(66476007)(38100700002)(1076003)(8676002)(508600001)(54906003)(6486002)(66946007)(6916009)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?GxAQFKptwVGIuY+wWmwUjdDWStqT?= =?utf-8?q?jhuf6VwhZAXIzxXBP2bBBMecBVvBgZIA1pk5pwq0utpTRUgAkQgSMbY1rssnQLVei?= =?utf-8?q?3b9RJrsSNVHdA1Vw9PShVtfXz3C5bitBGLeoZQ8Fq+DfGaKglNFYNVah4mwsI+ehA?= =?utf-8?q?gOkO11UIgCooPFJtTW4N2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EXd5+bghTXprYxzGX+MX7cOqNCRWku?= =?utf-8?q?6+oldgKkBasAE/Pzlzl5n85Yz6q/CgFaxkDWQLrMsArkaO81+fcmKbxumwDpxiy5Q?= =?utf-8?q?hDIkDLK2vyh0neipZ6zVF8KT8rQxaz24Qlh2hRemLqdiEckjxbvqyrQdtqVz9bM5o?= =?utf-8?q?yC8Zk13dTJdsI9KQottupASSQVpJcSCNHgL7if7+DoM3ZuHnUJ1m2ySMOjAQlk4yD?= =?utf-8?q?+/nMuipGUr5MVfsMiCG2/H89X9jXO5x5rUoSAkyzsTw8YO4o8jNtSL8PIsqxFRkVf?= =?utf-8?q?JIdacX8SqIT7lJ59kdwOSOXMYxBUMRfT+/wTPA5wo5ceUSjPorOSlugfRMQQVCyXF?= =?utf-8?q?W0NV1cRV6VMNq/AjWsMm+SAtuTSUI7m8KjkQnoJzRqPCMYWRo4O+bL+xg+wE0l+id?= =?utf-8?q?ScDMBOSE7kxyJ4bmT4cBEDsJCSbYj/DBBdEu6VH0sfO2LplVkn1uSpLbHeLY4OngQ?= =?utf-8?q?+u0R68Bl4jtepghNh25Hdj2MGNgqAlKagjg0oQtYLFLt/sLHRFQkAijyxeRrMImxx?= =?utf-8?q?O2FLaZSlSZ9laYq+hl4fDogUBDJtUztZvB2XElFDKwZy0Af2YOa6RqhQu0iJrbXm+?= =?utf-8?q?9yW3thGXHE9Wz0mMMRIkuDyG4+R1tbb8SwFXq1qKGap5XWuJLf5l8=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3b82e05-6ed6-4f41-b84f-08da2399f2fc X-MS-Exchange-CrossTenant-AuthSource: DS7PR03MB5608.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2022 13:22:14.2150 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335836de-42ef-43a2-b145-348c2ee9ca5b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zQ5bns9muO1JXf/NhXYQKgslld6veYOsM7kUW+GBE2FqKgDAsjBzyxt+hP523r7+JL8rqd9RCJxOVo87hOxvGQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR03MB3771 When writing an IO-APIC RTE entry make sure incoming interrupts never see a partially updated entry, by masking the pin while doing the update when necessary. Add some logic to attempt to limit the number of writes. With the masking now handled by __ioapic_write_entry itself when necessary, we can drop the setting of the disable hook for IO-APIC edge triggered interrupts. Signed-off-by: Roger Pau Monné --- Note this includes a revert of the first patch in the series. --- xen/arch/x86/io_apic.c | 45 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index f61e56f3d1..1860af7353 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -267,12 +267,47 @@ void __ioapic_write_entry( unsigned int apic, unsigned int pin, bool raw, struct IO_APIC_route_entry e) { - union entry_union eu = { .entry = e }; - if ( raw || !iommu_intremap ) { - __io_apic_write(apic, 0x11 + 2 * pin, eu.w2); - __io_apic_write(apic, 0x10 + 2 * pin, eu.w1); + union entry_union eu = { .entry = e }; + union entry_union curr = { + .entry = __ioapic_read_entry(apic, pin, true), + }; + bool masked = true; + + if ( curr.entry.mask ) + { + /* + * If pin is currently masked we can update the high part first + * without worrying about the RTE being in an inconsistent state. + */ + if ( curr.w2 != eu.w2 ) + __io_apic_write(apic, 0x11 + 2 * pin, eu.w2); + if ( curr.w1 != eu.w1 ) + __io_apic_write(apic, 0x10 + 2 * pin, eu.w1); + return; + } + + if ( curr.w1 != eu.w1 && curr.w2 != eu.w2 && !eu.entry.mask ) + { + /* + * If updating both halves mask the entry while updating so + * interrupts are not injected with an inconsistent RTE. + */ + eu.entry.mask = 1; + masked = false; + } + + if ( curr.w1 != eu.w1 ) + __io_apic_write(apic, 0x10 + 2 * pin, eu.w1); + if ( curr.w2 != eu.w2 ) + __io_apic_write(apic, 0x11 + 2 * pin, eu.w2); + + if ( !masked ) + { + eu.entry.mask = 0; + __io_apic_write(apic, 0x10 + 2 * pin, eu.w1); + } } else iommu_update_ire_from_apic(apic, pin, e.raw); @@ -1780,7 +1815,7 @@ static hw_irq_controller ioapic_edge_type = { .startup = startup_edge_ioapic_irq, .shutdown = irq_shutdown_none, .enable = unmask_IO_APIC_irq, - .disable = mask_IO_APIC_irq, + .disable = irq_disable_none, .ack = ack_edge_ioapic_irq, .set_affinity = set_ioapic_affinity_irq, };