From patchwork Tue May 18 05:21:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12263539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50E5CC433B4 for ; Tue, 18 May 2021 05:22:05 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E5AA961361 for ; Tue, 18 May 2021 05:22:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5AA961361 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.128613.241423 (Exim 4.92) (envelope-from ) id 1lisAx-0000Xf-Is; Tue, 18 May 2021 05:21:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 128613.241423; Tue, 18 May 2021 05:21: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 1lisAx-0000XY-Fq; Tue, 18 May 2021 05:21:51 +0000 Received: by outflank-mailman (input) for mailman id 128613; Tue, 18 May 2021 05:21:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisAv-0000XS-FI for xen-devel@lists.xenproject.org; Tue, 18 May 2021 05:21:49 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (unknown [40.107.3.64]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 78af3743-edf4-4978-a783-2edaca25601b; Tue, 18 May 2021 05:21:46 +0000 (UTC) Received: from AM6PR08CA0007.eurprd08.prod.outlook.com (2603:10a6:20b:b2::19) by AM0PR08MB3330.eurprd08.prod.outlook.com (2603:10a6:208:5c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Tue, 18 May 2021 05:21:43 +0000 Received: from AM5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::e2) by AM6PR08CA0007.outlook.office365.com (2603:10a6:20b:b2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:43 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT024.mail.protection.outlook.com (10.152.16.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:43 +0000 Received: ("Tessian outbound 0f1e4509c199:v92"); Tue, 18 May 2021 05:21:43 +0000 Received: from c6bec359284a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 72016849-DD8E-447A-AF69-C5D4479BD6E6.1; Tue, 18 May 2021 05:21:36 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c6bec359284a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 May 2021 05:21:36 +0000 Received: from AM6P192CA0065.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::42) by DB8PR08MB5404.eurprd08.prod.outlook.com (2603:10a6:10:117::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Tue, 18 May 2021 05:21:34 +0000 Received: from VE1EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::bb) by AM6P192CA0065.outlook.office365.com (2603:10a6:209:82::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:21:34 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT018.mail.protection.outlook.com (10.152.18.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21: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.2176.14; Tue, 18 May 2021 05:21:33 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2176.14; Tue, 18 May 2021 05:21:33 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 18 May 2021 05:21:30 +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: 78af3743-edf4-4978-a783-2edaca25601b 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=du5OP3mWpKQtM/QoyT2ZsDEjLUVsC0mPKC4RWPNn37o=; b=tZjWizBbTesSpribmwEqGTbBsIOJMbGGEhrrtIeC+9Npwub6mARxvcjvgcDjkzas9iOo6fZc3Sv6RCOYmU2VBVAlyJBNw8nmKBd6TFCikBTf+ysRvgw3YMMa38Z14RaWAKrOcjkPO+xWbVp70+CNiWBjepgPPR7bWBjb7eurGI0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; 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: 82aa9357170c4fdc X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UpES8RNL1KPyWVL8RKVqVOzPurftiNp94elIgFVM0AUvLBH7cJfnQPrPaGlVWPlRxz0B7dBCq7kBKKZmvTYGtofk3PeKff9WIg9FxpFyB9X50c3Ukd6VtofuEVVGn4QyjLTwEhSCLoivv1vu+YnpX87o1eM5A8b+sFA1K7J6hClrsUJbVjIguCdz/oo5/ZK53NQiUH6rleclBpq6BJL94tFd69p6n8O3f2KIIi3BTrQB4HAnREHOEu/lHLdrxZS6OCPS1rdDd8MwblZZCg2LMOx0N6bh7n6UXCt6hqUPe4iOGprFVBk47IWpdc7K1oIzc1R5Ec5zFDYh/rxsYjDuWA== 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-SenderADCheck; bh=du5OP3mWpKQtM/QoyT2ZsDEjLUVsC0mPKC4RWPNn37o=; b=bv3vj4HuFRpRMePJBoMkzjXnOwjSMojsln3VQWQQKx0eSblTk0RbXNF3wKJeDRxPY3Sf3BoT5rByPQCgCcg/sXomjPIMEgM087TOqd5ku3RexINOaZgQyrz/7GSmHVmxqYfETKOv2kvf7PZ+ZI38CH1j38jJ7dBK8364wc+yJdWfYw68N4TUwFqJeQmupMp8hy44o27lTG+aH9u8q8qEXxR9XGWFlmUN6d/ziWniNYWXa1laVPLpihUiYGdjHofg162yaX+Vo8yuPFNuP+gZ13p8d+kQnRLC4mNzUOuTRb8zc4jgw1k1V/+C8xLysU7Je72EtuqwffZec3NWynFAOQ== 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=du5OP3mWpKQtM/QoyT2ZsDEjLUVsC0mPKC4RWPNn37o=; b=tZjWizBbTesSpribmwEqGTbBsIOJMbGGEhrrtIeC+9Npwub6mARxvcjvgcDjkzas9iOo6fZc3Sv6RCOYmU2VBVAlyJBNw8nmKBd6TFCikBTf+ysRvgw3YMMa38Z14RaWAKrOcjkPO+xWbVp70+CNiWBjepgPPR7bWBjb7eurGI0= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; 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 01/10] xen/arm: introduce domain on Static Allocation Date: Tue, 18 May 2021 05:21:04 +0000 Message-ID: <20210518052113.725808-2-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518052113.725808-1-penny.zheng@arm.com> References: <20210518052113.725808-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76e46bd6-cf87-43e2-95dd-08d919bcd2ed X-MS-TrafficTypeDiagnostic: DB8PR08MB5404:|AM0PR08MB3330: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8273;OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: F9SiYjmWZKYsM3s96cl/mX/fsp1oReI9T7a5wXs2Ny/cCmjDOr23X5otT6BGv7KVjnR+b2qBh0ibXgrPOd+eEijoazT5upDgCA+8LN6z0NqMn+YwiIRHMfcw6svNOBsksOC+Kyw04gqgQR2jhcL7sJXWWg9k6M3A9mJtXYgmHD8LD3VL3LZ60VH/9IjOHI3bzCfAbLpERbkx5/bW64m2ylBI4LKtdlnh5gbMYGt11RH12PmP+WypwtLGfjVqKfKI7jRJERexwzOhr3ArEkKVlOS5wDbPAR5GTwW53zuZF3idQWRquVQUCtM0VUvRxrXTcnKsrxaNddh2SK6Cnh8ZG0sfu1l09eRgdym8Q+bA4fl/+BIXstAqpVATJYHxhYU0BTHmmJ7X5cZoMlGwNTJgedVqzZ7OqkFETPUDrdQ6azArK//RtUFMMRcC55BDeKl/bhGa5E5BQCiF4/rzmv0SQWjTmpijDCCDZZDfAOtoVe0jTfRub1/b+bS7tOkGxPssHj+HGedLhZJPKHn8Yv5LpuoZQRHCS0hX6+sT3ovhLaUByrsh8/KcogvanxwzexjAFwEnn4b1EmZG/iWymD9UmpYno9CZrP4pTzWOR6iPQ4J5vp3WAasmRLInTpqZ+5QMbmsmm4sSPhdEGDleUjQtBYcoOlEtCrqc0Td4/dya//W3FNYd6sW1VbMWhynKiW70 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)(376002)(136003)(346002)(396003)(39850400004)(36840700001)(46966006)(47076005)(36860700001)(5660300002)(186003)(26005)(2616005)(336012)(478600001)(81166007)(2906002)(82740400003)(70586007)(4326008)(54906003)(82310400003)(356005)(426003)(8676002)(1076003)(70206006)(36756003)(86362001)(44832011)(110136005)(83380400001)(316002)(8936002)(6666004)(7696005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5404 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: b82fa1be-3500-4c41-9175-08d919bccda9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PT/koVu75C1Fj/Dhw+UvdhPExqGstVbqnbDKZMTIY1SzGtRAbzmJQygrIAdVuLdukcREXfbwmeE5Rj92KB2Sy23/MoHjXl2SDTUP5HnvwQN8hB8NL5LM11BAf8lgduZp6Hkdu/DRt+90jTWoMxFJ7G9VJxV+qCGoowxaSJ7pxSAHK0e9/Pkz5cQspv3S37H/+s4dl82YPn8LsMFt7c3entl9LEa8s2dLhDSDPjj9DAYkyDm9HnBFxd5hUNl5BQWM37BlMppg3fCmhkk8SBTc8I1C01fYvaVFdupXXbYvPfQxq4+UBtUlMDlH4hFB8QE3FgCJVF4Uv1+Xq0e0nWlxwNbLFYcbEkB6MdHPOjIikeaQzo/87Qje84y8JO41UejYTA/MwWRfTduKZQVDzUyHxibyqmippv6cS5Z7qGxzK8Yboy1BsrDI8Zv8lfknQPKCb+6YxTuch02G7FzjXRj615lWENmPNvMdusM3THqkWxklL+SRZDZx9m0AbyAeWCZy52ZS2ctDOfHZ+re5941su2RT1immrX39genrj6gPE4rEfob3HtD/6xiWhrx0kaiYiJcnmV/RjY7LwLPnGBdWRlJ8ll6adQp6PscI8EgJcxDAU2hGhY+y8hma72EBpRqmAuuWDySEpH1rec8RxKOQ1lF3j2pEpSZ7u8zd7T4/7+Q= 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)(346002)(376002)(136003)(396003)(39850400004)(36840700001)(46966006)(7696005)(83380400001)(81166007)(54906003)(5660300002)(110136005)(36860700001)(47076005)(82740400003)(316002)(8676002)(8936002)(478600001)(44832011)(2616005)(36756003)(82310400003)(336012)(186003)(1076003)(2906002)(4326008)(70586007)(426003)(6666004)(26005)(86362001)(70206006);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 05:21:43.2208 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76e46bd6-cf87-43e2-95dd-08d919bcd2ed 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: AM5EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3330 Static Allocation refers to system or sub-system(domains) for which memory areas are pre-defined by configuration using physical address ranges. Those pre-defined memory, -- Static Momery, as parts of RAM reserved in the beginning, shall never go to heap allocator or boot allocator for any use. Domains on Static Allocation is supported through device tree property `xen,static-mem` specifying reserved RAM banks as this domain's guest RAM. By default, they shall be mapped to the fixed guest RAM address `GUEST_RAM0_BASE`, `GUEST_RAM1_BASE`. This patch introduces this new `xen,static-mem` property to define static memory nodes in device tree file. This patch also documents and parses this new attribute at boot time and stores related info in static_mem for later initialization. Signed-off-by: Penny Zheng --- docs/misc/arm/device-tree/booting.txt | 33 +++++++++++++++++ xen/arch/arm/bootfdt.c | 52 +++++++++++++++++++++++++++ xen/include/asm-arm/setup.h | 2 ++ 3 files changed, 87 insertions(+) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt index 5243bc7fd3..d209149d71 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -268,3 +268,36 @@ The DTB fragment is loaded at 0xc000000 in the example above. It should follow the convention explained in docs/misc/arm/passthrough.txt. The DTB fragment will be added to the guest device tree, so that the guest kernel will be able to discover the device. + + +Static Allocation +============= + +Static Allocation refers to system or sub-system(domains) for which memory +areas are pre-defined by configuration using physical address ranges. +Those pre-defined memory, -- Static Momery, as parts of RAM reserved in the +beginning, shall never go to heap allocator or boot allocator for any use. + +Domains on Static Allocation is supported through device tree property +`xen,static-mem` specifying reserved RAM banks as this domain's guest RAM. +By default, they shall be mapped to the fixed guest RAM address +`GUEST_RAM0_BASE`, `GUEST_RAM1_BASE`. + +Static Allocation is only supported on AArch64 for now. + +The dtb property should look like as follows: + + chosen { + domU1 { + compatible = "xen,domain"; + #address-cells = <0x2>; + #size-cells = <0x2>; + cpus = <2>; + xen,static-mem = <0x0 0x30000000 0x0 0x20000000>; + + ... + }; + }; + +DOMU1 on Static Allocation has reserved RAM bank at 0x30000000 of 512MB size +as guest RAM. diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index dcff512648..e9f14e6a44 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -327,6 +327,55 @@ static void __init process_chosen_node(const void *fdt, int node, add_boot_module(BOOTMOD_RAMDISK, start, end-start, false); } +static int __init process_static_memory(const void *fdt, int node, + const char *name, + u32 address_cells, u32 size_cells, + void *data) +{ + int i; + int banks; + const __be32 *cell; + paddr_t start, size; + u32 reg_cells = address_cells + size_cells; + struct meminfo *mem = data; + const struct fdt_property *prop; + + if ( address_cells < 1 || size_cells < 1 ) + { + printk("fdt: invalid #address-cells or #size-cells for static memory"); + return -EINVAL; + } + + /* + * Check if static memory property belongs to a specific domain, that is, + * its node `domUx` has compatible string "xen,domain". + */ + if ( fdt_node_check_compatible(fdt, node, "xen,domain") != 0 ) + printk("xen,static-mem property can only locate under /domUx node.\n"); + + prop = fdt_get_property(fdt, node, name, NULL); + if ( !prop ) + return -ENOENT; + + cell = (const __be32 *)prop->data; + banks = fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); + + for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ ) + { + device_tree_get_reg(&cell, address_cells, size_cells, &start, &size); + /* Some DT may describe empty bank, ignore them */ + if ( !size ) + continue; + mem->bank[mem->nr_banks].start = start; + mem->bank[mem->nr_banks].size = size; + mem->nr_banks++; + } + + if ( i < banks ) + return -ENOSPC; + return 0; +} + static int __init early_scan_node(const void *fdt, int node, const char *name, int depth, u32 address_cells, u32 size_cells, @@ -345,6 +394,9 @@ static int __init early_scan_node(const void *fdt, process_multiboot_node(fdt, node, name, address_cells, size_cells); else if ( depth == 1 && device_tree_node_matches(fdt, node, "chosen") ) process_chosen_node(fdt, node, name, address_cells, size_cells); + else if ( depth == 2 && fdt_get_property(fdt, node, "xen,static-mem", NULL) ) + process_static_memory(fdt, node, "xen,static-mem", address_cells, + size_cells, &bootinfo.static_mem); if ( rc < 0 ) printk("fdt: node `%s': parsing failed\n", name); diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h index 5283244015..5e9f296760 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -74,6 +74,8 @@ struct bootinfo { #ifdef CONFIG_ACPI struct meminfo acpi; #endif + /* Static Memory */ + struct meminfo static_mem; }; extern struct bootinfo bootinfo; From patchwork Tue May 18 05:21:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12263549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3FCAC433ED for ; Tue, 18 May 2021 05:22:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4B3CA6108B for ; Tue, 18 May 2021 05:22:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4B3CA6108B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.128618.241478 (Exim 4.92) (envelope-from ) id 1lisBD-00029O-Nr; Tue, 18 May 2021 05:22:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 128618.241478; Tue, 18 May 2021 05:22:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisBD-000297-KB; Tue, 18 May 2021 05:22:07 +0000 Received: by outflank-mailman (input) for mailman id 128618; Tue, 18 May 2021 05:22:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisBC-00019F-6q for xen-devel@lists.xenproject.org; Tue, 18 May 2021 05:22:06 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:7e1b::61f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 539c1e41-0f1d-4ab4-8353-6e8862bf21ca; Tue, 18 May 2021 05:22:00 +0000 (UTC) Received: from AS8P251CA0022.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::6) by AM5PR0801MB2018.eurprd08.prod.outlook.com (2603:10a6:203:43::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:21:58 +0000 Received: from VE1EUR03FT013.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2::4) by AS8P251CA0022.outlook.office365.com (2603:10a6:20b:2f2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.27 via Frontend Transport; Tue, 18 May 2021 05:21:58 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT013.mail.protection.outlook.com (10.152.19.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:57 +0000 Received: ("Tessian outbound ea2c9a942a09:v92"); Tue, 18 May 2021 05:21:57 +0000 Received: from 5236c737a9ab.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CA7AF26D-EB39-43EE-87A6-756D2538B304.1; Tue, 18 May 2021 05:21:50 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5236c737a9ab.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 May 2021 05:21:50 +0000 Received: from AM6P194CA0032.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::45) by VI1PR08MB4015.eurprd08.prod.outlook.com (2603:10a6:803:e1::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:21:48 +0000 Received: from VE1EUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::10) by AM6P194CA0032.outlook.office365.com (2603:10a6:209:90::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.32 via Frontend Transport; Tue, 18 May 2021 05:21:48 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT005.mail.protection.outlook.com (10.152.18.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:48 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2176.14; Tue, 18 May 2021 05:21:35 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 18 May 2021 05:21:33 +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: 539c1e41-0f1d-4ab4-8353-6e8862bf21ca 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=Y6ATApPmkJrCTf9a/bdU7n8KOS835CGS4AwJ5jf2OAQ=; b=FtAwzZyfqQX6TCwB96aAijXOtcr2L/e245WtP8F4vkcoCkanGYmwJHzqzAsvSu14CKU1FVs6IKbBF+wPpAx0067f+FiPz2azGpke+cMPOWUwZTa5HIRTuBMVYvLE82WZy7bjcbj/asGnm5aflWUsKwKs5R0g/RJuTYKC7hRGyH4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; 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: 97192d34f5350264 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FTHnQ07fRNS5BlvlqHDqyskc/9S0UEz6GUcdpGuapbw7glfOX5H7aGelZnGk6D4BSmAwMnFEivcUwz/YIQxATxATrZCj12JSkOflDxTLktQXWjg+GTeK4tDVX60nL7eoull+KpXL+lHF8LAwVRLgpLddxEdoMEsvYD5Uf5DSxwvnc03SZPWAZMnJfzuNB5Uksuwj7+6TsssAc4I+Csd5q6qO8RgJ6c6wg0OwdgTwxG9M96NgU8tM9dVnWASjLWSgtKym1RRvVlToNI6X4pAizb9e06o5uSgkpM1Un5m3Yfoon0+RE8t3gerc6k3zChtbxj9TmFcisDTBr32gimMkhw== 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-SenderADCheck; bh=Y6ATApPmkJrCTf9a/bdU7n8KOS835CGS4AwJ5jf2OAQ=; b=lvDdsQKErF1AEelc10ZAdO00PEOqtgNwm9Vy05ZOLdEbdXsJQKTfgu1l8I3zXJ/uNQITuwmBpymin+TOQRmRwAQmLQH2uB6nAc7LxueFmip2NrFfhjKT4z7nsmhsS8X2sco/4juM3XDrr3ptOO1kuRBEsVgglRVzGln8+JLGRSbULlr7e/opHaXVqTDn0Cvwt7GOECQ8ytr6JcVWRTq3PKc7SpBDAyQtyffd1PKz7skVHtLzYqRzPAuGlZFef6mwPFFid6ViXhakHcFbP3abe6UnaAHYEpdQCyPk8YWuGccGAz886D1TnduWalPw+FP5cXG3gXkNox1vuRNTgmNTOA== 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=Y6ATApPmkJrCTf9a/bdU7n8KOS835CGS4AwJ5jf2OAQ=; b=FtAwzZyfqQX6TCwB96aAijXOtcr2L/e245WtP8F4vkcoCkanGYmwJHzqzAsvSu14CKU1FVs6IKbBF+wPpAx0067f+FiPz2azGpke+cMPOWUwZTa5HIRTuBMVYvLE82WZy7bjcbj/asGnm5aflWUsKwKs5R0g/RJuTYKC7hRGyH4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; 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 02/10] xen/arm: handle static memory in dt_unreserved_regions Date: Tue, 18 May 2021 05:21:05 +0000 Message-ID: <20210518052113.725808-3-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518052113.725808-1-penny.zheng@arm.com> References: <20210518052113.725808-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4df65769-59d3-45fb-4aab-08d919bcdbac X-MS-TrafficTypeDiagnostic: VI1PR08MB4015:|AM5PR0801MB2018: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:854;OLM:854; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: odg6zEdrcvElYOsQxbaQWCT4gGB5zc8gDjzmdtmiwBoQz1tNER0qsUSurEMYNRtVrnjpGNyIDSVPs8dkuoFOdXTz/Pp+O7mUOR+1GCdbg70VHpPIehOwpEDEMWp6t7EPKqzfQNiuXITpflYE1ogrFqNk0nveaBtCIaN45QERjaSxAFSjL26cWFynti0HpJDYjr75cuX+UFbVkTRZ4jWM9x4ia+qyNiBbIqhmuPHpGMZysgUrUPEZhoqZjNuNe4CJ4hme4mft3dnd3Gk9KsbWVP59+rVCMww30AtGd2kMmncNM0EnIQ2Y41psqPL3aD2E23cFuT/OHpOm+FzuBCJ6xsWafmIzDRHjUCU0hWarJVZZtM6cNZ9mlf3+ntfLeRQ+WhfEGgMRSxtuvDLg7AhL7Y9ghV6kSPZwZAzunurUrhTWOUTdDGGLGLQml3TtiW31vGQB04qRDqn8qJdEV+6meTwJHk4WixRnnLnydLryXUWuVW8GbWhf2tAl3MdiurPA4/NwKoc6164F7+kvp7mMgK94ADga8Gj9DH42YeXTfoKfGSl9m01XpeOYfILLKnb+xb2I5VIRCGz5zKqM2QrRy418IvbUyq0sV8kMVHNQbs7s16rMqbcrGJSDbUAh3Cnn+BLBdRe3JD/85I4Q8U8yrwzGRixFMZkAg/O9gGc4Cmt45q1GBq0rvAmN0+cdNxKX 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)(346002)(136003)(39850400004)(396003)(376002)(36840700001)(46966006)(2906002)(82740400003)(44832011)(81166007)(83380400001)(8936002)(8676002)(82310400003)(356005)(1076003)(86362001)(110136005)(70586007)(336012)(6666004)(54906003)(47076005)(316002)(2616005)(26005)(478600001)(426003)(36860700001)(70206006)(4326008)(5660300002)(7696005)(36756003)(186003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4015 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: b83e22af-2083-44d1-af6a-08d919bcd5ca X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7vtvXyDQF++YL3xqJ+VVxUESCwPJY4FZfp0uq2OUrS5LQcz8vy4qvZJT42YXtORfN+3Sh7m4TSySFRJXR78LUGXA9GvnN3AJADewCjgQJl5kc46ECXSjpqAl+T7+S6pBe3aOrCDVVnvMUQ6NOsOElXFwzGIWHfJaWbsIgvwV2prF+g9sr0Vg/hgktjT+kZI1uuzjPqmUOzCGkjHpxlNzfeIt7ak3EMj5vsO+ZpI+xIXkRQfBVDeroU7pdIm0zRlF/W1GcwYXD8gGhCzKjbZCEBlcfCC9UjiNbI2hq4dai5aYBwXt/7fEYeaZCO61jBXD+kqTzb0PisYEOvc3W6k/si06lr+caI/JxUGJf7ko7oEBGtIOGaeygW44Jj+npG87gJj7m2OYgHmP2h3Pal9rcxhScJDuivdxOTASOaDGLjLGesGnDBu1UBMMHRITRbLJlqWhSrrrofB95R5tAhrCuGRMpFSIRhn+7p0GCAv/MYhTZDGBHnxIOWcfnDwiNoS2Fk6QF+pddMf4GbfjEIzn30KpDS6y5msOEdD/AXVgGxw19rdnoOi+09J06ahcogONBwRw331cqF/41zd3vW2LrAtB8XRyDbkSeXCesBRurSeRFu0qkZWTvk+ZkpfZfGQvq9estt2bxFC93KQYrFNpUAfr1q5eK5a+LP2XYpjMpmM= 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)(396003)(136003)(346002)(39850400004)(376002)(36840700001)(46966006)(81166007)(36756003)(54906003)(5660300002)(1076003)(2906002)(316002)(82310400003)(4326008)(110136005)(86362001)(36860700001)(186003)(8676002)(7696005)(70206006)(26005)(2616005)(8936002)(6666004)(478600001)(47076005)(44832011)(70586007)(83380400001)(426003)(82740400003)(336012);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 05:21:57.8415 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4df65769-59d3-45fb-4aab-08d919bcdbac 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: VE1EUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB2018 static memory regions overlap with memory nodes. The overlapping memory is reserved-memory and should be handled accordingly: dt_unreserved_regions should skip these regions the same way they are already skipping mem-reserved regions. Signed-off-by: Penny Zheng --- xen/arch/arm/setup.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 00aad1c194..444dbbd676 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -201,7 +201,7 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t e, void (*cb)(paddr_t, paddr_t), int first) { - int i, nr = fdt_num_mem_rsv(device_tree_flattened); + int i, nr_reserved, nr_static, nr = fdt_num_mem_rsv(device_tree_flattened); for ( i = first; i < nr ; i++ ) { @@ -222,18 +222,45 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t e, } /* - * i is the current bootmodule we are evaluating across all possible - * kinds. + * i is the current reserved RAM banks we are evaluating across all + * possible kinds. * * When retrieving the corresponding reserved-memory addresses * below, we need to index the bootinfo.reserved_mem bank starting * from 0, and only counting the reserved-memory modules. Hence, * we need to use i - nr. */ - for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) + i = i - nr; + nr_reserved = bootinfo.reserved_mem.nr_banks; + for ( ; i < nr_reserved; i++ ) { - paddr_t r_s = bootinfo.reserved_mem.bank[i - nr].start; - paddr_t r_e = r_s + bootinfo.reserved_mem.bank[i - nr].size; + paddr_t r_s = bootinfo.reserved_mem.bank[i].start; + paddr_t r_e = r_s + bootinfo.reserved_mem.bank[i].size; + + if ( s < r_e && r_s < e ) + { + dt_unreserved_regions(r_e, e, cb, i + 1); + dt_unreserved_regions(s, r_s, cb, i + 1); + return; + } + } + + /* + * i is the current reserved RAM banks we are evaluating across all + * possible kinds. + * + * When retrieving the corresponding static-memory bank address + * below, we need to index the bootinfo.static_mem starting + * from 0, and only counting the static-memory bank. Hence, + * we need to use i - nr_reserved. + */ + + i = i - nr_reserved; + nr_static = bootinfo.static_mem.nr_banks; + for ( ; i < nr_static; i++ ) + { + paddr_t r_s = bootinfo.static_mem.bank[i].start; + paddr_t r_e = r_s + bootinfo.static_mem.bank[i].size; if ( s < r_e && r_s < e ) { From patchwork Tue May 18 05:21:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12263547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47670C433ED for ; Tue, 18 May 2021 05:22:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EF1366100A for ; Tue, 18 May 2021 05:22:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF1366100A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.128617.241457 (Exim 4.92) (envelope-from ) id 1lisB9-0001Oo-9j; Tue, 18 May 2021 05:22:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 128617.241457; Tue, 18 May 2021 05:22: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 1lisB9-0001Mc-32; Tue, 18 May 2021 05:22:03 +0000 Received: by outflank-mailman (input) for mailman id 128617; Tue, 18 May 2021 05:22:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisB7-00019F-Ot for xen-devel@lists.xenproject.org; Tue, 18 May 2021 05:22:01 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (unknown [40.107.22.56]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 22c98885-b59f-492a-a86c-5ea2549982ed; Tue, 18 May 2021 05:21:59 +0000 (UTC) Received: from AM6P193CA0064.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::41) by DB8PR08MB5290.eurprd08.prod.outlook.com (2603:10a6:10:a5::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.31; Tue, 18 May 2021 05:21:57 +0000 Received: from AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8e:cafe::ee) by AM6P193CA0064.outlook.office365.com (2603:10a6:209:8e::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:21:57 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT043.mail.protection.outlook.com (10.152.17.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:56 +0000 Received: ("Tessian outbound 504317ef584c:v92"); Tue, 18 May 2021 05:21:56 +0000 Received: from e49ec5f258b2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 44D1C212-83AF-41CD-A324-6BDCCE7C1ADB.1; Tue, 18 May 2021 05:21:50 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e49ec5f258b2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 May 2021 05:21:50 +0000 Received: from AM6P194CA0017.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::30) by AM0PR08MB3474.eurprd08.prod.outlook.com (2603:10a6:208:e1::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Tue, 18 May 2021 05:21:49 +0000 Received: from VE1EUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::5c) by AM6P194CA0017.outlook.office365.com (2603:10a6:209:90::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:21:49 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT005.mail.protection.outlook.com (10.152.18.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:49 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2176.14; Tue, 18 May 2021 05:21:38 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 18 May 2021 05:21: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: 22c98885-b59f-492a-a86c-5ea2549982ed 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=5J8iLZFedAFmS+5HNJIXYA28hBbm27AI3WM5PMpmaN0=; b=x/GM7FDAFvwaDYzkBoyoH2VUTNak9wEY9n1pmmndAdQiLuX/OlmfqO+uxxJL7C8aUtDu73Xjqopo+/trgvc9ULO6yHcn8puL9e79O8/8PZnEnlw8Dbo/EjRVInR1RJy6RxvVjGVcYkODFrh3bSI1NDXmSVs3tRqnqf6HxSoqVio= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; 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: 1936533a0e7f1746 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AYFQ8chCOUp825RgWfo00oWm/7pxUUD3VTpMLkX/ugTVvHvEwY1ol10k7xB6jEjZl9ml8DaKZQztCdK+J2BzqKVvQcyFwCPJbq95S1CqH/OnlYaZn00kCjTaqCVmilYmURpXzM8X/iLhYgNCcFbG7W6tlOuWP1mCEmuGIVIW+3i9fnxqdKIixuX8qhygoMi1N4IxJFcOsLI7DVIEn6iK8El2Pm2XIGd4EI9gzeD9Mp0C9XoGysjexHDT+Tg/Wl1aImWW6rJacauVkLWyUZUNyT8hNlWXbO/X9D1vH0nnw03BDObtBoF99ZAFcGUji6OSsi+wYcdKY3fE10iMPrrP7g== 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-SenderADCheck; bh=5J8iLZFedAFmS+5HNJIXYA28hBbm27AI3WM5PMpmaN0=; b=CuRjXJqhjRQklzzSdIcUwefl5iFeEXgd2iWCTJoZZDnv97tMObotAD6S3ksm9tZsFGJlcgq78u7voAYsMHfokQXEiyiDDu4ZqJeXlIBZAgK82HCCxViNRUsZV8sivFHnTHwLNZtpkDLOyW/XwIMXA5C2PwG+hv7xmrNYoQImsd61hPYwjRdeMXZ/c+dIGqWyYOsRH1+KuLfJYLO44C0bVaaRI0MvpEg4PuOJySBWLQmCjf+iXYtYto2f/+a79C/AT3y0hdigfWyC647W/vEJpsAUnSTkhda6rxaaaqZxgFFnzqvdk+JtUaDAd6/+8l5fcJXoTrg0hi4c2z/4B8Unyw== 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=5J8iLZFedAFmS+5HNJIXYA28hBbm27AI3WM5PMpmaN0=; b=x/GM7FDAFvwaDYzkBoyoH2VUTNak9wEY9n1pmmndAdQiLuX/OlmfqO+uxxJL7C8aUtDu73Xjqopo+/trgvc9ULO6yHcn8puL9e79O8/8PZnEnlw8Dbo/EjRVInR1RJy6RxvVjGVcYkODFrh3bSI1NDXmSVs3tRqnqf6HxSoqVio= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; 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 03/10] xen/arm: introduce PGC_reserved Date: Tue, 18 May 2021 05:21:06 +0000 Message-ID: <20210518052113.725808-4-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518052113.725808-1-penny.zheng@arm.com> References: <20210518052113.725808-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17dbf392-8957-448f-c17e-08d919bcdb1a X-MS-TrafficTypeDiagnostic: AM0PR08MB3474:|DB8PR08MB5290: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2733;OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: IOZYbxKdCQYup2rYlh5fjDhoVqa58RYI7xubtEg5OOX0KLU96wxhLLghb5MzADeNKQADqP4G06dS5hJTSLIfc5phB4/m8Tt0AQwjKUF8I5/g8aGGRIH7PFUSdvVnoIspJsRcq9+7ZfucR9hE0b/C+n/rIfFpGoOggzNasBU44JtiGDBIue3s8fxMo4GURX3C8uhmn5Kq4/MLZeX/YAx4ppDIHH0Bw6M4++vwJpqkIM/cW1kEbvdUPgbL0fwgo0LFoCNrzJI/gZ90RvpfqBOxHhQa/jwYvDDlxKJD04GGKWqr4jZXCypmXI8MxAqPF3JloTwJjvZF8Ta4XmRBn93YyQtpOyKTpnrXTcIVU3wgj4+h6cpY1yR7FTr5vLHYxNTOBBuZP0mIgGpvkc37B8DuNJn/V0cDYHBlH4x4Fc8RhEhZvcBIcXYMNYKQNSYLOkqlWhctqZJUVETK2aR/DFsRjTuhlaLSATa2qcNmbA18Wf0a9vubjDOtZbrXEnq6uTxBwYikMXiirtXqSW5FUCNGmQV9upCUyOes0F9t47w1SSQBIW4gzkIl0zGvpcv8GV6/KxMvVdDe20sEHH2dZV6BBw8lBHVF3Ze7FKNsLJ81k2G/Hxwb6KpVomcL9CJQ3FOwLuMlhC4jxm09pzPpjVOq17mkIZX5OpRghmlLp1806ABr42P7CUlJoYIXG7uFGh6X 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)(376002)(346002)(136003)(39850400004)(396003)(46966006)(36840700001)(316002)(86362001)(81166007)(186003)(1076003)(8676002)(110136005)(82740400003)(478600001)(47076005)(8936002)(426003)(36756003)(70206006)(83380400001)(356005)(5660300002)(54906003)(2906002)(82310400003)(336012)(70586007)(4326008)(7696005)(6666004)(44832011)(26005)(2616005)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3474 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ea7cf5e5-212b-48a1-a2d4-08d919bcd677 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tMXJaSvyh+X49EXeU+Ko9a/5bIpUQNTDPZjWdefmLpouE++uFU5Wdt9qRgkqMuVlpFPM0vo/YIWL57p22Tr7WyoYPejBlHkjiYADHIsfFO+iVURIT8rd9QdQYuP8u6tRZiP/kjwKpd1FtuhQKbhAAH00F80bTXuOVKV47VccHzA0k8U+LfhIzvGb/D9V09laVSkNqcJUogcN0tHnhjx4N/ClXmLmgfldlxBWCGwlU2fz/zsp0qPjmQKUhIQ5KxjI0Co5Qv2Aj86LNY+0E17/73zqmHLZFXIhruI643mbCNBw55F1ixsfre1Ls5ESlO+NOgkLJURIVQeQK+pRKBMRU65bGlKAPMKPSST8pBhZZdW8kdzsInEt4C+s1mg9ra/4Y9tn10LWLORSTu2i9WU5T46nbuIQJRPzd9vblOta2qf7bdSlBY86IERrD/yhua/YD06h54ozia2dIsNT3isYw0hXIbf60tX7ljE+rLJLlqx3P3DvCDx6c33R0rc0EujQoOADr6evIn2860DGUKqD1TwEMZoUDc5qxuY+gNLpgmcDhBi+EgwTNmRkaQ4aV1Lnp2/Ry0xYoWEnEBe1VoEDfXKQjZKlcUJk/BE25XN5O91PDuEoOZ8kS5lGEG2OA0luUJIbl/JTixX8RqYLR9NLc6CWMNtc83yR0ab+gGFqbqA= 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)(346002)(396003)(136003)(39850400004)(376002)(46966006)(36840700001)(110136005)(26005)(81166007)(7696005)(82310400003)(478600001)(83380400001)(70586007)(316002)(70206006)(4326008)(36860700001)(47076005)(186003)(82740400003)(2616005)(1076003)(426003)(5660300002)(336012)(8676002)(44832011)(6666004)(86362001)(2906002)(36756003)(8936002)(54906003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 05:21:56.9625 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17dbf392-8957-448f-c17e-08d919bcdb1a 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: AM5EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5290 In order to differentiate pages of static memory, from those allocated from heap, this patch introduces a new page flag PGC_reserved to tell. New struct reserved in struct page_info is to describe reserved page info, that is, which specific domain this page is reserved to. Helper page_get_reserved_owner and page_set_reserved_owner are designated to get/set reserved page's owner. Struct domain is enlarged to more than PAGE_SIZE, due to newly-imported struct reserved in struct page_info. Signed-off-by: Penny Zheng --- xen/include/asm-arm/mm.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 0b7de3102e..d8922fd5db 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -88,7 +88,15 @@ struct page_info */ u32 tlbflush_timestamp; }; - u64 pad; + + /* Page is reserved. */ + struct { + /* + * Reserved Owner of this page, + * if this page is reserved to a specific domain. + */ + struct domain *domain; + } reserved; }; #define PG_shift(idx) (BITS_PER_LONG - (idx)) @@ -108,6 +116,9 @@ struct page_info /* Page is Xen heap? */ #define _PGC_xen_heap PG_shift(2) #define PGC_xen_heap PG_mask(1, 2) + /* Page is reserved, referring static memory */ +#define _PGC_reserved PG_shift(3) +#define PGC_reserved PG_mask(1, 3) /* ... */ /* Page is broken? */ #define _PGC_broken PG_shift(7) @@ -161,6 +172,9 @@ extern unsigned long xenheap_base_pdx; #define page_get_owner(_p) (_p)->v.inuse.domain #define page_set_owner(_p,_d) ((_p)->v.inuse.domain = (_d)) +#define page_get_reserved_owner(_p) (_p)->reserved.domain +#define page_set_reserved_owner(_p,_d) ((_p)->reserved.domain = (_d)) + #define maddr_get_owner(ma) (page_get_owner(maddr_to_page((ma)))) #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START) From patchwork Tue May 18 05:21:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12263541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D073C433ED for ; Tue, 18 May 2021 05:22:05 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2540B61363 for ; Tue, 18 May 2021 05:22:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2540B61363 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.128614.241434 (Exim 4.92) (envelope-from ) id 1lisB2-0000p9-SH; Tue, 18 May 2021 05:21:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 128614.241434; Tue, 18 May 2021 05:21:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisB2-0000ov-OO; Tue, 18 May 2021 05:21:56 +0000 Received: by outflank-mailman (input) for mailman id 128614; Tue, 18 May 2021 05:21:56 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisB2-0000oV-7N for xen-devel@lists.xenproject.org; Tue, 18 May 2021 05:21:56 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (unknown [40.107.1.83]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c87f45e4-de27-4076-a08c-d183282498bb; Tue, 18 May 2021 05:21:54 +0000 (UTC) Received: from DB7PR05CA0038.eurprd05.prod.outlook.com (2603:10a6:10:2e::15) by AS8PR08MB6085.eurprd08.prod.outlook.com (2603:10a6:20b:294::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Tue, 18 May 2021 05:21:50 +0000 Received: from DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2e:cafe::15) by DB7PR05CA0038.outlook.office365.com (2603:10a6:10:2e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.32 via Frontend Transport; Tue, 18 May 2021 05:21:50 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT031.mail.protection.outlook.com (10.152.20.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:50 +0000 Received: ("Tessian outbound 3050e7a5b95d:v92"); Tue, 18 May 2021 05:21:50 +0000 Received: from b27086a73afc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0594D1CA-7287-4677-9637-438FA4D7785C.1; Tue, 18 May 2021 05:21:44 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b27086a73afc.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 May 2021 05:21:44 +0000 Received: from AM6PR01CA0056.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::33) by AM6PR08MB4375.eurprd08.prod.outlook.com (2603:10a6:20b:b8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:21:43 +0000 Received: from AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:e0:cafe::3d) by AM6PR01CA0056.outlook.office365.com (2603:10a6:20b:e0::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:21:43 +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.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:42 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2176.14; Tue, 18 May 2021 05:21:41 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 18 May 2021 05:21:39 +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: c87f45e4-de27-4076-a08c-d183282498bb 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=2KQQ4ZqD+jOLvYXqT3cXJP1kPDbk4rROsPwkwbO9YKo=; b=JDxdlW6xBOBhuFREHdVyEtA595DeKXvfGAFemmyD6FMPYnhp0UhVhYTVDbof/OqnzfUbdW6OJUI/rF8vAFUxP3L8zAyO3AEoWGQs7k7mDczENsqHas6lTW85XEd6JcM0lr/jkLzd2QICTUX0r8VufLsZQ8APz/cbN/N34ryzRtw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; 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: c2b47eb8e8d018e7 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HIoFZcaTw40XFy6IMbUwZU+b6LayTkxP6PqLFXnLsiM7qiG7FWiC1Kd2J/ERk7vRPKOjIpZ/9R9tr8c3MclK9CGxc/4+oTjt9lNKo2I+LjKCAdBaMwa3TTTO4SUeMQNHgfMiVrnvD4SDSaFUxlUugk7PEaU1ZlR+yUblS7gpqO6/F3n0I7NE96K3AEQeT7NXs4s86W9n2w7ETZRYmiAiDpA1b27RLmzXpM001ZfGN8G7UHpk+KEkahSWbcWYJuc5NKnf5xhjW9N21tmHp7G8DpfQSAZ7ZpJpsY9NGmR6Uug3213g5SSNv+mmM+lTNi7kDOMt4HbIdWt5ZupJnAnkxw== 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-SenderADCheck; bh=2KQQ4ZqD+jOLvYXqT3cXJP1kPDbk4rROsPwkwbO9YKo=; b=CTWbuMTF9penajP0yGvz2bkMJLud6CusF9oU+YDEXOswSv8quczqFaM4Z0eyqOYo7psmAq4YU5SiMfX0pkXJ5QwGrmAyjT5+TqCci1kD4vZWY/GTeD1Gkq2XwOEi+rbK+UsNSmoNk95fK8rzt8Mwa4cC97J9VBFdxEwyH33IvOlwCx64YQjp4zoK0OF0veV+N8nXXhjGJzAUJeHHgvOecdtGB84fo6lMkJPgjrhkdAew9gUz4AljsAI2ySSAaOTgC1EzeIlu0S3umM8CUrOhDAPuSmj61LPrDcxeIXtCDvuuIT5ZrZB1OazzkUsReHgb5Y3K1CI13weU/HfasyJ5wQ== 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=2KQQ4ZqD+jOLvYXqT3cXJP1kPDbk4rROsPwkwbO9YKo=; b=JDxdlW6xBOBhuFREHdVyEtA595DeKXvfGAFemmyD6FMPYnhp0UhVhYTVDbof/OqnzfUbdW6OJUI/rF8vAFUxP3L8zAyO3AEoWGQs7k7mDczENsqHas6lTW85XEd6JcM0lr/jkLzd2QICTUX0r8VufLsZQ8APz/cbN/N34ryzRtw= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; 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 04/10] xen/arm: static memory initialization Date: Tue, 18 May 2021 05:21:07 +0000 Message-ID: <20210518052113.725808-5-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518052113.725808-1-penny.zheng@arm.com> References: <20210518052113.725808-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e33081cd-4603-415e-b2b6-08d919bcd740 X-MS-TrafficTypeDiagnostic: AM6PR08MB4375:|AS8PR08MB6085: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2582;OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 64H980U++Cmpl4LANGBOruWixAxgFkMB+Cuk3e94o+bRlXf9gsCAmZ2xUYWcSzn3MQli481yWiTYFF1nMGrXH8qv8PvtjL+wE7mc5hzzRg0agpbLvX0EDfV4JyzFy3/+cPdi8OXoIpgrlglzZE4y57DcOGdczb5bdVWKbcLmEzRzJmvHRx7FGlA0QLG0HMjtM5oodFaIvE+2m+d+3oqidwCp8kyj1SX7wx2OHlrUZIcSpTjsSyD4ZZwxH8BIKKL0SDG4eBf5Kaln6/sQsiaZAs/ibHPYfM9FhadsP8rjb89JHrFt+wgp501rOmbqvBTafjdKY7QS505iIwWznb9cWVSEbw+BLn+uMn6lMSpmBNIYF2czhLgogB5DGPeTdyI65ru8wuT1XQdEPKhFG4uwcoyCZxRpyBJWuCv2aGhPRHU4mhprhZPCW7MY8I7Ynjzw86DF6GnrnorgbE+MDJ2Zq6qb/E88xCaea8IK10DLgIlFryVsy+QFcOwnuzUfJ3f/SphSZQDBL9YkkQGXm8Q1nq+WvYKp0cIK+zjGUD+OCpa4IlEA6XtYGJPTcfY8V9qhWSWpo6/GfHDmlp4wFavvna3NbfoRZBJzXA1yS1ga8ugcdkybet9XsI/y+gw16O9AG/pwjAe2FoYArf+hERkq02k0o0WzyiSG5zRuUEzxfVwMj1A4w+0ajVNWD8dduiBl 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)(346002)(376002)(396003)(136003)(39850400004)(36840700001)(46966006)(2906002)(6666004)(5660300002)(81166007)(82310400003)(36860700001)(36756003)(83380400001)(1076003)(70586007)(336012)(478600001)(4326008)(54906003)(426003)(7696005)(110136005)(44832011)(86362001)(316002)(356005)(186003)(8676002)(82740400003)(70206006)(8936002)(47076005)(26005)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4375 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 218a7176-d02e-4c49-bdc1-08d919bcd2b8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bCU5qWrBGZ0UCNeOC3pBXr/Nic6zWzCU9YSFdZGp4tlpF/8oVDW0T4d22KcOkNJko7/2HC3dejpTO4rhBFMY3FERG8Rk2ZMJxSp+ess3JmiPwcyBTvemvrXN/zMpaWVFFeXDoGQzfvJB23r/OjoeACZiigogl1vrORr0+yaxl09Pwb8o/eKKFzNLJvKITCV7Dj9TVPHqu7GLB9PX4h/wvdasPpSpY/uxg666zkunVs+mriVwvia2u3sQ4UwjS6cusV8HDVq5YcH9KRE4SjaT+ACVeb8Mu5tqdp11ceaRf6811kiuu8xTxD9/+V4ZFIIuWI3Pyt4aDHKQOspD0nB7JLRe8JpbmYUzwdmaIjO4SzPZrCddVr1YDeI/f7tLSXQEjrzDkNog289PGGcZOh657/iMVZ3wU/YF4oZ40dclbuFyId70yirk0JLZ6uavlvlEY+PzY3wv4+KU+i/OZi2wCpHhwJUVgBj6jjathmVWKJ9SinsJvi/8iZvIIc8aw5LSNjx3v0e1K23XjoLtFH8Jqzb3aHo6lVuVCXdgVoyI8Oeoy/Z1wkdrD+d0cJD4NE8RaiH5XMQI1MJXVWQfYScFE29jIW/jdCJdMy43HE1+Anzw2imKkak29Mh5VaiSNdM7xruudtP2eo5amhomNgLEnE5VastPE7ofeQpSzEARasg= 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)(396003)(39850400004)(346002)(136003)(376002)(36840700001)(46966006)(86362001)(4326008)(36860700001)(6666004)(2906002)(2616005)(70206006)(478600001)(70586007)(8676002)(5660300002)(8936002)(82740400003)(36756003)(316002)(110136005)(426003)(186003)(1076003)(44832011)(81166007)(82310400003)(26005)(47076005)(83380400001)(7696005)(336012)(54906003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 05:21:50.5453 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e33081cd-4603-415e-b2b6-08d919bcd740 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: DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6085 This patch introduces static memory initialization, during system RAM boot up. New func init_staticmem_pages is the equivalent of init_heap_pages, responsible for static memory initialization. Helper func free_staticmem_pages is the equivalent of free_heap_pages, to free nr_pfns pages of static memory. For each page, it includes the following steps: 1. change page state from in-use(also initialization state) to free state and grant PGC_reserved. 2. set its owner NULL and make sure this page is not a guest frame any more 3. follow the same cache coherency policy in free_heap_pages 4. scrub the page in need Signed-off-by: Penny Zheng --- xen/arch/arm/setup.c | 2 ++ xen/common/page_alloc.c | 70 +++++++++++++++++++++++++++++++++++++++++ xen/include/xen/mm.h | 3 ++ 3 files changed, 75 insertions(+) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 444dbbd676..f80162c478 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -818,6 +818,8 @@ static void __init setup_mm(void) setup_frametable_mappings(ram_start, ram_end); max_page = PFN_DOWN(ram_end); + + init_staticmem_pages(); } #endif diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index ace6333c18..58b53c6ac2 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -150,6 +150,9 @@ #define p2m_pod_offline_or_broken_hit(pg) 0 #define p2m_pod_offline_or_broken_replace(pg) BUG_ON(pg != NULL) #endif +#ifdef CONFIG_ARM_64 +#include +#endif /* * Comma-separated list of hexadecimal page numbers containing bad bytes. @@ -1512,6 +1515,49 @@ static void free_heap_pages( spin_unlock(&heap_lock); } +/* Equivalent of free_heap_pages to free nr_pfns pages of static memory. */ +static void free_staticmem_pages(struct page_info *pg, unsigned long nr_pfns, + bool need_scrub) +{ + mfn_t mfn = page_to_mfn(pg); + int i; + + for ( i = 0; i < nr_pfns; i++ ) + { + switch ( pg[i].count_info & PGC_state ) + { + case PGC_state_inuse: + BUG_ON(pg[i].count_info & PGC_broken); + /* Make it free and reserved. */ + pg[i].count_info = PGC_state_free | PGC_reserved; + break; + + default: + printk(XENLOG_ERR + "Page state shall be only in PGC_state_inuse. " + "pg[%u] MFN %"PRI_mfn" count_info=%#lx tlbflush_timestamp=%#x.\n", + i, mfn_x(mfn) + i, + pg[i].count_info, + pg[i].tlbflush_timestamp); + BUG(); + } + + /* + * Follow the same cache coherence scheme in free_heap_pages. + * If a page has no owner it will need no safety TLB flush. + */ + pg[i].u.free.need_tlbflush = (page_get_owner(&pg[i]) != NULL); + if ( pg[i].u.free.need_tlbflush ) + page_set_tlbflush_timestamp(&pg[i]); + + /* This page is not a guest frame any more. */ + page_set_owner(&pg[i], NULL); + set_gpfn_from_mfn(mfn_x(mfn) + i, INVALID_M2P_ENTRY); + + if ( need_scrub ) + scrub_one_page(&pg[i]); + } +} /* * Following rules applied for page offline: @@ -1828,6 +1874,30 @@ static void init_heap_pages( } } +/* Equivalent of init_heap_pages to do static memory initialization */ +void __init init_staticmem_pages(void) +{ + int bank; + + /* + * TODO: Considering NUMA-support scenario. + */ + for ( bank = 0 ; bank < bootinfo.static_mem.nr_banks; bank++ ) + { + paddr_t bank_start = bootinfo.static_mem.bank[bank].start; + paddr_t bank_size = bootinfo.static_mem.bank[bank].size; + paddr_t bank_end = bank_start + bank_size; + + bank_start = round_pgup(bank_start); + bank_end = round_pgdown(bank_end); + if ( bank_end <= bank_start ) + return; + + free_staticmem_pages(maddr_to_page(bank_start), + (bank_end - bank_start) >> PAGE_SHIFT, false); + } +} + static unsigned long avail_heap_pages( unsigned int zone_lo, unsigned int zone_hi, unsigned int node) { diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 667f9dac83..8b1a2207b2 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -85,6 +85,9 @@ bool scrub_free_pages(void); } while ( false ) #define FREE_XENHEAP_PAGE(p) FREE_XENHEAP_PAGES(p, 0) +/* Static Memory */ +void init_staticmem_pages(void); + /* Map machine page range in Xen virtual address space. */ int map_pages_to_xen( unsigned long virt, From patchwork Tue May 18 05:21:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12263551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8C9DC433ED for ; Tue, 18 May 2021 05:22:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6A8F56108B for ; Tue, 18 May 2021 05:22:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A8F56108B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.128620.241489 (Exim 4.92) (envelope-from ) id 1lisBI-0002ia-4N; Tue, 18 May 2021 05:22:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 128620.241489; Tue, 18 May 2021 05:22: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 1lisBH-0002i4-Ul; Tue, 18 May 2021 05:22:11 +0000 Received: by outflank-mailman (input) for mailman id 128620; Tue, 18 May 2021 05:22:11 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisBH-00019F-6x for xen-devel@lists.xenproject.org; Tue, 18 May 2021 05:22:11 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.82]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ffbe51d9-08e8-430c-b575-47a5bd832918; Tue, 18 May 2021 05:22:01 +0000 (UTC) Received: from AM6PR05CA0032.eurprd05.prod.outlook.com (2603:10a6:20b:2e::45) by DBAPR08MB5830.eurprd08.prod.outlook.com (2603:10a6:10:1a7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:21:57 +0000 Received: from VE1EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::88) by AM6PR05CA0032.outlook.office365.com (2603:10a6:20b:2e::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:21:56 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT020.mail.protection.outlook.com (10.152.18.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:56 +0000 Received: ("Tessian outbound ea2c9a942a09:v92"); Tue, 18 May 2021 05:21:56 +0000 Received: from a5edd8368e23.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C1CEBFC5-4D84-47DC-8713-CC85463C7614.1; Tue, 18 May 2021 05:21:50 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a5edd8368e23.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 May 2021 05:21:50 +0000 Received: from AM6PR01CA0047.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::24) by AM8PR08MB6546.eurprd08.prod.outlook.com (2603:10a6:20b:355::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:21:47 +0000 Received: from AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:e0:cafe::23) by AM6PR01CA0047.outlook.office365.com (2603:10a6:20b:e0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:47 +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.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:46 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2176.14; Tue, 18 May 2021 05:21:43 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 18 May 2021 05:21: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: ffbe51d9-08e8-430c-b575-47a5bd832918 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=mWXR0/xvkg8fl1DOrhLwDN/UAdqmRXxJdB80UDoJgTw=; b=zRqFKgfhKUrXm0Zrx6A5JsqiASeNTzkjJxXJ4sGhNS3J2GDfriW223+WDbWrLN96Mk2v9vhwnm4Zz7dd1b+OubdicpgLKOAglqFF3j2JYY4HGS+p3LswDbtauY2m2jbDLqiHljGzg3izgZfh9Yh+kWiAm75P9Qi+HJ9QGs/gjL4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; 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: 0465a10a71ce3249 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iP3BGCR0fld0pDZE3tSsUgSe8073ZIiIzLijEvu1Ik9Fx4BjGBMUJdnFfNLIFR+tYffnRyWEFWrwZv3ymuiZdrGWmHPuawUt90XafcAnHVwAbC0TLknxWAOm1r6l+fbBB3ry8xa2Oss1pnSPL9z/rwNGeA1o/yLqNTG5olwyn792rIs8LTK6hfxEKHVZpdCM46curYQwk83bkKutDcsU8A0G9e0b5mvClvkWPOg9Ta0oXGqR/T8OTnsQQiWr846kV1CeKGKHUcOUO/IgLA5tcC4Z/XhoMefP3acip2JTx/rbI7fcFoaSLV9Wo7B1zLHWoaMEDeDbm6chWSEIdx97lw== 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-SenderADCheck; bh=mWXR0/xvkg8fl1DOrhLwDN/UAdqmRXxJdB80UDoJgTw=; b=iquAEduFif0g/09hNY2aabYW+y+n95Q6Ja77IWClB5+KtU+6/QZHdhN6ArYCEVgBYwsCLpEFpZdSK442MBZtFTaD0j2tdD6E7rqmW+aCoxHfIZNMCcUYUwfYKN7EHDcSDVXxAjDyF2eOVSe0x5f9sLd34muLHMF8jee6edrFPRxiNmYEgCs8WF7gcaoAu81KFoNMYr5d7KYTNgva+T/9NadNBCBKDgfYdNtbpWiCQqFCXEDyqk09iDjWN/fwrj7jolwxZWe2R7p4a9StR696GrKcRcdOIzkgU2xxWa3hw4/WD+DXyP3RN5rzjGyEUcZQagRFo81kBsP8bgwMRNpMzA== 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=mWXR0/xvkg8fl1DOrhLwDN/UAdqmRXxJdB80UDoJgTw=; b=zRqFKgfhKUrXm0Zrx6A5JsqiASeNTzkjJxXJ4sGhNS3J2GDfriW223+WDbWrLN96Mk2v9vhwnm4Zz7dd1b+OubdicpgLKOAglqFF3j2JYY4HGS+p3LswDbtauY2m2jbDLqiHljGzg3izgZfh9Yh+kWiAm75P9Qi+HJ9QGs/gjL4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; 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 05/10] xen/arm: introduce alloc_staticmem_pages Date: Tue, 18 May 2021 05:21:08 +0000 Message-ID: <20210518052113.725808-6-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518052113.725808-1-penny.zheng@arm.com> References: <20210518052113.725808-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 367e8842-5f01-42d4-9d80-08d919bcdade X-MS-TrafficTypeDiagnostic: AM8PR08MB6546:|DBAPR08MB5830: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:64;OLM:64; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: pozjuBEdLJWPLQ2j9pjfaBPDvZUqeVcREMpRtm7y+CZHk5iokvwhVnvZisXUL6dfcXjnDfcwann0iTr8MP37hcWn2pqkE0j5P5euUg02bi3cLs+EXqkhvvpJK71dULaWxMVkRVaA1ZP1QQherNxP5mhzWUqQoDcLnWqwuwzAZ8A6sDtCiY7sx1qpFrFGL7a/6mwdbY6K/ZZVCWbmgltde9C7rp+j1NchVOxlb3lBEF4aSLC3FN8czNIfO7O8E7rFc7KwnMm5pmc7IapLAHfPTgrmtMLpXL4nfbFsmtKbt5uIxeU75AZJ5HFuE891UT4D65fojiKqpTYOXm7g1kWz/ksYh0GG8vN4+9x/2zPVIXQnaVmZyLrtd2E62nAfhCTpDfKn7lyyqupLXWU0Tuu89O+ArGk8KvtXd0rTwcZHWkUge04aJUgyfNuF9oH+MKOXxhzTgLrPAFYms0MS/bOq50aUr159QVmraqMRtLpt7RPDEwu0aVUUxuB8e9brlXdGL0QtgZMaLwpa7QsVRdGWA7G56XnEHErUoMDcTLivWdyNu/5NrO3fHjAmf9NW/snbecATPIFWRir5XYfQpNHIp5SvRDRoKdR1L13LwIekb1Pihg7gTb6e58dK3KoJrYbKg3d/SuQH1Z9TUw30b3W7znd6JGUw7pb9I4BpC7pnMiWKrWar6gQjeeJSzEudUaHP 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)(346002)(136003)(376002)(39850400004)(396003)(36840700001)(46966006)(82740400003)(6666004)(86362001)(8936002)(70206006)(4326008)(1076003)(8676002)(47076005)(44832011)(110136005)(426003)(7696005)(36756003)(70586007)(26005)(82310400003)(478600001)(186003)(316002)(2906002)(5660300002)(2616005)(81166007)(54906003)(336012)(36860700001)(356005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6546 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 1a1bd56a-c0ee-4be3-a05a-08d919bcd50a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cx00cHDr2xGlzBf5u9DoopmiCjUE/x1kBXiXQcgUpQG0rHSrk2DcWZZoShvIcTZEFA0VVeX1jdbkdkwrQpLNNoKj2V0Kk5wFfVPRB4ovhsj27tu9ub788+AKQk1uyU5poUjLyGUTjcrG61BgvEu0W992PP/l+Zoru1XNLtOOgioMrful4dQWFuKoUu0TJYaX0FnMeWY8D0V0BsUt3Cbvezv6DmhELMpDmgPNvrhYmRRZPV8vO4/yydRDZA2vXhE56YhMtL7J530XVyWQc27PwbChDpNjGobAGlzu6SYo7bhKPTrfrnOXYsENpTSzVGMMKXgYBTizO/EYpJRdWfiKzlokmmDbdzXuTUtuwfOep1/ipdJx/COJ0Mcx81QtrnRtoDLr4Gs5n1E+ifsm/WYKtOLbVwllW0tMzw9rOINDBppH5myu8Yjdj1PQ9mn+4+vqd+O/OyUiRXkTFZKQAXfHF693awjVto5pacPyM5mfmgNHNKo4xCtr7DGm97SccypoqhpJRsPp6CUXm7CbjYHA3Gdx7QQX8lgctREq/cG9nolUcT3RBU9RbcTNOYtgycHe8rbPkXQmp4n7V9qkOETDqzhnKg43fVM+rsjgbkReCmZhM6kqp6szg+46J/l+mlFBOPgZLHq4LlYKOl0Pl2d72w== 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)(39850400004)(396003)(136003)(346002)(376002)(36840700001)(46966006)(316002)(2616005)(426003)(8676002)(82310400003)(86362001)(47076005)(36860700001)(1076003)(70586007)(81166007)(478600001)(6666004)(8936002)(110136005)(7696005)(186003)(82740400003)(5660300002)(4326008)(2906002)(36756003)(54906003)(70206006)(26005)(336012)(44832011);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 05:21:56.4844 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 367e8842-5f01-42d4-9d80-08d919bcdade 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: VE1EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5830 alloc_staticmem_pages is designated to allocate nr_pfns contiguous pages of static memory. And it is the equivalent of alloc_heap_pages for static memory. This commit only covers allocating at specified starting address. For each page, it shall check if the page is reserved (PGC_reserved) and free. It shall also do a set of necessary initialization, which are mostly the same ones in alloc_heap_pages, like, following the same cache-coherency policy and turning page status into PGC_state_used, etc. Signed-off-by: Penny Zheng --- xen/common/page_alloc.c | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 58b53c6ac2..adf2889e76 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1068,6 +1068,70 @@ static struct page_info *alloc_heap_pages( return pg; } +/* + * Allocate nr_pfns contiguous pages, starting at #start, of static memory. + * It is the equivalent of alloc_heap_pages for static memory + */ +static struct page_info *alloc_staticmem_pages(unsigned long nr_pfns, + paddr_t start, + unsigned int memflags) +{ + bool need_tlbflush = false; + uint32_t tlbflush_timestamp = 0; + unsigned int i; + struct page_info *pg; + mfn_t s_mfn; + + /* For now, it only supports allocating at specified address. */ + s_mfn = maddr_to_mfn(start); + pg = mfn_to_page(s_mfn); + if ( !pg ) + return NULL; + + for ( i = 0; i < nr_pfns; i++) + { + /* + * Reference count must continuously be zero for free pages + * of static memory(PGC_reserved). + */ + ASSERT(pg[i].count_info & PGC_reserved); + if ( (pg[i].count_info & ~PGC_reserved) != PGC_state_free ) + { + printk(XENLOG_ERR + "Reference count must continuously be zero for free pages" + "pg[%u] MFN %"PRI_mfn" c=%#lx t=%#x\n", + i, mfn_x(page_to_mfn(pg + i)), + pg[i].count_info, pg[i].tlbflush_timestamp); + BUG(); + } + + if ( !(memflags & MEMF_no_tlbflush) ) + accumulate_tlbflush(&need_tlbflush, &pg[i], + &tlbflush_timestamp); + + /* + * Reserve flag PGC_reserved and change page state + * to PGC_state_inuse. + */ + pg[i].count_info = (pg[i].count_info & PGC_reserved) | PGC_state_inuse; + /* Initialise fields which have other uses for free pages. */ + pg[i].u.inuse.type_info = 0; + page_set_owner(&pg[i], NULL); + + /* + * Ensure cache and RAM are consistent for platforms where the + * guest can control its own visibility of/through the cache. + */ + flush_page_to_ram(mfn_x(page_to_mfn(&pg[i])), + !(memflags & MEMF_no_icache_flush)); + } + + if ( need_tlbflush ) + filtered_flush_tlb_mask(tlbflush_timestamp); + + return pg; +} + /* Remove any offlined page in the buddy pointed to by head. */ static int reserve_offlined_page(struct page_info *head) { From patchwork Tue May 18 05:21:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12263545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB26BC43460 for ; Tue, 18 May 2021 05:22:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7EDEC6108B for ; Tue, 18 May 2021 05:22:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EDEC6108B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.128616.241451 (Exim 4.92) (envelope-from ) id 1lisB8-0001EH-OM; Tue, 18 May 2021 05:22:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 128616.241451; Tue, 18 May 2021 05:22:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisB8-0001DC-Ey; Tue, 18 May 2021 05:22:02 +0000 Received: by outflank-mailman (input) for mailman id 128616; Tue, 18 May 2021 05:22:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisB7-00019F-7s for xen-devel@lists.xenproject.org; Tue, 18 May 2021 05:22:01 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.54]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e7776fe5-c659-4fa9-bae3-6038b9f1d11b; Tue, 18 May 2021 05:21:59 +0000 (UTC) Received: from AM6PR08CA0035.eurprd08.prod.outlook.com (2603:10a6:20b:c0::23) by DB7PR08MB3852.eurprd08.prod.outlook.com (2603:10a6:10:7f::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Tue, 18 May 2021 05:21:57 +0000 Received: from AM5EUR03FT006.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:c0:cafe::cc) by AM6PR08CA0035.outlook.office365.com (2603:10a6:20b:c0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:21:57 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT006.mail.protection.outlook.com (10.152.16.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:57 +0000 Received: ("Tessian outbound 6c8a2be3c2e7:v92"); Tue, 18 May 2021 05:21:57 +0000 Received: from 58d3c760b65e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8281B599-D76D-4C7B-907F-0008096FA724.1; Tue, 18 May 2021 05:21:50 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 58d3c760b65e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 May 2021 05:21:50 +0000 Received: from AM6PR01CA0048.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::25) by PAXPR08MB6986.eurprd08.prod.outlook.com (2603:10a6:102:1de::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:21:49 +0000 Received: from AM5EUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:e0:cafe::71) by AM6PR01CA0048.outlook.office365.com (2603:10a6:20b:e0::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:21:49 +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.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:49 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2176.14; Tue, 18 May 2021 05:21:46 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 18 May 2021 05:21:44 +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: e7776fe5-c659-4fa9-bae3-6038b9f1d11b 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=QirTiM5BMFqVEm2akRsnyKmv1ZPwRYUKo4oLM4omp7M=; b=6cv8kmt+/cThiBqyQqFikKTfM1ITBUInNckkOehGk2AmAjlkK37LdGGt7XaoAZZvnr/mZqQdyY3AuiOeB9L7zrnKlb9FHbXvPQXq5Mx/XqV/ohXhQ9BHasIDWS01nMplPBXOBctWv9Bqn/xCS8YvHCVs7s6zTui/iAWrP/kJmvk= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; 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: 7b81643dc9652aef X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OldNX2vr0OfF/2CaQzl8FkQu0fxRpLNUJ5jq5NCrCnGCZAdox1GAL1jIp+NnHYeBT/+VrsgMiCcohUsMY7GG76ri15uJ/A1lQzTItr4OwsBJt8rqIROEGLnYOY1voY6eNAbfttUPAF/iTbB6wgWOwACeVHlQM+mrytAZhrbPJx+B9Wz2yqRGko1/XAu03x7bETOjsg/AEOZQ/TQj12F30u8OEUj8wfoeAajYeqwz6+WuldA4v8x9vjk8rjLRllBQCKU+NSWJmaTQ6OJWi7mdWVaDnONYrh7fwaRGISWAIrIcyJmVXph/A+ZVxHyIvgx7/9UDUCQmg3P7pnO00jpldA== 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-SenderADCheck; bh=QirTiM5BMFqVEm2akRsnyKmv1ZPwRYUKo4oLM4omp7M=; b=HMYz6EH1/lZGqkBIJszMxDiow+xGMT+9F/oNnJVIqH7SosT//jORLs/0bIV1x6PYYk9s3tIyAeRXV+NPCjJcMEi6PHkDL2lEVrSe6CkD+jRNaZDMubYm28JCrffx4NErGywXo9GLowv6RjyVeD0N7dxWsHQx7U8Sl3jMN1a6GiQmRCUQcSPEFAa4M2vtWYVtOheZ1xrCJx5V7vpQQX3HtchdklVBo1CSIpDb6pweV5Hrc1ffApbNqOgUkyZR2pQR9DbyYfcEAc5NYCZXckjpX9GRoa5xK/aVybudhMatJramP+nK7lKjdQm8b4eo0BEAvAJ6cPzzru/NWyq4l57Zyg== 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=QirTiM5BMFqVEm2akRsnyKmv1ZPwRYUKo4oLM4omp7M=; b=6cv8kmt+/cThiBqyQqFikKTfM1ITBUInNckkOehGk2AmAjlkK37LdGGt7XaoAZZvnr/mZqQdyY3AuiOeB9L7zrnKlb9FHbXvPQXq5Mx/XqV/ohXhQ9BHasIDWS01nMplPBXOBctWv9Bqn/xCS8YvHCVs7s6zTui/iAWrP/kJmvk= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; 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 06/10] xen: replace order with nr_pfns in assign_pages for better compatibility Date: Tue, 18 May 2021 05:21:09 +0000 Message-ID: <20210518052113.725808-7-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518052113.725808-1-penny.zheng@arm.com> References: <20210518052113.725808-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9fd858e9-608b-4f28-e450-08d919bcdb74 X-MS-TrafficTypeDiagnostic: PAXPR08MB6986:|DB7PR08MB3852: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2657;OLM:2657; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: QUNkkpUVMuE18FlZNUqu0BjVFNSUCeqE5btNzUBPQyzvBYuqHW7oJ8EFbzXmtQPlPr0JGYBQyN+rwu8XGCOKjbIhsXiScO2vA/rndoK77nAmwteNEiZY84Yq6xffZgPAFSu9zR1SQgsO+Kq0iGIf7xzTWU/fpmpaUzWUx7Xe0bAOeuIwd8m+pfKDovhZ4sFLm02WHxcpm+Z0ISWnfQRIztKq1ujK/2J/EoguviHcrBSjCsFJrLmEEoODImljH3tcldn48Y0/K3ZG66ikfeQAFCZ+aj8VfzvXX5O5iD0hbQZKHDTzthosps8Hwb8oSKiNTwVGAT6MmyUDGH0n1bc6Pebe4vDBaUzGjaLf9uWOX0S8N0uYcaAEkxDhO9eO32fldiNlYVHmcbcFC57ceYpenc+PCWAvZRrMAWjG1onuiqtp8bfZcv1mhCOnppVLnL5/AZPA4q61w4iS7izZzm2oTnwOGvAOq/w7A4shWWVE5INlc83m7gayUyFRr4FrA0NJ8bg6F742Cu9Y7COIEMoj51ju+8AkSd4uNyc/hOouxctN8zlAWbwXjkfzprzJZZsGt1Z9gbtc8Ow8/BXppLsMdOXeWtVFvlaqycD1FCfp8X6/8/5gWTZpB1/m4y+/OQQLigjUUU0QkGgb5iNW5TbI6483uIbUUoCnMPx1Y7101GL13sOkM524zvCR4MwAoXYs 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)(376002)(346002)(396003)(39850400004)(136003)(36840700001)(46966006)(83380400001)(316002)(6666004)(36756003)(7696005)(70206006)(2616005)(70586007)(478600001)(86362001)(110136005)(5660300002)(8676002)(82740400003)(336012)(36860700001)(1076003)(44832011)(356005)(426003)(81166007)(47076005)(2906002)(26005)(8936002)(186003)(54906003)(82310400003)(4326008)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6986 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 2b07f62c-18f4-4de8-9caf-08d919bcd65a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sxrucFlrFuBPBzDaZIveWaHc74CnV8uvzdEV1JZTfSttL05n584wrkyOEgrS/p0HLOR2whxXNMP9lDrqv71thBg7Fv+30YWxaa0Ia6uXhbT2FuUQKWGeMA+ILcyh85NY491Lkp5RsALji4TPZkfnMqiWVZADB6SBcu1G3NPSb24wJlRXdHgO5zRwc0cAvFHYdtBAUDQwwl3kFmxsjunNQ6Q0mAc5BnqDDvxnxWdRgsOq1NRz4mVSx2vp+dOYy7l/PsupIkJ9sQZFyQmHfVSMBJr5sC7VMASeGJNTp0Si6nqmNkuIAlO2E17r5GzuOrQhzD4YLadTysg8VbxSZ3+fTcDWsrC3J9WtKxMdPWVfoXb2/g7fRuT6k3JQK1LDgf2uf0kqPob+aZBnCJufS07c5hILFbiUS50WAWlXmD0qZbqnIOu0OJ8SW1Q9VH1qqLdbKLaj4M+5e1reO8D/9qb010YhOQG30LZVlTCtJtdZB83OLR2RhBH7jUZgDSruZlxrEdFq0th8NhtFS00YHmE0E714uWtWiLs2LSoStGmsKfSfrEW61L3xR9FYJN60hOq5/MZpHdJvJTjzTjTSEOZvMTDkMaBu72QFpiNffCRUiz08Wq99zQWNLYeHxVYLFDtODiQSAVQbKoSbx+ZxNaXSGw== 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)(346002)(376002)(136003)(396003)(39850400004)(36840700001)(46966006)(1076003)(47076005)(86362001)(54906003)(26005)(2906002)(110136005)(36860700001)(7696005)(2616005)(8676002)(81166007)(316002)(478600001)(6666004)(4326008)(186003)(44832011)(70206006)(5660300002)(82310400003)(336012)(70586007)(8936002)(426003)(36756003)(82740400003)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 05:21:57.5323 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fd858e9-608b-4f28-e450-08d919bcdb74 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: AM5EUR03FT006.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3852 Function parameter order in assign_pages is always used as 1ul << order, referring to 2@order pages. Now, for better compatibility with new static memory, order shall be replaced with nr_pfns pointing to page count with no constraint, like 250MB. Signed-off-by: Penny Zheng --- xen/arch/x86/pv/dom0_build.c | 2 +- xen/common/grant_table.c | 2 +- xen/common/memory.c | 4 ++-- xen/common/page_alloc.c | 16 ++++++++-------- xen/include/xen/mm.h | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index e0801a9e6d..4e57836763 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -556,7 +556,7 @@ int __init dom0_construct_pv(struct domain *d, else { while ( count-- ) - if ( assign_pages(d, mfn_to_page(_mfn(mfn++)), 0, 0) ) + if ( assign_pages(d, mfn_to_page(_mfn(mfn++)), 1, 0) ) BUG(); } initrd->mod_end = 0; diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index ab30e2e8cf..925bf924bd 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -2354,7 +2354,7 @@ gnttab_transfer( * is respected and speculative execution is blocked accordingly */ if ( unlikely(!evaluate_nospec(okay)) || - unlikely(assign_pages(e, page, 0, MEMF_no_refcount)) ) + unlikely(assign_pages(e, page, 1, MEMF_no_refcount)) ) { bool drop_dom_ref; diff --git a/xen/common/memory.c b/xen/common/memory.c index b5c70c4b85..2dca23aa7f 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -722,7 +722,7 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg) /* Assign each output page to the domain. */ for ( j = 0; (page = page_list_remove_head(&out_chunk_list)); ++j ) { - if ( assign_pages(d, page, exch.out.extent_order, + if ( assign_pages(d, page, 1UL << exch.out.extent_order, MEMF_no_refcount) ) { unsigned long dec_count; @@ -791,7 +791,7 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg) * cleared PGC_allocated. */ while ( (page = page_list_remove_head(&in_chunk_list)) ) - if ( assign_pages(d, page, 0, MEMF_no_refcount) ) + if ( assign_pages(d, page, 1, MEMF_no_refcount) ) { BUG_ON(!d->is_dying); free_domheap_page(page); diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index adf2889e76..0eb9f22a00 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2388,7 +2388,7 @@ void init_domheap_pages(paddr_t ps, paddr_t pe) int assign_pages( struct domain *d, struct page_info *pg, - unsigned int order, + unsigned long nr_pfns, unsigned int memflags) { int rc = 0; @@ -2408,7 +2408,7 @@ int assign_pages( { unsigned int extra_pages = 0; - for ( i = 0; i < (1ul << order); i++ ) + for ( i = 0; i < nr_pfns; i++ ) { ASSERT(!(pg[i].count_info & ~PGC_extra)); if ( pg[i].count_info & PGC_extra ) @@ -2417,18 +2417,18 @@ int assign_pages( ASSERT(!extra_pages || ((memflags & MEMF_no_refcount) && - extra_pages == 1u << order)); + extra_pages == nr_pfns)); } #endif if ( pg[0].count_info & PGC_extra ) { - d->extra_pages += 1u << order; + d->extra_pages += nr_pfns; memflags &= ~MEMF_no_refcount; } else if ( !(memflags & MEMF_no_refcount) ) { - unsigned int tot_pages = domain_tot_pages(d) + (1 << order); + unsigned int tot_pages = domain_tot_pages(d) + nr_pfns; if ( unlikely(tot_pages > d->max_pages) ) { @@ -2440,10 +2440,10 @@ int assign_pages( } if ( !(memflags & MEMF_no_refcount) && - unlikely(domain_adjust_tot_pages(d, 1 << order) == (1 << order)) ) + unlikely(domain_adjust_tot_pages(d, nr_pfns) == nr_pfns) ) get_knownalive_domain(d); - for ( i = 0; i < (1 << order); i++ ) + for ( i = 0; i < nr_pfns; i++ ) { ASSERT(page_get_owner(&pg[i]) == NULL); page_set_owner(&pg[i], d); @@ -2499,7 +2499,7 @@ struct page_info *alloc_domheap_pages( pg[i].count_info = PGC_extra; } } - if ( assign_pages(d, pg, order, memflags) ) + if ( assign_pages(d, pg, 1ul << order, memflags) ) { free_heap_pages(pg, order, memflags & MEMF_no_scrub); return NULL; diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 8b1a2207b2..dcf9daaa46 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -131,7 +131,7 @@ void heap_init_late(void); int assign_pages( struct domain *d, struct page_info *pg, - unsigned int order, + unsigned long nr_pfns, unsigned int memflags); /* Dump info to serial console */ From patchwork Tue May 18 05:21:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12263553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E97AC433ED for ; Tue, 18 May 2021 05:22:25 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4FE5C60FE9 for ; Tue, 18 May 2021 05:22:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FE5C60FE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.128624.241500 (Exim 4.92) (envelope-from ) id 1lisBN-0003M1-Mu; Tue, 18 May 2021 05:22:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 128624.241500; Tue, 18 May 2021 05:22:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisBN-0003Lm-II; Tue, 18 May 2021 05:22:17 +0000 Received: by outflank-mailman (input) for mailman id 128624; Tue, 18 May 2021 05:22:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisBM-00019F-73 for xen-devel@lists.xenproject.org; Tue, 18 May 2021 05:22:16 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (unknown [40.107.15.48]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ffa3db3a-c3a6-4fde-b98f-8d43feb17dde; Tue, 18 May 2021 05:22:08 +0000 (UTC) Received: from AM6P193CA0119.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::24) by HE1PR0801MB1850.eurprd08.prod.outlook.com (2603:10a6:3:86::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:22:05 +0000 Received: from AM5EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:85:cafe::88) by AM6P193CA0119.outlook.office365.com (2603:10a6:209:85::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.32 via Frontend Transport; Tue, 18 May 2021 05:22:05 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT004.mail.protection.outlook.com (10.152.16.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:22:05 +0000 Received: ("Tessian outbound 3c287b285c95:v92"); Tue, 18 May 2021 05:22:04 +0000 Received: from e6e41f494c34.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6002B449-B487-40A5-A21B-C21F9B34A70E.1; Tue, 18 May 2021 05:21:58 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e6e41f494c34.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 May 2021 05:21:58 +0000 Received: from AM6P194CA0036.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::49) by DBBPR08MB6314.eurprd08.prod.outlook.com (2603:10a6:10:20f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:21:56 +0000 Received: from VE1EUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::10) by AM6P194CA0036.outlook.office365.com (2603:10a6:209:90::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:21:56 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT005.mail.protection.outlook.com (10.152.18.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:21:56 +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.2176.14; Tue, 18 May 2021 05:21:49 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2176.14; Tue, 18 May 2021 05:21:49 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 18 May 2021 05:21: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: ffa3db3a-c3a6-4fde-b98f-8d43feb17dde 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=ZE+hOEo1iLiVZbrYdwypFc9m8SMes4QkXJwoF5cLLCI=; b=A8z/3Jxdey1736gclVsCGXTKdwqJJz09tMR1UFWSSyjbSXE9MGOZINe24d7v0xafWulN8eenAOdGopUeDxZHby/yjaemWRjCwq3PCO3e+aCi1Nz3Lz56tBCKjKNOi6WVsXx3MyTMMTgZoHzzoIjQdmRrYTigRyXJxbjE4K0opBc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; 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: 1d38469fbf5448af X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FCtIR/RVhesXgjkJHQGF9EjRi7lTkaz/TATKyOncArQXgMZ5K+8aHWA12A3MHcOJmel90Og6Nhasi8MWFTwoJAg6XY/gzGfYejKZAviC89TQeIx/i4qv7IL1YYjNqiA+aFN5aR6Z0pGjEpQ+NgKje0IcK1x0w5NpDs0VM7A//2UTlRFkWUO0+MTrkXFt9RF0e4PPnA5ye0oLow/Rq6v4QO4H2PaSuV5s9NLeHEo096CGFSSWtYIQi8eJJvsRgRYuChXuc7S5rYN0v8zANbsfVj1TESbGged3vbYvaomXJdcaZuChTi4ZNjFy0dA6TWJD3zOsJFmH/1AURpPGrfImyw== 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-SenderADCheck; bh=ZE+hOEo1iLiVZbrYdwypFc9m8SMes4QkXJwoF5cLLCI=; b=VjwXAY/5BMymAUmTnnGwMxb/gtiIeU+cji14rGREjDA+MP9rEKWnDGBl2yHpodrKvqFvF+cLmI/fN2J5xw6Mx1bykYi45PkUfCpUt/njKlztPU+BQN/XT0bAfxoVOXCSFTLc25ylU4hfSNzpPCIPeZtmvV2a7B1bFSybdA6F84N2HZSuSob0zVcEFji6WyHjF6e0KmI90eYK7gFERdzVu8k6wamFtHk6ICACE1pn/YpiOM2t8rgZyYrmheZRz7N5I1tu7PQK15l6IE+2joGehiZojd//cFJu8D8Hw8XcxLx9Q5BUiovuVsm2z3LJLe2ne0p1hIgwd/ZSgbyFKmoHTw== 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=ZE+hOEo1iLiVZbrYdwypFc9m8SMes4QkXJwoF5cLLCI=; b=A8z/3Jxdey1736gclVsCGXTKdwqJJz09tMR1UFWSSyjbSXE9MGOZINe24d7v0xafWulN8eenAOdGopUeDxZHby/yjaemWRjCwq3PCO3e+aCi1Nz3Lz56tBCKjKNOi6WVsXx3MyTMMTgZoHzzoIjQdmRrYTigRyXJxbjE4K0opBc= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; 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 07/10] xen/arm: intruduce alloc_domstatic_pages Date: Tue, 18 May 2021 05:21:10 +0000 Message-ID: <20210518052113.725808-8-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518052113.725808-1-penny.zheng@arm.com> References: <20210518052113.725808-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 337c6998-d82d-4726-f50e-08d919bce017 X-MS-TrafficTypeDiagnostic: DBBPR08MB6314:|HE1PR0801MB1850: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7219;OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: N0cvI42XJ3Wn/KwSal7wBIvhv5hDDhMQnllxpDKfddcNR2RaCEyLk44ft/YipEa7J7AAZ2DOVxNDYTK3VOJRhY5ya8nOPI07KBrMJ7BT/UtSyG9T3Xu+4GJPoOyX42ku7pPS9S4v8vL8MFrAzAV/AEgf7R3w/oTGNtVXLZbrMhuqTL0cHwdnoS9AkLd4hgALVhp7y2Jlf1GuTPjQSnXgeTwCTWQXo0I7qwFFtPVjvNgvaKaeMuLDksMPlphPsNM+Ac/xjnmucYQYAr91+ONERoKjpSEyCv0UYt+q48EN/gYHYOs0m2jpBGt1C/kV1jfO2mPESl1fV+mz1SVl8V4YjkCKx00mi9rxAooISlv2S2G+TLiq3b2P2bGSzMrovivyOs8Gkqcw6msUobLQD5349hXflMJFkvz7NuYEV6rao0BJgHIn8T6uNzHPeycj7//gZxXOfOzUrfxG2+TNw3WZlJhR2u462SXEDRixba0IMMMHJbfik5mFfALgk1Ey7n8hQ0ygkoDdGwqBFArZCdkfF1vUV2nkz29wIVoAC/7d0bFunHIo8kV5ZSt1dF1tR1DFP2yyZaR6PKSnALo5Vp6hwEe0bleVW0n/pJb38O0334ktvg8Ee9S226rfSr76BXFrEmYPfPc/SayEGw65yFkjtVNInbP0D3HZWbsCXonJ0ZZ7x2u0RAUfEuqv/LBjZUtg 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)(376002)(136003)(346002)(39850400004)(396003)(46966006)(36840700001)(36756003)(2616005)(83380400001)(36860700001)(82310400003)(86362001)(6666004)(336012)(478600001)(8936002)(7696005)(2906002)(82740400003)(44832011)(426003)(70206006)(81166007)(70586007)(316002)(8676002)(5660300002)(186003)(1076003)(356005)(47076005)(54906003)(4326008)(26005)(110136005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB6314 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a040dca4-7c1f-477c-dbd6-08d919bcda99 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KzMZVs4BLGX2lhVgTBdihpq5Ma33oRbAAZ7AY+SwYq6MrNfLVAtkB3G2CFS43zUBnl24KqeYC3Zmm86pym1b0jcBM3M7UTYuLryjxeKOn1cL9lO4siNRnTprdiVy0MOai3oxkl1HM1QPETEOjoBCNW15+WbsMeVR2s2adevEewF/q/sZ4/flpjnOI9g9pgsq9t/pYHDYLTl0DrGr015IEzv3gpwz092l8s+Od7YMXlLO5DYs4FUZnuhbmndBmLe0Ekgh1wwRAIrQj1Q9m8Be68yEyDEbRvIR/C245GQvj9/Wzy78PbTxQj5qStLlNRzmzwiH2jM5BpypSV80a+oOAmxY9jKyBtuDf3y+bAvbf3uKZQOKVeP6yknM6UzAabQuUsldsyHu/zyk5A8R5lTjRBchUcMsINLB+8a8h6LG3DTlla9bl+PHAr7BJyB5dVB1DsiW4MkNjMmBTecjoF10ZfJKTmqo4HYI4dxWWdhBzg4XtuAP39uPDz6eOQ5cGcak5Lmb5JK8FYAjj/8kXpL6nVGhM87xcO/uRaMi0odLuL3nYz2WuTQXOiZujZdte2dXghmlC9v59IHS2Zc+01E6aXZRYkXRIRybxD5oQ3rTY8ppr9E6bXhprr20y1Eop6fi+WdsX8FUE/yRlCwOjQYLlQ== 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)(376002)(396003)(346002)(39850400004)(136003)(46966006)(36840700001)(26005)(36860700001)(54906003)(86362001)(47076005)(8676002)(2906002)(36756003)(478600001)(110136005)(186003)(81166007)(6666004)(336012)(2616005)(316002)(1076003)(70586007)(5660300002)(83380400001)(70206006)(44832011)(8936002)(82740400003)(7696005)(4326008)(426003)(82310400003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 05:22:05.3279 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 337c6998-d82d-4726-f50e-08d919bce017 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: AM5EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1850 alloc_domstatic_pages is the equivalent of alloc_domheap_pages for static mmeory, and it is to allocate nr_pfns pages of static memory and assign them to one specific domain. It uses alloc_staticmen_pages to get nr_pages pages of static memory, then on success, it will use assign_pages to assign those pages to one specific domain, including using page_set_reserved_owner to set its reserved domain owner. Signed-off-by: Penny Zheng --- xen/common/page_alloc.c | 53 +++++++++++++++++++++++++++++++++++++++++ xen/include/xen/mm.h | 4 ++++ 2 files changed, 57 insertions(+) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 0eb9f22a00..f1f1296a61 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2447,6 +2447,9 @@ int assign_pages( { ASSERT(page_get_owner(&pg[i]) == NULL); page_set_owner(&pg[i], d); + /* use page_set_reserved_owner to set its reserved domain owner. */ + if ( (pg[i].count_info & PGC_reserved) ) + page_set_reserved_owner(&pg[i], d); smp_wmb(); /* Domain pointer must be visible before updating refcnt. */ pg[i].count_info = (pg[i].count_info & PGC_extra) | PGC_allocated | 1; @@ -2509,6 +2512,56 @@ struct page_info *alloc_domheap_pages( return pg; } +/* + * Allocate nr_pfns contiguous pages, starting at #start, of static memory, + * then assign them to one specific domain #d. + * It is the equivalent of alloc_domheap_pages for static memory. + */ +struct page_info *alloc_domstatic_pages( + struct domain *d, unsigned long nr_pfns, paddr_t start, + unsigned int memflags) +{ + struct page_info *pg = NULL; + unsigned long dma_size; + + ASSERT(!in_irq()); + + if ( memflags & MEMF_no_owner ) + memflags |= MEMF_no_refcount; + + if ( !dma_bitsize ) + memflags &= ~MEMF_no_dma; + else + { + dma_size = 1ul << bits_to_zone(dma_bitsize); + /* Starting address shall meet the DMA limitation. */ + if ( dma_size && start < dma_size ) + return NULL; + } + + pg = alloc_staticmem_pages(nr_pfns, start, memflags); + if ( !pg ) + return NULL; + + if ( d && !(memflags & MEMF_no_owner) ) + { + if ( memflags & MEMF_no_refcount ) + { + unsigned long i; + + for ( i = 0; i < nr_pfns; i++ ) + pg[i].count_info = PGC_extra; + } + if ( assign_pages(d, pg, nr_pfns, memflags) ) + { + free_staticmem_pages(pg, nr_pfns, memflags & MEMF_no_scrub); + return NULL; + } + } + + return pg; +} + void free_domheap_pages(struct page_info *pg, unsigned int order) { struct domain *d = page_get_owner(pg); diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index dcf9daaa46..e45987f0ed 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -111,6 +111,10 @@ unsigned long __must_check domain_adjust_tot_pages(struct domain *d, int domain_set_outstanding_pages(struct domain *d, unsigned long pages); void get_outstanding_claims(uint64_t *free_pages, uint64_t *outstanding_pages); +/* Static Memory */ +struct page_info *alloc_domstatic_pages(struct domain *d, + unsigned long nr_pfns, paddr_t start, unsigned int memflags); + /* Domain suballocator. These functions are *not* interrupt-safe.*/ void init_domheap_pages(paddr_t ps, paddr_t pe); struct page_info *alloc_domheap_pages( From patchwork Tue May 18 05:21:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12263555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CF14C433B4 for ; Tue, 18 May 2021 05:22:34 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BFB1F6108B for ; Tue, 18 May 2021 05:22:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BFB1F6108B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.128629.241510 (Exim 4.92) (envelope-from ) id 1lisBV-0004CU-5L; Tue, 18 May 2021 05:22:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 128629.241510; Tue, 18 May 2021 05:22:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisBV-0004CH-1p; Tue, 18 May 2021 05:22:25 +0000 Received: by outflank-mailman (input) for mailman id 128629; Tue, 18 May 2021 05:22:23 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisBT-00047I-M3 for xen-devel@lists.xenproject.org; Tue, 18 May 2021 05:22:23 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (unknown [40.107.22.77]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 8e1f321c-4bc0-4b0c-8634-350deec083ba; Tue, 18 May 2021 05:22:22 +0000 (UTC) Received: from AM7PR02CA0009.eurprd02.prod.outlook.com (2603:10a6:20b:100::19) by DB6PR0802MB2199.eurprd08.prod.outlook.com (2603:10a6:4:82::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Tue, 18 May 2021 05:22:20 +0000 Received: from AM5EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:100:cafe::ae) by AM7PR02CA0009.outlook.office365.com (2603:10a6:20b:100::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:22:20 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT051.mail.protection.outlook.com (10.152.16.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:22:20 +0000 Received: ("Tessian outbound 504317ef584c:v92"); Tue, 18 May 2021 05:22:20 +0000 Received: from 4ca63d3bf940.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 87B07377-33EE-4E9D-828B-361404BDB204.1; Tue, 18 May 2021 05:22:13 +0000 Received: from FRA01-PR2-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4ca63d3bf940.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 May 2021 05:22:13 +0000 Received: from AM6PR08CA0008.eurprd08.prod.outlook.com (2603:10a6:20b:b2::20) by PR2PR08MB4858.eurprd08.prod.outlook.com (2603:10a6:101:1f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Tue, 18 May 2021 05:22:12 +0000 Received: from VE1EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::bd) by AM6PR08CA0008.outlook.office365.com (2603:10a6:20b:b2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24 via Frontend Transport; Tue, 18 May 2021 05:22:12 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT046.mail.protection.outlook.com (10.152.19.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:22:12 +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.2176.14; Tue, 18 May 2021 05:21:52 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2176.14; Tue, 18 May 2021 05:21:52 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 18 May 2021 05:21:49 +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: 8e1f321c-4bc0-4b0c-8634-350deec083ba 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=9ZNC/nfkeDYicCmVJe5toeMnkfsndF5g/9+kkSrRk+M=; b=ogoyPpU9KTIuq7lcLHcOa/YvXOVxN63hmoRn/riXVZwmt7yGHohth7ynnprH9hUORhJQpUNfvEMqWL7T0cz/zKoi8xVKA9VXKF3P6KAtBK2TkgZOAJM1W9VjaQMEH2pprXYP4zwpWkH3vHcShAbDqEwF5kg+KtbDdDetK+cEJQ8= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; 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: a6f4acc816c8473b X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aZyWU+3eFnzBFFCDhXJPb49pfhbkDhc4nP2Bs3gb2QRIaCPo4c8ZFDg6Zkt9HCzEGkU3ByOM8XVLDSTOFTRYlBz/0NCEMOEUg2+K/QAbKQxhTJPD0IKaYcRK+iVyoYVZsUHg2UEtEjNTme3+/gVciwlWjNy5LNeYWjdLJDSO2QhEU85vGkzw2pF2vj3TQzaFzuuCPtY2fYp4f56ybOW70odgHPjJ8ET9MM/mO3d4YhdYUN7qpXFGw8PfO1aKuNgrjDgVT456weO86lXqxPbZTOK1WCbIIRIQJPB54/gpbHe2tqPvu3Q8I4D3GRoUGSgMBF1VzeOANGxcmyDmufr1mg== 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-SenderADCheck; bh=9ZNC/nfkeDYicCmVJe5toeMnkfsndF5g/9+kkSrRk+M=; b=f3PJgjXFuxfeZ1WcNt/5uRXvtEjUrhh0H9RHj3S/1oEFyRHZZOkPwqB2ZPn0OEj/MmaDYXNGYSjYW6CLK9m+toqKmU+uZJ8jAje6DKYeidU68WdvEvfpOOk9cIMu9sgWr6aThJRyYQBEn35f2/QWV0buFdFI7Wc/gLt6LQ6DGR/9TqLdPJC5SGZNaUIaK5Y5JRm3drNgx6dwgJn5bBCOd8+o4PZRn4zCK2DyC7t/zlEKiDXQ5mVlHz++5PfiUPG+aMlFVA+4jjjrQz3nFK83gJ/dtMllfmsbcpnILpXTfF0ZFRXdf99E+Qn1tcuYppKaJEb2gBBpHG6eQANK/gn/8Q== 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=9ZNC/nfkeDYicCmVJe5toeMnkfsndF5g/9+kkSrRk+M=; b=ogoyPpU9KTIuq7lcLHcOa/YvXOVxN63hmoRn/riXVZwmt7yGHohth7ynnprH9hUORhJQpUNfvEMqWL7T0cz/zKoi8xVKA9VXKF3P6KAtBK2TkgZOAJM1W9VjaQMEH2pprXYP4zwpWkH3vHcShAbDqEwF5kg+KtbDdDetK+cEJQ8= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; 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 08/10] xen/arm: introduce reserved_page_list Date: Tue, 18 May 2021 05:21:11 +0000 Message-ID: <20210518052113.725808-9-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518052113.725808-1-penny.zheng@arm.com> References: <20210518052113.725808-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9770d729-03d4-46d6-dc47-08d919bce8f1 X-MS-TrafficTypeDiagnostic: PR2PR08MB4858:|DB6PR0802MB2199: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:5516;OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: gzOnoWMOgYntjcBJG0Et1nPQDFF9M/nB5sCOh8SprxxAAtaZH+NUFZsnS9vPLnpORLqAUtX6hBoBP4uBq6QcayoWsU1+/YxCA/A/a+MhEMFj99BHawEc874+VMjiKjjuIBhZFr8yL4viIPpkdaW3JbtOM/RwSYxTDx5a0/Ic6K2StSDugtIvtri+tMgVVoSiyX8F2aR0Rta+kpZVKhQW0lUHmBB1jVAMaJ6ClIxXLm7wY8srnCnSTQJs2+k5IUaGZTx++2+i5daFb1RQZoUcr0HoPjBivy0zmwjmkHY1zywt3aKGJ0GGwTokH1ir7tdzU9xu2nrTuYe2FOD2UMLRTksA2Q6hR+Jh54EU1YpiG2WcRDaOdTyUgeoN4ojTAAwLiqqr12ceg0mlZMzgYyDg8o2cjLiFckgxNZ8PE8+OiU2bABHkKedN1iHKkbpPrLrt1y4pcHTP4Xk0dMp1pHvNAIbibsGD92i+2buUGuQ4H5IZEVeub5/pNQw54MRSRtBM4Yk+vr9Dt6ICkD3JqWKVDwK1F9+IM5/74nWUWBrnzvG/8vaAKLuppb38TIgfagMw1LFpfOJ+DZdhBjXyTzyxSx7Nezre5c0alLDQN2Ailau8qoX2hTi303Y09Si7x5rLdxzqDh9kjdf3T2qmQDeT8DOD/hMEJHo9KuPpz/vFcbEUO9nyjdjltpPRbhEZxdwa 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)(396003)(376002)(39850400004)(346002)(136003)(46966006)(36840700001)(1076003)(5660300002)(426003)(186003)(336012)(2616005)(82310400003)(47076005)(82740400003)(6666004)(70206006)(2906002)(70586007)(356005)(83380400001)(36756003)(86362001)(8936002)(478600001)(110136005)(4326008)(44832011)(316002)(54906003)(7696005)(8676002)(81166007)(36860700001)(26005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4858 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: feca53fd-4922-449d-5d93-08d919bce41b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S+kNN0rta+uUSFCEoGwCrJU8l8DrsFFlAp0DR+TABuk93hRdrvzCzRAcx1U1Ftq+zRrwM+eh675sLTVbEs7bdLKhdCT7UA4Qid71SKTTLU9jRWkrs8kUuQncah/K4AbEaZN9B0kTKClePnVrQVEblbUNHb8laEkeSTHzQVZZ8jkT35cIuM634fdoy+ayW7VfVdWcQf69zBDVbaLzF9UYkslZbYQKaGkLZXyHX9lSj5rAbpiNogr0AuVCwA6NblxNKvaWLaaxA9K1yGIEBQoMAt0qUTS9V+LqTHnn/nQQ0GwhQ4JKmc2stftvFztJvKO/lMJ8wsniNHAVt0N4yv8qvrA+SwSKs2MWYaVFpYrwscacPX2pXnmmbYqrX38foO2HFObUXx8OJff/u1uG71jC34OgZJb3/BrTJ34m5nwPL88tKWV4VMfs5hqq7P5eg6lBLy5/WfKIkccOKKcq85TjTs7Wvr9v3tW/uVi/wnhhI4FEJ1CKVz6jjt/SFTYPIdH3tZBRRDxZkgh3eYwtuShsBHdmtza3nwaGWE9CK5zCXNdgmo416P0Mmzy3mUN6lQaKv+bzBqoUXMjNQatg9AjSTleXw21DnPpZtDJpnbDchbQITVA6jfiufWRS92Rod/RIUceNQpshve+rptEwXLPb9R/yZhDSqjWuEAEJdqaunAM= 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)(39850400004)(396003)(346002)(136003)(376002)(36840700001)(46966006)(82310400003)(7696005)(6666004)(47076005)(36860700001)(426003)(478600001)(4326008)(26005)(336012)(1076003)(5660300002)(2616005)(44832011)(36756003)(8676002)(8936002)(316002)(54906003)(186003)(110136005)(82740400003)(81166007)(83380400001)(70206006)(70586007)(2906002)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 05:22:20.1646 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9770d729-03d4-46d6-dc47-08d919bce8f1 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: AM5EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2199 Since page_list under struct domain refers to linked pages as gueast RAM allocated from heap, it should not include reserved pages of static memory. The number of PGC_reserved pages assigned to a domain is tracked in a new 'reserved_pages' counter. Also introduce a new reserved_page_list to link pages of static memory. Let page_to_list return reserved_page_list, when flag is PGC_reserved. Later, when domain get destroyed or restarted, those new values will help relinquish memory to proper place, not been given back to heap. Signed-off-by: Penny Zheng --- xen/common/domain.c | 1 + xen/common/page_alloc.c | 7 +++++-- xen/include/xen/sched.h | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 6b71c6d6a9..c38afd2969 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -578,6 +578,7 @@ struct domain *domain_create(domid_t domid, INIT_PAGE_LIST_HEAD(&d->page_list); INIT_PAGE_LIST_HEAD(&d->extra_page_list); INIT_PAGE_LIST_HEAD(&d->xenpage_list); + INIT_PAGE_LIST_HEAD(&d->reserved_page_list); spin_lock_init(&d->node_affinity_lock); d->node_affinity = NODE_MASK_ALL; diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index f1f1296a61..e3f07ec6c5 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2410,7 +2410,7 @@ int assign_pages( for ( i = 0; i < nr_pfns; i++ ) { - ASSERT(!(pg[i].count_info & ~PGC_extra)); + ASSERT(!(pg[i].count_info & ~(PGC_extra | PGC_reserved))); if ( pg[i].count_info & PGC_extra ) extra_pages++; } @@ -2439,6 +2439,9 @@ int assign_pages( } } + if ( pg[0].count_info & PGC_reserved ) + d->reserved_pages += nr_pfns; + if ( !(memflags & MEMF_no_refcount) && unlikely(domain_adjust_tot_pages(d, nr_pfns) == nr_pfns) ) get_knownalive_domain(d); @@ -2452,7 +2455,7 @@ int assign_pages( page_set_reserved_owner(&pg[i], d); smp_wmb(); /* Domain pointer must be visible before updating refcnt. */ pg[i].count_info = - (pg[i].count_info & PGC_extra) | PGC_allocated | 1; + (pg[i].count_info & (PGC_extra | PGC_reserved)) | PGC_allocated | 1; page_list_add_tail(&pg[i], page_to_list(d, &pg[i])); } diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 3982167144..b6333ed8bb 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -368,6 +368,7 @@ struct domain struct page_list_head page_list; /* linked list */ struct page_list_head extra_page_list; /* linked list (size extra_pages) */ struct page_list_head xenpage_list; /* linked list (size xenheap_pages) */ + struct page_list_head reserved_page_list; /* linked list (size reserved pages) */ /* * This field should only be directly accessed by domain_adjust_tot_pages() @@ -379,6 +380,7 @@ struct domain unsigned int outstanding_pages; /* pages claimed but not possessed */ unsigned int max_pages; /* maximum value for domain_tot_pages() */ unsigned int extra_pages; /* pages not included in domain_tot_pages() */ + unsigned int reserved_pages; /* pages of static memory */ atomic_t shr_pages; /* shared pages */ atomic_t paged_pages; /* paged-out pages */ @@ -588,6 +590,9 @@ static inline struct page_list_head *page_to_list( if ( pg->count_info & PGC_extra ) return &d->extra_page_list; + if ( pg->count_info & PGC_reserved ) + return &d->reserved_page_list; + return &d->page_list; } From patchwork Tue May 18 05:21:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12263557 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01581C433B4 for ; Tue, 18 May 2021 05:22:41 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 931AD60FE9 for ; Tue, 18 May 2021 05:22:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 931AD60FE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.128635.241522 (Exim 4.92) (envelope-from ) id 1lisBc-00051m-Qf; Tue, 18 May 2021 05:22:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 128635.241522; Tue, 18 May 2021 05:22:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisBc-00051f-MD; Tue, 18 May 2021 05:22:32 +0000 Received: by outflank-mailman (input) for mailman id 128635; Tue, 18 May 2021 05:22:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisBb-00019F-7m for xen-devel@lists.xenproject.org; Tue, 18 May 2021 05:22:31 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:fe1e::629]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 599ea074-c24c-4eab-97e5-6cd0e1c41332; Tue, 18 May 2021 05:22:18 +0000 (UTC) Received: from AM0PR04CA0120.eurprd04.prod.outlook.com (2603:10a6:208:55::25) by DB6PR0802MB2598.eurprd08.prod.outlook.com (2603:10a6:4:97::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:22:16 +0000 Received: from AM5EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:55:cafe::61) by AM0PR04CA0120.outlook.office365.com (2603:10a6:208:55::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:22:16 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT025.mail.protection.outlook.com (10.152.16.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:22:15 +0000 Received: ("Tessian outbound 504317ef584c:v92"); Tue, 18 May 2021 05:22:15 +0000 Received: from a8228ba31155.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 22C9CDE8-865D-4F08-95D8-F9829E163804.1; Tue, 18 May 2021 05:22:08 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a8228ba31155.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 May 2021 05:22:08 +0000 Received: from AM5PR0601CA0044.eurprd06.prod.outlook.com (2603:10a6:203:68::30) by DB7PR08MB3338.eurprd08.prod.outlook.com (2603:10a6:5:1b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:22:07 +0000 Received: from AM5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:68:cafe::fa) by AM5PR0601CA0044.outlook.office365.com (2603:10a6:203:68::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:22:07 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT050.mail.protection.outlook.com (10.152.17.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:22:06 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2176.14; Tue, 18 May 2021 05:21:54 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 18 May 2021 05:21:52 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 599ea074-c24c-4eab-97e5-6cd0e1c41332 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=F8m43zx7x8u+u5yr2EVRgwygvKFWL/IN38zVtxS/SDg=; b=JmWBMpF4NraHMaTK5kI4Os0kGwewpd12qeakHYdubxm7l6C+2JPRidUwONaWFZCnZWED5YQ0woyRwGXmurm0kR2SASMrgiUDPZKr+7yF7I/aGHZ595nJNQ2yVvIfqij2lWLb4DmWElWFp2fd7KABZsu/zmyIGtvxG6lL9y5CH0E= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; 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: 146620f27eb284f0 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n4jPM40N69hYTMhvI75fN7KlbGig55PO4u/gP2b4rY39s2UlT/79cy6rg4WJ/6JW87hFyDt6XeUj27W9h/tqYouu3xUXK/9uThzGT2fNh9fmdItfWuDnN1feroRq8MkEJYZxzp1xqwj4JNOgH62cgPAjWNl8QdJozwtBSht4UKXrqqSyfKyy4E7hPrmqLBK7dZDEoKTRfgUDymO/Knt5RKzsSQpczJVQJ5tRgJctwCRD8s727F3IU9XxBZNWu85pNCAxUtL1+P1S3eQV5lP3glzzrmRexmBY4oVSvwx9StHeIEQUz4tpf/bgzoGhEgOLiBspgIshVFx9YfujeIYbZQ== 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-SenderADCheck; bh=F8m43zx7x8u+u5yr2EVRgwygvKFWL/IN38zVtxS/SDg=; b=cpd3Lj3Jfi+yoTAoxfXZTRq10LI3pjZecetiQNJTbNX2UyJwG79TrFEG6YWLX7qUwD4UD5JYasTyiaPw/obKJ/c8PBYAkSF2MKm74RceSbgTR4ykXX3h/mIH/a9zMwqmabQtxTA/NPeQbsvlZhER46ZCcC+v7WrKEg6t7Q5cMEKO4K0GPDMIaeRc7CSXDTgDiPpyEagIyk33p4OByhZaKYwj7V4G1jJNMY6BAG5/+jeS4MT/yBgQKOtSysC+h2E7hKYX/KoYmMABsPCJVMg6s4x1zV3bdKQ8m0ys2AmyrTXgXtbIl3FZcfQJsMPrY3wlXq/HDg5kUypgNA2O/Rb+1w== 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=F8m43zx7x8u+u5yr2EVRgwygvKFWL/IN38zVtxS/SDg=; b=JmWBMpF4NraHMaTK5kI4Os0kGwewpd12qeakHYdubxm7l6C+2JPRidUwONaWFZCnZWED5YQ0woyRwGXmurm0kR2SASMrgiUDPZKr+7yF7I/aGHZ595nJNQ2yVvIfqij2lWLb4DmWElWFp2fd7KABZsu/zmyIGtvxG6lL9y5CH0E= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; 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 09/10] xen/arm: parse `xen,static-mem` info during domain construction Date: Tue, 18 May 2021 05:21:12 +0000 Message-ID: <20210518052113.725808-10-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518052113.725808-1-penny.zheng@arm.com> References: <20210518052113.725808-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a905f5fe-fd47-4f2b-247f-08d919bce630 X-MS-TrafficTypeDiagnostic: DB7PR08MB3338:|DB6PR0802MB2598: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2089;OLM:2089; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: jnNDjiU2nU/HY1AORxFCFCTAGP2pCTFhyhvse5NTOrWByXqEdOq2FC0Jz82+NjyAvxBbf96Qsy1/M7pk4Fkd0u2hvPI4h0BiSogj5txcOqGzyuAFAjUMcRULgbhf9rGdHxRPYqW1baWm39T6/5dv2IO5yara3kcF/Ydmyn9P4fLa2+K52oyDsmhfaLgbLjrd7YEzMXa89bLAZDFaYWY+NvXFE970TCkX+T/WSF+cfzZ/HQTfwVng8+p61SvdD8uujcvvbt54tXTdg15ZAO1z6W6BBiwvt402YBSMsKA+GccfPX3bmKtc8kZnSeTHD6y6DJHU4uESm7BHfr1LjBraj3/Nars4D6bxWGs32MEAeuZxZ4QR1Jp1+c2zmXJ6UZxEaxg2E60BNuoWI4xw1luqqvMFQxKa4zUQJm/Zd43c+xUWXAaP1XYANSj537Z0ueGgG3rZDULI/kYCZbB9xHmBPxG0RhhMPTGsO4suzxqnv2I0rczyYEkM2BoQXM/1FcJDN5Ir6x8OAVSRuNb1LDueqrMycZq7efaiyfrPF42h0NcgRoDOuK9FguM4pJs+cpita8MrJ35qH7KT9KSx08NNHX90Lddp6yvFBmWHviozzgiAC+sbU35RK/tPjWwKnrTJbTtSBR6iM58P7JUsBux4V0372B3oeW/uN1DOFNTRfB9MOM0pOprBifrHcmzGMf2uq7kLTsUzBLrmzCsereIbRQ== 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)(136003)(376002)(396003)(346002)(39850400004)(36840700001)(46966006)(426003)(110136005)(54906003)(70586007)(4326008)(336012)(186003)(316002)(47076005)(8676002)(5660300002)(70206006)(2906002)(86362001)(7696005)(6666004)(82740400003)(8936002)(81166007)(36860700001)(82310400003)(44832011)(36756003)(356005)(83380400001)(1076003)(2616005)(26005)(478600001)(81973001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3338 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 20edcc16-d774-43e2-b8db-08d919bce10b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Af0pTLUmx8CTPEk0bdl3eAZflXMSVL3UryWs3i1sEveOiYpY2oqPxqJjSY9nGAyAW3vMDVmrExfLxXLeC9POw1zkbVH1OB3HrnbUpHnjTcneHZKIcrBk96VnZPyOy0OCZsI1LEVXAsEIMH6VSj/pm3MNHKXLSArnEEEF1BMVlREf0peNRd4tMui5v3Lhc+k1VmGmchvdBI6q/4xUiVo3LoyCaSzcPJbqBEEc4+e12B/eU1o3q2a8N8kPEEPX7P0k8uh3LwbFGWLrln0MS9rtNv5QEKEJgUmHzJi+O0DHVJa+q/gct0e/X6386uKllG4w0ydrw5ZI2I0kGiArhBWt6n2Whvn6//jXz2M7GAoTP28gPxZ1a4grLaztuJq+COZ7KUfVbZDIHY4YCUir/ECALNTomTJ+g4pq37qq8bpAiABTexosZwAM0bDMpNirB+a7Ti4L22DnKXxDmwP8FsgqZacw7ZyDrsZUOH9U23q5BQuTHmPdB2YR4+kmsem7BRWRTFX5veg0r1EO6J1Sw/UQ5mhaXuvo3NfPZ2HL5ZobFqIq7VSQqxbC0yUgHVJ0qk6ctQg4DIKykbFYfa+fKnBaGmv+EtRTjwvNygd7uSGGdpPYCfsxB/lD1gK4qxmRAp6RqfRcSOiVJrNsKzTV6USs0XiLH8jKnGrHgX5bKotC6uqEYwf4W97SjliIJmTOEy9m 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)(136003)(346002)(396003)(376002)(39850400004)(36840700001)(46966006)(110136005)(54906003)(8936002)(7696005)(26005)(44832011)(316002)(81166007)(36756003)(478600001)(86362001)(47076005)(8676002)(36860700001)(4326008)(82310400003)(82740400003)(186003)(1076003)(5660300002)(336012)(6666004)(426003)(70206006)(83380400001)(2616005)(2906002)(70586007)(81973001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 05:22:15.5516 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a905f5fe-fd47-4f2b-247f-08d919bce630 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: AM5EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2598 This commit parses `xen,static-mem` device tree property, to acquire static memory info reserved for this domain, when constructing domain during boot-up. Related info shall be stored in new static_mem value under per domain struct arch_domain. Right now, the implementation of allocate_static_memory is missing, and will be introduced later. It just BUG() out at the moment. Signed-off-by: Penny Zheng --- xen/arch/arm/domain_build.c | 58 ++++++++++++++++++++++++++++++++---- xen/include/asm-arm/domain.h | 3 ++ 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 282416e74d..30b55588b7 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2424,17 +2424,61 @@ static int __init construct_domU(struct domain *d, { struct kernel_info kinfo = {}; int rc; - u64 mem; + u64 mem, static_mem_size = 0; + const struct dt_property *prop; + u32 static_mem_len; + bool static_mem = false; + + /* + * Guest RAM could be of static memory from static allocation, + * which will be specified through "xen,static-mem" property. + */ + prop = dt_find_property(node, "xen,static-mem", &static_mem_len); + if ( prop ) + { + const __be32 *cell; + u32 addr_cells = 2, size_cells = 2, reg_cells; + u64 start, size; + int i, banks; + static_mem = true; + + dt_property_read_u32(node, "#address-cells", &addr_cells); + dt_property_read_u32(node, "#size-cells", &size_cells); + BUG_ON(size_cells > 2 || addr_cells > 2); + reg_cells = addr_cells + size_cells; + + cell = (const __be32 *)prop->value; + banks = static_mem_len / (reg_cells * sizeof (u32)); + BUG_ON(banks > NR_MEM_BANKS); + + for ( i = 0; i < banks; i++ ) + { + device_tree_get_reg(&cell, addr_cells, size_cells, &start, &size); + d->arch.static_mem.bank[i].start = start; + d->arch.static_mem.bank[i].size = size; + static_mem_size += size; + + printk(XENLOG_INFO + "Static Memory Bank[%d] for Domain %pd:" + "0x%"PRIx64"-0x%"PRIx64"\n", + i, d, + d->arch.static_mem.bank[i].start, + d->arch.static_mem.bank[i].start + + d->arch.static_mem.bank[i].size); + } + d->arch.static_mem.nr_banks = banks; + } rc = dt_property_read_u64(node, "memory", &mem); - if ( !rc ) + if ( !static_mem && !rc ) { printk("Error building DomU: cannot read \"memory\" property\n"); return -EINVAL; } - kinfo.unassigned_mem = (paddr_t)mem * SZ_1K; + kinfo.unassigned_mem = static_mem ? static_mem_size : (paddr_t)mem * SZ_1K; - printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", d->max_vcpus, mem); + printk("*** LOADING DOMU cpus=%u memory=%"PRIx64"KB ***\n", + d->max_vcpus, (kinfo.unassigned_mem) >> 10); kinfo.vpl011 = dt_property_read_bool(node, "vpl011"); @@ -2452,7 +2496,11 @@ static int __init construct_domU(struct domain *d, /* type must be set before allocate memory */ d->arch.type = kinfo.type; #endif - allocate_memory(d, &kinfo); + if ( static_mem ) + /* allocate_static_memory(d, &kinfo); */ + BUG(); + else + allocate_memory(d, &kinfo); rc = prepare_dtb_domU(d, &kinfo); if ( rc < 0 ) diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index c9277b5c6d..81b8eb453c 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -10,6 +10,7 @@ #include #include #include +#include #include struct hvm_domain @@ -89,6 +90,8 @@ struct arch_domain #ifdef CONFIG_TEE void *tee; #endif + + struct meminfo static_mem; } __cacheline_aligned; struct arch_vcpu From patchwork Tue May 18 05:21:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Penny Zheng X-Patchwork-Id: 12263559 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9330C433ED for ; Tue, 18 May 2021 05:23:17 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 564B66100A for ; Tue, 18 May 2021 05:23:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 564B66100A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.128655.241533 (Exim 4.92) (envelope-from ) id 1lisCD-0006XY-4S; Tue, 18 May 2021 05:23:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 128655.241533; Tue, 18 May 2021 05:23:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisCD-0006XN-1A; Tue, 18 May 2021 05:23:09 +0000 Received: by outflank-mailman (input) for mailman id 128655; Tue, 18 May 2021 05:23:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lisBq-00019F-8J for xen-devel@lists.xenproject.org; Tue, 18 May 2021 05:22:46 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (unknown [40.107.15.73]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4a23c45e-d7ee-4558-92c6-37e4e9481593; Tue, 18 May 2021 05:22:24 +0000 (UTC) Received: from DB6PR0301CA0067.eurprd03.prod.outlook.com (2603:10a6:6:30::14) by DB7PR08MB3595.eurprd08.prod.outlook.com (2603:10a6:10:40::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Tue, 18 May 2021 05:22:23 +0000 Received: from DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:30:cafe::76) by DB6PR0301CA0067.outlook.office365.com (2603:10a6:6:30::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:22:23 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT050.mail.protection.outlook.com (10.152.21.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:22:23 +0000 Received: ("Tessian outbound 6c8a2be3c2e7:v92"); Tue, 18 May 2021 05:22:22 +0000 Received: from 3507816d2bf8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B8B6842C-802E-4E8C-8D3A-DCCFDAC485D5.1; Tue, 18 May 2021 05:22:14 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3507816d2bf8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 18 May 2021 05:22:14 +0000 Received: from AM6PR08CA0013.eurprd08.prod.outlook.com (2603:10a6:20b:b2::25) by AM8PR08MB6514.eurprd08.prod.outlook.com (2603:10a6:20b:36b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Tue, 18 May 2021 05:22:13 +0000 Received: from VE1EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::7) by AM6PR08CA0013.outlook.office365.com (2603:10a6:20b:b2::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 18 May 2021 05:22:13 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT046.mail.protection.outlook.com (10.152.19.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4129.25 via Frontend Transport; Tue, 18 May 2021 05:22:13 +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.2176.14; Tue, 18 May 2021 05:21:58 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.2176.14; Tue, 18 May 2021 05:21:57 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 18 May 2021 05:21:55 +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: 4a23c45e-d7ee-4558-92c6-37e4e9481593 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=86kt5SDAa1ZjE9UwrzfaVaiOyuKnBJmNhimAFnTYVsQ=; b=FNDXUdDE6XbSgKQzOGrBQoWgBBTxX0iyW4vzWkKqz9aBiByrMDockZL+L/txjKwMsppbVuxrjZwbMRpCr+dXCDe1k0EtKNOrQooXM8pGF+fOI9bNZmfVRkPspvjERtnOjv7zoe0s6zfD7W793aSbhlaUl1TYGDKVtYxNVuO/fck= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; 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: 1d0e93b991ec7343 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YL/IIhpCU3zlPC1J3vGI8BK2td25vkHCZ8ss6bBsBC2VzzRQwJUYY/Hed+vRv8eHZxCbQ1gVKsZZPL/1V6RUq+n4VoA0Z3EokdU2GvYbJ57X5l6boigGK3KKyeBqbT4RJNtdnRe2IFWOMIPdjjF7tr2ccx1F7pNzrb01heOobiIrOrQzr4XxF2raBFokrC7lHZ+clnqvY4JNWL55jU9Euoa+gYsmby+qfib5uw5SyMSnSaea4jzorAwE9XrM0ShT6MAVPu8uGCDqwxFqvkwxKBvj9JXNfLKl2rTkjCe03QQ8A5c1nc+SJ7MjFa+ZUvnMRi7d9MtS3m/S99/lu2gThA== 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-SenderADCheck; bh=86kt5SDAa1ZjE9UwrzfaVaiOyuKnBJmNhimAFnTYVsQ=; b=k31a3371Pqn3v4lXkZAjaTdkc8yeC4k4AT7oHEXe1RITFqsUV4IpDyup0OqOziYYL7EV0Ab5yLoC26Dmi05j5S5xxGGy961Vs0utlkIeptDHwNoW+0ee0VWfFmVLBeFIE4QIOTAunABEDZi0rH9AtNiSqPRpardFnzaFSnMBgxxBX8KAxlTfiOMOcsz4xrFgV2s3AEfE+3ejBDa+Ia9Pj+VPUlOusB/O6WX5EcQiFenMbk/aiTpRVJi4ZTCsmnbg3GFTJjnSVJktIAIsskRt8K50jF4tU4uearsHTxRIXDsarur6D+/zzDatNMfugI5Gc56z4l8B3aZgNcJ8gKEQfA== 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=86kt5SDAa1ZjE9UwrzfaVaiOyuKnBJmNhimAFnTYVsQ=; b=FNDXUdDE6XbSgKQzOGrBQoWgBBTxX0iyW4vzWkKqz9aBiByrMDockZL+L/txjKwMsppbVuxrjZwbMRpCr+dXCDe1k0EtKNOrQooXM8pGF+fOI9bNZmfVRkPspvjERtnOjv7zoe0s6zfD7W793aSbhlaUl1TYGDKVtYxNVuO/fck= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; 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 10/10] xen/arm: introduce allocate_static_memory Date: Tue, 18 May 2021 05:21:13 +0000 Message-ID: <20210518052113.725808-11-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518052113.725808-1-penny.zheng@arm.com> References: <20210518052113.725808-1-penny.zheng@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c1fd1713-aab3-4fc5-c7ce-08d919bceaa5 X-MS-TrafficTypeDiagnostic: AM8PR08MB6514:|DB7PR08MB3595: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4714;OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: DvOWAfC9F4plK2BK0M4LykxgQy+wfGrNX4WkLBiBpcGgR5fhu6H7NZP2rmQD03aWP03C0tDyXLFUlVZStZRLiaGXpO60e52QwjV7d8vqkuwLyB/1PWieGl1bJZtVhRF2OFQTZGuZeax/NasVff0QmM4iZsxRVZu9tFxviOcTDCpkAJXTQyOx4W5C3aEG7CjSARY/ztRmmAgkdfJkge8AiPjAz+b3pDpbDqu+wbi9x0zRzt44qsH/xI0uz3GN1ZJhWHTbNPbR+q3N1g99UNqjLmX3i5S4fDjnIy9wkNanOoWV2mqRDMpo1+DUcOUKbsJoKZqGiL7/1nfKyKqkahKOnK/UlwOk5wOEtrF8umBxv5HXEgspDb887ECoqkBqDfJSx8viMaSzFyz9Nyrr924iRvGyN3KEUqdylomxeHAzPfZvKQo34ZIyACwkdoUJKDL0qOblEV8bB73863uB6aimZJSimuI3VjdsvS4P7m8TcsYKgGKEfNPQpGBfYXTQv2ZFov9ay8bDrf4RGqtuGYpouiO06EBWq28EemhUWIFZloKZbGBBhCH+RJa614mCewMBFZSCDyuVGlY3mUcF5Uszgn34io0Vo9q6FjhTsYhnrx1mYAee3H/sTmuLCEOF1SjOXTrS3woOF0oLQ7pr1lz+7pCQgQ7RBrUcBfSGyzj4Mw7UNtPgApU7fJRYc6UtcF7q 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)(376002)(136003)(346002)(396003)(39850400004)(36840700001)(46966006)(426003)(2616005)(5660300002)(82310400003)(110136005)(36756003)(2906002)(26005)(1076003)(4326008)(54906003)(8936002)(83380400001)(81166007)(86362001)(70586007)(356005)(36860700001)(186003)(70206006)(82740400003)(7696005)(6666004)(8676002)(44832011)(47076005)(478600001)(316002)(336012)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6514 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 7ab52b75-5457-4ff1-7abb-08d919bce4c8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aJqKRjPHRC4drwTZr4X5L+QSiGAUNmPVsS9wx9fTJCpPPh78/xmZGuLU0lauA64VNNeGku/pYm9qm5l44U87177bMZYJWW4mYKurqvmphcXi8LoR1v/xwZ/ddueThSqaXdKWVXQIwPapusWhmQSW0+fkMESk6Q1m/tx6E/1UpodXY6DDyqDC5toflcj3MrFJnf+p6+rJtsVNX+fQq6gl2Ox9KO8s42/iABvUTUvfhwQ/2ue9aMTTRi0dk5fqP/dP/bsTjFQBPsNiV/QS9f1KRUz/nyEfueodreau3OEKu/0cVNK2FG9LqXgRLATm1OtsQP9VVb5yHW7gMniZAknHfH3J9HF4aYW/UhgsrxHgYMQudJoraZ7nSWoO9ll68zyAkP3i0gXBTwwz7g2qqbwNP4f57VdU3ALZ95l1PvlHQ/a0CT5sdJhCzXTl2qy+RgISuV6MyM5WxhkWgOFDNEF1QoD1ruw2hFxsBHleGBDKRgP3Rg0SECsoJiqFqkoVUi52bbL4W5mJl62+gJpQzqVHi3CsvuzPOxfKjiBa3/aX/53HjCl9Rr9Z13q6HEKWTeChslXlSwkD/TkgzHWQqOd6Otr/KEE/ji32dUgC0LeDVmW6bHXGHBverIF7sXoWorEI2WCndDc3FETqZqBsr8IxyA== 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)(396003)(136003)(376002)(39850400004)(346002)(36840700001)(46966006)(336012)(36756003)(44832011)(86362001)(478600001)(2616005)(426003)(1076003)(186003)(4326008)(82740400003)(26005)(8676002)(6666004)(8936002)(81166007)(83380400001)(47076005)(82310400003)(36860700001)(110136005)(316002)(70206006)(70586007)(5660300002)(54906003)(7696005)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2021 05:22:23.0845 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c1fd1713-aab3-4fc5-c7ce-08d919bceaa5 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: DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3595 This commit introduces allocate_static_memory to allocate static memory as guest RAM for domain on Static Allocation. It uses alloc_domstatic_pages to allocate pre-defined static memory banks for this domain, and uses guest_physmap_add_page to set up P2M table, guest starting at fixed GUEST_RAM0_BASE, GUEST_RAM1_BASE. Signed-off-by: Penny Zheng --- xen/arch/arm/domain_build.c | 157 +++++++++++++++++++++++++++++++++++- 1 file changed, 155 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 30b55588b7..9f662313ad 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -437,6 +437,50 @@ static bool __init allocate_bank_memory(struct domain *d, return true; } +/* + * #ram_index and #ram_index refer to the index and starting address of guest + * memory kank stored in kinfo->mem. + * Static memory at #smfn of #tot_size shall be mapped #sgfn, and + * #sgfn will be next guest address to map when returning. + */ +static bool __init allocate_static_bank_memory(struct domain *d, + struct kernel_info *kinfo, + int ram_index, + paddr_t ram_addr, + gfn_t* sgfn, + mfn_t smfn, + paddr_t tot_size) +{ + int res; + struct membank *bank; + paddr_t _size = tot_size; + + bank = &kinfo->mem.bank[ram_index]; + bank->start = ram_addr; + bank->size = bank->size + tot_size; + + while ( tot_size > 0 ) + { + unsigned int order = get_allocation_size(tot_size); + + res = guest_physmap_add_page(d, *sgfn, smfn, order); + if ( res ) + { + dprintk(XENLOG_ERR, "Failed map pages to DOMU: %d", res); + return false; + } + + *sgfn = gfn_add(*sgfn, 1UL << order); + smfn = mfn_add(smfn, 1UL << order); + tot_size -= (1ULL << (PAGE_SHIFT + order)); + } + + kinfo->mem.nr_banks = ram_index + 1; + kinfo->unassigned_mem -= _size; + + return true; +} + static void __init allocate_memory(struct domain *d, struct kernel_info *kinfo) { unsigned int i; @@ -480,6 +524,116 @@ fail: (unsigned long)kinfo->unassigned_mem >> 10); } +/* 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) +{ + int nr_banks, _banks = 0; + size_t ram0_size = GUEST_RAM0_SIZE, ram1_size = GUEST_RAM1_SIZE; + paddr_t bank_start, bank_size; + gfn_t sgfn; + mfn_t smfn; + + kinfo->mem.nr_banks = 0; + sgfn = gaddr_to_gfn(GUEST_RAM0_BASE); + nr_banks = d->arch.static_mem.nr_banks; + ASSERT(nr_banks >= 0); + + if ( kinfo->unassigned_mem <= 0 ) + goto fail; + + while ( _banks < nr_banks ) + { + bank_start = d->arch.static_mem.bank[_banks].start; + smfn = maddr_to_mfn(bank_start); + bank_size = d->arch.static_mem.bank[_banks].size; + + if ( !alloc_domstatic_pages(d, bank_size >> PAGE_SHIFT, bank_start, 0) ) + { + printk(XENLOG_ERR + "%pd: cannot allocate static memory" + "(0x%"PRIx64" - 0x%"PRIx64")", + d, bank_start, bank_start + bank_size); + goto fail; + } + + /* + * By default, it shall be mapped to the fixed guest RAM address + * `GUEST_RAM0_BASE`, `GUEST_RAM1_BASE`. + * Starting from RAM0(GUEST_RAM0_BASE). + */ + if ( ram0_size ) + { + /* RAM0 at most holds GUEST_RAM0_SIZE. */ + if ( ram0_size >= bank_size ) + { + if ( !allocate_static_bank_memory(d, kinfo, + 0, GUEST_RAM0_BASE, + &sgfn, smfn, bank_size) ) + goto fail; + + ram0_size = ram0_size - bank_size; + _banks++; + continue; + } + else /* bank_size > ram0_size */ + { + if ( !allocate_static_bank_memory(d, kinfo, + 0, GUEST_RAM0_BASE, + &sgfn, smfn, ram0_size) ) + goto fail; + + /* The whole RAM0 is consumed. */ + ram0_size -= ram0_size; + /* This bank hasn't been totally mapped, seeking to RAM1. */ + bank_size = bank_size - ram0_size; + smfn = mfn_add(smfn, ram0_size >> PAGE_SHIFT); + sgfn = gaddr_to_gfn(GUEST_RAM1_BASE); + } + } + + if ( ram1_size >= bank_size ) + { + if ( !allocate_static_bank_memory(d, kinfo, + 1, GUEST_RAM1_BASE, + &sgfn, smfn, bank_size) ) + goto fail; + + ram1_size = ram1_size - bank_size; + _banks++; + continue; + } + else + /* + * If RAM1 still couldn't meet the requirement, + * no way to seek for now. + */ + goto fail; + } + + if ( kinfo->unassigned_mem ) + goto fail; + + for( int i = 0; i < kinfo->mem.nr_banks; i++ ) + { + printk(XENLOG_INFO "%pd BANK[%d] %#"PRIpaddr"-%#"PRIpaddr" (%ldMB)\n", + d, + i, + kinfo->mem.bank[i].start, + kinfo->mem.bank[i].start + kinfo->mem.bank[i].size, + /* Don't want format this as PRIpaddr (16 digit hex) */ + (unsigned long)(kinfo->mem.bank[i].size >> 20)); + } + + return; + +fail: + panic("Failed to allocate requested domain memory." + /* Don't want format this as PRIpaddr (16 digit hex) */ + " %ldKB unallocated. Fix the VMs configurations.\n", + (unsigned long)kinfo->unassigned_mem >> 10); +} + static int __init write_properties(struct domain *d, struct kernel_info *kinfo, const struct dt_device_node *node) { @@ -2497,8 +2651,7 @@ static int __init construct_domU(struct domain *d, d->arch.type = kinfo.type; #endif if ( static_mem ) - /* allocate_static_memory(d, &kinfo); */ - BUG(); + allocate_static_memory(d, &kinfo); else allocate_memory(d, &kinfo);