From patchwork Wed Sep 28 14:11:16 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: 12992278 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 8D9FBC04A95 for ; Wed, 28 Sep 2022 14:11:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.413356.656977 (Exim 4.92) (envelope-from ) id 1odXmu-0001LZ-S3; Wed, 28 Sep 2022 14:11:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 413356.656977; Wed, 28 Sep 2022 14:11:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1odXmu-0001LS-Ov; Wed, 28 Sep 2022 14:11:48 +0000 Received: by outflank-mailman (input) for mailman id 413356; Wed, 28 Sep 2022 14:11:47 +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 1odXmt-0000S3-G7 for xen-devel@lists.xenproject.org; Wed, 28 Sep 2022 14:11:47 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6faabdc5-3f37-11ed-9374-c1cf23e5d27e; Wed, 28 Sep 2022 16:11:26 +0200 (CEST) Received: from mail-dm6nam12lp2174.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.174]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Sep 2022 10:11:33 -0400 Received: from SJ0PR03MB6360.namprd03.prod.outlook.com (2603:10b6:a03:395::11) by SA0PR03MB5596.namprd03.prod.outlook.com (2603:10b6:806:b8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26; Wed, 28 Sep 2022 14:11:31 +0000 Received: from SJ0PR03MB6360.namprd03.prod.outlook.com ([fe80::861e:b46c:1acc:c576]) by SJ0PR03MB6360.namprd03.prod.outlook.com ([fe80::861e:b46c:1acc:c576%5]) with mapi id 15.20.5654.026; Wed, 28 Sep 2022 14:11:31 +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: 6faabdc5-3f37-11ed-9374-c1cf23e5d27e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1664374304; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=D0ar6Be/O6ceYvTffbwdzz9tYlDXEXceF7FBXTya4eM=; b=MDFm3VWjVCFgi8ByGAL0VBnnttZtC86+KHTMDgc+DPbCpX0TV6FHAO2Z xnfNBmQFjEkaWSVfoLH5ISc0z2fWLNmxdfwHeGfWwOcedRXBCd6a6FYOG jTnNcH4YnETldy0l0vMnPLm/zirBtnhaDG0U5eXWze48o2GUHsYfFUE8N 4=; X-IronPort-RemoteIP: 104.47.59.174 X-IronPort-MID: 84050010 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:whlHgq485/ZlzianDhgUQQxRtODGchMFZxGqfqrLsTDasY5as4F+v mRJWG2AaamNNjGhft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AsKuirDHgMWObO4/XNiZLdeBYDQzoq8hOHgz+E4KPzV0Hw5GZXbxp/hZMZtU TVmQ3w4auu99m91x/nzmfWq7BbgsHoxNdvDNGFzuIVNjLvoAC1Y5kJYczKgBkF5MWUrHo6mt jFpBkte+x19nPqZ2mw5SDg3gHxuQxenkPK+Bu9uz/OsMb5TDU1B45qnoRCaCbU7EImoZVVzL 9L93jxjesaMTrw2ADGo/TYXRBjkUS55VA4l/QIsnBZWYwCLJdMsI0k+l9PGptoJlO21GkeKp ghMCjg3ocWTbvDBEqp/lWHgebcFEjbJy32DXTr4aeuontrdHMQ9Tpr+CVQpAZDyHsHceg12w 31CNUXqFhwdL5mUUsEPpZmfSKWMB24ffueChPkHX3XUIc6Blnql7nbpJ0I2cDCQu168HJ1ou WLbG9l X-IronPort-AV: E=Sophos;i="5.93,352,1654574400"; d="scan'208";a="84050010" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UQhtuQJlpcsABc5iMYnJ9Lt4IPAQdYKblhgG0lBZRFecnwNqByxg8c3AzB+dLsc3FTMzxDWRCzhyoaFL9OvwGrboISkESFKtJ9VXuGbP+2jBmCmOxFws6HawFmXZ/Tc+obmCgBq9/sUoIBtFTircROUfduW4etW/JKRXJyr/p1fHlzMNeGeT0xUlwK8MvBtgh1Kl8rJgMLzWs/yaANVG4IlEVKTeFtTOtPoZUyreuk1Em7gUFTBwOgQX7B67Mjnn6+DxOru6gnR3ZUeFQVXuaKOWjE7IzjhDawYJ3zIbeLlH2JoBDlXNNEDjaPWPA/LUlgGPspil06EaUlOH8mmcPw== 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=kB9mpVtnBT/eigFVC4SQfhSkRGs0sR28/Ucd8sfyyMM=; b=U1QGVCMwLdjR+XGFnguTZA+QVt4IlMFMUkR3sOEGw1jwJDvhGgD4E7z2ampH+d2gw6OJbW2QF0h2gra6xfqwpiMFu/GnCRHvDW35R3qEjuLoBChEAraWurqI37ddETNfC8UihQa/Kv3u2j5VYFA8Fe+ObSQSoS2GN4fL+rjsUSj+PBmQ6JtSu+b3ut8gib86daF3CHAJz5Twvh9UW8QdGpqBsiK8VeQWTY6wz3mw4Jxw6enrwPm4O3QziCQyVnm0AP5CdnV3o9J31L84g9eg8PTAv3UAoX9DHySEcTiVpJ9FIe70BeeFrGLv0H7IbjtfJN5v4JmKcprCFrBqQ9z/wA== 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=kB9mpVtnBT/eigFVC4SQfhSkRGs0sR28/Ucd8sfyyMM=; b=G3ROh199xkDZHkcfduRKAfmQrrEI0KQbNo8wHorsKKyX8yrJKv9HfAHobojg85+NIFELX8cBJgYiKRmMUUc2WdEWBmdnKn1620WBH6AJeZpagicvdnNS4J9FTp6tHRfljXqOJQ2wzZ96EMqNDrQnCJGchnHEk1xDHmLW3OI3Qww= 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 , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH v3 1/2] arm/vgic: drop const attribute from gic_iomem_deny_access() Date: Wed, 28 Sep 2022 16:11:16 +0200 Message-Id: <20220928141117.51351-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928141117.51351-1-roger.pau@citrix.com> References: <20220928141117.51351-1-roger.pau@citrix.com> X-ClientProxiedBy: LO2P265CA0143.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::35) To SJ0PR03MB6360.namprd03.prod.outlook.com (2603:10b6:a03:395::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6360:EE_|SA0PR03MB5596:EE_ X-MS-Office365-Filtering-Correlation-Id: 61b6f6ec-d389-4238-ea6b-08daa15b56a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c6+lnQxUiO3yJ5JyFvukG5b8aNRSdYfOiq59lfnLV+arBxI9GMGoF1PlI4UFWzKlOCRQ/0uKhpK7+/XQG+l90TWgLF/EdBbalDIfWYS/Mmd7eC+7kc6+vVm7TEFQIH0UC4k83CYAvAECa61lveWKgxmJ9ag8bXTl0aM4n9eboTUyQkCcU+IFG7QN6oQsLuoiv+41WZn1mNPBkseEPGREN9Y+o1+kErnWdZlhpu7XgtnVEvQoU/AjHFPVPHnpqUovjui/qW2D2+tmdoV+4oOntQRVLbF5G3fGxlI/Y/iNGqg4c3mXdEyUGwnavvCEONHZtMI1iiznO9ftGYtZqvzFJ0wooMms/ShK/NCeXCSAMmxXWXLrdyzDI2YvNKKf50qV0u5zVUKK8AW1e05jbVFGjT4lFBUcAkhaErKYV3kms40JdlaT4bLkk/gsBc2Cku3fHp8nyE4ZoDAz7xRZSNOSxvCfk8hFYOxO3eYmxTPepTPIojnGSU9S9A28e7UipRQX5OMV0qjaqnbxZfKfgo+SIp8ETyyZwwaiBXh3uz8F25gF+MyUoXbsUekOeOhNR64HUdFrRfYDzseCjQgcOrQE9R4mGDZii2nKli9eEM7dPQx5H3FXI85zjv3OSSQ2g29C+zIa9CqSEEbtt50Umx2cSv32zg7jSRFD/28HaL08iQweSTw78u0/34/m1jwkCB6hS8sV5WZh52mmzNAf5YnX6A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6360.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(136003)(376002)(396003)(366004)(451199015)(82960400001)(6916009)(316002)(54906003)(5660300002)(8936002)(8676002)(36756003)(41300700001)(66556008)(66476007)(4326008)(2906002)(66946007)(6512007)(186003)(83380400001)(86362001)(2616005)(26005)(38100700002)(478600001)(1076003)(6486002)(6666004)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?oNPaI7JFpeWZ+jYws94FqYJpK/CU?= =?utf-8?q?QZiCTXrLrAnOthlrT3XAxn3ORABwiqFJ+MnuApKHUISAWrmnzulQI6t47clh9vS+5?= =?utf-8?q?LlWD+LNN4/wAGvrExHascrIn6NQU5VGc1UaePdJnOk//8jYP/oyfcsmChRlsx8hpJ?= =?utf-8?q?yjWU62LvVxnkVNpFdWb4zV17AgbfmHWPRnXBc76qQSATDuavpkEQULRek/XaHeq6p?= =?utf-8?q?KGi0kNGUQEAX4FpKdsOg5phPjaV9kl5EeEjQ7989uCBpPx48C2Nn1okXaayQ2f69d?= =?utf-8?q?HiPheF/Wsz2RVYWUlpg8/WwOzilG+WVrui6sf2IZn5bQnBHm9MujckGuZOrV6d5aX?= =?utf-8?q?n4wILhcF/RWu1puv+WRwYNxc1MgNjOLtJ439cOXaRRhPb3ZtP/j/3YvP2jAo2XsFN?= =?utf-8?q?Crihkt+d8FRy5OUEJKPOrxZOmyusQyy0cVOPoDZ42VJIi4fch1JfsUGzDzjBtkpAt?= =?utf-8?q?biTa/fSe0OdrCW2Jkw4mZhfEW9ynT80AspOHyjLv3LbsmlqPHcd+lvmDHqAHc+CGU?= =?utf-8?q?Q/6MRa4sv+ynEvMLh/4M655hG63PICvoq+YoLQ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+H1sVWVViuqMN9A2C?= =?utf-8?q?EPA6ZJIRq8YCXUcjaYh1C3/OC+EzWpJWcD8riCZfRJYEtR/hSLS1Z/54vhTal5Srj?= =?utf-8?q?K0gIi1GjPZ98rYzibw+U4k+JWxpTx1NSIg=3D=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61b6f6ec-d389-4238-ea6b-08daa15b56a8 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6360.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 14:11:31.2736 (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: cvWCB8cyPgwk8DnmZ7u45+4WZO5WRfmFMcw8h/4+OtvU47L0b5P/FiVjWF6MuobRIK8tGBKgHIXbic+/8A4wmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5596 While correct from a code point of view, the usage of the const attribute for the domain parameter of gic_iomem_deny_access() is at least partially bogus. Contents of the domain structure (the iomem rangeset) is modified by the function. Such modifications succeed because right now the iomem rangeset is allocated separately from struct domain, and hence is not subject to the constness of struct domain. Amend this by dropping the const attribute from the function parameter. This is required by further changes that will convert iomem_{permit,deny}_access into a function. Signed-off-by: Roger Pau Monné Reviewed-by: Bertrand Marquis --- xen/arch/arm/gic-v2.c | 2 +- xen/arch/arm/gic-v3.c | 2 +- xen/arch/arm/gic.c | 2 +- xen/arch/arm/include/asm/gic.h | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c index bd773bcc67..ae5bd8e95f 100644 --- a/xen/arch/arm/gic-v2.c +++ b/xen/arch/arm/gic-v2.c @@ -1083,7 +1083,7 @@ static void __init gicv2_dt_init(void) gicv2_extension_dt_init(node); } -static int gicv2_iomem_deny_access(const struct domain *d) +static int gicv2_iomem_deny_access(struct domain *d) { int rc; unsigned long mfn, nr; diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c index 64b36cec25..018fa0dfa0 100644 --- a/xen/arch/arm/gic-v3.c +++ b/xen/arch/arm/gic-v3.c @@ -1424,7 +1424,7 @@ static void __init gicv3_dt_init(void) &vbase, &vsize); } -static int gicv3_iomem_deny_access(const struct domain *d) +static int gicv3_iomem_deny_access(struct domain *d) { int rc, i; unsigned long mfn, nr; diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index 3b0331b538..9b82325442 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -462,7 +462,7 @@ unsigned long gic_get_hwdom_madt_size(const struct domain *d) } #endif -int gic_iomem_deny_access(const struct domain *d) +int gic_iomem_deny_access(struct domain *d) { return gic_hw_ops->iomem_deny_access(d); } diff --git a/xen/arch/arm/include/asm/gic.h b/xen/arch/arm/include/asm/gic.h index 3692fae393..76e3fa5dc4 100644 --- a/xen/arch/arm/include/asm/gic.h +++ b/xen/arch/arm/include/asm/gic.h @@ -392,7 +392,7 @@ struct gic_hw_operations { /* Map extra GIC MMIO, irqs and other hw stuffs to the hardware domain. */ int (*map_hwdom_extra_mappings)(struct domain *d); /* Deny access to GIC regions */ - int (*iomem_deny_access)(const struct domain *d); + int (*iomem_deny_access)(struct domain *d); /* Handle LPIs, which require special handling */ void (*do_LPI)(unsigned int lpi); }; @@ -449,7 +449,7 @@ unsigned long gic_get_hwdom_madt_size(const struct domain *d); #endif int gic_map_hwdom_extra_mappings(struct domain *d); -int gic_iomem_deny_access(const struct domain *d); +int gic_iomem_deny_access(struct domain *d); #endif /* __ASSEMBLY__ */ #endif From patchwork Wed Sep 28 14:11:17 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: 12992277 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 BC666C32771 for ; Wed, 28 Sep 2022 14:11:56 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.413355.656966 (Exim 4.92) (envelope-from ) id 1odXms-00013S-Es; Wed, 28 Sep 2022 14:11:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 413355.656966; Wed, 28 Sep 2022 14:11:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1odXms-00013E-BG; Wed, 28 Sep 2022 14:11:46 +0000 Received: by outflank-mailman (input) for mailman id 413355; Wed, 28 Sep 2022 14:11:44 +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 1odXmq-0000S3-Km for xen-devel@lists.xenproject.org; Wed, 28 Sep 2022 14:11:44 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6e71850c-3f37-11ed-9374-c1cf23e5d27e; Wed, 28 Sep 2022 16:11:24 +0200 (CEST) Received: from mail-dm6nam12lp2169.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.169]) by ob1.hc3370-68.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Sep 2022 10:11:38 -0400 Received: from SJ0PR03MB6360.namprd03.prod.outlook.com (2603:10b6:a03:395::11) by SA0PR03MB5596.namprd03.prod.outlook.com (2603:10b6:806:b8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26; Wed, 28 Sep 2022 14:11:36 +0000 Received: from SJ0PR03MB6360.namprd03.prod.outlook.com ([fe80::861e:b46c:1acc:c576]) by SJ0PR03MB6360.namprd03.prod.outlook.com ([fe80::861e:b46c:1acc:c576%5]) with mapi id 15.20.5654.026; Wed, 28 Sep 2022 14:11:36 +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: 6e71850c-3f37-11ed-9374-c1cf23e5d27e DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1664374301; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=xqpzPTo+tqWuVrT/dDNqz4ZD0jH2eM4n5dh29qP+bVQ=; b=eusiJvoriASupoqr9vMvZvkYVbKYRfOYJQCRomEKfQ1S3EVzEkrimdOo wve5x+Q5uYNccD0gCUQVO0HI59kcCs0pHHl/SdnpnoDVxaTNiJhePo24w BKoZh4cNE0th/2QyXIF2w+nbCed58hsWKUvUUzceM3D4wHWbri14cv0yQ A=; X-IronPort-RemoteIP: 104.47.59.169 X-IronPort-MID: 81960679 X-IronPort-Reputation: None X-IronPort-Listener: OutboundMail X-IronPort-SenderGroup: RELAY_O365 X-IronPort-MailFlowPolicy: $RELAYED IronPort-Data: A9a23:I90kCarI8QxXXUwAdC0TTIyHKXdeBmLpZBIvgKrLsJaIsI4StFCzt garIBmGM6mPZGXzc4sgaY2+8UpX75CEzIdkQAo5qi02RSNGpJuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngq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w5GZUbxp/hZMZtU TVmQ3w4auu99m91x/nzmfWq7BbgsHoxNdvDNGFzuIVNjLvoAC1Y5kJYczLgBkF5MWUrHo6mt jFpBkte+x19nPqZ2mw5SDg3gHxuQxen0PK+Bu9uz/OsMb5TDU1B45qnoRCaCbU7EImoZVVzL 9L93jxjesZMTrw2ADGo/TYXRBjkUS55VA4l/QIsnBZWYwCLJdMsI0k+l9PGptoJlO31GkeKp guMCjg3ocXTbvDBEqp/VWHgebcE0jbJy32DHTr4aeuonprdHMQ9Tps+CVQpAZEyHsHceg12w 31CNUXqFhwdL5mUUsEPpZmfSKWMB27ffueChPlHX3XUIc6Blnql7nbpJ0I2cDCQu178HJ1ou WKbG9l X-IronPort-AV: E=Sophos;i="5.93,352,1654574400"; d="scan'208";a="81960679" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S7AzwnHxpmN/KV8N9yvgj9FUdiQ68WAOAvVjMcQrG3XUs6PFtCsOUmQMsxtIMYZi+YIPrXUGgwv/zK+u6Mz66b/Ms7MAkCgNl9pxPuXGZWBMeYVp02pdQwNQ3Jm23pODIPl1RgQAl7Cq/G4RDXASnY7OJ4Xttt9w8SgVAVikuC/dVnutctL8/MGCym6s94HgARCikUF/WRacx/25Y7mGnMhYgFQyYOV2w2pvd5e6TM9ENY2pRo5HJjsCHYuXxuKMc2bh5Hue0s1MVO6ZLWU80hp2XQsJM0ZROhtcm6Hjzrk3ILLolmEZs+1siZ1CB26b9BEzDTSu/nEjQkBFKHbHig== 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=Rrg6TmkiWke+u14j4kPKExk7sncmIIb6n+HAE1tRCec=; b=URXKDG46zgef/aipTzYUvYzy/ZkI28GN0es8qfjUrOt8rrMf4Bpqhv/0L545Su0Gy4ruBMglI/gU7KlNllH/yBhlCVpivGhGgTrCvOKuR8EQaimq+z3nHspky+WDWQMoUTx8xlzcAOhycY5GSypb5FjhQCSziZrBlHQbrXd/EWQ26K7vrb20PtYMYx3w+I8D1X8ad87NNNafzx7dKU94YaSBdWssXNMQUJ3x1Wzj0CJh9CB5I31LcrqL4yhIx3coXqyBdLEVpfwErhI8OqgxjDa8LAD3GKEXOoHwcjSvR3wdrfoJAxYhwz3KJ66EQo84lTUCnEqHXefNtIXsVa6IJQ== 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=Rrg6TmkiWke+u14j4kPKExk7sncmIIb6n+HAE1tRCec=; b=TT3onQoNrLH2kcxjn0ET5qXM4WwWfLUVj3kFPNMykhCaK0u6KzMyhCX+6/ycLp3QXuwHBmISmF45m7zsAkLr+eGSgb3aohqrmitMD5nWzKuQhvhuBAIGB5n7V9eXAoWWJNzt8Rydp/aJyhy152L0N9+gLgcqIebT1O++bgCCgAU= 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 , George Dunlap , Julien Grall , Stefano Stabellini , Jun Nakajima , Kevin Tian Subject: [PATCH v3 2/2] x86/ept: limit calls to memory_type_changed() Date: Wed, 28 Sep 2022 16:11:17 +0200 Message-Id: <20220928141117.51351-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220928141117.51351-1-roger.pau@citrix.com> References: <20220928141117.51351-1-roger.pau@citrix.com> X-ClientProxiedBy: LO2P265CA0004.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::16) To SJ0PR03MB6360.namprd03.prod.outlook.com (2603:10b6:a03:395::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB6360:EE_|SA0PR03MB5596:EE_ X-MS-Office365-Filtering-Correlation-Id: adce3f8c-8cf4-45be-e88a-08daa15b5a9f X-LD-Processed: 335836de-42ef-43a2-b145-348c2ee9ca5b,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OnwZQzge45P4seLIah8vp128gWh5NiC+MUNgNwXSDU+v0ynal/qlMtbP5E1G/qOZi3L1R0bpMtPaa0YQbh6PYsIn5pScjh01uV9FneoOu+zfDNuxqtWzufUeJ1pLFcWtudLI/oYE8jMGQ38K0l6BduZknrkHWGqjJq98U/395YzpLKD4IPHlz+lHrYjdjRDKokzLOwR/wSdui7nQT3rYFnPQcsnrT8kd6cVYscWam1F9evtPI2W3hYwytsh+kCtqLb6S1mK4TNRJjVVx81rdJVXsFwjddsOYVNoqgNmZrER3hpfgBgpBi47o5u9ozR/6uR94n/qwUX40REhRLU2/yjNhjLKRAHXKBMj0XxOjArmQoS6C84Bh/gwoBN1b2+gGi/7ko/3QgYDndEFf8UaHgGJiqmRnSld6h53LexVnL2hjJiKR0RBxsYsRURB53UWovxBuXXsWuX5IG1hwSOFG6p3zrT7hs/1yWqGqRV46U/2GWMfjWwINRM7mSmc5cK2Vgxk323tW9VrNGqw9q6TX8BALIKOiYCH1Xbp/M/T9aWqeUiWN323aV2Gw4+nc/4sFix9pWpPA72uHIWUo+a2nRnHN3lxBvsS76FeRdWaEzTTYqfF5aWyCOGrsZqkiYoc0/RNyCMEv2LTp1/5OsDi9raYiytvWjx+OtLgEbq6hoUe35Ooh69qjSIUcLUMGaNO8UhPGNobjf0QNHDVx5Ej9pA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB6360.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(346002)(136003)(376002)(396003)(366004)(451199015)(82960400001)(6916009)(316002)(54906003)(5660300002)(8936002)(8676002)(36756003)(41300700001)(66556008)(66476007)(4326008)(2906002)(66946007)(6512007)(186003)(83380400001)(86362001)(2616005)(26005)(38100700002)(478600001)(1076003)(6486002)(6666004)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?cyMIptM7GyYQQavOEWAmNXo3ffKf?= =?utf-8?q?hquYd26k5yWskciObvdEMxOjYe5aj0KRDYB8rnM7eTjoKBTyhv+EtJKZbaQXRklQw?= =?utf-8?q?1lanWcJxs3ofsu+MGzlhXXCHN+8u8WUpSdAlkflBXxC67gbzh/AMDdykUlHsuqVMI?= =?utf-8?q?6VhkEiq2iEHHoCgZzbnZUucUPSLm5WAq2iBvq9oBIR7B6q/C44y3+B3T25kskomj9?= =?utf-8?q?SVvWEwC8iRgvvq3cjxwGJLV9lW7sYAazkjNN8Gz+b0AGOO11W8mBWEfuS2SlBmIW8?= =?utf-8?q?Dke6m4BNWDxQ+T//wvVA6xNgABJ2PiU+Ze3hcdAL9iIYPoU74Z289ONFmyJMhf75z?= =?utf-8?q?NJdbPHlj+Vez0jqtGsLYzH5+wSMTQlO4MyTkfNLfzY5KRsLpVeTm5qkhmyXQqMGNz?= =?utf-8?q?wQji7cmOCXoJHki//F3/RVWmJEqlvtcjlj88y9ZkQCBJr+nmBChRdl8nbLJUMpX6v?= =?utf-8?q?i+L87wZeMBRIRPHIAeAaxmUi1Ynd3bTIahCc3gs+6qrDmCZYXSCvkppK9yIiEjPg6?= =?utf-8?q?2VBWiWWP+nJYCILHDlMulNu2LaidbGw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gW1rqcpflMUzaTtZNHenVQCsSJKWBhERkI+4v?= =?utf-8?q?GbRxuLf+0pN8e5c+g00MpRw651vnRxpanL7P0ccd4GOQGoGrjzlLlNfNiyKhWNWCL?= =?utf-8?q?e4chDRtyZ92bFbMIguVl2ZGzZXFa2ByIgw=3D=3D?= X-OriginatorOrg: citrix.com X-MS-Exchange-CrossTenant-Network-Message-Id: adce3f8c-8cf4-45be-e88a-08daa15b5a9f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB6360.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 14:11:36.4152 (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: 49A+fQb96QSnmLFIw4zTmhfRQDazU7lgWFEAzYhbeWzRFHRsH24hX9EWlyoMYPlIBlqhC0o5WvV0Psk0hVQS+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR03MB5596 memory_type_changed() is currently only implemented for Intel EPT, and results in the invalidation of EMT attributes on all the entries in the EPT page tables. Such invalidation causes EPT_MISCONFIG vmexits when the guest tries to access any gfns for the first time, which results in the recalculation of the EMT for the accessed page. The vmexit and the recalculations are expensive, and as such should be avoided when possible. Remove the call to memory_type_changed() from XEN_DOMCTL_memory_mapping: there are no modifications of the iomem_caps ranges anymore that could alter the return of cache_flush_permitted() from that domctl. Encapsulate calls to memory_type_changed() resulting from changes to the domain iomem_caps or ioport_caps ranges in the helpers themselves (io{ports,mem}_{permit,deny}_access()), and add a note in epte_get_entry_emt() to remind that changes to the logic there likely need to be propagaed to the IO capabilities helpers. Note changes to the IO ports or memory ranges are not very common during guest runtime, but Citrix Hypervisor has an use case for them related to device passthrough. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- Changes since v2: - Split the Arm side changes into a pre-patch. Changes since v1: - Place the calls to memory_type_changed() inside the io{ports,mem}_{permit,deny}_access() helpers. --- xen/arch/x86/domctl.c | 4 ---- xen/arch/x86/include/asm/iocap.h | 33 +++++++++++++++++++++++---- xen/arch/x86/mm/p2m-ept.c | 4 ++++ xen/common/domctl.c | 4 ---- xen/include/xen/iocap.h | 38 ++++++++++++++++++++++++++++---- 5 files changed, 67 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 020df615bd..e9bfbc57a7 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -232,8 +232,6 @@ long arch_do_domctl( ret = ioports_permit_access(d, fp, fp + np - 1); else ret = ioports_deny_access(d, fp, fp + np - 1); - if ( !ret ) - memory_type_changed(d); break; } @@ -666,8 +664,6 @@ long arch_do_domctl( "ioport_map: error %ld denying dom%d access to [%x,%x]\n", ret, d->domain_id, fmp, fmp + np - 1); } - if ( !ret ) - memory_type_changed(d); break; } diff --git a/xen/arch/x86/include/asm/iocap.h b/xen/arch/x86/include/asm/iocap.h index eee47228d4..ce83c3d8a4 100644 --- a/xen/arch/x86/include/asm/iocap.h +++ b/xen/arch/x86/include/asm/iocap.h @@ -7,10 +7,11 @@ #ifndef __X86_IOCAP_H__ #define __X86_IOCAP_H__ -#define ioports_permit_access(d, s, e) \ - rangeset_add_range((d)->arch.ioport_caps, s, e) -#define ioports_deny_access(d, s, e) \ - rangeset_remove_range((d)->arch.ioport_caps, s, e) +#include +#include + +#include + #define ioports_access_permitted(d, s, e) \ rangeset_contains_range((d)->arch.ioport_caps, s, e) @@ -18,4 +19,28 @@ (!rangeset_is_empty((d)->iomem_caps) || \ !rangeset_is_empty((d)->arch.ioport_caps)) +static inline int ioports_permit_access(struct domain *d, unsigned long s, + unsigned long e) +{ + bool flush = cache_flush_permitted(d); + int ret = rangeset_add_range(d->arch.ioport_caps, s, e); + + if ( !ret && !is_iommu_enabled(d) && !flush ) + /* See comment in iomem_permit_access(). */ + memory_type_changed(d); + + return ret; +} +static inline int ioports_deny_access(struct domain *d, unsigned long s, + unsigned long e) +{ + int ret = rangeset_remove_range(d->arch.ioport_caps, s, e); + + if ( !ret && !is_iommu_enabled(d) && !cache_flush_permitted(d) ) + /* See comment in iomem_deny_access(). */ + memory_type_changed(d); + + return ret; +} + #endif /* __X86_IOCAP_H__ */ diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index b4919bad51..d61d66c20e 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -518,6 +518,10 @@ int epte_get_entry_emt(struct domain *d, gfn_t gfn, mfn_t mfn, return MTRR_TYPE_UNCACHABLE; } + /* + * Conditional must be kept in sync with the code in + * {iomem,ioports}_{permit,deny}_access(). + */ if ( type != p2m_mmio_direct && !is_iommu_enabled(d) && !cache_flush_permitted(d) ) { diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 452266710a..69fb9abd34 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -716,8 +716,6 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) ret = iomem_permit_access(d, mfn, mfn + nr_mfns - 1); else ret = iomem_deny_access(d, mfn, mfn + nr_mfns - 1); - if ( !ret ) - memory_type_changed(d); break; } @@ -778,8 +776,6 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) "memory_map: error %ld removing dom%d access to [%lx,%lx]\n", ret, d->domain_id, mfn, mfn_end); } - /* Do this unconditionally to cover errors on above failure paths. */ - memory_type_changed(d); break; } diff --git a/xen/include/xen/iocap.h b/xen/include/xen/iocap.h index 1ca3858fc0..0ca4c9745f 100644 --- a/xen/include/xen/iocap.h +++ b/xen/include/xen/iocap.h @@ -7,13 +7,43 @@ #ifndef __XEN_IOCAP_H__ #define __XEN_IOCAP_H__ +#include #include #include +#include + +static inline int iomem_permit_access(struct domain *d, unsigned long s, + unsigned long e) +{ + bool flush = cache_flush_permitted(d); + int ret = rangeset_add_range(d->iomem_caps, s, e); + + if ( !ret && !is_iommu_enabled(d) && !flush ) + /* + * Only flush if the range(s) are empty before this addition and + * IOMMU is not enabled for the domain, otherwise it makes no + * difference for effective cache attribute calculation purposes. + */ + memory_type_changed(d); + + return ret; +} +static inline int iomem_deny_access(struct domain *d, unsigned long s, + unsigned long e) +{ + int ret = rangeset_remove_range(d->iomem_caps, s, e); + + if ( !ret && !is_iommu_enabled(d) && !cache_flush_permitted(d) ) + /* + * Only flush if the range(s) are empty after this removal and + * IOMMU is not enabled for the domain, otherwise it makes no + * difference for effective cache attribute calculation purposes. + */ + memory_type_changed(d); + + return ret; +} -#define iomem_permit_access(d, s, e) \ - rangeset_add_range((d)->iomem_caps, s, e) -#define iomem_deny_access(d, s, e) \ - rangeset_remove_range((d)->iomem_caps, s, e) #define iomem_access_permitted(d, s, e) \ rangeset_contains_range((d)->iomem_caps, s, e)