From nobody Fri Apr 26 14:14:30 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=1631242389; cv=pass; d=zohomail.com; s=zohoarc; b=lXK3xUMfsWAO6VAJV/hxks3aWuWWtQpY1L71PIJNpbnfIlJLULtf+pkdPgclkOSFfWfhDwVFTjLggI7vqP6PCLrURJ1pN6W+EcWDWuShtR/1MH502snITjnqEWdTNWeAfhDLAQxd9qnvD4BYG1pMITtroakGz4z60QFQG7BtCw0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631242389; 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=qWGJef8NpyPIjTGv5tGyQyanogwWdxG4O/jjsJWp4l8=; b=bUhyjR9uvworEGmg0qmHfebUqg8jNSnu7K29FCnS9cPoqz3NdF13v24D2vinFnebAHwm4m9MfK3W6mCUrcVRSe3S+WruXUJMMD8c5UCisDcAyS01OGT1+Ja47mmSwV0Z8W4z0ZmrN++RXpkOgpzUE6lMU1vXJSmtr/H7ynZ9ERk= 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 1631242389724908.9571556991696; Thu, 9 Sep 2021 19:53:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.183854.332236 (Exim 4.92) (envelope-from ) id 1mOWer-0004Sz-6q; Fri, 10 Sep 2021 02:52:53 +0000 Received: by outflank-mailman (output) from mailman id 183854.332236; Fri, 10 Sep 2021 02:52:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOWer-0004Ss-1A; Fri, 10 Sep 2021 02:52:53 +0000 Received: by outflank-mailman (input) for mailman id 183854; Fri, 10 Sep 2021 02:52:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOWep-0004S2-Ss for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 02:52:51 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (unknown [40.107.22.71]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 11f5d985-b6c4-409f-a054-1cb3dd7e8314; Fri, 10 Sep 2021 02:52:49 +0000 (UTC) Received: from AM6PR08CA0008.eurprd08.prod.outlook.com (2603:10a6:20b:b2::20) by AM4PR08MB2883.eurprd08.prod.outlook.com (2603:10a6:205:9::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Fri, 10 Sep 2021 02:52:45 +0000 Received: from AM5EUR03FT019.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::c5) by AM6PR08CA0008.outlook.office365.com (2603:10a6:20b:b2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:45 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT019.mail.protection.outlook.com (10.152.16.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:45 +0000 Received: ("Tessian outbound b9598e0ead92:v103"); Fri, 10 Sep 2021 02:52:45 +0000 Received: from aef7096e1d60.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 18FEB2E9-24A8-463E-B391-F094B9E62699.1; Fri, 10 Sep 2021 02:52:38 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id aef7096e1d60.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 10 Sep 2021 02:52:38 +0000 Received: from AS9PR06CA0175.eurprd06.prod.outlook.com (2603:10a6:20b:45c::25) by VE1PR08MB4653.eurprd08.prod.outlook.com (2603:10a6:802:b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Fri, 10 Sep 2021 02:52:36 +0000 Received: from AM5EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45c:cafe::f5) by AS9PR06CA0175.outlook.office365.com (2603:10a6:20b:45c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:36 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT061.mail.protection.outlook.com (10.152.16.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Fri, 10 Sep 2021 02:52:36 +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; Fri, 10 Sep 2021 02:52:42 +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; Fri, 10 Sep 2021 02:52:34 +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; Fri, 10 Sep 2021 02:52:39 +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: 11f5d985-b6c4-409f-a054-1cb3dd7e8314 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=qWGJef8NpyPIjTGv5tGyQyanogwWdxG4O/jjsJWp4l8=; b=rdwRP2BhnFfHzdTn+7NGASRkWhm5/2ij8A894nlkuam8MHwmn6bRXbSjDtfPvZxhjd9CJ+pPjQ5sXjkwJrYEEPnLGCEVgnua+ghmnyKkU7wV3vh86rIfgogruZ59V/CXQwz3ld9YBNO0NG6eOwFVEIZE37tJPj1Hhk61/7cfOv8= 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: f99e22bbac556734 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ADzIWDzld4KnCWL311lXNKsj/TuZveQVZ4KazgGdVeHwnRsdJ0VRg632zUCty45wCztYJjWjyF+Wpuefgd7Ce4LVUpPdj7XqY9WLgRoH7eeHs6UgV0LwqA+oO+EiPNAOBSQqu2MkELusZaBa0jIgq8wwfvML1B/oWebsj68axdk7Wvp8Ggm8NChPeGUWTFuCvBclRJHOR1I1pYJFgOQryDbaFxNqWbe2J+fNCOcx18mZqBmieOGeCLQ/4k4azahfRx6RwLq1jyolv4tpB8ajV5jLy6Y6NdPM1yktB72UNpSOUvc1QN0f3w0f5rYHCAplBh//iKULNd10eMkC4rJCUw== 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=qWGJef8NpyPIjTGv5tGyQyanogwWdxG4O/jjsJWp4l8=; b=PN3wBOnBN1+6JIPSXfAXS5Hr0rdwDaPLtZ4Ae1w8HeI9pgGAGT5wd3WnBANlpsoSYMN0jMLtuTBfA+uHvTWPvcZlpnUYSqbiiUfTuUfwS8A8jH0BNL8J+Gpmr1Gi/AES/ZGLsiI0zhjI7KA3Ba5ZXNmsIr+cemhRh9j4RWXJKCbTi1TGvmfDBLZnEWD70YpmBxQ0y5q9QGD29cGdYElirodgqr0RyipRgL53HpMZzr7gpxZDUonijYe6rmt08VVjrpoz2aRPlkM1c8r5+b4vOyuJNePSkQ92y2kEM+fhNK/iKrBhO7pgk/eIOOlcnlhBSywdq1spM0hCpzPcfuKNhw== 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=qWGJef8NpyPIjTGv5tGyQyanogwWdxG4O/jjsJWp4l8=; b=rdwRP2BhnFfHzdTn+7NGASRkWhm5/2ij8A894nlkuam8MHwmn6bRXbSjDtfPvZxhjd9CJ+pPjQ5sXjkwJrYEEPnLGCEVgnua+ghmnyKkU7wV3vh86rIfgogruZ59V/CXQwz3ld9YBNO0NG6eOwFVEIZE37tJPj1Hhk61/7cfOv8= 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 v7 1/7] xen/arm: introduce new helper device_tree_get_meminfo Date: Fri, 10 Sep 2021 02:52:09 +0000 Message-ID: <20210910025215.1671073-2-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910025215.1671073-1-penny.zheng@arm.com> References: <20210910025215.1671073-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: d6514ac7-b076-4b74-7ebd-08d9740610f0 X-MS-TrafficTypeDiagnostic: VE1PR08MB4653:|AM4PR08MB2883: 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: j6TPtWGBobWDt2nNwtZp72ov6yuFpO7z45+5tXGNUAcDlGzxHVOdajsumaFTyM6JxFCvrdyF+qB3AqYFM3lESGT3XY32wbTpoa76sp9NxtB4ETT7RUNutIa931ujmrGuSW/zPdvaz+H7I5wZbNcW4qEjEJtoK01HV8YN8ra+r4ACLoEE7d1aSR3bR0/bBGUdqOEkx90q+oUD9kB6YNriSEpiVfNaS0Yf1BbcN01NWHZJlbgrnwimN8Bkfq0vjr/UessQ7uXjw2vThtvDoc4kMV5rd3LyaMfek2bJuz0KApxBp1LmrKhF4Rfz/T77HbHCbSiqwZNiU7XDWS2e1g2ASdcxZtKrIQqT2ehTNwQAmxFqxu8JwOUlY8TdFPqKuxlo+TBxKt7FmRNoeBuuPo82CtaZ7RU089yLGBBjkBaVzRvCWHUJuSTwQXJKAynSrlBoroXzUASvD1Kf9/b49ZyZe1aasHS6NApACVIOizOD6/xoRxp22DUFyS1hvmf+jZ00JmecMqPQZNZY6C7HyGshoOvez1TplKDN/8k2Tm2EtEBsU6i3cSxvaBLgPOGR2EaD1cCf7ACWKWsnrbJE3axOuIkptxGOE7lzvokUrretzEj3H/Naa3Wp2z5ryQdrd8zd2Zl+9AGxh37LWLuyYYw3wdr7mUWfKsOePWCn+ut/stf+Z9Spsx5EgkzsmWq74Bq8d7lb/MN0qsCZBoVJBMooc96O6kotRzGk+iGzEMV+GNM= 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)(7696005)(8676002)(70206006)(1076003)(36860700001)(70586007)(83380400001)(44832011)(82310400003)(81166007)(2616005)(426003)(336012)(356005)(86362001)(2906002)(4326008)(316002)(36756003)(54906003)(110136005)(5660300002)(26005)(508600001)(6666004)(186003)(8936002)(47076005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4653 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: d7277bf9-ea7f-4f1b-1d4c-08d974060b9c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xf6oME0yBKglru7326W8HRM+P/Cd6K9bVlaxburBsdEBtwHVFcJyiCLeLnyM0vHjQVch8aLVQVPe19TTDnWA4vi8OkAQsEXF+wxPgMbvMmQt2upHA1XTX0Wv4PLaDj5xftvrWGcLkpebKMfuwcqVV8eqkWrsUDENEOiKol6PWQNDaIHDYXVN7Wez/VjB9BiQzpHT7XilNeaU3hgrJyuT3dKf0ysFTNG0ZyKB/4qx9UCVGYYULDd/2U9WWbyBCx75HZs2tVNbv0cwjxR7sl6n5poXpWCoje3sCmHXV6arh11eaGHVeEoLcJ87zoxnHE50Ousx4CIODKZDyu4/3i30TmLKYvl0x3kieVRkkpqcUdYNRsQuq2un0vIc9nAqLEVn6OeMogt6Ln7yn2b81/5NiBCHQTZMxVu7vOQbEGOQ+szjvUeMUKkUlvjJzVjD/TjkbFJVC6A5oQt8Aki8yQLYfdg/aEPQ2eAP1zUMOreN8DN2F7Ka7yobh4AP22AE0+VN06+Da3erTCvGNjjUT63m72W5q3jjGcbvBAhzdggkc+sz0pWosH3EkiYhA27xVKHC86XXtdmyTSLcomNTzK3Z8UogpFH06RRtprITZNX7uN+mhx08DqHuNEjqsLv6hHMPcTYIbvaitVMgMnmHzu5SCJS1sLyzmNstjOMFGHXYh0aUFiqNUcwiVR6NNPg+2FH6QfUpXKvPFM8qKPhKp9v5bA== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(396003)(136003)(376002)(39860400002)(346002)(46966006)(36840700001)(1076003)(2906002)(110136005)(26005)(316002)(4326008)(6666004)(107886003)(478600001)(82310400003)(83380400001)(54906003)(81166007)(70206006)(5660300002)(47076005)(2616005)(336012)(44832011)(426003)(8676002)(82740400003)(8936002)(186003)(86362001)(36756003)(36860700001)(70586007)(7696005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 02:52:45.1908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d6514ac7-b076-4b74-7ebd-08d9740610f0 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: AM5EUR03FT019.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2883 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631242391512100001 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 Fri Apr 26 14:14:30 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=1631242389; cv=pass; d=zohomail.com; s=zohoarc; b=JhIwE60L155wsxp31bPYX68R/8iBkoHAaarXi4ZQscNzpm9oHJngGwf6b/W6YQ6/76Nk++g7amsY5MKbfidJ88a/D+MF4XN4BCZi2aHbwDzmKlcxwpZjWO4m/DEf2lZuWGcrcSJfc3SHjpNk/0uJW16UcaWNMqHFcVi+F1d1Pf4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631242389; 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=yzUXt/Gqs28bjIO6M0/X3qZ/21raERDi7GDI7xhSsGg=; b=EC3bAkp/yzNf05nZ92xQ7jfH1SWHliHWG7WwUCSNvyTjORqCD0IILDuxwmN9XtlKZ81PmfCeIqijBzXWoUC8Djc5Q0RVuUvTwFb5vmqhQzSVaS5LCy41y3dRwD71RYgsWgH4d5kLlRn6aJO2tKOwDntuP7phccTYq2bFB+ExrE8= 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 1631242389249108.36128284152267; Thu, 9 Sep 2021 19:53:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.183855.332247 (Exim 4.92) (envelope-from ) id 1mOWes-0004kK-ER; Fri, 10 Sep 2021 02:52:54 +0000 Received: by outflank-mailman (output) from mailman id 183855.332247; Fri, 10 Sep 2021 02:52: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 1mOWes-0004k5-9w; Fri, 10 Sep 2021 02:52:54 +0000 Received: by outflank-mailman (input) for mailman id 183855; Fri, 10 Sep 2021 02:52: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 1mOWeq-0004Sh-UC for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 02:52:52 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (unknown [40.107.0.85]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 301de676-11e2-11ec-b209-12813bfff9fa; Fri, 10 Sep 2021 02:52:51 +0000 (UTC) Received: from AS9PR06CA0069.eurprd06.prod.outlook.com (2603:10a6:20b:464::18) by VI1PR08MB3309.eurprd08.prod.outlook.com (2603:10a6:803:41::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Fri, 10 Sep 2021 02:52:49 +0000 Received: from AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:464:cafe::fa) by AS9PR06CA0069.outlook.office365.com (2603:10a6:20b:464::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:49 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT014.mail.protection.outlook.com (10.152.16.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 10 Sep 2021 02:52:49 +0000 Received: ("Tessian outbound d5def7722ff7:v103"); Fri, 10 Sep 2021 02:52:49 +0000 Received: from 84a38c9bd2fd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 46A29243-FC7F-4B10-A916-47B71ACCF0B8.1; Fri, 10 Sep 2021 02:52:42 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 84a38c9bd2fd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 10 Sep 2021 02:52:42 +0000 Received: from AS8PR04CA0078.eurprd04.prod.outlook.com (2603:10a6:20b:313::23) by PAXPR08MB7320.eurprd08.prod.outlook.com (2603:10a6:102:223::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Fri, 10 Sep 2021 02:52:40 +0000 Received: from AM5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:313:cafe::9a) by AS8PR04CA0078.outlook.office365.com (2603:10a6:20b:313::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:40 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT024.mail.protection.outlook.com (10.152.16.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Fri, 10 Sep 2021 02:52:40 +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; Fri, 10 Sep 2021 02:52:43 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2308.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:42 +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: 301de676-11e2-11ec-b209-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=yzUXt/Gqs28bjIO6M0/X3qZ/21raERDi7GDI7xhSsGg=; b=nVkALiXt6FKKB37t6txu2AjGXor0TqQuiBYRAURs7Sbpm5WkOeNAEubgvT8FKRDzORNrdNeU3DLid9q3cwveEJixGkc9TmL8gC1GQHtrn+kWqQY90cWKQD/52nSrWrZ6fteJXdwYLjPEEjk7pRbY+BivnQ6ThtdjS0vi76/CB40= 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: a6c2d208d22835e4 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YjIhp61sTRlNRhx7xgM0IZICf9Ea48BxK1/OVL7mrWSKMtkYHZeDBuOV3fkEWmCUdz/lvPnR0ldMYNvhHwNq5LTMhZn3vaX4jrRTN5xUYx78aUIa3LMZ+UugFLCetOo/I+67D3I8OSRq96S9TR7vjP9hqCKqFPwuKUZuMolo+Rw7AGReWKsu/Ssf/yTxn7atOrNDWp0aOpE44sSrRZtjtOMJlwZqOL63pl4xr9tX0UOMrAR59yss0vGKnTIyNMfwRdSmcZ+DK3ruxEAtPlS80uzz2BgFTnd54vZgTLVEwfI9/26W46j965OjM9GcoXTdXvqtT1hC97f5Gj8mn5lpaA== 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=yzUXt/Gqs28bjIO6M0/X3qZ/21raERDi7GDI7xhSsGg=; b=hSq3v9e26erGgEwUb0NLPImQ8TqAPZc4J3nrWY1FHrxKpRpE1MAS213X5MQI6W/vR+aT04t4pWCaj8MSYEqkV4ZaDtLJeZfmabzuBYztemvyni5YduCfZ/SkxNyW++vSCZg4tICpeslVFn/qUZjeq1gqmUyJgNeUWQQFb5mkKdTEjgtKVpSXROMcKzXyzL7b1Cwny6dHS36qXkOj/Ar6EvAEXPBddAWaNQq3cW65LkUgsvFvCP9jTeuUbhIddT5eoUh4m+hiQ2+pnpxcdvePI+EXTeSnzXbcU1USdh1e8EUyR1KEpMWF5SBr2NUOYBhRsdAYkEL+TbjkTfSkiaSZTg== 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=yzUXt/Gqs28bjIO6M0/X3qZ/21raERDi7GDI7xhSsGg=; b=nVkALiXt6FKKB37t6txu2AjGXor0TqQuiBYRAURs7Sbpm5WkOeNAEubgvT8FKRDzORNrdNeU3DLid9q3cwveEJixGkc9TmL8gC1GQHtrn+kWqQY90cWKQD/52nSrWrZ6fteJXdwYLjPEEjk7pRbY+BivnQ6ThtdjS0vi76/CB40= 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 v7 2/7] xen/arm: introduce domain on Static Allocation Date: Fri, 10 Sep 2021 02:52:10 +0000 Message-ID: <20210910025215.1671073-3-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910025215.1671073-1-penny.zheng@arm.com> References: <20210910025215.1671073-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: a09e70be-2866-440d-84bc-08d97406134f X-MS-TrafficTypeDiagnostic: PAXPR08MB7320:|VI1PR08MB3309: 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: ZD+CgfeJobLy9gqTgZSbTVW2CSgGgur+Kz69v/oTKp1GwdNEqQyPx8xoRjtNHIQo/oJu99COlDtBRwkVUqzXqosBEEovDRtZ/NIn4Qm73Tq0qi2xZeLNKEa8b96LlfBRH2tYn9yuSD0EGMtURdSoftesjTHfI1m+4JN7HKicvsab5LgJu+10iNhclsk0Qv5atlMN2qfEEdcOjCjFeueHmdUBG4/ZBaB3BB3VzPBsj2yMbYxdMVvV0mEWBR0ZRWBQEl736Hhku6RKW7U3GY39yPEXbJCFbi6Z/L4PE7iQ1lPo2BftdL4VGt+nLoG0pNny41nDCMxb4Nd7ChsomiZmT1wuNY18RKfQ7BomSo4N0OhSTHtfK/8yYozliJKercXEyiW/XOEDHdHHar0sgjT0FOfieomM6VGm0JbyDM5ITOboXe0JZJQ2R2cpVCT0CKo/yf0nIFqzqB1gYUU+MLes8koAeefLsjbUdtb1yvMzMZIMMnBqstQrtDLDYev6D1czbQpvvlY3YcwM0MrgmOv2WcTkq4nOpl9mrKt4cNfzAHmVplTsioAVFhFe/6as9eCLIJ41xpAwPvrUzvt3PLtSuPrVioQ49L/rc3dgix07rIE51DZy5kqTK72ACepjI+oaAN+V9GDHdmHU31Luq6t6hBwE9mxjlzFXfbG1KnBNJsqzvx1A/MZK0Tjek8bAIXm4ZY701F8iitkJPRiH7nDwtHq9wAzKaN4FMHZ4WKoVrXU= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(376002)(136003)(346002)(39860400002)(396003)(36840700001)(46966006)(36860700001)(36756003)(316002)(110136005)(83380400001)(186003)(47076005)(82310400003)(2616005)(4326008)(70586007)(426003)(70206006)(26005)(5660300002)(478600001)(6666004)(2906002)(86362001)(336012)(82740400003)(81166007)(356005)(54906003)(44832011)(8936002)(8676002)(7696005)(1076003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7320 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: e2be9174-2c99-4ace-0a8d-08d974060e08 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P2/wyYznGzsm4nHQEwBb6uXI8CJwGVzwnxBN1lsrOjusHE+6qOsMHZO4dE+i+8C40Mqa5B2NZkGWOsDPUDt5g/GZr8Mmv9tinZlW3BbGjQ251DXHMqOU+fOyHgURj6KTWcbf2VOsl1DWPH9VODiyKhHcTha0451tVX65QIDi/g6KDjQFmFtFYjpPjjhU8LmpTNY0LEmb5OvnOU9cnUzL83FW8J0od4j08hrDHiDLdHIEjcXphqjkVVppLsOj/5orKnaCYiNUEQl9eL5oYQJyGKBsWHuFHg7XluQoyzLWNcS9Vxpg01v7BHNaF3b1rRlG9F4rcLJ5Jc0gy6dvY51PJtMAzafePP6uIOAs+SAF2GqWpaC7Yl3W9ErfEbZpkcTsEgGfExZYSCGBN0ZmlUIkCx9LK/an+KheChYh2HBfqLg6IZlAlZrcn1d/i9LPcqD+pmPEAjx7FIPaKxJSi1EH5t/oMcF4+4XWlI0EyqGdgcQzTgqOSFmeOrRZjksjhuL/Zal9Rm6SXBuANqsrZ6kjYknTLVZg7wqqc4OHyzoqwb4vDbApxtmnQwUuWGTdUWzPCzABX0J3j+sjgBi2mJhsF4VMN2vag7+FX+9S6hpehE0t+1Huq/1bKSR4SPS2CDCWIiSDVWJRFsDbIrl32vgvi8V4zI66/kl0UXkuVVXY65H6uR3SYDaDvomUlmTLphEkgbmRyxvpuUE+29NAwnrkwA== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(376002)(346002)(396003)(39860400002)(136003)(46966006)(36840700001)(2906002)(2616005)(316002)(83380400001)(478600001)(107886003)(82310400003)(110136005)(186003)(6666004)(44832011)(54906003)(70206006)(70586007)(5660300002)(8936002)(26005)(336012)(86362001)(426003)(4326008)(8676002)(82740400003)(36860700001)(36756003)(1076003)(81166007)(7696005)(47076005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 02:52:49.1710 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a09e70be-2866-440d-84bc-08d97406134f 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: AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3309 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631243293890100001 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 Fri Apr 26 14:14:30 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=1631242397; cv=pass; d=zohomail.com; s=zohoarc; b=HJ1ELukGDuwMn5k/nw3BcWl2J3LAjlm/hr/SM38LGLjPHD6ivdA4Cy3Y8UedAB+VeCj9iYeQT9ToeD3j8g6po1znJ6m3kAKCrfRU000jHK4IoYTpGStoR6FCuoKNsDLgTT/sil9238+pKyxBuXWBZCgizAur31kWo+A5yB9ZFuA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631242397; 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=capopTUXeN6Gp0BElIxxH51wo9AZuM5IrrnOJB7A2NBLIHCyP3/8qQZS98W2xoSkMMZoUDC3QpXTuiYlpQY7mOSGe0x73Grq8jxBP1rNxVOJ3H6Bfxfa/BFCRIPlpaJQUB6Y6iAoN7rJD8CDgQb8WUUJJ8rkM0mm7xdL4H1GxeE= 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 1631242397566335.1946591133544; Thu, 9 Sep 2021 19:53:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.183857.332258 (Exim 4.92) (envelope-from ) id 1mOWf1-0005Hm-3K; Fri, 10 Sep 2021 02:53:03 +0000 Received: by outflank-mailman (output) from mailman id 183857.332258; Fri, 10 Sep 2021 02:53:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOWf0-0005GR-UW; Fri, 10 Sep 2021 02:53:02 +0000 Received: by outflank-mailman (input) for mailman id 183857; Fri, 10 Sep 2021 02:53:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOWez-0004S2-Rd for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 02:53:01 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:7e1a::607]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 83267da6-c972-4f40-bdfc-62b4bd15b13e; Fri, 10 Sep 2021 02:52:53 +0000 (UTC) Received: from AS8PR04CA0014.eurprd04.prod.outlook.com (2603:10a6:20b:310::19) by PAXPR08MB6605.eurprd08.prod.outlook.com (2603:10a6:102:153::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Fri, 10 Sep 2021 02:52:51 +0000 Received: from AM5EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:310:cafe::8f) by AS8PR04CA0014.outlook.office365.com (2603:10a6:20b:310::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:51 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT049.mail.protection.outlook.com (10.152.17.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19 via Frontend Transport; Fri, 10 Sep 2021 02:52:51 +0000 Received: ("Tessian outbound e27daf245730:v103"); Fri, 10 Sep 2021 02:52:50 +0000 Received: from d1bc6d506f25.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 22C3B9A6-7B49-43B4-8982-4B95B4DD05A9.1; Fri, 10 Sep 2021 02:52:44 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d1bc6d506f25.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 10 Sep 2021 02:52:44 +0000 Received: from AS8PR04CA0070.eurprd04.prod.outlook.com (2603:10a6:20b:313::15) by AS8PR08MB6278.eurprd08.prod.outlook.com (2603:10a6:20b:29a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Fri, 10 Sep 2021 02:52:42 +0000 Received: from AM5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:313:cafe::9b) by AS8PR04CA0070.outlook.office365.com (2603:10a6:20b:313::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:42 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT024.mail.protection.outlook.com (10.152.16.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Fri, 10 Sep 2021 02:52:42 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Fri, 10 Sep 2021 02:52:46 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2308.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:44 +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: 83267da6-c972-4f40-bdfc-62b4bd15b13e 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=YA7xJNX+7lrO/F6Bubd9wbDUzGgnyZApHYJThO4/ceyFmBcW/frlQHUSRiR7Me2T6lx/e+21dk5o0+uaHPsB1jHcMoRLOja8vlp7AWghXhlLcSiEcmBwxmZtB7660c8LV3s9aBhg35+qBHhNjZFtbCrKfon89xdlRp9hM9piD4Q= 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: 1c4e958c66743e38 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a6APgFWMbDbJ7BIj3hOAHXH9gIRbcq5u9cX5EWRKoaIl1jDVEMOtOO4wHs1SG4RPV6tdk+E9coz58O4zC0Pvq6pX89H6IIAUVcP8mbze7TOG4pfLhT/7S4Y2iDw4u6UMSvDpbgxadxMwSD6MjnbS/4yU4iVIuotdPCvcFf+MG4+3Qc93yG4kfYYN9ugLbgzHl6BqGq/grUoTqNrGxj+jq0Enw5vo/WTRVeWO6CKIL9OGb8NEa0j+7UDXRpxoh164/D+/pIEdjSZAtDmlkGk6MWFN5mMEf95kgCesZWSm6ahFwum/Ye0rXafNF5ses14u2mYLXxETpJa+/v8RjOZlEg== 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=Pv6hR7Hr8Rhx1i279//PJW8jzO8ortlchi7uNxAUf5uiUu2pV+7xARKX7RCgYujF+na5ay2Ct9tzoGCg7XnWATFqmx8Itmx3qYW8vDW65UTJLjZSGagYEM4LEBqMiUQVQ4GTuMxp5zDXhS8HXsDJU7p4YrGvZdte5/liar5C8gml9Q5suVxsPagTkr7I6gv9zPA4tXK2OVLOHUWN4dU2+KC0sC0G3j5vccC1mpr2vHnvbUw6FKa5Pm2Yy/RSi78uFI6r1mkrY9pQDsQuc9moEkJURcuxWb6XZfgwXWqVoXAfDPiVs2t6Zsak6bV6tAvkHT0KCVThgMO8kAsaPUyWvQ== 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=YA7xJNX+7lrO/F6Bubd9wbDUzGgnyZApHYJThO4/ceyFmBcW/frlQHUSRiR7Me2T6lx/e+21dk5o0+uaHPsB1jHcMoRLOja8vlp7AWghXhlLcSiEcmBwxmZtB7660c8LV3s9aBhg35+qBHhNjZFtbCrKfon89xdlRp9hM9piD4Q= 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 v7 3/7] xen: introduce mark_page_free Date: Fri, 10 Sep 2021 02:52:11 +0000 Message-ID: <20210910025215.1671073-4-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910025215.1671073-1-penny.zheng@arm.com> References: <20210910025215.1671073-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: 4083b3d1-d504-44cd-96af-08d97406147d X-MS-TrafficTypeDiagnostic: AS8PR08MB6278:|PAXPR08MB6605: 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: OBmtivbTaE937o5rHRs0Vpi7zGRVV9j7gF4JAAkcwRM86hdVHySjqYcW813vmeULkKhGHK1Tik9tCdZS7XBL3J+38fINKsn1P7j6Qhz5JjeNSNBU+0KZ4N+n6c1GekxnzwqjSgXXpkwf7W7bU79C055/+OSLWfhMp4Pf8zu1c8Xne2nbOe2KnQurI9KV8YslvpPeYbG6Sr7VMBL6UwtvrAsihckAFZF+imMNXHNeCGLdQ9chKrMimtyB3I+BhQH3X4qQ1H53MSvcbtEywB+vsOKjl40phf64jj6aEqxDNB3JnsEW83YD0+u5qnA+eqzJkPGMhDU8Miw+BFuLpi8A9sVVO+k5iLr9xyVzt8IyWDhLJsCGBvzs16h3c87L07JTQGFpRJ16R0tC3QWxXKflhJv9nieuXUYEX603sIr9l8S241+Q/KB+qN+tFnh5YWah6NjZr9/ZmMDDc3j2jaq1t3Zj9T2PbQ00BGGg2cZRupG9NO+2UKK3dK0DBhfLV3e6XDoPIYAa50EfJ6fY3a7D2ys5vxbnU6RLvemoX9uLzZJz3IFKxbE0eiUgW0JxiyMVxJJ+WHZKDoRsEuuIqxPjL4bYz8vOnd/lgwn/udjkUxaeCM0OztvN/mas9k7coYXqp9QK7aiLQ1HhUvXL8Z1RyTUhTmQnF9weg6we1jR243qUpxPLJeLZmBaQum1A1Kucjuo7hYoSketfRCrG03jmBfc97ekRoY2baFHgiqL3Ib4= 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)(396003)(376002)(346002)(136003)(46966006)(36840700001)(47076005)(6666004)(70206006)(316002)(2906002)(110136005)(82740400003)(54906003)(86362001)(478600001)(70586007)(8676002)(426003)(186003)(8936002)(4326008)(26005)(1076003)(44832011)(36756003)(7696005)(81166007)(356005)(2616005)(36860700001)(336012)(83380400001)(82310400003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6278 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 3d7e8852-6ece-4814-dc54-08d974060f4e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5sXt+8QZxLQZbD3C4mkLkKlvAftYZaO9HHLW2xU0PPi074nnC/cjRGQllYkXdjlu/obOUKKy05lEd+q33//VaGdS4kWZ2HXijIZ1yE//VJScCOx5xnpDVTr+kslHOqY4EMLYxQhkD+OL3Xw6b4QH+By9+ZOpPkOVTdvCwd7rKFG20pKsuH0MCe8MHmFPTJOUkhDFiAHNsHYED8/J8+wxWJUFiLslXYn/qjmxKUmBoTlG7vrLW4KvlyOS/AsOwSxpr4H9Vek8vyynItFUL5xyal9SMfGs8q9zd/eaDMFhtDtlHlrGcQkj8jVRbEeRfjBJj7nCq+g6ZDxBHXhrYr0sLh2PdxeBkK35D2fk9JwaF7Jy1HfNwvjlG2i/+TSEq7jAtHO2DE5xsJx8G7997XTNvzOSYDLtLbNR327AyIYX89X4gF7bUHg4ULkoupNnNsX+q16Rh8TJgVqHuOUHTcVh/CEffGBg1F/h6ZLZjPmYpNpdua3h+xI7oEG/Xncdx44cZswdGrm4qKg9ga4QjZT1nYHSa5OjgP0OV6GHIxE9iI0AbrZ9BMCrLKC2wh7e3tDCjWAclDZyrRipq5fuWpCdnTpFOc/bi+d4YJX3HLYPr5M/Gp+FUvXoXmKBxp61zR+cPw61I/NBzE7LFaXcNCmz2G90CpzlUNybPOa3mqCj3oFWX6G57vag5VWihaaqdJjw9IZzB7DnC8n143Amof7Yxg== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(376002)(346002)(39860400002)(396003)(136003)(46966006)(36840700001)(316002)(107886003)(36756003)(2616005)(4326008)(8676002)(70206006)(478600001)(5660300002)(70586007)(110136005)(336012)(81166007)(186003)(54906003)(426003)(82740400003)(36860700001)(82310400003)(1076003)(26005)(2906002)(83380400001)(86362001)(44832011)(47076005)(7696005)(8936002)(6666004);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 02:52:51.1416 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4083b3d1-d504-44cd-96af-08d97406147d 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: AM5EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6605 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631242399772100001 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 Fri Apr 26 14:14:30 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=1631242402; cv=pass; d=zohomail.com; s=zohoarc; b=IBJW2wNkBrb9ZOr8SXJqltbemMis8ESn7gZarnf8nn5XfyPYpjZDJBkrIT8AXP286z/6+4kTZld74jwFv+ckSd57YbMz5qfwqRBdVS1m9Y9tELNKGmL9b47SVwb7Vpo6d/8GrK12RnK75RfpaZd/opXRwhyCBCQNCnALjufqyHI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631242402; 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=YidLo1ofxwAYNecKLtQzrrxTjqkOLuglQ7KQpw39T7U=; b=ULvN8aSlM3V0RO9K1DW+lWg/36eTMvgphaYO0zbsdPND7s76M/H6l1F98j+oMl4Js/FmDl+b1+C/4yj1Fs9Z5/Wrp5VONuy/4/E1fk8INAR+D/9RgKh2Y/JvCg4jwIy6JMPhVPS2XTBzGfucukfkVz8e/cF/Esi4IBqvADQoUAo= 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 1631242402415316.40186866128056; Thu, 9 Sep 2021 19:53:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.183860.332280 (Exim 4.92) (envelope-from ) id 1mOWf6-00064w-02; Fri, 10 Sep 2021 02:53:08 +0000 Received: by outflank-mailman (output) from mailman id 183860.332280; Fri, 10 Sep 2021 02:53:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOWf5-00064R-Sb; Fri, 10 Sep 2021 02:53:07 +0000 Received: by outflank-mailman (input) for mailman id 183860; Fri, 10 Sep 2021 02:53:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOWf4-0004S2-Rj for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 02:53:06 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.45]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 18b20c5c-a14e-4c69-a699-0e31d94047d8; Fri, 10 Sep 2021 02:52:57 +0000 (UTC) Received: from AM0PR10CA0043.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::23) by VI1PR08MB5358.eurprd08.prod.outlook.com (2603:10a6:803:13c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Fri, 10 Sep 2021 02:52:55 +0000 Received: from VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:150:cafe::a9) by AM0PR10CA0043.outlook.office365.com (2603:10a6:20b:150::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:55 +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.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:54 +0000 Received: ("Tessian outbound 8e26f7114b75:v103"); Fri, 10 Sep 2021 02:52:54 +0000 Received: from 467429ba86a6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DD9D45A3-6A48-45DF-8B9B-50F3A0CE39CE.1; Fri, 10 Sep 2021 02:52:47 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 467429ba86a6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 10 Sep 2021 02:52:47 +0000 Received: from AS8PR04CA0070.eurprd04.prod.outlook.com (2603:10a6:20b:313::15) by AM0PR08MB5060.eurprd08.prod.outlook.com (2603:10a6:208:15e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.17; Fri, 10 Sep 2021 02:52:46 +0000 Received: from AM5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:313:cafe::f9) by AS8PR04CA0070.outlook.office365.com (2603:10a6:20b:313::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:45 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT024.mail.protection.outlook.com (10.152.16.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Fri, 10 Sep 2021 02:52:44 +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; Fri, 10 Sep 2021 02:52:48 +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; Fri, 10 Sep 2021 02:52:46 +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: 18b20c5c-a14e-4c69-a699-0e31d94047d8 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=YidLo1ofxwAYNecKLtQzrrxTjqkOLuglQ7KQpw39T7U=; b=rvDi12Z9MGGj2E5HXuHnfM+VUtvlasDQioIhYxX58L+3aUr7eZ/gueqLFbLLjGPj2IACBOGDISnQ80ciw4E8cmJF9OrNITnKgg4CSNtNxne3obR3Kfmq/3m+wOPbdIJ8426XQs5wkZNXJHSrVzwucfZgrUuuaIwgMT+FRtMR6og= 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: a20cb15cde3001a7 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hvLWhXzjfi4T5GeKjASTGUQgMXOMfbgIpDR7BUBmBxnaL4PAaDo8SU5rhqvcBlSrc582nRkpRNHpfdxGHPOjBjNOSfgnRcLFimgGzzke4z5merUBaHkRS0iXpNQNSGmiWacvVzKLcJGUbUqW7rtVZxd7CnWYlA06L3E/OHcfMINWj9IC9mHuGTGuILenk/tzyvUJC0j8JtYG0t6+Ozltge9tq16Q52IIn5RrNwOwjwncGZapsZjI2UStJysd2DriwSDjH8j4WwMBUmKEW7qa4J9OqQuroicQsXCU7cRQCTshWzBmlTQ3+EgYNRNiKQcZOrzUj5pohWcbx+ZHCths5Q== 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=YidLo1ofxwAYNecKLtQzrrxTjqkOLuglQ7KQpw39T7U=; b=dBJfV9Uzw20+GbqZPr5l4heFWrNdmQxrZGt+jUPbt3BzHkRXBTOzBnb4kFbyMIXRWx6oDV+gPJs/akqfVJ9QBRjkGFZ1MSQI7kt2mbP8DEetXvBCDbON9TKMaen4QMk02OKwiwBer+HPmuAEjcdL7hpZmwdArsRrBNjd4lZvVI6NeZsFo5GYetkOeYM68hdzPNiGV9mfSdy0951EM0IpJE5hAxgQR9PUmbkGuzYFLly064so8gTia1tsE+j4q3pzt5rXyhl1B5FdjXHJhUNO0idBoNPcwzjrBaS83J1m0bC1bdaK2/pnvSVc320NoxfUMfqQbxziNifLfuTYQTBnxQ== 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=YidLo1ofxwAYNecKLtQzrrxTjqkOLuglQ7KQpw39T7U=; b=rvDi12Z9MGGj2E5HXuHnfM+VUtvlasDQioIhYxX58L+3aUr7eZ/gueqLFbLLjGPj2IACBOGDISnQ80ciw4E8cmJF9OrNITnKgg4CSNtNxne3obR3Kfmq/3m+wOPbdIJ8426XQs5wkZNXJHSrVzwucfZgrUuuaIwgMT+FRtMR6og= 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 v7 4/7] xen/arm: static memory initialization Date: Fri, 10 Sep 2021 02:52:12 +0000 Message-ID: <20210910025215.1671073-5-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910025215.1671073-1-penny.zheng@arm.com> References: <20210910025215.1671073-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: ee647ff8-e2cd-4225-f2b6-08d9740616b5 X-MS-TrafficTypeDiagnostic: AM0PR08MB5060:|VI1PR08MB5358: 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: SMAmA19PCuYGuHyg9GzYGzyS/auodm99njZ/jgVio1hA/CqYLFMhJOCdSusERoF4Pnuf/0n/brQjw3kY1y5MQ1Pnj5+kisfA51cYUFJ8RN+GySXUnVZHHDc9tKs9FVZIGmKEZIcU3Fw6DDePXZ8f7GVUATgXsTO1K37dYYg3e4X0u/cmCt1hnnHogXe8jvCetNPvt6nn/1wVLsX0qB5hk+Tn4nWms/Wz1hblh1KYpS0ppIJynm56rMNxgcg+ZROmWtaSZlUT+k1bJouhC9FwogW/vq6vncubiqBwxcSfea7LVRBJaayDlpNsTNudlqNAIzl4p+V9+7D6yCeWhaJAJSxMgllispR2Gtcvp6WJiIJUERLuxQr2fJYVVzJROiSUS3yY5iTj0dlbR2LcMU/TLYC4omt+ofdZblHlygKLM6ENThi+6g6zmXKAS0at3zfpq6FH5r5+lwLsz6ROX3o3m0NPF5oHVacl8524w04Nvsqq8SeVfj6OhMgTAvr96QGoUSHXSaSkg+8wQZDfZKDnEuEQM0iEMuBpCvv3STQlroeZGUHgfor6PGPiVR50XYWTuGXmsL4tD53i3z9YIkL7KHQURxFk0I6PKa02WQCNcMkgpTvE65gBss/H4Ijdf4Rsr9wiFJA+kIy4XMyQ33AUdPjZggD7b4UaH9MBaDjajwOCeK98Z1tp8TaIYQIoNk6ncC36KTdtCevo9+qpi/3aXCuBLX+z6vY74lQg/UUcVTc= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(346002)(376002)(39860400002)(136003)(396003)(46966006)(36840700001)(7696005)(316002)(5660300002)(426003)(82740400003)(6666004)(36756003)(81166007)(82310400003)(356005)(110136005)(54906003)(478600001)(4326008)(70586007)(1076003)(2616005)(8936002)(186003)(336012)(26005)(70206006)(83380400001)(8676002)(2906002)(86362001)(47076005)(44832011)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5060 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ee39b5d5-4f95-42c8-b97b-08d9740610aa X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dRgEMkURts6a72aqC7g80Vi9W0NfFmyXWDkIRfMhH2xbpZ2ERnFEMI5pGfvoJQW2Bq4UsXW8pH85YgfnLPihFV4mBT4Smv6rhSJz9JsmKhVwl7AdJcOQFubdnUm63IFN6Q7XYUCV4y3w1wPsyjw3uV5PnifzmQZUdHyOu2cUnsj0McOfyT2aXC6uHbjykdqOk+mIzVyCSPh1WA2mcG64utXAG3MkEZ7XBRw1KAFPopKcg+NhwdkasPK0xf516PbOZAVnYkVOnxX45p8tzFOMBceqABnvXjQ7f8054QwlSOMBWpGLW0W4ZcXe1PVXEafticCUhN83EZrs8TW6LT0e2y51wwbZZen/YqQTCmYWzXd8H5Cd1hxoF2TgXn0PhecjHQC5UE8NnE3iB08/oIAGm7rFMIcfl6VkOIJt6OeKfDnf+JP2Q0wRRMBBWlwoHKb6vZitVP32Jl/FdzoOQr3llFDgKcj15JByPGEMzMMkUKxJZpZdgrtNuAwnSqIN1ILcn13f7BjxSVTMmhXJ/w8+2/dTMwCEKy2z+XZs9ml49PS0tskxHt9W7v2Svt4g1928kxragHjB2JgScn0D0g7vR4z2NJ1gG/Eg2McPi5j/+BTtm7qFzeYeW03nwEdm8Xc/1e4K6a4e2eF2uC/AulXEyQmld8oEk13egCICi9AaIlVaMSvmcIjVUffzdPBTJclbTUhz6SVX6zYgJ9TvO0HCxw== 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)(36840700001)(46966006)(26005)(316002)(107886003)(54906003)(47076005)(336012)(2906002)(508600001)(426003)(81166007)(4326008)(36756003)(83380400001)(86362001)(8936002)(7696005)(110136005)(5660300002)(8676002)(186003)(1076003)(82310400003)(36860700001)(44832011)(70206006)(70586007)(6666004)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 02:52:54.8145 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee647ff8-e2cd-4225-f2b6-08d9740616b5 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: VI1PR08MB5358 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631242403974100001 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 Fri Apr 26 14:14:30 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=1631242422; cv=pass; d=zohomail.com; s=zohoarc; b=Ee9K4GfrzXalmd2eiVojEZiaPG95BY8G/v0bws63eIEoMEP07mTB/O976sG/9FBWMDa4S8cdJ31wtIBiQg4TYynlTdzhPS2GzfGxHxFLmKarNi6CwjsAr0Uu9vKkMhe6d36bDMPIn16juckqWX0d7rUCP6gYv5/aahpxHgtPJa4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631242422; 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=Qka5FohwRchLmsQOFo9yjoRS80zQ82TnqHEM4A+5Y08=; b=CjbFe/dj8jSHo+jgicNiLNlv7woserdvPj9u//sEpEX6KOE4XPw2Pp7OBueQUpsWwid0LQhUmca5xQqKGDVHijVKIcFwvm44GmbvZPF5dTH1T7UDRC/Oo953635zyHvwDS6CIjskgqhXOoqtTkUNuEjgH1f0r3pcoZlsG0wtU+k= 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 163124242256635.58216869425189; Thu, 9 Sep 2021 19:53:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.183878.332291 (Exim 4.92) (envelope-from ) id 1mOWfQ-0007aA-C3; Fri, 10 Sep 2021 02:53:28 +0000 Received: by outflank-mailman (output) from mailman id 183878.332291; Fri, 10 Sep 2021 02:53: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 1mOWfQ-0007a0-8f; Fri, 10 Sep 2021 02:53:28 +0000 Received: by outflank-mailman (input) for mailman id 183878; Fri, 10 Sep 2021 02:53:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOWfO-0004S2-Sb for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 02:53:26 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (unknown [40.107.22.67]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ed32ae24-4cbf-446e-a3c5-fa9207010020; Fri, 10 Sep 2021 02:53:01 +0000 (UTC) Received: from AM0PR10CA0067.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:15::20) by DU2PR08MB7325.eurprd08.prod.outlook.com (2603:10a6:10:2e4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Fri, 10 Sep 2021 02:52:59 +0000 Received: from VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:15:cafe::ce) by AM0PR10CA0067.outlook.office365.com (2603:10a6:208:15::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:59 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT008.mail.protection.outlook.com (10.152.18.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:59 +0000 Received: ("Tessian outbound e27daf245730:v103"); Fri, 10 Sep 2021 02:52:58 +0000 Received: from 34fcc7f94187.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F7C93D37-C100-4FDC-8380-E3355918ACA6.1; Fri, 10 Sep 2021 02:52:52 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 34fcc7f94187.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 10 Sep 2021 02:52:52 +0000 Received: from AS8PR04CA0074.eurprd04.prod.outlook.com (2603:10a6:20b:313::19) by VE1PR08MB5838.eurprd08.prod.outlook.com (2603:10a6:800:1a7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.17; Fri, 10 Sep 2021 02:52:48 +0000 Received: from AM5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:313:cafe::2) by AS8PR04CA0074.outlook.office365.com (2603:10a6:20b:313::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:48 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT024.mail.protection.outlook.com (10.152.16.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Fri, 10 Sep 2021 02:52:48 +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; Fri, 10 Sep 2021 02:52:51 +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; Fri, 10 Sep 2021 02:52:49 +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: ed32ae24-4cbf-446e-a3c5-fa9207010020 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=Qka5FohwRchLmsQOFo9yjoRS80zQ82TnqHEM4A+5Y08=; b=6jMJB6WLgu5Jruu1Bq3Evw3lOvPlUOPorN4UB2DbybVwGSxHzrRaZ2bF96yYrXy7KW5HmC3bYI5zpQSno54u5voJ1p1myAenEBDlOvRnBIBDW3WKoAjjb2R7x5lkQaG0ogkXJU1l1gOynWWPGb274jz3PrFvSvKzmudB8ln6Tr4= 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: bee34eeaa078c05d X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RuPjdp1LkdQs3N94bhUpqCKd2cRAGtBnjd6as9qImAd4WiIoNB1/+7HWhXanxE/BAYB/jXxfawmzr7N5m3QQGCS+2WoY424jFEHBr8adnfeIljxXzEjXblUtOg2mahGziCBI3EwqrJ4dTlw8wqaKkvcQXegpaPqmqqkDl5qw/RavHIgd94PBghN3PxUDlxEMt523PjsPM+mBh3NTyWCWsTS2EUyEw7k2TNGDn43gaZtck7Lp7gq3zJoJHQnVr2vUtveUEMwwIociMXwpBr2wdaYH9anECEojLaSxft3itBeYWajc2WSsm8sEHj8BesZ1vMyRZaRjXs5RKUrVljmjBg== 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=Qka5FohwRchLmsQOFo9yjoRS80zQ82TnqHEM4A+5Y08=; b=G0lqfNRDsaVnFOwwYgPLG+rDDLY5rBJpfk+CKmnHwDGazr16oFC1zurRNbUgaAC4MqGY6yraqE5VdsoepR6P+9k9EWoQ0Dw2p+5nChzdVfOXzGJ+hdkgkddftd1M5YoRR/hrbtin50VvLuWYa0aOkANrS6LFwrFNtvOVLzwqc/QK62GJOcGZDaKUIKQKWEMBZVrO6IKfhk7fg7NI0DI2eCbaXBJq4mge293xGO+J3WEx8ivt1VojuGjbpsWinbvf2cUfxXqJa2Q4sqrvCc1VEW93ubvx0gKlko+1mlWs+wSdOFCiW9IG3/YiEg9uzmFtYKDlB36hJ3/CAvAhvDFk2w== 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=Qka5FohwRchLmsQOFo9yjoRS80zQ82TnqHEM4A+5Y08=; b=6jMJB6WLgu5Jruu1Bq3Evw3lOvPlUOPorN4UB2DbybVwGSxHzrRaZ2bF96yYrXy7KW5HmC3bYI5zpQSno54u5voJ1p1myAenEBDlOvRnBIBDW3WKoAjjb2R7x5lkQaG0ogkXJU1l1gOynWWPGb274jz3PrFvSvKzmudB8ln6Tr4= 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 v7 5/7] xen: re-define assign_pages and introduce a new function assign_page Date: Fri, 10 Sep 2021 02:52:13 +0000 Message-ID: <20210910025215.1671073-6-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910025215.1671073-1-penny.zheng@arm.com> References: <20210910025215.1671073-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: d82fe461-5d74-49e7-c1b5-08d974061950 X-MS-TrafficTypeDiagnostic: VE1PR08MB5838:|DU2PR08MB7325: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6430;OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Z+FRo+RfN5ZisZvPsYpoe2Cu+G9Qf/vHP9BH5spmL0ZDah5VzmXZZ1DicNSiDm6VbyRyiMAE/431/EDRisP9Jr75JFMGedJNDH3MIfyGBaQjCPJNrXolRqOsDvwNVlsBHvdubhA89b9tmxGP2KpWffSaFaTPpHuobUtQr+fwndIvjr09H1SgJVWssdGDWSCPLuA5hwTpz7j1S9V3FTcXnPc6k2fo5iTKAfhXagBkOu5Yc8C7gmCDDgZ79Xif2R2e2+Qwl7gdQgTEWYb3oy+T7JiYi29ojqABkO4y2vqYhTK5lbfkUIxAxO2FDXLY7ukBzE+G0kF7YxIhxp1oumSnZomyebX2RLwkDKbZYxd13Uori4hrtqFlFj3ZjS+BBJmwIr5W8OT7ikyU/j8C3HfLSTtZ5Y/AHZ2lQkqdj+zBYGs+FJlUG+mIbwhcgHkWcR/nSBd8bOAXUIOCk+38RMy1fX5m4pUSzbcvuoieSPNrJRV4OmFhHawDJC7VZg7Ehl5gSABTdp/nC6zp50DrhTSMcnGd7Xoa9cS3TM44xCZCvPk1QJd2fHVSnwserbb29aJYDqRblqsNaI3ImPbUHCJ47O3j/BbhyTMiybwDgHXmmc+SXhoWYiHkULweiuI98f/U1fVh2Gkb1x53qPOphZteWk1hcKtdFpfxyncIQPGV5F/GE9fPtCJw8GHzWP7Ft15swz2ZkO9HN8SHv5geIPeNhaO432jdqu3sSkjUrbOcgLU= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(346002)(376002)(396003)(39860400002)(136003)(36840700001)(46966006)(1076003)(83380400001)(426003)(8676002)(36756003)(478600001)(8936002)(2906002)(316002)(44832011)(82310400003)(47076005)(186003)(54906003)(70206006)(336012)(2616005)(86362001)(110136005)(36860700001)(70586007)(6666004)(26005)(356005)(4326008)(5660300002)(7696005)(81166007)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5838 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 17b54f2f-5173-45f4-ba8f-08d9740612c8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p9d9q0VWXuc7PauQJZRdcIZWexwBjmWhcPMqVQY2LkjQ9qFi6qwrRt1d03VI35biHsyd7FpfEKADBOnEbnZMJ4qPnV4KBpVOXpxzkhgRSVxX4XSfkdE8u34Oi1Iy1pqvBqgt5oIdmli/K5qPxOTtp7zPtei48RUM0tMITxDDNgm/O0fgiMBOF4X2Nr5zXgUiznzS3syQWSa3U/bMDUkxIPLvk6x5gH/AfQcpA44YIQSM68bcV0W/G7TMfjpI/Sk2eiGQR+3/eI+er+QUfDiT4U+iAdDVBYdEy+8XaijqiWgBlhI66t60BfybNumYct8xDAEpIfevWxE7yHlGu7PrcWq7Uwh5preNr37zUMhnEfLiberZQGSqPPxB0ndBg7GYTJsH0eikjPqhdIN3rLcoAjfD2gkDJM+hlI3qhBqDAZ2pVN/lLC+upwhG3FxdYou7KRsJurAGZ14cULZpO8LPJwF5BJTWZVej9g74e9Nxh1YK/QB3ZQ5kj6rd9AiD5jpD28ax0B9xNhizXFLdn80wKYqsFAwy7Fxupo6+pGAtjlcPqT0IjxyW9WAh4jfG8jG395gMiYngEkQxNTinK6xgn4kRvJoHuRSmNXgfaFVgA70AXdXRYYzgRNagUKBmyIMpnu0cDF24zxd13xVhGKz9WRVFt+FoRBS8DJd/LCOX6JjrS/WENABM1XCZFAQqaKvb 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)(346002)(376002)(39860400002)(136003)(46966006)(36840700001)(7696005)(82310400003)(54906003)(186003)(70206006)(1076003)(70586007)(336012)(8676002)(82740400003)(47076005)(81166007)(4326008)(86362001)(36756003)(110136005)(316002)(2906002)(44832011)(107886003)(5660300002)(2616005)(6666004)(8936002)(426003)(36860700001)(478600001)(26005)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 02:52:59.1775 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d82fe461-5d74-49e7-c1b5-08d974061950 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: VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB7325 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631242424861100001 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 assign_page for original page with a single order. Backporting confusion could be helped by altering the order of assign_pages parameters, such that the compiler would point out that adjustments at call sites are needed. 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 | 23 ++++++++++++++--------- xen/include/xen/mm.h | 6 ++++++ 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index d7f9e04b28..77efd3918c 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(mfn_to_page(_mfn(mfn++)), 1, d, 0) ) BUG(); } initrd->mod_end =3D 0; diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index e80f8d044d..fe1fc11b22 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(page, 1, e, MEMF_no_refcount)) ) { bool drop_dom_ref; =20 diff --git a/xen/common/memory.c b/xen/common/memory.c index 74babb0bd7..63642278fd 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(page, 1, d, 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..2aa8edac8c 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2259,9 +2259,9 @@ void init_domheap_pages(paddr_t ps, paddr_t pe) =20 =20 int assign_pages( - struct domain *d, struct page_info *pg, - unsigned int order, + unsigned long nr, + struct domain *d, 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(pg, 1UL << order, d, 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..9d6a45174e 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -132,9 +132,15 @@ int query_page_offline(mfn_t mfn, uint32_t *status); void heap_init_late(void); =20 int assign_pages( + struct page_info *pg, + unsigned long nr, struct domain *d, + 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 Fri Apr 26 14:14:30 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=1631242399; cv=pass; d=zohomail.com; s=zohoarc; b=LVRha2kLAqePwWyxWjToBbQjOiY/mBpgJeclb3NlcgLbGykaG/Kkg+Ip05O4EGHam43HEjdRA7zwRqzf/P3NuHGFKpW06h7RLiIu3s5r3CyO8x4RmGFPESRTjXozi9XeIdt5O8C56x0Q1pGtbDdXzDBHOvPfdMy7omIhAX3qs5Y= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631242399; 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=hGwFKYY5V6TMXu7tjZlS3TFGVb7eOMQrJfMUNLSc/DY=; b=OsicvOF1cJJ6z3eW4fpEEqjXEqXzaq39tfnWWQIZeKVvFeFgul2ra6Wiot+t/xdzNIvTvuhXNHYrOAccYHyYMaA1x/qb7Cn2Yu7OrrxJg8kES/tiWBtVJFcUOp4dbipxMMYzHs9Szbtf3wsUSaW8GsnNIt/0dYZAb8bzfIQuWp8= 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 1631242399948662.9028088655136; Thu, 9 Sep 2021 19:53:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.183858.332269 (Exim 4.92) (envelope-from ) id 1mOWf3-0005dl-EI; Fri, 10 Sep 2021 02:53:05 +0000 Received: by outflank-mailman (output) from mailman id 183858.332269; Fri, 10 Sep 2021 02:53:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOWf3-0005dY-AR; Fri, 10 Sep 2021 02:53:05 +0000 Received: by outflank-mailman (input) for mailman id 183858; Fri, 10 Sep 2021 02:53:03 +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 1mOWf1-0005Hy-36 for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 02:53:03 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.84]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 364fa0b6-11e2-11ec-b209-12813bfff9fa; Fri, 10 Sep 2021 02:53:01 +0000 (UTC) Received: from AM5PR04CA0011.eurprd04.prod.outlook.com (2603:10a6:206:1::24) by DBAPR08MB5768.eurprd08.prod.outlook.com (2603:10a6:10:1b1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Fri, 10 Sep 2021 02:52:59 +0000 Received: from VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::d2) by AM5PR04CA0011.outlook.office365.com (2603:10a6:206:1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:59 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT053.mail.protection.outlook.com (10.152.19.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:58 +0000 Received: ("Tessian outbound d5def7722ff7:v103"); Fri, 10 Sep 2021 02:52:58 +0000 Received: from b326055b7f74.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8D64FAC2-F47D-4F5A-80BE-9FD6D2FC3941.1; Fri, 10 Sep 2021 02:52:52 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b326055b7f74.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 10 Sep 2021 02:52:52 +0000 Received: from AS8PR04CA0079.eurprd04.prod.outlook.com (2603:10a6:20b:313::24) by HE1PR0802MB2585.eurprd08.prod.outlook.com (2603:10a6:3:d4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.21; Fri, 10 Sep 2021 02:52:50 +0000 Received: from AM5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:313:cafe::39) by AS8PR04CA0079.outlook.office365.com (2603:10a6:20b:313::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:50 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT024.mail.protection.outlook.com (10.152.16.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Fri, 10 Sep 2021 02:52:49 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Fri, 10 Sep 2021 02:52:53 +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; Fri, 10 Sep 2021 02:52:51 +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: 364fa0b6-11e2-11ec-b209-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=hGwFKYY5V6TMXu7tjZlS3TFGVb7eOMQrJfMUNLSc/DY=; b=4CEwSqaztcXIYoi435uzhaDzyqi/pZBUgaj+QKh0G5xGKehylQTnknaPQwuzOpKCGC5lfmum3zjrZyUdCvUiwh43JN2IW3SI/tf5/mcDo6yElRwZprWai26VjHg9C3IkMODeVR46HVuscIOfGKKgMM9VJsXFP2GceH3/ui8INXo= 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: 703c4f62234778a0 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sp/1nHV5tgMLNZF/mVW5m/BvqZoL3/KjHFRz38FlkeBk88s12C6ryq92ZIPCSR9/VaaMIgjaZo/jymiCPXioT0gfKt+xnhGfnyO3Vxw1l7wyuCuKZ4ROA/fhTux+S+r3/1i9lMxFcInh2ocEJVECTmcwZI1zg75mC9j6FCEUWdk4w7Y/hYW0mjCm25JwBTf/+T//1D3ohSG86ZgRyHGifWZqAmuV48pqT8Ll3uufHQbMMsacR79niGizcCGM70G5A1Lu4b/qrlrd1KtfhQWxvrEQmEq0RwbaZwni8NNoHDuMHEVxIenGUgc6jc4nebzwTADH6SOtmZ6IUTKASs2ssg== 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=hGwFKYY5V6TMXu7tjZlS3TFGVb7eOMQrJfMUNLSc/DY=; b=il0AROm0oKYVcDlQ924c9bQCWKQ87gZwqTOzycq/CQnJH3EfZDOASke9ewntmFURMaC3biFmMqdM/kg+sQ9cAuKdsR3vDeB+vbg33VOeeCuQ63xc4Q6JjeFOky7gzu8iGQMPPcxR6jTGMwB58QKc5sOGE6uazoWyCaIyrc8Onler7JrIUA3ZpTohA/2zIlxpPyrg271k6SA9ae0IiWQZCurTdII8hZ2aal/SWh82Y+y+8sEHuOdSdMOse4feH9pIFzTm6MdJkqORvj/WXgFebdtFNKXXbL26VcnGLFVVUDigIv8/AEHxH/b6F+A/i7zQn48z9NnBOxLrtQHknOCEzA== 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=hGwFKYY5V6TMXu7tjZlS3TFGVb7eOMQrJfMUNLSc/DY=; b=4CEwSqaztcXIYoi435uzhaDzyqi/pZBUgaj+QKh0G5xGKehylQTnknaPQwuzOpKCGC5lfmum3zjrZyUdCvUiwh43JN2IW3SI/tf5/mcDo6yElRwZprWai26VjHg9C3IkMODeVR46HVuscIOfGKKgMM9VJsXFP2GceH3/ui8INXo= 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 v7 6/7] xen/arm: introduce acquire_staticmem_pages and acquire_domstatic_pages Date: Fri, 10 Sep 2021 02:52:14 +0000 Message-ID: <20210910025215.1671073-7-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910025215.1671073-1-penny.zheng@arm.com> References: <20210910025215.1671073-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: 789e4663-c80f-4918-ea94-08d974061902 X-MS-TrafficTypeDiagnostic: HE1PR0802MB2585:|DBAPR08MB5768: 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: B69ufQAkoo4x7JS2n/eCI1CIMVScJzIvR2cTvZ5tfp9rJbr0OnWVmRY7ucjGHV1BfyZKNjHHpWUrnwR6bMD3crXPiAN9g9cu1309g/qpp87z8yuWvKb+DTxHWPaknUWk7aqV3Z6NpPomXQNfoo4h/mXBPcEmISuXSsb9zVW/hXPnx3isH8C/jLLCcIlxpMlQ4XMCHcJsOozJRtGAKNujmwPj1/lP5jKd9HDEccODXzpw7K8SeYtkQM/1CMYtH53On6hAo10MkpEXrVgyHUCT+LzHpFznSxjziVmhbs6tq4sv1IluPBnFVa99WYq8wF2/CTLXzdp/FWs6XuEg7UJL/axI6hw87+FDGsg/2R3aut6X4JL0BK9yEUuybWbB+duXfatNwCTATVwZhmii6TRGKDHVtdeTIygVcgXAsfltKQNd9YB0FYXlXSnbe/PdgaKpkzSzYeo1rfDaKQkBKS8/Rh5T8k1ta/7TGf3IQ4Nm/KIDg+IFho+ZAr7CLYCc6UTV1UN4H4l2JyAuq3QJjRJYBYSUauad/8Oxpm7G1JBuUURa0492WN/nS4UxNx+YTnUKT2k9op4ZxvThyc+NnduYke2UEFfnVc8FqDkDxWSr4w50EgYQDDgvGqqJrLeQTOg7nN4nunpXokvN1LBLTkaRgGHwOrwrKvlDc6PO7UtSVPth2W1tUzSqmngWwnfr6LzOHLmQOifDPuxtGgW26Hdk3/oQbPxOr+v5r7hzLU40Krc= 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)(396003)(136003)(39860400002)(346002)(36840700001)(46966006)(36756003)(356005)(8936002)(4326008)(82740400003)(2906002)(70586007)(316002)(83380400001)(5660300002)(478600001)(70206006)(82310400003)(81166007)(47076005)(7696005)(336012)(186003)(1076003)(2616005)(44832011)(426003)(6666004)(26005)(54906003)(86362001)(110136005)(8676002)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2585 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: f77242cb-d175-4fb6-d253-08d9740613c4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0J7Mrz8oQmoemMFwEMjm/LvD/WDiu+YTTLEkrBKzKzrvBE4mLJt9dBH8E7WWdcZUphEkN9JF2xCe92xYNq5DPN4TT7nz+Bzz8h4ncyY5ALP97vbySJ1qr/fczoAVU9NVyRHOt4ne11pwVoYmdaXO85l76XIgZMMxCkts9hxbOWBKcPmUIgo3HOziyLDW4ycytROzf9tfmeC695ACbIWaoPjKumh6qyzPDPyY82MTW+64rX/Fhv0S6SJxiP+BGtTCh5n5je/tttMGoe0p/PmH5aa+Ym/J7udGpuTlVUSMsInl0WXFtYRt11jvMitoAVz+ImMJ8/8K3RYW9zgoRq25kBM7qDZ2RhdbCG8AA9K1+7kEHCkCPNnbw7xdQnH+sBAvHt1Kp4d1+jE2pUbn7wvf9/1Tru5ujHsIAsE3YWYV8+6pFi8oU6JkUxvVLQUfuxw5JbVxGIi62iiOjLl2KMlrAJ5JTFdNN0QOHZ6TeVWBYPbPR9QCPz/Ap9kVXMc4Zucsu0cPfxfE7E+EfpJpSI+V+PkWawePuI7lqkIOTqJrxKvyjdFzYB+/+BRYuZTerC5uRwZcYnOCjxjrOERzOa/C8NVp+D9zWbl06vrLKh4792dXN4cvZ+SsxP8T+3LrlxkE8MJFVXvBrqyGpSztISUlWKH3MreTKcAVghIG46Rg11gJh5JGFus+C6fFoFxtAHKZvX9hgtuapOAKt1wWSIuBMQ== 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)(36840700001)(46966006)(36756003)(2616005)(8936002)(508600001)(81166007)(316002)(2906002)(110136005)(4326008)(54906003)(336012)(47076005)(83380400001)(6666004)(107886003)(426003)(86362001)(1076003)(5660300002)(82310400003)(186003)(26005)(36860700001)(44832011)(8676002)(70586007)(7696005)(70206006);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 02:52:58.6819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 789e4663-c80f-4918-ea94-08d974061902 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: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5768 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631242401863100001 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 2aa8edac8c..5eb87b51c8 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(pg, nr_mfns, d, 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 9d6a45174e..f8500f04d4 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 Fri Apr 26 14:14:30 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=1631242433; cv=pass; d=zohomail.com; s=zohoarc; b=UmRZWG4T2UppgkSQ8VCWaBNuLjyaVMpKdCZ97ORx7+9eCgV54nm5LcZaZFY5bralHAORYhIjfaxBzDu5VQem+dalDo10PZiDLlllxD75wCt/CCOH5KMXlDLbV8v+9GvinyGX4IWvJz4izjM5FvZaEFXY4PFjMfvo2m4jAaOUW+Q= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631242433; 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=/NnnHPaDcIoXHeQJGuPrSxCo6z4bgyFzyrpk+3oSabk=; b=Zji+1GLH2vcbw8DKI0XTPMZwefMmLueAvKTXFAn/Nk6NWJxi8MRuYXwy4OWcEIOBp0iq7bjmVmcG6K08IrS0gBrtWbcq4WVzhKrGq9XA4+N3JECoCZHUCj1lRoMvo5eFiXrsf2g6DGKTYz3rZQvtOp/e7PbkJHKaRskx/A5muVg= 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 1631242433821798.3345158335541; Thu, 9 Sep 2021 19:53:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.183887.332302 (Exim 4.92) (envelope-from ) id 1mOWfZ-00082Z-Su; Fri, 10 Sep 2021 02:53:37 +0000 Received: by outflank-mailman (output) from mailman id 183887.332302; Fri, 10 Sep 2021 02:53:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOWfZ-00082M-NY; Fri, 10 Sep 2021 02:53:37 +0000 Received: by outflank-mailman (input) for mailman id 183887; Fri, 10 Sep 2021 02:53:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mOWfY-0004S2-TE for xen-devel@lists.xenproject.org; Fri, 10 Sep 2021 02:53:36 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown [40.107.21.75]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c35f1c2e-438f-4a00-a602-2221e6a25293; Fri, 10 Sep 2021 02:53:05 +0000 (UTC) Received: from AM6PR08CA0015.eurprd08.prod.outlook.com (2603:10a6:20b:b2::27) by AM5PR0802MB2547.eurprd08.prod.outlook.com (2603:10a6:203:a0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Fri, 10 Sep 2021 02:53:03 +0000 Received: from VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::b7) by AM6PR08CA0015.outlook.office365.com (2603:10a6:20b:b2::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:53:02 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT051.mail.protection.outlook.com (10.152.19.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:53:02 +0000 Received: ("Tessian outbound a8bfe25d7364:v103"); Fri, 10 Sep 2021 02:53:02 +0000 Received: from 7bf717e4cf3e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EEC0EDA1-6B1F-42C1-846C-A46BDE7F37EB.1; Fri, 10 Sep 2021 02:52:55 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7bf717e4cf3e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 10 Sep 2021 02:52:55 +0000 Received: from AS8PR04CA0069.eurprd04.prod.outlook.com (2603:10a6:20b:313::14) by VE1PR08MB5053.eurprd08.prod.outlook.com (2603:10a6:803:10e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Fri, 10 Sep 2021 02:52:53 +0000 Received: from AM5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:313:cafe::9c) by AS8PR04CA0069.outlook.office365.com (2603:10a6:20b:313::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:53 +0000 Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT024.mail.protection.outlook.com (10.152.16.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4478.19 via Frontend Transport; Fri, 10 Sep 2021 02:52:52 +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; Fri, 10 Sep 2021 02:52:56 +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; Fri, 10 Sep 2021 02:52:49 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2308.14 via Frontend Transport; Fri, 10 Sep 2021 02:52:54 +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: c35f1c2e-438f-4a00-a602-2221e6a25293 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=/NnnHPaDcIoXHeQJGuPrSxCo6z4bgyFzyrpk+3oSabk=; b=tKxlwijYVMSRjesKxhZ4iIWhpzMJoLYnKrxktAAu/KtDeccIRinN09OvWEa0K5oBFXVj8FmWgvXBhGOL8WNMfJrWDqV8R6ih3NYd7bCVIKSEcGnkjDh3k/NBRdqOdmTJVrzMf1K7ct+ZZBTBpdmbTdY1/GgYIA/jAVZm9B6Wlmk= 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: cbfe770c9afe4a32 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nH8lg8Rv0Nv93ZNYv3aIo8GI4J2k4MxNZyMunM3JWn9zUditGYIFI6mTaqb4zdSyoM3fVVkApOIyfqTklyaYl+ydJjIqcLegXJZDmi8Xqv1JkVS5oA0JCKg1Zd4FXp7OzAPOb9TZG2PMmx8cYRBY+ciG4HHwVOiPP6GOEQ4qMmPZhGojvNvjEmz48fG9HWXr/0k4GmHMSvsZdNAS72kukZmp1S5lntKDJox6w/TfTSQ8Tw8ONURf0qmXnqEs7Yth1FfBT4NUMcBrGZw8kJCWvTmzjsQ0M/EmTNUXdHIcXA7XPGGftl3adOgHfFJbfLgOBK4RXkgMeNa18pSfD0TQMg== 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=/NnnHPaDcIoXHeQJGuPrSxCo6z4bgyFzyrpk+3oSabk=; b=lxjI83gk2TO8VwD63j/5FHnh5x171Jo53s4cz1xSenI+BdNv5f6F+HoWhl4dhBDDc2fpJG8Xqfsm4MGpF+nlmFMItP6SDcbxT0eFTM7w+lQTvVOXeIxPZnYTLscnZ4O9x/8pCmJogksqD2zJNPzCmMuoecchfHBQhd/MI7Q4mtLJcFKF+ggSPSOQ8bcmLmbkHKU8Mea2NEAlYdajgcFq+OBj0AUhlRxdodSD6a8WoZdyQ7BCp0NzgSL7QKJFFPKb4XDZog9b4RyQKDgPrV7lAXMxigKhvU3bAjA6Z0sX3oZ+UAO1sR/gJDpu2/ThCfWESkR5kwAjHK9WPqR3x9F8pg== 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=/NnnHPaDcIoXHeQJGuPrSxCo6z4bgyFzyrpk+3oSabk=; b=tKxlwijYVMSRjesKxhZ4iIWhpzMJoLYnKrxktAAu/KtDeccIRinN09OvWEa0K5oBFXVj8FmWgvXBhGOL8WNMfJrWDqV8R6ih3NYd7bCVIKSEcGnkjDh3k/NBRdqOdmTJVrzMf1K7ct+ZZBTBpdmbTdY1/GgYIA/jAVZm9B6Wlmk= 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 v7 7/7] xen/arm: introduce allocate_static_memory Date: Fri, 10 Sep 2021 02:52:15 +0000 Message-ID: <20210910025215.1671073-8-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910025215.1671073-1-penny.zheng@arm.com> References: <20210910025215.1671073-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: 8fd965e8-6750-4471-159b-08d974061b62 X-MS-TrafficTypeDiagnostic: VE1PR08MB5053:|AM5PR0802MB2547: 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: kDxhc3askg4m2P4IgpQNEJz8f+qGLfhKQJ4gVw/9odCd+hg84KH8RtQvQZ9T0lixbwhf1+RYnbyl4YHsHLq6Qd0TqXTVKrkutvmN6dEPYgNxFFQdHzhG+6AbgdHBwrlc0Z6L7QRqcEyy4ir1WZFDGj6cnSWwpreuKl3IvGxKQxXTd3ZyupUPBOlLl0oizpGzb3mF5Qyu+XQSUeVrym2AjGfaNE95KSebQaHGOfuMpJ+Poc+HzIKUJrOyBWftbj71JfUuCe4mHneLIFIHdFudaJwI2rataXYCuq6wmJyL+KOlC94LWLKP418BbWbpjwfNRvWnJd3A7ZsfCNA4GsR1lnZRuWHapbEJiGvCz/LxdqM4MvQ/3Pqjl0GckcEX758R4F2jlvKhhg4QVDcKAzs4uIk5YxCfw7+eLPUaslN0iL8ZCMBIgEr2BVhz7KZl2jKEUASiSmB1Vx1zvLqZ1QS6IoLWpPRbx7qw7hI9fCxdn7icmknODWl/lmuXi+HXokGdhvIWKFBBSEaXmO3Ozsepq3a+fYGVpoF5GHFHGoHZbYbUPzWMLtpIzvZhMX61skxMBtWeM9sIfsircSOhXaxAUqUIHZU2lwGjbYRySByCG9br1hcBZisgb9S9E8yMh+8rH5oV16ybCOa94GjTXT1uJgwK9sEh5YjNY3OmRs/iyYgnlv8Num9gyrrf+muQsvQbxqMLl1v3ol12LjlMfzIp0N6HR4DALXFLSoqx+1LK8Wk= 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)(346002)(376002)(39860400002)(46966006)(36840700001)(8936002)(82310400003)(82740400003)(70586007)(5660300002)(110136005)(81166007)(83380400001)(26005)(6666004)(86362001)(36756003)(1076003)(47076005)(2906002)(70206006)(426003)(44832011)(2616005)(356005)(7696005)(4326008)(186003)(36860700001)(336012)(316002)(8676002)(478600001)(54906003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5053 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 14892662-ccf3-43a0-2344-08d974061579 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YRoBAxkRqgnCeOrBFbjLIRhw7eyklvZUFuEiO0rmu++CPegIJKGBS34nwu4R15aY2gAIetz6QGtiMUIn5FKj3uGBbJmpIj710tAKGo8Cyo4WdMD96zPY5peKatZHlJJlYunFrRGPB6Vy1TRWZ1fvpmpH3xiDNAv0jpuqrP706aSctKMzjespoSTTm3jcefahEs0Jn9AJJkCPsAp7VWzwoOaWAO4s7xCUZr5Kn+u8q44+iJHAsT93twTLvUJbpsSb8xjDy//zWWOqL4yuazjpdYK1pwmxucgnXxHk6lhjFzQ0w7BO06YLRHJgGZU+jO0gHw8cW98uWzZKzoppRavSXr+/MonsTlcTxAJr4Y0dPfuyYZSuEYr6n/wEf0VYiT2hXWyLIe577uolyW6+KLdhj98C5ovN1f/PwrqvCtAXaUtoBOXYwHKS4oo8LhcH9B8xtpmLCN0+2+0QDkYxDAjkVRTPtzRRpXNFkxRXsa/N+KdrmMzRW3Glh3z0xcHwPqtklDKAMfZvER5DZLiQqXFndjwUxVb2nWsAHZMrQSeYesRflNNHp3gIdk9lz96AD6uZZdroouXNVXlF38Ghge1MuM7aHtxfwF8xACJnfC3Xn/9czMSmkB1NoOWoD575TDxU+SleNmTKPJXw27e5uR/pyyBviJ94pV41rmt+OYKF0Z4rzpARsWV7N18BLEpo5BQUyOp/sR6KeW7YUFBK2I0Spw== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(8936002)(81166007)(36756003)(26005)(7696005)(2616005)(107886003)(82310400003)(186003)(47076005)(36860700001)(83380400001)(508600001)(110136005)(54906003)(336012)(5660300002)(70586007)(70206006)(316002)(86362001)(44832011)(8676002)(426003)(6666004)(2906002)(4326008)(1076003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 02:53:02.6266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8fd965e8-6750-4471-159b-08d974061b62 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: VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2547 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1631242435151100001 Content-Type: text/plain; charset="utf-8" This commit introduces a new function allocate_static_memory to allocate static memory as guest RAM for domains on Static Allocation. It uses acquire_domstatic_pages to acquire pre-configured static memory for the domain, and uses guest_physmap_add_pages to set up the 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..62ab7d0ead 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