From nobody Tue Apr 23 13:50:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=2; a=rsa-sha256; t=1631094875; cv=pass; d=zohomail.com; s=zohoarc; b=VfvmDaf84VmOPsJmV0IUuWxo/rXbt3mYO/ff2IsWo6eyh10Zm0vrHrm+Lp4NcCYEvaPEn30YcBAy+UULvGg5SkPhzapIHDic17yW91PeJiyHk2MkmkERJBSeK6zgpOL5fBfRmG7O0fVhO1e6/MMgUXdyWMNskmnsdJStB8hJueo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631094875; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=atD+jn23OE3UfPIAVyiiv0CU9p/Xc0KpqFQDOZmE+ro=; b=I2e+rhdLt4byq34FQmFH3+00EgtCa6mwJhQeFhFaJhlTLDC8aYk/E12bXaYv/7NPAYa3v4T/yb/c0mnp8mpnE0NWhrbWiN0HSmRDWpggWhLvZEfdzQCV4WSM27C7VJToidMfKCJaxLxXQcfqTyjCz63QeTyPJJ6wXe/6RFyYIeI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631094875512915.0465184819966; Wed, 8 Sep 2021 02:54:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.181610.328801 (Exim 4.92) (envelope-from ) id 1mNuHa-0000bp-Nh; Wed, 08 Sep 2021 09:54:18 +0000 Received: by outflank-mailman (output) from mailman id 181610.328801; Wed, 08 Sep 2021 09:54:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuHa-0000bi-KL; Wed, 08 Sep 2021 09:54:18 +0000 Received: by outflank-mailman (input) for mailman id 181610; Wed, 08 Sep 2021 09:54:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuHZ-0000bc-I7 for xen-devel@lists.xenproject.org; Wed, 08 Sep 2021 09:54:17 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.49]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id b7b15bec-2067-4a9e-95f2-30d0d984b939; Wed, 08 Sep 2021 09:54:14 +0000 (UTC) Received: from AM5PR0701CA0057.eurprd07.prod.outlook.com (2603:10a6:203:2::19) by AM4PR08MB2884.eurprd08.prod.outlook.com (2603:10a6:205:e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Wed, 8 Sep 2021 09:54:13 +0000 Received: from VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:2:cafe::f6) by AM5PR0701CA0057.outlook.office365.com (2603:10a6:203:2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.8 via Frontend Transport; Wed, 8 Sep 2021 09:54:13 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT014.mail.protection.outlook.com (10.152.19.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:12 +0000 Received: ("Tessian outbound 7a08471b1ef6:v105"); Wed, 08 Sep 2021 09:54:12 +0000 Received: from f9cb34ce38a9.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E3D35D93-00F2-4BFD-944C-AECC6C0EEA11.1; Wed, 08 Sep 2021 09:54:06 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f9cb34ce38a9.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Sep 2021 09:54:06 +0000 Received: from AM0PR10CA0063.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:15::16) by VI1PR0801MB2110.eurprd08.prod.outlook.com (2603:10a6:800:88::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.25; Wed, 8 Sep 2021 09:54:05 +0000 Received: from VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:15:cafe::2b) by AM0PR10CA0063.outlook.office365.com (2603:10a6:208:15::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:05 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT008.mail.protection.outlook.com (10.152.18.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:05 +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.2308.14; Wed, 8 Sep 2021 09:54:08 +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.2308.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: b7b15bec-2067-4a9e-95f2-30d0d984b939 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=atD+jn23OE3UfPIAVyiiv0CU9p/Xc0KpqFQDOZmE+ro=; b=xDzMJJMeRGJQCDwVvReAfHVMVZWV5kkt1k/IaREBFsU0uWfazkma23ZCFC+VLoAvBjVEFTHThicE7LUMUoSNItl+eKZSMVAe9OBlpcz1iAJ91ZNiTIWzPv7OdBuBwHCKsD7z4IVhaJuc5kr0kj03Dxbl+1uL+FaghgWwjGdKwOE= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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: d66a6ad96b4563a5 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cs5964ruU/zXdVU2Oti8ZONkQoqxdfDsQ+Ad4dLFvz2eAtl4pgTmcOLaso7sj9c3sbBOFcGrie54bNiuF2TJ5pD1vRikS3RlmZEUBMjuz2POHlb8YHXryV4E5UkcUUq9wwIG5ylvNC/biNvCacVz5aqtFrQiGEbxrjc80xFjeBNE+JmlGPjGzDBGUsIcWGijeJE9dQFoZkADAhTdOQMzHNDOOULJmOiuQuGdagP1koNzi4X/sUt41+iy8Dv0u7YBbtDNROsm4DZim33kY0IeMu2nq+CXC7saPIzkuRunhZgg8wY75B/bNsfW6Mpu6H49YtcVGdsoUZv+d0VfMXcfIw== 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; bh=atD+jn23OE3UfPIAVyiiv0CU9p/Xc0KpqFQDOZmE+ro=; b=UNrFUXPtXXZnq8HhBCkoJokrXzibv+rbk8wPPYZXDvDTQh+SUQOhstHSKVNshg5L+um69/b+DMelqE92erxWyl70ukq7jK3mfO6BRb3lTasxk/F8yg96ph/HHHgjP+Ky8y4YsF2P1QgqpbAZSnMOr9dMr7n1qhBjWOtt/1F2P+vqeylPDG8jQgfgy16QlGOQiBf/4P7f0vBgfPUT77gV2TtUWxFx+K3EN+5Rnoty0BYM/82His+M9No2oq+TPcX2NhnMI0p+gtE89/K6P6AG41LPXKOtkmmR30JM8rpBLLUw8UrgWDGaZDWs3oziWXs7bosBGAP5xdffFhVwl/N9yA== 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=atD+jn23OE3UfPIAVyiiv0CU9p/Xc0KpqFQDOZmE+ro=; b=xDzMJJMeRGJQCDwVvReAfHVMVZWV5kkt1k/IaREBFsU0uWfazkma23ZCFC+VLoAvBjVEFTHThicE7LUMUoSNItl+eKZSMVAe9OBlpcz1iAJ91ZNiTIWzPv7OdBuBwHCKsD7z4IVhaJuc5kr0kj03Dxbl+1uL+FaghgWwjGdKwOE= 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 v6 1/7] xen/arm: introduce new helper device_tree_get_meminfo Date: Wed, 8 Sep 2021 09:52:42 +0000 Message-ID: <20210908095248.545981-2-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210908095248.545981-1-penny.zheng@arm.com> References: <20210908095248.545981-1-penny.zheng@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ea29876-98fb-4e87-885c-08d972ae9cae X-MS-TrafficTypeDiagnostic: VI1PR0801MB2110:|AM4PR08MB2884: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:41;OLM:41; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: GKdMi4ctUd5Xo6YEnZLv4p3v89P/yqnvqJ6+XsyQ6aBjkV3uPeh9BZe4vMYtc5Naum4aPMkRtLp5JoIGUlRFvEG/1poEW1Jwwjlj+e6pOUbajb5zoLKlztI+gxxdph58fZkcG8yUyhFqhNainvmMNExqUpWarbA/3cXBgo7zLE8z49xvQ4QzLlzIqbxNwCy0HtQ/SoHL3RxOC4XgXBrZ6p46Vg78RoXywPOHzvsJA/IiOPu8S5YVYwjHjrSh+GRLgA51Jsn3WkdiV0g3fH9Hv6S4zLpBVg8eg6Czvokwd46t+cmtBzFlucV8W+i6JJeq4hB8zC2oLoK2q3rmviSbzOprJ6LlBTFoMhIlmi5CwUDmOAPf1lIX3QlkZ5u/IuSznqukeFW80wXfQ4lOe2UDEnw4RmbTtARUhFo3KhkRmir4zDdVXSKbL9jztG0YVdQdwkfIwkP1ngJNGxHz/2Ahv87osJA9jmgQNOxV70P4N1ZDD55aZcyyRjN3jVtRUIQzjYu+FE8GQ/6rIdP+AgOkmkU2aofwXcBMrjdFNQOfJDQdl6c1BM/IoVqBmoh9KvI60d4qc266hcU7zli7WKKsjVD438ZGWVNVxKLLzC6nd6Tjp7mf8NWolpRHsSUBbrexKO8c4x0lSvhFj0pxii9ZjA5eqauWsJvH8Azhxg+mK+Ww9TWxz5oslGTbuBEDgwKTKB7Psr7dP/Ah5aBTzjpvZILETyYvxTz9PrFTCK9gnyA= 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)(396003)(39860400002)(376002)(346002)(36840700001)(46966006)(5660300002)(2906002)(336012)(478600001)(2616005)(7696005)(316002)(86362001)(47076005)(83380400001)(36756003)(6666004)(26005)(81166007)(82310400003)(1076003)(44832011)(8676002)(82740400003)(4326008)(426003)(110136005)(36860700001)(70206006)(70586007)(8936002)(54906003)(356005)(186003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2110 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: a22bcb71-7aec-41fa-0708-08d972ae981d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4YCmS1+/kYlhRhk0d0qPdxTIYUZkNOq+LhvbJQPjFpoP/PK3JqfOqQ5X/A0anWOmlhiXB8FgeuT+AxOd9Nxh3Iv5jpbx/NEl3ay8wcehhyWpx6CZ8tPYnvqNZCapMEebc6IzCSpy6enV03j+tWKEbx0fQiSf1kKKBu2uRhMb9DILiYK5RZrvuFmek4JK2YOEHet2gib97doolQWaU3pT/jf6ah+XnWPZRUvxHunu2phfNW8W5n8KqHvNMgSQFxgT4XY8gqDg1aSUviCV0K/X1mSF3MhWOeQxei8YvIniEE0d7H8KAnMgQ75RiiGswYZI2PPAPZwuARwwMkWWb1QgpvsCYunitHgZjhCoqi0BnYgOWSktVjhLgGnHwa4v8xtCZykzNPDkmz/b8KW9X2LNfM3p0fPI+Ou4EjGSAkxd1bC07hNvbY6j5biyDQt95QvuJeipeEbtoxChYItvyg0R7JdS53cdAnVy90vQISVRDP5xFwfWmBA+N2WIkQWqm6udpRvK6oaaOraKusANoQ4mWqODhVrr50qWD79yk90B4cMtpWp3AStgGGlDprzzOdTJoY7URX73WQZfYjGLCK7I2xxzo+9LgIS2W1rQVJOvxMt51U8599bi0HmsyALmF6WetZrQJSBi6zqmtSV13lHeHiRlAI/OyiF9iAPGvLwUgBKSOwXCoEprhimzBmJRso5e2yGtsyUUyVkJ2FSyKFxCzw== 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)(376002)(346002)(396003)(39860400002)(46966006)(36840700001)(7696005)(2906002)(82310400003)(86362001)(5660300002)(8676002)(478600001)(70206006)(70586007)(26005)(186003)(47076005)(36860700001)(336012)(8936002)(54906003)(1076003)(316002)(6666004)(2616005)(44832011)(82740400003)(36756003)(83380400001)(4326008)(110136005)(107886003)(81166007)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 09:54:12.7096 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ea29876-98fb-4e87-885c-08d972ae9cae 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: VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2884 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631094877577100001 Content-Type: text/plain; charset="utf-8" This commit creates a new helper device_tree_get_meminfo to iterate over a device tree property to get memory info, like "reg". Signed-off-by: Penny Zheng Reviewed-by: Stefano Stabellini --- xen/arch/arm/bootfdt.c | 83 ++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 476e32e0f5..b01badda3e 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -63,6 +63,52 @@ void __init device_tree_get_reg(const __be32 **cell, u32= address_cells, *size =3D dt_next_cell(size_cells, cell); } =20 +static int __init device_tree_get_meminfo(const void *fdt, int node, + const char *prop_name, + u32 address_cells, u32 size_cell= s, + void *data) +{ + const struct fdt_property *prop; + unsigned int i, banks; + const __be32 *cell; + u32 reg_cells =3D address_cells + size_cells; + paddr_t start, size; + struct meminfo *mem =3D data; + + if ( address_cells < 1 || size_cells < 1 ) + { + printk("fdt: property `%s': invalid #address-cells or #size-cells", + prop_name); + return -EINVAL; + } + + prop =3D fdt_get_property(fdt, node, prop_name, NULL); + if ( !prop ) + return -ENOENT; + + cell =3D (const __be32 *)prop->data; + banks =3D fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); + + for ( i =3D 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ ) + { + device_tree_get_reg(&cell, address_cells, size_cells, &start, &siz= e); + /* Some DT may describe empty bank, ignore them */ + if ( !size ) + continue; + mem->bank[mem->nr_banks].start =3D start; + mem->bank[mem->nr_banks].size =3D size; + mem->nr_banks++; + } + + if ( i < banks ) + { + printk("Warning: Max number of supported memory regions reached.\n= "); + return -ENOSPC; + } + + return 0; +} + u32 __init device_tree_get_u32(const void *fdt, int node, const char *prop_name, u32 dflt) { @@ -139,42 +185,7 @@ static int __init process_memory_node(const void *fdt,= int node, u32 address_cells, u32 size_cells, void *data) { - const struct fdt_property *prop; - int i; - int banks; - const __be32 *cell; - paddr_t start, size; - u32 reg_cells =3D address_cells + size_cells; - struct meminfo *mem =3D data; - - if ( address_cells < 1 || size_cells < 1 ) - { - printk("fdt: node `%s': invalid #address-cells or #size-cells", - name); - return -EINVAL; - } - - prop =3D fdt_get_property(fdt, node, "reg", NULL); - if ( !prop ) - return -ENOENT; - - cell =3D (const __be32 *)prop->data; - banks =3D fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); - - for ( i =3D 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ ) - { - device_tree_get_reg(&cell, address_cells, size_cells, &start, &siz= e); - /* Some DT may describe empty bank, ignore them */ - if ( !size ) - continue; - mem->bank[mem->nr_banks].start =3D start; - mem->bank[mem->nr_banks].size =3D size; - mem->nr_banks++; - } - - if ( i < banks ) - return -ENOSPC; - return 0; + return device_tree_get_meminfo(fdt, node, "reg", address_cells, size_c= ells, data); } =20 static int __init process_reserved_memory_node(const void *fdt, int node, --=20 2.25.1 From nobody Tue Apr 23 13:50:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=2; a=rsa-sha256; t=1631094906; cv=pass; d=zohomail.com; s=zohoarc; b=B2RQamNWWo1UEA20H1we4odaWr2ZjNTVL4LBZFY28/m/whPPXVl183lbg9UX9RpI1ucr5Ris2BpBYX8pbVljX06Nycqt2w7BRDC6f08joMlDpIcc9cM3j69IB0aqu/iXSIKvf0ZqlsYuixqdH9uHL7GhAZ6SykXySVDRkuhIv8A= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631094906; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MXkdwEjVyQ82/D1j1eSxQZQfJtE5JUO8wUvXNctlD2M=; b=LVs93Efnjb+Ttz1n7w1sNO1Yj2uUQE+tf4yFKGAZbCc7dO9t7pWjWT19ayAiI7bLZfYpNLWW1mhCI++ekDXaTnWRxiTgC8WGMSaWEaYNAU/4BJUh+zvOAM9Czn/y5X+GSJBcbzLJzNKY3oQYN96WkmLIkPes+xka09+pvpZb/L4= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631094906019995.2938994388861; Wed, 8 Sep 2021 02:55:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.181628.328900 (Exim 4.92) (envelope-from ) id 1mNuI6-0004Zm-JX; Wed, 08 Sep 2021 09:54:50 +0000 Received: by outflank-mailman (output) from mailman id 181628.328900; Wed, 08 Sep 2021 09:54:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuI6-0004Z9-Eq; Wed, 08 Sep 2021 09:54:50 +0000 Received: by outflank-mailman (input) for mailman id 181628; Wed, 08 Sep 2021 09:54:48 +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 1mNuI4-0001EI-4h for xen-devel@lists.xenproject.org; Wed, 08 Sep 2021 09:54:48 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [40.107.8.44]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c4067fc8-108a-11ec-b148-12813bfff9fa; Wed, 08 Sep 2021 09:54:32 +0000 (UTC) Received: from DBBPR09CA0022.eurprd09.prod.outlook.com (2603:10a6:10:c0::34) by DBAPR08MB5717.eurprd08.prod.outlook.com (2603:10a6:10:1ae::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.21; Wed, 8 Sep 2021 09:54:29 +0000 Received: from DB5EUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::ee) by DBBPR09CA0022.outlook.office365.com (2603:10a6:10:c0::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:29 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT045.mail.protection.outlook.com (10.152.21.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:29 +0000 Received: ("Tessian outbound b48d04bf8afd:v105"); Wed, 08 Sep 2021 09:54:29 +0000 Received: from 0a083f3b0cee.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9541EF8D-BDB2-4C5C-B993-98BB700987A7.1; Wed, 08 Sep 2021 09:54:08 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0a083f3b0cee.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Sep 2021 09:54:08 +0000 Received: from DU2PR04CA0019.eurprd04.prod.outlook.com (2603:10a6:10:3b::24) by VI1PR08MB2814.eurprd08.prod.outlook.com (2603:10a6:802:1f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.22; Wed, 8 Sep 2021 09:54:06 +0000 Received: from DB5EUR03FT054.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3b:cafe::b8) by DU2PR04CA0019.outlook.office365.com (2603:10a6:10:3b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:06 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT054.mail.protection.outlook.com (10.152.20.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:06 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.14; Wed, 8 Sep 2021 09:54:11 +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.2308.14; Wed, 8 Sep 2021 09:54:04 +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.2308.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: c4067fc8-108a-11ec-b148-12813bfff9fa 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=MXkdwEjVyQ82/D1j1eSxQZQfJtE5JUO8wUvXNctlD2M=; b=jVs9JpcbPL22+ynUZG+fFCTyljcDWMetWM2ISdh4k8/+bhThLAQkxVZPJDB1XHOFI5j6nFG03l/T4bOyv5xx3PpMKLKJ3cL9bBRVytLcw7mn3spvuJEpxlGN5Ef/a9pRWOy0bSBo6Y6/aJRse1gyQyFxyqom0QVM6AGewRGlSyg= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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: 8f4fa1b2d57f1ca3 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zas51da3cn0wrB+jPtbEhng/oTJ5BGF73p0uZSLmSekv3DJv0LSZca7XA8LXyWL79GI7l6Sa9Ixg289KyhipO5k2UmK3k7IpVqjn3QoR5wAN6XuppM9ZkzDXJkTBjaNnCsSrmYjg6Dr8EITYHLurqupr844BBzImDOqy8PvrnsHlobqNL1RGXsjyfT2Up2QD0HZTJ8V5S36bRZHyNI2tKyYd2kjPAMSLpC9YuU1o5EMrL+SZxzUlM/PO8wohVrU7C3Lb+DHRvA8XkkZ3atZH24rqVlKCug8/AtC1AeQgbTi4ePJGs9CSxibezV00pFKLwW45AL2p4wzVC7dn7ZO4KA== 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; bh=MXkdwEjVyQ82/D1j1eSxQZQfJtE5JUO8wUvXNctlD2M=; b=VODPylCXW9DRdpWek+PUtrzAicCTB/ZR0jOGe3By8rltTkEGwh4uIergf3dURf+zThfWiNjEjit8RA1ZUG/GGvocTp1hGfNsYMvJyGDfPD/CCpI/RN5vqukhsHhdMj1VtEEaf0OEvM2Kh3rG7HBZyXWzG18DVnLaU3wSOu2pA+tHSMNMpp/WWTLbl+BJCYyulpSZCUo+ac0PFZO1tw89XSLnRI+CI4Op7rCVy4xjqh8rHRILH8vMx34YOpKB2GHyFxEbRv6tW/eM40N9BZGcUeU5C3ZcHzjizQ86mtDNSJ6HsNbV68uAFK3cHhisWKSzSj+ql051s70vUMKNXSSepw== 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=MXkdwEjVyQ82/D1j1eSxQZQfJtE5JUO8wUvXNctlD2M=; b=jVs9JpcbPL22+ynUZG+fFCTyljcDWMetWM2ISdh4k8/+bhThLAQkxVZPJDB1XHOFI5j6nFG03l/T4bOyv5xx3PpMKLKJ3cL9bBRVytLcw7mn3spvuJEpxlGN5Ef/a9pRWOy0bSBo6Y6/aJRse1gyQyFxyqom0QVM6AGewRGlSyg= 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 v6 2/7] xen/arm: introduce domain on Static Allocation Date: Wed, 8 Sep 2021 09:52:43 +0000 Message-ID: <20210908095248.545981-3-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210908095248.545981-1-penny.zheng@arm.com> References: <20210908095248.545981-1-penny.zheng@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 14296cbc-908d-4340-a8a5-08d972aea66a X-MS-TrafficTypeDiagnostic: VI1PR08MB2814:|DBAPR08MB5717: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: LuIu0+pxr56YjVQdUDpyJ+gR2ldmA70kBn2fBEG8oVQJFLdkO/Ul42sid/6FWDHmUtq9gB8w/C2X5evd3wkF141bNGz56MwVH5FsWrH4RO6gD2yvVOxij7+St3XMlUsMY1PRv3VIKPFuqnIgb/ozHdVsH0Yp+/QXn+ikny5wRYCwJjBunpBGS+8wKdnh5gbAzXneE2HsA4VnfHdpMnirLZi+RjbYwCvAaovMCZ4vf9qD3Egl7qS8eMgp+g2AQDW8sKzEDBwVFxBZMijVJUMsLEjM1qiI6RctvfAELYmeN+zamsb2KYTjbnWiT1mgtqmB9fsgm/dFU5zkI0RAkqy1lBczrGvs7RXn8/JiG6CaBX7esACf+OlFeoCJgom04NCXc9ePcyP/pRsYrh3ms3BSeciAl8qox4k0n2WN9V5PTShOuecDIT+Kly0gL0lRUeXOW1DjxJC1PEQ0KDRYe34pVtdALrscJWQLFa7+xWcLvuUqgLxVSD10d3qivcj5NipjEZI/0aKmHh7EKCXk+vtfc3BzSJbXKgX7ZD4xhp8gAUfThRe5R+LZrKo7wXyqS4t2h1VfBZOgFBa8lZAkLZXV2v0YU6HHxEmqctjkRASVxkauRznlMPIEELJCqcrmrj13mR0fyiiC31XS1icdZYkIdMfMtLPbKiyNC4ejuG6Q3VoVPP08ORAHqy+f0p/E9BfUMaTqlBMDcBN+26YdDFeD3ikoR0+6JuPTLKTmkpYPLvo= 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)(346002)(136003)(376002)(39860400002)(36840700001)(46966006)(1076003)(82740400003)(6666004)(83380400001)(2906002)(36756003)(110136005)(5660300002)(86362001)(54906003)(7696005)(82310400003)(44832011)(4326008)(478600001)(47076005)(186003)(36860700001)(81166007)(8936002)(70206006)(356005)(70586007)(336012)(26005)(8676002)(2616005)(316002)(426003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2814 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ca927daa-0fb8-49a1-4a09-08d972ae98bb X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PeQjW98bbKWCZUD1BXubt1SIO2xgvOs+wnBCilTNnJNJmSN5HtEqwHQWR0l0hxf1tmG1EJZ1xr71Z4F2vxxCbeN4QopyIovKq8b4PeVZiv29fdbKdWDaTS1+uFNzxA29Wvt8BUMgXpBSY5m00SrSacSSQzq2NaWTeO6bsqGAjMHIYmeDgTP86UA2ymW4pwYvdXXASDwHbg44kTia43lZPK1CpAScjmZqid4mVPqMrsOzU9SUEf7YVUwV9uteLu9w51bzNhji57Naoy2HDVt6zm1lVILYkbfU4cO+EZiMd/NE/IRoh1EbFtYRdhFwkSBL4KvQbPUBG1o8nqMw6EMgrda//8hz97RncAmfg8p3y6yXUyKxOyl88XBEYk35dBsgPv3LXlhmftkdZlOd/AVKKrKmvZbwe9MBHrMUN80HpGHGkoDkzYQ6W82TKx5KOjGuzvQ+kcZSmsOoVsUv35A0+I4PLvJMPkk4aMgA04uMfjCF5KjvdJQUC08a5YXB1KU49ueldg+IbXstcq1yl4Xq5tcU9pRj+9Pyxtj2khf5bkWgTlHVuHNTJ1bnzasz1N99JbqzQUA1ZGtRpC9pef3X1tmI/GDAPSUXLYSg/BejjClF2baK5CNR5aWrQzFxEU2BfbHB+rluZ+PFgaZR8k5d8GzrLXAi3/pBxM6Aaiyar8MgxgLwbJ5j4ZCNG90bAiq9y9sn1vfO2nTUgzkZaNW9MA== 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)(396003)(39860400002)(376002)(346002)(46966006)(36840700001)(36860700001)(426003)(81166007)(107886003)(186003)(36756003)(478600001)(5660300002)(316002)(86362001)(336012)(82310400003)(8676002)(70206006)(54906003)(70586007)(26005)(1076003)(82740400003)(110136005)(2616005)(47076005)(2906002)(6666004)(44832011)(7696005)(8936002)(4326008)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 09:54:29.1439 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 14296cbc-908d-4340-a8a5-08d972aea66a X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5717 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631094907137100001 Content-Type: text/plain; charset="utf-8" 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 Memory, as parts of RAM reserved in the beginning, shall never go to heap allocator or boot allocator for any use. Memory can be statically allocated to a domain using the property "xen,stat= ic- mem" defined in the domain configuration. The number of cells for the addre= ss and the size must be defined using respectively the properties "#xen,static-mem-address-cells" and "#xen,static-mem-size-cells". The property 'memory' is still needed and should match the amount of memory given to the guest. Currently, it either comes from static memory or lets X= en allocate from heap. *Mixing* is not supported. The static memory will be mapped in the guest at the usual guest memory addresses (GUEST_RAM0_BASE, GUEST_RAM1_BASE) defined by xen/include/public/arch-arm.h. This patch introduces this new `xen,static-mem` feature, and also documents and parses this new attribute at boot time. This patch also introduces a new field "bool xen_domain" in "struct membank" to tell whether the memory bank is reserved as the whole hardware resource, or bind to a xen domain node, through "xen,static-mem" Signed-off-by: Penny Zheng Reviewed-by: Stefano Stabellini --- docs/misc/arm/device-tree/booting.txt | 42 +++++++++++++++++++++++++++ xen/arch/arm/bootfdt.c | 30 +++++++++++++++++-- xen/include/asm-arm/setup.h | 1 + 3 files changed, 71 insertions(+), 2 deletions(-) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-t= ree/booting.txt index 5243bc7fd3..44cd9e1a9a 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -268,3 +268,45 @@ 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 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Static Allocation refers to system or sub-system(domains) for which memory +areas are pre-defined by configuration using physical address ranges. + +Memory can be statically allocated to a domain using the property "xen,sta= tic- +mem" defined in the domain configuration. The number of cells for the addr= ess +and the size must be defined using respectively the properties +"#xen,static-mem-address-cells" and "#xen,static-mem-size-cells". + +The property 'memory' is still needed and should match the amount of memory +given to the guest. Currently, it either comes from static memory or lets = Xen +allocate from heap. *Mixing* is not supported. + +The static memory will be mapped in the guest at the usual guest memory +addresses (GUEST_RAM0_BASE, GUEST_RAM1_BASE) defined by +xen/include/public/arch-arm.h. + +Below is an example on how to specify the static memory region in the +device-tree: + + / { + chosen { + domU1 { + compatible =3D "xen,domain"; + #address-cells =3D <0x2>; + #size-cells =3D <0x2>; + cpus =3D <2>; + memory =3D <0x0 0x80000>; + #xen,static-mem-address-cells =3D <0x1>; + #xen,static-mem-size-cells =3D <0x1>; + xen,static-mem =3D <0x30000000 0x20000000>; + ... + }; + }; + }; + +This will reserve a 512MB region starting at the host physical address +0x30000000 to be exclusively used by DomU1. diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index b01badda3e..afaa0e249b 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -66,7 +66,7 @@ void __init device_tree_get_reg(const __be32 **cell, u32 = address_cells, static int __init device_tree_get_meminfo(const void *fdt, int node, const char *prop_name, u32 address_cells, u32 size_cell= s, - void *data) + void *data, bool xen_domain) { const struct fdt_property *prop; unsigned int i, banks; @@ -97,6 +97,7 @@ static int __init device_tree_get_meminfo(const void *fdt= , int node, continue; mem->bank[mem->nr_banks].start =3D start; mem->bank[mem->nr_banks].size =3D size; + mem->bank[mem->nr_banks].xen_domain =3D xen_domain; mem->nr_banks++; } =20 @@ -185,7 +186,8 @@ static int __init process_memory_node(const void *fdt, = int node, u32 address_cells, u32 size_cells, void *data) { - return device_tree_get_meminfo(fdt, node, "reg", address_cells, size_c= ells, data); + return device_tree_get_meminfo(fdt, node, "reg", address_cells, size_c= ells, + data, false); } =20 static int __init process_reserved_memory_node(const void *fdt, int node, @@ -339,6 +341,28 @@ static void __init process_chosen_node(const void *fdt= , int node, add_boot_module(BOOTMOD_RAMDISK, start, end-start, false); } =20 +static int __init process_domain_node(const void *fdt, int node, + const char *name, + u32 address_cells, u32 size_cells) +{ + const struct fdt_property *prop; + + printk("Checking for \"xen,static-mem\" in domain node\n"); + + prop =3D fdt_get_property(fdt, node, "xen,static-mem", NULL); + if ( !prop ) + /* No "xen,static-mem" present. */ + return 0; + + address_cells =3D device_tree_get_u32(fdt, node, + "#xen,static-mem-address-cells", 0= ); + size_cells =3D device_tree_get_u32(fdt, node, + "#xen,static-mem-size-cells", 0); + + return device_tree_get_meminfo(fdt, node, "xen,static-mem", address_ce= lls, + size_cells, &bootinfo.reserved_mem, tru= e); +} + static int __init early_scan_node(const void *fdt, int node, const char *name, int depth, u32 address_cells, u32 size_cells, @@ -357,6 +381,8 @@ static int __init early_scan_node(const void *fdt, process_multiboot_node(fdt, node, name, address_cells, size_cells); else if ( depth =3D=3D 1 && device_tree_node_matches(fdt, node, "chose= n") ) process_chosen_node(fdt, node, name, address_cells, size_cells); + else if ( depth =3D=3D 2 && device_tree_node_compatible(fdt, node, "xe= n,domain") ) + rc =3D process_domain_node(fdt, node, name, address_cells, size_ce= lls); =20 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 c4b6af6029..95da0b7ab9 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -24,6 +24,7 @@ typedef enum { struct membank { paddr_t start; paddr_t size; + bool xen_domain; /* whether the memory bank is bound to a Xen domain. = */ }; =20 struct meminfo { --=20 2.25.1 From nobody Tue Apr 23 13:50:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=2; a=rsa-sha256; t=1631094882; cv=pass; d=zohomail.com; s=zohoarc; b=eULII6IetCSrYvYPkrOecJulpFIwRlbzgAFUoIzMiIIQ0WgVaYYqzLr7UIHvuZVzrEuWJTMS9qQHd5dp7EuJJWxLwFee7ilQtejTJN0GNg5LY5z5vItXLMP5iQZvWm/krv0i5AEGG8yrYa1egZV8Xl58Mfmn5If+VZk3LAV+eVY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631094882; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AMCW5xXNqkaV3p45gVg1gz98GeXvw0DWsgYQwmmZLho=; b=Evv02wjvdmMHNG0jhoAqO0QSvN1qzm2G15INf3rpK5/ICqzJ0JZhdL7N5L06YvJuPN1j1lpd5i8/cHNC9AQzjeTUv9Vy8On0bniyq1daRlvEj673LOZTevrVd6SGZ6KGXEyYKqZD0Q9LbSs+3AektZBNHOHhPyc9F+HsKVBl1L8= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16310948826101001.9267194483244; Wed, 8 Sep 2021 02:54:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.181612.328822 (Exim 4.92) (envelope-from ) id 1mNuHk-0001Ep-EE; Wed, 08 Sep 2021 09:54:28 +0000 Received: by outflank-mailman (output) from mailman id 181612.328822; Wed, 08 Sep 2021 09:54:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuHk-0001Eg-Ae; Wed, 08 Sep 2021 09:54:28 +0000 Received: by outflank-mailman (input) for mailman id 181612; Wed, 08 Sep 2021 09:54:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuHj-0000bc-Gg for xen-devel@lists.xenproject.org; Wed, 08 Sep 2021 09:54:27 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.66]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 710e629f-b153-4d48-945e-6e5213475b1e; Wed, 08 Sep 2021 09:54:19 +0000 (UTC) Received: from AM5PR0701CA0002.eurprd07.prod.outlook.com (2603:10a6:203:51::12) by AM6PR08MB4504.eurprd08.prod.outlook.com (2603:10a6:20b:bd::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.20; Wed, 8 Sep 2021 09:54:16 +0000 Received: from VE1EUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:51:cafe::80) by AM5PR0701CA0002.outlook.office365.com (2603:10a6:203:51::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.6 via Frontend Transport; Wed, 8 Sep 2021 09:54:16 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT052.mail.protection.outlook.com (10.152.19.173) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:16 +0000 Received: ("Tessian outbound b48d04bf8afd:v105"); Wed, 08 Sep 2021 09:54:15 +0000 Received: from c44f5e52554f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 51AD65E1-3B5B-43CE-846D-6B3460ACD56B.1; Wed, 08 Sep 2021 09:54:09 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c44f5e52554f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Sep 2021 09:54:09 +0000 Received: from AM6PR01CA0048.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::25) by AM8PR08MB6611.eurprd08.prod.outlook.com (2603:10a6:20b:36b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.22; Wed, 8 Sep 2021 09:54:08 +0000 Received: from VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:e0:cafe::32) 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.4500.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:08 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT055.mail.protection.outlook.com (10.152.19.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:08 +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.2308.14; Wed, 8 Sep 2021 09:54:12 +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.2308.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 710e629f-b153-4d48-945e-6e5213475b1e 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=AMCW5xXNqkaV3p45gVg1gz98GeXvw0DWsgYQwmmZLho=; b=YapclBF9JHWSw1oLOXUWmwDXkDDlWaTR49bkTFpbeJwIZ1rBBqJNxXhnDAI/JAoo8p9yWtJd66enr4DcSMlOe/QFb5pEMqp33UshvsdOIhkkqTzO8ki0m//TZ7jD1rQjgWzo9TBbIQhYKEsI5/dYjTT9YzCtOmGXVnmamuSVO7g= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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: 3fd3d9752e95c7b8 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AKK9ez2QUc/A0Qvnnjmi4Qm9SDSLvrtWPe+seb4l/zxrcXrG30OjJQ64i6vJYHeaC2iatcvOOJ3CDqaz0euepEl1TNfRh8h9Sx655n9qSm2Lh8dvfO6zVJ5nS6pp+/tgsBpL/qPjSVV/QPK83luX6+cwK2M5Jdx62//a4kzBodXult0+CVdsHrxaOZqIhOFdqRyWoNMmtJBei61npWbHIG03wyzriWoUS//pM/hmVUS93Do5ThJb0yKQBMOZqBWjacmanM04ojRf+kHpNGby75j64IeO9hVZkolOpee3sgsqcoMxNzLp7UpONC3xD+EHAu8DnW1ayQhBB1fC7s+nsw== 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; bh=AMCW5xXNqkaV3p45gVg1gz98GeXvw0DWsgYQwmmZLho=; b=jQetPhEu9LIt/pyh59/vFu+WVq1RQJpUb6ZN9XplNmNPv124XFLeAka7LjQjrye0q0bvB2wSufie64zreRzVaGGdPFlUCKTXrMowvssfCru2uJZd+ex0IaQXBE7FgamfsQC8XjiQFj4bqD5iBUAELP7UZ9i7fYZdu/9MFCPIdWTR4KSVgBnweH+n+oY9ehERfWoH4GYptXG/9sX3IqX+S+ArFsfvE2bfEoU/cMqH6+Pq1Z5CPeI4ctev072j9EZUY8DH95w8HN1fQjkNNWhZkqqyqeHGTlm0Is201fIvv+ZVD5cUBBkviuk172rufyZbKW8Ni4s0xFAX138pir+fXQ== 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=AMCW5xXNqkaV3p45gVg1gz98GeXvw0DWsgYQwmmZLho=; b=YapclBF9JHWSw1oLOXUWmwDXkDDlWaTR49bkTFpbeJwIZ1rBBqJNxXhnDAI/JAoo8p9yWtJd66enr4DcSMlOe/QFb5pEMqp33UshvsdOIhkkqTzO8ki0m//TZ7jD1rQjgWzo9TBbIQhYKEsI5/dYjTT9YzCtOmGXVnmamuSVO7g= 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 v6 3/7] xen: introduce mark_page_free Date: Wed, 8 Sep 2021 09:52:44 +0000 Message-ID: <20210908095248.545981-4-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210908095248.545981-1-penny.zheng@arm.com> References: <20210908095248.545981-1-penny.zheng@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9ee270c3-d84b-46e8-5064-08d972ae9eda X-MS-TrafficTypeDiagnostic: AM8PR08MB6611:|AM6PR08MB4504: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1051;OLM:1051; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Pj+BKWgtu/2rQ4dGzigUQfEgqbZ3it7nn01d8j16dP4g9B4AlucmsxNu1vKm0s2lXEk/gazxU3iY+lNYRgf2VrRwvl+5MRUjmnQuZ9+cLpddFf5scxs1xINxL9MF/YIv2kO3ApIElTz+yyVqWcan2kw3f7NU1t2REedGknDeCh/BL5B8ANkUiIro/wXyyuADOhmFjseYOTBkU8wOV51f1PEoouQyCHdSBIRUE+nAfcsBDCrWWxPKeh4PNJLYPL3WYkfQEBXkZ543wZEBKMMzpHCa6xqWpP510jVerubGYxbmnlaJSbPGBizoHtvALRsgflAhPlATYMso6R30dHddZQAwtXWQh6pvgcTiL89xfX+Q/bq83MW0QtCSoUnrJotPZ0E/r6X02HIjtHBP//5V9cREo6vZYXjP011aNPajxQ+M62iWh698aNs8l9o4dbINpXYzZZb+uEB4Ff4zrjVTuwLe5/B8GSv/swJs9vMu1E14hjbD5/vNO3oh/zQ+0CRhS9SBdEgJxJ+Hz4NR3gaBYZ0M+c5nZttQ3iirE/BuqqTAKKdpdQhN9EPECERIAH6MjMzodp8Zo5DUCaCsFg0aMmUM/mdRUw+GtXB4VwC0oiAlj6nEa6yXsk+xOcV2+meQ9wIsTJprIRXA1ez+vAhH1sMuCEIjEV2jx09Tv4KIJJ27o/trv1NLNgl1I7E+icJVA56jUx2PKa0T2cFJMXktzTm8sTatW75UbHCs1IMHgpU= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(2616005)(81166007)(8936002)(426003)(4326008)(316002)(5660300002)(336012)(1076003)(8676002)(47076005)(2906002)(356005)(70586007)(70206006)(83380400001)(36756003)(26005)(110136005)(186003)(86362001)(36860700001)(7696005)(44832011)(82310400003)(6666004)(54906003)(508600001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6611 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: e34ca84a-a1f7-46e3-1735-08d972ae99f2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Txja8jyXeoLQrPOBX1Lv9eB7y+rdXz+wonQN2hXo8IO68DniA/prBGZfUxZ7mkeaSdXOX4krcOhVNmJwIRcYO7u996eLlgrGasxbVOBc8mnYtgJAf+t0h8B+86TLi4iMXfq5BR7YBt4+s1Jmd9xPbtTiyxODkovfbwYBsp00FH+vSL0zndO4JUihmgR60dTNdThuj2qJpPjiMOQcizzYFd+YC1WOrDsoIJhzcyQRciZwlmBE1NeXfg8HBUd6YgcvzsVfq5M5jWjDUmz776NFN6Ga2nQnYUT4H7/9NidFMABnvHQ+aurF9smuBuztpHYRHUy/Vg47P7QSkIuP8fIsr0h6Rb3YcbHcimvmDOWh4iWfvRcxu0IJffhDP43sHtYvHTZBLeRDIfjs42pkFYEZAHgzjn4dflVY5S29Supew0cYBafgFSS5DyNRBF0xjVJe9haBDB3BAdHSOtpt96mEWzW9GYgD4xxZLOIjkaQx2P7pmXPaggoSyoptM7Mxu8QXqr4XoZAwc9yZQMnNXgD+P9+2xc6P3gCuD0zGPPLPe+9Ean4xxQc+MHa98F6yqqQL+RqzRHR27C9YKJfNxv/n5zWTHNC9wdLx7czrYvCbZl06t/1RJIUWMpXT3GdkUwOcBKAekuPPk3LAT/3XWscmxKufuno9G4Kchq/Doh83V50bbc9n7dSMWzkOZnSDkJuhw1veMW4nCSMXelqPcjSV5w== 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)(136003)(376002)(39860400002)(396003)(36840700001)(46966006)(186003)(5660300002)(2616005)(107886003)(83380400001)(86362001)(36860700001)(1076003)(82310400003)(47076005)(6666004)(36756003)(81166007)(478600001)(82740400003)(336012)(70586007)(426003)(8936002)(2906002)(4326008)(316002)(26005)(7696005)(44832011)(54906003)(70206006)(8676002)(110136005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 09:54:16.3489 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ee270c3-d84b-46e8-5064-08d972ae9eda 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: VE1EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4504 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631094883646100001 Content-Type: text/plain; charset="utf-8" This commit defines a new helper mark_page_free to extract common code, like following the same cache/TLB coherency policy, between free_heap_pages and the new function free_staticmem_pages, which will be introduced later. The PDX compression makes that conversion between the MFN and the page can be potentially non-trivial. As the function is internal, pass the MFN and the page. They are both expected to match. Signed-off-by: Penny Zheng Acked-by: Jan Beulich Reviewed-by: Julien Grall --- xen/common/page_alloc.c | 89 ++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 958ba0cd92..a3ee5eca9e 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1376,6 +1376,53 @@ bool scrub_free_pages(void) return node_to_scrub(false) !=3D NUMA_NO_NODE; } =20 +static void mark_page_free(struct page_info *pg, mfn_t mfn) +{ + ASSERT(mfn_x(mfn) =3D=3D mfn_x(page_to_mfn(pg))); + + /* + * Cannot assume that count_info =3D=3D 0, as there are some corner ca= ses + * where it isn't the case and yet it isn't a bug: + * 1. page_get_owner() is NULL + * 2. page_get_owner() is a domain that was never accessible by + * its domid (e.g., failed to fully construct the domain). + * 3. page was never addressable by the guest (e.g., it's an + * auto-translate-physmap guest and the page was never included + * in its pseudophysical address space). + * In all the above cases there can be no guest mappings of this page. + */ + switch ( pg->count_info & PGC_state ) + { + case PGC_state_inuse: + BUG_ON(pg->count_info & PGC_broken); + pg->count_info =3D PGC_state_free; + break; + + case PGC_state_offlining: + pg->count_info =3D (pg->count_info & PGC_broken) | + PGC_state_offlined; + tainted =3D 1; + break; + + default: + printk(XENLOG_ERR + "pg MFN %"PRI_mfn" c=3D%#lx o=3D%u v=3D%#lx t=3D%#x\n", + mfn_x(mfn), + pg->count_info, pg->v.free.order, + pg->u.free.val, pg->tlbflush_timestamp); + BUG(); + } + + /* If a page has no owner it will need no safety TLB flush. */ + pg->u.free.need_tlbflush =3D (page_get_owner(pg) !=3D NULL); + if ( pg->u.free.need_tlbflush ) + page_set_tlbflush_timestamp(pg); + + /* This page is not a guest frame any more. */ + page_set_owner(pg, NULL); /* set_gpfn_from_mfn snoops pg owner */ + set_gpfn_from_mfn(mfn_x(mfn), INVALID_M2P_ENTRY); +} + /* Free 2^@order set of pages. */ static void free_heap_pages( struct page_info *pg, unsigned int order, bool need_scrub) @@ -1392,47 +1439,7 @@ static void free_heap_pages( =20 for ( i =3D 0; i < (1 << order); i++ ) { - /* - * Cannot assume that count_info =3D=3D 0, as there are some corne= r cases - * where it isn't the case and yet it isn't a bug: - * 1. page_get_owner() is NULL - * 2. page_get_owner() is a domain that was never accessible by - * its domid (e.g., failed to fully construct the domain). - * 3. page was never addressable by the guest (e.g., it's an - * auto-translate-physmap guest and the page was never included - * in its pseudophysical address space). - * In all the above cases there can be no guest mappings of this p= age. - */ - switch ( pg[i].count_info & PGC_state ) - { - case PGC_state_inuse: - BUG_ON(pg[i].count_info & PGC_broken); - pg[i].count_info =3D PGC_state_free; - break; - - case PGC_state_offlining: - pg[i].count_info =3D (pg[i].count_info & PGC_broken) | - PGC_state_offlined; - tainted =3D 1; - break; - - default: - printk(XENLOG_ERR - "pg[%u] MFN %"PRI_mfn" c=3D%#lx o=3D%u v=3D%#lx t=3D%#x= \n", - i, mfn_x(mfn) + i, - pg[i].count_info, pg[i].v.free.order, - pg[i].u.free.val, pg[i].tlbflush_timestamp); - BUG(); - } - - /* If a page has no owner it will need no safety TLB flush. */ - pg[i].u.free.need_tlbflush =3D (page_get_owner(&pg[i]) !=3D 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 snoops pg owner= */ - set_gpfn_from_mfn(mfn_x(mfn) + i, INVALID_M2P_ENTRY); + mark_page_free(&pg[i], mfn_add(mfn, i)); =20 if ( need_scrub ) { --=20 2.25.1 From nobody Tue Apr 23 13:50:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=2; a=rsa-sha256; t=1631094899; cv=pass; d=zohomail.com; s=zohoarc; b=jJYuBYMs8+L8EEOJGi+1SraoXYtPEUstisMfC/L/qPM5r1vfqOSV/AXrdcw9o1VVXwA2yjS9lOky9FdDG1YZB//H+vz1x7xouQ5/Omh35RrY70NwyCfVPt2tOKbbY016Sqe8uA1fz8OmOu6fDJoND9F8gDni3O3rFNG3xt9mMQw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631094899; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VWaJ31sy4Cs8NaQhMRjrM5i+mYxMfjvIRjfogEWDwok=; b=cZOyHq8RFbJQPpSu75fhIbxa3OUQ9lTr2FDzchDqcbt0c9luMBxT24zDb2pWKhHKsWYhw/9mKNUJvpT3hsb5MjbQUpM7lg2FPbG6ChF2VMaKKWaQ638W+mRNTyEeKhNw2n2gtPrcEFRpnnM04pznqL1BhZVFLyHg8zV//6ajOng= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631094899524684.3892274062246; Wed, 8 Sep 2021 02:54:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.181622.328878 (Exim 4.92) (envelope-from ) id 1mNuI0-0003VV-HE; Wed, 08 Sep 2021 09:54:44 +0000 Received: by outflank-mailman (output) from mailman id 181622.328878; Wed, 08 Sep 2021 09:54:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuI0-0003VE-DC; Wed, 08 Sep 2021 09:54:44 +0000 Received: by outflank-mailman (input) for mailman id 181622; Wed, 08 Sep 2021 09:54:43 +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 1mNuHz-0001EI-4x for xen-devel@lists.xenproject.org; Wed, 08 Sep 2021 09:54:43 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (unknown [40.107.7.45]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c2f1fdc4-108a-11ec-b148-12813bfff9fa; Wed, 08 Sep 2021 09:54:31 +0000 (UTC) Received: from AS8PR04CA0170.eurprd04.prod.outlook.com (2603:10a6:20b:331::25) by AM5PR0801MB1745.eurprd08.prod.outlook.com (2603:10a6:203:3a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.23; Wed, 8 Sep 2021 09:54:20 +0000 Received: from VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:331:cafe::10) by AS8PR04CA0170.outlook.office365.com (2603:10a6:20b:331::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:20 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT044.mail.protection.outlook.com (10.152.19.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:20 +0000 Received: ("Tessian outbound 0ec886cb54dd:v105"); Wed, 08 Sep 2021 09:54:19 +0000 Received: from a14e68f2d9c3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DD5C5540-293F-4767-9609-8CF34A47C456.1; Wed, 08 Sep 2021 09:54:14 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a14e68f2d9c3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Sep 2021 09:54:14 +0000 Received: from PR0P264CA0185.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::29) by PAXPR08MB7033.eurprd08.prod.outlook.com (2603:10a6:102:205::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.24; Wed, 8 Sep 2021 09:54:12 +0000 Received: from VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:100:1c:cafe::7) by PR0P264CA0185.outlook.office365.com (2603:10a6:100:1c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:12 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT041.mail.protection.outlook.com (10.152.19.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:12 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.14; Wed, 8 Sep 2021 09:54:16 +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.2308.14; Wed, 8 Sep 2021 09:54:08 +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.2308.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: c2f1fdc4-108a-11ec-b148-12813bfff9fa 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=VWaJ31sy4Cs8NaQhMRjrM5i+mYxMfjvIRjfogEWDwok=; b=ADdZ4P/coQ35CGkuuOyodRvhsQCgHL8tdCdcvXXTx/6Gxirwxr7u47BZk8+OQL8/CifC/xmi3e+1QRvl6kNR5TfC9LweWA7PFX0bZE11Vc8aUPsyJg1LKochit52pNyyv+qkCVQm1QuTDQlGz/kA5LarnRMuw4Czu74K43o9928= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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: b74c3c38bd22e03a X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OCGByYaeyKtAb8BiUooJCHGJJ8zpbkoev5qp1lgNYUHAKVyVKqcm9hkr6YVfp+fjkR66G19atRNAUiGq6ftwWCpbUioHJc601UD3+gDByhKbYco9PxARP75fFKwYYyoTZlU9mXiUrqtq8pUSzDaFe6a105BDVjV1vOX6XMe+BcaT1Sv0wUhiLcYg3Y+0GuD5kdq39fHIs+ZtmNtfadQ1ceu3HyQV/dkJk7GJQquAOwNcyP8ew44ZmM2ZBdu58Fg8J6AKqkCehSQVAlKiCZzKscvC8qR46dC4wsNbqb0Gdgjm4Isrs1DNNG9TugICsbmfbHI7w+cdnkQHlGc8xEAsnQ== 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; bh=VWaJ31sy4Cs8NaQhMRjrM5i+mYxMfjvIRjfogEWDwok=; b=S2Kk/A4P1zrQSJjFJf8qln9Uur3sCwvsh1b8EeSGnd3kP5F3J4e0jR6wi7BitSaVrx/Y/Jjv6iZ7/to6uNBOMT1OuV9l9ZSu3Sd1QrzqwlA4NW0suItxdLXmBc3mED2vmndVoHd//2CMpxiJwgEHn8l5o21mbLLy/8NR7Fx7UZGOe3xl09YISM2tUQ5HPm0o4FpbrWBEUMbAy0y7NI5rBwTstujfERMpA7uZjxD+G5SiAiXB8jbFunFn4KrHvcsjnZrVtQ5cgjwzYSqBXbA5zKUDxGB7PVuMmS3O+9vq7SZWF/MsmFDKLdAzLh9dDD+kRlrCrrKhkOP3wZJ9xD5acw== 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=VWaJ31sy4Cs8NaQhMRjrM5i+mYxMfjvIRjfogEWDwok=; b=ADdZ4P/coQ35CGkuuOyodRvhsQCgHL8tdCdcvXXTx/6Gxirwxr7u47BZk8+OQL8/CifC/xmi3e+1QRvl6kNR5TfC9LweWA7PFX0bZE11Vc8aUPsyJg1LKochit52pNyyv+qkCVQm1QuTDQlGz/kA5LarnRMuw4Czu74K43o9928= 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 v6 4/7] xen/arm: static memory initialization Date: Wed, 8 Sep 2021 09:52:45 +0000 Message-ID: <20210908095248.545981-5-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210908095248.545981-1-penny.zheng@arm.com> References: <20210908095248.545981-1-penny.zheng@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d308a56e-e3b3-49a4-f2c7-08d972aea11b X-MS-TrafficTypeDiagnostic: PAXPR08MB7033:|AM5PR0801MB1745: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:207;OLM:207; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ld7uyxPh7vBV7epAQhqr2GgiIKpuSfE7ghweRdu4B9JGWtPhndYkAchVe2lwHxGHNEitVqcvkwTqqv7bJz5pg7qxJ6gWEBjZpe6DoMDGzKqCaDOKpwDOiz58QvKJDtRTz22v6JyeDhal1AHMLiOV+yrXM3PiXQottMnBfxyDXYzhBk1vctIOgPdTjTaafqzM/d56Yl48GHplqCYdZtg+PiF7cRDWTRUOkAvWZmEVQmY/enZowlU8J33YcEzH+UD5XRn8BoRBlxc3Vrm3jFPEivIW4ziJQ6gpfO5zOLUa7FkjqMCYPdF32d7dJwjezJO16XHtEQPx5lva+9IJEWorDSIbxg+0zWuyaZya2P9fXuVM0yelBj/bqM6lEf27oLldbmTRRVeL5GQMNdzUlMntKXE7wCeI9loGmCoS8kriq7vXGCjlogPuUmqMRqbcyFpxzE+lo62mA/F8/Zz5elWJLTXlRSD3u7gA5j9vjzKV1bKoloJ2Z0Ronrwbu+j4urm0K14hYY0366wlsiio/14mpaiVTiAEsqNC8NdV7hlFZV16I9+WO2y1vsbffhI9lCom2CDACYilbZ4pWtQhRIbBJmZ1o7bPW6AoSjlvWMGoM/QEtR+EJmTEJv8ehNkjSBnxJ5L/zycBT1jcReiytxPeOilbSsi7srCDNBKFprAB35/vQeI6zYA4ikPe0fFs0u14wKgue8bznfX12p7YbM4DiAbTvkMcy4hdT3DNTPoy620= 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)(39860400002)(136003)(46966006)(36840700001)(86362001)(316002)(82310400003)(26005)(70586007)(36860700001)(4326008)(336012)(8676002)(110136005)(82740400003)(8936002)(54906003)(186003)(6666004)(70206006)(426003)(1076003)(7696005)(356005)(47076005)(2906002)(36756003)(2616005)(83380400001)(5660300002)(478600001)(44832011)(81166007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7033 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ea79c35b-fd2b-4ef4-cd5c-08d972ae9c9e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HY/1ydUxKveCzmZWY9DTLrajh29OLKuYP2XD/0JadVmUXkfVc4V/AiP0qsKhEvHCWXv0Y6ICjb/JEtOpyj0xOqBJgY1NWTQzNBAHfGWSGV3uPSKlvyhaLGaFLVV90BUrYxC6wUVqYq480td5vnRYWErSHjcT9Bnq8nHTceJ6lpyM/x4ZAa5FiqHKAxnPidc2mlzApJNr08ox4Jny51L9RE+B3di8T6s5X/cuGICNQ7N5MZGGGzFsSGyiIIY72WEJKb2ikafjY7WZTBCREhLKLrnhi2FpkBmt76CLpKiLHIXLGOphWuLkx9um+F0q3OdrN6vGlsQSBPSXRNzEPQ/ruCIdK0inYRoMRtIs9+97E2jv8fYY4+EJWBz7TYQZo89lqHkBs4IhI1ttBhZVAYVVJoLQHZIZ9SXn2RIuOOvdv/KCeJgWiWXG2VJqZTv43pHL+9SvIGwLGw+UBuXXyCavU0tAlOxt7Qzu30dYV4xzAXiMrrygo23eyRe9VsvxWp78cMJCguRvTv4gJBgznofhuIerARyGG5PM6dFIIXch37Mdb3VQHTmrUSYuLYrpezmfe6AFHFlEMzN56e/1lRob+aQr/bNtCmiKqRrp7wsgldVFrjj0RDKT1skec1nQlD4RymVF+680z8on7GJddNBkS05CQ9b609ZdSqYmDtSaheGz+HScSOQQwmxx+bGwEaVVzKvaq4hNLnZ1ey3WRSVJqw== 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)(39860400002)(346002)(136003)(376002)(36840700001)(46966006)(26005)(2616005)(36860700001)(81166007)(82740400003)(6666004)(107886003)(336012)(36756003)(1076003)(83380400001)(47076005)(82310400003)(86362001)(426003)(7696005)(186003)(110136005)(8676002)(316002)(8936002)(478600001)(44832011)(70206006)(5660300002)(70586007)(2906002)(54906003)(4326008);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 09:54:20.1347 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d308a56e-e3b3-49a4-f2c7-08d972aea11b 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: VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1745 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631094900799100001 Content-Type: text/plain; charset="utf-8" This patch introduces static memory initialization, during system boot-up. The new function init_staticmem_pages is responsible for static memory initialization. Helper free_staticmem_pages is the equivalent of free_heap_pages, to free nr_mfns pages of static memory. This commit also introduces a new CONFIG_STATIC_MEMORY option to wrap all static-allocation-related code. Put asynchronously scrubbing pages of static memory in TODO list. Signed-off-by: Penny Zheng Reviewed-by: Stefano Stabellini --- xen/arch/arm/setup.c | 27 +++++++++++++++++++++++++++ xen/common/Kconfig | 13 +++++++++++++ xen/common/page_alloc.c | 21 +++++++++++++++++++++ xen/include/xen/mm.h | 6 ++++++ 4 files changed, 67 insertions(+) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 63a908e325..5be7f2b0c2 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -609,6 +609,29 @@ static void __init init_pdx(void) } } =20 +/* Static memory initialization */ +static void __init init_staticmem_pages(void) +{ +#ifdef CONFIG_STATIC_MEMORY + unsigned int bank; + + for ( bank =3D 0 ; bank < bootinfo.reserved_mem.nr_banks; bank++ ) + { + if ( bootinfo.reserved_mem.bank[bank].xen_domain ) + { + mfn_t bank_start =3D _mfn(PFN_UP(bootinfo.reserved_mem.bank[ba= nk].start)); + unsigned long bank_pages =3D PFN_DOWN(bootinfo.reserved_mem.ba= nk[bank].size); + mfn_t bank_end =3D mfn_add(bank_start, bank_pages); + + if ( mfn_x(bank_end) <=3D mfn_x(bank_start) ) + return; + + free_staticmem_pages(mfn_to_page(bank_start), bank_pages, fals= e); + } + } +#endif +} + #ifdef CONFIG_ARM_32 static void __init setup_mm(void) { @@ -736,6 +759,8 @@ static void __init setup_mm(void) /* Add xenheap memory that was not already added to the boot allocator= . */ init_xenheap_pages(mfn_to_maddr(xenheap_mfn_start), mfn_to_maddr(xenheap_mfn_end)); + + init_staticmem_pages(); } #else /* CONFIG_ARM_64 */ static void __init setup_mm(void) @@ -789,6 +814,8 @@ static void __init setup_mm(void) =20 setup_frametable_mappings(ram_start, ram_end); max_page =3D PFN_DOWN(ram_end); + + init_staticmem_pages(); } #endif =20 diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 0ddd18e11a..3558be0dbc 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -67,6 +67,19 @@ config MEM_ACCESS config NEEDS_LIBELF bool =20 +config STATIC_MEMORY + bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED + depends on ARM + help + Static Allocation refers to system or sub-system(domains) for + which memory areas are pre-defined by configuration using physical + address ranges. + + When enabled, memory can be statically allocated to a domain using + the property "xen,static-mem" defined in the domain configuration. + + If unsure, say N. + menu "Speculative hardening" =20 config SPECULATIVE_HARDEN_ARRAY diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index a3ee5eca9e..ba7adc80db 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2604,6 +2604,27 @@ struct domain *get_pg_owner(domid_t domid) return pg_owner; } =20 +#ifdef CONFIG_STATIC_MEMORY +/* Equivalent of free_heap_pages to free nr_mfns pages of static memory. */ +void __init free_staticmem_pages(struct page_info *pg, unsigned long nr_mf= ns, + bool need_scrub) +{ + mfn_t mfn =3D page_to_mfn(pg); + unsigned long i; + + for ( i =3D 0; i < nr_mfns; i++ ) + { + mark_page_free(&pg[i], mfn_add(mfn, i)); + + if ( need_scrub ) + { + /* TODO: asynchronous scrubbing for pages of static memory. */ + scrub_one_page(pg); + } + } +} +#endif + /* * Local variables: * mode: C diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 667f9dac83..8e8fb5a615 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -85,6 +85,12 @@ bool scrub_free_pages(void); } while ( false ) #define FREE_XENHEAP_PAGE(p) FREE_XENHEAP_PAGES(p, 0) =20 +#ifdef CONFIG_STATIC_MEMORY +/* These functions are for static memory */ +void free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, + bool need_scrub); +#endif + /* Map machine page range in Xen virtual address space. */ int map_pages_to_xen( unsigned long virt, --=20 2.25.1 From nobody Tue Apr 23 13:50:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=2; a=rsa-sha256; t=1631094908; cv=pass; d=zohomail.com; s=zohoarc; b=KMiqMJlwstTsVIkuRMF/4gyrrngOO2k+cl1WEjhseNMOPIU9IHVlGPi1blZpccH96ollkav3W4p46oFWIoLmv/g562ibCfgTUV7tG5F+ksKyOQVh5cqu7ZDj3ExnKRYlq+3uYXb/7n/sCbhFxE6Cq241fUvGmfNcGLNZu1zJGZU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631094908; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GZ922YnGKts8gghHRklqg+V1lm7yq6BNVhkDhoqkHMI=; b=b+JqsIjg4gyPmDgpP0jsKGCg10AB0AR8YySWLHESADU2P6u81+kfqIRujQBbEz9YwVTTwsZh1U3UHj8woau61Uqz0QyC9+I9ZFfM1VLFy1hwq+trLNaUFjYDPI7xv4AMi8U+hA0K0h1bmllWrxgoXPkJKgC72CBGIfISgGQK3dI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631094908199494.63765634868446; Wed, 8 Sep 2021 02:55:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.181634.328911 (Exim 4.92) (envelope-from ) id 1mNuIA-000597-2V; Wed, 08 Sep 2021 09:54:54 +0000 Received: by outflank-mailman (output) from mailman id 181634.328911; Wed, 08 Sep 2021 09:54:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuI9-00058c-RH; Wed, 08 Sep 2021 09:54:53 +0000 Received: by outflank-mailman (input) for mailman id 181634; Wed, 08 Sep 2021 09:54:53 +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 1mNuI9-0001EI-4v for xen-devel@lists.xenproject.org; Wed, 08 Sep 2021 09:54:53 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (unknown [40.107.4.77]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c32e3227-108a-11ec-b148-12813bfff9fa; Wed, 08 Sep 2021 09:54:33 +0000 (UTC) Received: from AM7PR02CA0003.eurprd02.prod.outlook.com (2603:10a6:20b:100::13) by HE1PR0802MB2507.eurprd08.prod.outlook.com (2603:10a6:3:e1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.21; Wed, 8 Sep 2021 09:54:28 +0000 Received: from AM5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:100:cafe::35) by AM7PR02CA0003.outlook.office365.com (2603:10a6:20b:100::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:28 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT050.mail.protection.outlook.com (10.152.17.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:26 +0000 Received: ("Tessian outbound 7a08471b1ef6:v105"); Wed, 08 Sep 2021 09:54:26 +0000 Received: from 74c9ed8f84e5.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 308EF0D1-ED56-442B-A907-3A37F47D11CC.1; Wed, 08 Sep 2021 09:54:20 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 74c9ed8f84e5.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Sep 2021 09:54:20 +0000 Received: from PR0P264CA0172.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::16) by VI1PR0801MB1662.eurprd08.prod.outlook.com (2603:10a6:800:52::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Wed, 8 Sep 2021 09:54:16 +0000 Received: from VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:100:1c:cafe::60) by PR0P264CA0172.outlook.office365.com (2603:10a6:100:1c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:16 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT041.mail.protection.outlook.com (10.152.19.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:16 +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.2308.14; Wed, 8 Sep 2021 09:54:17 +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.2308.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: c32e3227-108a-11ec-b148-12813bfff9fa 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=GZ922YnGKts8gghHRklqg+V1lm7yq6BNVhkDhoqkHMI=; b=oZaIAM+gZAQkg+BJPFVHM36wkQ/p/jcSkuM7oLy3d9SyhjNzPgoHCje0/gEfQQEixz0Ut0Kfhfvm+R2nIgSRDDT62rf08YcIkBuhueU0cPko15zhqOJPsyWRUa1E8+Ui0MHBp9G25VFtUDeMIa2bdzNsWhji6vf1QOeBy2MK3xM= X-MS-Exchange-Authentication-Results: spf=temperror (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=temperror action=none header.from=arm.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-CheckRecipientChecked: true X-CR-MTA-CID: 3a3057876d07db5c X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R1UHluNxa+R6hIjroPCKQEv618n0gJrKd/ItShm0P+PdD4MeCghE9u90DATF9G2gLWmnoTObK+BvZasCqoIcqWSk6EAIbWYMm7OMCSSArlN+GsJGom6hNpxRrWMC+vBhlqvZYCYgk6GxKUN45tBhyrSOBQwJ4zjNCqcNtw0wZ3VUSbEMO48PpBKeijnZ+i/KQGR2Se7Mmj89SLADwfIuGGMan2JQTB2q/K4yRwJhA4yEyVPpXKliB7NiOrMWy43C5Gw9YU8QtyFPCd0V/Hs/SWxN2TPiwRYv87wqGYmQ0gX7piW8IYtifTmAIJx8Xa82I5A94dtqeEFtFH7hjP2PHA== 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; bh=GZ922YnGKts8gghHRklqg+V1lm7yq6BNVhkDhoqkHMI=; b=MB0KTYSaheV22jOk2JpsTHfILbwu0HG4f+6q62WBzM0bkKdPsj1JXmPZAFaVJnw6Sq08NuYgJtCGPeCJbEy8aqv/xfzGCI6ehbCKGrFe43/l+UBTNzDqGCpQZHFh7Oi7EWK12oqlRoGmX8X7vtq349Hvenb7jXppLD5QKaCWTN0mBOIzX59uM0E6rm9d4bYEtACYZwVLZlEUhQwXF6OcltcomOOh6Glw5gz8mE/8atGoXQemSCGFpmrWpRekUuwOLF0vWKq0tKvPxjwTrBkN9KxrJaf1D1OG/XE7RGGfNcf2aoaPbGkdPG31k2S7nrZfa/2Jshv/Ohdg0c5hbpDc4Q== 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=GZ922YnGKts8gghHRklqg+V1lm7yq6BNVhkDhoqkHMI=; b=oZaIAM+gZAQkg+BJPFVHM36wkQ/p/jcSkuM7oLy3d9SyhjNzPgoHCje0/gEfQQEixz0Ut0Kfhfvm+R2nIgSRDDT62rf08YcIkBuhueU0cPko15zhqOJPsyWRUa1E8+Ui0MHBp9G25VFtUDeMIa2bdzNsWhji6vf1QOeBy2MK3xM= 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 v6 5/7] xen: re-define assign_pages and introduce a new function assign_page Date: Wed, 8 Sep 2021 09:52:46 +0000 Message-ID: <20210908095248.545981-6-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210908095248.545981-1-penny.zheng@arm.com> References: <20210908095248.545981-1-penny.zheng@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0467dcbc-9d1c-46db-730d-08d972aea527 X-MS-TrafficTypeDiagnostic: VI1PR0801MB1662:|HE1PR0802MB2507: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:288;OLM:288; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: uFgXCUUMY1VZxuDKCZ7RPJldeqgtMKzm8TK/lpz8Yu1v/Kb/+lgI6z81WLrkfDJTGjwAHrxgYNjIFlLgKynw6B9t7w/zjBRFFCxSd8LdnFhNPHKoO69gOIEpndt1w2GPYD5ri9F0+dxm0pR8O4nQrBY9n64RpWmYPvqee6dL0xy1IpjK+xcL/OFcaTE+1XxEHVQFAIr0JvQarhhtCSEPUDtRlGtn2G+2AutencUc7qnDkRIChKWlvKC+T90jQhHmP7SZ27qcvBCz7uCciNlyEjRy7bfs5mRbFoUCZNxVhvT1/NRfZdHE3jnR+illQZ41I+JthmZvDZweiyDDkOvoVr56zeo/u2rVP0wtvgLSL1Nn3dqRxO3yEN42jR5wxN6O+CKQJMxG0pKmu2YYF9F84YIXxPPmxmPgX8gw1aNTHqyKOnHzvkPz6/L/V/CZt/rNWj7L4WuYzsCD0aEEC+60RGcri6JtiKn7rQcDFPifq1DyyrVf0YXSaJKxeeNX+G3TBhGDZioWxulPwAj9GzZ7rivaMewFZFKVlmf8EtXY6o1fL9mYGmzLie0aO+PxU4ELgp6pQlUb0OfCkK3LL1ioo5HVgkL7xAIID8G1yFJi0GBimIM0GwKQcR1N8QqqKyfgTAVR1SgC7Hp3kTCNQByLzO7JtiqcpcWBOUvi+fVVhcxuLEfUh1ADYZpZnwJatqEGtx3Xt7Ix1TMLRDOuNAoFHMX/3jF5dIDbJmX2voWPy3k= 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)(39860400002)(136003)(376002)(346002)(396003)(36840700001)(46966006)(2906002)(1076003)(44832011)(82740400003)(356005)(2616005)(54906003)(83380400001)(26005)(81166007)(70206006)(82310400003)(8936002)(7696005)(5660300002)(70586007)(110136005)(4326008)(36860700001)(86362001)(47076005)(316002)(186003)(426003)(6666004)(336012)(36756003)(478600001)(8676002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1662 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 0a3a3f3c-2d03-4abb-3fa9-08d972ae9ef2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bfdLnWz4F/l5rOi4ojEeHFBdQMWWDHcVK2Kc+aKrLBzcWM5ooI9jOSCPRYVAn8VqdjKlkH0U45M6/yI+ERxZ5b6pwHV6XOdgXJD6tkcU3rbjClQ3MPltJTxJs2V0bLrO/4nPT9ec5L/NeHWz+DWPzrt8fDctZCaSlHG0sdkvdVZl3nzvQrkDjgti53lHwnUQpuFySeMpRlete10tn8YyAQ6dSKvZCttyZjyWPQfDqTZN3Lgraol3jVVfbxQna6eJIJ4tqMIY7/PYxR6rR8O50lPxs0eS/M6aMaBbp3JrrknuSN5oZAe4C1uj2jiCgs7LOVGYh5G+EysFhPha1I3AhHL24lEclbHbTuPU6f7/69xIh1miuTo0APE7R0qpvWeXLMg4/wHhYCFxlFsSgXo+aIlML0HEYRo8V4MCUPFH95ROMNA5wvo79NJmn+7DGxlVCwCvIqTHQj5dcU7l9b1ueoX2BYutD7qTE+rArBFh04I5b4zeI5JE4jQYVxsXhm64xcTESwBhLb2YhA3SSLANKyO9KcHvyx4gfUdOGAAOyqaQ13eApvIyTUcHFHG2sMSCiUWLp/ovI/piwXO55miBKuq+p7EzlV5Y6kjAGKqn285j5I/tCJepIkJVxq4v7Nc5WtFM+en5vsLT/81JJ3fyqsgb3lSavtwiAzHIzlGKJOr3ORSQFZc99FaLfDCaV1dxBOr3V8+sK9ihBkL1BtIncQ== 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)(39860400002)(136003)(376002)(346002)(396003)(46966006)(36840700001)(316002)(47076005)(2616005)(63370400001)(478600001)(70586007)(26005)(54906003)(2906002)(110136005)(4326008)(36860700001)(1076003)(82740400003)(5660300002)(44832011)(107886003)(82310400003)(6666004)(36756003)(186003)(81166007)(83380400001)(86362001)(426003)(63350400001)(336012)(8936002)(7696005)(8676002)(70206006);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 09:54:26.9728 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0467dcbc-9d1c-46db-730d-08d972aea527 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: AM5EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2507 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631094909282100001 Content-Type: text/plain; charset="utf-8" In order to deal with the trouble of count-to-order conversion when page nu= mber is not in a power-of-two, this commit re-define assign_pages for nr pages a= nd introduces a new helper assign_page for original page with a single order. Signed-off-by: Penny Zheng --- xen/arch/x86/pv/dom0_build.c | 2 +- xen/common/grant_table.c | 2 +- xen/common/memory.c | 6 +++--- xen/common/page_alloc.c | 21 +++++++++++++-------- xen/include/xen/mm.h | 6 ++++++ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index d7f9e04b28..7787cc8fca 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -568,7 +568,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 =3D 0; diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index ee61603a97..50f5f83023 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -2358,7 +2358,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; =20 diff --git a/xen/common/memory.c b/xen/common/memory.c index 74babb0bd7..9cef8790ff 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -728,8 +728,8 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_= memory_exchange_t) arg) /* Assign each output page to the domain. */ for ( j =3D 0; (page =3D page_list_remove_head(&out_chunk_list)); = ++j ) { - if ( assign_pages(d, page, exch.out.extent_order, - MEMF_no_refcount) ) + if ( assign_page(page, exch.out.extent_order, d, + MEMF_no_refcount) ) { unsigned long dec_count; bool_t drop_dom_ref; @@ -797,7 +797,7 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_= memory_exchange_t) arg) * cleared PGC_allocated. */ while ( (page =3D 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 ba7adc80db..bb19bb10ff 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2261,7 +2261,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, unsigned int memflags) { int rc =3D 0; @@ -2281,7 +2281,7 @@ int assign_pages( { unsigned int extra_pages =3D 0; =20 - for ( i =3D 0; i < (1ul << order); i++ ) + for ( i =3D 0; i < nr; i++ ) { ASSERT(!(pg[i].count_info & ~PGC_extra)); if ( pg[i].count_info & PGC_extra ) @@ -2290,18 +2290,18 @@ int assign_pages( =20 ASSERT(!extra_pages || ((memflags & MEMF_no_refcount) && - extra_pages =3D=3D 1u << order)); + extra_pages =3D=3D nr)); } #endif =20 if ( pg[0].count_info & PGC_extra ) { - d->extra_pages +=3D 1u << order; + d->extra_pages +=3D nr; memflags &=3D ~MEMF_no_refcount; } else if ( !(memflags & MEMF_no_refcount) ) { - unsigned int tot_pages =3D domain_tot_pages(d) + (1 << order); + unsigned int tot_pages =3D domain_tot_pages(d) + nr; =20 if ( unlikely(tot_pages > d->max_pages) ) { @@ -2313,10 +2313,10 @@ int assign_pages( } =20 if ( !(memflags & MEMF_no_refcount) && - unlikely(domain_adjust_tot_pages(d, 1 << order) =3D=3D (1 << orde= r)) ) + unlikely(domain_adjust_tot_pages(d, nr) =3D=3D nr) ) get_knownalive_domain(d); =20 - for ( i =3D 0; i < (1 << order); i++ ) + for ( i =3D 0; i < nr; i++ ) { ASSERT(page_get_owner(&pg[i]) =3D=3D NULL); page_set_owner(&pg[i], d); @@ -2331,6 +2331,11 @@ int assign_pages( return rc; } =20 +int assign_page(struct page_info *pg, unsigned int order, struct domain *d, + unsigned int memflags) +{ + return assign_pages(d, pg, 1UL << order, memflags); +} =20 struct page_info *alloc_domheap_pages( struct domain *d, unsigned int order, unsigned int memflags) @@ -2373,7 +2378,7 @@ struct page_info *alloc_domheap_pages( pg[i].count_info =3D PGC_extra; } } - if ( assign_pages(d, pg, order, memflags) ) + if ( assign_page(pg, order, d, 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 8e8fb5a615..a74e93eba8 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -133,8 +133,14 @@ void heap_init_late(void); =20 int assign_pages( struct domain *d, + struct page_info *pg, + unsigned long nr, + unsigned int memflags); + +int assign_page( struct page_info *pg, unsigned int order, + struct domain *d, unsigned int memflags); =20 /* Dump info to serial console */ --=20 2.25.1 From nobody Tue Apr 23 13:50:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=2; a=rsa-sha256; t=1631094893; cv=pass; d=zohomail.com; s=zohoarc; b=FclNEV8mTZwyM0zNZyuRk9t0r54wHecrvig/ptKDdTZBZ6wM4BAnzYtP3fGuixMyFAVF5nAxlZEhOw4FCuT/4E5Dsckc7RKNX67PNguS6f1MrbTf5shgFtnm76Ltr3J7zOq9n6Hea0/OKyq8oVcgI+ME5FPoC5MY85rE4tpCs4c= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631094893; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ulrPrQnKNKHeTjBqMvFiBcaLOSg+pt3ZsckmpTE4xGg=; b=WKvioYByHxx7Px7iQBBHuwzStfUYLmCwbJv5pvZxbepkkmpC3ADdRpdVTeJMorgKi76UNnfXUQDeJOSG30Qt4TB85xHsPnJLPUAZyGTIeaeV7k5ifp7QuV0u4HXDxlyBsY4ul4FXxdTh/RElb63FhKIVaOIuUeBsg/RdNanQ1mw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631094893072586.7852400480941; Wed, 8 Sep 2021 02:54:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.181616.328856 (Exim 4.92) (envelope-from ) id 1mNuHu-0002Sq-Gj; Wed, 08 Sep 2021 09:54:38 +0000 Received: by outflank-mailman (output) from mailman id 181616.328856; Wed, 08 Sep 2021 09:54:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuHu-0002SN-C5; Wed, 08 Sep 2021 09:54:38 +0000 Received: by outflank-mailman (input) for mailman id 181616; Wed, 08 Sep 2021 09:54:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuHt-0000bc-H8 for xen-devel@lists.xenproject.org; Wed, 08 Sep 2021 09:54:37 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.63]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id eece8e26-0e47-4435-b533-0948220731fa; Wed, 08 Sep 2021 09:54:28 +0000 (UTC) Received: from AM5PR0602CA0007.eurprd06.prod.outlook.com (2603:10a6:203:a3::17) by DB9PR08MB6762.eurprd08.prod.outlook.com (2603:10a6:10:2a8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.22; Wed, 8 Sep 2021 09:54:26 +0000 Received: from AM5EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:a3:cafe::f9) by AM5PR0602CA0007.outlook.office365.com (2603:10a6:203:a3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:26 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT037.mail.protection.outlook.com (10.152.17.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:26 +0000 Received: ("Tessian outbound b9872a30149f:v105"); Wed, 08 Sep 2021 09:54:25 +0000 Received: from f70b2a647f00.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 75238AC5-D489-4D20-9685-0146AADA106F.1; Wed, 08 Sep 2021 09:54:20 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f70b2a647f00.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Sep 2021 09:54:20 +0000 Received: from PR0P264CA0191.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::35) by AM6PR08MB3623.eurprd08.prod.outlook.com (2603:10a6:20b:48::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.24; Wed, 8 Sep 2021 09:54:18 +0000 Received: from VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:100:1c:cafe::f) by PR0P264CA0191.outlook.office365.com (2603:10a6:100:1c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:18 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT041.mail.protection.outlook.com (10.152.19.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:18 +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.2308.14; Wed, 8 Sep 2021 09:54:20 +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.2308.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: eece8e26-0e47-4435-b533-0948220731fa 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=ulrPrQnKNKHeTjBqMvFiBcaLOSg+pt3ZsckmpTE4xGg=; b=NhfkiD374f1cloiY9O5ZepaoDxfL6UQl6/Cc71E02QObnBD9V2Eud+a9vo394hrzw9y1mjjMK+/87UDILLF3KNy+EmfSTNDbgXBKds8IQyK2xz9/oLpD2PqZ+QSbvygGs1eRnPjOtDEZIgftBJIW8IH+CPrIOpe26AreZZrAbdU= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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: 23d4e0f8689de261 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HjW+45NasmLGFrCPkiko7oX/Z2tpz6BEGB4dIph9QbnzcK08vthBamEcvApL2p6IommH16cBY71+TNrvIBRfaUbFyoc5BmH94NGUKr9yBvttnkBRz7+UPEDjy3+nw3dHAhg3kl3ZNv27gA3KX8Kz0fzompH8PDcXxdxa2duEnd20VBA8od9J++PHAdhFFM6qCvNQ5D38w1pVtSuMLllMEBcS5KfHRqIDV6tpFpWYRZAUkYccUC9RzLB0XVNLX8h/o/76EDowAuFA/kFVx+9ecadpd/TA3YA4AkE2KpYTRa1ueLfevT8+Yoc78nRWyGMPMXMswLOlGhdP0c7iT2l3MA== 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; bh=ulrPrQnKNKHeTjBqMvFiBcaLOSg+pt3ZsckmpTE4xGg=; b=goRlHzMSp/PDdpVqfzCXTO5VSoUCXPWfS2tdz+Cyb3IKzkSkwIF3c5p1eTqUVpglY9EkHBgMjqK0fisXUq2j5StfC2wcfTQAKulVZSkhus0Tso5oInPVs042ESnZ4qZVrKPYl9E4hAV9MyXgyXe7xsC+A1qKGJwZPrby+F9gr2g6xmSYN4giKawfGWn7sL0wCZnToZCChsHUKWbcXUJg2esM8s383+puoHho2xXH/TOt3kcTP8xj07SUIJ9UYVPKYaC4C8gJmyQKfI/MuAEQyqIGVDUmzzqyFzuq13jg6+lR/Rex2RpCTYIJk/lsuHFO0lOvH7aUuG2yJc8OtKD37w== 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=ulrPrQnKNKHeTjBqMvFiBcaLOSg+pt3ZsckmpTE4xGg=; b=NhfkiD374f1cloiY9O5ZepaoDxfL6UQl6/Cc71E02QObnBD9V2Eud+a9vo394hrzw9y1mjjMK+/87UDILLF3KNy+EmfSTNDbgXBKds8IQyK2xz9/oLpD2PqZ+QSbvygGs1eRnPjOtDEZIgftBJIW8IH+CPrIOpe26AreZZrAbdU= 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 v6 6/7] xen/arm: introduce acquire_staticmem_pages and acquire_domstatic_pages Date: Wed, 8 Sep 2021 09:52:47 +0000 Message-ID: <20210908095248.545981-7-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210908095248.545981-1-penny.zheng@arm.com> References: <20210908095248.545981-1-penny.zheng@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce590b9e-63d8-459c-867d-08d972aea4a7 X-MS-TrafficTypeDiagnostic: AM6PR08MB3623:|DB9PR08MB6762: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6790;OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: nl8jk9LRhIMcN6l2ckGpEixtbCGp8JTWoblfBW+orT5kCMwhRPKY2Rv2p+FIhdNObOFK19X+99rgk8ntJ9Tj1YwVuVwBOzVo98HnEjvMueevO7+jofecUZHcpAxRerkHUkRrOotJIHHODe+RxkJ8HVNI5DTpZifHBgbkHw3lqu2IXO15Z9xPqG4ijWUStS02dIKCNA7c8BNNHYnUBG2iS98CVtvCKZopYORRXH1OWhKbPS1lD2zysEs0xN4ncYvf8xCuy3QmxDGehoPH7zf4Fd0yRVb8KJOUe+8So6Heh/EdpYmvcG7OdRR15wtLnHZwzszX6cF6Kqtk23hMtZHnFvW5EfinQlyNYO63bRuMikS64gZgXzXeu4f83rzrBZC9Lmu/zsL2bY+23cg4vTUGHkd67GstNeDYPYoNsn+b6kqi0Qz3HGfzf1sHV5fFZmToIB/z+vcXDhOxKjCTdxxkna8tzbL0QelSTfNeQ/jbyCgT1r2VkMxIbfDOIvgTZoxCRFqhd4Z2/1vkBfLflYiD3w3/s/E7NrMebORUjsqq+Rzq9jQdNAmgLaO2jARzAt5ZjrdyXm8+GOgEbzuBXvI6Zt6eGUKRp8pwkgimjnBBght92fiYHou9+P8DosWgWFm2Ak7/lOTBoN+Yha/upgE5urHDMPSP2PVg+V732U64M34Ma7aJ1MLo+j/+g4sEYkd7JAEZDx5GuDSKKDHQ0i2mVbWmXwxEmtKQ3MkT3XNrdgE= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(110136005)(316002)(81166007)(356005)(54906003)(7696005)(6666004)(70586007)(2616005)(1076003)(508600001)(336012)(426003)(70206006)(186003)(4326008)(8936002)(2906002)(26005)(5660300002)(8676002)(36860700001)(86362001)(36756003)(44832011)(47076005)(82310400003)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3623 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: d56d9f29-9e71-4677-8119-08d972ae9fe7 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nv23PaB9KOLZkqXBH6qg7uco6r2/L5UmqnXw9D6ODSpa+0csl+0MpfWUz0nqvVfdNrd6qJ7RidszSiEgTd4CVUApqz0bPdoLzc54LK3jvTpic9iKd45Wiq1gv/ZO9HuiJXYmXyK5MO6hJgBvKHcgwcyhfsCWWVmQkcLUDG7SkLjeAZ009jiEIzDkZB7uHncY5Zy2Y2TpXbNe6JlinNekQQj8tFmThfLoMfYlMmIXN5OqPvOaoS6HQYzXaZVRwtoG6yGmp2UW7UyiHXgMNGRgORBnbugjUCqkQP7CjAvKMgm+3u5ELKopZmFnMc46P4GZ1fSgyr+TM0kaD3RVmiuddsUICRtHcCVgpY1oQJ08t+92quvBDqxjGZZ597k9mnVMeO7yMf4rqj36HBKtAMC2Tk6WFPKSuROlQE51IdWYkBOtme9CK0JLkNBcroAGBeOEh9d7vwD3BksolJBUfV7yYxlmBguwvirLGC7uh21R8Pg2NKD87WqffIuYA4RN1LQVeknz7o/OXs0MBePYer4bHp9z1Tgr+xaWz/2BvJQzFxcUDYEj94iWL6t3uw01wcAjPrJmzcC08ostH/3mk+MWpO1ADgovKn7U1eI6Tc5D58A/+3aXRNRnACcGY2b9X64mO9g+UoWXO2s3BhBjjn2WfIvXL7Z7ctxPEut2SJVhDHDUo4CPxQ9f/FmqiEBLOME1DCnLfLvlzDU3FAExh9VSxw== 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)(39860400002)(376002)(396003)(46966006)(36840700001)(81166007)(8936002)(8676002)(70206006)(70586007)(2616005)(7696005)(36756003)(26005)(336012)(426003)(316002)(2906002)(4326008)(47076005)(54906003)(5660300002)(36860700001)(82740400003)(6666004)(110136005)(478600001)(186003)(86362001)(1076003)(83380400001)(44832011)(107886003)(82310400003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 09:54:26.1435 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce590b9e-63d8-459c-867d-08d972aea4a7 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: AM5EUR03FT037.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6762 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631094894370100002 Content-Type: text/plain; charset="utf-8" New function acquire_staticmem_pages aims to acquire nr_mfns contiguous pag= es of static memory, starting at #smfn. And it is the equivalent of alloc_heap_pages for static memory. 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_inuse, etc. New function acquire_domstatic_pages is the equivalent of alloc_domheap_pag= es for static memory, and it is to acquire nr_mfns contiguous pages of static memory and assign them to one specific domain. It uses acquire_staticmem_pages to acquire nr_mfns pages of static memory. Then on success, it will use assign_pages to assign those pages to one specific domain. In order to differentiate pages of static memory from those allocated from heap, this patch introduces a new page flag PGC_reserved, then mark pages of static memory PGC_reserved when initializing them. Signed-off-by: Penny Zheng Reviewed-by: Stefano Stabellini --- xen/common/page_alloc.c | 118 ++++++++++++++++++++++++++++++++++++++- xen/include/asm-arm/mm.h | 3 + xen/include/xen/mm.h | 2 + 3 files changed, 121 insertions(+), 2 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index bb19bb10ff..59dffcfa1d 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -151,6 +151,10 @@ #define p2m_pod_offline_or_broken_replace(pg) BUG_ON(pg !=3D NULL) #endif =20 +#ifndef PGC_reserved +#define PGC_reserved 0 +#endif + /* * Comma-separated list of hexadecimal page numbers containing bad bytes. * e.g. 'badpage=3D0x3f45,0x8a321'. @@ -2283,7 +2287,7 @@ int assign_pages( =20 for ( i =3D 0; i < nr; 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++; } @@ -2322,7 +2326,8 @@ int assign_pages( page_set_owner(&pg[i], d); smp_wmb(); /* Domain pointer must be visible before updating refcn= t. */ pg[i].count_info =3D - (pg[i].count_info & PGC_extra) | PGC_allocated | 1; + (pg[i].count_info & (PGC_extra | PGC_reserved)) | PGC_allocate= d | 1; + page_list_add_tail(&pg[i], page_to_list(d, &pg[i])); } =20 @@ -2626,8 +2631,117 @@ void __init free_staticmem_pages(struct page_info *= pg, unsigned long nr_mfns, /* TODO: asynchronous scrubbing for pages of static memory. */ scrub_one_page(pg); } + + /* In case initializing page of static memory, mark it PGC_reserve= d. */ + pg[i].count_info |=3D PGC_reserved; } } + +/* + * Acquire nr_mfns contiguous reserved pages, starting at #smfn, of + * static memory. + * This function needs to be reworked if used outside of boot. + */ +static struct page_info * __init acquire_staticmem_pages(mfn_t smfn, + unsigned long nr_= mfns, + unsigned int memf= lags) +{ + bool need_tlbflush =3D false; + uint32_t tlbflush_timestamp =3D 0; + unsigned long i; + struct page_info *pg; + + ASSERT(nr_mfns); + for ( i =3D 0; i < nr_mfns; i++ ) + if ( !mfn_valid(mfn_add(smfn, i)) ) + return NULL; + + pg =3D mfn_to_page(smfn); + + spin_lock(&heap_lock); + + for ( i =3D 0; i < nr_mfns; i++ ) + { + /* The page should be reserved and not yet allocated. */ + if ( pg[i].count_info !=3D (PGC_state_free | PGC_reserved) ) + { + printk(XENLOG_ERR + "pg[%lu] Static MFN %"PRI_mfn" c=3D%#lx t=3D%#x\n", + i, mfn_x(smfn) + i, + pg[i].count_info, pg[i].tlbflush_timestamp); + goto out_err; + } + + if ( !(memflags & MEMF_no_tlbflush) ) + accumulate_tlbflush(&need_tlbflush, &pg[i], + &tlbflush_timestamp); + + /* + * Preserve flag PGC_reserved and change page state + * to PGC_state_inuse. + */ + pg[i].count_info =3D PGC_reserved | PGC_state_inuse; + /* Initialise fields which have other uses for free pages. */ + pg[i].u.inuse.type_info =3D 0; + page_set_owner(&pg[i], NULL); + } + + spin_unlock(&heap_lock); + + if ( need_tlbflush ) + filtered_flush_tlb_mask(tlbflush_timestamp); + + /* + * Ensure cache and RAM are consistent for platforms where the guest + * can control its own visibility of/through the cache. + */ + for ( i =3D 0; i < nr_mfns; i++ ) + flush_page_to_ram(mfn_x(smfn) + i, !(memflags & MEMF_no_icache_flu= sh)); + + return pg; + + out_err: + while ( i-- ) + pg[i].count_info =3D PGC_reserved | PGC_state_free; + + spin_unlock(&heap_lock); + + return NULL; +} + +/* + * Acquire nr_mfns contiguous pages, starting at #smfn, of static memory, + * then assign them to one specific domain #d. + */ +int __init acquire_domstatic_pages(struct domain *d, mfn_t smfn, + unsigned long nr_mfns, unsigned int mem= flags) +{ + struct page_info *pg; + + ASSERT(!in_irq()); + + pg =3D acquire_staticmem_pages(smfn, nr_mfns, memflags); + if ( !pg ) + return -ENOENT; + + if ( !d || (memflags & (MEMF_no_owner | MEMF_no_refcount)) ) + { + /* + * Respective handling omitted here because right now + * acquired static memory is only for guest RAM. + */ + ASSERT_UNREACHABLE(); + return -EINVAL; + } + + if ( assign_pages(d, pg, nr_mfns, memflags) ) + { + free_staticmem_pages(pg, nr_mfns, memflags & MEMF_no_scrub); + return -EINVAL; + } + + return 0; +} #endif =20 /* diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index ded74d29da..7b5e7b7f69 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -108,6 +108,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 */ +#define _PGC_reserved PG_shift(3) +#define PGC_reserved PG_mask(1, 3) /* ... */ /* Page is broken? */ #define _PGC_broken PG_shift(7) diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index a74e93eba8..da1b158693 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -89,6 +89,8 @@ bool scrub_free_pages(void); /* These functions are for static memory */ void free_staticmem_pages(struct page_info *pg, unsigned long nr_mfns, bool need_scrub); +int acquire_domstatic_pages(struct domain *d, mfn_t smfn, unsigned long nr= _mfns, + unsigned int memflags); #endif =20 /* Map machine page range in Xen virtual address space. */ --=20 2.25.1 From nobody Tue Apr 23 13:50:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=2; a=rsa-sha256; t=1631094903; cv=pass; d=zohomail.com; s=zohoarc; b=c9Ro110HdeHGb7yqYd/XQul91ov99dJIXa7PHD4LWZnllAaft0AwdkmdhIsxVigseV7qlFiV2vluAHMivQ/xjGsgPtTIU8ytU8vUBg5AnwnoruPt+86UnD6AGz3iBHqebfwaRwKqPwnhqPYNrC/UYUfBIy9tQxirrbrWJVYsZtM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631094903; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q9Xvps1nERdmkV37FMndb6oyhfDMDttEJab3tc9qnbU=; b=Y2+OiVDQhDT4ZVD+Q8QyURXzt/xp35oW9FQQAeTD0YxdJlUWeGRsl4TU7mnSnLJU9DDo0ti4P/RiOLduTVM1zW2icLoRSvveCVMuX5wBSGD/BqBkMEtm6c727UmiuuDXdqA3zu+dR8coSPBJKO0I7BJvYevEZzv9Y/bj6MWqZPQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; arc=pass (i=1 dmarc=pass fromdomain=arm.com); dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1631094903173678.4056288865054; Wed, 8 Sep 2021 02:55:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.181626.328889 (Exim 4.92) (envelope-from ) id 1mNuI4-0004Gm-VM; Wed, 08 Sep 2021 09:54:48 +0000 Received: by outflank-mailman (output) from mailman id 181626.328889; Wed, 08 Sep 2021 09:54:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuI4-0004GM-RB; Wed, 08 Sep 2021 09:54:48 +0000 Received: by outflank-mailman (input) for mailman id 181626; Wed, 08 Sep 2021 09:54:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mNuI3-0000bc-HI for xen-devel@lists.xenproject.org; Wed, 08 Sep 2021 09:54:47 +0000 Received: from FRA01-PR2-obe.outbound.protection.outlook.com (unknown [40.107.12.78]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 78803600-1be9-494b-9e7c-8c98769411dc; Wed, 08 Sep 2021 09:54:31 +0000 (UTC) Received: from AM7PR02CA0014.eurprd02.prod.outlook.com (2603:10a6:20b:100::24) by PR2PR08MB4715.eurprd08.prod.outlook.com (2603:10a6:101:1d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.22; Wed, 8 Sep 2021 09:54:30 +0000 Received: from AM5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:100:cafe::c6) by AM7PR02CA0014.outlook.office365.com (2603:10a6:20b:100::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20 via Frontend Transport; Wed, 8 Sep 2021 09:54:29 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT050.mail.protection.outlook.com (10.152.17.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:29 +0000 Received: ("Tessian outbound 7a08471b1ef6:v105"); Wed, 08 Sep 2021 09:54:29 +0000 Received: from 3afc8c350cb9.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7BF624EC-5049-42E5-91B8-05FD44A495A4.1; Wed, 08 Sep 2021 09:54:23 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3afc8c350cb9.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Sep 2021 09:54:23 +0000 Received: from PR0P264CA0184.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::28) by VI1PR08MB4447.eurprd08.prod.outlook.com (2603:10a6:803:f3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.22; Wed, 8 Sep 2021 09:54:19 +0000 Received: from VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:100:1c:cafe::6) by PR0P264CA0184.outlook.office365.com (2603:10a6:100:1c::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:19 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT041.mail.protection.outlook.com (10.152.19.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Wed, 8 Sep 2021 09:54:19 +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.2308.14; Wed, 8 Sep 2021 09:54:22 +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.2308.14 via Frontend Transport; Wed, 8 Sep 2021 09:54:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 78803600-1be9-494b-9e7c-8c98769411dc 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=Q9Xvps1nERdmkV37FMndb6oyhfDMDttEJab3tc9qnbU=; b=1H8cRACXBw54AoXOv2bne/IOQrNzoRv0sd/p/MJbAF88AnpkiVAXBPMUNkNf6C90X/04q6vQwpnX9Xg4ng8RMCtZiRR0U5Y/65h85Z5Eu4M71O9kmSmFUk011TbeEa5OyJPaz5fEO/ahpBd3heSrh6fz5JRpV1Kl1ZwD8Fz1eN4= 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 (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; 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: 0110ddf03a380d5f X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G0twraB4bld5XI72+NKgCux4wCa47nDs3V13g+pTOdVQWU7vtAr2CXB9+S+rvaiOx40Jh9lRAVnfjmA9vha7fD+KFaTKBfR9eFFFOyNYTOhkbMkcCLe5kjT30IZwkJQaBF3S9gyOD5T0i30MfXw3Ij0pW0wljqE0mOikHrhtNO4F/7rilhGRw9jB1VsuFntWLhi70WuvifT+cesezQZm0+Gtf21QCkpbM41moDP299W3hTu+WNcqz8XcPjjDx7aovx/GaINPbVe1NGHjYFy5j5WHjdto8GbMMywE6e2I7Lp9LSRpcHrxDrIymJ0YAYrRf/NJqvrG0hJf1Ncw1kFptA== 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; bh=Q9Xvps1nERdmkV37FMndb6oyhfDMDttEJab3tc9qnbU=; b=X6dadGPLbA9nOHxzFsAjgNIUYzTwFTBWy9uXhLMA6vrznhcui89/S+m6zWW8bsvhN+3SwJ5nweeCNtkjIgG0SC34A1vbRITqGfyKxFpwrfsLzbcAppxmKRrHpDRfXDhXPP+uEiSHfBEI1HWX/oKrW/ICCdu1/oZN2bE+24UXfaNSMxWRgdUdiYtotC905KEhiyoj9i88P0xY3Vz3NrWarPqQme7OR6ZFIucis8Sqzct/uK3DzEpJDQt/DO5HA5O+546qTBpDBRNjcAyWzGOXEXqXOKWIzQA2MXSBU1q1v7IEuo4fM38bTF/o5P2nKySLYPRVcNY8nbBwAk1ZRK8VtQ== 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=Q9Xvps1nERdmkV37FMndb6oyhfDMDttEJab3tc9qnbU=; b=1H8cRACXBw54AoXOv2bne/IOQrNzoRv0sd/p/MJbAF88AnpkiVAXBPMUNkNf6C90X/04q6vQwpnX9Xg4ng8RMCtZiRR0U5Y/65h85Z5Eu4M71O9kmSmFUk011TbeEa5OyJPaz5fEO/ahpBd3heSrh6fz5JRpV1Kl1ZwD8Fz1eN4= 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 v6 7/7] xen/arm: introduce allocate_static_memory Date: Wed, 8 Sep 2021 09:52:48 +0000 Message-ID: <20210908095248.545981-8-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210908095248.545981-1-penny.zheng@arm.com> References: <20210908095248.545981-1-penny.zheng@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ecfed280-6e87-429f-927b-08d972aea6ec X-MS-TrafficTypeDiagnostic: VI1PR08MB4447:|PR2PR08MB4715: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:644;OLM:644; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 1TxyTFqHUG3FWwPS6fkevvNE/gmvhc90TJ7+rEFAbKJ+HEy08xGdIwmdR9SwLc7eRazGAB8HveJVf5dh1UlzErAT+aniC/lek62ZqNEBDNEFrv4lKSGHxB8bJ7et/V2xDP9yKlfB5UwG7eGTNt/tUfPXJs51iwnP1J7jAPO88YHiDogaiqGMPZpARDQpvc3/SbOcDYBBmd+jlpvaoCeR1PLz7KgAUcr0kIZOdRJFDgBm1c07j8fhKMYgckNDdNnhT14DoxD0XTXVtVb9xIQ+s/gkR0uaeJktuGogs/LpBIb0e87WI2cpHIuQDAXC4Gyc6A2+ya8tFJ6VVjRApw1I/263PbWib/GT7AAuhJIfg8iobmN8D1JD5BoUaxBUYFzOhr7/8HhEyb/fIV3WZYT4pntE9++IlZMOJrBcC1ojGw205/RZ21UJqdBPKueR4x6TvVAja6eO63MI4+IKC5g6J1HXTTggbwmgQHy47DbouUrXKkdm7Ecpf8V/wR1JNzO/9VWSNBmaBFWcgZbkorYNGCyB9623jaPSIw0yh8AguY5ycoNSRVux85rza/qRFkjMSnPXwPSXpRr3wdUcFuvNSTyZsgTe6HP8U/ON6qWlCKzb8LgBb1dSPhLcR7ych3op0jjrwVFCo3ZzXZYR3c/CmycnkeOalTwGwoSMXiIVe5qExTu8HFJiGlLeNfnqcoSA9ETL+1P+Y/KYJbV6RHkXsw8GvlBZvrjNj6JiZY2bn/g= 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)(39860400002)(376002)(396003)(136003)(346002)(46966006)(36840700001)(26005)(8936002)(70206006)(70586007)(110136005)(54906003)(4326008)(186003)(2906002)(316002)(81166007)(82740400003)(7696005)(5660300002)(336012)(83380400001)(47076005)(6666004)(356005)(82310400003)(478600001)(36860700001)(8676002)(1076003)(2616005)(36756003)(426003)(44832011)(86362001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4447 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 1a1e78b6-238c-4d93-88ed-08d972aea083 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V3mU7NCkvMGrOPE7LXMqB7IInLn2g5kcbrhyRcuq3riN0jdwqdveK5w73qKRwz4rWyqrULvVVzjt1m9vNtAwC4F3ncCeeuJWSV5c0W3/ZsEpGide4yCQV7PL1Om33T6AaCOgX2l400zJw6h8fBZtoxOTXjBUpknXtHJpFLXqtfTtoWMVew+7+JHMVNIfFTqj0GmdccMnhrt2EIC1JORlXqAowMLNdVwAtyxHh48GbAT/PCOBL/4PfAEAqsuNeSAUL6xHKG1d2IHPCWnZqyd1XlFjuLIG0YJa7al6MDQHkzYZ9vdhZdCTXhp2lWI8nwBLaVEVlaa3KbGpXjPYILnGEuqOmoKipclnnev0n0zxZrwBpsXQ5ExB5U9Sa56dhtqefWu45g2sIgf/s7R0Q6jmF6UH0T8SYpCrvQbTooHbkeRjjAoCVxyZ54RfvwhtikZl7kcrDDaxHQNmjeUhImqj1nlzownv0qqKyY7ndAMvhQT5qIOEOEUWXGlLES46SRIZB5cT5ZQ+aFisMRUtc3goIg5CF9lJywIRGj514xa2yYNA7n5NpfmSclL9kRWbFBPVyCEYxy8KPOEnOcVLsONge94pHIUR+BbEDt3t+V0E3bEo+iTJR4kd+e7+Z/e5gMM12ikT4O3KrNXnE42kJEVPvQzG2QbGNo4yVB97hCWYf4KqTsms98JHsyMWjdn9Y3DIVvKmq9NkDKDSum4TuO6bsw== 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)(39860400002)(136003)(376002)(396003)(46966006)(36840700001)(2616005)(186003)(336012)(82740400003)(426003)(83380400001)(107886003)(82310400003)(36756003)(47076005)(8676002)(70206006)(6666004)(26005)(70586007)(8936002)(478600001)(81166007)(36860700001)(2906002)(5660300002)(7696005)(44832011)(4326008)(54906003)(1076003)(316002)(110136005)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2021 09:54:29.9214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecfed280-6e87-429f-927b-08d972aea6ec 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: AM5EUR03FT050.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4715 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631094904968100001 Content-Type: text/plain; charset="utf-8" This commit introduces a new function allocate_static_memory to allocate static memory as guest RAM for Domain on Static Allocation. It uses acquire_domstatic_pages to acquire pre-configured static memory for this domain, and uses guest_physmap_add_pages to set up P2M table. These pre-defined static memory banks shall be mapped to the usual guest memory addresses (GUEST_RAM0_BASE, GUEST_RAM1_BASE) defined by xen/include/public/arch-arm.h. In order to deal with the trouble of count-to-order conversion when page nu= mber is not in a power-of-two, this commit exports p2m_insert_mapping and introd= uce a new function guest_physmap_add_pages to cope with adding guest RAM p2m mapping with nr_pages. Signed-off-by: Penny Zheng Reviewed-by: Stefano Stabellini --- xen/arch/arm/domain_build.c | 161 +++++++++++++++++++++++++++++++++++- xen/arch/arm/p2m.c | 7 +- xen/include/asm-arm/p2m.h | 11 +++ 3 files changed, 173 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 206038d1c0..b011cc4789 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -480,6 +480,162 @@ fail: (unsigned long)kinfo->unassigned_mem >> 10); } =20 +#ifdef CONFIG_STATIC_MEMORY +static bool __init append_static_memory_to_bank(struct domain *d, + struct membank *bank, + mfn_t smfn, + paddr_t size) +{ + int res; + unsigned int nr_pages =3D PFN_DOWN(size); + /* Infer next GFN. */ + gfn_t sgfn =3D gaddr_to_gfn(bank->start + bank->size); + + res =3D guest_physmap_add_pages(d, sgfn, smfn, nr_pages); + if ( res ) + { + dprintk(XENLOG_ERR, "Failed to map pages to DOMU: %d", res); + return false; + } + + bank->size =3D bank->size + size; + + return true; +} + +/* Allocate memory from static memory as RAM for one specific domain d. */ +static void __init allocate_static_memory(struct domain *d, + struct kernel_info *kinfo, + const struct dt_device_node *nod= e) +{ + const struct dt_property *prop; + u32 addr_cells, size_cells, reg_cells; + unsigned int nr_banks, gbank, bank =3D 0; + const uint64_t rambase[] =3D GUEST_RAM_BANK_BASES; + const uint64_t ramsize[] =3D GUEST_RAM_BANK_SIZES; + const __be32 *cell; + u64 tot_size =3D 0; + paddr_t pbase, psize, gsize; + mfn_t smfn; + int res; + + prop =3D dt_find_property(node, "xen,static-mem", NULL); + if ( !dt_property_read_u32(node, "#xen,static-mem-address-cells", + &addr_cells) ) + { + printk(XENLOG_ERR + "%pd: failed to read \"#xen,static-mem-address-cells\".\n",= d); + goto fail; + } + + if ( !dt_property_read_u32(node, "#xen,static-mem-size-cells", + &size_cells) ) + { + printk(XENLOG_ERR + "%pd: failed to read \"#xen,static-mem-size-cells\".\n", d); + goto fail; + } + reg_cells =3D addr_cells + size_cells; + + /* + * The static memory will be mapped in the guest at the usual guest me= mory + * addresses (GUEST_RAM0_BASE, GUEST_RAM1_BASE) defined by + * xen/include/public/arch-arm.h. + */ + gbank =3D 0; + gsize =3D ramsize[gbank]; + kinfo->mem.bank[gbank].start =3D rambase[gbank]; + + cell =3D (const __be32 *)prop->value; + nr_banks =3D (prop->length) / (reg_cells * sizeof (u32)); + + for ( ; bank < nr_banks; bank++ ) + { + device_tree_get_reg(&cell, addr_cells, size_cells, &pbase, &psize); + ASSERT(IS_ALIGNED(pbase, PAGE_SIZE) && IS_ALIGNED(psize, PAGE_SIZE= )); + + smfn =3D maddr_to_mfn(pbase); + res =3D acquire_domstatic_pages(d, smfn, PFN_DOWN(psize), 0); + if ( res ) + { + printk(XENLOG_ERR + "%pd: failed to acquire static memory: %d.\n", d, res); + goto fail; + } + + printk(XENLOG_INFO "%pd: STATIC BANK[%u] %#"PRIpaddr"-%#"PRIpaddr"= \n", + d, bank, pbase, pbase + psize); + + while ( 1 ) + { + /* Map as much as possible the static range to the guest bank = */ + if ( !append_static_memory_to_bank(d, &kinfo->mem.bank[gbank],= smfn, + min(psize, gsize)) ) + goto fail; + + /* + * The current physical bank is fully mapped. + * Handle the next physical bank. + */ + if ( gsize >=3D psize ) + { + gsize =3D gsize - psize; + break; + } + /* + * When current guest bank is not enough to map, exhaust + * the current one and seek to the next. + * Before seeking to the next, check if we still have available + * guest bank. + */ + else if ( (gbank + 1) >=3D GUEST_RAM_BANKS ) + { + printk(XENLOG_ERR "Exhausted all possible guest banks.\n"); + goto fail; + } + else + { + psize =3D psize - gsize; + smfn =3D mfn_add(smfn, gsize >> PAGE_SHIFT); + /* Update to the next guest bank. */ + gbank++; + gsize =3D ramsize[gbank]; + kinfo->mem.bank[gbank].start =3D rambase[gbank]; + } + } + + tot_size +=3D psize; + } + + kinfo->mem.nr_banks =3D ++gbank; + + kinfo->unassigned_mem -=3D tot_size; + /* + * The property 'memory' should match the amount of memory given to the + * guest. + * Currently, it is only possible to either acquire static memory or l= et + * Xen allocate. *Mixing* is not supported'. + */ + if ( kinfo->unassigned_mem ) + { + printk(XENLOG_ERR + "Size of \"memory\" property doesn't match up with the sum-= up of \"xen,static-mem\". Unsupported configuration.\n"); + goto fail; + } + + return; + + fail: + panic("Failed to allocate requested static memory for domain %pd.", d); +} +#else +static void __init allocate_static_memory(struct domain *d, + struct kernel_info *kinfo, + const struct dt_device_node *nod= e) +{ +} +#endif + static int __init write_properties(struct domain *d, struct kernel_info *k= info, const struct dt_device_node *node) { @@ -2453,7 +2609,10 @@ static int __init construct_domU(struct domain *d, /* type must be set before allocate memory */ d->arch.type =3D kinfo.type; #endif - allocate_memory(d, &kinfo); + if ( !dt_find_property(node, "xen,static-mem", NULL) ) + allocate_memory(d, &kinfo); + else + allocate_static_memory(d, &kinfo, node); =20 rc =3D prepare_dtb_domU(d, &kinfo); if ( rc < 0 ) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index eff9a105e7..6e01e83967 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1293,11 +1293,8 @@ out: return resolved; } =20 -static inline int p2m_insert_mapping(struct domain *d, - gfn_t start_gfn, - unsigned long nr, - mfn_t mfn, - p2m_type_t t) +int p2m_insert_mapping(struct domain *d, gfn_t start_gfn, unsigned long nr, + mfn_t mfn, p2m_type_t t) { struct p2m_domain *p2m =3D p2m_get_hostp2m(d); int rc; diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 6a2108398f..f885cc522b 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -300,6 +300,9 @@ int map_dev_mmio_region(struct domain *d, unsigned long nr, mfn_t mfn); =20 +int p2m_insert_mapping(struct domain *d, gfn_t start_gfn, unsigned long nr, + mfn_t mfn, p2m_type_t t); + int guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, @@ -315,6 +318,14 @@ static inline int guest_physmap_add_page(struct domain= *d, return guest_physmap_add_entry(d, gfn, mfn, page_order, p2m_ram_rw); } =20 +static inline int guest_physmap_add_pages(struct domain *d, + gfn_t gfn, + mfn_t mfn, + unsigned int nr_pages) +{ + return p2m_insert_mapping(d, gfn, nr_pages, mfn, p2m_ram_rw); +} + mfn_t gfn_to_mfn(struct domain *d, gfn_t gfn); =20 /* Look up a GFN and take a reference count on the backing page. */ --=20 2.25.1