From patchwork Thu Jan 27 07:49:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726370 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 3697CC433EF for ; Thu, 27 Jan 2022 07:50:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261214.452037 (Exim 4.92) (envelope-from ) id 1nCzYK-0000CG-EO; Thu, 27 Jan 2022 07:50:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261214.452037; Thu, 27 Jan 2022 07:50:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzYK-0000C7-Af; Thu, 27 Jan 2022 07:50:44 +0000 Received: by outflank-mailman (input) for mailman id 261214; Thu, 27 Jan 2022 07:50:43 +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 1nCzYI-0008Mi-Th for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:50:43 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on060d.outbound.protection.outlook.com [2a01:111:f400:fe0c::60d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d3197f61-7f45-11ec-8f75-fffcc8bd4f1a; Thu, 27 Jan 2022 08:50:42 +0100 (CET) Received: from DB6P18901CA0013.EURP189.PROD.OUTLOOK.COM (2603:10a6:4:16::23) by DB8PR08MB5130.eurprd08.prod.outlook.com (2603:10a6:10:e9::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 27 Jan 2022 07:50:39 +0000 Received: from DB5EUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:16:cafe::f0) by DB6P18901CA0013.outlook.office365.com (2603:10a6:4:16::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:39 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT044.mail.protection.outlook.com (10.152.21.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:38 +0000 Received: ("Tessian outbound 63bb5eb69ee8:v113"); Thu, 27 Jan 2022 07:50:38 +0000 Received: from c780f9168eb1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CB5BDB13-C668-40B6-A27A-DEF6F3187B7E.1; Thu, 27 Jan 2022 07:50:30 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c780f9168eb1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:50:30 +0000 Received: from AS9PR06CA0210.eurprd06.prod.outlook.com (2603:10a6:20b:45d::28) by VE1PR08MB4877.eurprd08.prod.outlook.com (2603:10a6:802:a4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 07:50:28 +0000 Received: from AM5EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45d:cafe::ca) by AS9PR06CA0210.outlook.office365.com (2603:10a6:20b:45d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:28 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT046.mail.protection.outlook.com (10.152.16.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:28 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:27 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:26 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50:25 +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: d3197f61-7f45-11ec-8f75-fffcc8bd4f1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rSh3L/AFX1kwUWbUN803XD5qISN//S+9dF22OnqF/Ss=; b=lPPyoz94FwlEGHmUOII9wMO8lhVidDeQOajv7kcMUtK9QPNsX8EnMarfB9mnxQiLrWPoRuvHpapr9yW0aLDnUTJgrMflzcCyQiknO2FkPHxatDpGI5bZ5AUc9EhMeaEePc/GqXAtxnHm6+lJxVlZfxwNS0N7llTuEJU0BwLrYiw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: a0e7a4546c4c73d0 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AQ6eHOKhVvbZrMVMNTxbEEBiC2J8Sw+Bas6vEk9Sqs0LSV4tanBU0KJQ6bPHLbRJQiWUsQWFKGU7lGklbNE1963zmsBQypRql1KRiuwETVqZOo9WtIZmJjmjvSq+y90e6NolHKe0iL3j2cSbZr0rATRhp4W5RxcLLcmgKBH0W38CbBoOsdQg4OvcsFXKcKveL6KGBfbZvTUdrmAjeFBdrBw0s+wD1hJapw5eTYIVU5N5kyxobFZyTHna8m0n5T6EvdBFk49o4NObTxpL2+njTO2lv0DPgceJSgC6O1p6fUuKIUaiJVnkJS8AnWDwPGLcRl01JUuvN2MH4tzTNChSzg== 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=rSh3L/AFX1kwUWbUN803XD5qISN//S+9dF22OnqF/Ss=; b=Z/UqlXJ5LpH2G/yL+BQlvggij6/yxlD6hoHyRxagsEiZKAcraH00ldXJ7rbpJYGmBh+Kijw3nKxBggUlrCkvB82HqpbT3VuijcWNE9hjAiflN9UsGym6ZZhaKhs6h4sOtNDxaogXWwdKoaU/B+gGvvaKuJq3fwfhAjtfI1EwLlcrdLVXPMEREOmDO18cFaPRyQ1wnV2OhiyOAl56gLwliF77TDbBfXBx+SZnvjEHgE3g9Jfz5CKAet/BEwb+y94egEzTdG9/o2Uwk+D5jYTt5LRaRBr4bZHzgfa+uu4Wg7QrbogAWekgjbRQeepplAOj7xCwEB/UdHnlsc0nsyZqtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rSh3L/AFX1kwUWbUN803XD5qISN//S+9dF22OnqF/Ss=; b=lPPyoz94FwlEGHmUOII9wMO8lhVidDeQOajv7kcMUtK9QPNsX8EnMarfB9mnxQiLrWPoRuvHpapr9yW0aLDnUTJgrMflzcCyQiknO2FkPHxatDpGI5bZ5AUc9EhMeaEePc/GqXAtxnHm6+lJxVlZfxwNS0N7llTuEJU0BwLrYiw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 01/11] xen: introduce internal CDF_xxx flags for domain creation Date: Thu, 27 Jan 2022 07:49:19 +0000 Message-ID: <20220127074929.502885-2-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 297eebb0-cc8e-41cd-ce0f-08d9e169b5f3 X-MS-TrafficTypeDiagnostic: VE1PR08MB4877:EE_|DB5EUR03FT044:EE_|DB8PR08MB5130:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1051;OLM:1051; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: KSGpiICiUrydWxOKs8WR34Rt4t6PUOE2R7pix5PnOADzVLDAAL2BJwV+9AKMNR6EfuChvAp1MK/Uqu8RS2qhz/KDpEbXVzifsMFdpnRSxj/84HeZR/TeTR/r8CjJKmMmWVeDzibTQlJnHu8/B15rp9krE68QX82PDTNrPWOqhOoT36t050QGYuNq1QNUQrmOMTAyTePoShVvQVABBo+ofFhcaKIVgZxiBoScRl1SV6MLifwIOoZBchOC9lQYrT40wmMosM3Phjg3u6QE2JIP2fgz5xox+BPDyON8ljlA0jwioexAfZQmmzJZOAg48aDX9DKM1x/py3oKkW8E22n2J0FQuUFCTqVK1oqBJytHzl8/6Ergy9Sp1/qo2wbVaNeFn3k9pK3MrrASf9zOS9mfUlHKTiDeI++S6ObFbY/r0Du6XVKK6Crvk0W8CwT5TYF209mrIGg7k/D1V2yv6E++uNakCUHgs0zPucE4dTeZ/xrnWwwHbM7tS5HguBDgHaSSCap42+Q9cGQZyes33J15oYuEC4V/oI7mzZLMHAhDEcmr8b81WV3nSlY0yg9HzCoVR8RVPWkr+mM+m3ooUVXsolOBisvxGYCtxQ92DGdz4H1I99WZaSwfA05EKGhl3aPlC6uigx6ckeEtSbZdeYOq48xC4mCLT3BSMeikrwRLHdjdXgLKtzeVJ9xsUbGGj9Bzl8xKcUjzkxRPSG4U+HyYY9qQCzCKHgVgNC9KZIgm0cU= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(186003)(36756003)(1076003)(81166007)(36860700001)(26005)(40460700003)(356005)(47076005)(7696005)(44832011)(2616005)(6666004)(2906002)(82310400004)(83380400001)(336012)(70206006)(70586007)(4326008)(508600001)(8676002)(426003)(8936002)(54906003)(110136005)(5660300002)(86362001)(316002)(21314003)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4877 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1fc58dbc-a7ff-42b5-0f87-08d9e169afa8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8qp8svwKDWe3TRJosiRBO34prpAV/MqZqxKgAvDJHXyU1qOPrwLoOkoPeMXaT2zgTO1YE4+IxLqzb/BIvkq4rYAH1UrPCfTdtzBXmFuyvgz4JQRdV9r5rSeMmjfjaZN6EuBPWWiKgoh3qwYHf8ljuDhHCBVtSeT8e/6kbYq0E3ZLSdP6VjU5P/WeOewQUVtzO0oE0tnCj0juLgrLrNBd4/VYEgkyGyfJGXcnsL7eaYAR3Dmkdtg+1ZpT2Tucp0//cbKqd7hmy+FAyS9avksaax5b5oWbwNLfQ/OEhFho2QS0GjH2GOtpStyjpLDCNgD7ELaliIHGXXbauj/KHQqtsMC7uLLNSvhiha/AggW9i7sO3VsSmAnupJwNPYxrAuMopSXm5I3wMraumZUkDoKo9lVRsoIZ0QZTY1P6eQG9y94bzOvD6GJKY9nb783pFTHUm7fWty87TvyivngAbIBK6et+gIhvY3I2svH5RS5kVM7cgwomfP0HYsQOZJq9IGVqaT6mB/uubiqNTE3l0OaGYWacELEW8ZG/SxtS/K6hwzFWQnnPaGTxnkjBBFFZPfHD9cx1cUvSbsFQO5mTLVFHph+YJ91G86BAL4M0IMlCBOJIwhuEVONzQDmruz/h2MUMxjLg5mGI0NvEcCBdwYw0Kl3+Se7bNmesfkBlkUaYJA295AjCz9QjIObtq1NxxBhG2WfRFIw6CefKn1Pa9LBucg== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(2616005)(44832011)(81166007)(2906002)(36860700001)(83380400001)(1076003)(47076005)(82310400004)(186003)(26005)(70586007)(5660300002)(508600001)(426003)(336012)(4326008)(8936002)(8676002)(6666004)(36756003)(70206006)(316002)(86362001)(40460700003)(54906003)(7696005)(110136005)(21314003)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:50:38.9949 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 297eebb0-cc8e-41cd-ce0f-08d9e169b5f3 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5130 From: Stefano Stabellini We are passing an internal-only boolean flag at domain creation to specify whether we want the domain to be privileged (i.e. dom0) or not. Another flag will be introduced later in this series. This commit extends original "boolean" to an "unsigned int" covering both the existing "is_priv" and our new "directmap", which will be introduced later. To make visible the relationship, we name the respective constants CDF_xxx (with no XEN_DOMCTL_ prefix) to represent the difference with the public constants XEN_DOMCTL_CDF_xxx. Allocate bit 0 as CDF_privileged: whether a domain is privileged or not. Signed-off-by: Stefano Stabellini Signed-off-by: Penny Zheng Reviewed-by: Jan Beulich Tested-by: Stefano Stabellini Reviewed-by: Julien Grall --- v4 changes: - new commit --- v5 changes - remove const constraint --- xen/arch/arm/domain_build.c | 4 ++-- xen/arch/x86/setup.c | 2 +- xen/common/domain.c | 10 +++++----- xen/common/sched/core.c | 2 +- xen/include/xen/domain.h | 4 ++++ xen/include/xen/sched.h | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 6931c022a2..0fab8604de 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3058,7 +3058,7 @@ void __init create_domUs(void) * very important to use the pre-increment operator to call * domain_create() with a domid > 0. (domid == 0 is reserved for Dom0) */ - d = domain_create(++max_init_domid, &d_cfg, false); + d = domain_create(++max_init_domid, &d_cfg, 0); if ( IS_ERR(d) ) panic("Error creating domain %s\n", dt_node_name(node)); @@ -3160,7 +3160,7 @@ void __init create_dom0(void) if ( iommu_enabled ) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; - dom0 = domain_create(0, &dom0_cfg, true); + dom0 = domain_create(0, &dom0_cfg, CDF_privileged); if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) ) panic("Error creating domain 0\n"); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index e716005145..a14271488c 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -789,7 +789,7 @@ static struct domain *__init create_dom0(const module_t *image, /* Create initial domain. Not d0 for pvshim. */ domid = get_initial_domain_id(); - d = domain_create(domid, &dom0_cfg, !pv_shim); + d = domain_create(domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); if ( IS_ERR(d) ) panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); diff --git a/xen/common/domain.c b/xen/common/domain.c index 2048ebad86..a79103e04a 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -552,7 +552,7 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) struct domain *domain_create(domid_t domid, struct xen_domctl_createdomain *config, - bool is_priv) + unsigned int flags) { struct domain *d, **pd, *old_hwdom = NULL; enum { INIT_watchdog = 1u<<1, @@ -578,7 +578,7 @@ struct domain *domain_create(domid_t domid, } /* Sort out our idea of is_control_domain(). */ - d->is_privileged = is_priv; + d->is_privileged = flags & CDF_privileged; /* Sort out our idea of is_hardware_domain(). */ if ( domid == 0 || domid == hardware_domid ) @@ -772,7 +772,7 @@ void __init setup_system_domains(void) * Hidden PCI devices will also be associated with this domain * (but be [partly] controlled by Dom0 nevertheless). */ - dom_xen = domain_create(DOMID_XEN, NULL, false); + dom_xen = domain_create(DOMID_XEN, NULL, 0); if ( IS_ERR(dom_xen) ) panic("Failed to create d[XEN]: %ld\n", PTR_ERR(dom_xen)); @@ -782,7 +782,7 @@ void __init setup_system_domains(void) * array. Mappings occur at the priv of the caller. * Quarantined PCI devices will be associated with this domain. */ - dom_io = domain_create(DOMID_IO, NULL, false); + dom_io = domain_create(DOMID_IO, NULL, 0); if ( IS_ERR(dom_io) ) panic("Failed to create d[IO]: %ld\n", PTR_ERR(dom_io)); @@ -791,7 +791,7 @@ void __init setup_system_domains(void) * Initialise our COW domain. * This domain owns sharable pages. */ - dom_cow = domain_create(DOMID_COW, NULL, false); + dom_cow = domain_create(DOMID_COW, NULL, 0); if ( IS_ERR(dom_cow) ) panic("Failed to create d[COW]: %ld\n", PTR_ERR(dom_cow)); #endif diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 8f4b1ca10d..f5c819349b 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -3021,7 +3021,7 @@ void __init scheduler_init(void) sched_ratelimit_us = SCHED_DEFAULT_RATELIMIT_US; } - idle_domain = domain_create(DOMID_IDLE, NULL, false); + idle_domain = domain_create(DOMID_IDLE, NULL, 0); BUG_ON(IS_ERR(idle_domain)); BUG_ON(nr_cpu_ids > ARRAY_SIZE(idle_vcpu)); idle_domain->vcpu = idle_vcpu; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 160c8dbdab..cfb0b47f13 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -28,6 +28,10 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info); void arch_get_domain_info(const struct domain *d, struct xen_domctl_getdomaininfo *info); +/* CDF_* constant. Internal flags for domain creation. */ +/* Is this a privileged domain? */ +#define CDF_privileged (1U << 0) + /* * Arch-specifics. */ diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 37f78cc4c4..24a9a87f83 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -665,7 +665,7 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config); */ struct domain *domain_create(domid_t domid, struct xen_domctl_createdomain *config, - bool is_priv); + unsigned int flags); /* * rcu_lock_domain_by_id() is more efficient than get_domain_by_id(). From patchwork Thu Jan 27 07:49:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726373 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 F120CC433FE for ; Thu, 27 Jan 2022 07:51:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261216.452059 (Exim 4.92) (envelope-from ) id 1nCzYU-0000sI-4H; Thu, 27 Jan 2022 07:50:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261216.452059; Thu, 27 Jan 2022 07:50:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzYT-0000s7-W8; Thu, 27 Jan 2022 07:50:53 +0000 Received: by outflank-mailman (input) for mailman id 261216; Thu, 27 Jan 2022 07:50:52 +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 1nCzYR-0000Xj-VT for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:50:52 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20625.outbound.protection.outlook.com [2a01:111:f400:7e1a::625]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d8bb539b-7f45-11ec-8eb8-a37418f5ba1a; Thu, 27 Jan 2022 08:50:50 +0100 (CET) Received: from DB6PR0301CA0075.eurprd03.prod.outlook.com (2603:10a6:6:30::22) by AM9PR08MB6820.eurprd08.prod.outlook.com (2603:10a6:20b:30f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 27 Jan 2022 07:50:41 +0000 Received: from DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:30:cafe::a6) by DB6PR0301CA0075.outlook.office365.com (2603:10a6:6:30::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.17 via Frontend Transport; Thu, 27 Jan 2022 07:50:41 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT016.mail.protection.outlook.com (10.152.20.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:41 +0000 Received: ("Tessian outbound 18e50a6f0513:v113"); Thu, 27 Jan 2022 07:50:41 +0000 Received: from 47971b1d2ff1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CEEA1370-56B6-42BE-9901-F134C1CDAB0D.1; Thu, 27 Jan 2022 07:50:34 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 47971b1d2ff1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:50:34 +0000 Received: from AS8PR04CA0106.eurprd04.prod.outlook.com (2603:10a6:20b:31e::21) by AM0PR08MB4961.eurprd08.prod.outlook.com (2603:10a6:208:161::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 27 Jan 2022 07:50:31 +0000 Received: from AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31e:cafe::55) by AS8PR04CA0106.outlook.office365.com (2603:10a6:20b:31e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:50:31 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT032.mail.protection.outlook.com (10.152.16.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:31 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:29 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50:27 +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: d8bb539b-7f45-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qJY+Z8v2F+OrilDf0c+mywrBc7V7NbAWQsU/sTzRiWQ=; b=YOWaLxK2hRMsjcThyNKtsOXrILT4Gu3QkZrllp7XvKCBYQgatpTiAV/dKOT2Igbm3BkQKYYjtKr6lPWJtok7y6JpM0GqYp1FJIlQPlaZEAthvQ5e0J5IzC5Jh+rDzlk/Aqg6eD24p7u0f0a8ztwIIWPsY9zxUjZu3oI24EMRewM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: e9646bc275f6d35e X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C2JVR5LaimGOCi2GUq7jN8EW7Q4qMPrcVvb+Kha9qlw4JLBUyN/HvL1H/XgtQafi5cUdpbtXBC0fE6dXYDpLegCO18kja416hUrhLMD3XULATn9Mm7DSQucqayNNAdXo2Fap+W+/dnBormPm/GvP83vs6H4sN4+GF0HEPWf9JWefj5BaXDDpjiEyKook6HLIPz+Qlfoyyyc+3XU62kx4kpiUwPIIDp5rawJXUg9pt+PpA2xdDghkUWNTT1r4Lh2GRhG2EFb2LagLXM0l4BH+j8MM7UE96Kaei7F4hEN4+djHBekvUaEWSNA8fYwdaOPTImfDhVon1pUr1QdVx4phhA== 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=qJY+Z8v2F+OrilDf0c+mywrBc7V7NbAWQsU/sTzRiWQ=; b=P2oxIwm9La25o3IPrp2gu7NVmOig1zBDJCUvZ8/GU5FJ6z/llktjJO38z1lFCUv0OhmXkMZHmr8Uu/9HuoLvVSBlkBlcqhSzFtdAvRiNfoM6AL+zA3L5TP3OSdDdODjJyJ0ViA9xAtdHe1A0OjyMjmYNRq4hwScPqLRoRzxg2b0FE0Q8Xj4CfWx/bnBYXs4SN7XAYDcFRSk/qpQ1n5jcRYBgrpzPkrzv3vY0uhezxmS0nLxDxHsZpMpdF1w3CUdew1b3r7ufRqZfzrLjrXVBSyCZRb3D/jT+TilyYvLdQDoqUuZZuAEfrENU6JwV3M9DTS4wrUcki1b2FTcoq1Rv3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qJY+Z8v2F+OrilDf0c+mywrBc7V7NbAWQsU/sTzRiWQ=; b=YOWaLxK2hRMsjcThyNKtsOXrILT4Gu3QkZrllp7XvKCBYQgatpTiAV/dKOT2Igbm3BkQKYYjtKr6lPWJtok7y6JpM0GqYp1FJIlQPlaZEAthvQ5e0J5IzC5Jh+rDzlk/Aqg6eD24p7u0f0a8ztwIIWPsY9zxUjZu3oI24EMRewM= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 02/11] xen: introduce CDF_directmap Date: Thu, 27 Jan 2022 07:49:20 +0000 Message-ID: <20220127074929.502885-3-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 2034215e-60a6-408e-8712-08d9e169b72c X-MS-TrafficTypeDiagnostic: AM0PR08MB4961:EE_|DB5EUR03FT016:EE_|AM9PR08MB6820:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:213;OLM:213; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: S6ty7VA1WgAomn9VI6LOvP5W71fC7dsKo5l/EfKkbNHg3xoI6xd/PVrB0UlfZKmLRoSv5hoX9Elzp21YE85Bg1OwtXtzCLgBLHGG5bwGFeA/BHaZ63W3h/xUQB9+ZBXagoGa+Q5ywTf1JKsSOBf2nRpO0s3ephuAS1vle9/OrCUWPqFTeV1c3Muq6CrsK6c1hj8hXrXakCy5jupynevU4Dnz8nZJZ8Lo3dAG9i47S8YeL/JJwz/b+HQj2H5IaOij+llUHY8d77dEKAHsLZEa+9dssgLHKpSOT+ttJ+cFUrkwRmSG4moVyNTiwY2ylkxFQk/bqf6LqGBBjxSTIrzmHK7YkXljluW6PsDKXEGgM38OdUfvqH6CN1SCtZloXkXSO3dE4FBRse2CY6ptyuiZnyDSS+nJ9x9dWaqt/vjHkojrSEzeSNIe8YDGr8tLoHUHam5H1amtpNrNMd5mVwNyQV7W41ks0vqrMYsBSZA3qfWEUsVJ79KeSy0dS7Q94BWvDU+TfhZnUXc0qAatw+VdYKvPqyHxCX8rf5V0oKEeB4W9+YxEoafTftgyUU3b/W9FbJHQn3TcRIbbdMZLHJ4F2njaq9azluURPaDFLn17sFlwlVw/FvfFWJ6kd4ejLqZ67fCYAupWaEpirdrvKWrRGTSF2xVHpNP6QktawcOtDuapl9cIWgqsori1Cp8r1L1WYR7besOi9bVvt16qDE3Sw81iLh2WYagD4achjasU7rI= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(36756003)(6666004)(336012)(426003)(70586007)(70206006)(8676002)(4326008)(8936002)(5660300002)(7696005)(508600001)(110136005)(86362001)(316002)(54906003)(40460700003)(81166007)(44832011)(356005)(2906002)(2616005)(26005)(47076005)(1076003)(186003)(82310400004)(83380400001)(36860700001)(21314003)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4961 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c93fe7fd-476d-4415-fedb-08d9e169b14c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QsrKD67OpbVVNwqUmpgToM95YkJIxhUNlatGnbUqWkFCl0IM0cMhiuMDU8yRFIu0MiQyOkotdKSRk7MjzhoES1dzsDSTtmFU8rqa/NfXu7Qc3sg6mPXLwh6Xh4/dKZrVNavfp7I4b+j5DOFEl5pUWyvABMWBPF9me2XT8cpqpr8kfxrapTVFZqiBR5hl3CWg6nsGGTk4IUPDbq5sqZvYMUnrhlVH3QUZ7dHYAR5S1j0rhhXJLpQy6O5EY379RzZXOQ7DpIcDL+KhK5oa26gHpF8JgJFV7tMdbJVDW/bKANTIKnNxz/Fhde+GTphCwWSlw6Sm6hRSAYkXUofFutU89n39gWqYbxhD2J5PlTrUc/WdY/XaX5S+1BNvOmv4UC93aQG2yrF7u7XF1sYPAAIRIjc2QyaTf4snBsMZucIXbRFX6UZdlZEq6hgQLEGkCukqcNkrdR9ClU337UKFiXH2P2f6IzlcXNczaLM2KZWwqLxPdJIeSVwM6fs7O+cdrlRaAupvB6KIYRGU8s/CJ5jTdKrgxhTqrnn/Qc+O4CwrZfdeL9p87DsKRzzs3o5cglUIvoqJD86W0U4FCOUAtcqP7qu6yE9GJamrguPtNPq3Rb6RNsrmx+0FCgatN5zrCJlQafU61z4PKs+LNwwXJYd8lDWvHNSwLVKeEK2pGJE/rTiHNCpYGouRAsm83tLrnuBN5tFO3UjiJUfxIkqCLA2bPA== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(83380400001)(86362001)(426003)(5660300002)(2906002)(36756003)(6666004)(47076005)(336012)(54906003)(110136005)(7696005)(40460700003)(8936002)(26005)(316002)(36860700001)(508600001)(1076003)(4326008)(8676002)(186003)(44832011)(70206006)(81166007)(2616005)(82310400004)(70586007)(21314003)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:50:41.0600 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2034215e-60a6-408e-8712-08d9e169b72c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6820 From: Stefano Stabellini This commit introduces a new arm-specific flag CDF_directmap to specify that a domain should have its memory direct-map(guest physical address == physical address) at domain creation. Also, add a directmap flag under struct arch_domain and use it to reimplement is_domain_direct_mapped. For now, direct-map is only available when statically allocated memory is used for the domain, that is, "xen,static-mem" must be also defined in the domain configuration. Signed-off-by: Stefano Stabellini Signed-off-by: Penny Zheng Acked-by: Jan Beulich Tested-by: Stefano Stabellini --- CC: andrew.cooper3@citrix.com CC: jbeulich@suse.com CC: George Dunlap CC: Ian Jackson CC: Wei Liu CC: "Roger Pau MonnĂ©" --- v2 changes - remove the introduce of internal flag - remove flag direct_map since we already store this flag in d->options - Refine is_domain_direct_mapped to check whether the flag XEN_DOMCTL_CDF_directmap is set - reword "1:1 direct-map" to just "direct-map" --- v3 changes - move flag back to xen/include/xen/domain.h, to let it be only available for domain created by XEN. - name it with extra "INTERNAL" and add comments to warn developers not to accidently use its bitfield when introducing new XEN_DOMCTL_CDF_xxx flag. - reject this flag in x86'es arch_sanitise_domain_config() --- v4 changes - introduce new internal flag CDF_directmap - add a directmap flag under struct arch_domain and use it to reimplement is_domain_direct_mapped. - expand arch_domain_create to include internal-only parameter "const unsigned int flags" --- v5 changes - remove const constraint - strict "static allocation" check --- docs/misc/arm/device-tree/booting.txt | 6 ++++++ xen/arch/arm/domain.c | 5 ++++- xen/arch/arm/domain_build.c | 14 ++++++++++++-- xen/arch/arm/include/asm/domain.h | 5 +++-- xen/arch/x86/domain.c | 3 ++- xen/common/domain.c | 2 +- xen/include/xen/domain.h | 5 ++++- 7 files changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt index 71895663a4..a94125394e 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -182,6 +182,12 @@ with the following properties: Both #address-cells and #size-cells need to be specified because both sub-nodes (described shortly) have reg properties. +- direct-map + + Only available when statically allocated memory is used for the domain. + An empty property to request the memory of the domain to be + direct-map (guest physical address == physical address). + Under the "xen,domain" compatible node, one or more sub-nodes are present for the DomU kernel and ramdisk. diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 92a6c509e5..8110c1df86 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -692,7 +692,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) } int arch_domain_create(struct domain *d, - struct xen_domctl_createdomain *config) + struct xen_domctl_createdomain *config, + unsigned int flags) { int rc, count = 0; @@ -708,6 +709,8 @@ int arch_domain_create(struct domain *d, ioreq_domain_init(d); #endif + d->arch.directmap = flags & CDF_directmap; + /* p2m_init relies on some value initialized by the IOMMU subsystem */ if ( (rc = iommu_domain_init(d, config->iommu_opts)) != 0 ) goto fail; diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 0fab8604de..6467e8ee32 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3029,10 +3029,20 @@ void __init create_domUs(void) .max_maptrack_frames = -1, .grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version), }; + unsigned int flags = 0U; if ( !dt_device_is_compatible(node, "xen,domain") ) continue; + if ( dt_property_read_bool(node, "direct-map") ) + { + if ( !IS_ENABLED(CONFIG_STATIC_MEMORY) || !dt_find_property(node, "xen,static-mem", NULL) ) + panic("direct-map is not valid for domain %s without static allocation.\n", + dt_node_name(node)); + + flags |= CDF_directmap; + } + if ( !dt_property_read_u32(node, "cpus", &d_cfg.max_vcpus) ) panic("Missing property 'cpus' for domain %s\n", dt_node_name(node)); @@ -3058,7 +3068,7 @@ void __init create_domUs(void) * very important to use the pre-increment operator to call * domain_create() with a domid > 0. (domid == 0 is reserved for Dom0) */ - d = domain_create(++max_init_domid, &d_cfg, 0); + d = domain_create(++max_init_domid, &d_cfg, flags); if ( IS_ERR(d) ) panic("Error creating domain %s\n", dt_node_name(node)); @@ -3160,7 +3170,7 @@ void __init create_dom0(void) if ( iommu_enabled ) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; - dom0 = domain_create(0, &dom0_cfg, CDF_privileged); + dom0 = domain_create(0, &dom0_cfg, CDF_privileged | CDF_directmap); if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) ) panic("Error creating domain 0\n"); diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h index 9b3647587a..cb37ce89ec 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -29,8 +29,7 @@ enum domain_type { #define is_64bit_domain(d) (0) #endif -/* The hardware domain has always its memory direct mapped. */ -#define is_domain_direct_mapped(d) is_hardware_domain(d) +#define is_domain_direct_mapped(d) (d->arch.directmap) struct vtimer { struct vcpu *v; @@ -89,6 +88,8 @@ struct arch_domain #ifdef CONFIG_TEE void *tee; #endif + + bool directmap; } __cacheline_aligned; struct arch_vcpu diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index ef1812dc14..9835f90ea0 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -722,7 +722,8 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) } int arch_domain_create(struct domain *d, - struct xen_domctl_createdomain *config) + struct xen_domctl_createdomain *config, + unsigned int flags) { bool paging_initialised = false; uint32_t emflags; diff --git a/xen/common/domain.c b/xen/common/domain.c index a79103e04a..3742322d22 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -659,7 +659,7 @@ struct domain *domain_create(domid_t domid, radix_tree_init(&d->pirq_tree); } - if ( (err = arch_domain_create(d, config)) != 0 ) + if ( (err = arch_domain_create(d, config, flags)) != 0 ) goto fail; init_status |= INIT_arch; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index cfb0b47f13..3a2371d715 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -31,6 +31,8 @@ void arch_get_domain_info(const struct domain *d, /* CDF_* constant. Internal flags for domain creation. */ /* Is this a privileged domain? */ #define CDF_privileged (1U << 0) +/* Should domain memory be directly mapped? */ +#define CDF_directmap (1U << 1) /* * Arch-specifics. @@ -65,7 +67,8 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset); void unmap_vcpu_info(struct vcpu *v); int arch_domain_create(struct domain *d, - struct xen_domctl_createdomain *config); + struct xen_domctl_createdomain *config, + unsigned int flags); void arch_domain_destroy(struct domain *d); From patchwork Thu Jan 27 07:49:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726378 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 B758AC433F5 for ; Thu, 27 Jan 2022 07:51:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261228.452114 (Exim 4.92) (envelope-from ) id 1nCzYm-0003Zv-Go; Thu, 27 Jan 2022 07:51:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261228.452114; Thu, 27 Jan 2022 07:51:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzYm-0003Za-B7; Thu, 27 Jan 2022 07:51:12 +0000 Received: by outflank-mailman (input) for mailman id 261228; Thu, 27 Jan 2022 07:51:10 +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 1nCzYk-0000Xj-P4 for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:51:10 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on061a.outbound.protection.outlook.com [2a01:111:f400:fe1e::61a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e1fd8c1a-7f45-11ec-8eb8-a37418f5ba1a; Thu, 27 Jan 2022 08:51:06 +0100 (CET) Received: from AS9PR06CA0175.eurprd06.prod.outlook.com (2603:10a6:20b:45c::25) by PA4PR08MB6128.eurprd08.prod.outlook.com (2603:10a6:102:f2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Thu, 27 Jan 2022 07:51:03 +0000 Received: from VE1EUR03FT028.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45c:cafe::1e) by AS9PR06CA0175.outlook.office365.com (2603:10a6:20b:45c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:51:03 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT028.mail.protection.outlook.com (10.152.18.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:51:02 +0000 Received: ("Tessian outbound 2877e54fe176:v113"); Thu, 27 Jan 2022 07:51:02 +0000 Received: from 3aa213c0726f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A40001FB-D96D-4334-9974-9672E1538D2D.1; Thu, 27 Jan 2022 07:50:56 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3aa213c0726f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:50:56 +0000 Received: from DB6PR0301CA0058.eurprd03.prod.outlook.com (2603:10a6:4:54::26) by VI1PR08MB4029.eurprd08.prod.outlook.com (2603:10a6:803:ec::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 27 Jan 2022 07:50:54 +0000 Received: from DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::e2) by DB6PR0301CA0058.outlook.office365.com (2603:10a6:4:54::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:50:53 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT037.mail.protection.outlook.com (10.152.20.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:53 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:32 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:31 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50:29 +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: e1fd8c1a-7f45-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Rl3pkQoUExfheoWKn2LL1MYHodWIJQAVAKmSODsmtEM=; b=vwMHaAuwe9WJ5uX602CpgHOUFjwzJG/w04emSjL0YtI438gWd7vjnv4KyEXYy2c5SexBk/o7x/kkX5T45YDe4Oui/dnSv7TV7+AA3Sx7Vo5BbZxMWBPOx7zXHHmu4tTtPp/Iaozc1Od/OWS6rHD5lz92bs+ta9JLN/93EuvRQGs= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 1c844911c2d0f9d3 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FEAwo/xv1/topxQPlBp6JoeF2VhN/T61cESr/Ghdfq0YwbjX0bPkyFrqYB8iM56NEIQZShbc01WhlyeSgCFYb4OS/m+DCPqQdD/MSgdezQh2lQA+K/PHfURaULzgSDbaqBx2LlknAgwJDc92MUXPsqUZFRLcETRB9gCF9JZqWdfagSNL8r/wZVd+vzFXc8P3TB2blTmQB953Sxe02MyDVnxE/KS9Dfpt8A5xolUME/xdJDnWncSv+TLi+jzKJgz+AfNUUbOSg4czzE0olYjmZbT7V0IysMD+Ji9d2YBIOioo5+bGxxzLsRQ3F1h9mSkrufYUl6S6aOOzQRlD+YnOkA== 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=Rl3pkQoUExfheoWKn2LL1MYHodWIJQAVAKmSODsmtEM=; b=PP7HDOL8M5HYSdUzE42w5OIGGhMB43wD/oODVYTMmpjSg3A2OjRVdJQehv7MzH5LizpN/UNXU/2+TmCa1GNDogkxSqp1D2Cd8z2y0hH2g3qqjNOG+0HsBnhekaKfMwuOHKEt4+A3FstBktPa7ztGYDJoXEx5Ps+s/M+O0k13uNNbI207LqBQ1jd5PE42umtVz/PWSmt2DKMgR/REFJq7dYMuI3/DL54gm+C3KQPsKD3mF7ySPgBjZdcaTTggTq1+grzrbZU8VDPs75eNTgmfADgHYcW8FC5dT3+wNJjQ6SWY+hC+KAeAvkVZ+vWt821IZUHBHVLi+MM8NreN39vn5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Rl3pkQoUExfheoWKn2LL1MYHodWIJQAVAKmSODsmtEM=; b=vwMHaAuwe9WJ5uX602CpgHOUFjwzJG/w04emSjL0YtI438gWd7vjnv4KyEXYy2c5SexBk/o7x/kkX5T45YDe4Oui/dnSv7TV7+AA3Sx7Vo5BbZxMWBPOx7zXHHmu4tTtPp/Iaozc1Od/OWS6rHD5lz92bs+ta9JLN/93EuvRQGs= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 03/11] xen/arm: avoid setting XEN_DOMCTL_CDF_iommu when IOMMU off Date: Thu, 27 Jan 2022 07:49:21 +0000 Message-ID: <20220127074929.502885-4-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 07f30cc9-8caf-48d9-975f-08d9e169c42e X-MS-TrafficTypeDiagnostic: VI1PR08MB4029:EE_|VE1EUR03FT028:EE_|PA4PR08MB6128:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1332;OLM:1332; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 7i0Lwtjjnn9mIYEafqA1AdQBTpadhLbvhbjjyuAhDsTR43wWjUnaABxkYdtOA467gE8sk0svFIbMq0JOzuZYeR1ok29Wd8jB6ODZa1C0ALqnMdTsJGhTicxENIx+vyYSPk9sfWHd1Eu5DkxLCUdPNd5zSRYy7QWfD7XO51HtoDCkcxuLKJjNg3GeSj376F1qhoodRCickYmiAaAK103OfqMvx5nBTKanGvJliwdqqMMWmvv9/V3STxWtgaBHZekHgUetlqkboMXLIEGW3bDmnobZEYKFqLOLbDrKhcjd7BSRcB9DLK5qOy7bNDq8Vk5ii0UQ/aJv4ZGW3aZYcZlZD1Zawc9INr5mQ4wCjxvSiWS6vCHu+UKamCmmj+DrnLLmZJxFw77CWfAMmhRWWi1KB9Ih1nVwGJdB8rIFT8FN4pHzD3hDhDIT9Z+JLD/UgsFhQcLomcJriMEv34pg02myD8tIlFCxv4/Sp8HaGzK94CuhJEV8IXWp3mvzuCw5Kr6T3OXhEMS0+hJxegLmLuSt15OP7I+fF5xYvXPdevqxCGRFWB6l5DZLLEHq5EBxJfUCk7mnYFUY3IWPSOy1hK3QJjFsKq4jy7fUmOq3xrMw9WRNXsxbkLwOb2FrbaXMdew3AuG62yQ9wQtlgIAuyl6ain7htXf1gZssc25EODByDv7cwIclJabfN0uHg7Lm/ml+iKe0S4pLneuMy1NFgcmT0Q== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(2616005)(44832011)(81166007)(2906002)(356005)(36860700001)(83380400001)(1076003)(47076005)(82310400004)(186003)(26005)(70586007)(5660300002)(508600001)(426003)(336012)(4326008)(8936002)(8676002)(6666004)(36756003)(70206006)(316002)(86362001)(40460700003)(54906003)(7696005)(110136005)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4029 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 325893ee-de7e-4d49-fe4c-08d9e169be94 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FJSZ6Y7PhGn4YEMb3Y+2+zPflBvIAnU1zYI446sa3ZxvX8g6LuWiEcRIl1Lb/+vxQXJOF2V813E5HiVZj6ZA4M0dQJRbEjizzGGrQUhUGWMJAFRhjdTT3LFPcdwKhhzDsVHaLcW1JGSwc0mtwDJ3hg6CEtAQ14fIR3wxJ4eVU8h5aiBilLlER6IMiYeH4w4v7+ihoh+YAfVT+Kjxa5hNu7ymoMN6ML5HAl79+KCi/AtK0SL9k4omMye/i56K5wRUDoc4S43o8uIfEOy8YWI5KX1LEREjp3PcG6zwy4pr8REWRhSiFhYcHeAYljY8RXJT9TghugwqH0Gf5BuKTrMsNssIAiknbRTnSevLXMQFOgdJa5jQ6BID/ruAhMH7o61VodBnoY5jwuG89WrxfT/uT8Cw7zLVsD84iLyfQQE6mabCKzw1GcztXjfFqKU3BV1bDSB0MgD7FZJtmNyx155cy0XNKYLvDGB6CFBB+lifeBuDOdJJ/YzzQtx4XIRUShrfQT/Z5VI6G0FXKpf8NEg1MM4tvOZhSpvlIABam7lZnV7hiCHk/bDCnsQKFEia6dmwf7NAoPsyYIHqHvYZL6d3+AizVXpWs98pd0qBIKwxGEGPV0z9yNXgC8dMBqikRe3KZOsetsaodiZCXwhXDNcH1Pl3nG1wI/jSwQtkAcCowsXPBeH1LmiFy12Ilf7n/FAOVWobexZGdpKZcnLxrUoYBvcPxBb7k01/3InRTmpuxvaehMLTe+QEJMVnLkU7MpABBOiW6MwWhqT8ufVn5vXD+w== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(46966006)(40470700004)(36840700001)(4326008)(86362001)(8676002)(83380400001)(47076005)(5660300002)(2616005)(81166007)(2906002)(7696005)(6666004)(1076003)(26005)(44832011)(508600001)(36756003)(186003)(40460700003)(82310400004)(110136005)(54906003)(70586007)(70206006)(426003)(316002)(8936002)(336012)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:51:02.7745 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07f30cc9-8caf-48d9-975f-08d9e169c42e X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT028.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6128 From: Stefano Stabellini When IOMMU is absent or shall not be used (trusted domain, performance, hardware limitation, ..., etc), in which cases this commit avoids setting XEN_DOMCTL_CDF_iommu to make those user cases possible and prevent failure later during device assignment. Signed-off-by: Stefano Stabellini Signed-off-by: Penny Zheng Tested-by: Stefano Stabellini --- v3 changes: - new commit, split from the original "[PATCH v2 2/6] xen/arm: introduce direct-map for domUs" --- v4 changes: - explain briefly in the commit message why we want to do device assignment without IOMMU. --- v5 changes: - nothing changed --- xen/arch/arm/domain_build.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 6467e8ee32..c1e8c99f64 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -3047,7 +3047,8 @@ void __init create_domUs(void) panic("Missing property 'cpus' for domain %s\n", dt_node_name(node)); - if ( dt_find_compatible_node(node, NULL, "multiboot,device-tree") ) + if ( dt_find_compatible_node(node, NULL, "multiboot,device-tree") && + iommu_enabled ) d_cfg.flags |= XEN_DOMCTL_CDF_iommu; if ( !dt_property_read_u32(node, "nr_spis", &d_cfg.arch.nr_spis) ) From patchwork Thu Jan 27 07:49:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726372 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 2D9BBC433F5 for ; Thu, 27 Jan 2022 07:51:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261215.452048 (Exim 4.92) (envelope-from ) id 1nCzYR-0000ZM-Ly; Thu, 27 Jan 2022 07:50:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261215.452048; Thu, 27 Jan 2022 07:50:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzYR-0000ZB-Ic; Thu, 27 Jan 2022 07:50:51 +0000 Received: by outflank-mailman (input) for mailman id 261215; Thu, 27 Jan 2022 07:50:50 +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 1nCzYQ-0000Xj-Bj for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:50:50 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0627.outbound.protection.outlook.com [2a01:111:f400:fe0c::627]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d737afb7-7f45-11ec-8eb8-a37418f5ba1a; Thu, 27 Jan 2022 08:50:49 +0100 (CET) Received: from DB6P18901CA0010.EURP189.PROD.OUTLOOK.COM (2603:10a6:4:16::20) by AM5PR0801MB1651.eurprd08.prod.outlook.com (2603:10a6:203:39::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 27 Jan 2022 07:50:43 +0000 Received: from DB5EUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:16:cafe::ec) by DB6P18901CA0010.outlook.office365.com (2603:10a6:4:16::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:50:43 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT044.mail.protection.outlook.com (10.152.21.167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:43 +0000 Received: ("Tessian outbound 63bb5eb69ee8:v113"); Thu, 27 Jan 2022 07:50:43 +0000 Received: from c34b16ce37c1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8846CCC2-29D0-4286-9D8E-C4CE81294CE9.1; Thu, 27 Jan 2022 07:50:37 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c34b16ce37c1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:50:37 +0000 Received: from AS8PR04CA0093.eurprd04.prod.outlook.com (2603:10a6:20b:31e::8) by AM6PR08MB4405.eurprd08.prod.outlook.com (2603:10a6:20b:b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.13; Thu, 27 Jan 2022 07:50:34 +0000 Received: from AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31e:cafe::24) by AS8PR04CA0093.outlook.office365.com (2603:10a6:20b:31e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:34 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT032.mail.protection.outlook.com (10.152.16.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:34 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:34 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:33 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50:32 +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: d737afb7-7f45-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sH+JDxJqSi4MWsWTFqNhTsipHdTKsPE2NyugzwEu6T4=; b=Vc7dnXhke1WEMCeyxX0IS8a4Un2a+xHRKrZuuuo8cASs3NGbMo/8E3/7yILtWEpwYRQIF0Tks496X3ga03/7Um9LxC1k7JhrpKPefuOjlswZH9M/CNJoR6OJK4wlOJZ1pcNMZHI250fx/duzCyX7hG0if97Q1dnxMP7ftjiKGMc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 6cb73171e516e849 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=esla83ufDgRB4Mm+JNxkW8Cx5CPCE/329La6LqyBPqYWGSKxzsKl1kWx3+qjk3C88/Q7PXQ07j3PsoJ+9qa/FB+b/8Pxr0nLuQ1XEXP/8Jp6PGeQLBimI2T+sLI1cB4+X4T7qdl5FA1HA+NpnVacJZKktl2h1q2TIKogGPXRy8wTM+wJgY3ZthkYRU0kJ7uA9haD9li2IWBaIYZWvMrNomD0Y6Z7P149UBu672DwnpnsKUDl5ppgyHpd9Lo350GZ4Hrpcb4pfoZs6VaNJguUDG73FpNbK9Z+sWLT7D416Ul0QJHu35f++SGGIIEo3HVS03cgFeW1exI2HM6C3nct3w== 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=sH+JDxJqSi4MWsWTFqNhTsipHdTKsPE2NyugzwEu6T4=; b=Y1N0SWOyn0LGqBRpg55Z807evmue0+VIjv/vvaEftB6pMqpZlBzy4EabEzWbTd9OXsOTOp5q46nu4Xs0mcNB40erlK2J1tdYar2djrx6Ofqg/k/EVSkIkoYd+6P5ryW0v0cbvy1t2J9l5kP4OPkVraCgy7OvP3vmXNJclTrA44VoNH0htPKYcBOu9LmtOpEjhq252wiA7kndqt+eQGB7r34UP2iGBsvDXcHrSU53Melyw1dP2kHGj6wsybyMIyFC4/Acvw+3rg4pS7DbMslujgfOkX8MUV18tEvap0V9isUq6Kbrdx4WRcamfKK8xDyNu6D4rT5yusVIdr1/2oVkNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sH+JDxJqSi4MWsWTFqNhTsipHdTKsPE2NyugzwEu6T4=; b=Vc7dnXhke1WEMCeyxX0IS8a4Un2a+xHRKrZuuuo8cASs3NGbMo/8E3/7yILtWEpwYRQIF0Tks496X3ga03/7Um9LxC1k7JhrpKPefuOjlswZH9M/CNJoR6OJK4wlOJZ1pcNMZHI250fx/duzCyX7hG0if97Q1dnxMP7ftjiKGMc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 04/11] xen/arm: introduce new helper parse_static_mem_prop and acquire_static_memory_bank Date: Thu, 27 Jan 2022 07:49:22 +0000 Message-ID: <20220127074929.502885-5-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 46d47487-b43b-4e15-6e9a-08d9e169b883 X-MS-TrafficTypeDiagnostic: AM6PR08MB4405:EE_|DB5EUR03FT044:EE_|AM5PR0801MB1651:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:281;OLM:281; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: SpR9G3ONgDxJ6mcbjZJRKREMM6lJ3FmLvqotqI8Qv4qs+OYzWUWo28pL3jjpnGBIWGC+usm2+LBFqgjaRTp7Wcrz7/KzZkD0IL7fB37oag+bLWxButVm2Of385pg1ANN8USn8XWX/x/y4Fxv0PmJcUH2Wg3QOkfFee0N7wbV1H8bwZ0edIpIl9MHFgAe7/O6X1Im19k++mokagStbsjb3WOYHaBOpZhW+HFc9DslGkMjj70w4wQ1hOoMLLWii7Q34+dsVDodz/t0CHkNBymLNrZ86tsNvtbwspSsAhc2x1JrNntdg3cJB/aXiNyLOWPifQhHt0Z40jI4xiDF6D44Oan0eaXNfmwRS1AnRA3OgUoml7koU/po/znK6S1UCBd5kI+S/BRAzbv8Kn5lZjojHo4EH7y9nhdO1qqQTM9zQq6MSt7+EDfesuf6osWI6P632JuulHRA4ozHTvvnDo9w4GghS8SPoejXSAl+QBZoECNEEU0xpOXjJGSLv63X/h/uRlzewS34yBkkKfOs1dpi/Y6nKIn+L+i5Dv9nThqLI0n/lcUXOfyt7KwC3NDvbHFAh1CybfQbKlX5eKvHJCAu5L8EcCk6doVr8+abXI16moM0mi1COmZqgGh17Nn48L6msiKn+U5eywQc0dEfvX2sHMGWJf3zOlLkCKGK2IHvXA//XnO1NfIyKYYMRTvk5tcFbq3Cr7YUMXb/OoSITlPE/jlEXwXwqSFHYEMW7pdXsxLJGr3Psu43xJDcVzjmDBBDxvRODdgDhHsR2tCnIoJ8ZfLjkpYU0tqbVUAyKpDTcj8= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(40470700004)(46966006)(36840700001)(7696005)(44832011)(5660300002)(6666004)(83380400001)(8936002)(2616005)(86362001)(70206006)(40460700003)(47076005)(356005)(4326008)(81166007)(110136005)(54906003)(316002)(26005)(336012)(36860700001)(82310400004)(2906002)(508600001)(70586007)(426003)(8676002)(1076003)(186003)(36756003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4405 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d86766de-d184-44c4-29b3-08d9e169b36a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q4aB5jJX/dS19+0SWGdMla0w+zcXmYCndCxWhRBzUFT3TmDuusOnS/HuFpHO4wr3bOQrRK/zaDGUIX5buS7AutgVaJ00Y00zbETTn+3fRh1tj9vWSu6VSDiKJaNLyImCN4FRzKijQdYqRhU9Y9sU5kdmm6KXqUA0I1MtnppJDUiYKEvGkvotqYYkMcsKQIMl3cJoGR7CHJ4kEbwxh1mTbu2km5Ar/6S8DXVmAlfd7tZPQ1OuXKHRZGrMp7QJn75JTROEm+tOl3BNB/jsItbo3qdsffNUDALjaxXhpUTN6pZ3pF3XELTIiJw4TN85NZbEYSSehXa/gITVPVCIsqoXYO7Sf7lNJVnagnXYqumQZltpQCM8HCN5skKzTnraImuqROdlLYZITELSNGyiNkz48X4GrkIhMXmWCUzkaQHYmKDMRNRN7oxoiOfEBidR7EoxAn5ZBMt3GhBUdKKYYI61tcswMDu12vcu7aLRnDuY456FZjHR53oN2Q47aGioxR8NBgP1wlBBtzg8epaHMAyE93iJAxnwBM8ASnlz/d46yo4Ab8J6N/AxULmhqq0Ornh5dZewKbWboRQyFYBWTdxn7mWkCpNnr4ZjPMoz89OHNg31YwEYEubzHGq1/IzUIlB30CIb2oHdOWmHJZuyxIvVh17zu++3xiXvmmYY18S9986mQY9QeJQ/wkYlLeRNOekZ X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(82310400004)(110136005)(54906003)(26005)(426003)(336012)(47076005)(1076003)(83380400001)(186003)(6666004)(7696005)(508600001)(2616005)(86362001)(36860700001)(70586007)(8936002)(8676002)(4326008)(70206006)(2906002)(44832011)(5660300002)(40460700003)(316002)(81166007)(36756003)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:50:43.3072 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 46d47487-b43b-4e15-6e9a-08d9e169b883 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1651 Later, we will introduce assign_static_memory_11 for allocating static memory for direct-map domains, and it will share a lot common codes with the existing allocate_static_memory. In order not to bring a lot of duplicate codes, and also to make the whole code more readable, this commit extracts common codes into two new helpers parse_static_mem_prop and acquire_static_memory_bank. Signed-off-by: Penny Zheng Reviewed-by: Stefano Stabellini Tested-by: Stefano Stabellini --- v3 changes: - new commit, split from the original "[PATCH v2 2/6] xen/arm: introduce direct-map for domUs" --- v4 changes - explain briefly in the commit message why we want to do device assignment without IOMMU. --- v5 changes - fix coding style --- xen/arch/arm/domain_build.c | 100 +++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 36 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index c1e8c99f64..e61d2d53ba 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -509,12 +509,69 @@ static bool __init append_static_memory_to_bank(struct domain *d, return true; } +static mfn_t __init acquire_static_memory_bank(struct domain *d, + const __be32 **cell, + u32 addr_cells, u32 size_cells, + paddr_t *pbase, paddr_t *psize) +{ + mfn_t smfn; + int res; + + device_tree_get_reg(cell, addr_cells, size_cells, pbase, psize); + ASSERT(IS_ALIGNED(*pbase, PAGE_SIZE) && IS_ALIGNED(*psize, PAGE_SIZE)); + if ( PFN_DOWN(*psize) > UINT_MAX ) + { + printk(XENLOG_ERR "%pd: static memory size too large: %#"PRIpaddr, + d, *psize); + return INVALID_MFN; + } + + smfn = maddr_to_mfn(*pbase); + res = acquire_domstatic_pages(d, smfn, PFN_DOWN(*psize), 0); + if ( res ) + { + printk(XENLOG_ERR + "%pd: failed to acquire static memory: %d.\n", d, res); + return INVALID_MFN; + } + + return smfn; +} + +static int __init parse_static_mem_prop(const struct dt_device_node *node, + u32 *addr_cells, u32 *size_cells, + int *length, const __be32 **cell) +{ + const struct dt_property *prop; + + prop = dt_find_property(node, "xen,static-mem", NULL); + if ( !dt_property_read_u32(node, "#xen,static-mem-address-cells", + addr_cells) ) + { + printk(XENLOG_ERR + "failed to read \"#xen,static-mem-address-cells\".\n"); + return -EINVAL; + } + + if ( !dt_property_read_u32(node, "#xen,static-mem-size-cells", + size_cells) ) + { + printk(XENLOG_ERR + "failed to read \"#xen,static-mem-size-cells\".\n"); + return -EINVAL; + } + + *cell = (const __be32 *)prop->value; + *length = prop->length; + + return 0; +} + /* Allocate memory from static memory as RAM for one specific domain d. */ static void __init allocate_static_memory(struct domain *d, struct kernel_info *kinfo, const struct dt_device_node *node) { - const struct dt_property *prop; u32 addr_cells, size_cells, reg_cells; unsigned int nr_banks, gbank, bank = 0; const uint64_t rambase[] = GUEST_RAM_BANK_BASES; @@ -523,24 +580,10 @@ static void __init allocate_static_memory(struct domain *d, u64 tot_size = 0; paddr_t pbase, psize, gsize; mfn_t smfn; - int res; - - prop = dt_find_property(node, "xen,static-mem", NULL); - if ( !dt_property_read_u32(node, "#xen,static-mem-address-cells", - &addr_cells) ) - { - printk(XENLOG_ERR - "%pd: failed to read \"#xen,static-mem-address-cells\".\n", d); - goto fail; - } + int length; - if ( !dt_property_read_u32(node, "#xen,static-mem-size-cells", - &size_cells) ) - { - printk(XENLOG_ERR - "%pd: failed to read \"#xen,static-mem-size-cells\".\n", d); + if ( parse_static_mem_prop(node, &addr_cells, &size_cells, &length, &cell) ) goto fail; - } reg_cells = addr_cells + size_cells; /* @@ -551,29 +594,14 @@ static void __init allocate_static_memory(struct domain *d, gbank = 0; gsize = ramsize[gbank]; kinfo->mem.bank[gbank].start = rambase[gbank]; - - cell = (const __be32 *)prop->value; - nr_banks = (prop->length) / (reg_cells * sizeof (u32)); + nr_banks = length / (reg_cells * sizeof (u32)); for ( ; bank < nr_banks; bank++ ) { - device_tree_get_reg(&cell, addr_cells, size_cells, &pbase, &psize); - ASSERT(IS_ALIGNED(pbase, PAGE_SIZE) && IS_ALIGNED(psize, PAGE_SIZE)); - - if ( PFN_DOWN(psize) > UINT_MAX ) - { - printk(XENLOG_ERR "%pd: static memory size too large: %#"PRIpaddr, - d, psize); + smfn = acquire_static_memory_bank(d, &cell, addr_cells, size_cells, + &pbase, &psize); + if ( mfn_eq(smfn, INVALID_MFN) ) goto fail; - } - smfn = maddr_to_mfn(pbase); - res = acquire_domstatic_pages(d, smfn, PFN_DOWN(psize), 0); - if ( res ) - { - printk(XENLOG_ERR - "%pd: failed to acquire static memory: %d.\n", d, res); - goto fail; - } printk(XENLOG_INFO "%pd: STATIC BANK[%u] %#"PRIpaddr"-%#"PRIpaddr"\n", d, bank, pbase, pbase + psize); From patchwork Thu Jan 27 07:49:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726379 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 ADCFDC433EF for ; Thu, 27 Jan 2022 07:51:25 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261232.452125 (Exim 4.92) (envelope-from ) id 1nCzYo-0003xl-5H; Thu, 27 Jan 2022 07:51:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261232.452125; Thu, 27 Jan 2022 07:51:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzYo-0003we-05; Thu, 27 Jan 2022 07:51:14 +0000 Received: by outflank-mailman (input) for mailman id 261232; Thu, 27 Jan 2022 07:51:13 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzYm-0008Mi-SI for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:51:13 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2061f.outbound.protection.outlook.com [2a01:111:f400:7e1b::61f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id e4da8ad7-7f45-11ec-8f75-fffcc8bd4f1a; Thu, 27 Jan 2022 08:51:11 +0100 (CET) Received: from AM8P191CA0016.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::21) by AM9PR08MB7101.eurprd08.prod.outlook.com (2603:10a6:20b:41a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 07:51:10 +0000 Received: from VE1EUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:21a:cafe::b6) by AM8P191CA0016.outlook.office365.com (2603:10a6:20b:21a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:51:10 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT019.mail.protection.outlook.com (10.152.18.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:51:09 +0000 Received: ("Tessian outbound 741ca6c82739:v113"); Thu, 27 Jan 2022 07:51:09 +0000 Received: from e105dde92142.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CC93E2F0-21EA-4475-94A2-76E03B244F59.1; Thu, 27 Jan 2022 07:51:03 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e105dde92142.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:51:03 +0000 Received: from DB6PR0301CA0061.eurprd03.prod.outlook.com (2603:10a6:4:54::29) by DBAPR08MB5847.eurprd08.prod.outlook.com (2603:10a6:10:1a0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 07:50:55 +0000 Received: from DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::70) by DB6PR0301CA0061.outlook.office365.com (2603:10a6:4:54::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:50:55 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT037.mail.protection.outlook.com (10.152.20.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:55 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:36 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:35 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50:34 +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: e4da8ad7-7f45-11ec-8f75-fffcc8bd4f1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HJ6pNGZyTQYLxJKZGBnj9F34C5RzJhd0CRvAgb1BVyU=; b=PA/rvwGNZkNJApPB68L21Y4sL3jX0/KuSSVoDUTgbaWhmaQKkzJnfIrzVsKauWgXkbq7s8MgllCaxNf8Q37ZgOgFtYQonIMA7/kHY6l7fGxb96C2/PXXZ2WUO1zfv8qY0jlTxiV0kInqYE0XWWsCSmuLu/1pNoM1d+5yvc3S5F8= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: fc1e44a9ecbac685 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hZ0kQAYF8QlByHFRDLkIv/rOVPvCSuxvNyHmpIftqL+NYEzeg8DsWCmaaHeWa+ZZczlSJl5ddPVI93gXs6qm7wsVf1g5Nay/a8dPu30txIwtY4a+hK6RXwMByY4FM41f54+jhRsOIgFROw4ySH7VLSRrr7TnRzG7Mh3evNeb0ajIlrew99Afy4rtSuTeVdIRKN5n90UyZ1qyycTurR8WmUxiKPUdLXTl49+9NOFHx/Uyr1wIagyNT5L8gJyUmeBABT7bNVxQzNSTlIU8x7nO5h1kV/CQ1KDe+KHLs2s2D4npZGrOhsvYy4keENGQ6WKOBs3ZuPJjZlYn+ZWG9fQNtg== 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=HJ6pNGZyTQYLxJKZGBnj9F34C5RzJhd0CRvAgb1BVyU=; b=c6kfX5lOsUezfWWxOjN0zr9a6gYy1bGRUbu2gplxppcNaVmlw8YsKHQmm6LLOB5I60p7NXCMOtrNBh2UUwzrZk2A7yRnC3VD5cbrj0pRa531kwqCHvmh86p+xV2CUch56AQIcuYaTSm+/RB4K+QH9P9jRoBFamICiMHOEnPAAXbR2Z4WkEl6za1KGQKll3T/8JAAMImgapLWZmQxfaA+YFc6SQfxvfhs7kcQY7K0RrHmYrxUn77pFxV21Mo0hkHljyrTt0u27+CBeEG1rTd0PEJm0MUj9GwvqmdwVyOxbW1SJ+Z7bdU58yhBoIXVQ1B3lRsAYVFIm8bWSXPIrqkQng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HJ6pNGZyTQYLxJKZGBnj9F34C5RzJhd0CRvAgb1BVyU=; b=PA/rvwGNZkNJApPB68L21Y4sL3jX0/KuSSVoDUTgbaWhmaQKkzJnfIrzVsKauWgXkbq7s8MgllCaxNf8Q37ZgOgFtYQonIMA7/kHY6l7fGxb96C2/PXXZ2WUO1zfv8qY0jlTxiV0kInqYE0XWWsCSmuLu/1pNoM1d+5yvc3S5F8= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 05/11] xen/arm: introduce direct-map for domUs Date: Thu, 27 Jan 2022 07:49:23 +0000 Message-ID: <20220127074929.502885-6-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 0fef3adb-fa6b-471d-0603-08d9e169c84f X-MS-TrafficTypeDiagnostic: DBAPR08MB5847:EE_|VE1EUR03FT019:EE_|AM9PR08MB7101:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1332;OLM:1332; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: YIGTyZ10pbiRE2SCuJzGy3xYDA9n7WdEcB0TtjwG7ipnpOcgthhCWudKsY1nortkoiQ2I5048UpHQ7o6vSm7w50u2/1NT7snwA4eiRShUX31jPOy/dJcMphwoK4q1Ff2s8VydD+xR2mPL5VKNXbpXea1X5IUneF3tXO0Q6PMl7C8ItiKi9k+7RuMEOXV8oZ/dOzrDWTJ4YhC/WOO1dUdBTcdPlUgWPUy3VScX6N08S2SmOT0CE+0s+FWflDRISGNUNTPGOzB2G4V0ohSHbMvy5Ziu2hghTAMyCuqjCzd+JQRy7PqDMBVyKh81ub/T8R0mMi9GxKLzAYjETgHO0ROL63MREcQUbmhfxa40Aw1GkM4JI4doAzAejUN9Qr4Txbfv2zdkdOzAZ7oDT6z6wCyJg+BZSL5eU7wGlZLA6HtTfeN/GD/n14gIHLCh+wxWJn3YiBPODYa1O39/tEq4Dv6onuCkROz9GcnARa+bcJFXMOryW9FiWIsRBzuavXp8aQM3FQQAxu1RMmHnp/0oQ8Fps1fJFzk427pUSaWBLuPkT3oKJ6OBtpM7j8wfEPYPtEKLI1z+WkGlyb+9CnJj6VrnHC5EstWIlkONjRQcnHCFwM1AKRXcude1uIpZK5isg69WmA9XSohpEmW5zZX9DycrN5LDKWUxqwgngv+vgYLqQxIgXnOfqyb4iDh21zxv5S4OyksbVH1MRXEJfqompnVYQ== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(5660300002)(36860700001)(2616005)(70206006)(70586007)(2906002)(36756003)(508600001)(6666004)(81166007)(44832011)(356005)(7696005)(83380400001)(54906003)(26005)(82310400004)(316002)(40460700003)(336012)(110136005)(8936002)(8676002)(4326008)(1076003)(186003)(47076005)(426003)(86362001)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5847 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 27549ade-7b54-4dc7-4f7e-08d9e169bfae X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 72bo7nO9CoeYRE2LFIVw7WCx4vXCqGtN2oGfdu4VZJMe1kblMpN6MsxhobV/OS5EZULpNUJ1gBpfdRx/biATHVAf1yBce1AFDFYXDVYkwPavOIyJe/9T5703j9J4FJMFISy839B+PwdNTRJ21WGHNR0/TzDMurDNIGxgZtABd3nlUGcTfb+gmROHXLZ4gBnk8PDQEDo15uRrHBPobWSBZlsHePAJK8UbpgqpXLMKDN0UlfsGnEXXSZOEY/EuqP5NKm1WWsWSmUqWTJLtx6qssnrH39vyaVX+sFrfgI33dJXExxATwgmp0zOoqU6oONA+bPtwwy+nMDyRLLZbtDDxKTqvOJfUAVP6pPQuJgeCCn5ZFqU7LlijR68Cm3I3qzZwPSx8HpRVpsha0zZGCQgeVyVh5v42vUhA1mUN6aCq+6Sm0jZQ/8yqmmu7g9EYgxoeiUlCmLA7YDxkbBK82/qrtSvoffJpzZZ523Lq5K37KiGfcgjhz5PgrSjrtlMnckIZLP7TlAIL7K3Rc1hXhYf6sE5UeLYpKaObymY825F8ySwF830vP/icLHA4UGAkeeY/2aOf5bhXWeTaqQfhvG8PslCpU67PaJkrgaHdtOHCGvXOLrYfBVP+mnxfyhYuWBdi0GpYYYPEgt4j2uFYQB0T9oL9fIKXPJ0mOfs4srfSyifDVcpsIdTAEt+vkn60ttv4 X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(2616005)(26005)(186003)(1076003)(508600001)(86362001)(44832011)(426003)(36860700001)(47076005)(336012)(40460700003)(83380400001)(2906002)(6666004)(7696005)(4326008)(110136005)(81166007)(316002)(82310400004)(8936002)(5660300002)(70206006)(70586007)(8676002)(54906003)(36756003)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:51:09.7025 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0fef3adb-fa6b-471d-0603-08d9e169c84f X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB7101 Cases where domU needs direct-map memory map: * IOMMU not present in the system. * IOMMU disabled if it doesn't cover a specific device and all the guests are trusted. Thinking a mixed scenario, where a few devices with IOMMU and a few without, then guest DMA security still could not be totally guaranteed. So users may want to disable the IOMMU, to at least gain some performance improvement from IOMMU disabled. * IOMMU disabled as a workaround when it doesn't have enough bandwidth. To be specific, in a few extreme situation, when multiple devices do DMA concurrently, these requests may exceed IOMMU's transmission capacity. * IOMMU disabled when it adds too much latency on DMA. For example, TLB may be missing in some IOMMU hardware, which may bring latency in DMA progress, so users may want to disable it in some realtime scenario. * Guest OS relies on the host memory layout This commit introduces a new helper assign_static_memory_11 to allocate static memory as guest RAM for direct-map domain. Signed-off-by: Penny Zheng Reviewed-by: Stefano Stabellini Tested-by: Stefano Stabellini --- v2 changes: - split the common codes into two helpers: parse_static_mem_prop and acquire_static_memory_bank to deduce complexity. - introduce a new helper allocate_static_memory_11 for allocating static memory for direct-map guests - remove redundant use "bool direct_map", to be replaced by d_cfg.flags & XEN_DOMCTL_CDF_directmap - remove panic action since it is fine to assign a non-DMA capable device when IOMMU and direct-map both off --- v3 changes: - doc refinement - drop the pointless gbank - add check of the size of nr_banks shall not exceed NR_MEM_BANKS - add ASSERT_UNREACHABLE to catch any misuse - add another check of validating flag XEN_DOMCTL_CDF_INTERNAL_directmap only when CONFIG_STATIC_MEMORY is set. --- v4 changes: - comment refinement - rename function allocate_static_memory_11() to assign_static_memory_11() to make clear there is actually no allocation done. Instead we are only mapping pre-defined host regions to pre-defined guest regions. - remove tot_size to directly substract psize from kinfo->unassigned_mem - check kinfo->unassigned_mem doesn't underflow or overflow - remove nested if/else - refine "panic" info --- v5 changes: - fix coding style --- xen/arch/arm/domain_build.c | 97 +++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index e61d2d53ba..ec29bd302c 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -494,8 +494,17 @@ static bool __init append_static_memory_to_bank(struct domain *d, { int res; unsigned int nr_pages = PFN_DOWN(size); - /* Infer next GFN. */ - gfn_t sgfn = gaddr_to_gfn(bank->start + bank->size); + gfn_t sgfn; + + /* + * For direct-mapped domain, the GFN match the MFN. + * Otherwise, this is inferred on what has already been allocated + * in the bank. + */ + if ( !is_domain_direct_mapped(d) ) + sgfn = gaddr_to_gfn(bank->start + bank->size); + else + sgfn = gaddr_to_gfn(mfn_to_maddr(smfn)); res = guest_physmap_add_pages(d, sgfn, smfn, nr_pages); if ( res ) @@ -668,12 +677,92 @@ static void __init allocate_static_memory(struct domain *d, fail: panic("Failed to allocate requested static memory for domain %pd.", d); } + +/* + * Allocate static memory as RAM for one specific domain d. + * The static memory will be directly mapped in the guest(Guest Physical + * Address == Physical Address). + */ +static void __init assign_static_memory_11(struct domain *d, + struct kernel_info *kinfo, + const struct dt_device_node *node) +{ + u32 addr_cells, size_cells, reg_cells; + unsigned int nr_banks, bank = 0; + const __be32 *cell; + paddr_t pbase, psize; + mfn_t smfn; + int length; + + if ( parse_static_mem_prop(node, &addr_cells, &size_cells, &length, &cell) ) + { + printk(XENLOG_ERR + "%pd: failed to parse \"xen,static-mem\" property.\n", d); + goto fail; + } + reg_cells = addr_cells + size_cells; + nr_banks = length / (reg_cells * sizeof(u32)); + + if ( nr_banks > NR_MEM_BANKS ) + { + printk(XENLOG_ERR + "%pd: exceed max number of supported guest memory banks.\n", d); + goto fail; + } + + for ( ; bank < nr_banks; bank++ ) + { + smfn = acquire_static_memory_bank(d, &cell, addr_cells, size_cells, + &pbase, &psize); + if ( mfn_eq(smfn, INVALID_MFN) ) + goto fail; + + printk(XENLOG_INFO "%pd: STATIC BANK[%u] %#"PRIpaddr"-%#"PRIpaddr"\n", + d, bank, pbase, pbase + psize); + + /* One guest memory bank is matched with one physical memory bank. */ + kinfo->mem.bank[bank].start = pbase; + if ( !append_static_memory_to_bank(d, &kinfo->mem.bank[bank], + smfn, psize) ) + goto fail; + + kinfo->unassigned_mem -= psize; + } + + kinfo->mem.nr_banks = nr_banks; + + /* + * The property 'memory' should match the amount of memory given to + * the guest. + * Currently, it is only possible to either acquire static memory or + * let Xen allocate. *Mixing* is not supported. + */ + if ( kinfo->unassigned_mem != 0 ) + { + printk(XENLOG_ERR + "Size of \"memory\" property doesn't match up with the sum-up of \"xen,static-mem\".\n"); + goto fail; + } + + return; + + fail: + panic("Failed to assign requested static memory for direct-map domain %pd.", + d); +} #else static void __init allocate_static_memory(struct domain *d, struct kernel_info *kinfo, const struct dt_device_node *node) { } + +static void __init assign_static_memory_11(struct domain *d, + struct kernel_info *kinfo, + const struct dt_device_node *node) +{ + ASSERT_UNREACHABLE(); +} #endif /* @@ -3023,8 +3112,10 @@ static int __init construct_domU(struct domain *d, #endif if ( !dt_find_property(node, "xen,static-mem", NULL) ) allocate_memory(d, &kinfo); - else + else if ( !is_domain_direct_mapped(d) ) allocate_static_memory(d, &kinfo, node); + else + assign_static_memory_11(d, &kinfo, node); rc = prepare_dtb_domU(d, &kinfo); if ( rc < 0 ) From patchwork Thu Jan 27 07:49:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726374 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 BFD7CC433F5 for ; Thu, 27 Jan 2022 07:51:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261217.452070 (Exim 4.92) (envelope-from ) id 1nCzYV-00018o-Go; Thu, 27 Jan 2022 07:50:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261217.452070; Thu, 27 Jan 2022 07:50:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzYV-00018c-9N; Thu, 27 Jan 2022 07:50:55 +0000 Received: by outflank-mailman (input) for mailman id 261217; Thu, 27 Jan 2022 07:50:54 +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 1nCzYU-0008Mi-Dg for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:50:54 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0600.outbound.protection.outlook.com [2a01:111:f400:fe1e::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id da354251-7f45-11ec-8f75-fffcc8bd4f1a; Thu, 27 Jan 2022 08:50:53 +0100 (CET) Received: from DB6PR1001CA0027.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:55::13) by VI1PR0801MB1885.eurprd08.prod.outlook.com (2603:10a6:800:84::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 07:50:50 +0000 Received: from DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:55:cafe::df) by DB6PR1001CA0027.outlook.office365.com (2603:10a6:4:55::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:50:50 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT027.mail.protection.outlook.com (10.152.20.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:49 +0000 Received: ("Tessian outbound 2877e54fe176:v113"); Thu, 27 Jan 2022 07:50:49 +0000 Received: from 22ec596bc51f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1F59E17D-8800-4770-B9F5-9F826555375A.1; Thu, 27 Jan 2022 07:50:43 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 22ec596bc51f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:50:43 +0000 Received: from AS9PR06CA0396.eurprd06.prod.outlook.com (2603:10a6:20b:461::9) by AM5PR0801MB1634.eurprd08.prod.outlook.com (2603:10a6:203:39::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.14; Thu, 27 Jan 2022 07:50:40 +0000 Received: from AM5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:461:cafe::4e) by AS9PR06CA0396.outlook.office365.com (2603:10a6:20b:461::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:40 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT012.mail.protection.outlook.com (10.152.16.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:40 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:38 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:37 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50: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: da354251-7f45-11ec-8f75-fffcc8bd4f1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5ADeT2DevMW88RBtpOZP9XyqhR303hWtW1f/VBC5H4k=; b=evXeaosW0bIjoA8RBjMsViybg5chvFqBj8UTq1W7uFQFajFAtxPnH/aZtafomgCnKCamBZtR0uk0aOrWrtrr1YxlGVyYoA4p7KQs3GyRizIenFgOSmx2F+sZg+MZ9CgDfMPkD8EY/o4qylGKLaKXyH6mTmWpAi9fphK/tdo8+5U= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 4668b5f1c2a5e3f1 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WCW6lGP8Nwbc9guDJDgDin3T5X8WFfNzB4cxbjPIpQE+m8Bpw8qIkY5II2gbvI59AiVLHVYcas1aRRtzHj2vzhEoyBv3hndU0xotzFR+jvO83yMkv12xQZYZy4qyqWfbZLAOMmd2+MHs0D7B/rNqw04MY8UVEveSBk/mZz+78aj9aqgOCJf1D3Kw67gjTC6EU60pTghKeVULkzJsntpANBrGLZx5NgjrCFP6l+fQT7HBWnA1XD5zwI9+ucjxIrMAUEaGbjMNCauNLADS1tH8uCo7KsxjcAOcfSIP7KuTFbZtxXPfsKZM615qOO7iNsCW2ZCAYOUcGYDYG9yXbombyA== 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=5ADeT2DevMW88RBtpOZP9XyqhR303hWtW1f/VBC5H4k=; b=FaHwWwq1w4BUmm9nj74ATWuxD1T4sLijglvTn5IzLNG2wdroKvOviUB69jEV0PyZAd25nnxtQOMkE49kiTS54qoY+8K9iTEA1gehLNSUJcrW+ylMOys1uVv6fWyJVje3lVJSbQBOuLTvlNYF1xrIXU+5b1Ard+1uxOsWVknN+e/u91rEy4S3Zk3eFsR19FkYiW2lbE6ULQB8rz8UXZ5iGl+YmcdEjXjuOCNbgJQ6+La+SWh3kegAC0IgW2qYiEfWiF1+Uwmm142i3+reJQmg5gT7XGEcQf5jz4Ll95Z/PbmuZtcEnYEYCpfoA6ZLbQmxoJmZw/eSvZjsgdm8LnbnYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5ADeT2DevMW88RBtpOZP9XyqhR303hWtW1f/VBC5H4k=; b=evXeaosW0bIjoA8RBjMsViybg5chvFqBj8UTq1W7uFQFajFAtxPnH/aZtafomgCnKCamBZtR0uk0aOrWrtrr1YxlGVyYoA4p7KQs3GyRizIenFgOSmx2F+sZg+MZ9CgDfMPkD8EY/o4qylGKLaKXyH6mTmWpAi9fphK/tdo8+5U= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 06/11] xen/arm: add ASSERT_UNREACHABLE in allocate_static_memory Date: Thu, 27 Jan 2022 07:49:24 +0000 Message-ID: <20220127074929.502885-7-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: cf3d3887-5b1d-49a8-080a-08d9e169bc73 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1634:EE_|DB5EUR03FT027:EE_|VI1PR0801MB1885:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:326;OLM:326; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: dKj/ASqYfY7IOU1Pk0j5xYdQUFcdH1dgbeRLmE7joC2iSl0LB2SiXZQTK97w/01HOr8Nx0YHAlpJSqWSoiisT8pbN95Hqwxg6fyWfyciGSEBZ7/cQzxahq1BdxulpnVZYndCGXYZA3aBEMNniZ50HKKsi/iR9leEgNj+bxyiGp8/M5YQFOkebh4/AOy/5dLHHNtLt5sjBywD6ZJaZpElOOYvVIUAst790YT6RuMuowNOxlK10qmjPMeo4En4np0ByKMljkVk/6FmHMBMGkyuzTmViAKxdY7vKg4ZSschYwA7tcnRWarTggJkZOuc8wRfPWc795CrGuL/VAsfyIIrp9ChOVlAkEfPTqm0nuHR47M/IgqUFJ7Q8OOPTD2EJAhZMS/H1GssXlD1dInCNc4uxn+nfmGF2T8bWMOHEp5SXpvxzs099TCq/+I9kBbrTXd7omQmHgaUGat1RfgiU+D+LTBLeSnFrifnbf291Yjam1VL5NwZHCeminzZgPe/gYvmbhdlovt8iYt9hyMLaq7hZOeVJ5GMVkMv5IOVnxsAkHMWtua24vsRdx03ASg/nbtoXKkX1i+4vJbS5Wbpdf6EN8dOmFuXAQQ4uBBYpilpJBnpCORZtmUNcbU+zO0t0GHguxKfqInTrhnxCJt9E4Yc0Av/DSnmS437ymYoODOgw/RE6m5mfS0WjbgccJGRRl3fs2uM0D4ZEw4JC8PpKDiKk0PvDExXxzVPhB2LIdSAZN7BmVbkLiocAx/T0EvAAPviLFhlKFqs2IzhVO7MAqQsuM64rS8Vt2V/cmXNK4Hs1fQ= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(40470700004)(46966006)(82310400004)(40460700003)(8676002)(2906002)(54906003)(316002)(4326008)(508600001)(186003)(336012)(110136005)(26005)(47076005)(5660300002)(6666004)(1076003)(4744005)(81166007)(2616005)(44832011)(7696005)(36860700001)(70586007)(426003)(70206006)(86362001)(36756003)(356005)(8936002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1634 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f988be24-d081-4013-29c4-08d9e169b6d1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SscVWSg11K5oGEhNhQX+U3nImf8evTA2NTemQDdw/v3LcD3Sf4DAKl9ExEoHTmLbyrKqTmwbE/iPiOAe5g30leEt9Ju3VTp3kOfDFk9bTUkzQUsPLD55Uef1WbpcXJboELRZLyXrL+VR+5H/tbGVkumypysZc59m4NKgySff9Iw4S78wp98Ib7Tr8t9bUrECEF7G6hd/SjxBc6Ztxd3KxOt+xkc294vJyiuQYF3HF00jgxgLGDN6L64OkFd5pAvu9lUz908BUVCbodBFrYgFSb/dNrKq0gUxAVn87Hmo3Bq2oGYWv3QycvY8UQAmNeZUrjl8+bzr0Ulb7hD0PJYgSow1oGpBiuowzrljF5z9X5Wohb0vTasldZmFW+tiZFE90daGi3I016B3MhaV6b8kWafoFrTc3NKQC9X3qH39TsSk4sU5+NO05CI1lWng+t5qAFgfVysjCx83s5j7aQH0K2a+OL/+05XHZNrvBwe/Diiksl1cVizfzbjLrg+dAFDcfPFZYmLAKQLZYAQJkOTqH8v3htJ4HJGUSVollEb2sgQupaLJreYsfjl3j8E2m7cqpboTLrPx3jRRvL0WDTqgm8sOXm3NclxRPsWaHrT2GhLQ0TrmgO/EGZ3BLprU0PvI8rnT9Sx9CjnvqQJiNNYNEJ/zBnP88Okben6cQW56YVCs9k6n8cgFcd1gaeDgZJ67 X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(316002)(70586007)(70206006)(8936002)(8676002)(82310400004)(4326008)(7696005)(40460700003)(336012)(426003)(26005)(44832011)(5660300002)(186003)(6666004)(1076003)(86362001)(47076005)(36756003)(81166007)(36860700001)(508600001)(4744005)(2616005)(54906003)(2906002)(110136005)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:50:49.9106 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf3d3887-5b1d-49a8-080a-08d9e169bc73 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1885 Helper allocate_static_memory is not meant to be reachable when built with !CONFIG_STATIC_MEMORY, so this commit adds ASSERT_UNREACHABLE in it to catch potential misuse. Signed-off-by: Penny Zheng Acked-by: Julien Grall Tested-by: Stefano Stabellini --- v3 changes: - new commit --- v4 changes: - nothing changed --- v5 changes: - nothing changed --- xen/arch/arm/domain_build.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index ec29bd302c..52f256de9c 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -755,6 +755,7 @@ static void __init allocate_static_memory(struct domain *d, struct kernel_info *kinfo, const struct dt_device_node *node) { + ASSERT_UNREACHABLE(); } static void __init assign_static_memory_11(struct domain *d, From patchwork Thu Jan 27 07:49:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726376 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 61316C433F5 for ; Thu, 27 Jan 2022 07:51:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261221.452092 (Exim 4.92) (envelope-from ) id 1nCzYd-0002Ca-FN; Thu, 27 Jan 2022 07:51:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261221.452092; Thu, 27 Jan 2022 07:51:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzYd-0002CP-9u; Thu, 27 Jan 2022 07:51:03 +0000 Received: by outflank-mailman (input) for mailman id 261221; Thu, 27 Jan 2022 07:51:01 +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 1nCzYb-0000Xj-DZ for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:51:01 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0621.outbound.protection.outlook.com [2a01:111:f400:fe0c::621]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ddff6367-7f45-11ec-8eb8-a37418f5ba1a; Thu, 27 Jan 2022 08:51:00 +0100 (CET) Received: from DB6PR0301CA0079.eurprd03.prod.outlook.com (2603:10a6:6:30::26) by DBAPR08MB5672.eurprd08.prod.outlook.com (2603:10a6:10:1ad::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 07:50:54 +0000 Received: from DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:30:cafe::68) by DB6PR0301CA0079.outlook.office365.com (2603:10a6:6:30::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:54 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT049.mail.protection.outlook.com (10.152.20.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:54 +0000 Received: ("Tessian outbound 341d209a0e52:v113"); Thu, 27 Jan 2022 07:50:54 +0000 Received: from 1d318a173880.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5EF2D08F-F751-4B8F-B3F8-AB26A3B854F7.1; Thu, 27 Jan 2022 07:50:47 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1d318a173880.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:50:47 +0000 Received: from AS9PR06CA0406.eurprd06.prod.outlook.com (2603:10a6:20b:461::16) by VI1PR08MB2973.eurprd08.prod.outlook.com (2603:10a6:803:4d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 27 Jan 2022 07:50:41 +0000 Received: from AM5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:461:cafe::cd) by AS9PR06CA0406.outlook.office365.com (2603:10a6:20b:461::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:41 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT012.mail.protection.outlook.com (10.152.16.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:41 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:40 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50:38 +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: ddff6367-7f45-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=92c4thxXtm2R15izEYnn+8igZY9iFkc7Fk+R9NtSz44=; b=ucYr5ThdxMW4w6n1FZ4ZNboL1NZNo5AjIZF8bbU/LaxyWETDTyy82/9sDgkIWezcjJdEujDHmxssAhlKOE0QytCK5n4aJMtu49hM3ugDG5v8NaVyswfC/JE/IM41zwX7t73swbfkDKK40ArwzvzCF7P3FGUgzBgyENTKkxfp2uc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: b91a6021e0fab8e2 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TPiwNwHhPVs8Xke09dN2hh1lZhyQ+O43EHePUjxJWpyfeG4xOpY8Zo2aeOWk1pU5LS17R6W6PhAMtpOeGWTWp0YsM5aJ7FjpHkDwY5dhPLqrB044A5pLBSlmacdUu/klMPW6FDCjMyYE4BX/icbUSyD5F5jHhQhxmA5Jpcv5FrBOCXx2MnIQXG+HyHG6wz4E+JU909T2iLZMK7fwYGFYtcIcQQgrmh5J46Q0uOk8mmPYjh3uQr0DeCvYas08qTLRbKNc6tpwXgLMDS/LXmrYN1e13PR/XaiREOtSD4dL7MakDJbAjKWkJ3hagicWzpJcceBKHnRIX9/Rj359fyn2ig== 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=92c4thxXtm2R15izEYnn+8igZY9iFkc7Fk+R9NtSz44=; b=NH4gKpne+VjEh/RCto+oQ38bGOodF7cCLiDvzccDRF1EVVCe5HEcCnAWHOuvW2+78x/xDGFcSJsQo3pL8bTFjIPuaKw6AgvRwxtuVcS03b20kuswRddTY6mZiaNdyT0aVniDEyTP3SeU8rWg20pACL1s4bLu/M9uxLsyuILs1dsC4jCd+xzOBHGWqAIBWmy16d1zk2/nQkQMi6RLXxA/XnaeoPohoxdp4BTQI/MR+EP9vrTIq4p3Y4AwtIYLNFTuS2QG3dIVqRp4yW5X/aLxktSnKaGOC6BN1p8sJ6hEa81D6rNVnrSK6CbDvAv+Rme9+5cAoXM4u4A6qQ9jpJM7Cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=92c4thxXtm2R15izEYnn+8igZY9iFkc7Fk+R9NtSz44=; b=ucYr5ThdxMW4w6n1FZ4ZNboL1NZNo5AjIZF8bbU/LaxyWETDTyy82/9sDgkIWezcjJdEujDHmxssAhlKOE0QytCK5n4aJMtu49hM3ugDG5v8NaVyswfC/JE/IM41zwX7t73swbfkDKK40ArwzvzCF7P3FGUgzBgyENTKkxfp2uc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 07/11] xen/arm: if direct-map domain use native addresses for GICv2 Date: Thu, 27 Jan 2022 07:49:25 +0000 Message-ID: <20220127074929.502885-8-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 0634c7f6-cb23-43d0-eac3-08d9e169bf18 X-MS-TrafficTypeDiagnostic: VI1PR08MB2973:EE_|DB5EUR03FT049:EE_|DBAPR08MB5672:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: bsTBQiZBPJw7Vh9hHaUPZGlr11VdhvUroyKLq1Ui8orAUT2XEUe6Z/nsEtbd7uGxvGWg5dzRAP6P3876Oy8FU1oDW9UP0D001g8SNYIr5hmDx3uHCWyPPUei8QcRAlDl2Qcj5J0vVzyq6QDx3aVFLIeZ7pJ8NTWyPTZTfbjTXQi5stBUz1V+hCWV/91UvvnodbRjYPB9MZT2EUmksixlVmunBXVhMpKvtWzkfCqUFIYN3ETk1mVaQ/ml3YIQxhZv716Ff0fO4CMoIKfaps53QkBj8tSQUEJUtT1EBPRwm8+cbZWwk3hHBVYzmwgdz8d0f6nWNNyVnCxo+KgabLA1m6ucgYiUVQui1FmpsOddnF3m0xdhG8LqBLGWoCO5gItGtCPi4ReLmjwjaU6anx9LLC0R3aSUOz+qEdWXrdN7rAqQgKllqnyhi55x6MmQFYoiMlmoeFWQuob5dSTllk82Khw4tSKn1E9hjKN1gOo0GXA+z6Vfr4KlE6YaWAA5BR3QAgX6093BrR5uDmx6VObYUmYhCi08W91V+UsyjBNHKHahthHU2kVe4OUfH8l3xJBv7lBq3Arww++5DkIWyYJNJlwo1itvpGwv/dJClaRb5ddstEEoPq2MTGYjgOFFJuQZ7l3nTKjqBXbNAkQp+HjzC0W0FyhcxsHyUK7grYdS1sQBP7zU0XycMzf7+u/kd4cZMGZTl+RSmFZNFtIEVfrBmA== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(70206006)(70586007)(336012)(426003)(8676002)(8936002)(86362001)(4326008)(83380400001)(82310400004)(44832011)(5660300002)(356005)(47076005)(81166007)(54906003)(6666004)(36860700001)(2906002)(40460700003)(36756003)(110136005)(2616005)(508600001)(316002)(7696005)(186003)(26005)(1076003)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2973 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 9c634ab6-6b37-42a8-8455-08d9e169b74f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WRSJHTXCd0yr3GYIyqd4mnnjLTIe6rONgv5Yv1EPxNLZKGH2+fdJb/26XT54EzJ5Nund0nOV2tFRp4Yzm12kYUoAkSoCkfMoPxoEUT2Fptjx70ZNiTEnoG5w2DS5FC2O/e5oABh7qv/r/C6ZKSB8sRjFUFGFeW/olHhuiMLIJM/zmPnhazWmePOcuNRx/WCSSe5FS5YV6B6j+uDuBqWYrBlsFPhV31axQCOtUNzaJUlpcxUrRYKWjsriehMczW0x1Xy13fk14yYr1yKBMkJ3q2U+7xbBHv9xPdhLGFKtNNfhzcgXvts8XwH3D2w0gWWaicHaS3+mtte+3HzQdrPWXk//eRsn8EAizK4grrzv6UYQoyFZJ2ixNtZsAMFdnfcetIqXZhUTuWQeeGSeFGk+5WobWktAZIOG3wM+mi1gDZ4T0fxP/ec7F2YOAiofvwJ89UJF8cyQGumb2MbkuR8o26ZpLaBy6yVdLx5BSUvTIPpmBlShsiXCJIEMAzlG6mNhD4ofvpRxb5W/sTaq/qlL9LBr+WlciMKsKPjBpZ5ejwkdXaRGz2eJo5JKTFOAlPa2ty9PNcZDlgbABQxG8POYLHCDxq4NbolGztyF5rMZbTLp3Q0ZCjuuibJ9qB4p5u4kVmrXxmMA5sAOgcQJKKTEptXUJ6l1rB17oHH0wqPJ0Jf1EHT+MKR0RWibA12TaNs+ X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(70206006)(70586007)(110136005)(5660300002)(8936002)(8676002)(36756003)(44832011)(82310400004)(54906003)(2906002)(316002)(4326008)(81166007)(7696005)(40460700003)(2616005)(36860700001)(6666004)(47076005)(26005)(83380400001)(426003)(336012)(1076003)(508600001)(186003)(86362001)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:50:54.3532 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0634c7f6-cb23-43d0-eac3-08d9e169bf18 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5672 From: Stefano Stabellini Today we use native addresses to map the GICv2 for Dom0 and fixed addresses for DomUs. This patch changes the behavior so that native addresses are used for all domains that are direct-mapped. NEW VGIC has different naming schemes, like referring distributor base address as vgic_dist_base, other than the dbase. So this patch also introduces vgic_dist_base/vgic_cpu_base accessor to access correct distributor base address/cpu interface base address on varied scenarios, Signed-off-by: Stefano Stabellini Signed-off-by: Penny Zheng Tested-by: Stefano Stabellini Reviewed-by: Julien Grall --- v2 changes - combine all changes in patch 4-6 here --- v3 changes - refine comment message - add a comment explaining how the 38 was found of "char buf[38]" - simply map the CPU interface at the GPA vgic_v2_hw.cbase - remove a spurious change --- v4 changes: - refine comment to let it be a summary of the if/else if/else. --- v5 changes: - nothing changed --- xen/arch/arm/domain_build.c | 11 +++++++--- xen/arch/arm/include/asm/new_vgic.h | 10 +++++++++ xen/arch/arm/include/asm/vgic.h | 11 ++++++++++ xen/arch/arm/vgic-v2.c | 34 +++++++++++++++++++++++------ xen/arch/arm/vgic/vgic-v2.c | 34 +++++++++++++++++++++++------ 5 files changed, 83 insertions(+), 17 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 52f256de9c..87391adde6 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2273,8 +2273,13 @@ static int __init make_gicv2_domU_node(struct kernel_info *kinfo) int res = 0; __be32 reg[(GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS) * 2]; __be32 *cells; + const struct domain *d = kinfo->d; + /* Placeholder for interrupt-controller@ + a 64-bit number + \0 */ + char buf[38]; - res = fdt_begin_node(fdt, "interrupt-controller@"__stringify(GUEST_GICD_BASE)); + snprintf(buf, sizeof(buf), "interrupt-controller@%"PRIx64, + vgic_dist_base(&d->arch.vgic)); + res = fdt_begin_node(fdt, buf); if ( res ) return res; @@ -2296,9 +2301,9 @@ static int __init make_gicv2_domU_node(struct kernel_info *kinfo) cells = ®[0]; dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_CELLS, - GUEST_GICD_BASE, GUEST_GICD_SIZE); + vgic_dist_base(&d->arch.vgic), GUEST_GICD_SIZE); dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_CELLS, - GUEST_GICC_BASE, GUEST_GICC_SIZE); + vgic_cpu_base(&d->arch.vgic), GUEST_GICC_SIZE); res = fdt_property(fdt, "reg", reg, sizeof(reg)); if (res) diff --git a/xen/arch/arm/include/asm/new_vgic.h b/xen/arch/arm/include/asm/new_vgic.h index 97d622bff6..ab57fcd91d 100644 --- a/xen/arch/arm/include/asm/new_vgic.h +++ b/xen/arch/arm/include/asm/new_vgic.h @@ -186,6 +186,16 @@ struct vgic_cpu { uint32_t num_id_bits; }; +static inline paddr_t vgic_cpu_base(const struct vgic_dist *vgic) +{ + return vgic->vgic_cpu_base; +} + +static inline paddr_t vgic_dist_base(const struct vgic_dist *vgic) +{ + return vgic->vgic_dist_base; +} + #endif /* __ASM_ARM_NEW_VGIC_H */ /* diff --git a/xen/arch/arm/include/asm/vgic.h b/xen/arch/arm/include/asm/vgic.h index ade427a808..d2a9fc7d83 100644 --- a/xen/arch/arm/include/asm/vgic.h +++ b/xen/arch/arm/include/asm/vgic.h @@ -152,6 +152,7 @@ struct vgic_dist { struct pending_irq *pending_irqs; /* Base address for guest GIC */ paddr_t dbase; /* Distributor base address */ + paddr_t cbase; /* CPU interface base address */ #ifdef CONFIG_GICV3 /* GIC V3 addressing */ /* List of contiguous occupied by the redistributors */ @@ -271,6 +272,16 @@ static inline int REG_RANK_NR(int b, uint32_t n) enum gic_sgi_mode; +static inline paddr_t vgic_cpu_base(const struct vgic_dist *vgic) +{ + return vgic->cbase; +} + +static inline paddr_t vgic_dist_base(const struct vgic_dist *vgic) +{ + return vgic->dbase; +} + /* * Offset of GICD_ with its rank, for GICD_ size with * -bits-per-interrupt. diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c index 589c033eda..b1bd7a46ad 100644 --- a/xen/arch/arm/vgic-v2.c +++ b/xen/arch/arm/vgic-v2.c @@ -654,12 +654,16 @@ static int vgic_v2_vcpu_init(struct vcpu *v) static int vgic_v2_domain_init(struct domain *d) { int ret; - paddr_t cbase, csize; + paddr_t csize; paddr_t vbase; /* - * The hardware domain gets the hardware address. - * Guests get the virtual platform layout. + * The hardware domain and direct-mapped domain both get the hardware + * address. + * We have to handle them separately because the hwdom is re-using the + * same Device-Tree as the host (see more details below). + * + * Other domains get the virtual platform layout. */ if ( is_hardware_domain(d) ) { @@ -671,10 +675,26 @@ static int vgic_v2_domain_init(struct domain *d) * Note that we assume the size of the CPU interface is always * aligned to PAGE_SIZE. */ - cbase = vgic_v2_hw.cbase; + d->arch.vgic.cbase = vgic_v2_hw.cbase; csize = vgic_v2_hw.csize; vbase = vgic_v2_hw.vbase; } + else if ( is_domain_direct_mapped(d) ) + { + /* + * For all the direct-mapped domain other than the hardware domain, + * we only map a 8kB CPU interface but we make sure it is at a + * location occupied by the physical GIC in the host device tree. + * + * We need to add an offset to the virtual CPU interface base + * address when the GIC is aliased to get a 8kB contiguous + * region. + */ + d->arch.vgic.dbase = vgic_v2_hw.dbase; + d->arch.vgic.cbase = vgic_v2_hw.cbase; + csize = GUEST_GICC_SIZE; + vbase = vgic_v2_hw.vbase + vgic_v2_hw.aliased_offset; + } else { d->arch.vgic.dbase = GUEST_GICD_BASE; @@ -685,7 +705,7 @@ static int vgic_v2_domain_init(struct domain *d) * region. */ BUILD_BUG_ON(GUEST_GICC_SIZE != SZ_8K); - cbase = GUEST_GICC_BASE; + d->arch.vgic.cbase = GUEST_GICC_BASE; csize = GUEST_GICC_SIZE; vbase = vgic_v2_hw.vbase + vgic_v2_hw.aliased_offset; } @@ -694,8 +714,8 @@ static int vgic_v2_domain_init(struct domain *d) * Map the gic virtual cpu interface in the gic cpu interface * region of the guest. */ - ret = map_mmio_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE, - maddr_to_mfn(vbase)); + ret = map_mmio_regions(d, gaddr_to_gfn(d->arch.vgic.cbase), + csize / PAGE_SIZE, maddr_to_mfn(vbase)); if ( ret ) return ret; diff --git a/xen/arch/arm/vgic/vgic-v2.c b/xen/arch/arm/vgic/vgic-v2.c index b5ba4ace87..1a99d3a8b4 100644 --- a/xen/arch/arm/vgic/vgic-v2.c +++ b/xen/arch/arm/vgic/vgic-v2.c @@ -258,13 +258,17 @@ void vgic_v2_enable(struct vcpu *vcpu) int vgic_v2_map_resources(struct domain *d) { struct vgic_dist *dist = &d->arch.vgic; - paddr_t cbase, csize; + paddr_t csize; paddr_t vbase; int ret; /* - * The hardware domain gets the hardware address. - * Guests get the virtual platform layout. + * The hardware domain and direct-mapped domain both get the hardware + * address. + * We have to handle them separately because the hwdom is re-using the + * same Device-Tree as the host (see more details below). + * + * Other domains get the virtual platform layout. */ if ( is_hardware_domain(d) ) { @@ -276,10 +280,26 @@ int vgic_v2_map_resources(struct domain *d) * Note that we assume the size of the CPU interface is always * aligned to PAGE_SIZE. */ - cbase = gic_v2_hw_data.cbase; + d->arch.vgic.vgic_cpu_base = gic_v2_hw_data.cbase; csize = gic_v2_hw_data.csize; vbase = gic_v2_hw_data.vbase; } + else if ( is_domain_direct_mapped(d) ) + { + d->arch.vgic.vgic_dist_base = gic_v2_hw_data.dbase; + /* + * For all the direct-mapped domain other than the hardware domain, + * we only map a 8kB CPU interface but we make sure it is at a location + * occupied by the physical GIC in the host device tree. + * + * We need to add an offset to the virtual CPU interface base + * address when the GIC is aliased to get a 8kB contiguous + * region. + */ + d->arch.vgic.vgic_cpu_base = gic_v2_hw_data.cbase; + csize = GUEST_GICC_SIZE; + vbase = gic_v2_hw_data.vbase + gic_v2_hw_data.aliased_offset; + } else { d->arch.vgic.vgic_dist_base = GUEST_GICD_BASE; @@ -290,7 +310,7 @@ int vgic_v2_map_resources(struct domain *d) * region. */ BUILD_BUG_ON(GUEST_GICC_SIZE != SZ_8K); - cbase = GUEST_GICC_BASE; + d->arch.vgic.vgic_cpu_base = GUEST_GICC_BASE; csize = GUEST_GICC_SIZE; vbase = gic_v2_hw_data.vbase + gic_v2_hw_data.aliased_offset; } @@ -308,8 +328,8 @@ int vgic_v2_map_resources(struct domain *d) * Map the gic virtual cpu interface in the gic cpu interface * region of the guest. */ - ret = map_mmio_regions(d, gaddr_to_gfn(cbase), csize / PAGE_SIZE, - maddr_to_mfn(vbase)); + ret = map_mmio_regions(d, gaddr_to_gfn(d->arch.vgic.vgic_cpu_base), + csize / PAGE_SIZE, maddr_to_mfn(vbase)); if ( ret ) { gdprintk(XENLOG_ERR, "Unable to remap VGIC CPU to VCPU\n"); From patchwork Thu Jan 27 07:49:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726375 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 D527BC433F5 for ; Thu, 27 Jan 2022 07:51:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261220.452080 (Exim 4.92) (envelope-from ) id 1nCzYY-0001at-2R; Thu, 27 Jan 2022 07:50:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261220.452080; Thu, 27 Jan 2022 07:50: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 1nCzYX-0001aa-Um; Thu, 27 Jan 2022 07:50:57 +0000 Received: by outflank-mailman (input) for mailman id 261220; Thu, 27 Jan 2022 07:50: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 1nCzYW-0008Mi-Kd for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:50:56 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20619.outbound.protection.outlook.com [2a01:111:f400:7e1b::619]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id db55eb29-7f45-11ec-8f75-fffcc8bd4f1a; Thu, 27 Jan 2022 08:50:55 +0100 (CET) Received: from AS9PR04CA0081.eurprd04.prod.outlook.com (2603:10a6:20b:48b::22) by HE1PR0801MB1996.eurprd08.prod.outlook.com (2603:10a6:3:54::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Thu, 27 Jan 2022 07:50:52 +0000 Received: from VE1EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:48b:cafe::b9) by AS9PR04CA0081.outlook.office365.com (2603:10a6:20b:48b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:50:52 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT063.mail.protection.outlook.com (10.152.18.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:51 +0000 Received: ("Tessian outbound 1f399c739551:v113"); Thu, 27 Jan 2022 07:50:51 +0000 Received: from 0a577f82bb16.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A4A52311-87C7-434D-8891-B9A20B23E059.1; Thu, 27 Jan 2022 07:50:44 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0a577f82bb16.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:50:44 +0000 Received: from AS9PR06CA0182.eurprd06.prod.outlook.com (2603:10a6:20b:45d::16) by DB9PR08MB6992.eurprd08.prod.outlook.com (2603:10a6:10:2c6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 07:50:43 +0000 Received: from AM5EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45d:cafe::d) by AS9PR06CA0182.outlook.office365.com (2603:10a6:20b:45d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:43 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT046.mail.protection.outlook.com (10.152.16.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:43 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:42 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50:41 +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: db55eb29-7f45-11ec-8f75-fffcc8bd4f1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zv99J/JvMfg/PNJtCHZ3IadhuqFRQ7hXXDxbc+rSdBs=; b=9iJxpoh4krPejyXqyHN8wXFT/M7Qlr39a2d3YbAriYnXCLY0rRRe1NH5nt3l/EhNSoGEOVEISKzPpH29hw94AYhBc/SvXs/Xp5sweEmmofNnG0hz6KSNL2F0EmeCoZTNLZ7fiXg+sfd+OT4wxwl3hjJbm5JXwzCoETwyOREX1Xg= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: a7f6b200aa6f18af X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j9eh1KFLRb3HJnzrr9pdBLVV9UbQ6HPV+76bKjsozv/0h59frKPiI/pGaX43UBAOx/rTkV/gZB8N0yZdk2aArCmUr0zcmjANX2jHAKwU63siM3hK7AHztw3KxlecZEdYfZ5fGxTPi0aereWYg0qeV8sDgWl95XZkl/6ovjBHvVCLdHv1K7gkq73Lq2M5qhIzpr3k5fmD0Y0/SIMD92KA/docukzo/gRhJAtX8mLcSEfCjPtO4DTLM2+ZR0rQqUmbHXecouQWC0yWjJ7+wVMJq7OW6gHK8dKUFggwdxARZgXsNewRlM3HB7N2pJXocsfosdJDgq1PdA9Exhmilc112A== 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=Zv99J/JvMfg/PNJtCHZ3IadhuqFRQ7hXXDxbc+rSdBs=; b=l2gSdUVV2vQ4fKKlAjveKMOuUdWQ/AGIRS0sjWUzfgZ90MdYamv/CsbG3VD7o86iUV6+3LpBlQmCvu5OFDNVhxVY/d0mBTt7rVdTSBhvl+0ZVO9rGjDzV8ZMqiU9tNPajh0X4wcWOtGXhG3VAdsvreSp3TAPPpHfssI0HDpj3E2y763Mr9iKUYglPMyZVecI3lC0YbB1rnHtLIBvNsG0kTq0RPQwj6XrMwZTc672ELjeTk/ikeRjiRBkMuVRL6WDpesCfqNDLe2NzQvjz+t0kXUcarxqceDMM0H5gC20BqQVNa7udXi9I+NVrPYYOEHE99NuU+XJeyYG64l1A8eIRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zv99J/JvMfg/PNJtCHZ3IadhuqFRQ7hXXDxbc+rSdBs=; b=9iJxpoh4krPejyXqyHN8wXFT/M7Qlr39a2d3YbAriYnXCLY0rRRe1NH5nt3l/EhNSoGEOVEISKzPpH29hw94AYhBc/SvXs/Xp5sweEmmofNnG0hz6KSNL2F0EmeCoZTNLZ7fiXg+sfd+OT4wxwl3hjJbm5JXwzCoETwyOREX1Xg= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 08/11] xen/arm: gate make_gicv3_domU_node with CONFIG_GICV3 Date: Thu, 27 Jan 2022 07:49:26 +0000 Message-ID: <20220127074929.502885-9-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 1a472994-30e0-4646-67ee-08d9e169bdab X-MS-TrafficTypeDiagnostic: DB9PR08MB6992:EE_|VE1EUR03FT063:EE_|HE1PR0801MB1996:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:78;OLM:78; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: +gx5fE4vfaU+A55P9QNH16RXL1nfd07hbO1NJ1P2HOYZ0nQ4XqAY7ICb3iituL2i7Vgnd4MB2Yh74B/zDfCOZRNBPj7mhx5hDv0e12AGCpfbhxS1VxTfjVJXJnS/Yoqv23jkD5l9ZK25RC+IxNfZOJutxuSjcYZ6BBtIUaaHFYyFz035PwsrIjz8Vz3fHlQuNV41eL7EKyx88a7z5eT/Yhqkpdlk4mrgV0U8ODg+6O4DH4atogD0iKorAK9xohEPKgVLmLkaJWn1tbsx3UCDDw9u8rhVBZi/JZpkrHmCtL2K+BhMlm3crEDyE+mxzaS61Pa3EGICsmmyG1pNQD0pe/c4kxGza2OXp9VnaJZcNFoP2twMXaeE5zf3wvcZeMTTdMWMQW25azRnoVD1lro4XyIecVRqfDj5jPTNICz6r/HGU1hr0N1qOsIJ5u/fDpSEqDUMHRsLkaPn10jUV04GkhFyYE3vgBuDT/POuvALniO7JToCub71LzJyR8nSdT+9Fh/ADcV0IMYFI21TDzkrKVrp9pdKeMItdZBDTiTDEW8SbuKB3tnALo1F2j5epp6hmrWqiCl/iW9M/AOZ+Dd+yBTWyJcmznMXUoNl3yNTtbhicnuu0BYjguCKERKGu6J8Wr3AeWcEF3SB8OfcdXarTKq3Q8xI4SEVpkDpu7f2sPvrWn6eWPU8cvY0gtdGB8UsB12WLYEb/u2MCIU+/5MC0w== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(40460700003)(2906002)(336012)(186003)(2616005)(1076003)(7696005)(6666004)(26005)(426003)(81166007)(82310400004)(36860700001)(44832011)(47076005)(5660300002)(508600001)(70586007)(70206006)(36756003)(8936002)(110136005)(54906003)(8676002)(4326008)(86362001)(316002)(356005)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6992 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 45e28c0e-e5a6-420d-0a54-08d9e169b8a8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JAGHGmMPZnl10LLid3q7UvBHjpfwko4HiHNbuO33Xm4rlS0eWl/V+dN9Uk8E78K0gBznQT/ZujQF+GSIyXPY31XImhAYI1hWFxg70FxCeopEvDB9hLxhA7UkIJ6oxp6/4Cd1XaMrjKW0QGtV4nVEJATd4Lo0GIsuQ8Ps4Zi6I7EBF6aLrU+d4tCFv6rUYh9fcDSfHjZn/7zB5jWXVUtwYylafdvBPiS8TTffzGXBtcaAJiIzYsbK/G//Ta+VRZr+ZCp7HvqMg2wNoM5F4XhB+t2W6qcM9I9TCOSAVMlc7R8b33IrPdzgHfrnDf+EB3wMtBDSzNDpwtqzFW13Ui+24iAJueh+qjtHh61i8BHdruo3H53HFazs372VMH/I/DfD+0izt907Fc2Vtiov+rlh4n7YLFJWDOh63YcbYS35SyPZBInWHnE7Xt5XXaKmms/8qp4LB5BOfxmTuFEEA+yva/jSossTnTEJGRaBhuYpcAtHACdU/kru8RIee7oFNRTOmOG9rA2z+H6psztJwhO0gBSxmpM7iJTI5D9yL4u+TkKwww279qtCFrhPQ0G7/RnVbXOUnCK+dvyy/uEGTOnEnTY35kBpmdh712qlJbPiKIqp9h/inAIHa3A03nFlJ7iL2ThWMTu2RqPj7354Pha2e5k+G41Dw8tpSv/8jwnBnB5r5teyzAqZePdbkgVWtTjk8VBFxgzYeSDaElzePmcH8Og+oCrS8iX+2b9dwcGJanFw89akxi5bEmoliz1It6N8/3IBS/1B430SQ8DXVAacYg== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(40470700004)(186003)(336012)(86362001)(26005)(82310400004)(2616005)(36756003)(70586007)(36860700001)(6666004)(8936002)(5660300002)(1076003)(81166007)(44832011)(316002)(426003)(8676002)(2906002)(47076005)(54906003)(70206006)(7696005)(40460700003)(4326008)(508600001)(110136005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:50:51.8484 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a472994-30e0-4646-67ee-08d9e169bdab X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1996 This commit gates function make_gicv3_domU_node with CONFIG_GICV3. Signed-off-by: Penny Zheng Acked-by: Stefano Stabellini Tested-by: Stefano Stabellini --- v4 changes: - remove ASSERT_UNREACHABLE() to avoid breaking compilation on prod build with CONFIG_GICV3=n --- v5 changes: - nothing changed --- xen/arch/arm/domain_build.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 87391adde6..a01dc60b55 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2322,6 +2322,7 @@ static int __init make_gicv2_domU_node(struct kernel_info *kinfo) return res; } +#ifdef CONFIG_GICV3 static int __init make_gicv3_domU_node(struct kernel_info *kinfo) { void *fdt = kinfo->fdt; @@ -2371,13 +2372,16 @@ static int __init make_gicv3_domU_node(struct kernel_info *kinfo) return res; } +#endif static int __init make_gic_domU_node(struct kernel_info *kinfo) { switch ( kinfo->d->arch.vgic.version ) { +#ifdef CONFIG_GICV3 case GIC_V3: return make_gicv3_domU_node(kinfo); +#endif case GIC_V2: return make_gicv2_domU_node(kinfo); default: From patchwork Thu Jan 27 07:49:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726380 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 94EFBC433EF for ; Thu, 27 Jan 2022 07:57:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261246.452147 (Exim 4.92) (envelope-from ) id 1nCzea-0006dD-Bo; Thu, 27 Jan 2022 07:57:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261246.452147; Thu, 27 Jan 2022 07:57:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzea-0006cy-8f; Thu, 27 Jan 2022 07:57:12 +0000 Received: by outflank-mailman (input) for mailman id 261246; Thu, 27 Jan 2022 07:57:11 +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 1nCzYn-0000Xj-Qx for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:51:14 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03on0602.outbound.protection.outlook.com [2a01:111:f400:fe0a::602]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e3f6d853-7f45-11ec-8eb8-a37418f5ba1a; Thu, 27 Jan 2022 08:51:10 +0100 (CET) Received: from DB8PR06CA0031.eurprd06.prod.outlook.com (2603:10a6:10:100::44) by PA4PR08MB6270.eurprd08.prod.outlook.com (2603:10a6:102:f3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Thu, 27 Jan 2022 07:51:07 +0000 Received: from DB5EUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:100:cafe::1a) by DB8PR06CA0031.outlook.office365.com (2603:10a6:10:100::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:51:07 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT045.mail.protection.outlook.com (10.152.21.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:51:07 +0000 Received: ("Tessian outbound 31aeb3346a45:v113"); Thu, 27 Jan 2022 07:51:07 +0000 Received: from 128d14ed8f60.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E1D87FAF-AB90-492D-BF3E-CC1231DCDE9F.1; Thu, 27 Jan 2022 07:51:01 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 128d14ed8f60.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:51:01 +0000 Received: from DB6PR0301CA0059.eurprd03.prod.outlook.com (2603:10a6:4:54::27) by VI1PR0802MB2222.eurprd08.prod.outlook.com (2603:10a6:800:9b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.13; Thu, 27 Jan 2022 07:50:59 +0000 Received: from DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::a1) by DB6PR0301CA0059.outlook.office365.com (2603:10a6:4:54::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:50:59 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT037.mail.protection.outlook.com (10.152.20.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:59 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:45 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:44 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50:43 +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: e3f6d853-7f45-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4yHBHWg0SsFunO7nPJhF8c2G7ELWbJA5oRhqIflaUA8=; b=d5P/qfrM/9H0c1aCeiyKnXDQLD/pMPtQh6bW+sCnHutFJxAlUvHA0Sr6zIu2dWM/E9C1zjyptQZrM4cUlMfXu/qzCuJT/ftV3P1ElTTJIaRYlG+2B2BWn+SHorAQsz/CTt3OWClQ2uIxCmM3CIrwyUkcMLivpS4qj5O7rC6aAtw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 39d3dce02635785d X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h3sCeeX6iDBJI6JRgzm49UHKoypHB5xNFA5ArlfzerTNTbZGONzdjCjEbTe3kXju9T/7m8KUwn5dlpRYUgyIEDioR0QKQ2swJarc1FqXP7C7wyUekryhaGCzH89pymnTLdtqjw4dqw8cvOG4yeSfTgWibUXSuWCieqSbk3IU9uUncXUq1J+ll+4RInDlBzMKq75MGwz6D11gsNeUfs0kBvTluTFsdY16Bzva2izk8LtJuPJo4yu1GBOwe1abBG+SSnj7baS2rrOcrlufWFs8E30nx22Vdz4xtUGL+uweGnvYsOXePWIXklJXctN4tFJX61rH23xQ1bUiGE2miAw/sA== 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=4yHBHWg0SsFunO7nPJhF8c2G7ELWbJA5oRhqIflaUA8=; b=O9L7xqK44URBEBrI7W0Qde/MUSjgpziODkLAg//bEwR7V1OtUt+SMsX7a+HQPa/bgh5y/FHNBA7A+2QxVmAeXLDP+wnyjXr58ngc1ZJYXdaHCtWOmZ/mDtEOmz9e5WOZew7mJtS+mhAkmRoM5D23tF4O/Ut0vZmijQHncAnHkN3gdcyJ/b+M3HmaiTDLdflyqbzCp49kAcaSAxKujazbNQQc2aztkoAvJ96t2oc/8B5ipY2EVK8UMbMxIWDhba8GgaP0k9SSA8HZNdDy4VtsY4pC8AjDUET5ycweI8Nnze5NeEwWEeDmUQuwq5fvZfGGNYEd5OIcyNWrMXZRulHHWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4yHBHWg0SsFunO7nPJhF8c2G7ELWbJA5oRhqIflaUA8=; b=d5P/qfrM/9H0c1aCeiyKnXDQLD/pMPtQh6bW+sCnHutFJxAlUvHA0Sr6zIu2dWM/E9C1zjyptQZrM4cUlMfXu/qzCuJT/ftV3P1ElTTJIaRYlG+2B2BWn+SHorAQsz/CTt3OWClQ2uIxCmM3CIrwyUkcMLivpS4qj5O7rC6aAtw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 09/11] xen/arm: if direct-map domain use native addresses for GICv3 Date: Thu, 27 Jan 2022 07:49:27 +0000 Message-ID: <20220127074929.502885-10-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: efed1adb-c521-4815-ef8f-08d9e169c718 X-MS-TrafficTypeDiagnostic: VI1PR0802MB2222:EE_|DB5EUR03FT045:EE_|PA4PR08MB6270:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6430;OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: UHSm05SWqe5cZnsxOYaicIDqe7MbFoVXxlJMaDxOtW2CGj8ZVv7oT5WsjJgKKKAZbLTb1a4MOKOchBJtQXXpHjSxZnqKt+tMpo0Q+0Gu6nlAoARIxwm1nLwnekXbqlQdWKmqkSYjUw7IHmNfmdStgffWuMa0at3ur557V9W6Tk3s/928PvAG5ttz5kxkJQn03gnPm+HWoKnUXWYN6IWv9dkZbzDFCIAhhEbQ6Xmhp8AFYc8Zvwny0REdIw5MI6fZQ+6DXWfNbv1gzVksAuvJhg0eP/cYqqAKOQ37FCcRzPdsq1E6vVvvw9KZRch5eIj0XxXJmsPd1vAsLeUsFTT+uAEjY4DOFNM/IiQZ72//zTpJLQFMWhuKOmv4Gx3SB/xc9Aic9WAEKNXvKVb6pbD+AydvPJtfl48qUP7Ory3fHAjVoXzWwTuohYRZQB5kDXoiYu0bZG2W2qKi6kNCCSEJy722PFBQozbl4MjgbggkAC2XqjkoCmG/UPFMeJnDUnfR8PyyrivNJOuTjgPP3t+vF42A+W5T17HDA6OWfky3DLKMseyVMSVK213TqIbF0f0mh4IWWFR/LdZlxD4sb0D+XK3vbfbQVw9V65PpGn8pH1zXfc6B/cGBNUDQVQz10YuirMqWgmagFlvbv+UIvx0YHW7fGWW5BGmqLUOc0g9/7QDzPhGo8LnrRgpLkBjBFbsAACnGAeDbWH6botCS36AKsnEWzdWRZ6xT2NYQBp33WAP9xMzuAY7umVzsCH+d2sg/gDWyvRMr7L/zZeY6BWugeUsI2ZnJLwDuJATJGPsuoqQ= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(46966006)(40470700004)(36840700001)(5660300002)(70206006)(110136005)(336012)(47076005)(26005)(2906002)(36860700001)(356005)(8676002)(8936002)(186003)(44832011)(54906003)(316002)(70586007)(81166007)(82310400004)(86362001)(1076003)(6666004)(83380400001)(508600001)(426003)(7696005)(36756003)(2616005)(4326008)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2222 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d8d1dfc7-06d6-469d-64da-08d9e169c215 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LiusU4IMJP+U82I2H6B9Gz7naw78BbZem8nVuLktRFMH7Izd/lU+Tbx0HiEsobwwjMpivPUBBKJvWBVBfEjwWBS7ZrSQg4B+ht5IZhej+WfHR9wjciVHp6YoVyhDwKO2C4439w4tmLr4o/9n1WyUpjTuyYfhplcII0MlFdNfHnp0x8uaLHcva5CpBCwgph4niiUwDVWn3TVrCj9S2ZL3TdOwbID22ZOygc+b7x1wu9jnFGt6K/BasI7pwHI15YW1M7w22dndCqBhCNxw7EuONrYrjlhJEnl8vM07hBG3gLjt7VvnWhPWTkD5CB4Gxh2owsGZNfP3m2gvri8XsF2wYq7U3S8EXDnRdIyiTCEsxQX0+D10/OCpsj2lIYJPYiYG2UeyvbgRZoyf8zS+4uozWiP4MVSMRbsHqjr5IJgGzYXTynD6p5FfMnDqLVe1UV/mbPdNR4GpjX/iPeppLOAeFy7RrUMbjISOmtpDQTvTBF1cV52CSc4ov8l9RJljDqz9/orOAQnpVo3UG1ACKv393qOTBfR/N7lpD14Zf+RcRQTQ3V7wZMFTzoUrPhkNcEp5lmViXqmAo6VgegOU+NuMveR9FbmGz7PtkbpL0h3sM6UVwpWMdOfDvxI0YxTWpQOKbsxPtzOII0opigmSle1lgzA+d9o+7C1hESTsQgKi0WLaSKpqy2dgO89zyTor94Oc699lsi7SPEESpTwTYX4l6ehuAutxSlBALDM6d2TOzSMeSntmXpbyHKvBitIKgOue4Y7IxFbDY13yeQOLUBC5hQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(40470700004)(81166007)(44832011)(70586007)(36756003)(70206006)(2616005)(40460700003)(8936002)(4326008)(83380400001)(186003)(5660300002)(426003)(82310400004)(26005)(1076003)(336012)(8676002)(316002)(6666004)(110136005)(86362001)(54906003)(508600001)(7696005)(47076005)(2906002)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:51:07.7595 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: efed1adb-c521-4815-ef8f-08d9e169c718 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6270 From: Stefano Stabellini Today we use native addresses to map the GICv3 for Dom0 and fixed addresses for DomUs. This patch changes the behavior so that native addresses are used for all domain which is using the host memory layout Considering that DOM0 may not always be directly mapped in the future, this patch introduces a new helper "domain_use_host_layout()" that wraps both two check "is_domain_direct_mapped(d) || is_hardware_domain(d)" for more flexible usage. Signed-off-by: Stefano Stabellini Signed-off-by: Penny Zheng Tested-by: Stefano Stabellini Reviewed-by: Julien Grall --- v2 changes: - remove redistributor accessor - introduce new helper "is_domain_use_host_layout()" - comment fix --- v3 changes: - the comment on top of 'buf' to explain how 38 was found - fix res getting overwritten - drop 'cells += (GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS)' - free 'reg' right way - fix comment - rename 'is_domain_use_host_layout()' to 'domain_use_host_layout()' --- v4 changes: - refine comment --- v5 changes: - nothing changed --- xen/arch/arm/domain_build.c | 34 +++++++++++++++++++++++-------- xen/arch/arm/include/asm/domain.h | 14 +++++++++++++ xen/arch/arm/vgic-v3.c | 26 ++++++++++++----------- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index a01dc60b55..cff2cb93cc 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2327,10 +2327,16 @@ static int __init make_gicv3_domU_node(struct kernel_info *kinfo) { void *fdt = kinfo->fdt; int res = 0; - __be32 reg[(GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS) * 2]; - __be32 *cells; + __be32 *reg, *cells; + const struct domain *d = kinfo->d; + /* Placeholder for interrupt-controller@ + a 64-bit number + \0 */ + char buf[38]; + unsigned int i, len = 0; + + snprintf(buf, sizeof(buf), "interrupt-controller@%"PRIx64, + vgic_dist_base(&d->arch.vgic)); - res = fdt_begin_node(fdt, "interrupt-controller@"__stringify(GUEST_GICV3_GICD_BASE)); + res = fdt_begin_node(fdt, buf); if ( res ) return res; @@ -2350,13 +2356,25 @@ static int __init make_gicv3_domU_node(struct kernel_info *kinfo) if ( res ) return res; - cells = ®[0]; - dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_CELLS, - GUEST_GICV3_GICD_BASE, GUEST_GICV3_GICD_SIZE); + /* reg specifies all re-distributors and Distributor. */ + len = (GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS) * + (d->arch.vgic.nr_regions + 1) * sizeof(__be32); + reg = xmalloc_bytes(len); + if ( reg == NULL ) + return -ENOMEM; + cells = reg; + dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_CELLS, - GUEST_GICV3_GICR0_BASE, GUEST_GICV3_GICR0_SIZE); + vgic_dist_base(&d->arch.vgic), GUEST_GICV3_GICD_SIZE); - res = fdt_property(fdt, "reg", reg, sizeof(reg)); + for ( i = 0; i < d->arch.vgic.nr_regions; i++ ) + dt_child_set_range(&cells, + GUEST_ROOT_ADDRESS_CELLS, GUEST_ROOT_SIZE_CELLS, + d->arch.vgic.rdist_regions[i].base, + d->arch.vgic.rdist_regions[i].size); + + res = fdt_property(fdt, "reg", reg, len); + xfree(reg); if (res) return res; diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h index cb37ce89ec..848fec8a0f 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -31,6 +31,20 @@ enum domain_type { #define is_domain_direct_mapped(d) (d->arch.directmap) +/* + * Is the domain using the host memory layout? + * + * Direct-mapped domain will always have the RAM mapped with GFN == MFN. + * To avoid any trouble finding space, it is easier to force using the + * host memory layout. + * + * The hardware domain will use the host layout regardless of + * direct-mapped because some OS may rely on a specific address ranges + * for the devices. + */ +#define domain_use_host_layout(d) (is_domain_direct_mapped(d) || \ + is_hardware_domain(d)) + struct vtimer { struct vcpu *v; int irq; diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c index 65bb7991a6..144089a7b6 100644 --- a/xen/arch/arm/vgic-v3.c +++ b/xen/arch/arm/vgic-v3.c @@ -1640,14 +1640,15 @@ static inline unsigned int vgic_v3_max_rdist_count(struct domain *d) * Normally there is only one GICv3 redistributor region. * The GICv3 DT binding provisions for multiple regions, since there are * platforms out there which need those (multi-socket systems). - * For Dom0 we have to live with the MMIO layout the hardware provides, - * so we have to copy the multiple regions - as the first region may not - * provide enough space to hold all redistributors we need. + * For domain using the host memory layout, we have to live with the MMIO + * layout the hardware provides, so we have to copy the multiple regions + * - as the first region may not provide enough space to hold all + * redistributors we need. * However DomU get a constructed memory map, so we can go with * the architected single redistributor region. */ - return is_hardware_domain(d) ? vgic_v3_hw.nr_rdist_regions : - GUEST_GICV3_RDIST_REGIONS; + return domain_use_host_layout(d) ? vgic_v3_hw.nr_rdist_regions : + GUEST_GICV3_RDIST_REGIONS; } static int vgic_v3_domain_init(struct domain *d) @@ -1669,10 +1670,11 @@ static int vgic_v3_domain_init(struct domain *d) radix_tree_init(&d->arch.vgic.pend_lpi_tree); /* - * Domain 0 gets the hardware address. - * Guests get the virtual platform layout. + * For domain using the host memory layout, it gets the hardware + * address. + * Other domains get the virtual platform layout. */ - if ( is_hardware_domain(d) ) + if ( domain_use_host_layout(d) ) { unsigned int first_cpu = 0; @@ -1695,10 +1697,10 @@ static int vgic_v3_domain_init(struct domain *d) } /* - * The hardware domain may not use all the re-distributors - * regions (e.g when the number of vCPUs does not match the - * number of pCPUs). Update the number of regions to avoid - * exposing unused region as they will not get emulated. + * For domain using the host memory layout, it may not use all + * the re-distributors regions (e.g when the number of vCPUs does + * not match the number of pCPUs). Update the number of regions to + * avoid exposing unused region as they will not get emulated. */ d->arch.vgic.nr_regions = i + 1; From patchwork Thu Jan 27 07:49:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726377 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 65ED3C433EF for ; Thu, 27 Jan 2022 07:51:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261222.452103 (Exim 4.92) (envelope-from ) id 1nCzYf-0002W7-3w; Thu, 27 Jan 2022 07:51:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261222.452103; Thu, 27 Jan 2022 07:51:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzYe-0002Vd-Se; Thu, 27 Jan 2022 07:51:04 +0000 Received: by outflank-mailman (input) for mailman id 261222; Thu, 27 Jan 2022 07:51:03 +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 1nCzYd-0000Xj-6Y for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:51:03 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2060c.outbound.protection.outlook.com [2a01:111:f400:7e1b::60c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id df22b873-7f45-11ec-8eb8-a37418f5ba1a; Thu, 27 Jan 2022 08:51:02 +0100 (CET) Received: from AS9PR04CA0039.eurprd04.prod.outlook.com (2603:10a6:20b:46a::33) by VI1PR08MB3693.eurprd08.prod.outlook.com (2603:10a6:803:ba::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 07:50:57 +0000 Received: from AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46a:cafe::9e) by AS9PR04CA0039.outlook.office365.com (2603:10a6:20b:46a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:50:57 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT023.mail.protection.outlook.com (10.152.16.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:57 +0000 Received: ("Tessian outbound 341d209a0e52:v113"); Thu, 27 Jan 2022 07:50:57 +0000 Received: from 64383953ffce.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AE18489E-133D-4068-9C1D-E88C7A94542E.1; Thu, 27 Jan 2022 07:50:50 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 64383953ffce.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:50:50 +0000 Received: from AS9PR06CA0022.eurprd06.prod.outlook.com (2603:10a6:20b:462::14) by AM0PR08MB5284.eurprd08.prod.outlook.com (2603:10a6:208:12a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 27 Jan 2022 07:50:49 +0000 Received: from AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:462:cafe::4a) by AS9PR06CA0022.outlook.office365.com (2603:10a6:20b:462::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:49 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT018.mail.protection.outlook.com (10.152.16.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:49 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:47 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50:45 +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: df22b873-7f45-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k8CtSJ23GsJakIevRnNKBt0vBQ8CUngOOT5AcDXX548=; b=MUWYoiRlmLlGeKcBomXuCxRIRI0rJ9n1X8NHwTEFB5uo6gMXOBk2wctW/JB1MPitV3ru8dhKhQtv+bcrv9VYPzER2FZPoaeLhQHdQiA7pppRE709Kgq1iOydI0UkEl/H6mYx5z6TpxsQYoGiFEROCftXZM9uTtJjemN0Zptgrgg= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 3a3dd52fa7e5f5e0 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KtlDUKZCSdazox97n0JYFSKN8IDFf9Rw6Ds8BBHbwG6JoXrsP6KS1SQ8rPVnV+EJHgirz3tEr7vZCkbXIuQFZ8RHYItknTns3/KK21xRV9NofofQGDAUhUbveRdjy8iaIhyJQ/Ab2Q9hU3COXV8GfoSG7IA2yy6Uczajagt0nCEZs7j0DII+oS7dM1CawzsweotiWwrvOEW9/MM0CHl9f6RnNLBUOd4KfLkI2+9xC8Xa4jAkpVUZuqMdyEXXFFeGWeKDvEXB6QzSUmDF1YkbXajwJryL/OHBePNPTW8R7e4s+ranuuRYq3S2N6JiVvzXKnj5CyjjbmEojwgWAfNtcA== 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=k8CtSJ23GsJakIevRnNKBt0vBQ8CUngOOT5AcDXX548=; b=f0icKa2Et5sF6boMTWRyKWqdExipo2uW6PX/GEwpNii3bpOCEF+DBFKsYrBhUELooRc5osHjQTB8A6G4z0KcQjaqd8OGXXe6VUMPGeN8pFIkc88Dt6MfVnPhakiLQ9/ziSAkG5NVXjqCCndOeEjpBZ/GUa6UOcctLDr+7VKOsLScT1Sy216eaOAjDosx4kUXXm1aTv9weFi3RAGQOD+UevA75oe8XPJ1lbCZBDrBKX2/SdplHLF9hPvlmmehf0ZY4eNfiZn0fDqbUpDiJyEq7wIxNf34PnZKC8U0nwLJ5495yQrC6mAtRB1kpHJBAD6FfSU0TThl0N+P4BfkRj8yOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k8CtSJ23GsJakIevRnNKBt0vBQ8CUngOOT5AcDXX548=; b=MUWYoiRlmLlGeKcBomXuCxRIRI0rJ9n1X8NHwTEFB5uo6gMXOBk2wctW/JB1MPitV3ru8dhKhQtv+bcrv9VYPzER2FZPoaeLhQHdQiA7pppRE709Kgq1iOydI0UkEl/H6mYx5z6TpxsQYoGiFEROCftXZM9uTtJjemN0Zptgrgg= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 10/11] xen/arm: if direct-map domain use native UART address and IRQ number for vPL011 Date: Thu, 27 Jan 2022 07:49:28 +0000 Message-ID: <20220127074929.502885-11-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: daccd649-5a00-4051-036a-08d9e169c108 X-MS-TrafficTypeDiagnostic: AM0PR08MB5284:EE_|AM5EUR03FT023:EE_|VI1PR08MB3693:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ini/MalvR427+EcTDQvf8NVgUWbWdQqp6aiadtzQRcuTIf1pIaLU2vhoOHNMHb74f1UDbcTt7/0W3KFWk1apnhrNhLq6F6cJ2w6qcJW8bBtuut4dEP8HhEup6fTf7i9zbsTQ90sZgGd6aEWVGjGn3C5SST4NMCFXKChOfLrTueSvGPXhykliM2aXBJmYYcfGRA+P8u030oKbONVX/+WCRS7BbOuka4Lsv8mwERkISBcvqIW/RPAwT2yojPzZMqWoaT/nWPWI4jyvPEWZ9Fl/9A4t5nInJHK3itSJGXt1eOQaYrTojIjl9MnPZCwSTylQKEHpIMYg4EztK2rBuyRLVSUmx86hA4MiGRTf3kPCkoPzJHsUbpT9f+nxO8vurYQsmrE8+HHZNgqeYncuc/EhUunALsOD7casEsIeQLHj293xJZAIT6NVWTH/hcgzhpqj/jzI6RcOU+l5wwXzqVdUWA9kdK5V/Kylb4HaxSJ2yDUeHdb/PtC3ijYBOdmGYmD4pecDFXSYEkSfhgTZI5nvt76X29pJmXS610SnW7Wt3NbXwpmQNOyCCWYA45i7GmsM6rAVNk+PlDuoCewjIUNS7PAEd3SzOAiFyZJHxiaa0PYUX/+u+DxBktWYghqh3/c0iakfVjYqgdEt/NDFfwDUX32TyyKOeXw7t9QdF7BcHkHxXbDmhCEgRTdvrPM3vr43+DUbj6fJuzeWicSS9lUdhg== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(36756003)(6666004)(70586007)(70206006)(426003)(336012)(8676002)(8936002)(5660300002)(4326008)(7696005)(508600001)(86362001)(316002)(54906003)(40460700003)(110136005)(356005)(44832011)(2906002)(81166007)(2616005)(1076003)(26005)(186003)(47076005)(82310400004)(36860700001)(83380400001)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5284 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0aaa8d1c-3a95-47ca-4149-08d9e169bc1b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QzCHNVuQV6uzGxJSnVf2wn6H2kqcsiYMLgiaqW/P7xdyV25D5hcGK2TKgaW4zyJ3djgo4fO7RoQryCF76BKLhG4JZzkhLmDqEmPUOO3NVUfmqH5lXsJuW4EBbifhFZBSJfAeKJ1m2e/JPVcuB+UJuVOuPlca/0Jwvugw6SuH3P+40H/LFYT1kGCJ4U2kswVHyt9ny7EZumT1Xs2PfnGXG7BUwlXhnrpcEkI2KjpitvzyTf8A1oQ+PMxcyPR1NaoAi11cgdeGqlLbZsDtCg6xqMUJe7OEC1pziseXf7VVG8SOECKZ2qyes5OPfv0bbi0wlwNL0ySDlGA2uSHt5oe16luFBUpl1TzyLbO8bGbraFOWmNdk7RHMbjtgZ4kicb/gWzC03je4smBrjKoJpfDBzeSXkUmFBODujAW1OE/AA8c1N59HFokW1DjElG6unBqZUP8haWoT2Zb2NSHFsaCtqWSDzTH1YBHw3oE7d1X/jtpuQWB7EAP1mDgsw53/zl19AHYVejVSPY2wRd+SyduxEUioLD7RcoCNBdw8bPMgNQkFnrHmyRlX6/fshjAD0N4wfVEpQjFYgjOctLl6ftA5BMDowUGcsQTz1k01hkOv4rk8FYCQqyG7nt1Qx1LzlfOycjzk7Lh32sv/GxVYQDnhngy0KqARrU+8MRxG6/uNwgx30753B2GP+P8Nh7qCplB3 X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(54906003)(36756003)(186003)(86362001)(1076003)(6666004)(26005)(2616005)(40460700003)(110136005)(316002)(47076005)(508600001)(44832011)(36860700001)(81166007)(5660300002)(336012)(70586007)(70206006)(8936002)(8676002)(4326008)(82310400004)(426003)(7696005)(2906002)(83380400001)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:50:57.5354 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: daccd649-5a00-4051-036a-08d9e169c108 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3693 From: Stefano Stabellini We always use a fix address to map the vPL011 to domains. The address could be a problem for direct-map domains. So, for domains that are directly mapped, reuse the address of the physical UART on the platform to avoid potential clashes. Do the same for the virtual IRQ number: instead of always using GUEST_VPL011_SPI, try to reuse the physical SPI number if possible. Signed-off-by: Stefano Stabellini Signed-off-by: Penny Zheng Tested-by: Stefano Stabellini Reviewed-by: Julien Grall --- v2 changes: - explain why vpl011 initialization before creating its device tree node - error out if the domain is direct-mapped and the IRQ is not found - harden the code and add a check/comment when the hardware UART region is smaller than GUEST_VPL011_SIZE. --- v3 changes: - explain how the '27' was found for 'buf' - fix checking before dereferencing - refine comment message --- v4 changes: - refine comment message --- v5 changes: - nothing changed --- xen/arch/arm/domain_build.c | 44 +++++++++++++++++++---- xen/arch/arm/include/asm/vpl011.h | 2 ++ xen/arch/arm/vpl011.c | 60 +++++++++++++++++++++++++++---- 3 files changed, 92 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index cff2cb93cc..8be01678de 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -30,6 +30,7 @@ #include #include +#include static unsigned int __initdata opt_dom0_max_vcpus; integer_param("dom0_max_vcpus", opt_dom0_max_vcpus); @@ -2415,8 +2416,12 @@ static int __init make_vpl011_uart_node(struct kernel_info *kinfo) gic_interrupt_t intr; __be32 reg[GUEST_ROOT_ADDRESS_CELLS + GUEST_ROOT_SIZE_CELLS]; __be32 *cells; + struct domain *d = kinfo->d; + /* Placeholder for sbsa-uart@ + a 64-bit number + \0 */ + char buf[27]; - res = fdt_begin_node(fdt, "sbsa-uart@"__stringify(GUEST_PL011_BASE)); + snprintf(buf, sizeof(buf), "sbsa-uart@%"PRIx64, d->arch.vpl011.base_addr); + res = fdt_begin_node(fdt, buf); if ( res ) return res; @@ -2426,14 +2431,14 @@ static int __init make_vpl011_uart_node(struct kernel_info *kinfo) cells = ®[0]; dt_child_set_range(&cells, GUEST_ROOT_ADDRESS_CELLS, - GUEST_ROOT_SIZE_CELLS, GUEST_PL011_BASE, + GUEST_ROOT_SIZE_CELLS, d->arch.vpl011.base_addr, GUEST_PL011_SIZE); res = fdt_property(fdt, "reg", reg, sizeof(reg)); if ( res ) return res; - set_interrupt(intr, GUEST_VPL011_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); + set_interrupt(intr, d->arch.vpl011.virq, 0xf, DT_IRQ_TYPE_LEVEL_HIGH); res = fdt_property(fdt, "interrupts", intr, sizeof (intr)); if ( res ) @@ -3145,6 +3150,14 @@ static int __init construct_domU(struct domain *d, else assign_static_memory_11(d, &kinfo, node); + /* + * Base address and irq number are needed when creating vpl011 device + * tree node in prepare_dtb_domU, so initialization on related variables + * shall be done first. + */ + if ( kinfo.vpl011 ) + rc = domain_vpl011_init(d, NULL); + rc = prepare_dtb_domU(d, &kinfo); if ( rc < 0 ) return rc; @@ -3153,9 +3166,6 @@ static int __init construct_domU(struct domain *d, if ( rc < 0 ) return rc; - if ( kinfo.vpl011 ) - rc = domain_vpl011_init(d, NULL); - return rc; } @@ -3200,15 +3210,35 @@ void __init create_domUs(void) if ( !dt_property_read_u32(node, "nr_spis", &d_cfg.arch.nr_spis) ) { + unsigned int vpl011_virq = GUEST_VPL011_SPI; + d_cfg.arch.nr_spis = gic_number_lines() - 32; + /* + * The VPL011 virq is GUEST_VPL011_SPI, unless direct-map is + * set, in which case it'll match the hardware. + * + * Since the domain is not yet created, we can't use + * d->arch.vpl011.irq. So the logic to find the vIRQ has to + * be hardcoded. + * The logic here shall be consistent with the one in + * domain_vpl011_init(). + */ + if ( flags & CDF_directmap ) + { + vpl011_virq = serial_irq(SERHND_DTUART); + if ( vpl011_virq < 0 ) + panic("Error getting IRQ number for this serial port %d\n", + SERHND_DTUART); + } + /* * vpl011 uses one emulated SPI. If vpl011 is requested, make * sure that we allocate enough SPIs for it. */ if ( dt_property_read_bool(node, "vpl011") ) d_cfg.arch.nr_spis = MAX(d_cfg.arch.nr_spis, - GUEST_VPL011_SPI - 32 + 1); + vpl011_virq - 32 + 1); } /* diff --git a/xen/arch/arm/include/asm/vpl011.h b/xen/arch/arm/include/asm/vpl011.h index e6c7ab7381..c09abcd7a9 100644 --- a/xen/arch/arm/include/asm/vpl011.h +++ b/xen/arch/arm/include/asm/vpl011.h @@ -53,6 +53,8 @@ struct vpl011 { uint32_t uarticr; /* Interrupt clear register */ uint32_t uartris; /* Raw interrupt status register */ uint32_t shadow_uartmis; /* shadow masked interrupt register */ + paddr_t base_addr; + unsigned int virq; spinlock_t lock; evtchn_port_t evtchn; }; diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 895f436cc4..43522d48fd 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -71,11 +72,11 @@ static void vpl011_update_interrupt_status(struct domain *d) * status bit has been set since the last time. */ if ( uartmis & ~vpl011->shadow_uartmis ) - vgic_inject_irq(d, NULL, GUEST_VPL011_SPI, true); + vgic_inject_irq(d, NULL, vpl011->virq, true); vpl011->shadow_uartmis = uartmis; #else - vgic_inject_irq(d, NULL, GUEST_VPL011_SPI, uartmis); + vgic_inject_irq(d, NULL, vpl011->virq, uartmis); #endif } @@ -347,7 +348,8 @@ static int vpl011_mmio_read(struct vcpu *v, void *priv) { struct hsr_dabt dabt = info->dabt; - uint32_t vpl011_reg = (uint32_t)(info->gpa - GUEST_PL011_BASE); + uint32_t vpl011_reg = (uint32_t)(info->gpa - + v->domain->arch.vpl011.base_addr); struct vpl011 *vpl011 = &v->domain->arch.vpl011; struct domain *d = v->domain; unsigned long flags; @@ -430,7 +432,8 @@ static int vpl011_mmio_write(struct vcpu *v, void *priv) { struct hsr_dabt dabt = info->dabt; - uint32_t vpl011_reg = (uint32_t)(info->gpa - GUEST_PL011_BASE); + uint32_t vpl011_reg = (uint32_t)(info->gpa - + v->domain->arch.vpl011.base_addr); struct vpl011 *vpl011 = &v->domain->arch.vpl011; struct domain *d = v->domain; unsigned long flags; @@ -626,6 +629,49 @@ int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info) if ( vpl011->backend.dom.ring_buf ) return -EINVAL; + /* + * The VPL011 virq is GUEST_VPL011_SPI, except for direct-map domains + * where the hardware value shall be used. + * The logic here should stay in sync with the one in + * create_domUs(). + */ + if ( is_domain_direct_mapped(d) ) + { + const struct vuart_info *uart = serial_vuart_info(SERHND_DTUART); + int vpl011_irq = serial_irq(SERHND_DTUART); + + if ( (uart != NULL) && (vpl011_irq > 0) ) + { + vpl011->base_addr = uart->base_addr; + vpl011->virq = vpl011_irq; + } + else + { + printk(XENLOG_ERR + "vpl011: Unable to re-use the Xen UART information.\n"); + return -EINVAL; + } + + /* + * Since the PL011 we emulate for the guest requires a 4KB region, + * and on some Hardware (e.g. on some sunxi SoC), the UART MMIO + * region is less than 4KB, in which case, there may exist multiple + * devices within the same 4KB region, here adds the following check to + * prevent potential known pitfalls + */ + if ( uart->size < GUEST_PL011_SIZE ) + { + printk(XENLOG_ERR + "vpl011: Can't re-use the Xen UART MMIO region as it is too small.\n"); + return -EINVAL; + } + } + else + { + vpl011->base_addr = GUEST_PL011_BASE; + vpl011->virq = GUEST_VPL011_SPI; + } + /* * info is NULL when the backend is in Xen. * info is != NULL when the backend is in a domain. @@ -661,7 +707,7 @@ int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info) } } - rc = vgic_reserve_virq(d, GUEST_VPL011_SPI); + rc = vgic_reserve_virq(d, vpl011->virq); if ( !rc ) { rc = -EINVAL; @@ -673,12 +719,12 @@ int domain_vpl011_init(struct domain *d, struct vpl011_init_info *info) spin_lock_init(&vpl011->lock); register_mmio_handler(d, &vpl011_mmio_handler, - GUEST_PL011_BASE, GUEST_PL011_SIZE, NULL); + vpl011->base_addr, GUEST_PL011_SIZE, NULL); return 0; out2: - vgic_free_virq(d, GUEST_VPL011_SPI); + vgic_free_virq(d, vpl011->virq); out1: if ( vpl011->backend_in_domain ) From patchwork Thu Jan 27 07:49:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12726381 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 AC244C433EF for ; Thu, 27 Jan 2022 07:57:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.261254.452158 (Exim 4.92) (envelope-from ) id 1nCzei-00074q-LY; Thu, 27 Jan 2022 07:57:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 261254.452158; Thu, 27 Jan 2022 07:57:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nCzei-00074g-HF; Thu, 27 Jan 2022 07:57:20 +0000 Received: by outflank-mailman (input) for mailman id 261254; Thu, 27 Jan 2022 07:57:18 +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 1nCzYm-0000Xj-PX for xen-devel@lists.xenproject.org; Thu, 27 Jan 2022 07:51:13 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0622.outbound.protection.outlook.com [2a01:111:f400:fe1f::622]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e37e206e-7f45-11ec-8eb8-a37418f5ba1a; Thu, 27 Jan 2022 08:51:09 +0100 (CET) Received: from DU2PR04CA0215.eurprd04.prod.outlook.com (2603:10a6:10:2b1::10) by AM0PR08MB3057.eurprd08.prod.outlook.com (2603:10a6:208:57::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 07:51:04 +0000 Received: from DB5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b1:cafe::da) by DU2PR04CA0215.outlook.office365.com (2603:10a6:10:2b1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:51:04 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT024.mail.protection.outlook.com (10.152.20.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:51:04 +0000 Received: ("Tessian outbound 741ca6c82739:v113"); Thu, 27 Jan 2022 07:51:04 +0000 Received: from 76afdeb32a0b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7A15F6C0-0970-4E25-AE5E-8A0214808630.1; Thu, 27 Jan 2022 07:50:58 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 76afdeb32a0b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 27 Jan 2022 07:50:58 +0000 Received: from DB6PR0301CA0050.eurprd03.prod.outlook.com (2603:10a6:4:54::18) by AM0PR08MB3954.eurprd08.prod.outlook.com (2603:10a6:208:130::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 07:50:56 +0000 Received: from DB5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::2d) by DB6PR0301CA0050.outlook.office365.com (2603:10a6:4:54::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17 via Frontend Transport; Thu, 27 Jan 2022 07:50:55 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT037.mail.protection.outlook.com (10.152.20.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 07:50:55 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 27 Jan 2022 07:50:49 +0000 Received: from penny.shanghai.arm.com (10.169.188.91) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 27 Jan 2022 07:50:47 +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: e37e206e-7f45-11ec-8eb8-a37418f5ba1a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fcniZhKAF+YlzkF8r4ObH2CSPPalx5peyg6qh95+h3o=; b=nqFHC9vBUa77Q7UdBVvDxOdQWJQWYZ1OmpOFVywIGQM+Eqvui3KLRBMOMBl/PXIMTvLRJfHYAkUhhsQqzd8UUYddLde4r6lECP0NqW0oK+y+7pV8VlPyXfkG+vwZXByCKE3k959hcka0a3T9rKfdx8DsCRjtDW9BuS/HdD/KrF0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-CheckRecipientChecked: true X-CR-MTA-CID: 2778a4c416ac9ed8 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EcOegVREa0pntX0NOkJU1LFEOGYnli6lJ9SkL0Q8LtHNDQrkeBZ+c2cBllZTgSLbFZI3ndqR2ZgvoGL686Oyi0xxx0vvIDaUJSYhzD81cbuBWVGE8Clc5mXJakY0POYDAEE0nbuTafQzsm/ygMh/FzE7Rk4RyaeYBVTQqa+qkLJwEIlNn0XjTj8u0CC5Irl33dp7hmQ1VKX84kvA1ztL9pO5wcfg21KZb5ipSNYyQuchbHB/HO6G4+AxluWSOlYv8dnLc30qzbVAJkXZLVm6SYw3B8VjCEK19aTEHxJwM5myfkpd/QzFaP+uXGe84j9Zb/MG8seKT/eeEvKiIjv8Pg== 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=fcniZhKAF+YlzkF8r4ObH2CSPPalx5peyg6qh95+h3o=; b=Yz2JMyW4zY9JOG4QqpdM9nVgb75Ev+AxzoNrFgE4mmG6lrpdIvAGg0McsYevT0PKiYyJqf884GOXbyWNuWjY9F0rZ/kNmFBh/zwUvw1oniWdLkCQiOy0Mx/e3NUeLuGrT3eGDlSIsoKcMcOr9nhNluv+KBojguLNXFcRW3e8pk7CNmz8NSkC+0iBhmjuzWwUcr/6XEk+rm1hs9jp3kzz9pUhNKgZI8K9XKSnSsy5dHEhFJlFzyfwoeA1odhoErJ6wafyLHmaUGqAdLY2t74XZkf5DK8IbNfuQDgdJ0xhPz5eSfx3P6oY7aXMXPcqlVvVGYyO9wIraZ/My3k4MkNEQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fcniZhKAF+YlzkF8r4ObH2CSPPalx5peyg6qh95+h3o=; b=nqFHC9vBUa77Q7UdBVvDxOdQWJQWYZ1OmpOFVywIGQM+Eqvui3KLRBMOMBl/PXIMTvLRJfHYAkUhhsQqzd8UUYddLde4r6lECP0NqW0oK+y+7pV8VlPyXfkG+vwZXByCKE3k959hcka0a3T9rKfdx8DsCRjtDW9BuS/HdD/KrF0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; From: Penny Zheng To: , , CC: , Subject: [PATCH v5 11/11] xen/docs: Document how to do passthrough without IOMMU Date: Thu, 27 Jan 2022 07:49:29 +0000 Message-ID: <20220127074929.502885-12-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127074929.502885-1-penny.zheng@arm.com> References: <20220127074929.502885-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: c50995f4-530e-4289-e9b6-08d9e169c52e X-MS-TrafficTypeDiagnostic: AM0PR08MB3954:EE_|DB5EUR03FT024:EE_|AM0PR08MB3057:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1751;OLM:1751; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: exw++onWsfnf+UHypgGwng7/bYZn6bdN+YZiuQu30BYb6Rtd+c0A1se/Z31pDe8lfG/WOoU1YY1fyGkIkkWuzycLICjKBx03S9xuNxRSHYUQcBzDflVRN3JK3jLIz6+MLZmWviAPUkSk1gyRFRtNj8v3iu4z9obIR42gYphsdab4doBabvEZf8WxTGRYCk5D9+JTiPZOR46srYola/DW9RlpuDzNzgcafRskiZMuW6QHqNyTFu/iVEDHFyX6lb9WzmLoovwWA4TS9xsuki2JtzaR+cnZPdbiltWsg4/mu2ThnpswQRz+JBig5uvYsVwElzv5+qKoMcIUH/Zo+4+4TwOhsKvQHDjpIGBXTzHL3UIQXy2aBS3hzKtFr+NIGbgG6aTQaEqZ6BkCHtkiCgbhj128Em2bOQLOJYhdOW6Tq4OSABueZrgHI56MPclXGfVvDj4JA0ZBhWtanlkxyTVAGoTjbzfA8YWPqTNy9Gggkz2S5k4Mrc7XY82wXqVFH+2mVn5+4Lg2/962xFRuOQja3GcUc3im1dtxPVt3UMCLySzWam5RkecjL8Jhqal+kiSu0TDTunl1T923y1o559I3rqw3cOmiteaHQMSBdjCAC3sMM/a/G7DplLqidbC+bY5Hw5pI7wxFjo+emHskZ7BWGSbJzLT755rOrv83DthlZ2Arr4iIWAtRB37PoNGQHLUO2Zs9lJ+UCuvjchSYdAZSQA== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(70586007)(70206006)(4326008)(8676002)(81166007)(82310400004)(8936002)(426003)(5660300002)(336012)(356005)(83380400001)(2906002)(7696005)(40460700003)(6666004)(2616005)(110136005)(36756003)(54906003)(86362001)(1076003)(186003)(26005)(44832011)(36860700001)(508600001)(316002)(47076005)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3954 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: dc20f1f8-7c4a-4faa-22df-08d9e169c004 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SHK0EllLIpTGYsOG6CxGDsIpicmEt+LIQKgy8hfKpyoMkVW+bXoQkYhMteoeJjam0iQrzDzCj4Payqd4g8EUm+9jYRTpRGP1UiEb9RLd0nIGH5/HMVjpwZyHlzbuYiWE/RXkATeOdijBhthbA8LC4WBTLXow4+qRmIyvRF5r68zgnOjORZDsCbeoGY6HG9e5JLIJOha4//ttbPwrDPWChiursw9r9oaIt4j4KYY/TNoJW4A2TflC+BAKyRNIviU97LAx7+QPqQOupHhXuzbrLR+J1Ekyu2FBhr3KjPL5XsryIX65utaGO8ge4WlDUVcx6BT+CMuNnwdpETyDeIiu+kIJoui8ZMD5Wv7GVmSi+GJhM8aIyum3a3SS3erFKoH+slbM2RR8Na8xqEmYVhrVufs1M7T/rpEe2juUkeOP7Pao0CyVRAb7AO2c4ayWhw58VsqeCvX68Ru5afIraB9dTW0+D6YePTVES2lNYx5ISAqenUcXZlGV43AGU40k0MqWzYTLojqTD4S9v3AS9wA4tTzMhPQeU2caMHlkuhHVhFA76iSpmWf9kMfdT0N8cyFQIXRwwgnmDi6dav+ReNI+gMJkFFOvmUZW7eEi0LAu+8wVyzKdGVHtoSCWBk95qU7PGzs0MzZ6tD9mytFIyvM7Bt1McXzwghoek2p09CrGWptNZkkIqKgDp6gxpxzSMJST X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(2906002)(36860700001)(5660300002)(2616005)(70206006)(70586007)(508600001)(6666004)(81166007)(36756003)(44832011)(7696005)(83380400001)(26005)(82310400004)(316002)(40460700003)(54906003)(110136005)(336012)(4326008)(8676002)(8936002)(47076005)(1076003)(186003)(426003)(86362001)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 07:51:04.5481 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c50995f4-530e-4289-e9b6-08d9e169c52e X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3057 From: Stefano Stabellini This commit creates a new doc to document how to do passthrough without IOMMU. Signed-off-by: Stefano Stabellini Signed-off-by: Penny Zheng Tested-by: Stefano Stabellini Acked-by: Julien Grall --- v2 changes: - nothing changed --- v3 changes: - nothing changed --- v4 changes: - nothing changed --- v5 changes: - nothing changed --- docs/misc/arm/passthrough-noiommu.txt | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 docs/misc/arm/passthrough-noiommu.txt diff --git a/docs/misc/arm/passthrough-noiommu.txt b/docs/misc/arm/passthrough-noiommu.txt new file mode 100644 index 0000000000..3e2ef21ad7 --- /dev/null +++ b/docs/misc/arm/passthrough-noiommu.txt @@ -0,0 +1,52 @@ +Request Device Assignment without IOMMU support +=============================================== + +*WARNING: +Users should be aware that it is not always secure to assign a device without +IOMMU protection. +When the device is not protected by the IOMMU, the administrator should make +sure that: + 1. The device is assigned to a trusted guest. + 2. Users have additional security mechanism on the platform. + +This document assumes that the IOMMU is absent from the system or it is +disabled (status = "disabled" in device tree). + +Add xen,force-assign-without-iommu; to the device tree snippet: + +ethernet: ethernet@ff0e0000 { + compatible = "cdns,zynqmp-gem"; + xen,path = "/amba/ethernet@ff0e0000"; + xen,reg = <0x0 0xff0e0000 0x1000 0x0 0xff0e0000>; + xen,force-assign-without-iommu; +}; + +Request 1:1 memory mapping for the domain on static allocation +============================================================== + +Add a direct-map property under the appropriate /chosen/domU node which +is also statically allocated with physical memory ranges through +xen,static-mem property as its guest RAM. + +Below is an example on how to specify the 1:1 memory mapping for the domain +on static allocation in the device-tree: + +/ { + chosen { + domU1 { + compatible = "xen,domain"; + #address-cells = <0x2>; + #size-cells = <0x2>; + cpus = <2>; + memory = <0x0 0x80000>; + #xen,static-mem-address-cells = <0x1>; + #xen,static-mem-size-cells = <0x1>; + xen,static-mem = <0x30000000 0x20000000>; + direct-map; + ... + }; + }; +}; + +Besides reserving a 512MB region starting at the host physical address +0x30000000 to DomU1, it also requests 1:1 memory mapping.