From nobody Thu May 2 19:42:08 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=1627468153; cv=pass; d=zohomail.com; s=zohoarc; b=OaAoZww9szRP/ojPM/YIXW3SaDOCJOgt+XaUesMfq1hIjUoE6QMc+1eGjtCAmPd4E+CV9J7pf0sy0og/NkYZk6nPEjLCKs++XQ+AgrSDuy7a54C7wi/GmPH9NibuHwMvOM8fRx9XCKjTYPuVQrWqg7coVilONyAeoIekFgWPhXg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468153; 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=wYEBoopV1YlRD0XXxn0aEpPvzx8no2mTrWFdMcSB8LE=; b=JqxBh5IBr+va4+doRAatdv1XLm8sIwTREdtSwMwTa6j5bQQmskjrCmSJVTzraZLqJTvXCNZJVMlQJSuQFSl0fTEm17zjW/fv6KdzQQqy3b8kAtO8/fLdpK27A85qexi0ffLWK3+wg67NWUuZpMwAtZbK0hmdy8uW+ckKsvk8haY= 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 1627468153035123.98282025661524; Wed, 28 Jul 2021 03:29:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161424.296414 (Exim 4.92) (envelope-from ) id 1m8go0-0004sT-GK; Wed, 28 Jul 2021 10:28:52 +0000 Received: by outflank-mailman (output) from mailman id 161424.296414; Wed, 28 Jul 2021 10:28:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8go0-0004sI-CF; Wed, 28 Jul 2021 10:28:52 +0000 Received: by outflank-mailman (input) for mailman id 161424; Wed, 28 Jul 2021 10:28:51 +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 1m8gnz-0004GY-D1 for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:28:51 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.43]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 97b57ffe-ef8e-11eb-9786-12813bfff9fa; Wed, 28 Jul 2021 10:28:47 +0000 (UTC) Received: from DB6P195CA0019.EURP195.PROD.OUTLOOK.COM (2603:10a6:4:cb::29) by VI1PR0801MB2078.eurprd08.prod.outlook.com (2603:10a6:800:83::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.30; Wed, 28 Jul 2021 10:28:46 +0000 Received: from DB5EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:cb:cafe::a8) by DB6P195CA0019.outlook.office365.com (2603:10a6:4:cb::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.20 via Frontend Transport; Wed, 28 Jul 2021 10:28:46 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT046.mail.protection.outlook.com (10.152.21.230) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:46 +0000 Received: ("Tessian outbound 69e1fde53269:v100"); Wed, 28 Jul 2021 10:28:45 +0000 Received: from 54344488be41.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 99962709-FABF-43C0-8283-00E9E1CBF429.1; Wed, 28 Jul 2021 10:28:38 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 54344488be41.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:28:38 +0000 Received: from AM6P194CA0008.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::21) by AM6PR08MB4231.eurprd08.prod.outlook.com (2603:10a6:20b:73::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.29; Wed, 28 Jul 2021 10:28:27 +0000 Received: from VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::30) by AM6P194CA0008.outlook.office365.com (2603:10a6:209:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.20 via Frontend Transport; Wed, 28 Jul 2021 10:28:27 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT055.mail.protection.outlook.com (10.152.19.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:27 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:24 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28:22 +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: 97b57ffe-ef8e-11eb-9786-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=wYEBoopV1YlRD0XXxn0aEpPvzx8no2mTrWFdMcSB8LE=; b=Y9BtjPl/FkA2tS+Dh6Gk4CLfyy/bgKDs5VqNb0sYQOmQhi95ji2coXEMVmphHpwBZHiiBj41VWZS6pxplxZngv8WE5qXFlyDKarFdDx04HzSIrmR7iS4CkL96gM4uoomyqWaYHqR5LTGb1Vl9wvLnqd/eWEKU6oIeNRgmiY7QCE= 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: 68053127126dae03 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=exhxDZQ4YzvSFENyaGxWjUYJt2siptm9+uZTSFZI8rdum/UZHvMJHzM+WOvJMQWgaxZi/ekVBJFlzhHS8Xjhl9SZnIHgWTRSd33dJrJVTE445XBXxVgi4rOXZt1lymDic/nEaQxnJtqJyEScRB20Q7Hv4aq8o/3ay/iYfIFR3xhezWQrAqc7Ij2VH0nbX7dNBZRE4H/hdNvlORo61owTQSD6jM4f9/RSLjva5RKw2ZNhQQo8de7Rx3yXu1yFH5PeNduDCwqtWLS9p+zhF34aUBuDmO8RP9NRpxy1I8KliloVz8poFRbuc8Lq7dvWA3c0ZtFLCgx+J5hVBSkcogainQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wYEBoopV1YlRD0XXxn0aEpPvzx8no2mTrWFdMcSB8LE=; b=dXqqzAkcyS+wzzCARZUhpl5fyeJ1BSD+skf6UbvEQqFgE8Av3x73QLEqedk52WbnZiPCF2o5QUpL17NfqggFwZTVwOr2if/i375pCeAeL8JxHUXLt9mDCPLAQziyP/TMHcoXCPo9dMRWwb8AhM+n5JYOM63uZBflD1z9dpaS81bBQRgJcv4ewrweZSShocJEBQETLwdZpbzri/u0onY3+7ABY31qmU3MT4HSNCdhEjzsZPJOBQVrvmvZ/rfu+KT2osQILeOYl/BbWRX6s0H+uOXkjNBpje7WNXmoZZEyi4tV6YC4FPFvKYwqSC486QjWea02wjMCgRy7nHIw71Ma9w== 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=wYEBoopV1YlRD0XXxn0aEpPvzx8no2mTrWFdMcSB8LE=; b=Y9BtjPl/FkA2tS+Dh6Gk4CLfyy/bgKDs5VqNb0sYQOmQhi95ji2coXEMVmphHpwBZHiiBj41VWZS6pxplxZngv8WE5qXFlyDKarFdDx04HzSIrmR7iS4CkL96gM4uoomyqWaYHqR5LTGb1Vl9wvLnqd/eWEKU6oIeNRgmiY7QCE= 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 V4 01/10] xen/arm: introduce domain on Static Allocation Date: Wed, 28 Jul 2021 10:27:48 +0000 Message-ID: <20210728102758.3269446-2-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: a5a95fab-0673-4843-21b4-08d951b27b0d X-MS-TrafficTypeDiagnostic: AM6PR08MB4231:|VI1PR0801MB2078: 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: 50P1UrHuS14tDk4UIoBjbptLM5+wdyd3pVd0wbanx6cdMSnUbSd4KemLNH0go7i131U5acFwDFFWoEMiDM4BRAfHOuUMLnRciEG9kJKt+yoi2Q9koks/ynsz7H5sHLWMS1UZ46MHMcQsa1f8HwaTxmgDLjTUAeMyJAxoA+rnFI+7skLpbr0tJYXkh+McXOLIb9hvsDCQdh5oBRwS/SFVA6arnA5NiPvRI5XIM8rysojmQRkWTZjdoInqogSO8ppcknnIYj7UFa7Z/ejilxW13JBSMoc1QtiNcfJmE5N6w9T0fYl9iZgwwDo3MxfF8exIJhLQ0trHqZd3Nqy4iybkftGe1BFgZOKhlTSX9KOo1rT3PIbufEQCtRMLu1ePZFqOwZqzncXsjDpW2P9aWrVMBcoF0o7YrMU4Bq4LQH2U9YU4nyMu9M+IaD8tmMU/eapzcUaij+s126zC5ofep6Fs9021m40D28KSIF2mC0iICf3S2pKaAGv9QwfPWdJaZCGQUS07ipqv6ANMOsdhR6sLMztIAaTOrmELt44IIbHBg5kOeJ4K+FKFw9G8ltV7H3IvVEjbuSSaTUjOvPZHXNGkaxyxFxy89ych3PrmSQj7ZpH2wAoHtL3zR1d/LEdX9IluoaPmMNsBl+7+JrFKdYFYRRqrqt6SX5TdVyxW6DHit8ce6lTBuFwGkMB40jQm0x3BtVRXIArVQ4qHBTnKLZ8KW1NYpvlk6NgKWQt2W8NN98g= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(396003)(346002)(376002)(39850400004)(136003)(36840700001)(46966006)(478600001)(4326008)(8676002)(8936002)(54906003)(356005)(82740400003)(81166007)(44832011)(47076005)(426003)(1076003)(26005)(336012)(2906002)(316002)(70586007)(70206006)(2616005)(86362001)(82310400003)(36756003)(186003)(7696005)(110136005)(83380400001)(36860700001)(6666004)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4231 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: c86e4c30-d395-47a6-9915-08d951b27008 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GEMhiwZ8/cuiRpWH0Yq20IHSH2bL8gh1Cust1bKxzjzjkgiiv12pUetlTSY0ACjyOZ/rqKswclwOfPyG4hePnyavBKBF91C7SIaYdxypv3V2KNzp1gtWo9nGHXtkxg62wjQgWtRl6gjyWNRveMF4eWkVNOlxFuuwqCszEHCmoonXQqpLpj+ZxDHnUycX53EliELRIUf+RbiToARhGgNxv1Nrq4uVtPH+sQPT/oRCJVq1JvAhJ+CYWZfc8ug3DohUQQ7tQqXgtnLc1JASZw6AJMFgeoiQAy3aGmyy4iL/y8dJsIgyHT90bGdh6dDJVnHNTrGUyHCXFBTU0rVvEVyOXbClyBIQNprDVxT6Wnvfbn1ZtnJyOUstWm/mT4yUU9j+kT9a2yrgEQiAzyR8lPBwBEcrM22IDyXI7Ag1b6A7FTCYoxQH7v+68Jb/hrSrUqTLRTzBq2hBQwf4qizX3nrA2OF1Fz5Sr9mZ7BwmYJk/vHxWjYxAfsoTkFlW7pIjI/SnAEayhThxO2Yf3ZXi2CFEC/6aQBZ3DEi2C6XmYJWVWcL3GU3nt9RX9hgUGraL/ZvJb9dNgFgz3oNkkUOfz4wsSuk4Cq4FSugn3liKwzjD820jAjg0EByYM3uuRPN4Qeqjqj9axDeJtdih2qssHJnUz0ZCOHBn0rFgzUr63Mzilt8AlltJriitw9qJ0+JgGngWVJc/TMbur6irudTQLd26wg== 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)(136003)(396003)(346002)(39850400004)(46966006)(36840700001)(82740400003)(70586007)(83380400001)(70206006)(82310400003)(186003)(7696005)(110136005)(86362001)(54906003)(426003)(2616005)(26005)(44832011)(5660300002)(316002)(8676002)(8936002)(336012)(2906002)(81166007)(4326008)(6666004)(36860700001)(47076005)(1076003)(478600001)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:28:46.0042 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5a95fab-0673-4843-21b4-08d951b27b0d 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: DB5EUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2078 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468153529100001 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. Domains on Static Allocation is supported through device tree property `xen,static-mem` specifying reserved RAM banks as this domain's guest RAM. By default, they shall be mapped to the fixed guest RAM address `GUEST_RAM0_BASE`, `GUEST_RAM1_BASE`. This patch introduces this new `xen,static-mem` feature, and also documents and parses this new attribute at boot time and stores related info in static_mem for later initialization. Signed-off-by: Penny Zheng --- docs/misc/arm/device-tree/booting.txt | 40 +++++++++++++++++++++ xen/arch/arm/bootfdt.c | 51 +++++++++++++++++++++++++++ xen/include/asm-arm/setup.h | 2 ++ 3 files changed, 93 insertions(+) diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-t= ree/booting.txt index 5243bc7fd3..2a1ddca29b 100644 --- a/docs/misc/arm/device-tree/booting.txt +++ b/docs/misc/arm/device-tree/booting.txt @@ -268,3 +268,43 @@ 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. +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. + +Domains on Static Allocation is supported through static memory property, +defined under according /domUx in the name of "xen,static-mem", which are +specifying physical RAM as this domain's guest RAM. +The size of address-cells/size-cells must be defined in +"#xen,static-mem-address-cells" and "#xen,static-mem-size-cells". + +On memory allocation, these pre-defined static memory ranges shall be +firstly mapped to the fixed guest bank "GUEST_RAM0". Until it exhausts the +`GUEST_RAM0_SIZE`, then it will seek to `GUEST_RAM1_BASE`, and so on. +`GUEST_RAM0` may take up several pre-defined physical RAM regions. + +The dtb property should look like as follows: + + / { + chosen { + domU1 { + compatible =3D "xen,domain"; + #address-cells =3D <0x2>; + #size-cells =3D <0x2>; + cpus =3D <2>; + #xen,static-mem-address-cells =3D <0x1>; + #xen,static-mem-size-cells =3D <0x1>; + xen,static-mem =3D <0x30000000 0x20000000>; + ... + }; + }; + }; + +DomU1 will have a static memory of 512MB reserved from the physical address +0x30000000 to 0x50000000. diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 476e32e0f5..d2714446e1 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -193,6 +193,55 @@ static int __init process_reserved_memory_node(const v= oid *fdt, int node, return 0; } =20 +static int __init process_static_memory(const void *fdt, int node, void *d= ata) +{ + int i =3D 0, banks; + const __be32 *cell; + paddr_t start, size; + u32 address_cells, size_cells, reg_cells; + struct meminfo *mem =3D data; + const struct fdt_property *prop; + + + 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); + if ( (address_cells =3D=3D 0) || (size_cells =3D=3D 0) ) + { + printk("Missing \"#xen,static-mem-address-cell\" or " + "\"#xen,static-mem-address-cell\".\n"); + return -EINVAL; + } + reg_cells =3D address_cells + size_cells; + + prop =3D fdt_get_property(fdt, node, "xen,static-mem", NULL); + /* + * Static memory shall belong to a specific domain, that is, + * its node `domUx` has compatible string "xen,domain". + */ + if ( fdt_node_check_compatible(fdt, node, "xen,domain") !=3D 0 ) + { + printk("xen,static-mem property can only be located under /domUx n= ode.\n"); + return -EINVAL; + } + + cell =3D (const __be32 *)prop->data; + banks =3D fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); + + for ( ; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ ) + { + device_tree_get_reg(&cell, address_cells, size_cells, &start, &siz= e); + 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; +} + static int __init process_reserved_memory(const void *fdt, int node, const char *name, int depth, u32 address_cells, u32 size_cell= s) @@ -346,6 +395,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 && fdt_get_property(fdt, node, "xen,static-me= m", NULL) ) + process_static_memory(fdt, node, &bootinfo.static_mem); =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..e076329fc4 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -74,6 +74,8 @@ struct bootinfo { #ifdef CONFIG_ACPI struct meminfo acpi; #endif + /* Static Memory */ + struct meminfo static_mem; }; =20 extern struct bootinfo bootinfo; --=20 2.25.1 From nobody Thu May 2 19:42:08 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=1627468149; cv=pass; d=zohomail.com; s=zohoarc; b=hDuyJwnfw38VvwubIGfnc00aG62QJhY8Qk+N8aZf/ZnFWTYFfwoODW2xeqKc7FFhsJMpBZxag0DDZtnjscSSrnVQ2vtmiRmOrZdxcmFDrHUHnb1Vx6VPHg+6NiN9CZn5fzvZOaNsSFJDED9nfMEReh1EL2avkmbTgGDE3WVwkG4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468149; 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=pqU3vVGiI7GLhNQwwAeYPut2BD+FA6nGju3mVA8aiz8=; b=kBQ+xoDfrD8OYHSbY5H5QsQ18/0/FyTCB7wGhour1Uc9hK+YUOa1+iVYlNdlPvm6lc4OuqWonAUKEYDejSNRmor5vq8pAYQ3OyFsvKgBn2mJfvK1SKXCsW/8My8LSVEdDkoaQpTthHIvL2XsPEAScxypxJwfT/DIFYtJt+vu4p4= 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 1627468149590438.9468173158074; Wed, 28 Jul 2021 03:29:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161422.296389 (Exim 4.92) (envelope-from ) id 1m8gnv-0004H6-O7; Wed, 28 Jul 2021 10:28:47 +0000 Received: by outflank-mailman (output) from mailman id 161422.296389; Wed, 28 Jul 2021 10:28:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8gnv-0004Gx-L1; Wed, 28 Jul 2021 10:28:47 +0000 Received: by outflank-mailman (input) for mailman id 161422; Wed, 28 Jul 2021 10:28:46 +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 1m8gnu-0004GY-Hb for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:28:46 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (unknown [40.107.3.71]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9578ea33-ef8e-11eb-9786-12813bfff9fa; Wed, 28 Jul 2021 10:28:44 +0000 (UTC) Received: from AM6P193CA0077.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::18) by AM8PR08MB5571.eurprd08.prod.outlook.com (2603:10a6:20b:1d0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Wed, 28 Jul 2021 10:28:42 +0000 Received: from AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::f2) by AM6P193CA0077.outlook.office365.com (2603:10a6:209:88::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.19 via Frontend Transport; Wed, 28 Jul 2021 10:28:42 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT018.mail.protection.outlook.com (10.152.16.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:42 +0000 Received: ("Tessian outbound 1942ea606101:v100"); Wed, 28 Jul 2021 10:28:41 +0000 Received: from 96c23839c747.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 46857A04-0CDF-463C-9AFF-8E782B3B840F.1; Wed, 28 Jul 2021 10:28:34 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 96c23839c747.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:28:34 +0000 Received: from AS8P189CA0029.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:31f::15) by AM8PR08MB6628.eurprd08.prod.outlook.com (2603:10a6:20b:362::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.30; Wed, 28 Jul 2021 10:28:31 +0000 Received: from VE1EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31f:cafe::6d) by AS8P189CA0029.outlook.office365.com (2603:10a6:20b:31f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:31 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT018.mail.protection.outlook.com (10.152.18.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:31 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:27 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:27 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28:24 +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: 9578ea33-ef8e-11eb-9786-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=pqU3vVGiI7GLhNQwwAeYPut2BD+FA6nGju3mVA8aiz8=; b=v/8y4t/bifSMKGTTPX3Xy/F/Z/TG7fJwPgd0akk/ZqjY5u06yso8na+gjYQTWp7RY3qeuqLmUzXpwDBUDJQpp28LVXeGRHT72kvdQWcFmZ7WZzpSIjXIfSHRDcg1qfNRH2DQ1+jY63CVi+5n5tXzJaZTbbEbBP/AqicoMx4CVh0= 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: 8ba852145f384422 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c0NYC0C9feuFkWCcfk/PWM2fbFff2FkcNRoiqveR07oXIur81EcdthT1C7FGNSBgMtPJWtkOMhHf7dy/T/mc9X7aW51J5y0C6luSfLbuM8/vWzob3LPLdR91hCQLVvAYX7jAkf9aRHL7d25hyQw2jxhsj/pqDgP5cY4glCvZ7cr5Tgvw6HlScXSZN9+zi2Fr+grm1A57TO+jlhAhJ0222w4zKe5H5V4A9uhUlxF6hC4cjkKdYn/r0egWrUDD5wjj1k0tG9HXnWimWFj/KkvuxtmFMc8BK1GqlaQ/tmtTylFs9AQx/QwC/CHG2eM9aphJzpxP6TfCF5jFHuOUun7YPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pqU3vVGiI7GLhNQwwAeYPut2BD+FA6nGju3mVA8aiz8=; b=FTidgiYjj/A9EQwfUT123JPTUVylAZv2dhjVnOmZMtkdvl2K5wiEQ9X1aWGR9mIV7oZUwSBcSc+rHV3CqeLEjJ9BwFKmU39vOI06KNFaKMGYDfH9akNS5N8s2Sz0Ya2BR+YejLrAJVRl745fjl+6DIZTLUOt+AHEVwQeDn0kE0wiHJ3OPHz8T4OECUe4vWfBHg10rCmqnorQl6r5lUQwVb+Kf1lEeJv4qyb8AKiMT+WWvkg12U4uEZspnhXd42XOIKgMbv3SjCls7630zsyRJYf70zI+j1Pzjt/fiPwtRJ5t+FreV9AiW2G8NfM7UBtOF4AvvUC//ojcCdaHe8XIfQ== 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=pqU3vVGiI7GLhNQwwAeYPut2BD+FA6nGju3mVA8aiz8=; b=v/8y4t/bifSMKGTTPX3Xy/F/Z/TG7fJwPgd0akk/ZqjY5u06yso8na+gjYQTWp7RY3qeuqLmUzXpwDBUDJQpp28LVXeGRHT72kvdQWcFmZ7WZzpSIjXIfSHRDcg1qfNRH2DQ1+jY63CVi+5n5tXzJaZTbbEbBP/AqicoMx4CVh0= 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 V4 02/10] xen/arm: introduce new helper device_tree_get_meminfo Date: Wed, 28 Jul 2021 10:27:49 +0000 Message-ID: <20210728102758.3269446-3-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: bd0dbc63-ae5b-42ae-d62c-08d951b278cc X-MS-TrafficTypeDiagnostic: AM8PR08MB6628:|AM8PR08MB5571: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:580;OLM:580; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: OZ9pX8zVLpZSiR/+hh4mwmZ6ZTKhOuW4umm3CNkEPEIuTaD05vhQVlplz2lAA5NdlAHXKR/KitOc7m52KOEEyMARWWx1fY52DMMHS4kSAZlYGHpWQqfBciTF6eNz3nlzeY8/BYrKs1RN7aAMdVSGccgL0+1+7sP8qbnTIR8IoE7wDwpdxBZLhpIo+o/U4DYUOmDpZkodUpGFI7lordYlpFMQVN79U/4zORzKAnAC4+VjSEXXpCkGi1ak6VBhqidIeeTstdhJXK1g+TQ7LT5RwlnbcJjaKr7gaO8JfwZyurfef0OPdyF24RHhda5inDnJwLpIzleVteF6LO7g+exUQ4lAXcVq0HhlaVg1ybUwRHZdtPZTwiq7xCyzRg6lYojjyW/LHhPGRxN99x/mIo3riDQEqB422/nJ+HA7eSFnaL+PuXzgoaAx3qxt6anqijLL7JTzhOpnLI8dM/QWaAXYsa99UbRJ2hnsZ3/3OJ61qQ0mCX5AE3bstCdaDgCmjuEJZJuBES9SxWIf4bJmdnqM4EO+6xgKg0cXW3i01p1nk9oid5p2qaWgFF05p9Ud2seRWIPf+UZagZhEqpiQ44OQvPevPHUbiTtF/VbB468DAL3JyV4uk6MBdjvb7N9vOFqv/hRuCErSOFr0xFAh6R0VnPaf7CgQzBerzGvKkcAHwSDSuEpC8/BV+mMW3EUFOUE0UXawrUBlUznyqZFvWLgJNrFyTi76Mdbg+5UvRy7DawM= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(376002)(346002)(136003)(396003)(39850400004)(46966006)(36840700001)(82740400003)(7696005)(36860700001)(81166007)(54906003)(8676002)(336012)(2906002)(44832011)(110136005)(8936002)(6666004)(36756003)(83380400001)(186003)(1076003)(70206006)(356005)(70586007)(5660300002)(2616005)(478600001)(426003)(4326008)(82310400003)(47076005)(86362001)(26005)(316002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6628 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 27162d95-eb81-4835-f551-08d951b27276 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 40S0TjdiQ783TqZABys18xPHhdfQY1D0WT9/LpQMoaMPK+zCJG2AKUEaxB1eT9+gZwQWFG/K7tcNbzHlsPgBYxW/4sdAnVZuoJNLEBPnIwtoqvGnb+7GbUXvnzi6+HWQWBohMsbo6zdCy4SwhFOZiKbWP8b/svfR+WntrMVbX0cAxfETxUHDEG7sQthf9DWdCAsXXjylO41EddfnNDLO4lg/FXB0fnWORlmLAeSWFnaKjXsdFPjM5Ta1XurntAIKON1Xr1CS79JXyE3dbiH6F++xfskNWMtaWr+Dyt4vmCHZTWFSz68yK23PJZa1j67HhudJChDnIy6JimmfmSf6P14wQ9kKYfEJ98/Pw7Af34iRdhvACqN7oDSri2h9TDXpJpZ1LZklSb78sMLhKM1xLvGpyB8XCpVVl6b1KbKQ/ywGG7lP9iWxxiVFo3bz3H1D5Cu5dTk6SWE71B/IGYhe7ILy1aLZwBzVqmjCjHezlAScL0chG4U7NbxpGOSbO8LX8Lp7uJZCrno74uy/4FcIEe/vPT3GLp2hqMmO1WFSDtfRKX5Wi/r60saeC6EmAWXhNEjTiJ44HQHvbnu6OdndIglprSnyOmuxZyDHcMx8tb7F3xmlbz5UerzfDlGRDG60++tejulC+kqCBPQmFGj9UFMNxlG89fzor3fjhJlDET25CBG1kFqBpU6b7HiX/P1C/AcoQD8nZrlY4wMHgJHhCQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(39850400004)(346002)(396003)(136003)(376002)(36840700001)(46966006)(6666004)(82740400003)(54906003)(110136005)(426003)(36756003)(70206006)(44832011)(5660300002)(4326008)(83380400001)(336012)(86362001)(2616005)(81166007)(186003)(7696005)(1076003)(70586007)(8936002)(316002)(82310400003)(2906002)(8676002)(36860700001)(26005)(478600001)(47076005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:28:42.1775 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd0dbc63-ae5b-42ae-d62c-08d951b278cc 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: AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5571 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468151213100006 Content-Type: text/plain; charset="utf-8" A few functions iterate over the device tree property to get memory info, like "reg" or "xen,static-mem", so this commit creates a new helper device_tree_get_meminfo to extract the common codes. Signed-off-by: Penny Zheng --- xen/arch/arm/bootfdt.c | 104 +++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 62 deletions(-) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index d2714446e1..04210684c9 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -63,6 +63,44 @@ 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; + + 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,14 +177,6 @@ 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", @@ -154,27 +184,7 @@ static int __init process_memory_node(const void *fdt,= int node, return -EINVAL; } =20 - 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, @@ -195,13 +205,7 @@ static int __init process_reserved_memory_node(const v= oid *fdt, int node, =20 static int __init process_static_memory(const void *fdt, int node, void *d= ata) { - int i =3D 0, banks; - const __be32 *cell; - paddr_t start, size; - u32 address_cells, size_cells, reg_cells; - struct meminfo *mem =3D data; - const struct fdt_property *prop; - + u32 address_cells, size_cells; =20 address_cells =3D device_tree_get_u32(fdt, node, "#xen,static-mem-address-cells", 0= ); @@ -213,33 +217,9 @@ static int __init process_static_memory(const void *fd= t, int node, void *data) "\"#xen,static-mem-address-cell\".\n"); return -EINVAL; } - reg_cells =3D address_cells + size_cells; - - prop =3D fdt_get_property(fdt, node, "xen,static-mem", NULL); - /* - * Static memory shall belong to a specific domain, that is, - * its node `domUx` has compatible string "xen,domain". - */ - if ( fdt_node_check_compatible(fdt, node, "xen,domain") !=3D 0 ) - { - printk("xen,static-mem property can only be located under /domUx n= ode.\n"); - return -EINVAL; - } - - cell =3D (const __be32 *)prop->data; - banks =3D fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32)); - - for ( ; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ ) - { - device_tree_get_reg(&cell, address_cells, size_cells, &start, &siz= e); - mem->bank[mem->nr_banks].start =3D start; - mem->bank[mem->nr_banks].size =3D size; - mem->nr_banks++; - } =20 - if ( i < banks ) - return -ENOSPC; - return 0; + return device_tree_get_meminfo(fdt, node, "xen,static-mem", address_ce= lls, + size_cells, data); } =20 static int __init process_reserved_memory(const void *fdt, int node, --=20 2.25.1 From nobody Thu May 2 19:42:08 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=1627468144; cv=pass; d=zohomail.com; s=zohoarc; b=OCQQ0RtLC7Pfywf0/929ip6MHrcgnTc9D6uqv4ukawyVC9iDSN2d6m+E9ND+/KCWOJZ02qFBae5NtsAXz5L2MU2sNbAsL5ZH7fIX67JjINIx4t6UPqIhUyH5RvTXvo3qBSdeHEA4E9K/R19xm9GY1icar7wVJBZxfQubQrovUqk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468144; 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=ckLezNToPFFF/X08RBBj0Q+V9x7GEG2pfO9+DHh3puY=; b=H4nfFP5g8sb2+U3JbzB2mB1Wvn8xMReGrXvSNdenH0lQsqK7w7w7BvN78sIITqroQHmQI9io5lXezwnR+C/W1ZHJAuTsfvqy28bnZwRNnnJoX4OGCn+hXjmEOccBTGm295FZdgaG9fpVkbBEzOfu97hL6SqH62v4JsiSKyh0624= 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 1627468144835908.1693316257669; Wed, 28 Jul 2021 03:29:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161423.296402 (Exim 4.92) (envelope-from ) id 1m8gny-0004ZS-6P; Wed, 28 Jul 2021 10:28:50 +0000 Received: by outflank-mailman (output) from mailman id 161423.296402; Wed, 28 Jul 2021 10:28:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8gny-0004ZH-37; Wed, 28 Jul 2021 10:28:50 +0000 Received: by outflank-mailman (input) for mailman id 161423; Wed, 28 Jul 2021 10:28:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8gnw-00040B-IT for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:28:48 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (unknown [40.107.15.59]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id abc0f5d9-05a3-4f5c-a98b-6c49918dfb7c; Wed, 28 Jul 2021 10:28:46 +0000 (UTC) Received: from AM6PR0502CA0066.eurprd05.prod.outlook.com (2603:10a6:20b:56::43) by VE1PR08MB5213.eurprd08.prod.outlook.com (2603:10a6:803:10d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.31; Wed, 28 Jul 2021 10:28:43 +0000 Received: from AM5EUR03FT013.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:56:cafe::43) by AM6PR0502CA0066.outlook.office365.com (2603:10a6:20b:56::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:43 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT013.mail.protection.outlook.com (10.152.16.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:43 +0000 Received: ("Tessian outbound 5f693336bfca:v100"); Wed, 28 Jul 2021 10:28:43 +0000 Received: from 84c1a0941bfd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3284B5BD-9FC9-4E3E-9E3A-AEB518B68198.1; Wed, 28 Jul 2021 10:28:34 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 84c1a0941bfd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:28:34 +0000 Received: from AM6P194CA0020.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::33) by AM9PR08MB6769.eurprd08.prod.outlook.com (2603:10a6:20b:2fd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Wed, 28 Jul 2021 10:28:33 +0000 Received: from VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::16) by AM6P194CA0020.outlook.office365.com (2603:10a6:209:90::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:33 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT055.mail.protection.outlook.com (10.152.19.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:33 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:29 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28:27 +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: abc0f5d9-05a3-4f5c-a98b-6c49918dfb7c 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=ckLezNToPFFF/X08RBBj0Q+V9x7GEG2pfO9+DHh3puY=; b=f/P5Y/wSdpBR5rkK1QGMMf7HeRcTeEx6cnbIYqrFw42EuwGvke2JMuNIHYLOzCAHqzcjTEEGEQufNtc4XVq4MuCJFVezjroMgik0YU5eem27eN2v3bRhXIei2wUSvJTleqXh3F2ZuIzi26BNJ5pQgDkhi8XE0wDIoDkDht+ThNo= 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: 4e3fb8d2def9c618 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hp1U1SOPp4BNb7yR4ExYxZvZyKhfkEBp2R/jVYTqXLryvZBCn+T6MWrX9VpU2LR4ouWzBxAVyeuzJm1LXGIKH9S3LmzujssyA1JdGGOuagfz1Bs7zLxY3IFoOUUekoYnp8pI0XNOe6OOiSFHlSpc3dlqk7hHD7AqJGtsVmhsaejFw0VzoPqaqMzpGNH8CkWJmFckdKc/NYe5oshgQFxl//Wui1eI+dTDoEh2RLbjZT1wt3RUGo6ZwFmlYQivH2o3K6hUSd/Dzuj7hP5C7GCRv9IRNS6X935wXb15NiJYJyClpxgqPpaZLq/+itSFFkdFB5c9JTnxb1RwsGmdvhkT1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ckLezNToPFFF/X08RBBj0Q+V9x7GEG2pfO9+DHh3puY=; b=ne9Oh78pwtdVmSLofORQJl9GqYsFfUwwb+XMMr12d/3Ae8Ix7OCCBMtZgZLIX//ROjdveHvTyVIeWVBXJvOYP5NQgwHc+6bVMaiogr+pEoBTjfT1zMbKGWXI9q4aY9RJ4xVIpPU4p5HRRmqEa96ve8RQ7Y0x56WibDvCN4zDbaX2QbfIthK8meXBH1KFsT0djNKDr+toCMEI+US7CyiQbHtrs1HOhCPLfb6Wf2vcLgdN7rZHMCEleEOanG1wEWF4iYwbn3f05xFl2NVrQGiVYu7LTrG4iFQod+AaHH8M665TPgosRUHwIjFN4TfTphN5FX+Ih5kaCItFJHKBtodWFw== 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=ckLezNToPFFF/X08RBBj0Q+V9x7GEG2pfO9+DHh3puY=; b=f/P5Y/wSdpBR5rkK1QGMMf7HeRcTeEx6cnbIYqrFw42EuwGvke2JMuNIHYLOzCAHqzcjTEEGEQufNtc4XVq4MuCJFVezjroMgik0YU5eem27eN2v3bRhXIei2wUSvJTleqXh3F2ZuIzi26BNJ5pQgDkhi8XE0wDIoDkDht+ThNo= 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 V4 03/10] xen/arm: handle static memory in dt_unreserved_regions Date: Wed, 28 Jul 2021 10:27:50 +0000 Message-ID: <20210728102758.3269446-4-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: 452ae837-1d2f-4c92-da77-08d951b279b6 X-MS-TrafficTypeDiagnostic: AM9PR08MB6769:|VE1PR08MB5213: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1265;OLM:1265; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: FPD3me3Jq5b0hCuDsyRc9oG+eyFtm6Vmp5vy+WfckePMohCcwCTzYgU9wIavR1Q9JL762UCbJ/WQx1QgH8GmP2WUgD8GYx85TJXi2hx43d2aR8IeP6Jj9mH4pcpuir3DvdlfPikY2eXu547Pk+8A556eFIMQFL1mgHyTlZ3LcWn0oPOvHlcU1jyapMihZV0Y89OdB9qbW/Q6Fkym5uoXRkYtiUgVtXkUrG8fa/SrwkfSYMUq8nyI7SreRY6/LN2n21ZKWciLjA/y9UmVetUSWDhDX6VEs82aj+5hObhutXTT82U2gAh5ok6+TRAOW8IJnSBjKCDL3La4ar75YqfFVsRgWBamjZRApuzDtrwPhdeEO4xyhN9U4e8BEB2V3Kj6hm9Uoki3byRaeq5vcDPxSRmtfD0O5mTxYU5asugLEcLwmx8nMkUt0JGXBj73qt2xTMOht1Jy632LZ2Lnz2yJfjOW498EiuwmVw1TOy7xrIytPMXL9lRSJw0cXM6AM69vdbAXUtw8fGS5tbu0fgWvEKBCprw+2yARN2+YvgBHtz7L3F+PpV+CGXMzP0Fa/tVq7mzJLBtbndyfaWenZbi2NAkU97qJsGnI2aLLD7FqZjELufIC/Sh+WEZPaLvC5LIZpX49KP8PoA4qX+R5wUU2ieNG6DKuw4jnCtSnhgqRnk/wehmjMWIb9RuAtvZc8h+bQoQ/N6HKhB+4fZZfQybF/umEWfz90myN4bU6OqSZz9A= 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)(36756003)(83380400001)(26005)(508600001)(7696005)(336012)(356005)(70586007)(54906003)(36860700001)(426003)(186003)(5660300002)(70206006)(2616005)(44832011)(110136005)(4326008)(47076005)(316002)(86362001)(2906002)(1076003)(8676002)(8936002)(82310400003)(6666004)(81166007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6769 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: bbb6e91e-29d4-4524-f2e2-08d951b27374 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xOdPAkG45Ild5qv3eQZR06/pPefZKTSxxIpPOpqp9ZYvvavjLgZW15lPEIWzsxNA65mTczKJbtmFMUUA8rjIhUQKwPcXKMv1zASbrGuwF2gjpVA7khKdasC9749iiDi+hKN/N9WlAAirXsFxm+O6hg9LgQORFqWaJHCzvVAtuu4OctoW3/mNbQiYB3yxo4Qd9vVRGp2QJy/fdME2PhN6sB/ElFQfVqouQsSsyyttxd0lh5sRyj6u0ppeWZmLrOoJO21a4Gsuxba8vJziiOgGgqA1Ehf96LF5BhC7O6sPCLtjnjoAIwh1v29WQYuywpuhbL9Gg/g/Qj+HJCvwDVb0pdV+aVR4/8TcIWm9ZOdoQICGqbdk2JpFzxykiFkn+Ww9pVbqcMMfkpfG0URrHbVRe2Sz7SLYpaYwvpEHHnkLUHuhun1iESoVmQcey5l7PdisDcq/r4R2j1Es2Yf2v9ycGsFdZcDNDCMOiFlb2VXbpqvUxql1zLMkGxBU6GTbuLgfi+0LR6oerVFRtQKOTUQy5C3Gx1uV58rDvU0jLGF6fB/eFT/YRYWvgr2dXevbmfbxdrE0tEiD22oOAyb53SMMaLjT/b4R5I8K1GdUlQ0PP7Grm6+iG0SHqYtUp8FkfKszucI9cXMUkXLl3eBVp8adZe/ZYSwbPy1gYy0EeZALCnqrgG+zXYii/56MfT7LUCLj3/OugNMtmWPmbm/mbNap8Q== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(376002)(396003)(39850400004)(346002)(136003)(46966006)(36840700001)(81166007)(110136005)(70206006)(70586007)(186003)(82740400003)(336012)(316002)(82310400003)(83380400001)(54906003)(7696005)(478600001)(426003)(1076003)(47076005)(8936002)(36860700001)(6666004)(26005)(86362001)(2616005)(5660300002)(36756003)(4326008)(2906002)(8676002)(44832011);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:28:43.7121 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 452ae837-1d2f-4c92-da77-08d951b279b6 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: AM5EUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5213 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468147803100001 Content-Type: text/plain; charset="utf-8" static memory regions overlap with memory nodes. The overlapping memory is reserved-memory and should be handled accordingly: dt_unreserved_regions should skip these regions the same way they are already skipping mem-reserved regions. Signed-off-by: Penny Zheng --- xen/arch/arm/setup.c | 47 ++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 63a908e325..f569134317 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -200,6 +200,13 @@ static void __init dt_unreserved_regions(paddr_t s, pa= ddr_t e, int first) { int i, nr =3D fdt_num_mem_rsv(device_tree_flattened); + /* + * There are two types of reserved memory stored in bootinfo, one defi= nes + * in /reserved-memory node, the other refers to domain on static allo= cation + * through "xen,static-mem" property. + */ + int nr_rsv_type =3D 2, t =3D 0, prev_nr; + struct meminfo *rsv_type[2] =3D {&bootinfo.reserved_mem, &bootinfo.sta= tic_mem}; =20 for ( i =3D first; i < nr ; i++ ) { @@ -219,26 +226,32 @@ static void __init dt_unreserved_regions(paddr_t s, p= addr_t e, } } =20 - /* - * i is the current bootmodule we are evaluating across all possible - * kinds. - * - * When retrieving the corresponding reserved-memory addresses - * below, we need to index the bootinfo.reserved_mem bank starting - * from 0, and only counting the reserved-memory modules. Hence, - * we need to use i - nr. - */ - for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) + prev_nr =3D nr; + while ( t < nr_rsv_type ) { - paddr_t r_s =3D bootinfo.reserved_mem.bank[i - nr].start; - paddr_t r_e =3D r_s + bootinfo.reserved_mem.bank[i - nr].size; - - if ( s < r_e && r_s < e ) + /* + * i is the current bootmodule we are evaluating across all possib= le + * kinds. + * + * When retrieving the corresponding reserved-memory addresses + * below, we need to index the reserved mem bank starting + * from 0, and only counting the reserved-memory modules. Hence, + * we need to use i - prev_nr. + */ + i =3D i - prev_nr; + for ( ; i < rsv_type[t]->nr_banks; i++ ) { - dt_unreserved_regions(r_e, e, cb, i + 1); - dt_unreserved_regions(s, r_s, cb, i + 1); - return; + paddr_t r_s =3D rsv_type[t]->bank[i].start; + paddr_t r_e =3D r_s + rsv_type[t]->bank[i].size; + + if ( s < r_e && r_s < e ) + { + dt_unreserved_regions(r_e, e, cb, i + 1); + dt_unreserved_regions(s, r_s, cb, i + 1); + return; + } } + prev_nr =3D rsv_type[t++]->nr_banks; } =20 cb(s, e); --=20 2.25.1 From nobody Thu May 2 19:42:08 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=1627468595; cv=pass; d=zohomail.com; s=zohoarc; b=LaMPzjR+J0aiMktTM3IJvbcjpnBX40Tn15za0w1O3ErJ4dmME6gTX+CEM+6qEL1FIRi3n9yK/r6U8ljHG4ZxfbDcfyuanw8q0ZV3QKHjKrMQtENzfH3fBZgyq547NwXAxFDOwqHFGgEH6G5Bt6/HGOp3lX5P40JdaGwcQbMetMo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468595; 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=HF/qyGehAhKUdJPQWT1CPjsg2X/NGFj5Lk0x43C30TM=; b=NATMagvhbdhjzV0YoNmwBvauuvz8wZZyoood53xNKgjHI1ouKahljG+KqfI752/KIY+vsldAhghKll276/HVL5ws3MAQwvbHKwPlOQjDHYUqgEgdzFp/LQfQGIt2psSCsTWT7j51g6xToirAk/1G+clmACUKgrVIJjP3tkukCfc= 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 1627468595384699.0140276822609; Wed, 28 Jul 2021 03:36:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161489.296503 (Exim 4.92) (envelope-from ) id 1m8gvC-0002n2-8g; Wed, 28 Jul 2021 10:36:18 +0000 Received: by outflank-mailman (output) from mailman id 161489.296503; Wed, 28 Jul 2021 10:36:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8gvC-0002mp-45; Wed, 28 Jul 2021 10:36:18 +0000 Received: by outflank-mailman (input) for mailman id 161489; Wed, 28 Jul 2021 10:36:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8goz-00040B-Kj for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:29:53 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (unknown [40.107.4.89]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d07ba7fc-98c5-4ffb-8abb-c0bd5a418f9c; Wed, 28 Jul 2021 10:29:17 +0000 (UTC) Received: from DB6PR07CA0170.eurprd07.prod.outlook.com (2603:10a6:6:43::24) by VI1PR0802MB2239.eurprd08.prod.outlook.com (2603:10a6:800:a4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Wed, 28 Jul 2021 10:29:13 +0000 Received: from DB5EUR03FT030.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:43:cafe::f3) by DB6PR07CA0170.outlook.office365.com (2603:10a6:6:43::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.11 via Frontend Transport; Wed, 28 Jul 2021 10:29:13 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT030.mail.protection.outlook.com (10.152.20.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:29:13 +0000 Received: ("Tessian outbound 5f693336bfca:v100"); Wed, 28 Jul 2021 10:29:13 +0000 Received: from a755207bef08.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 81D406B7-94AE-4C7B-BBEC-DD5DBBE047D8.1; Wed, 28 Jul 2021 10:28:59 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a755207bef08.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:28:59 +0000 Received: from AM0PR01CA0167.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::36) by AM9PR08MB6225.eurprd08.prod.outlook.com (2603:10a6:20b:2de::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Wed, 28 Jul 2021 10:28:58 +0000 Received: from VE1EUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:aa:cafe::14) by AM0PR01CA0167.outlook.office365.com (2603:10a6:208:aa::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:58 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT021.mail.protection.outlook.com (10.152.18.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:58 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28: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.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28: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: d07ba7fc-98c5-4ffb-8abb-c0bd5a418f9c 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=HF/qyGehAhKUdJPQWT1CPjsg2X/NGFj5Lk0x43C30TM=; b=ZC1NG7cD/onzZyPeJXRA9C4OX7lvVdU3GFsB/s1ihM3v1WIAwgdR2qSp9Biis2lTIiD7YoxbbWqN98eg5qePZ9ZrW6G2c40e1RlSdSVyZUs65Vab3YjpOetMh4hfn5ISZXvPoIpiLUpS8pNPoOy7ES1lv/DVkcUisyVqFWISbQo= 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: 9ca811b0cc911400 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eHFcIAmYBxBGuikbwN2ZHEOhBGYnAy2Q4lq72bmKPmpIA/Q5ZG2fpcxK//YMInO6/5VTK3v6RUBv2JvxblyZto5rEsDMkSwfIVVozeL+hVWppHfzdOOLNuRlpTfsFZAbO4yOkTd0HgZaJdCYIjcrA+sWmGh9Lhf0cbiiMmNwsKeTmMwVb9/O0ncVJ3+qOVYtcIa+3sREHSKUldYvUf58Np/CyDgbm6nc3dqgKFAeMvUJL4OhTYK4umO0SdS6sF5u/fZjVhg/HuFUbrU7UCalW7aIovJrBQIXkBoKgb3lWFpmoAUVoY47qwLya13upDOY5sluCCK0fKcjTKu/5LWCqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HF/qyGehAhKUdJPQWT1CPjsg2X/NGFj5Lk0x43C30TM=; b=AmJilmMvAMT18MPxqNFTmAossKTkaCoK43Wg2IWDHDMPmSjlHU/LyrvY3snA4mSG5vClFXITufW2jAKTtY5DXKb1U7y2/IrJJxucjJLjl7ts56hmdFonpKu6ANm+IOuE9c864ffwikFyuf4oS39VRzRf4B7PHNyM0wO5hl1dQrULI4C+9UBdpheDU8hXBs93OKRTE9Nt4rbLQ1n3k2U3SOpd8GvAg/0d3PyQIAnnY+9mxcwJsg9RXzXlXgQlu8rQKeDAWY4a50WcQnBCSNbtnOgUN0lTwxjv0mDECITsVcJWS+OgxOC3zS2tfQdm4tOJ5WpNAaEiHGJlLLvDy3AGEw== 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=HF/qyGehAhKUdJPQWT1CPjsg2X/NGFj5Lk0x43C30TM=; b=ZC1NG7cD/onzZyPeJXRA9C4OX7lvVdU3GFsB/s1ihM3v1WIAwgdR2qSp9Biis2lTIiD7YoxbbWqN98eg5qePZ9ZrW6G2c40e1RlSdSVyZUs65Vab3YjpOetMh4hfn5ISZXvPoIpiLUpS8pNPoOy7ES1lv/DVkcUisyVqFWISbQo= 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 V4 04/10] xen: introduce mark_page_free Date: Wed, 28 Jul 2021 10:27:58 +0000 Message-ID: <20210728102758.3269446-12-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: 91950616-1321-4258-41c7-08d951b28b59 X-MS-TrafficTypeDiagnostic: AM9PR08MB6225:|VI1PR0802MB2239: 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: bVm9h5GgGH2Yji/QeBgZ0vwk0JhvGWM//Jv0Fm/9VsnMNxR6adC28fdEOrWE0oBrPJkH3obhI8sTF+9RLp5HzlmxUqHrmqgNE26PRAlH38j3acpBTat7Ywc40YCWzMKQ4Nr/LBm8lxHtThm/vROGFmrjWyOUA4SPCTpV31CUHCe3eL9LqU6vTZ00spJ5mF+XuhN9KV6sfbvvwWXt16PwUXGiCtXZWgn7lDfCHUS5xF9otldP18066QKn9gNy1SS1m8yH8uMxkYlLRIVRV7N3IBDi6QXyb7q2eFYaw9B4JEW6kNC7yXh/Ub1vw03kp5SjycDzv1OlaU4qGHlLm6XMaZXxAWFUnBLRj/mXKFzHhsabapI29AZByKBfNhXed3cS8+t0WuwqNxbiZW+HyThYNoriTqlZteB2Vqz/eVdhGr/f1o8EsScCGor1nPAx9ei5143LvF10ncy3flzVSQaF6B22YMdRhSsvJFn+xTHWM5ShiniW9e8rEp5BQTh6OWqsGDiq+ZJb9BKIB6B9LMMoAIG/U2iGwA6JX15Ndsh3YPIGaNXmCcLFGfq9A0EKpDk+BPpCcbJfAU3v6KAIw+CiUa9kbWxurHF5rSlnWRiQfX9QnkJ1/opmsGXbblyJXb0Y0+p5S/5hBwSayyVGARRCWT0IjaqYFWKHk/LoB1q4AgRPjpFUcDPnKOTz3qeYOe7/P+JC8lGI7h2IFNCuaH8t/95byrY3holw1nG1IKnG9PQ= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(376002)(346002)(39850400004)(136003)(396003)(46966006)(36840700001)(54906003)(316002)(70206006)(5660300002)(47076005)(7696005)(8936002)(478600001)(44832011)(6666004)(110136005)(356005)(26005)(186003)(83380400001)(70586007)(2906002)(82310400003)(86362001)(426003)(2616005)(1076003)(81166007)(4326008)(36860700001)(336012)(36756003)(82740400003)(8676002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6225 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: d9e5f88a-3d3d-40c0-4ead-08d951b28290 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CfkCNrm9jBeFzsAgZlmNFrc+BQRnZ69gfyjeXYTq636Qo0IzuP64n4h79o7i6mwCk6ihZmdW0dqR9r0df1JNw/jfaKBFBPwowyPmK7EWC0aWG3Wme4mMHuP4LjcAaPtv6AC7ZWvREej4QymiSw0d9TELXqRaNh25Gwv0r85D3o+KiMkn/8pCd8zEQGNo78LWULC2Pk6AX3GzS+4pCRE4PZo58vzMhCGewxdbzDgjJhA0ZjDz2xiTR7RsowMym2vqSI21svGItuoXE+EN3cvyLvxdt9fBJUwSJFaysKl5S3RTvz2t+/UEZu+iGiI8p6jByvNbLfcNLNnYdVKvUfhA1DQ3yuUrxjJQXHut5Zh4xU+mVhGfgY8qlx2vlO0MeUIwkZG9/HJkWB5EU1eUe+yMcKNR3hfjD089jI3EWDYgjmoD+dNap0g1l6KZZx2qaMy4w3U6rwYfYbu/PWSYHNdIkgwJAU8p7GUDepI5XaUvRHGc7GOJqSYHiXLKClPMDYQEafusk8QcORlPrJwhJRd/P40+GIFjQt7XEJJCZpxfbWxlNAJsP+W3dX7s+ExhXX0ylLQXu3cmymq4VAemvhbEBD94qvd1Zb9ftZ8KiOZU5ekCyHRrr0vp5rz/3hBI6OWeWwz+Lh8YkkNYJWmmb7IteUp0IblG5SF6lB435bbEKiO9URqkzgaD5Ues4rpfXju74YyQgBWLvboMlJuzC3ARiA== 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)(426003)(36756003)(2906002)(36860700001)(86362001)(186003)(82310400003)(81166007)(2616005)(1076003)(4326008)(26005)(7696005)(336012)(6666004)(44832011)(47076005)(83380400001)(8936002)(8676002)(110136005)(5660300002)(316002)(70586007)(508600001)(70206006)(54906003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:29:13.3486 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91950616-1321-4258-41c7-08d951b28b59 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: DB5EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2239 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468597136100001 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. Signed-off-by: Penny Zheng Acked-by: Jan Beulich --- 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 Thu May 2 19:42:08 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=1627468154; cv=pass; d=zohomail.com; s=zohoarc; b=IW+/ng3ycKvVoXsYojak04QK6UgQx05bwEhuq8gpMINo/hALQ9QPlMKf4xhQeLzCoWPmhIbevqlPnR/u2Zdptsee0w3uHrjcbKgpk6jTGeKyl1+v+SvaqtP7KEifG3t+s51eAIlysXvH2V29X73qCOKX86LFQI4/8VyGwz5A4MI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468154; 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=HF/qyGehAhKUdJPQWT1CPjsg2X/NGFj5Lk0x43C30TM=; b=Rdbvmns+tQ+smsSclbDUxK2nBUG2l3zVE+eleDR2z4PRwkIT5MyDzkm9GyC3zutjBBziN+0xT22+UxdgGR9zJXDpImnZjJq4LTDytonuBCTs0tmkhptD7laTdLp0gHFNYYhVEZXNQrhzWZmTWY3dKtTTO0F++w/8tp84saWeLnc= 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 1627468154071599.8191366217071; Wed, 28 Jul 2021 03:29:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161426.296438 (Exim 4.92) (envelope-from ) id 1m8go6-0005ae-BY; Wed, 28 Jul 2021 10:28:58 +0000 Received: by outflank-mailman (output) from mailman id 161426.296438; Wed, 28 Jul 2021 10:28:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8go6-0005aM-7y; Wed, 28 Jul 2021 10:28:58 +0000 Received: by outflank-mailman (input) for mailman id 161426; Wed, 28 Jul 2021 10:28:56 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8go4-0004GY-D6 for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:28:56 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (unknown [40.107.7.82]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 97bca0a4-ef8e-11eb-9786-12813bfff9fa; Wed, 28 Jul 2021 10:28:48 +0000 (UTC) Received: from AM7PR04CA0005.eurprd04.prod.outlook.com (2603:10a6:20b:110::15) by DB7PR08MB4619.eurprd08.prod.outlook.com (2603:10a6:10:7d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.28; Wed, 28 Jul 2021 10:28:46 +0000 Received: from AM5EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:110:cafe::28) by AM7PR04CA0005.outlook.office365.com (2603:10a6:20b:110::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17 via Frontend Transport; Wed, 28 Jul 2021 10:28:45 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT056.mail.protection.outlook.com (10.152.17.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:45 +0000 Received: ("Tessian outbound 69e1fde53269:v100"); Wed, 28 Jul 2021 10:28:44 +0000 Received: from 039df29cc42c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B89B1D88-8B61-4AC3-BA55-DD72599D427F.1; Wed, 28 Jul 2021 10:28:38 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 039df29cc42c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:28:38 +0000 Received: from AM6P194CA0025.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::38) by AM0PR08MB5106.eurprd08.prod.outlook.com (2603:10a6:208:160::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.31; Wed, 28 Jul 2021 10:28:36 +0000 Received: from VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::1f) by AM6P194CA0025.outlook.office365.com (2603:10a6:209:90::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:36 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT055.mail.protection.outlook.com (10.152.19.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:36 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:32 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28:30 +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: 97bca0a4-ef8e-11eb-9786-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=HF/qyGehAhKUdJPQWT1CPjsg2X/NGFj5Lk0x43C30TM=; b=cdPPUcV+1e8SXkIsZs1gg9C7NiEkbe9aVZY8iutpj+rMIt4VtYMaItEmsIo7HyoljpgVuOEa/pXxoHyrRrPDQGqv68uMv041RChQRUvN7oUHHXCd7bVmlXlfJsRTWazSP7sZAv7VA2+QTQS2UMjgJSZYISZ+AKO++IImP6j/Wiw= 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: bb1446495a968a1b X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U2IrLBCRJtYs2MOOM6mD3+8Eym8tzTSVtAYbT/RT/4tHrDxhKoGsV5D8vl07fe7UJRdHoY8AqseEMrouuW6giR+S70its4G+ComJPXWNN+wGNsiZjIpsLzmypXepftJlGZ9xzfe9/mw1lbD7QGb3YTTnXWsq5pY1Xlty/MioTu6BK8kSG/W0k3wKt7qsLN9gyYUoW/q2ECLRSel2zuxN0J/5ZM5usIjOp4WAdDRigmDidU2rNFbct/kp42KAesmB6OeQ0NP2w2unr89wjsBk6tlhhfxkDjkZtBzuKWDNojiztqDXQSLHWtGB8sua6FxYvWo9O0HaJCpOW2tjVecANQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HF/qyGehAhKUdJPQWT1CPjsg2X/NGFj5Lk0x43C30TM=; b=Df/IECZkkgsiOalG3lSABQTk3SKhBcw9GJ6AnxsmSSvftIg6Vg0UeE6zp+uBgNMqMjIthk9px3K1ozTMP6XEKVLjXJYDE0RKN4RuwPM1WQyWjbxAk9ogXY8n030FoE+8kOH6gnhT57334hajIOqEJPSj2fZQYCAWYXBOSP5u1G/SrL4Y9blPalrbAJ22N7qui3jf8LYRVBxml6sFWFPVmn1UWrK5ysM7Dm4ZIZFtwnGa0P2UDfbOnvfN1XmRzRNsTReZRthfvk6ShNW9aS3cJa4aUgKwp6MYPZsu0mW85ShfO4XvYb4z2gQRKd4xK/aaUQcbu7fg9OJu05gj/hKhOw== 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=HF/qyGehAhKUdJPQWT1CPjsg2X/NGFj5Lk0x43C30TM=; b=cdPPUcV+1e8SXkIsZs1gg9C7NiEkbe9aVZY8iutpj+rMIt4VtYMaItEmsIo7HyoljpgVuOEa/pXxoHyrRrPDQGqv68uMv041RChQRUvN7oUHHXCd7bVmlXlfJsRTWazSP7sZAv7VA2+QTQS2UMjgJSZYISZ+AKO++IImP6j/Wiw= 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 V4 04/10] xen: introduce mark_page_free Date: Wed, 28 Jul 2021 10:27:51 +0000 Message-ID: <20210728102758.3269446-5-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: 73fa1d9c-c6b5-4bc3-ccba-08d951b27ab6 X-MS-TrafficTypeDiagnostic: AM0PR08MB5106:|DB7PR08MB4619: 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: hoAf5LoGX1TrVUiv7AtQIpFQ3fMluhc4gwdTlADnvKOk4+IITz4jMJREhO5DzKhNeEQDiQy4tT7BmVWZxNZrN3BQ/Kq2kUfBgoGFnWRuS41WftR6rr+ngHEjTlR2U8EBXmZx/uDT6kt7QoETpo1C0pU+k/VuY18FRoHkjDPRUk5WshcBL9wZfQ8uai+OMzirmxmUroFoWwlBsl/tI16423KOivnMhjCxuLLXK164QW2TjfSKIPc9jasASnsldZi/bpKq+ubVsi8rWHhrWK/d0vkbouJlV9ktPSq2fFRv9j/puWTBiUA0PhonUJ6fL5HATUTvwKWkpfUaYkzwXy1gsIyqah7K5zNLEMjOwuOEiR4KhY52FcnJ/ZndhP6MBVhVpV4DRw/rhILq40xvwgS5/GjCYT9kHU3DZZ6fYqe0Eiv3vuD+hIblcjfktVVP7li8LN90dQxLkq+cM8rZUL0XEWCQkA+KGb3tBxLjTXrh4Ax+c8ofWPAXKgWP9xe9EZ5sC0EUClW0qy3JVd22aZrf12yK4S+GSNhNHrO66XqxC/JjsSW3JZAWJAjNBL0y7kiUaQX5coqSgWyuyztQiN/63W9UhuVUA5wJm0ynFRBoLzZohvMnI7IJdM0dPRoQToHNXPSGz3QmaFtR6ErvWsyL/QtVvIff48k96srBcIE/S6RO6yYoZwiMy40TAtAZI8nJmMdzqWcvBCBPQYDcuJYO3kEVcy1F+WHAZurnxqn41eQ= 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)(39850400004)(396003)(346002)(376002)(36840700001)(46966006)(186003)(36756003)(426003)(44832011)(5660300002)(47076005)(336012)(356005)(81166007)(70206006)(8676002)(86362001)(26005)(2616005)(82740400003)(36860700001)(2906002)(8936002)(6666004)(70586007)(478600001)(1076003)(4326008)(82310400003)(316002)(83380400001)(54906003)(110136005)(7696005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5106 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: dc91a438-3771-4822-d54f-08d951b2753a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E63TuJlGhhLEKfnysFnxKaHnXtvt1D8KchN/YiDaHyIBZPyT6IWKnWC0FIUFwXAavBeaX1aJ7uCncjz7Tl1Xqrw0cfZxsSdQZ/I1dAYXkmKxuFIgp+lrTTGKgP8oEU8DZhcr6QTY98ZC8uat5n9BATXZV99DZRydgN4ItW5oabAQ8q+Zwb9Fo/lqJ1ZzrjP55Z6mCx93mQQy4VUzXX86ump5mLOR8UnfjYLEB/p1XGBMHQ8GZV7F3V9q+JW+sSDgTKCVZtTkpAq702Yu/3YaPL1xgl9Byz+NxrlHagWTY6X91CAmtYZ1lcG40oLjAZMKhuM2zfGOfHBS6TVxATVHhcXCpFTaY25+JMPtxbtG6pCISVaVspXgUXpDL7lA/YmF9FXU0MODbenkSRDW8BfjyUbqPOwP0kk4QMWwlSxMH+Y6QXBEZ1Rfbyv/5+GR4KnsTTAFlfgrv2wUTurf3ES4GKZ4GTDgHvQTrGGy0Kd8gcWse5ZNX01LkPZPxjRYzzhRb7Z6t3a8EFnR8Ot4z3xMRlYbCJwSZipikirMDOSiTOAbPqvIpiRN9/+7ha3kPcWfJxJeURQ/G6PigkM/+JdbIHYKiLVHDFflU+AdolfxhdW5Xu+vtENnmDmVLm8Kx/6+AFIutXjS3UUMMAf0vAOjOzeLmb7JRlJTInm0fRUgqyISskYgIbCAJUrMD9EQjxxGbHN0t4dwVA+DxWHehKQHqw== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(39850400004)(376002)(346002)(396003)(136003)(46966006)(36840700001)(8676002)(82740400003)(36756003)(110136005)(5660300002)(8936002)(316002)(336012)(26005)(86362001)(186003)(82310400003)(44832011)(6666004)(70586007)(83380400001)(81166007)(47076005)(4326008)(7696005)(2906002)(36860700001)(2616005)(426003)(478600001)(70206006)(1076003)(54906003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:28:45.3934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73fa1d9c-c6b5-4bc3-ccba-08d951b27ab6 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: AM5EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB4619 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468155585100003 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. 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 Thu May 2 19:42:08 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=1627468155; cv=pass; d=zohomail.com; s=zohoarc; b=UTnaqwErwUFJtOFOP9L+PZekqKipcW2cQxcB1A6fgA40RMpVsGdgAIkkwHNB4GslyiFJrVyqxSiCCt0atGlrSDmSiBcGA4Wi7Ewq/ZZeZOAXGmIHSt31DN/MCJVoHCY1Q6rSIstyjCgYfzXmyl/INoYUZUGr9ba8Kr3mL+sjtW8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468155; 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=039yhm0OXE63ZaHtdlaK4YptpkTMc2iTaBz36ataqqk=; b=n25WuO+kFCUdnp4qrkLcF5kuqXyAlGXNvY85UznT5GKFg7LHiPeRXYfp5tDfXrxIzm4X/DkXhdqN/YRihWrS8oJ/3D+U7PVB/yrFauxxwguxVdvH6DLWN42OyFsN5uxPIjaxjrljAL3t4x9AcS/p8BpGwm9qbo3CpghSc50UCew= 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 1627468155144690.704118325111; Wed, 28 Jul 2021 03:29:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161427.296449 (Exim 4.92) (envelope-from ) id 1m8go7-0005tc-P9; Wed, 28 Jul 2021 10:28:59 +0000 Received: by outflank-mailman (output) from mailman id 161427.296449; Wed, 28 Jul 2021 10:28:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8go7-0005sT-Jy; Wed, 28 Jul 2021 10:28:59 +0000 Received: by outflank-mailman (input) for mailman id 161427; Wed, 28 Jul 2021 10:28:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8go6-00040B-Im for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:28:58 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:7e1b::623]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 35944c1c-e9ef-422a-b0fa-98c4a03e87c6; Wed, 28 Jul 2021 10:28:50 +0000 (UTC) Received: from DB9PR02CA0009.eurprd02.prod.outlook.com (2603:10a6:10:1d9::14) by AM9PR08MB5905.eurprd08.prod.outlook.com (2603:10a6:20b:282::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Wed, 28 Jul 2021 10:28:48 +0000 Received: from DB5EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d9:cafe::e2) by DB9PR02CA0009.outlook.office365.com (2603:10a6:10:1d9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:48 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT009.mail.protection.outlook.com (10.152.20.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:48 +0000 Received: ("Tessian outbound 31e6e3649d31:v100"); Wed, 28 Jul 2021 10:28:48 +0000 Received: from e816462a8ab3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 12E6E4CB-4FCE-4035-A7CA-30C622ABA7B7.1; Wed, 28 Jul 2021 10:28:41 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e816462a8ab3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:28:41 +0000 Received: from AM6P194CA0036.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:90::49) by PAXPR08MB6783.eurprd08.prod.outlook.com (2603:10a6:102:131::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17; Wed, 28 Jul 2021 10:28:38 +0000 Received: from VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:90:cafe::37) by AM6P194CA0036.outlook.office365.com (2603:10a6:209:90::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:38 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT055.mail.protection.outlook.com (10.152.19.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:38 +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.2176.14; Wed, 28 Jul 2021 10:28:35 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:35 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28:32 +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: 35944c1c-e9ef-422a-b0fa-98c4a03e87c6 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=039yhm0OXE63ZaHtdlaK4YptpkTMc2iTaBz36ataqqk=; b=p/JMgktVy1rZtUIcyO6VvlvmcGEr+elBd4eLcAejfdMYZ9oOLeGAY2OqYtdI354/PqArhTN2EhLV7XhJGSF0UBPvk42EmnSXyI2o4ME6us/K2404ENNf3uMhKVKO7bK0nLsLy/V1VdYo+pS2loVx1aEweA5uv3zYXF0HWD9TFX0= 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: f09a9c1e3d445cc8 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZafKQqpqRQ6bw/cQVGwJhOLQJWYSrE6GZLAaB2D3y2RWIfaun1ypntdIBScKWVmKYnFZKTqhtSl/E6X9iYHOAY+Y5CrkO31XNkcxPbFpED2WfmHEFFIoz0ONtDJXfneimWvsF8PyijpUciTiAPTyYm41FfB3W+d7/KytrBmw+u+OTh67v0LiHCjqGeMxLfq7APPgPK3O3sVhIFgWkh8PGOnNjxE5vZFEvW+nwilniC53U9gOYFaObmK4GcfPU4ONZodi5mwjyohl7rOfdj3drOagRpT6bckiP5hyUIhvVUdTn4mb7NMRLku1aIQZ9TTIxNNPVMm1rcnJcZ/lqjqtdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=039yhm0OXE63ZaHtdlaK4YptpkTMc2iTaBz36ataqqk=; b=Vnjs7FlECBTvoa0B2PZrnD+OoTcf7PJCQlJiPlf7tDEZpK9Yi3Cket2WAcG+JxysaijVHpyZOVUfpR5mhm+UmsNkiNInsL2SoVIqUm/OmMuYvq27I3hrkdA3XPlOzmPteW3ONCCTpBj5GR+NVKc2k0ZRBnkkfSbKq+BgTKLcAEDIkldfiCqY076gX341kMOdVeMfU2Fs+TBjY+l1wSjrAx7VnLzozro8jJRQdXnSEEtN9uvpKID/x7W1NSLu3KvpnC4vjBD9tom1Lw75T4D6e3U6FcsJxm9fBfcvxjxAnjsKoqCARlRCwMn4G0kdFyWOKnhjG5zh60LhoKz8bb9APQ== 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=039yhm0OXE63ZaHtdlaK4YptpkTMc2iTaBz36ataqqk=; b=p/JMgktVy1rZtUIcyO6VvlvmcGEr+elBd4eLcAejfdMYZ9oOLeGAY2OqYtdI354/PqArhTN2EhLV7XhJGSF0UBPvk42EmnSXyI2o4ME6us/K2404ENNf3uMhKVKO7bK0nLsLy/V1VdYo+pS2loVx1aEweA5uv3zYXF0HWD9TFX0= 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 V4 05/10] xen/arm: static memory initialization Date: Wed, 28 Jul 2021 10:27:52 +0000 Message-ID: <20210728102758.3269446-6-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: f0fead5a-c03d-4fb3-7960-08d951b27c47 X-MS-TrafficTypeDiagnostic: PAXPR08MB6783:|AM9PR08MB5905: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:159;OLM:159; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 79RzpEsb0lWGRVzdlwxRnTDECqQg3azhHdaYN6F5J++AcO0FwG/NYLRKZRYIdoJJHn44Xt+rGkw145pUVPgdlr8H3OG+CXnHezppwzalhm/Gc0gejVuP26uU3Wzy0+wtWBoG14x2XcGBnBmnZOXh7qNoGaN6B6p+cvpvzwujDbDragXmwBdYjM05nCmNiUWM4IChZKL+QTML+DD8fee14qRcpsFjadZEYvG0DYfnenN78LHwafCniKHEzWPGsxCaezQL40jGswxjY6TM4FtBTUzIOtpsGvtdfnmhNPZD49IdzH1TJkzV5W83AAyV8SvwutO3aFd1pGdivRcaVPZNINH8JeVljhU2qz9rxKomycEsKhDu+9c7x/8duxKIN0i/rEEQnkHnOPfR1rQlD8/xKPAn91/84NzUr1HOKHWYV1EK2O1xMlzNyuXBkhyp4cqacK8c6Y4zm6yceBAWbtF2bx9fjNxdjAm5TfVkjQNlIiStriU3Rm9XhodoaVoYdSWgWxsNkXh1utp9WzkWPFztgdjWsqgXUoC6RA6/a3tKdzZ7quzyMY1DwfFwJLJ2r2opvkHAlyqqdilL0PZJGfgpUB0YGzj1gV7u4EQtW0HwomKG9UAdpq/PMd49X2z78T1U1vY9WP9SO49nW+ubGYLK4rDSD89bZ+78KOmLZpOA11p9t+iDuGM3iWDpnCXkmrmUq68+yD7TbmV9f3hj/PUwWil5dDU1DwewJsRffi2KE9E= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(508600001)(82310400003)(7696005)(2906002)(36860700001)(81166007)(44832011)(47076005)(186003)(356005)(8936002)(1076003)(6666004)(26005)(336012)(2616005)(36756003)(426003)(4326008)(83380400001)(70586007)(5660300002)(54906003)(86362001)(316002)(110136005)(70206006)(8676002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6783 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ef8c5ae4-cf28-40cc-e237-08d951b27657 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jeT0fkzksuiQjcfDR6AOkn8w6jdUuHnLRoHpLI1ROUNkc0c5v+4Fq3wLbN9/ym1ZTTjb3I5lfYJTYQNJrHe7o+LmFGODsyPKSS49kohzftOZnLC/HcfEQAI7Mhgs5/higk3koXFra7FTaP4xTELLGYvs3hzohZF6nGDArkJwP+ny8IgYie6TJQPB1bol0ssFKt2RzWV7QHrQ2xMt+WbH8dBbKXKN8HvvY21K5anLauwM1Tr21m8nQ9YG4rbOrAchBwwbztI79TTQcmEodPcqAuHOFVUHKjrB0YpKdsT38YsZmt/UpQVazNaXml6NTSIJuAurM41nGtQIRaUrXWFxap4q21yGnegLGqQ4J+bmgpILrDjt1kY+8R7FelAeQFQKT6wfPYclzajdfU612jGYckAF3Azk3gLdbGQierj3jryeROQG/vB4rz/jIRfLHUraNWNuNb27lnxNYO57DGnaCPbVsoU2M1AS+QZWMfrf83+qaN1eMZLMkJtJ4CMmQqIm4UpY+9XlmhlsL3GG+n2pI/Q6kJUNL9mG/f8Z+dez/ZDxILD8Vf9EEqAuuoFVvxKVoH7DTB9zq9eS9cenlas4/i5LKFZ7qU4k9RoCu9s6GIpiOxOZxV/1iXMl7u/ITfn4mdD4VniDL+E/JXLUxPiH4cZrxrbIqSSmtyQadFvx28HNj0rnlLGshQREuvtGy2vIKbxzvQalTrcyygxM5tlZvA== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(39850400004)(346002)(396003)(136003)(376002)(46966006)(36840700001)(86362001)(8936002)(26005)(5660300002)(6666004)(54906003)(44832011)(82310400003)(8676002)(70586007)(82740400003)(83380400001)(36860700001)(47076005)(316002)(1076003)(81166007)(7696005)(186003)(2616005)(426003)(36756003)(70206006)(478600001)(110136005)(2906002)(4326008)(336012);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:28:48.0643 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0fead5a-c03d-4fb3-7960-08d951b27c47 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: DB5EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB5905 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468155594100004 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 new CONFIG_STATIC_MEMORY to avoid bringing dead codes in other archs. Put asynchronous scrubbing for pages of static memory in TODO list. Signed-off-by: Penny Zheng Acked-by: Jan Beulich --- v4 change: - move the option CONFIG_STATIC_MEMORY to common code, and with Arm "select"ing it - replace round_pg{down,up}() with PFN_DOWN()/PFN_UP() --- xen/arch/arm/Kconfig | 1 + xen/arch/arm/setup.c | 24 ++++++++++++++++++++++++ xen/common/Kconfig | 3 +++ xen/common/page_alloc.c | 20 ++++++++++++++++++++ xen/include/xen/mm.h | 6 ++++++ 5 files changed, 54 insertions(+) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index ecfa6822e4..cc7a943d27 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -15,6 +15,7 @@ config ARM select HAS_PASSTHROUGH select HAS_PDX select IOMMU_FORCE_PT_SHARE + select STATIC_MEMORY =20 config ARCH_DEFCONFIG string diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index f569134317..369f6631ee 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -622,6 +622,26 @@ static void __init init_pdx(void) } } =20 +/* Static memory initialization */ +static void __init init_staticmem_pages(void) +{ + unsigned int bank; + + /* TODO: Considering NUMA-support scenario. */ + for ( bank =3D 0 ; bank < bootinfo.static_mem.nr_banks; bank++ ) + { + unsigned long bank_start =3D PFN_UP(bootinfo.static_mem.bank[bank]= .start); + unsigned long bank_size =3D PFN_DOWN(bootinfo.static_mem.bank[bank= ].size); + unsigned long bank_end =3D bank_start + bank_size; + + if ( bank_end <=3D bank_start ) + return; + + free_staticmem_pages(mfn_to_page(_mfn(bank_start)), + bank_size, false); + } +} + #ifdef CONFIG_ARM_32 static void __init setup_mm(void) { @@ -749,6 +769,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) @@ -802,6 +824,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..8f736eea82 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -67,6 +67,9 @@ config MEM_ACCESS config NEEDS_LIBELF bool =20 +config STATIC_MEMORY + bool + menu "Speculative hardening" =20 config SPECULATIVE_HARDEN_ARRAY diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index a3ee5eca9e..2acb73e323 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1519,6 +1519,26 @@ static void free_heap_pages( spin_unlock(&heap_lock); } =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 =20 /* * Following rules applied for page offline: 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 Thu May 2 19:42:08 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=1627468148; cv=pass; d=zohomail.com; s=zohoarc; b=LyDIK3Wm7dqwDQmFMRyEH3ynLFkx4UgbHCb0ADYlE7vXvenGXGtISTV5JDNkcqETEWMMhzTgVlBqb1YJ50JRimnAezNsEaJHKJ7iIHnK1/JtMN5CdMpYeoeHrFMFWWRm/EN2/X1okTKxj3+4KnSDY6QFrXNZuXMywW51MYfO2d0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468148; 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=aq/CVp/Ccy89yXBl4+lKWxTcJAN2riHCxWA4scIZ/gk=; b=a7gF5S4bNRUs6E4EMzf19CYNiwPQvqSkboJORDewRbu3NMqE2yEIVko9Ocdl1tSyfTwN5EvIDSZ1NnBlLkVJH3k1t63mBK0lpnA+dF6rQylWaOqeJmsoKxsbhuIc/eZHxNCfoPOEnmcUa1IhBVVXTkKPuwaTV7KpnRbIGQW2zzc= 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 1627468148838529.0204026517067; Wed, 28 Jul 2021 03:29:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161425.296426 (Exim 4.92) (envelope-from ) id 1m8go3-0005Cv-2U; Wed, 28 Jul 2021 10:28:55 +0000 Received: by outflank-mailman (output) from mailman id 161425.296426; Wed, 28 Jul 2021 10:28:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8go2-0005Cg-TS; Wed, 28 Jul 2021 10:28:54 +0000 Received: by outflank-mailman (input) for mailman id 161425; Wed, 28 Jul 2021 10:28:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8go1-00040B-Ie for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:28:53 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:fe0d::628]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7a0e5ef1-843b-4116-aa70-f155df538fc3; Wed, 28 Jul 2021 10:28:49 +0000 (UTC) Received: from DB6PR0501CA0044.eurprd05.prod.outlook.com (2603:10a6:4:67::30) by VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Wed, 28 Jul 2021 10:28:47 +0000 Received: from DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:67:cafe::16) by DB6PR0501CA0044.outlook.office365.com (2603:10a6:4:67::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.19 via Frontend Transport; Wed, 28 Jul 2021 10:28:47 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT026.mail.protection.outlook.com (10.152.20.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:47 +0000 Received: ("Tessian outbound 1942ea606101:v100"); Wed, 28 Jul 2021 10:28:47 +0000 Received: from 824baf3abbc7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 18516FEE-9590-4434-9503-CB263F55DF89.1; Wed, 28 Jul 2021 10:28:41 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 824baf3abbc7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:28:41 +0000 Received: from AM3PR07CA0090.eurprd07.prod.outlook.com (2603:10a6:207:6::24) by AM0PR08MB4580.eurprd08.prod.outlook.com (2603:10a6:208:10c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Wed, 28 Jul 2021 10:28:40 +0000 Received: from VE1EUR03FT017.eop-EUR03.prod.protection.outlook.com (2603:10a6:207:6:cafe::73) by AM3PR07CA0090.outlook.office365.com (2603:10a6:207:6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.7 via Frontend Transport; Wed, 28 Jul 2021 10:28:40 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT017.mail.protection.outlook.com (10.152.18.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28: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.2176.14; Wed, 28 Jul 2021 10:28:37 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28:35 +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: 7a0e5ef1-843b-4116-aa70-f155df538fc3 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=aq/CVp/Ccy89yXBl4+lKWxTcJAN2riHCxWA4scIZ/gk=; b=y89XdKUP6fMzJgqTnuICOwWs1J4FA21prd8h4m64CE0HmvURKkM633vRr57CoLwynTl8n9fUpqHvBsiUfJEcgvC6Nu2pWuPNCHhZjekaSH8LVgwPaCcTr2/ntCzWA1w7ms+RF7hALbx8btGKP33U5C+uUt9Qg8EgNxElEkvcsrw= 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: 87a4df21130eecb1 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UyawuLUc0VdWsIVBAc4Ffaqr0TTx+O64R7m0SGgXVlRmJ2YFDg/OfJrKVwOHAKWwnEZ0cnxkARmWqtYoQnxLqLcHpn13fzQxhvspME/eRdrXXaPshO7YrFfKkfj662/ti9FKIou81tW2BNGrrOVWZ4iMPHI0aL1Ijown/+bLK6gyY8nfTZ73UeLQZHrH539BdWj8a0ffvI2vrB6+eTZ+YgegDz4oxgrZVO0SWC+kJ3s/ulzKW/6Zep6KozgWS0/9TivgxHpIDGKl9EM74TKSkdoZ6d66+9/vXifc69/eAOpwDIhAuufu6kQn7Px1hVmb5ac6j5LrrN6ucMuJiN1SmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aq/CVp/Ccy89yXBl4+lKWxTcJAN2riHCxWA4scIZ/gk=; b=An0ALzUDtTqXGssePqPdmijk+t8AGpKGRuMaLwpnozE5Ekfc0PXfBhkKqvTbytJeco1wEXehnCjGq3I5DnHc0JLRBG9VU79VsHeWvyO0WiJqABcisr9KZkTe7BYmSN1xdvdk+3iAHcGROm+EBUehd8oSsLa/Ah56IOznp16awo8BWVEMCQFYEfikQB8w9XO16SkODYTVVlfTeNdzKfzseVKfpvC4MNv4G4HIyuG4R5wP680fiKIt7GViqx2AtDDg8Ys+CEF4Mo4PsCJKola4M7TnTRCsaCfJMoLChzuG7J2tTuSjyGuz1WHxxMv2uvo2W1Cr1J6Jv6XePP3nXjnrbg== 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=aq/CVp/Ccy89yXBl4+lKWxTcJAN2riHCxWA4scIZ/gk=; b=y89XdKUP6fMzJgqTnuICOwWs1J4FA21prd8h4m64CE0HmvURKkM633vRr57CoLwynTl8n9fUpqHvBsiUfJEcgvC6Nu2pWuPNCHhZjekaSH8LVgwPaCcTr2/ntCzWA1w7ms+RF7hALbx8btGKP33U5C+uUt9Qg8EgNxElEkvcsrw= 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 V4 06/10] xen/arm: introduce PGC_reserved Date: Wed, 28 Jul 2021 10:27:53 +0000 Message-ID: <20210728102758.3269446-7-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: 10c93beb-31dc-4980-060b-08d951b27c05 X-MS-TrafficTypeDiagnostic: AM0PR08MB4580:|VE1PR08MB4974: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2276;OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: /zSPlKVUKfFkwodmYumipm35csRyivtLk04Z3AFbmpNoI+6cC3XlBhK3a8D3g3nsiU8Sk3NUyStJBuOnKgVwNB7UyFhble0djf8CUfcwWAIbLORMY3VV+iQy4LnhkLGN1/BUGfJD75WUkw8Nb6eeZ2+WzotyarGaGo5oxD2AFpx8nxozDPiSAr8Nfx1QfaIY5J7j1mDJ01ILxsV89FwmQ9cb55fyEwNIdmgRqab5iSF9c9O4fqkgLv/yJiCkbCTY9fCKacSjlpqbRndcWvcBP0X54k06xKJWq6OfH6FrPqmhdXtas0BQuGLFdc2cq/RZYJtEFIRCAwhOVjRuM0VUYzPYzb2zJVbNT8MO0kjbe0VUN4Vt7hAKdNCupTHWZcpNXS3qv0xSzPobKmgx64JHlMkfSOj3SUQEGUeiQs3GU/0mPQHEsYfbWd2NePgfaM/RLZ71QPQpJeBVfc2mmhZ40Yn8VKaIB7pZnVAWhUDZX28jqvGVDZOG+2253TP+mwPgs6MKMMPLtIXPKNJJ9kocbi4BygwW0VxCKK2hUdt5RnCPM2vv/HsFfc7jUb9yvEId+90LO5WLVWbZT3ubGPVB20ljjoFNJl/6C3kPNVPXjh1qodL+8cIfo1j7SgGLm9JWXcuWKYnqIPMYAz9B1Mdhs+cTnqKPsXgval9bWmv4jkPxM9x7xBnbZ28/d09NT96ZTqsW85Xnt1YUgxFSHICUYxhuZRGPUuXgz3p4qEVx77M= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(396003)(39860400002)(136003)(346002)(376002)(46966006)(36840700001)(336012)(478600001)(2906002)(26005)(6666004)(186003)(82310400003)(36756003)(7696005)(86362001)(356005)(5660300002)(44832011)(81166007)(36860700001)(70586007)(83380400001)(2616005)(426003)(1076003)(47076005)(54906003)(70206006)(110136005)(316002)(82740400003)(4326008)(8936002)(8676002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4580 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4e8eb35b-a2c9-4526-a0fe-08d951b2778b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2sbfYgLwNPMwhJyhR+ZdaOQj8o7X0Fx/YlcmJC//i0CKFdt7SPgVo2Z1iZyp41EE1wSQcuz+QbdRe/TrkoQS/AZYfr7Sm+9RacEJ7PYwUw32oKR/lw/9aV+oUqVYFvQdrsbACqUiBLQaGkVBJAu//QQACvmFTFhPj/Bp8fXMGKe0A0jHmYUMyCryrvgvK+re3KaStXNf6bHymYb5f2tfHwomr12wkU+TWA/USqN8zLLvqQBv9cotED1JzXX3B2aCRLQi7usHdxFT7nY+E9Bf99hLAFd8yZvKJ3jVFK36WUuWM2TYYBF6Zy4wTnYXZKmYkER3vylOSbppmbal5dVCLCgXoH+1xtRaEzEEQfGTZhf4uqYiHyUBsbfrYmFGqmDpLq94oZxF2S9m9WFf3NO14nvJ+LaKtDtnQKbgnRWwTiasRQZlKNDAN9PuioOaPCHHVwfY+aZSGH6L9p1Guk5FW2egFYRisE/XZEWcdvIYjjaITSW85IOod2JFRJoBle+SmPZN6EuwsKDXQ+u92JEXhuIu/U39/9J8Y5B4dpKFRE/RQr/urw5eTBVeWSwcFjr/JUItoAKd6ciD5ILYS00/i6oKt7a505jMlSZ9zKNuPKVMX6MsunT0/ufvfX5yKCSmkEnWjza27KXerBZ7rTejPfspA7XRV7wDSFAfriQDG3DLSjCxwM+FnzPT9kyJ8uXefllVe1TNC+PHo6lgdrA3sA== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(136003)(39850400004)(396003)(346002)(376002)(36840700001)(46966006)(6666004)(54906003)(110136005)(426003)(82740400003)(4326008)(36756003)(83380400001)(5660300002)(44832011)(70206006)(2616005)(336012)(86362001)(36860700001)(316002)(47076005)(8936002)(81166007)(186003)(7696005)(1076003)(70586007)(2906002)(82310400003)(8676002)(478600001)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:28:47.6308 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10c93beb-31dc-4980-060b-08d951b27c05 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: DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4974 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468151198100005 Content-Type: text/plain; charset="utf-8" This patch introduces a new page flag PGC_reserved in order to differentiate pages of static memory from those allocated from heap. Mark pages of static memory PGC_reserved when initializing them. Signed-off-by: Penny Zheng --- xen/common/page_alloc.c | 3 +++ xen/include/asm-arm/mm.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 2acb73e323..f51e406401 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1536,6 +1536,9 @@ 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; } } #endif 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) --=20 2.25.1 From nobody Thu May 2 19:42:08 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=1627468160; cv=pass; d=zohomail.com; s=zohoarc; b=Ey00r2wyno55ypE8wXFb3j+qAIgZPc/KYPl4yDynTSPyitx7+zgDO5gChka3LyYzkMyzRwXbCZv//v9I4ZLDP1ITgmcb9uIYUqiz7AfVEfDjhHi8zerWvST46JAwOBVp2h8vo71vKlgXrymUoRHR78lICKkCJ3+swBCM2wYO5Bc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468160; 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=hCUWQDaTiidx+E9zuPE9oXjMot3xhLFaC2iMm+uCkok=; b=ZF1VD++5DR+kLzpadQNtr1TBoJFr2kWgAwjrAdMxMLKXWK5QddQmmhrMJ3RsdAxHB2hHISyBbbvYqMUlTVrwFjYW8Oslxo5JmchtnjHFYm/2Mj9wInZBiDIbhgjSuie+ntMUe6Qbdmf93haaeVzMGQrdz7C1SrEBcNbY+Ai1H5k= 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 1627468160182222.94886640874267; Wed, 28 Jul 2021 03:29:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161428.296462 (Exim 4.92) (envelope-from ) id 1m8goA-0006No-O8; Wed, 28 Jul 2021 10:29:02 +0000 Received: by outflank-mailman (output) from mailman id 161428.296462; Wed, 28 Jul 2021 10:29:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8goA-0006N2-Hl; Wed, 28 Jul 2021 10:29:02 +0000 Received: by outflank-mailman (input) for mailman id 161428; Wed, 28 Jul 2021 10:29:01 +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 1m8go9-0004GY-Dn for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:29:01 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (unknown [40.107.3.48]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9c22ffc6-ef8e-11eb-9786-12813bfff9fa; Wed, 28 Jul 2021 10:28:55 +0000 (UTC) Received: from AM6PR05CA0017.eurprd05.prod.outlook.com (2603:10a6:20b:2e::30) by AM6PR08MB3365.eurprd08.prod.outlook.com (2603:10a6:20b:42::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Wed, 28 Jul 2021 10:28:53 +0000 Received: from VE1EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::3e) by AM6PR05CA0017.outlook.office365.com (2603:10a6:20b:2e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17 via Frontend Transport; Wed, 28 Jul 2021 10:28:53 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT023.mail.protection.outlook.com (10.152.18.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:52 +0000 Received: ("Tessian outbound 1e4fcc40c873:v100"); Wed, 28 Jul 2021 10:28:52 +0000 Received: from 106622ec1638.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FEFFF744-99BD-4604-B864-1AB4B7C2BCCE.1; Wed, 28 Jul 2021 10:28:45 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 106622ec1638.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:28:45 +0000 Received: from AM5PR1001CA0011.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::24) by AS8PR08MB6758.eurprd08.prod.outlook.com (2603:10a6:20b:39a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Wed, 28 Jul 2021 10:28:44 +0000 Received: from VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:2:cafe::2d) by AM5PR1001CA0011.outlook.office365.com (2603:10a6:206:2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:44 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT049.mail.protection.outlook.com (10.152.19.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:44 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:41 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:41 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28:38 +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: 9c22ffc6-ef8e-11eb-9786-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=hCUWQDaTiidx+E9zuPE9oXjMot3xhLFaC2iMm+uCkok=; b=reTN5WzrHSYeAo0SgqenD0XrQEax8sYwFoRT8Xf61jUagAbkxtRbGIe69b4KjzZ4gRhCOTBpQwPcieINRgs3/FErixaagYAt+wMHUX+ZkYWlMa+LP2tQMuqOpjb7jYnOC+VmCkPVcRFMlKPnCA0I/prDM/PtokhQHDnSQC6ZuOs= 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: daf66f73026ec041 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GhG7Xq4+PSnffvBofkvzVwXKkwEv7KdLeinscSL74kJPmC+2MX0A0/NKVESPzs4UOa7H8uVUWJuUmv33HUdht8IPsV2jnTGwp3O+uK6OvfXYVJgm55pDQ+GQr6epcPFZZrsxJAXOt9+/ntPzEpTO+aoa3sXk271RugYAi+iCkZxkwAxt1GEsAvNb+y5LQCg+rmO0tHtHUFJsjuszPqTv12v7ZuVRVxUTWtwFfWraZIBKt6+Fjbup8/iHX9mKBKQUsoBy8OPR1dxOspdKd1moqEXVLfF5hmg/tRJMlHlzD4TdrC8+LyAj4WjsRyvoj8Wsx7QW1l8iFUJCbHBebIMCLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hCUWQDaTiidx+E9zuPE9oXjMot3xhLFaC2iMm+uCkok=; b=ajI9bdMFtDJt+SxC4Y+BDq8Rvfag5iGl6yJ8g3hPDPThTjsw9D/kUA0AMC426SLhz55Fq/FbHVOLNs3Dm+7MgRKEQh9bKYVOXq0mx0TIkBdb4fPK1HJlI+BPBLYfn2Hn9k/j14XRaz1JvoyOzF7lYvwoPUIEcva5nggKiAOLQgGkJWpO3hZo7L2WrqqlFYfUfbQmQ/fiG2sa08/SiGa/xPpLdq4iCeavaXmj6nepr9xk1/lQyYy9Kz4RxYX2QOadEVoIfozmtmHjxsFIeUTEh2v9N0Vow0lSNAM1OaPf8CnYl4GI1Gky+/A5X2bcvORy13zWg7odvMs35R79NojPAA== 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=hCUWQDaTiidx+E9zuPE9oXjMot3xhLFaC2iMm+uCkok=; b=reTN5WzrHSYeAo0SgqenD0XrQEax8sYwFoRT8Xf61jUagAbkxtRbGIe69b4KjzZ4gRhCOTBpQwPcieINRgs3/FErixaagYAt+wMHUX+ZkYWlMa+LP2tQMuqOpjb7jYnOC+VmCkPVcRFMlKPnCA0I/prDM/PtokhQHDnSQC6ZuOs= 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 V4 07/10] xen: re-define assign_pages and introduce assign_page Date: Wed, 28 Jul 2021 10:27:54 +0000 Message-ID: <20210728102758.3269446-8-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: 3f0b5b4d-9f6c-4e40-f0cd-08d951b27f39 X-MS-TrafficTypeDiagnostic: AS8PR08MB6758:|AM6PR08MB3365: 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: kbPVJo2aJjs+NXnUlOVKVwygUx2Ri4syXxnkASXC+LHwepNYl8Ei83oePqP+ge2WhoEIm1F8cxcHMd1uN8FKeI8Puu/f3zkXzOZVCAfc/vTn251wx3WUU1KCc665BvWv6DhlR1hPKAWowkC0694sS+9bklQZ5I35ZgbeLTUbKxokcRevxYfxrw82kX7+O6/xOpiZDoPeXqu1qSQSbiIsMkxfZ48qUqaZQso1YgpMOTFiFACdgzIjOFYsqDgmdBU7pj3w7wWzmX7idCgFBcuHzPCSuOB1pCalRmSBFqLI9vuiaMiACNsxJQaPq+FR+FlgekHUoioUjsaFK9xY7o9iiM0cq0+TzBmJkqQ5tt1A4d+YDWiOv05m4YuiHzuANo4pzNAO+PPvVCdb+LC49ztwh3QEN618GsMPKLgi2N0mwIf2h6Eb6aqDCrktj/yZmINvJKqOfXXZGMzRP7/RhdOa6GJS/ikpKSQFSTSc+XweIylaU1gbxaAam7TVzNG2dMASmV1PCniO2qv2DTmwYi3Or5tXwrb/WURUBN5qQnQ+1vTVmpQiXcI5ERrvfsSL4OFF3MobLjgwATUa3m5Z3Jfz7Dsqn7CIaT1EJToN17j872PoIB1u9cl1ZVF23LE5tNsIU7awJXc9WJXHkI5Wy9sdg4vPxkGD7Mb7DSh102wGJY1/mni6ooyGibaSsXj8xRpNw+iLK6fOzDcHL9Kf+Et7zCPbK0LVPz/LIHAGOs1u938= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(376002)(39850400004)(36840700001)(46966006)(7696005)(6666004)(1076003)(2616005)(86362001)(5660300002)(82310400003)(4326008)(36756003)(426003)(47076005)(2906002)(8676002)(54906003)(186003)(110136005)(8936002)(83380400001)(478600001)(356005)(26005)(82740400003)(36860700001)(44832011)(70586007)(316002)(70206006)(81166007)(336012)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6758 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 98f7b237-2d45-41f4-ed3b-08d951b27a1c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pgvc8UBrjeWvBBptn4E/1rpTTvaeIS7w6LpuKYpdVbzEE4LvdJ3oCxlJDfzBFGdMD6Snfa+CR4GMInwFnl57ArKKCK1AY8sbBDwkSLQ5+XQL6uE9LCw5bNzYAJqd5ioDg3mRJiG+g8cj1DCnSVzeM957l+wt9viGRmDJTSxGppSryY/W4sMHZHiuR1mUuw0ZMgdOef5tTI+99E0mqSi33HgzDDovrqqqUmyTOdkrf11TXrBFu4ZOiL9FCF1+LyamTsMc4J/gQQYQ1q9wtBOaS0BY0cP9bs08ZVri1j7oOdWNrvoObLPn7gqTdVPSrdxpOIwgpnbRgWW+xhIWrzQn716TTMdSGPg6FmpMZwIkU1QgSs6VjTdge4nCG9NBqN+sk8cpv3kIaymF520a6TTDhKzz3pB0mLwS4aUeaAqcbA6NXwvYKwfpwCcAwEnHcLa2GUKAdusC5brmnkXLqhX8DmlXllEZcr1RbbAcX+EQ0/D3JKPoVNLBGmZYwTzYfzv5PsYKBOX/eG+UHwrwfPEnX5+YrSrC2WFqzysTDpq2wWm8v35+ZV2Gnb8SFR5KMQKuryIJgYQHvib5feokV4Fr5heJKrOi+l4dzSlVXD9ER/dQCYoIRPkjixNxAHbJm+kR93KXZnmFLkTjZVMBQc6LwkhVc/GOvG+yeemXyfIWFkDXM6WGGK68PI1Mq7VNtTXNdMJtCmjN1kWd6hhkJ/T9/Q== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(46966006)(36840700001)(70206006)(81166007)(54906003)(6666004)(186003)(316002)(36756003)(47076005)(5660300002)(70586007)(82310400003)(26005)(426003)(110136005)(1076003)(2616005)(44832011)(2906002)(83380400001)(508600001)(8676002)(4326008)(7696005)(336012)(8936002)(86362001)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:28:52.9018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f0b5b4d-9f6c-4e40-f0cd-08d951b27f39 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: VE1EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3365 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468161811100001 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_page parameters, such that the compiler would point out that adjustments at call sites are needed. Signed-off-by: Penny Zheng Acked-by: Jan Beulich --- v4 change: - in all cases where order-0 pages get passed, prefer using assign_pages to pass literal 1 - reconstruct the order of assign_pages parameters - remove the unnecessary parentheses --- xen/arch/x86/pv/dom0_build.c | 2 +- xen/common/grant_table.c | 2 +- xen/common/memory.c | 4 ++-- xen/common/page_alloc.c | 23 ++++++++++++++--------- xen/include/xen/mm.h | 6 ++++++ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index af47615b22..9142f359da 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -556,7 +556,7 @@ int __init dom0_construct_pv(struct domain *d, else { while ( count-- ) - if ( assign_pages(d, mfn_to_page(_mfn(mfn++)), 0, 0) ) + if ( assign_pages(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 fab77ab9cc..1f6b89bff4 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -2342,7 +2342,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 e07bd9a5ea..083e14b84f 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -728,7 +728,7 @@ 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, + if ( assign_page(d, page, exch.out.extent_order, MEMF_no_refcount) ) { unsigned long dec_count; @@ -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 f51e406401..e279c6f713 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2282,9 +2282,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; @@ -2304,7 +2304,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 ) @@ -2313,18 +2313,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) ) { @@ -2336,10 +2336,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); @@ -2354,6 +2354,11 @@ int assign_pages( return rc; } =20 +int assign_page(struct domain *d, struct page_info *pg, unsigned int order, + 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) @@ -2396,7 +2401,7 @@ struct page_info *alloc_domheap_pages( pg[i].count_info =3D PGC_extra; } } - if ( assign_pages(d, pg, order, memflags) ) + if ( assign_page(d, pg, order, memflags) ) { free_heap_pages(pg, order, memflags & MEMF_no_scrub); return NULL; diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 8e8fb5a615..2e75cdcbb7 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -132,6 +132,12 @@ 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 domain *d, struct page_info *pg, unsigned int order, --=20 2.25.1 From nobody Thu May 2 19:42:08 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=1627468165; cv=pass; d=zohomail.com; s=zohoarc; b=BOn9MW9uWeAbOObWJ/Vi7EN3I1ho2+q+I16pMPebuqEVZswna4i9frm+CuqEWNoU+rqDbEJtkNkCas/ipohJCpeX5NlJ52kcR3EApViSyamdm6F24vdb6kL2AXaMJpNN7nGyk1xHfAZxrU4EOK6ObsHnR6o90f0/nyq8FHMNsWo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468165; 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=Eq4yUqDpYRGNFdQptknzn+SqgvCNRsk87GkopXgdUKw=; b=g98GU3kr7VnAaOuH0ef9h/DWO6e43g9h33w+htimopfJnzeaexgdQKFL5mc9BVep61cQb++rhd/ZrRB4UGytvpLKkOw+wApHo5rsDEI0UQdBobfMn3TV35ti9YN9m4VsED7YIYH4U5Nwzg6ffFImRdYMdhYtYSfmLUdpdzBzlQE= 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 1627468165521965.1662198204219; Wed, 28 Jul 2021 03:29:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161434.296484 (Exim 4.92) (envelope-from ) id 1m8goI-0007bI-1R; Wed, 28 Jul 2021 10:29:10 +0000 Received: by outflank-mailman (output) from mailman id 161434.296484; Wed, 28 Jul 2021 10:29:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8goH-0007Zy-SW; Wed, 28 Jul 2021 10:29:09 +0000 Received: by outflank-mailman (input) for mailman id 161434; Wed, 28 Jul 2021 10:29:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8goG-00040B-JK for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:29:08 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [40.107.8.75]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id eca45ce1-add8-4c99-9567-2b44813c8b0b; Wed, 28 Jul 2021 10:28:57 +0000 (UTC) Received: from DB6PR0802CA0030.eurprd08.prod.outlook.com (2603:10a6:4:a3::16) by DBBPR08MB4377.eurprd08.prod.outlook.com (2603:10a6:10:c6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17; Wed, 28 Jul 2021 10:28:55 +0000 Received: from DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a3:cafe::83) by DB6PR0802CA0030.outlook.office365.com (2603:10a6:4:a3::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:55 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT016.mail.protection.outlook.com (10.152.20.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:55 +0000 Received: ("Tessian outbound 31e6e3649d31:v100"); Wed, 28 Jul 2021 10:28:55 +0000 Received: from 71695685e734.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A24285DF-53B7-4A19-A218-EB80FFDF70EF.1; Wed, 28 Jul 2021 10:28:49 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 71695685e734.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:28:49 +0000 Received: from AM5PR1001CA0026.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::39) by DB7PR08MB3659.eurprd08.prod.outlook.com (2603:10a6:10:4a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.29; Wed, 28 Jul 2021 10:28:46 +0000 Received: from VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:2:cafe::20) by AM5PR1001CA0026.outlook.office365.com (2603:10a6:206:2::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:46 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT049.mail.protection.outlook.com (10.152.19.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:45 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:43 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28:41 +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: eca45ce1-add8-4c99-9567-2b44813c8b0b 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=Eq4yUqDpYRGNFdQptknzn+SqgvCNRsk87GkopXgdUKw=; b=NltAFF4fPgdIEz+KPQ7DWmiOPTyuHpWsfQ7BE5ERbM80p/3TwL9NT/qXa3jh+7VwJuY0HnobWnXIGtaBm5Iqiqffn51bD0Qp30O5bRHTTy7zfjDDRbDvVrVnO6P6+BkRoVEZVb123uevzXsLGTFv5Ynz6EZb9JQC/NuQPEEsSGg= 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: d025559729ff1416 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DpPwcjSR74pzVBGK+qvAOm2OMxFWiH6N5Mfd5IzDjtFirJ5jTSK61mbjRoeyTT4P/o8xC0Iq0PR5Kxz9GFHMLXP0+oBpxrGGsDGjzPXu3LAsb3r7uLfIEqKiU1COpmZ2GCO6x/ZpzC1SPoWsoKsNhWR5PN+0PpTwnKjUFTSekfvJ1dBWQO6X5K9Kdr00DbEhOOBS4vRtfIRtN94Z3/kS6a1XpTs6aL/U9GHuVmdRXdrv6z1DeH+tiVrigA8jo1koV7MggkyNi6GdNzczMWDqauMnShS7h0P1SsrYrmJNFlG23bWcu5Xo7EYxErw3Kf2NXk8Wkh0UEtdQFmowZQNQAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Eq4yUqDpYRGNFdQptknzn+SqgvCNRsk87GkopXgdUKw=; b=EgtLKCN2KA1Y04itZ7g709n0od9VYv4bqYCvYduU6z+r09LelWzHrYs9eKwVXqpGKaUZ2aHsQvQlnldfP56hrjEFJQa13Iv4ZyfiJDTVslX1YX/7xdMMFRvtJFYjSRWhth/OEbI1z6vzHwIovwzlkkBioJ/SUPKpiXMQDx0e20pp39Vq0+E/eGK8hye5r2iHZjjfGxdRleFtafAWwMkWMtMmulNvUIhmZcKnBwY/50WdaEzEbJhxkMzrFZKyAoCn09cE9KGObGiSwnsXxrhVZMZiIKgmMErVRXWCQrv36Q0UWrWwzOI7uuLIXN8sxmAmUxuNsZ9Q6NmAuxcB2xgL5w== 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=Eq4yUqDpYRGNFdQptknzn+SqgvCNRsk87GkopXgdUKw=; b=NltAFF4fPgdIEz+KPQ7DWmiOPTyuHpWsfQ7BE5ERbM80p/3TwL9NT/qXa3jh+7VwJuY0HnobWnXIGtaBm5Iqiqffn51bD0Qp30O5bRHTTy7zfjDDRbDvVrVnO6P6+BkRoVEZVb123uevzXsLGTFv5Ynz6EZb9JQC/NuQPEEsSGg= 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 V4 08/10] xen/arm: introduce acquire_staticmem_pages and acquire_domstatic_pages Date: Wed, 28 Jul 2021 10:27:55 +0000 Message-ID: <20210728102758.3269446-9-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: 4df38fb4-1115-4a00-c0a5-08d951b28082 X-MS-TrafficTypeDiagnostic: DB7PR08MB3659:|DBBPR08MB4377: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3631;OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: h6K3KJjJmkLE7TSBa8B9M+1EqF9gcNyP0mYwqHz//S6KKtjEeutcMdprVWWXRZD/NU9eFDeTZbWnRzKnHsUDth8Ub2hNDrhFtrhiDUc9hSqjUaDoXg4LSf2+xDJyia1h/6e4pdDQ/7q9+C0dXIPTuXDIdtiGSIdxDioXJBAtfKkcnr5t39WUUn96QixpNX7OYX7XE+7vmvCA/4CYqB20rxE3IJX1JRC9JEQiePR1mxM7O2nbidnL1vVZg7yM3ytmy5zoWvn7Wc1pnAMqS2hq35JplNJTBKt55mpzyceE/4bZL7SKfTNVM0fam/ktv/6b7K6ZwIxn0rcmyTs9ryVdP2YRVsbi0jvXEOPNyO1j1xFHkcQLPobc9QX6fIMH8dD7QNnprSNTMVTAaS1pPWSv3YNNNPzJ6wSOp3bzcN+8HBm02d35nW9miLcArXphibqrEjm8x/+lig4SDKvDteh64Ui+qRT1WVHYJhTaPPlKTqThgm/t1NH4U8vyfxNPOEpxuMErlNZxNz82zQGtI4J+vrfW/JLGHcu2czAia7ZPULJXVl/cbcL31YNVFrefyyyXZDOCMr9MNVTSMqZphFABzDuZZ2pyDV8bN2GM8E9juCG4ATmYIrKsrVp+/CwU2wl8lcrOihQabPshxxTBnSdq/82SMYlrwb6n7zmfJahbxc3+hEjV2mrWv7EjuXYhNuNIOhdnUwjL4Y4gm4zEsrmeJSxOREs2cPKApvAYbWgcpn0= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(396003)(346002)(376002)(136003)(39860400002)(46966006)(36840700001)(8676002)(8936002)(2906002)(26005)(44832011)(86362001)(186003)(36756003)(7696005)(2616005)(47076005)(478600001)(1076003)(36860700001)(6666004)(82310400003)(336012)(5660300002)(356005)(83380400001)(70586007)(82740400003)(4326008)(70206006)(316002)(54906003)(110136005)(426003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3659 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: b2b40b37-53a0-40e1-de1c-08d951b27b08 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rT+62bpNfyTFQqpmavFHkGCDkY4ZoDHdizmowgzeWnMlWcO7jzHvzacknOekB0NHniZLd5giBUFBWpzsVfO5+75+L+W35JqYZqhqv+vNXaDH++jRm5UUwbjldaFskERR/ip1uPl0mZpvHVJBJXvvyw/P8gyRT+FkL/HMyiRkS8vAixAWlCk0r+pIEWjauVo0fNrRnkaYPYvxN8EiyIcYVMqCoh8Jg/WQHIPL/u2yIsSv0KRv4fJkZuKHqORzXjy7D0N/C+w88gSZcWOaYgYvijqPoDEnZopDj+2vzx0HI46DtDj8gn9aw8oqysc/egJntLIbl4rHUvRHnvwKqP8eNTPmbRFKPxfzn0BN8G7594rBATNt4yb2ODGXpE7ZHJ4vyB3EAhHWsLDz4xWi15toUy+INJm3k85qSEMffWZeT3hCgW/onqT2iMQMdHjajEa+KTLNR3MC1qgr5AuE9UgqOFG6cGu8TphbzMofH6DTHDS6OuszRUlc155FPGTZALHGIJDMUdsg5UQJ8eXZrab+TI6Ax0pVMmxGFgk3oyYb87EBZo/shSn3pt/UwmMoe9sIA3YH/qL0iliVhQhvhSL06QjtQS+p0kx22dFeZSdW6nLtfIPIOBgpnhG6knOHb7nuFekViW53ugifsjTrLCGzpX4GVynBxPsJ2lO5nJyYR797J39DY5Jlo+qXgosF/OXicy11JR79zXY6MsRw8NtNxQ== 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)(5660300002)(70586007)(83380400001)(36756003)(54906003)(426003)(110136005)(316002)(86362001)(4326008)(8676002)(2616005)(70206006)(2906002)(44832011)(7696005)(82310400003)(508600001)(1076003)(6666004)(26005)(81166007)(36860700001)(186003)(8936002)(336012)(47076005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:28:55.1647 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4df38fb4-1115-4a00-c0a5-08d951b28082 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4377 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468166266100001 Content-Type: text/plain; charset="utf-8" alloc_staticmem_pages aims to acquire nr_mfns contiguous pages of static memory. And it is the equivalent of alloc_heap_pages for static memory. Here only covers acquiring pre-configured 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. acquire_domstatic_pages is the equivalent of alloc_domheap_pages for static memory, and it is to acquire nr_mfns contiguous pages of static memo= ry and assign them to one specific domain. It uses acquire_staticmem_pages to acquire nr_mfns pre-configured pages of static memory, then on success, it will use assign_pages to assign those pa= ges to one specific domain. Signed-off-by: Penny Zheng --- v4 change: - moving tlb/cache flush outside of the locked region, considering XSA-364 and reducing the amount of work happening with the heap_lock held - remove MEMF_no_refcount case - make acquire_staticmem_pages/acquire_domstatic_pages being __init --- xen/common/page_alloc.c | 108 +++++++++++++++++++++++++++++++++++++++- xen/include/xen/mm.h | 3 ++ 2 files changed, 109 insertions(+), 2 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index e279c6f713..b0edaf12b3 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 CONFIG_STATIC_MEMORY +#define PGC_reserved 0 +#endif + /* * Comma-separated list of hexadecimal page numbers containing bad bytes. * e.g. 'badpage=3D0x3f45,0x8a321'. @@ -1065,6 +1069,73 @@ static struct page_info *alloc_heap_pages( return pg; } =20 +#ifdef CONFIG_STATIC_MEMORY +/* + * Acquire nr_mfns contiguous reserved pages, starting at #smfn, of + * static memory. + */ +static struct page_info * __init acquire_staticmem_pages(unsigned long nr_= mfns, + mfn_t smfn, + unsigned int memf= lags) +{ + bool need_tlbflush =3D false; + uint32_t tlbflush_timestamp =3D 0; + unsigned long i; + struct page_info *pg; + + /* For now, it only supports pre-configured static memory. */ + if ( !mfn_valid(smfn) || !nr_mfns ) + return NULL; + + spin_lock(&heap_lock); + + pg =3D mfn_to_page(smfn); + + for ( i =3D 0; i < nr_mfns; i++ ) + { + /* + * Reference count must continuously be zero for free pages + * of static memory(PGC_reserved). + */ + 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(page_to_mfn(pg + i)), + pg[i].count_info, pg[i].tlbflush_timestamp); + BUG(); + } + + if ( !(memflags & MEMF_no_tlbflush) ) + accumulate_tlbflush(&need_tlbflush, &pg[i], + &tlbflush_timestamp); + + /* + * 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; +} +#endif + /* Remove any offlined page in the buddy pointed to by head. */ static int reserve_offlined_page(struct page_info *head) { @@ -2306,7 +2377,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++; } @@ -2345,7 +2416,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 @@ -2411,6 +2483,38 @@ struct page_info *alloc_domheap_pages( return pg; } =20 +#ifdef CONFIG_STATIC_MEMORY +/* + * Acquire nr_mfns contiguous pages, starting at #smfn, of static memory, + * then assign them to one specific domain #d. + */ +struct page_info * __init acquire_domstatic_pages(struct domain *d, + unsigned long nr_mfns, + mfn_t smfn, unsigned int= memflags) +{ + struct page_info *pg =3D NULL; + + ASSERT(!in_irq()); + + pg =3D acquire_staticmem_pages(nr_mfns, smfn, memflags); + if ( !pg ) + return NULL; + + /* + * MEMF_no_owner/MEMF_no_refcount cases are missing here because + * right now, acquired static memory is only for guest RAM. + */ + ASSERT(d); + if ( assign_pages(pg, nr_mfns, d, memflags) ) + { + free_staticmem_pages(pg, nr_mfns, memflags & MEMF_no_scrub); + return NULL; + } + + return pg; +} +#endif + void free_domheap_pages(struct page_info *pg, unsigned int order) { struct domain *d =3D page_get_owner(pg); diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 2e75cdcbb7..62e8e2ad61 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -89,6 +89,9 @@ 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); +struct page_info *acquire_domstatic_pages(struct domain *d, + unsigned long nr_mfns, mfn_t smf= n, + unsigned int memflags); #endif =20 /* Map machine page range in Xen virtual address space. */ --=20 2.25.1 From nobody Thu May 2 19:42:08 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=1627468162; cv=pass; d=zohomail.com; s=zohoarc; b=JT23MBWNFMWzYoEOZeBRqr571sG8WGYpvD/wWn+J8TfcsqG1i6Un94wRHHvK053MVNTCdIO0PtWvm7SLRbH9YmV6un3skaNMBWwCOONBwCTttffOBvAVTlrZLQSfAl9towKWpIXumso/2/RcA/H+sdEAC+3zECSSeujB6XOGHNE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468162; 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=NY6M4tUyN/50lC3m48HvlUq9t50qEgCk7Ith9fpSm7s=; b=ZMez/pn/R78Gn0pXZIEe7Tm/DwPb4TYOUqtTSeiDytvM4Whij5OoM12gKxJnc6vqWi0A2xHlTJt//0FDwDdbOFq/0t4m8akdFh4eODku56DeK/aM4IJ6qp6s1ru40QKOvaT09rmtEdRCYSD0Ggd7G2sU1dtOZNYJN9bt5Mg+TYc= 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 1627468162198386.71549375369045; Wed, 28 Jul 2021 03:29:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161431.296474 (Exim 4.92) (envelope-from ) id 1m8goG-000797-56; Wed, 28 Jul 2021 10:29:08 +0000 Received: by outflank-mailman (output) from mailman id 161431.296474; Wed, 28 Jul 2021 10:29:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8goF-00078o-W9; Wed, 28 Jul 2021 10:29:08 +0000 Received: by outflank-mailman (input) for mailman id 161431; Wed, 28 Jul 2021 10:29:06 +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 1m8goE-0004GY-Db for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:29:06 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (unknown [40.107.13.45]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9f30213a-ef8e-11eb-9786-12813bfff9fa; Wed, 28 Jul 2021 10:29:00 +0000 (UTC) Received: from DB6PR0501CA0032.eurprd05.prod.outlook.com (2603:10a6:4:67::18) by DBBPR08MB4664.eurprd08.prod.outlook.com (2603:10a6:10:f1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.28; Wed, 28 Jul 2021 10:28:58 +0000 Received: from DB5EUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:67:cafe::dc) by DB6PR0501CA0032.outlook.office365.com (2603:10a6:4:67::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:58 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT055.mail.protection.outlook.com (10.152.21.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:58 +0000 Received: ("Tessian outbound 4c02392472aa:v100"); Wed, 28 Jul 2021 10:28:58 +0000 Received: from 0a90fa88718a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DF3CE0E7-471F-436F-A75B-44B4148534DC.1; Wed, 28 Jul 2021 10:28:52 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0a90fa88718a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:28:52 +0000 Received: from AM5P194CA0014.EURP194.PROD.OUTLOOK.COM (2603:10a6:203:8f::24) by DBBPR08MB4396.eurprd08.prod.outlook.com (2603:10a6:10:ca::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.29; Wed, 28 Jul 2021 10:28:49 +0000 Received: from VE1EUR03FT013.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:8f:cafe::2c) by AM5P194CA0014.outlook.office365.com (2603:10a6:203:8f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:28:49 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT013.mail.protection.outlook.com (10.152.19.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:48 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:46 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28:46 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28:43 +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: 9f30213a-ef8e-11eb-9786-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=NY6M4tUyN/50lC3m48HvlUq9t50qEgCk7Ith9fpSm7s=; b=nWfaews+3X11Kbpn1UT3p7oatmDZKFyHS7eJnr9NDci4Xn3QOUULzS7d6JLOkxGNyhsrEigEhkxbSBmf0ZtJDHblFkweB8oIPdizfXLQJQ/GanemQo2p/TsziVqPd/Ou/Nn8DFVR6fkZAmR5+76wlobB19/2WclNxNOVh2MGeBc= 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: e7c45a9ccae45962 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RWKe90ax3Y/8iTcUHsN5DJHjyJ17nsuWnv98DKaqoo6oUvHwc/sNkfSKB94QJByWRfJFsjjY/aW/TSDejSfDLA4s/PvSoBWkKP190u9YxBOpGJyD40A1zoc+B25H2An+sGOHQBM3JF8ruCnkc/m5unoJNkeYC29Z/bXwBBJc2UceT4k3juhE1GofVQjuZUZ2buL8On+SH79GSC1xOC7vyI0AAzM2Ch+IuWoiAsaY95PA2jAX0ZU3OCucaPjcbgOdyPvlyHXQhL6iPPxdpGya+jL9JY9VcGfL4V76kawfCJ7rYK9MQiv2pwhRj+uS0qiw8cIuF8BcjDFxD8R9bm5NRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NY6M4tUyN/50lC3m48HvlUq9t50qEgCk7Ith9fpSm7s=; b=mQP7zKs8FSuMjUkj9TN2gNf2IqhdiuvVW4ImmD702S7s19eVdWBSf3H7/vQZbqi0sZl+PKm0MfX8mq3ymDYlH1SZqgGsjbnIP0xS9V/ek1AjDHU9f5jMDCEQd+PmgBqZ8OtagvZqcO1d2gilYoVvxcTVoHkEso4ZJI02tghKM21GSM9XdDD7LdqBWOV8VyqkGTkqdLMw7FuVcJrw7NPxC+vMNIRFXWE/ECXxyBHM360/u0csF0sEoXZioDBZkKUlZLEV1JsNrxUdzKLEx9em64OW9IkRh5/e4geVv2z7Qk+u8NC+GNGLObHXMLxfJOQYnsvndQxwosQvFLuPy+YWKg== 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=NY6M4tUyN/50lC3m48HvlUq9t50qEgCk7Ith9fpSm7s=; b=nWfaews+3X11Kbpn1UT3p7oatmDZKFyHS7eJnr9NDci4Xn3QOUULzS7d6JLOkxGNyhsrEigEhkxbSBmf0ZtJDHblFkweB8oIPdizfXLQJQ/GanemQo2p/TsziVqPd/Ou/Nn8DFVR6fkZAmR5+76wlobB19/2WclNxNOVh2MGeBc= 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 V4 09/10] xen/arm: check "xen,static-mem" property during domain construction Date: Wed, 28 Jul 2021 10:27:56 +0000 Message-ID: <20210728102758.3269446-10-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: b83d1186-d625-47b0-dd4e-08d951b28293 X-MS-TrafficTypeDiagnostic: DBBPR08MB4396:|DBBPR08MB4664: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1247;OLM:1247; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: RjoxI3ZCuF1F94ievRPklFyIrC+PLMIVq8iOrRmBwO8bcA7/fEKkwKRCDYUx1haTe+8yXnMZoQe79g2IejrwkF8yF1Rt0dOY8nhanS3bXpzI3NNmFn1VUN2cNzwejwy9WZnFb3QfpYpfCf25/1Nw5yFvIwcLpIHJfJkd6d8q0uRt7ewVVx1UDz/7UP0wA7PZCDVPGuDYpmAnvzSX4p7DH68xNThZIVY2/Cvn6GlSPzDSKBeeCpfSO4EbAy3/TX+XorTCkRT6SOt+Ko1148ZxonBJ0pm2T5oZ004QZyb++1ad8/BahhF0IZvvyhniqLwmPbdhGq9vRzXOedw8b/CBWfRieDnVB4ZC8hZpYg3laT6zvJPuyVnpRDptKy+3AkOOlLKsrUHbZEDf7qAbAL6hmmWGgmMT27ifLwXTcsle1lUVzs1F+EAGTbuvwEMMq9Eoz+aefi344ONCCg5aGa96LRYpuHcNS8VUWFgn/ajVhZ0n+PedCOhhzeh9NHxpxnDtAdvYfbbJbwhYfbj8eySn7CFaAnwBLiXeZ7jKi4XU5ytBm821Dn5y33eZJ5/BjD275aBdRZa0FkGKkMf5A9dmsGKV/Nmsvng0v9639Ojx8SpLqoRPIDnCEfJOdCqzvSNQCnZGsdjrgYa2dGZqWBsFFYssHJKlYb+ogk1mkX+xRZ4I3EpL5MxMLjwe6Uj5iSgJ15lEHfysINwNFOlUCp4I9SkrohK1E+HL8XyY/lybLbA= 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)(36840700001)(46966006)(1076003)(82740400003)(110136005)(8676002)(47076005)(86362001)(316002)(2906002)(336012)(36756003)(426003)(4326008)(44832011)(70586007)(70206006)(83380400001)(6666004)(26005)(7696005)(8936002)(36860700001)(478600001)(186003)(5660300002)(356005)(2616005)(82310400003)(54906003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4396 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5fcf034b-7de1-4f83-356f-08d951b27ccc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xu78GFPTx02XKBUA0PYOQaBVH8fnAFmiodZ2GAJ4cHAebPDw0lUz2bsLBeq2qfcpewGue2DZRUUZ4QX/UoX+rz86b5kfCY0hNywJws3O3kjVHqaZWt/1B/uN6bWeSrr1IvT/u8RS+X8oZmj2vDJFFzGyNlbrQUKGforiXPU1NDoenBaud3KkX4nsoVVPRTu/7HRTKxTT2YYEpH6OuYeYYQQ8ygKx5iMbQJK7RYLlDHsur4o4esZ8avwV244XWfsX8D9/xyLawNuSZMDSidyuipjiBSDMAEFOLaeB4UF8L70ONx07IsYwLTkScvwprJwFLMEfkRWG6zixYQuwe+2K5H/LtTXaZNdomuVj3/gudUF5wYEcoGaBOrXbylzGwVmkWiXRGdh4JAArIxN6fYcmZVFcIRortoQepHX69YAHgRbQj8sWumVXp5bampgm8cyj7IIuACcVlK+vekwQhIXOZp3Mp3jWnCGvoKvOszQgSok0SUw2ozbt1TAtJb9ghnE6xD5i9ChUMLWOCtl+1z9QcFJqOksDsYTGeWtrA04x/Ysl1SYIM0nDACV/oELysxRpv5g+C4UpgZUcOpw5Jg7KjJlYGSHWFzQ+/VgchggoZkwbapRNNsA4x3i9YmyW2SS+64uAe3ta6QqKxjbiLeOVtdPdwMiY1iT/2u/E6ZUML6H8KE358WHFkxGGa19DsLVO496S3ZS7gTUpmP9TJf2CpQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(376002)(396003)(346002)(39860400002)(136003)(46966006)(36840700001)(44832011)(7696005)(81166007)(36756003)(70206006)(2906002)(6666004)(70586007)(336012)(36860700001)(26005)(82740400003)(426003)(2616005)(186003)(1076003)(110136005)(86362001)(82310400003)(47076005)(316002)(478600001)(8936002)(8676002)(83380400001)(4326008)(54906003)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:28:58.6312 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b83d1186-d625-47b0-dd4e-08d951b28293 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: DB5EUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4664 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468163981100005 Content-Type: text/plain; charset="utf-8" This commit checks "xen,static-mem" device tree property in /domUx node, to determine whether domain is on Static Allocation, when constructing domain during boot-up. Right now, the implementation of allocate_static_memory is missing, and will be introduced later. It just BUG() out at the moment. Signed-off-by: Penny Zheng --- xen/arch/arm/domain_build.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 6c86d52781..cdb16f2086 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -2425,6 +2425,37 @@ static int __init construct_domU(struct domain *d, struct kernel_info kinfo =3D {}; int rc; u64 mem; + const struct dt_property *static_mem_prop; + u32 static_mem_addr_cells, static_mem_size_cells; + bool static_mem =3D false; + + /* + * Guest RAM could be static memory which will be specified through + * "xen,static-mem" property. + */ + static_mem_prop =3D dt_find_property(node, "xen,static-mem", NULL); + if ( static_mem_prop ) + { + static_mem =3D true; + + if ( !dt_property_read_u32(node, "#xen,static-mem-address-cells", + &static_mem_addr_cells) ) + { + printk("Error building DomU: cannot read " + "\"#xen,static-mem-address-cells\" property\n"); + return -EINVAL; + } + + if ( !dt_property_read_u32(node, "#xen,static-mem-size-cells", + &static_mem_size_cells) ) + { + printk("Error building DomU: cannot read " + "\"#xen,static-mem-size-cells\" property\n"); + return -EINVAL; + } + + BUG_ON(static_mem_size_cells > 2 || static_mem_addr_cells > 2); + } =20 rc =3D dt_property_read_u64(node, "memory", &mem); if ( !rc ) @@ -2452,7 +2483,11 @@ 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 ( !static_mem ) + allocate_memory(d, &kinfo); + else + /* TODO: allocate_static_memory(...). */ + BUG(); =20 rc =3D prepare_dtb_domU(d, &kinfo); if ( rc < 0 ) --=20 2.25.1 From nobody Thu May 2 19:42:08 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=1627468599; cv=pass; d=zohomail.com; s=zohoarc; b=dnAH5pQbdfpQsrKoDZdBc9j73UMHLlcFKRIVcFEFQ1ZhC6ah1e9uldaQMt/7S2bEdlezl+UAP/kGoGYzCBylefxLlbwTxUZcWoSPRCkAEeQiS8R3fw5g3gmJxmKVzuZnZSO8+Sm031OGRCYl4syCQT6D3CBSne5WZpb3TuNAc+Y= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627468599; 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=zmfA8FI6NfA6jk+mUsEPar1jSj8DwHYRvwaxcZozXR0=; b=kq+M6pPjPscm/TuiauKayNHvgKzetvvmvTm49S9jDVdZ9Kk6kYPvHI7TgeCeOhjmmCYidlNQyOcU0E7qFk1tVjOZu54DZ2Yq+ytE0hM/hGppEtPeM8k6okrOELDLMiTFgvje+NV9EBoe4C8BctlDGmBJw/QmutMz5WG7btiR9pk= 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 1627468599640389.71713066483426; Wed, 28 Jul 2021 03:36:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.161487.296498 (Exim 4.92) (envelope-from ) id 1m8gvB-0002jW-VW; Wed, 28 Jul 2021 10:36:17 +0000 Received: by outflank-mailman (output) from mailman id 161487.296498; Wed, 28 Jul 2021 10:36:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8gvB-0002jP-RJ; Wed, 28 Jul 2021 10:36:17 +0000 Received: by outflank-mailman (input) for mailman id 161487; Wed, 28 Jul 2021 10:36:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m8gpE-00040B-LL for xen-devel@lists.xenproject.org; Wed, 28 Jul 2021 10:30:08 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [40.107.8.84]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 131e452d-64c3-4b00-827f-6313ab349ef9; Wed, 28 Jul 2021 10:29:18 +0000 (UTC) Received: from AM5P194CA0004.EURP194.PROD.OUTLOOK.COM (2603:10a6:203:8f::14) by PAXPR08MB6640.eurprd08.prod.outlook.com (2603:10a6:102:dd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.31; Wed, 28 Jul 2021 10:29:16 +0000 Received: from VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:8f:cafe::f1) by AM5P194CA0004.outlook.office365.com (2603:10a6:203:8f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Wed, 28 Jul 2021 10:29:16 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT034.mail.protection.outlook.com (10.152.18.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:29:16 +0000 Received: ("Tessian outbound 5f693336bfca:v100"); Wed, 28 Jul 2021 10:29:16 +0000 Received: from 2138220fbbc3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7991EE38-FE34-4992-8030-BC24FB0D102F.1; Wed, 28 Jul 2021 10:29:00 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2138220fbbc3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Jul 2021 10:29:00 +0000 Received: from AM0PR01CA0174.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::43) by DBBPR08MB4680.eurprd08.prod.outlook.com (2603:10a6:10:f2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25; Wed, 28 Jul 2021 10:28:55 +0000 Received: from VE1EUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:aa:cafe::e) by AM0PR01CA0174.outlook.office365.com (2603:10a6:208:aa::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17 via Frontend Transport; Wed, 28 Jul 2021 10:28:55 +0000 Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT021.mail.protection.outlook.com (10.152.18.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4352.24 via Frontend Transport; Wed, 28 Jul 2021 10:28:55 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 28 Jul 2021 10:28: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.2176.14 via Frontend Transport; Wed, 28 Jul 2021 10:28: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: 131e452d-64c3-4b00-827f-6313ab349ef9 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=zmfA8FI6NfA6jk+mUsEPar1jSj8DwHYRvwaxcZozXR0=; b=Ov+IgAkkiymNH2HrNKEbqK0CKTFXs1/zywa/uPQx2mOBXnu8098MrCMPp7kHGGBP/eYXuEtuc37JWGckZsaU6DS2+RrszWpQHmof8jpbCqOu16WtKe5SS0ZmUh3Wa3Q/YJI2Jd9OI7DUOBKt1LcsNvryoifHB+EAkglslTEEQGQ= 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: ede5a8212e535404 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hqOFJFFScCBjg13P7XZo4I8zLATBuyXPHiR0hdanesT8r/IK68eyGJ6rf6W/12lADPpALsr+1mrG/Nn+JO6VrK0eymMBtBAbxQoevxWi5y2BB+txxbjf1Xdm+llmdJR7XLJ9LTkfWZqW7lq0CP9u+7yhIFjmf2iG0PJjTeFtEN2Nhx1lBW1DaMif8ZM/mjiZxRk1xJdGZvJXs1HdPGmGTxpGocvZS2x2JGkVXkQ81g/6k+CIkGgrExLIndeYE1MSTseCvllImBzzYk1P5WyEg6EeSPJ4X+RdUUIIxqFiJrxxv0STdT1KFABdPqfT60638MLjtvpEJ6VlCuu3pOZjgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zmfA8FI6NfA6jk+mUsEPar1jSj8DwHYRvwaxcZozXR0=; b=CICbhL3wwLtJY9wHff7uycFCWz7K94KX/sphI0N3xRpcLqPmGbNdPR9VaLNTWUUobPpFYAbFXBuevMd+KLFWaef6X33TZdZCF6AO+cfkyZGsDjnRzTfelK7FmkbRMuh9lRqVAFOzV0coNaeySsihOdWji3wXB8poEcYeOqi8b63mUssH00TI9Nx6YAggcoPvgGbiaE4CgabBtQNoN1B632JpMeqQlKn/GYSwI5gfbaJT7qEH6vF4bxv0GNeigsEgkhLSm2+siI94gdtnn6Lito3iM+dwiYRlXiGVp0+SCvvYnxXBik3qRO6JIl9JzzHhMXtCkrPXnFFa1X0o1NBpdA== 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=zmfA8FI6NfA6jk+mUsEPar1jSj8DwHYRvwaxcZozXR0=; b=Ov+IgAkkiymNH2HrNKEbqK0CKTFXs1/zywa/uPQx2mOBXnu8098MrCMPp7kHGGBP/eYXuEtuc37JWGckZsaU6DS2+RrszWpQHmof8jpbCqOu16WtKe5SS0ZmUh3Wa3Q/YJI2Jd9OI7DUOBKt1LcsNvryoifHB+EAkglslTEEQGQ= 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 V4 10/10] xen/arm: introduce allocate_static_memory Date: Wed, 28 Jul 2021 10:27:57 +0000 Message-ID: <20210728102758.3269446-11-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728102758.3269446-1-penny.zheng@arm.com> References: <20210728102758.3269446-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: 69e4e19d-d314-416c-40fa-08d951b28d4d X-MS-TrafficTypeDiagnostic: DBBPR08MB4680:|PAXPR08MB6640: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:5236;OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: qy+SqIJMljWZq4WXRnsLjlmyzWsvPw1aTOeahNw0ww2wFLT5zLlkhaP7YTJ0ytKFBWnsS0LuoyHvg6okeF120hq/uRTbVZ9goMfmSkmiMEMvVulWoGesgSvOCGko/J3wbbHbteH9nWB9IX/IhJejPZcMpioCyl6W3w11s3y2oi4n337QFzEGzoOJ2ifGvJN1mQQIId3e613W74dTmaac++9RWHLvS2qq2Cta7ktFT6JiGX0sh2VJqrR7V616s1aTHKzKw66rQimblHwUGMnMhrJ85/yn/XUdd9xtIWAAJrsjFqGmlJSQCdSzaVFBReIWCZzkXUpn1zc+brO4I8Z1JJCLRUVgVK4M6lS69Re2MHB7AzOpA4FMm01d2fCoAN6nmKhzNcFOPmDY8+kmaBJ6Yr5bnKPCubdav7Tk9LgaSx7/OT9lUgiu67VVQSLtICt2PpirIJ3yj46Wsv3tx9Cd+MajnuyBpOfavFqmZg40QP29kf9/MUXjhqhRc0BjRO+k+00gHCB5MAGiCkSmk5vonIC26puX6cS1+uCM+TXYN/s0h00jzmYWEuNjRA97eCE6eX540MF8XL94PUY1hTnyLiV+nu3d2tk9pQj0ezt5dUWvTerYorXRpvGsJxIGZ9H4f23DucmA5Zac+Hzkt/pEMlIol5wddD8BXGYYFfw79bhYoVxQ7//QZn2H/N9F1Or/6OkDJArdKWs5xsV7FUVNV8KOrZ8silfGZhkPTtwEWRo= 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)(39850400004)(346002)(396003)(376002)(46966006)(36840700001)(86362001)(70586007)(8676002)(82310400003)(478600001)(356005)(36860700001)(4326008)(83380400001)(2616005)(316002)(54906003)(2906002)(70206006)(47076005)(7696005)(36756003)(81166007)(5660300002)(82740400003)(26005)(44832011)(110136005)(426003)(336012)(8936002)(6666004)(186003)(1076003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4680 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 9a2909e2-a171-4ab7-7b85-08d951b280c4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d+8GA8hk7+6jn/onCm/zeWtFVTxVjySQs8C8MNy+NCtRtafJlDOJFOaJhrnem3MqOAD1rJYtYW7jEgsIUlXhtPEpXaDe/Ju7Jcfjp53DikDhWVJikUDgbXSC8BJ+4ZKlQPG9Bd8B/9haKEpm/jHeKXR/S/gazRY1LmOt8ailGglsUWZzlFMIhKQZwfevHHvCkLwikrJmNVsliRfbaurqr/I3Vk+tgAe1DUNrPddFGhLqMTWPPRr0FjiS0Ii7PMWSnYnwwpZWVyLxSK8huuC2j5PK9yK0IFsCbFwulYMrhbBb55A90n8u/KuWUw52yfgyQEJ5TE35YbdtmasUW8DZKy/NXePHg9AYxWq9mwUgxOUgkFV77bz2n3VEL4xiv3uAjI666CaWSNTQeC9/LoreSQZgFgQ70VqnA2dZvJ+hTn6/QME3tEqDLUctnXMe8vQZnP5D/rLcXTNnZvlyYbc838wk0rc7snLU1I6MpHZWmp7XtSveZPuYl5g2oB4YSc31orqmbWgTpe6xUiM4ToSwLUneuJK3gCEPzQulxogGVu99prTx4CLCtoXja4s93g49l6iFcJfpZ5fL2w1aSh41k+UccNCmU9J7jVMNasgCOhozMg8fe6j6PLRbWLoEh7cXceZlYp/lOzF2n7agVTFYiOjGFZezwoIrF88urNd44pBEEHvStmPIgDblEAbeqBX2ciB9P9T8JRISGXLqUEOdGg== 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)(2906002)(82310400003)(54906003)(186003)(83380400001)(36756003)(44832011)(8676002)(86362001)(81166007)(70206006)(26005)(7696005)(2616005)(4326008)(6666004)(336012)(70586007)(36860700001)(508600001)(8936002)(1076003)(47076005)(5660300002)(316002)(110136005)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2021 10:29:16.5058 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69e4e19d-d314-416c-40fa-08d951b28d4d 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: VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6640 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1627468601631100001 Content-Type: text/plain; charset="utf-8" This commit introduces allocate_static_memory to allocate static memory as guest RAM for Domain on Static Allocation. It uses acquire_domstatic_pages to acquire pre-configured static memory for this domain, and uses guest_physmap_add_page to set up P2M table. These pre-defined static memory banks shall be firstly mapped to the fixed guest RAM address `GUEST_RAM0_BASE`. And until it exhausts the `GUEST_RAM0_SIZE`, it will seek to `GUEST_RAM1_BASE`, and so on. `GUEST_RAM0` may take up several pre-defined physical RAM regions. Signed-off-by: Penny Zheng --- xen/arch/arm/domain_build.c | 137 +++++++++++++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index cdb16f2086..ed290ee31b 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -480,6 +480,139 @@ fail: (unsigned long)kinfo->unassigned_mem >> 10); } =20 +static bool __init append_static_memory_to_bank(struct domain *d, + struct membank *bank, + mfn_t smfn, + paddr_t size) +{ + int res; + paddr_t tot_size =3D size; + /* Infer next GFN. */ + gfn_t sgfn =3D gaddr_to_gfn(bank->start + bank->size); + + while ( tot_size > 0 ) + { + unsigned int order =3D get_allocation_size(tot_size); + + res =3D guest_physmap_add_page(d, sgfn, smfn, order); + if ( res ) + { + dprintk(XENLOG_ERR, "Failed map pages to DOMU: %d", res); + return false; + } + + smfn =3D mfn_add(smfn, 1UL << order); + tot_size -=3D (1UL << (PAGE_SHIFT + order)); + } + + 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_property *prop, + u32 addr_cells, u32 size_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; + u32 reg_cells =3D addr_cells + size_cells; + u64 tot_size =3D 0; + paddr_t pbase, psize, gsize; + mfn_t smfn; + + /* Start with GUEST_RAM0. */ + kinfo->mem.nr_banks =3D 0; + 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)); + BUG_ON(nr_banks > NR_MEM_BANKS); + + while ( bank < nr_banks ) + { + device_tree_get_reg(&cell, addr_cells, size_cells, &pbase, &psize); + tot_size +=3D psize; + smfn =3D maddr_to_mfn(pbase); + + if ( !acquire_domstatic_pages(d, psize >> PAGE_SHIFT, smfn, 0) ) + { + printk(XENLOG_ERR + "%pd: cannot acquire static memory " + "(0x%"PRIpaddr" - 0x%"PRIpaddr").\n", + d, pbase, pbase + psize); + goto fail; + } + + printk(XENLOG_INFO "%pd: STATIC BANK[%d] %#"PRIpaddr"-%#"PRIpaddr"= \n", + d, bank, pbase, pbase + psize); + + /* + * It shall be mapped to the fixed guest RAM address rambase[i], + * And until it exhausts the ramsize[i], it will seek to the next + * rambase[i+1]. + */ + while ( 1 ) + { + /* + * The current physical bank is fully mapped. + * Handle the next physical bank. + */ + if ( gsize >=3D psize ) + { + if ( !append_static_memory_to_bank(d, &kinfo->mem.bank[gba= nk], + smfn, psize) ) + goto fail; + + gsize =3D gsize - psize; + bank++; + break; + } + /* + * Current guest bank memory is not enough to map. + * Check if we have another guest bank available. + * gbank refers guest memory bank index. + */ + else if ( (gbank + 2) > GUEST_RAM_BANKS ) { + printk("Exhausted the number of guest bank\n"); + goto fail; + } + else + { + if ( !append_static_memory_to_bank(d, &kinfo->mem.bank[gba= nk], + smfn, gsize) ) + goto fail; + + 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]; + } + } + } + + kinfo->mem.nr_banks =3D ++gbank; + kinfo->unassigned_mem -=3D tot_size; + if ( kinfo->unassigned_mem ) + printk(XENLOG_ERR + "Size of \"memory\" property doesn't match up with the ones= " + "defined in \"xen,static-mem\".\n"); + + return; + +fail: + panic("Failed to allocate requested static memory for domain %pd." + "Fix the VMs configurations.\n", + d); +} + static int __init write_properties(struct domain *d, struct kernel_info *k= info, const struct dt_device_node *node) { @@ -2486,8 +2619,8 @@ static int __init construct_domU(struct domain *d, if ( !static_mem ) allocate_memory(d, &kinfo); else - /* TODO: allocate_static_memory(...). */ - BUG(); + allocate_static_memory(d, &kinfo, static_mem_prop, + static_mem_addr_cells, static_mem_size_cell= s); =20 rc =3D prepare_dtb_domU(d, &kinfo); if ( rc < 0 ) --=20 2.25.1