From nobody Sat May 4 12:28:43 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=1626326356; cv=pass; d=zohomail.com; s=zohoarc; b=SjwWEC6wcM5quBBZnTbnpX0LnrbeqeuCIkwHdgBeztOrN7L11ZqnPRKQquwKjn14bd3O2lqEeASaY2OAMjsyudLQEwO2hrhvY4cpoKjfnPNXL4YcL69xTiBz+NKhSWAOCmWtvb3pARDWTC1+jm1uve6Iz+PCLqMZqcHxyz3CNZo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626326356; 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=Iful6SKFh5yAFK5a8vc6iLO1PFy2rWyY82gDbNfEiXM=; b=GDHMqCzgjD4smcFR1CMGQtiJuk5RxB1NlKhMZkF+Yv4s8kKMLLxAqvOwytgJ2rjcP2nm9YGa83VR/4AXwfaVHGMsnvTGaBsr2t5U178ZvyXjHRSn6ifRmilh2Z7xdRa1mEcCi/DExXr6WMDTx3MlE2nzD6W6oiNSFKZ+jA888rs= 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 1626326356691849.7988933176633; Wed, 14 Jul 2021 22:19:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.156292.288405 (Exim 4.92) (envelope-from ) id 1m3tlm-00084F-2S; Thu, 15 Jul 2021 05:18:46 +0000 Received: by outflank-mailman (output) from mailman id 156292.288405; Thu, 15 Jul 2021 05:18:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tll-000848-UY; Thu, 15 Jul 2021 05:18:45 +0000 Received: by outflank-mailman (input) for mailman id 156292; Thu, 15 Jul 2021 05:18:44 +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 1m3tlk-00083i-ND for xen-devel@lists.xenproject.org; Thu, 15 Jul 2021 05:18:44 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown [40.107.21.63]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1f13d1fc-e52c-11eb-8891-12813bfff9fa; Thu, 15 Jul 2021 05:18:43 +0000 (UTC) Received: from AS8PR04CA0082.eurprd04.prod.outlook.com (2603:10a6:20b:313::27) by AM6PR08MB3798.eurprd08.prod.outlook.com (2603:10a6:20b:82::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Thu, 15 Jul 2021 05:18:37 +0000 Received: from AM5EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:313:cafe::21) by AS8PR04CA0082.outlook.office365.com (2603:10a6:20b:313::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:37 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT004.mail.protection.outlook.com (10.152.16.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:36 +0000 Received: ("Tessian outbound b81a99a0393d:v99"); Thu, 15 Jul 2021 05:18:36 +0000 Received: from 5290271f0273.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 47E4E018-3139-41CF-A2CB-CB8DA517D4A9.1; Thu, 15 Jul 2021 05:18:30 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5290271f0273.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Jul 2021 05:18:30 +0000 Received: from DB8PR06CA0066.eurprd06.prod.outlook.com (2603:10a6:10:120::40) by AM5PR0802MB2451.eurprd08.prod.outlook.com (2603:10a6:203:9d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.25; Thu, 15 Jul 2021 05:18:28 +0000 Received: from DB5EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:120:cafe::f) by DB8PR06CA0066.outlook.office365.com (2603:10a6:10:120::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:28 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT023.mail.protection.outlook.com (10.152.20.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18: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; Thu, 15 Jul 2021 05:18:26 +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; Thu, 15 Jul 2021 05:18: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: 1f13d1fc-e52c-11eb-8891-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=Iful6SKFh5yAFK5a8vc6iLO1PFy2rWyY82gDbNfEiXM=; b=K0JIJPdHtmuwaELCHS2rq4MBVeulibfFEJQukUh2GglwO9cvRLDVYo/1v8c/swtdwsZXNbexC8S5jMSbbCC4WaPBV860qQtXxbmk6c8fWvBbtNM2osY8MgMWPSFewSVArSY3MDSS3MxIbZCGo2MJcLeZXwZmXgvzMayIrH299ZM= 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: 1763cc68dc876658 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FsDnvUay8FYop8XcCtpK6Jyq0Jjr3DbxssatqHICHkjR8aHC3tziohSgvHS9AQMLpVbhQ+kAGoW9oA2EzjXTdojgvG2xau6Wfq6PgXqqU1nfSJCQawLp5wPVhW6fGvxZfNZAL1fbcYXqSgKj5D2KTZ34qjMYZtr4EKMQL8qx1pi/WHtMN/tV2JPX4hEt1f6Z8fSmJZ9eXQG+/ZAZEGCSOZuvuzMAVEVuB+yzkoB3zOOgJQWDjHfb9hqkz8eKCDuzggQWqG3xuJFuNl5/AMdGJ6ZG5+kx5yrWAU1aPgVolteXJ/6yw16clepruZwEqZmn+MTHM9hGPBCxZJgh7dJJXw== 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=Iful6SKFh5yAFK5a8vc6iLO1PFy2rWyY82gDbNfEiXM=; b=FEz99fMg+o/ruZLT72I+rn7qJx87+RedUuGNjBA4Uv9XnU/5h2NxFJc1iZvSVnWCa3uP41uaP+69626FyVzHbE8gcJ3fDaLy1oM4eDvaYR9aabpUjwxWDB52uTxghRgq6hnVGl3Z4WtZ3n0EVaYTFhjXtpS9Jr5r2XFDGYFXxGocpv/bMMvg+840OPTR/66vialB/UOOuUGxE891TAOgkmsS3d9ZXlG72ry+tvrTQtDH+gmuc9E0I4zOcGtqSuQzCIeydt9DICA60Cp6nYYg77EWVYf3MGIkkAiD7hL9geQN46g4CxFjKxrZqi6T1uF/xlJjgzq8J9NrDei1E/qpWQ== 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=Iful6SKFh5yAFK5a8vc6iLO1PFy2rWyY82gDbNfEiXM=; b=K0JIJPdHtmuwaELCHS2rq4MBVeulibfFEJQukUh2GglwO9cvRLDVYo/1v8c/swtdwsZXNbexC8S5jMSbbCC4WaPBV860qQtXxbmk6c8fWvBbtNM2osY8MgMWPSFewSVArSY3MDSS3MxIbZCGo2MJcLeZXwZmXgvzMayIrH299ZM= 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 V3 01/10] xen/arm: introduce domain on Static Allocation Date: Thu, 15 Jul 2021 05:18:10 +0000 Message-ID: <20210715051819.3073628-2-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210715051819.3073628-1-penny.zheng@arm.com> References: <20210715051819.3073628-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: 53a6a949-714c-4a9a-6aed-08d9474fffbc X-MS-TrafficTypeDiagnostic: AM5PR0802MB2451:|AM6PR08MB3798: 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: MW2GkbPOErCi9d8aNJPbCFsRjfvCrsNV/AF+Rx2BeVvZBJR60zXuTFMWwcMeTHhAlB9pFL6arF8T071xxsFc9YEWA+CI6Lq9utd805TwaLiLfIGwdldq7HpYbiU8siPLkZLIDeruMx0PVxEXNsc691qt0IfOaxbbnwd7rumguVX4XuY/zlSMUgzApWsPbGF9g9AELfJROrGRpdD69h6Xjs6/JtsQ9KA2wKsZIJal1NJmxk4wWwx0cgdxHzN6r5/lWEtySC5Xh+oSItcHfLudPCtzuFSdOXFh1yi/Bw3S7rtaM1PNWcErTs4o2Leos/X2Tntxjovr4se3NEhjnCLi6vSz2fr5bg7Y6QXvMnsNm7YU17ahhBByhlk5dKr0kZgc+NxIMUOYzPcdI17hBEopxas+BRzLF7wY7JdxYBJvW+PdnChR0fGBYYaN1WdufEVCyghoET61zIIxZwxomi4Y3Rq04j0ePWgtuuR3vQAJ/ASDtm6+zuuZZuXBrj5V7w5ZkvBCjFhkH9Bg1PJcWMIAKcPT40BRjK4ikwjJPdfH1XLNGbnytncOaVAGJr+D/NqSJ6E1r0PCqEQzlPNsqehliQR9ypsCfGYM+T4ABxsTtJodDpjO5TyDOW7tTFacRUZWczMsLQ2I7V/phgm7q15vBXf03Ri1FehakOQ1DAgR8Mwh6EUZ0lHHwkYQWqR1KXO3VlzGRyPveAozBUUvCuO5uU8T85CJzF2wUpCvX4CtVBY= 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)(81166007)(26005)(7696005)(478600001)(2616005)(5660300002)(6666004)(82310400003)(356005)(4326008)(2906002)(8676002)(86362001)(316002)(54906003)(186003)(1076003)(8936002)(70586007)(70206006)(36756003)(426003)(36860700001)(110136005)(47076005)(44832011)(336012)(83380400001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2451 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4b840cf3-293c-4fa1-a81b-08d9474ffa6f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ysdv00YuWUpDUQnzYFGngbs/HRb9g5HtUrgpWdnua7CmcQtyfqrI9cx6CqB0xT6hhW7qEwztOt2aR1ltDHAegQp6bdqSWUaoye5GPnYlYpdam6bM7sYGrPcDFLMsXWTvIxZVi1pED2GJvNx71Bcu2ZO5jvqKKXyW7mAYvWhfTCfz1iaqGCiL38aOFFACCgMLSye0ysretIdN16FJFsQaU1EG/GnPVxRcv3qB0vTQLSQ6LvHMPgGT7YkpeljMI/Cp4amj1NAZXuQ9B6JRV6UKqw5HATWQTMHu+PNcJ7N30FuRawrbMyiVQtGNVBZpp+vy2RQa9FqJX1Sta5Y35cSiN3B43FJsLHo9W96WEUXT1tZJIs6qrnEEwG7QBo/lULV4HjXZEVlUerRZXsEAvDezko/FhE37WkH5kjHlrlMmLMxqtkuauBsASRvTDvUBHc+PB4uLwEUJgTxP+BpEUfdKfc7lkiQD+HdEvhaoYlV9cQIFNzL0ESzT5IeWuKjLY/sKAGR7I30AWoClebKCZL2KVNund4cL70ZhF2ibxfmSnJ7ZGI6/DvJQjkyEdAulzxR3keIbL1wTSB7jyRWzVJFYG0e30o+Qo2Le4zL5iri2x8+7egnaEvHIT2yXXRSkc6sMh1qRovpQi0TkL5/pLMHDVQsIdWeYczgvWGr+EVy+rPeLBVnD9h7ig/XxPtdxZCqXloy5gSOfpv1MF18iRPJ8og== 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)(39850400004)(396003)(346002)(136003)(36840700001)(46966006)(54906003)(36860700001)(82310400003)(478600001)(81166007)(7696005)(4326008)(82740400003)(6666004)(86362001)(8936002)(1076003)(110136005)(5660300002)(336012)(316002)(8676002)(36756003)(186003)(70586007)(426003)(70206006)(47076005)(44832011)(2616005)(83380400001)(2906002)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 05:18:36.7583 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53a6a949-714c-4a9a-6aed-08d9474fffbc X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3798 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1626326358271100003 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 --- v3 changes: - use "xen,static-mem" property to be compatible with System Sevice Tree in the future --- 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 Sat May 4 12:28:43 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=1626326358; cv=pass; d=zohomail.com; s=zohoarc; b=TUjDnJT3LzrkICfQPFhaGrX6oSwKdCVMkXNFvNGOIjbLOyhBjzqruuK6eX6vSdARbE4fzO8551WrDTrtgZqF/5k7YYNvWxcDWJPT7bc+GXn9c0Ji32FxGU9PYuy0YWkRGxiOA4FUzT9s8SXHMCP/1Yu+QkKeWYZf6bmAUHGXYRs= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626326358; 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=ShBZR1l2+1pB50YNRs1WMBAcaW77Ie5c4YZKt6TH5cBRbOHK0c6kEpSVuJ3aG+UnIke5cyTr0Dh7+WvjmLCmjTR/bLT8gj+sP2Rve3cr9NUQU9Z1MMi84d+8pXUgzQ8evC8nO3oDMBKo83gZWNwnVjyk/aYFo0bELvO/HMBDuHA= 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 1626326358820623.3952010119398; Wed, 14 Jul 2021 22:19:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.156293.288416 (Exim 4.92) (envelope-from ) id 1m3tlq-0008N4-E2; Thu, 15 Jul 2021 05:18:50 +0000 Received: by outflank-mailman (output) from mailman id 156293.288416; Thu, 15 Jul 2021 05:18: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 1m3tlq-0008Mu-AU; Thu, 15 Jul 2021 05:18:50 +0000 Received: by outflank-mailman (input) for mailman id 156293; Thu, 15 Jul 2021 05:18:49 +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 1m3tlp-00083i-C3 for xen-devel@lists.xenproject.org; Thu, 15 Jul 2021 05:18:49 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (unknown [40.107.7.45]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 21a0c45e-e52c-11eb-8891-12813bfff9fa; Thu, 15 Jul 2021 05:18:47 +0000 (UTC) Received: from AM6P193CA0110.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:85::15) by DB8PR08MB4026.eurprd08.prod.outlook.com (2603:10a6:10:aa::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Thu, 15 Jul 2021 05:18:40 +0000 Received: from AM5EUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:85:cafe::c6) by AM6P193CA0110.outlook.office365.com (2603:10a6:209:85::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23 via Frontend Transport; Thu, 15 Jul 2021 05:18:40 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT026.mail.protection.outlook.com (10.152.16.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:39 +0000 Received: ("Tessian outbound ef2da60907d5:v99"); Thu, 15 Jul 2021 05:18:39 +0000 Received: from 56eed0801f3b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3298B7CB-4162-490A-B382-5CD75E83B8DB.1; Thu, 15 Jul 2021 05:18:33 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 56eed0801f3b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Jul 2021 05:18:33 +0000 Received: from DB8PR06CA0038.eurprd06.prod.outlook.com (2603:10a6:10:120::12) by AM5PR0801MB1987.eurprd08.prod.outlook.com (2603:10a6:203:47::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.25; Thu, 15 Jul 2021 05:18:31 +0000 Received: from DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:120:cafe::93) by DB8PR06CA0038.outlook.office365.com (2603:10a6:10:120::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:31 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT027.mail.protection.outlook.com (10.152.20.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:31 +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; Thu, 15 Jul 2021 05:18: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; Thu, 15 Jul 2021 05:18: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: 21a0c45e-e52c-11eb-8891-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=sVo1DJ5oxew23bckWudEyHjTZUZag78PDOVGDXP+U21rhEoHYj7g06yTS6kZCBIsHZubuiATMAmbaRFqnd6eclxzZSaIjICDbCriq24loHbo3aiy1rsjBijk7Ye85i/oJFr7kz3/C17ALlal/PqE3HNBR9Q/8ddfRcPt79OiBtM= 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: 4a954491ebf86a9d X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OtYhI0ms3t5Cpj/E5UC0T3oUQqY/SlvuRRG3uXDpT7g3rYjMAv5FojGnqLvksyw4IU8Mi3LI2vSXPKgJ2z1xCNitPygQpemgJo+qh9qmdodwfUYkNDWLdypNT7hIIjOjyBta3FBzQEkj75quKrxQ+7Ja4N+7HpkpFlphVs9FaAo/ucJC5hL867PQBy4OnmtO0vMl2RGChF9Q+nL2kcDE/jGVmVrWwPxMde70w4NivViAY2YNkdKJJOUX5Qn8J4XTBGWjCMHum9KFqlgtZNt4+O5f/USrm35kYbqULMP5pB80S4sWa92NBxyrjI/mfvmF1hsAoJ005gyQOzqd3mSPVg== 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=iiNMZrZFXrcP+8EGTRbWGkHmQ2r3vMhuC0t0PJIlgCWpZNHTRZptiry4Gq9IA94MiUeWJnolouT8yurIwJMOi4BZrEUP6xu7i8PmLVKe7dcHz91vsllzcbkGOT6aPaJvbO7od/6q8uSy7LdIVLGii7XsEEkGKO6q8E70IlYaaMg+1LYUL24bq1hXx3vGdtqJBzoQTGN9h+Wknq3fkmN/GE/SCG/mOYPYWgZdtm7vS7AzJXoXAABGvJ2kRTt8gEdoXOUK481FkkmjTJ5hb7ftJ+uDjw36iw1EbvaSkqR91M0PtWaMXfXGzeKah5m8nCPA8s01VsC/1Ix3yx5OVbLZzQ== 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=sVo1DJ5oxew23bckWudEyHjTZUZag78PDOVGDXP+U21rhEoHYj7g06yTS6kZCBIsHZubuiATMAmbaRFqnd6eclxzZSaIjICDbCriq24loHbo3aiy1rsjBijk7Ye85i/oJFr7kz3/C17ALlal/PqE3HNBR9Q/8ddfRcPt79OiBtM= 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 V3 02/10] xen/arm: introduce new helper device_tree_get_meminfo Date: Thu, 15 Jul 2021 05:18:11 +0000 Message-ID: <20210715051819.3073628-3-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210715051819.3073628-1-penny.zheng@arm.com> References: <20210715051819.3073628-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: 183d19f4-f280-48b6-2cad-08d9475001a7 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1987:|DB8PR08MB4026: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:580;OLM:580; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: fzOrV7tM06yzry1ig/XBIkBojH61BQmHn6rpxVnghWpYw5gZgR945/jeiMBGUlHEwia6O2LEw3TQS5Etcl85aOhZBSVIasa0p6f2m48zMxcojWpjzHGGkXx/qdRnwKJBVBceSdhd2rMPgfa1LkROBCtfjB4c1XNVMHaO2cCYaS0RqSRNqfrUZ8I8+xEOXKn+wc5T0r2L92CUnYsVmctsgnkfECPNjCCdWscTvisRlpWEpOApy9Ak/vs3H5bcsif1n/2iwuxH8zpcoDlJ1CkvmmPbvi0yseoIi0bT+YEVw4NW+QFuktY61dT/f5Yn9hQg2yGDmyzyiMcj47H+NHZEcDYzDm8CwKiucO9EzyhAqpvO9kuDp5zJ1WLFG8FNMCvLTB+eGcdCJhVeATwfH+Hk3dxtEwYj3BOZNqBxzQej1Q/oEhO/MzoThIEombiVq4VkCbmAf5CHpEx/jXsZmZJWWtIhdKfv1fR/iIpt7esUIA/U3i2hyBaPzIQVHWr9seYaKShaTG4BbDq3u8bY3fzU2/AfW02iTgLejE7N4GkA7dGMry201MtV68x9XD2F2JqJkQ3U2oTkdsStXyWXHSRFpYzz1ddEFdpS6n8rf9vZMhkhm9eMoJkw+dbJaBAtG5pCG5LkK1+F55EIONWZMZmV4shrlJ/m1kz+ZimJ7gEgjqP/QGGR0dEstgCLAWPLpdj3Ua3TM+oeVYJFkSPWqHQ3DzPGp960l/sAHqPrI7ufXH0= 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)(346002)(396003)(39850400004)(376002)(36840700001)(46966006)(1076003)(82740400003)(70586007)(83380400001)(36756003)(426003)(81166007)(70206006)(5660300002)(86362001)(8676002)(356005)(2906002)(110136005)(54906003)(8936002)(44832011)(47076005)(4326008)(6666004)(186003)(316002)(2616005)(36860700001)(82310400003)(478600001)(26005)(336012)(7696005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1987 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 39325497-bbea-4953-c2c2-08d9474ffc6a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QTBIUY7ODNagrJNlGKaueIlXvXK58lQQhIEylNE6YThS6nxDwQGfirLzlaHZh3b6b7Ef+Ysd218E8253BCkl5f/HlXmFnUm3VGBOpiHQIde+Uo/H5k801LVp50BJunlrNxBCSOVvgnfVca5uMTl85QWD7seipELYCWMS6Tp6/k7jpJRcAf8EJxRsuBYxv/dTdSO7UaZT2Ah1qYM4sFJ5R5bXSU9Z/SmvQBlKgRv79JIFGaG/n7b3Z2p5iR7Hoh2DiOtaPEnsl+3QX1klzQy7wQKKdilwiFU+O7D2HXOLZck0l+zbFA/ocuj0SzBbvDXF+TxTmim21eMK3I34v1FYvBJjOfKTBX1i+56AepMwGxNU5PmP1PZr6Kywr2Y7+OO3mgbrUmueSlh1H3b32QauntZ3DHhH3A7FKp8tWJ7S/kwl5Ez/mJwh+cM5fFkc7eHWQmG2YoIsqJv2+HowT1X38cX0f1Gq3JuNf05owwrZFuYcn562WsYunxdALTqvCxsTItcvRQSs3/wm+7bZm2/TxQKxmAqTqhIvGlHv8WjFHiWNCC6+xPSHcY9MvYbz5LeFKibeDdOrhmNar9M/IXxsZpBJsWXKT5hXrNLD1FBAoBqlT9ejCDK8yPETWjugkEH6WAsHHLsoTDYZJfJRn3PHyk9sIVh63Z+mfPj23q7PDzBdfzBEBUHt+M8BDI1NAkSFytwHV7rI6iWplDkxKmCjdw== 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)(39850400004)(396003)(136003)(346002)(36840700001)(46966006)(82310400003)(26005)(86362001)(70586007)(478600001)(7696005)(4326008)(186003)(36756003)(54906003)(426003)(2616005)(316002)(5660300002)(8676002)(336012)(110136005)(70206006)(1076003)(8936002)(82740400003)(47076005)(44832011)(36860700001)(2906002)(6666004)(81166007)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 05:18:39.9705 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 183d19f4-f280-48b6-2cad-08d9475001a7 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: AM5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4026 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1626326360139100008 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 Sat May 4 12:28:43 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=1626326356; cv=pass; d=zohomail.com; s=zohoarc; b=g2kTQ0SqT67KQj+OBME94VlITdRY1NjCJlilgHDUkcWYBxozKU680tGbEN8/NeGSTdyDs9cLqnB9HuN+sP0xj0edDmTzjbGwct8sI9iWiP7FsjlXfVhwZKkmgfazZ3U+zsrlMlTzhCnUWzXxxul+U9swh5ac0XVf2Vi3eyLw0VI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626326356; 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=E612QY3hggINdE3fQg6TwWgv5c6iumbjlcSfMIoMkC4=; b=imn3J9vgFl3DL4yFWS3SFlie2DQqwCCNoGDkoz6yCkt7BV1t4xwFQTgB3AeNlgjpcEmaowlhX2LItDfUgL+WagEWvTW+vaGZ7piB0e6q87NXG95GErti+xfLJ7pLKN0jkn5zJOI4O4amw514DTzJjYIUpxdKjJNS4WWmodMTvjA= 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 1626326356650757.3258084306167; Wed, 14 Jul 2021 22:19:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.156296.288438 (Exim 4.92) (envelope-from ) id 1m3tlx-0000fo-9F; Thu, 15 Jul 2021 05:18:57 +0000 Received: by outflank-mailman (output) from mailman id 156296.288438; Thu, 15 Jul 2021 05:18:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tlx-0000fZ-3u; Thu, 15 Jul 2021 05:18:57 +0000 Received: by outflank-mailman (input) for mailman id 156296; Thu, 15 Jul 2021 05:18:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tlw-00009P-90 for xen-devel@lists.xenproject.org; Thu, 15 Jul 2021 05:18:56 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (unknown [40.107.20.43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 61873ed1-442a-4e6b-928d-016267b87ae2; Thu, 15 Jul 2021 05:18:49 +0000 (UTC) Received: from DB9PR05CA0016.eurprd05.prod.outlook.com (2603:10a6:10:1da::21) by AS8PR08MB6613.eurprd08.prod.outlook.com (2603:10a6:20b:339::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Thu, 15 Jul 2021 05:18:47 +0000 Received: from DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1da:cafe::e9) by DB9PR05CA0016.outlook.office365.com (2603:10a6:10:1da::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20 via Frontend Transport; Thu, 15 Jul 2021 05:18:47 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT031.mail.protection.outlook.com (10.152.20.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:46 +0000 Received: ("Tessian outbound 57330d0f8f60:v99"); Thu, 15 Jul 2021 05:18:46 +0000 Received: from 24e5e3f15a90.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5E5D74CA-B84C-410A-80DA-E0EF1E10DE31.1; Thu, 15 Jul 2021 05:18:40 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 24e5e3f15a90.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Jul 2021 05:18:40 +0000 Received: from DB6PR0501CA0047.eurprd05.prod.outlook.com (2603:10a6:4:67::33) by DBBPR08MB4805.eurprd08.prod.outlook.com (2603:10a6:10:dd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Thu, 15 Jul 2021 05:18:33 +0000 Received: from DB5EUR03FT003.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:67:cafe::36) by DB6PR0501CA0047.outlook.office365.com (2603:10a6:4:67::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:33 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT003.mail.protection.outlook.com (10.152.20.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18: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; Thu, 15 Jul 2021 05:18: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; Thu, 15 Jul 2021 05:18: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: 61873ed1-442a-4e6b-928d-016267b87ae2 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=E612QY3hggINdE3fQg6TwWgv5c6iumbjlcSfMIoMkC4=; b=oZT7pHoMh65/yFRf0TJAW2neqNipNbQ24tq5BiiSlV9bg+CGSZgrNh+ZNkMWZcuPlFIjGjQ7SUs72ZMnBYzCK38tTbSr0wrO9X0tns2q1AqSXny989Cv9nNVbXeP+dOE+T3gruVbdkP1jiJ50MQQy8f3BxsbXOU0ZkDbhMVkAfY= X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.xenproject.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.xenproject.org; dmarc=temperror action=none header.from=arm.com; Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-CheckRecipientChecked: true X-CR-MTA-CID: 4b46a35c717f3afd X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WkztgqiU3niGW2Uyf7qpogMbyZ6nHc4Nv2xxEqKGf7zRRJlOUo0idQOK1vriZtHspDRuY4Rsg58YRMa/mrXz4uaMrCNYQTRLefMRhJf1lhc12rlT6bFSC93FmcjJCL/KTRz+ctb6cahEM04t8itC4+W+jNfI4xW0boxA5z8UMUNvjG7B1CQK6Ypes0OUI8UH/wkKZ72GvRpZrFt/d1CSQIKVQZfeGHedAwSFs9+o3qYdAO6y4V9ePuerstVWBQPwpxv6y7+rdfKgFomiWtXRt+9xCuAK6Apv0VL9Yfy+ezWu7qFYzOa3VI+yAENacUoWJ7fue68VKWm9a0ZpJdAhKA== 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=E612QY3hggINdE3fQg6TwWgv5c6iumbjlcSfMIoMkC4=; b=G2j6PTGTrsR1LiyFtargZxdyX5WS7q3YClr+BZWisvJRO+bywFwoqjNcPJApSzztsvsdgy0qWz3ZCzcvrs60+b7IvLM8b904DqPEDPUIJwFtn4lKee2z15HXEsGvBn5Ywgjk5xgmUXOsftO+2BvCrH+tS48qO+ehzuwutA4PJbPKX0OEWTpU2nyQKDZzIejjCbNBZgfIoNgI4bmabPapQbkg9qjnuEHwN38tJJ6w665O5cS8bZMPtDkMZGNvWHTRPm+USKCj3dOW5flqkOYZofURD4aTqZKfi1A0vj+JIibKEk4tEn1Kc3qj/IBqiskYUds8bgP2UPf9mp0HPGoi/w== 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=E612QY3hggINdE3fQg6TwWgv5c6iumbjlcSfMIoMkC4=; b=oZT7pHoMh65/yFRf0TJAW2neqNipNbQ24tq5BiiSlV9bg+CGSZgrNh+ZNkMWZcuPlFIjGjQ7SUs72ZMnBYzCK38tTbSr0wrO9X0tns2q1AqSXny989Cv9nNVbXeP+dOE+T3gruVbdkP1jiJ50MQQy8f3BxsbXOU0ZkDbhMVkAfY= 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 V3 03/10] xen/arm: handle static memory in dt_unreserved_regions Date: Thu, 15 Jul 2021 05:18:12 +0000 Message-ID: <20210715051819.3073628-4-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210715051819.3073628-1-penny.zheng@arm.com> References: <20210715051819.3073628-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: d616a1d8-efa2-4168-695c-08d9475005c3 X-MS-TrafficTypeDiagnostic: DBBPR08MB4805:|AS8PR08MB6613: 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: yBHaIgTMNvU49IthGd/KQLNA6NVuuIMAe+H/b4cKxluR3b3aKHoZY0Gy5kt1twuEaiNtZVDwTO1nDx+xyAlcIsf+mLyq0BUFHLKRxoAch8XktUhw+Z677Qu3IUEKKR5tdWvatR0R68RyCHaE3DN+ATeYVR0RixPLfVOm/+EI4rOfze1xn7MJhTZQ2ZtJzIu/b/EtArUhncC7ONurxMdbMDWvg4KYaWJjxGEa/XfkLFFzKItUQWsQ8Ww31Oq5RTxIGfOFY1+9IrPF1YgxwCbrMHnOlk6MaSYtCxaj9ifXyeqHZiH8h+4S+xCEtnuBbGuptgo3mYOe1d3Ytl/O50RZtFKdrTyUvIp9tvfJ7nd4o6HLZDROSE5e6uAH0MfH3Rf5HuU1Y4n0r4a4/viB84BQFrPEbyME9/Eq2f2+yavT03c9XXlMM8vhkaeBIA37r+SDtdqV+8ORvKLRmGSxPNXaYTfIXg91+N8wFf8o5agtRWCoAuA1/zfQFaJHzpHSc0Q5F3ebFYV0nUoEeEFmIxhK97LrrMxOqV4XnqCISRRYDDSBMc3lC2geUwGEkBNuj1moXTrIs3VAOcnYkAr4Ag6VLQDXWYfjKgiO4yFOPW5WeCRaPzPN8hZjWcy5eYCJ8+9GFY5cCSexStWKXve4trIhb1yq6/XBqkjV4nq766hQBr1/p2gULFTNT8JHbDPDlVdiMBVGDwRByY5izK55tI5EnUXJNrxraxYKZFA2fhb+cKc= 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)(39850400004)(136003)(376002)(346002)(46966006)(36840700001)(26005)(44832011)(8936002)(2616005)(1076003)(54906003)(36756003)(82740400003)(6666004)(81166007)(36860700001)(186003)(4326008)(426003)(478600001)(83380400001)(336012)(356005)(86362001)(5660300002)(2906002)(7696005)(70206006)(47076005)(8676002)(316002)(70586007)(82310400003)(110136005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4805 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4a04a21b-b935-4ee2-03b5-08d9474ffdeb X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FeYoSQIyYSicjUomUokvHIBQWG0XYWiQa9W2nulOCdjl+4Og59u9/3mTUMRwvmdWa/hkmiaOfPMG+NUJdlv2QHhRT3ALiSGiP18sA8f7g9ZpiUfZKSj07DdVX2FAKkuiaegUHNfUWJBKtzga1ikcAdJ+hLDPPG+3Zeq1vqPFIceSZaXPWpVfOIwk0B68djx2M24C01/72m8AQah5rEnU8KB12K+cZwJjiZakInG/n3J8wgz5zAvGnjgqeQ6xoOCyf0YMGsV/SHmboi4TrTIBJEimkI0UiIg9vH0H0twG9j+n4BQm3kWyVJi0eUBSVQIeYPFR4YQ7Vuv83195yKk711bzz6EAldzg5Q5UOoNdNB53+wXedxQfgueGSVCqkApwjwC3/RlI55c5iGfDlbg01fIID1BpnnOD4+Idb/x2kzocSdDd3Pp43PX+J1jHS61Hut0VjJ4lH2Kya+O28aX0dl7XgpLhsEcjd1lORmpqQAXcCMvD+pJCuo82pQcBG2o3jHiGwl69S/+oK/GoXOApHdvMQ80svVqnJtGN+KKqfTrZtYvDykuXyCc4gLouvyeDAEQj/2eln8W1lIkLyvg4hReLGTnZlLPrS3uMLzhPvSKNHzC/n4LQIaxxE8msAM7qexFkYvUo2Dfs9uBcJjTCxIlTfxvslVLx6heh4yeEHqIAIRA6q/sAcsqMYx+Rg0bpU9pdQftglI5MKk/xs1Hn1w== 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)(396003)(346002)(136003)(36840700001)(46966006)(4326008)(26005)(70206006)(63350400001)(83380400001)(110136005)(36756003)(2616005)(8676002)(44832011)(186003)(82740400003)(36860700001)(336012)(316002)(63370400001)(5660300002)(81166007)(7696005)(70586007)(2906002)(426003)(54906003)(6666004)(86362001)(8936002)(82310400003)(478600001)(1076003)(47076005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 05:18:46.9214 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d616a1d8-efa2-4168-695c-08d9475005c3 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6613 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1626326358255100001 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 --- v3 changes: - extract common codes for dealing with reserved memory stored in bootinfo --- 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 Sat May 4 12:28:43 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=1626326356; cv=pass; d=zohomail.com; s=zohoarc; b=HX3ZG5+ep32S+INfJosPwDOFgOsGjQ2wt4l2N6w3XEyFU4GpaFeGAwP838s35CtpTrQzTJMjxOIMIYJ3xzRUzMer3qlR8/R/PeAGLexYwKiwG8ai/CW3YnIGm2+cdqE56HJY4kpyrHlls7lYtN0HXdliYj9dqcHnJc/ah4Jp5gc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626326356; 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=OT7F8O9ZbaKYoXsj6+GA4KbW+uyHqlgT1xpJ1lW5eYs=; b=f7MsvF2CeGgN0A2ZDDPWh3N9hPBJOCHGOYbN5HdCxJ5gYK2n3b+Pn8Gx5SvxH3pxAG8GmFSKvrk39jeMqcwPDxOuwLrciFzJWx42VHlPevNRKVR1Rvc6f8ih8aAsDse9W38xGA5YpwduLDiYPQYrNBxb/qOaSIQYnY7q3w/pvIA= 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 16263263565791007.8861741800632; Wed, 14 Jul 2021 22:19:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.156294.288427 (Exim 4.92) (envelope-from ) id 1m3tls-0000El-Mb; Thu, 15 Jul 2021 05:18:52 +0000 Received: by outflank-mailman (output) from mailman id 156294.288427; Thu, 15 Jul 2021 05:18: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 1m3tls-0000Eb-If; Thu, 15 Jul 2021 05:18:52 +0000 Received: by outflank-mailman (input) for mailman id 156294; Thu, 15 Jul 2021 05:18:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tlr-00009P-I6 for xen-devel@lists.xenproject.org; Thu, 15 Jul 2021 05:18:51 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (unknown [40.107.6.43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0108b0aa-35d6-4d89-badc-dd42c6fd97e9; Thu, 15 Jul 2021 05:18:48 +0000 (UTC) Received: from AM5PR0201CA0018.eurprd02.prod.outlook.com (2603:10a6:203:3d::28) by VE1PR08MB5581.eurprd08.prod.outlook.com (2603:10a6:800:1a0::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.27; Thu, 15 Jul 2021 05:18:45 +0000 Received: from VE1EUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:3d:cafe::49) by AM5PR0201CA0018.outlook.office365.com (2603:10a6:203:3d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:45 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT045.mail.protection.outlook.com (10.152.19.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:44 +0000 Received: ("Tessian outbound 664b93226e0b:v99"); Thu, 15 Jul 2021 05:18:44 +0000 Received: from 98af33798e9a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 148036FD-1276-4BA9-9756-4E3F6E672A3A.1; Thu, 15 Jul 2021 05:18:38 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 98af33798e9a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Jul 2021 05:18:38 +0000 Received: from DB9PR02CA0027.eurprd02.prod.outlook.com (2603:10a6:10:1d9::32) by DB6PR0801MB1911.eurprd08.prod.outlook.com (2603:10a6:4:74::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.24; Thu, 15 Jul 2021 05:18:37 +0000 Received: from DB5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d9:cafe::17) by DB9PR02CA0027.outlook.office365.com (2603:10a6:10:1d9::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:37 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT012.mail.protection.outlook.com (10.152.20.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18: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; Thu, 15 Jul 2021 05:18: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; Thu, 15 Jul 2021 05:18:33 +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: 0108b0aa-35d6-4d89-badc-dd42c6fd97e9 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=OT7F8O9ZbaKYoXsj6+GA4KbW+uyHqlgT1xpJ1lW5eYs=; b=bRmkCCXHH+twu1TlJOocEkvnItDgMJ9cQ78SKTiQ+BE3nC8xq4pe/tSeTFbOd3dJNgLo/ktxnPP4yit7L8a1MJWV+/fNejm4FqFRy75VTouSWzrsA+XZ2iB9kauiHrUAFVMaiEbsEgCApbZefRzpK/TzC3RrAQrdY5moOqLf7QY= 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: 7de1e53f76b2142a X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jCz5d00Y4n9N4+Bz1jjEuTLAUceKorvT1Js5N7JbmbSzgXAOQ7VOHODresB5u956IRmWC2T3MtmSzhcZVuyogX1gz9YR/F/OQehLUcmuO327jApkpWavCdE02e8zYhW6mjYO2Y434kC/TAtG2Dy8itIkn+/fw084GpGOa6sfEBk3pk5jrcoOLrk48n51Gq8HNK9CmQjhhPDR2tfokmu9Kt7YUwA3NmT0EMu1nLrPvoOVeuAWrf07yxyfXdQKZ5fAU03CcbvsWrg64v9IPjRozocXG796kKUK3zkNn+/QdDLVmBpM2bteeU6nNr0VCrIOeGudp9JukiLfAKcetAcXDg== 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=OT7F8O9ZbaKYoXsj6+GA4KbW+uyHqlgT1xpJ1lW5eYs=; b=TKgMX9m39v2MEak5vqcxpXTZHeR3uGefdxcEKHAjySFDcDkdb3CR3VXEEBeHoQDWoCeIZTR9XiHY9+Im2cQQ+RnAW4mTGjRA9qriJbODVqzvrE8U6C0OojHkxEMpw5vtMc110kUDF+8zELEnoXfAkbgThgsWEhHJ2xP6gaep4LchCeHFs3cJeHfRr8gUX9zE+Ya0qCO989nH1MgQc4sdb5lVV1Zm9qbkU2C9hjOXBuedLrWAGk3WUR3k82DNDBVsIA4IpS6bYQsI6REmqnTSwwnLO51ulGvmD7YaPiWFv0g1A2x1qnig5JhZYRN+XtPpsQJPvfiLeauhPsC3ZQO5bA== 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=OT7F8O9ZbaKYoXsj6+GA4KbW+uyHqlgT1xpJ1lW5eYs=; b=bRmkCCXHH+twu1TlJOocEkvnItDgMJ9cQ78SKTiQ+BE3nC8xq4pe/tSeTFbOd3dJNgLo/ktxnPP4yit7L8a1MJWV+/fNejm4FqFRy75VTouSWzrsA+XZ2iB9kauiHrUAFVMaiEbsEgCApbZefRzpK/TzC3RrAQrdY5moOqLf7QY= 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 V3 04/10] xen: introduce mark_page_free Date: Thu, 15 Jul 2021 05:18:13 +0000 Message-ID: <20210715051819.3073628-5-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210715051819.3073628-1-penny.zheng@arm.com> References: <20210715051819.3073628-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: ea83acbd-ccde-4e55-520a-08d9475004b2 X-MS-TrafficTypeDiagnostic: DB6PR0801MB1911:|VE1PR08MB5581: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1051;OLM:1051; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: k/P7MCSDanzelEayVIMbXHgRcpYj00wP37r822vZMjs6cOFpa7f4hP3giuXxlThrFhQpQgUUVh9u4rqJD/L6+2ISXid/bBEZ6p5iznM1kwXu8Kclo7ewAPqZAFWsTr3/Y4FRHpHJhi9cXrNDJz9hlOXevRYpI2FV11rG0+rPyRgawurvkxKl10TeOteRcKkm0K3dDUJf76e/6H1YSzDT3cpNrJ3gqNtCb/MWEFtV609r/pYLbQaGweTpkbsrRKPgYssUEWxsHdr/Hs85w1Ua6Co0BYcyR0YjD4iAMWy1w3xyPetq7q7haEJ+ayZGNYRyPrB1phwazBAJ5RyWa4gY1ctai54Qj7CA3Rxe/Zab7Ba7YIrZ+tffXjG+wuDZ/IebBhoguTR6NJgOCbYAbmZh+ie8eihtYgH+AjCy9mOQV9isU/UQ7vl2IlPAilmN3BoucZsAVM6WIOU8p8l8iffUhiVcYiudll+noqNfgGSUQDTPJMpIBka3zFllzX26wb7bajaNs4YKPyeKlt0pU9JuTw7M2vEmgUOrx30v0mB6rs7Ujgv6FNXKjjQlPxHr8Uu/7iWRJ6Q1nT/DrZNifrLBJQ1xJO/82qtboYW21m+5Dp1q6XBLLD3zMJFS6ihnjnksMVIQPoGpbdL8lMUecLTFx1wunFngNCtx6NyU4rxrNFIULl3yXoCy1FNFPmwpXrxZb4QOQAIILSwZwGXXsMhB7ZTmwtZypp5V2JC/FgpyOmU= 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)(39850400004)(136003)(346002)(376002)(396003)(46966006)(36840700001)(81166007)(426003)(110136005)(7696005)(26005)(186003)(5660300002)(36860700001)(36756003)(316002)(4326008)(8936002)(82740400003)(336012)(47076005)(2906002)(6666004)(70586007)(478600001)(54906003)(86362001)(70206006)(1076003)(44832011)(8676002)(82310400003)(356005)(83380400001)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1911 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 67c1f5e6-2f45-442a-f245-08d9474fffc1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fYfIWsi0P7bdjIyqRboITLJ/Ejdyphh2Cpt+k3wgEYujZDAPDwXhWVKCViCHOr6Q5Tnu/VnTrSigKXhmSvkHmuPazwhI3qSaQHVZ/lPCYcfWTI7/cGaMBqjETe5Tx58zAppLGhVsCATrh1x0WvM4CGcGbvT0FvHVZimW6Q+MDesQtK37x80vTL4c3hP7H8qwJDbyHjEF+/4XRxXFIACe1oxgUZoXXOKdgawnT3bRaDm1ovy2nARuYT/VwE/oCO7U70YNbaw3qEc0fwIymNRkydG6nbZOy9+Dvrvkye17XspkgnZoUow9y304Pitz7okwkc2QvHSlDUtYYeHEmz2oFXN8P1a8dtnYDNQqdH3CANGsLkq9MIaD9AHk5pIxVkbJyU4YI2NAwG4hGWfWaXIFk83mQ2AryuC2CCgpJvfTHHd1fyyMAh5/kjaQUtoDFc2llZ9LVdbhmBiQNp9mVxG6jKtjCicBU7o379M7IEDH/UhhsERRm45taqRSYfzCASErdiDrZDt1vxkL4OzcY4OzS3flXZiJ0NfFvvbyWCtc9NjT+qTqSw/t/yNOPOYbVyRJk7byZCBg88PjIth7qs4E5fPtm+wRzgCF2ndgq9wZgBrjZrtAoKaSV62ScZuLyKRASKzh9ckh0YK6NCdNHcTzZ1xvmvIbwnkjLFH3NTbR4fGvkBVhT5SHFm4SrB3CqH1M6Af6mEaUztwfcVP0m7XTdQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(396003)(39850400004)(376002)(136003)(346002)(46966006)(36840700001)(70206006)(186003)(2616005)(82740400003)(44832011)(7696005)(8676002)(47076005)(8936002)(26005)(36860700001)(82310400003)(2906002)(478600001)(70586007)(336012)(6666004)(86362001)(54906003)(81166007)(110136005)(426003)(83380400001)(316002)(36756003)(4326008)(5660300002)(1076003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 05:18:44.9797 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea83acbd-ccde-4e55-520a-08d9475004b2 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: VE1EUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5581 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1626326358262100002 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 --- v3 changes: - rename from "free_page" to "mark_page_free" - remove non-trivial page_to_mfn conversion due to pdx compression, and let the MFN passed in - add an ASSERT() to double check both passed-in pg and MFN match up. - let all switch-cases shared --- 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..95d9be169d 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 Sat May 4 12:28:43 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=1626326368; cv=pass; d=zohomail.com; s=zohoarc; b=ixrl3CxsGOExWrZMLrlDVLo9Z18sMG0T0ttk/wXNhY6eKytRX9wViXJeaXvgyFcdLtnP4XeofvjWl9UsZ4gZvP3w1M7cfzIyS/uMROPS2+TIqn6C0wAV7WHqFVNQOKTQeqlV0cayrL6JZjNWQacW1Mf0jZc1waGNqOngVKpM3zE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626326368; 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=6RuQQnLM+Fgaeuh0yD31SI005nmfjCuq9/hVXZqKUE8=; b=AJcewhlT3ucajcYqRU4Lb7wcR9pu18Xmxj3J7osTyhrxFfH4I5QKacxiUiysmjMdThskPlBsMFdUyzlDS+GgOAmB6VhQTBu7GjLDH+Dgg9cJ57mS5e3i4ozrOJfHDj+wnwfYTSbN/ncPet4MNCYys/zTKa/e2eWD5psMVcmDM/c= 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 162632636796790.5470706313846; Wed, 14 Jul 2021 22:19:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.156298.288449 (Exim 4.92) (envelope-from ) id 1m3tm2-0001Dm-IN; Thu, 15 Jul 2021 05:19:02 +0000 Received: by outflank-mailman (output) from mailman id 156298.288449; Thu, 15 Jul 2021 05:19: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 1m3tm2-0001DT-ES; Thu, 15 Jul 2021 05:19:02 +0000 Received: by outflank-mailman (input) for mailman id 156298; Thu, 15 Jul 2021 05:19:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tm1-00009P-8x for xen-devel@lists.xenproject.org; Thu, 15 Jul 2021 05:19:01 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (unknown [40.107.8.80]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id fca2b67a-f9a0-41ef-8658-1a18fe74c998; Thu, 15 Jul 2021 05:18:51 +0000 (UTC) Received: from AM6P193CA0071.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::48) by AM6PR08MB5077.eurprd08.prod.outlook.com (2603:10a6:20b:e6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Thu, 15 Jul 2021 05:18:49 +0000 Received: from VE1EUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8e:cafe::80) by AM6P193CA0071.outlook.office365.com (2603:10a6:209:8e::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.22 via Frontend Transport; Thu, 15 Jul 2021 05:18:49 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT012.mail.protection.outlook.com (10.152.18.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:48 +0000 Received: ("Tessian outbound 809237f40a36:v99"); Thu, 15 Jul 2021 05:18:48 +0000 Received: from d6a36b010456.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4FC92E74-5853-4BB0-8FA9-D4E6438EDF4C.1; Thu, 15 Jul 2021 05:18:42 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d6a36b010456.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Jul 2021 05:18:42 +0000 Received: from DB6PR0301CA0057.eurprd03.prod.outlook.com (2603:10a6:4:54::25) by VI1PR08MB4591.eurprd08.prod.outlook.com (2603:10a6:803:b5::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Thu, 15 Jul 2021 05:18:40 +0000 Received: from DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::52) by DB6PR0301CA0057.outlook.office365.com (2603:10a6:4:54::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:39 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT053.mail.protection.outlook.com (10.152.21.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:39 +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; Thu, 15 Jul 2021 05:18:38 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Thu, 15 Jul 2021 05:18:36 +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: fca2b67a-f9a0-41ef-8658-1a18fe74c998 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=6RuQQnLM+Fgaeuh0yD31SI005nmfjCuq9/hVXZqKUE8=; b=iGzqmAhc5l3+s1k0ba+/ltjDXvO+/YxBBzKiGApOyN3y5+Fexi+cwPWMNUw9sSfwz0zdltG686d05ljcXLg+z9Eqn7fHEyx7DkCScVUx7dDz0Obn+N40zRu3ahKFY1i6UDGhmAzz0YQpn/wlWOhdxV7uNyVAII0IbK+oK5OSZN8= 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: eacd1cd9d0cb26ab X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=evSz65sMci3VGbUy2l06x5tz9tlnwjTYvoihud7uV4IpIIxUPA1026QWCoswY9UmjB2fIvlomCuSEf52SEeOtnzzMSdlAoeSuAHCiMqrVdrjSQNAR9+XfENSSM+EDwOcMp7C35AJ1ZbwOsr+HFqoObD1rWAFAhRq6/sXGjQPCaY+y+uuY4nJfxwJ92rSNP9rMRVDT+sgOocg+O+Sce41kN3cVp4o0rik7i7mRV5zApWRmt/o7NhheStCVJzmoittoMFdqdMwWkS3iqaF5Cc1Eu1hQfbnPlOYMN4YspS+zdttKrEFl7rbAbFKXMYj2ZTOLn94Rz0TJR1iqnGog8a4HQ== 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=6RuQQnLM+Fgaeuh0yD31SI005nmfjCuq9/hVXZqKUE8=; b=jfUga6eJFZxanhUZ7hvmcwJlmm2oySkZG3zwGvmerrYod7zl6umeYBl/ScaZ0hQiLFg1Dt6tm2CGyFOWjg2FiJ43ANCmC29Q2blcWSgsgKnBTaSDM5A+k32SRLwkPlGT+6UdlYbMOWjZe/RHw4FZG8DxOtDxauJz71AaYHn4a3jlmIwmyuyV9b97vFGHzgOayYj2SSR6BRCTWJAcZ2D/ps3/pt9Hn9eLBsRY0KbY8Ot5YeANx9iSwvIvHJs0qRlVR32EU4hxcIwHY1MLtD2l/90jZlMbWE1ERe1u/YD9BdlabutGhiC4qIhwwxbBTya1vvbh6B9IkQzsmmEzJ23sjA== 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=6RuQQnLM+Fgaeuh0yD31SI005nmfjCuq9/hVXZqKUE8=; b=iGzqmAhc5l3+s1k0ba+/ltjDXvO+/YxBBzKiGApOyN3y5+Fexi+cwPWMNUw9sSfwz0zdltG686d05ljcXLg+z9Eqn7fHEyx7DkCScVUx7dDz0Obn+N40zRu3ahKFY1i6UDGhmAzz0YQpn/wlWOhdxV7uNyVAII0IbK+oK5OSZN8= 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 V3 05/10] xen/arm: static memory initialization Date: Thu, 15 Jul 2021 05:18:14 +0000 Message-ID: <20210715051819.3073628-6-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210715051819.3073628-1-penny.zheng@arm.com> References: <20210715051819.3073628-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: 7c920649-f0bd-40a7-a526-08d9475006f3 X-MS-TrafficTypeDiagnostic: VI1PR08MB4591:|AM6PR08MB5077: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:323;OLM:323; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: UdhAvQBBD3kwuTTjyIiSSHnV/r48SNrk1R/AggH67MGo1PoU+XnbBMvETvZzTBCd7wJFKcu1H2jZuu5USqDH2EmC24P4K3dkgln/jo4CIK3+2oA1tPb2Zxl+nRclF3nfkrxwS5FSLUmkCT76hERJ3t5Xct+5suVOWLhxb4bw28y52hMzyc3F0ieAJbVtWX6pv33OoIEs4b3eyrts23ocUd4ve7wnDLuDiNnafY0gJ2zg0Uye40Rf4+pFsxXq5mxvb7q79nJWPRMuwjWEN+m1zjOP+IkvikmWXqnlXK08P//0lgtkvMjLlJYD+Fdk8DUYDHqpdXCyoAGWcd6iPTdlzY119N4+2JxqXKrNX5clssK3rUCWIVTQCi4PetHwpTnphmwAVhGxIuDtujXLuIR7dhut0/7ULAEcXe7J+oOAo+duGJ+f2KrWRcCFLKMSu0D19LESYNPsTlYut15I4nEQ5dcNwtAfUWd2slorZr3hwmw5YSvFn46+jowQ2p19jYf2EwmsFOQIZ4hz3b2GG1P+8PDXLkkLTY1OpATP4SnnT20up+sCYpQ/XDt3J/1MKwOkh+s9Amhq4FgVM3I7qX8JzisCi2gJSylvRFdZLZRM16HWnLhpKm/U7Gpb+X9j+CIQTFGi8p4y9gmFcqNFRBu3Hl2v9Q3dGZ55lc+ADe9gzbEeMCuZY6To1Qq3FCl4AFY+FQrIdTyR6jMFfjkdLbXoUfNOnSkaJYP9mybqdNjq4rA= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(346002)(376002)(39850400004)(396003)(136003)(36840700001)(46966006)(5660300002)(70206006)(1076003)(2906002)(7696005)(70586007)(186003)(36860700001)(316002)(86362001)(81166007)(8676002)(44832011)(110136005)(82740400003)(36756003)(54906003)(83380400001)(336012)(478600001)(47076005)(82310400003)(6666004)(2616005)(356005)(26005)(426003)(4326008)(8936002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4591 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 3fbcd178-91a9-41c0-5bc6-08d947500163 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s2fr5kTgwtuxutEfGRHIh4x31j4Eb5KvHFZSyC0vXpTz9Ya/UoLOpN3dYevZRmwwia16iefgknhp1gaFmiyUGGdzwAwuVFEzMkfd3o2f89K0mxR9qvIW8nruhwI3CPe689w+Kn30rNzoFSR2LMWaN9/3maEajmtHF00BmCmJ4bQbeQlkb99iiB4l9g174eteAt+U3RAi8ubnFsRP7d1NLPQA8GBsWMOi6J52FK542uVEkUM2HrhlMbwip5NGuA5USPkyXHyR22FbKJHE3Gl5C8zPu+91eZaCS5tW2l1Q/xC00heW8X/J/qWFQ+pXQBdyL/3jC3ijEv77YVfyKvEMZmvSj3I1DtK2JaCh65pYVRKN0O1L/hDknJMbe4BXjrsgS9wLRxuef1pJqtqpFn3dlZt9KmxScM/5AsgV+CPkYOtEnM5dqoREax3AQS/SofotN2T7Q6sz8cLSP6Kgyiuviv1+HU5iU7hDrn+5j1BPhM4l/sCc6LcecLKU5kVqbBhxMQBqJMWoWBzPXjC7zITvx6WcoUeWZGasroOWGHQZwLW+Y6FVSe8BX/xII1Rnh+qY7Bm3a62n6kD+IP6G3oGr9CjXurRpks8ji/kPxlypCAvdkNi0cLRh5zFxX58yOZDa2aVdA9pxgXt027RfngTwRi59+99e8PiFoRu8woCqGCF0L7HERfWgVsBQflvwgYY+a0ELl7UhC4nKXRLO3sYgYQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(346002)(396003)(39850400004)(376002)(136003)(46966006)(36840700001)(44832011)(81166007)(82310400003)(1076003)(86362001)(6666004)(316002)(186003)(8676002)(82740400003)(8936002)(7696005)(36860700001)(336012)(5660300002)(26005)(426003)(2906002)(110136005)(36756003)(4326008)(54906003)(2616005)(478600001)(70586007)(70206006)(83380400001)(47076005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 05:18:48.8063 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c920649-f0bd-40a7-a526-08d9475006f3 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: VE1EUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5077 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1626326368742100001 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 --- v3 change: - include addition of CONFIG_STATIC_ALLOCATION in this commit, where it is firstly used and also change the name to CONFIG_STATIC_MEMORY - Fix TAB typo in Kconfig - put init_staticmem_pages in setup_mm --- xen/arch/arm/Kconfig | 3 +++ xen/arch/arm/setup.c | 26 ++++++++++++++++++++++++++ xen/common/page_alloc.c | 20 ++++++++++++++++++++ xen/include/xen/mm.h | 6 ++++++ 4 files changed, 55 insertions(+) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index ecfa6822e4..b91e2efc4f 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -106,6 +106,9 @@ config TEE =20 source "arch/arm/tee/Kconfig" =20 +config STATIC_MEMORY + def_bool y + endmenu =20 menu "ARM errata workaround via the alternative framework" diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index f569134317..aec8bc8494 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -622,6 +622,28 @@ 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++ ) + { + paddr_t bank_start =3D bootinfo.static_mem.bank[bank].start; + paddr_t bank_size =3D bootinfo.static_mem.bank[bank].size; + paddr_t bank_end =3D bank_start + bank_size; + + bank_start =3D round_pgup(bank_start); + bank_end =3D round_pgdown(bank_end); + if ( bank_end <=3D bank_start ) + return; + + free_staticmem_pages(maddr_to_page(bank_start), + (bank_end - bank_start) >> PAGE_SHIFT, false); + } +} + #ifdef CONFIG_ARM_32 static void __init setup_mm(void) { @@ -749,6 +771,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 +826,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/page_alloc.c b/xen/common/page_alloc.c index 95d9be169d..f394d6627a 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 Sat May 4 12:28:43 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=1626326378; cv=pass; d=zohomail.com; s=zohoarc; b=BjeMGIgHZBaZu9514g28tQcTUO13MkHQLTHWQ6UvBvaHX/mrDHun9WuxVxjakZY/TLyZ5tbipj9naf482kPpLxZJWIZI5HofezjouUj6Xj8WKu0v3k+Fp8xQ5yYZztYroeUeFbgNfMdHT4yjafg7BJjjK/XFyIuvq7U+jTZGQq4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626326378; 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=FSUaZhIJ132fP5dvjR7UOX33VSmQ3hubM795HYhZnO8=; b=DvPTyBkDR7SZNXEiWTpgemsnXQED6KkL7nrzDd9BOfL88RHOCDtcdPDgF+r8i6dCnZCtMn0qnhat+syrLy4M5aELDeRNec//YkPGv0XMfrRqTOmH9a8ybvHPYkAeiZhug0DOYfZlfnAxZr4nMyrx/lzPD5MGPtE0EX2WWoVp3oA= 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 1626326378131605.1268743770421; Wed, 14 Jul 2021 22:19:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.156308.288471 (Exim 4.92) (envelope-from ) id 1m3tmH-0002hS-Fp; Thu, 15 Jul 2021 05:19:17 +0000 Received: by outflank-mailman (output) from mailman id 156308.288471; Thu, 15 Jul 2021 05:19: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 1m3tmH-0002hJ-CQ; Thu, 15 Jul 2021 05:19:17 +0000 Received: by outflank-mailman (input) for mailman id 156308; Thu, 15 Jul 2021 05:19: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 1m3tmG-00009P-9Q for xen-devel@lists.xenproject.org; Thu, 15 Jul 2021 05:19:16 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown [40.107.21.55]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c9bf7b7b-6f8c-4a95-b378-1e7ff86d5afc; Thu, 15 Jul 2021 05:18:53 +0000 (UTC) Received: from DB9PR05CA0012.eurprd05.prod.outlook.com (2603:10a6:10:1da::17) by AM0PR08MB3492.eurprd08.prod.outlook.com (2603:10a6:208:da::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Thu, 15 Jul 2021 05:18:51 +0000 Received: from DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1da:cafe::9b) by DB9PR05CA0012.outlook.office365.com (2603:10a6:10:1da::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:51 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT031.mail.protection.outlook.com (10.152.20.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:51 +0000 Received: ("Tessian outbound 57330d0f8f60:v99"); Thu, 15 Jul 2021 05:18:51 +0000 Received: from 9b657cef5389.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F6357AAD-1979-47AD-A6B1-A3BADF2F7401.1; Thu, 15 Jul 2021 05:18:44 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9b657cef5389.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Jul 2021 05:18:44 +0000 Received: from DB8PR06CA0058.eurprd06.prod.outlook.com (2603:10a6:10:120::32) by DB7PR08MB3436.eurprd08.prod.outlook.com (2603:10a6:10:44::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Thu, 15 Jul 2021 05:18:42 +0000 Received: from DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:120:cafe::69) by DB8PR06CA0058.outlook.office365.com (2603:10a6:10:120::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:42 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT027.mail.protection.outlook.com (10.152.20.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:42 +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; Thu, 15 Jul 2021 05:18: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; Thu, 15 Jul 2021 05:18: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; Thu, 15 Jul 2021 05:18:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: c9bf7b7b-6f8c-4a95-b378-1e7ff86d5afc 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=FSUaZhIJ132fP5dvjR7UOX33VSmQ3hubM795HYhZnO8=; b=KnheMaRuNZ1IRNS2DFGcoqZXaDEOeF8COjEHF/xbeGeXlo2AR65vD0xs+z1zU/4FlJAZJXHzM8IqSURf1b4KXXrnwE7rm2OgQyssJSpaUmTcs8xZLK/raCxG7jKWc9QH3xEuWZ/KQvlCPAgOPz5Mdbqllh6GBmaE8pboceh+GGY= 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: 483706ace2e951ec X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BFIAIjILSdi41Vv7YqWgpIM4cIm4Pmsl5oLtdjihxh523UeDEPHmgZxNQxhL0I4u+bHmYBfSRF9AFDHurgn0TTlZn1uXnbDFvtVxyy+ItiDKngjqU1dqmbwPUnZZRAQv8e3oM4l7bNWmv5EnnkGVfZM9NEeqjjcIro2HWXcyzUxp/Mzijs3ZfWMeLIT16VAe+TIlu4m6LRuuHFK41EWg6xxGbd+yAW43+UWihXUUA2cAPjgpOEuyDAQs8eo2zCCnZasRHIjh/tW8Y9DmLlNwd4J1Iut5CKgvhk4myFIEMe8KfKRJKcVHoAlaW/f3x+ZTb13uCwV5HY2Ot6QoJn4qrQ== 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=FSUaZhIJ132fP5dvjR7UOX33VSmQ3hubM795HYhZnO8=; b=gCZMUUcuOkKxsNd676rEkkjppeD7WpDRNLT//woOK2VHeK+takVp89Ji1GUQU9j0S1OdDJgDSlw9xD7SE8N7M3WUMRrLKuSGFOh2jiatimt5UU6t3XpmQJzTKhcFgEHoixNLr93z+I0dRSLtPjbBOnjRlhl7DXp+Bmt8g1zCg9dvDt5CLLT4EviJ6dUWwrWlbxcRIAfl9YREq89BOyPW4JUcWGZ2PBnXTM0KNObJ2SKmv7+LruTDepeuqtT5vsHB6dSkqVBsPGMk7KJQYmy2xtrimNH9To6B86Tq5uqFaH/ghO2D239DHCuDANeZ3+bt+CmO5mXR5cPD0LDGN/bg9w== 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=FSUaZhIJ132fP5dvjR7UOX33VSmQ3hubM795HYhZnO8=; b=KnheMaRuNZ1IRNS2DFGcoqZXaDEOeF8COjEHF/xbeGeXlo2AR65vD0xs+z1zU/4FlJAZJXHzM8IqSURf1b4KXXrnwE7rm2OgQyssJSpaUmTcs8xZLK/raCxG7jKWc9QH3xEuWZ/KQvlCPAgOPz5Mdbqllh6GBmaE8pboceh+GGY= 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 V3 06/10] xen/arm: introduce PGC_reserved Date: Thu, 15 Jul 2021 05:18:15 +0000 Message-ID: <20210715051819.3073628-7-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210715051819.3073628-1-penny.zheng@arm.com> References: <20210715051819.3073628-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: 83dcba9c-c79d-4ba3-3ba0-08d947500832 X-MS-TrafficTypeDiagnostic: DB7PR08MB3436:|AM0PR08MB3492: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2276;OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: bUsFFh+gY+lxoHy2rXVi8sAs1bhAPaYBz8YaRahx3vSjFdEmRGbBuwc7UmcY6LmGEZwmW5xIoncU/8JBGAXCBOzmz8eEB3jTanxXScFlVBZqozbALHe6PCyq3b9zlGGVQ13aWAZSwq60KLpjb8CUSvdKcY50E3AY8SW5IBFbKISLrgv3jb//ks5HNSQpkENorBIZ+5DuQnexLsxgLVA1E7Z4Gc8F4yMzKDYrDbtsWo6ok+Y4TryJ7Dz7IcapPZ4bl4kijJaFhmEyH1WVFb3h6I/sSHjzCChLZ7aZMaRfiJe45tmU6ViHj+V9MULSAHcB/y1Uo/Im8eP5bJmLcm0+y0Ew/xPuTK9VBj4Hd6GTeaxi3es9i/I0QAto+EaVrENjV6y0c2bKXz7pY9O2KQenMyCcBp3trnNbBFmc8y65iJ7X2AR9+HA6+RfuYGSvDrYXK3ucoB1eVZs2aejVn6lDim9pZWMDYw/Ph0XYDvtsGSv561LxTEqAshcrmb0VaYltFJV2ya7+WAPOtsxJiDq7ZTD+jFqIMsfRnFjUxB3bhY9Brb1xBu2MvJzCsjf7kI3VkQzV+ICz6UKsvut/pqpMtb41SvPAGSdhSQEBcEw4VP3uA/pYv6j8KBFZ0/8c8nHP/wuGsNZGV8lfn/nBJ92gH9+xZgrzJznYAk38d+pcNu4ESraPEdbgFftmneASW+KrZIj/reVa3KpHhJG9kltLEUjadaJml5r5PDjlX9qshHI= 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)(39850400004)(346002)(376002)(136003)(396003)(36840700001)(46966006)(356005)(82740400003)(478600001)(36860700001)(5660300002)(8936002)(4326008)(7696005)(1076003)(54906003)(81166007)(186003)(82310400003)(6666004)(86362001)(110136005)(36756003)(2906002)(26005)(70206006)(70586007)(316002)(44832011)(336012)(426003)(2616005)(83380400001)(47076005)(8676002)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3436 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 9599777b-5b73-4ec6-5548-08d947500365 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8YBZv2SsJSr1OvLCNsHwiRNacNRSBk4cziLRYKM6EDLyotQzdfmYMhYITnqKrc4SNc/IHbDydnUK3+Z/C8yGTxpktRU0pidyFcYwuJ/O9qhYpGMaaMfwVBHZ97MYmBQxeSg/CE1OxsqAxiy/iamNyYJaxYBOLFtaRkkeRxQTfyjWTLVXklcSqRC5KgeWG2x0BEkfErvkyukuNwCwcdhZQZTftrUS8Z0S1QUABf8KnTGErkzTw9jMh8FKJIiMegs6aHkR3uVDab6UhGUdBNqss9XVOkuJAgZF6M7Yb7vikjGv6SpRMsYo0thPyN8SQAoPDCnU5W2pDgN/VjE/Rii/YBM6v4qbGoM+9pOl0I4qYDGMd4q4KQCM09VY/Xt2LGSBBR+CSXo44NqQ5bGfaiSN50kqeNekgV+NY4rJt20qrqJ9xpWQuwTR3POIXNiOfDmhTU/vr54lq+KOMarCdQW/4irbczkPDGKz9aONiAGJC/01OwsH63eQbrhtwV0w1qAjYGWKoO5DEORsZjfYeWWwFjDv7VJB5JJFwx/3vnbO8mp6wiukevhWU1SU4LqduU5TrRNUCpXo7F8lIUVPjP+Xu2zE3CvxQDA6+MNT9V3wv/9txj1tM+uq0o4lRR1BMnV50OSR9aYDRw/Uqz4ZgQb8nmTSzA2BBOfOO+RCGfU+9k/v1i6OJqrNzkeReSEi0/x9s1zwAes1DtRVLkfoySm6eg== 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)(186003)(316002)(2906002)(8676002)(36860700001)(82310400003)(5660300002)(8936002)(47076005)(6666004)(4326008)(26005)(83380400001)(81166007)(54906003)(110136005)(336012)(426003)(70206006)(2616005)(7696005)(36756003)(1076003)(70586007)(478600001)(44832011)(86362001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 05:18:51.0031 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83dcba9c-c79d-4ba3-3ba0-08d947500832 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3492 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1626326379148100002 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 --- v3 change: - introduce PGC_reserved when it is firstly used. --- 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 f394d6627a..15edaca227 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 Sat May 4 12:28:43 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=1626326386; cv=pass; d=zohomail.com; s=zohoarc; b=RMHjQf75RBANHtgObGxZDeYVfRhK+B3KjmATYntDlVMtjraqL5vbVnGnWiDz/pMGLkUL/rLVXzqohua74hxhuvk3wPFljy3/8bE46eoZ7+/SItaD6l32LqDKBbqMylhewPUQdSK4Sr/YdimPHwdxrejWpVSlU5OvEX69u8xEVVw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626326386; 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=Zi+y5UgZCqyilrjAU2VTEHJyZTzOIipfdYPe5SW9Q2o=; b=So1OzEQsjJeAW2TiIxaoYbZhzsytGDBB2rokIEFzActTZS7eUe6geMn3eJPoXWoNsWGnK9SBf/m3S/VUpZ5jifiTXk/F03YhzKrpdxMqmPx6G9Lo8DmoetKH85RUCsjhMsf29bi3j8CZMF2rKBWUUAFiXvgn7YIDzWhvA+8Q2xo= 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 1626326386588448.0300218543156; Wed, 14 Jul 2021 22:19:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.156311.288482 (Exim 4.92) (envelope-from ) id 1m3tmM-0003Hv-W8; Thu, 15 Jul 2021 05:19:22 +0000 Received: by outflank-mailman (output) from mailman id 156311.288482; Thu, 15 Jul 2021 05:19:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tmM-0003He-SP; Thu, 15 Jul 2021 05:19:22 +0000 Received: by outflank-mailman (input) for mailman id 156311; Thu, 15 Jul 2021 05:19:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tmL-00009P-9c for xen-devel@lists.xenproject.org; Thu, 15 Jul 2021 05:19:21 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:fe1e::60c]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 36fbf5ad-7c34-4f0d-a611-02f641bdabed; Thu, 15 Jul 2021 05:18:59 +0000 (UTC) Received: from PR1P264CA0008.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:19e::13) by AM0PR08MB3523.eurprd08.prod.outlook.com (2603:10a6:208:dd::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Thu, 15 Jul 2021 05:18:56 +0000 Received: from VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:102:19e:cafe::28) by PR1P264CA0008.outlook.office365.com (2603:10a6:102:19e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23 via Frontend Transport; Thu, 15 Jul 2021 05:18:56 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT049.mail.protection.outlook.com (10.152.19.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:56 +0000 Received: ("Tessian outbound 664b93226e0b:v99"); Thu, 15 Jul 2021 05:18:55 +0000 Received: from 2ed5fc456fa3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 625275A4-F104-4D74-8FED-976801E8D943.1; Thu, 15 Jul 2021 05:18:49 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2ed5fc456fa3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Jul 2021 05:18:49 +0000 Received: from DB9PR02CA0016.eurprd02.prod.outlook.com (2603:10a6:10:1d9::21) by AM5PR0801MB1972.eurprd08.prod.outlook.com (2603:10a6:203:4b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Thu, 15 Jul 2021 05:18:45 +0000 Received: from DB5EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d9:cafe::31) by DB9PR02CA0016.outlook.office365.com (2603:10a6:10:1d9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:45 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT051.mail.protection.outlook.com (10.152.21.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18: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; Thu, 15 Jul 2021 05:18:44 +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; Thu, 15 Jul 2021 05:18: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: 36fbf5ad-7c34-4f0d-a611-02f641bdabed 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=Zi+y5UgZCqyilrjAU2VTEHJyZTzOIipfdYPe5SW9Q2o=; b=zimSjpmNwalGChGa5H7BKuaMHCay1S0NHFZ0QYx6359sG2vOEJFMMHpgULTcFaMILnWNGQMp2K39Rlz5pivwPGIGT3bcuUwKhTxy7iNy8qcVtwiCRq1sV4WeYclPGpuEbMTpYcyXcoxCxKZHG9ICLluFC8OdlXcYDp2YChh0cQU= 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: acccea191def6458 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ScXa3iYXOxg0hGaKjq6m38yeKLEmzxFPPr3ONaT9sDNhKM4hQHmLJk9P49h9RhMjalobWDh1vusY7vPljpwQ3KkXlvWc8x4eq6b/ouOLe1xOcyj5rx3Y7LIQmfZrUqv6+5plkv9IPLEsMjvewOBVFYT//botu3K0V/CHTWYC+eCr2aRRxz4rUxXPck+uRKAJsXYR9zvdz3qTMlNNz2BPuO3K2OuG0RXDtY7wQH6NN5UDg1nziNUtAlJG9mw4izzlN0YjTypwn1KE0MhWzHYsEj277caONOUDEsaDHHKJWvHW1XxVRAPRGAfrFYKoiLh5RhGdoL2ZvjxCQqtC04YHAw== 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=Zi+y5UgZCqyilrjAU2VTEHJyZTzOIipfdYPe5SW9Q2o=; b=oBL/fCg7aIrkznfHMkso/kuwp27g6bkbk8dA5JE3rLJvmstY4pm8WwpjquWCzGAMrOAcv3G6bpQMfWpCau46+tCDlKrDycExRuDVq7UY3BIqEvgy1m4ufJoEoa55lm4g1zlPxgcyDXWySu9KyymtPrlY7SJNeBXVEpiSM9Mc8TVUOHW9r8u28FWbkDzHRusdDoicdp0DDa0tVfQCENbWLXZhRYfT3KUvpz4jRhHvI2xAE6UAqHpWjCtJLkooTQm+j9zSeKhzaxlCNwYvCTupd+k4sAN/v+1mqgZ9Ke/Mtsup/hWwj86V+u+6y2FWabMDOhOMOS0E6b3ebAap7fzYZw== 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=Zi+y5UgZCqyilrjAU2VTEHJyZTzOIipfdYPe5SW9Q2o=; b=zimSjpmNwalGChGa5H7BKuaMHCay1S0NHFZ0QYx6359sG2vOEJFMMHpgULTcFaMILnWNGQMp2K39Rlz5pivwPGIGT3bcuUwKhTxy7iNy8qcVtwiCRq1sV4WeYclPGpuEbMTpYcyXcoxCxKZHG9ICLluFC8OdlXcYDp2YChh0cQU= 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 V3 07/10] xen: re-define assign_pages and introduce assign_page Date: Thu, 15 Jul 2021 05:18:16 +0000 Message-ID: <20210715051819.3073628-8-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210715051819.3073628-1-penny.zheng@arm.com> References: <20210715051819.3073628-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: b727ed82-b5cf-4ddc-0ade-08d947500b78 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1972:|AM0PR08MB3523: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6430;OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: zZEAnNfMirG7xdA4DadQDMICrn+KBLatN2FvBpPrmjp5LepS4FB2VkyqzxGpNJlQnd8f1piGDtUQSId7qpFYrEnAmRthHNPY9SiYOeyvtIT7NIP3uN/TpKHFJf0pbTq3ZAU6O7Z8wj63a9BxXUCAESv42MbWH1zeWFDNy72KC4j7QX8KzFEGJfMEv1mvM/wKF4sr4DO1lubk965ON1pUJ/NbckJewQUWXRLoWXIZun2n6U8Fck0OhFj1zAQO5aWRJWkKGfH8Z3Wughxb9WZGJoguTz5vT37fGDuiBfRO2vXffJ6iM/Q0XjkwkiVBKmyiceGa0xm53eT61kmxDFRTJHt8zKXf/xX5oZBDLxnI6GAUHnK+GIy3fMSMUZV4gA2O5VOemZ+QG5qcbCnBUgN0KrnSMy827F3oUhQfbfIeph2rZw9kgTLJAkmwJxgaJ/A2eQ+Jmm8DEELkD/u1f8vyPJMoxgx/wRVkF/q7PGYxpB5fp4p37JgacVFJze6B+nSmcPmN/Q7iL0mHrI84GU24f/x3WjvyNHp2Tq8G+Tw3AqBYCIHBaJgX3Oijr5IKnlB21iRFAPLvpf1yomcgJE3udwrn9oeRNPw8QjWp/4yCTBGnjM+DTMMrHsZ9q8lwhg89ptT3K0NXIvxr+vuc/XhEVoXuZVcj3Ps4ctKCbJ06a+6X93h+R3UIeDyZSSOPF030ABX3+fqlh4LKzRcXexc2d8voT1jpemtbj8DNl4d/CRU= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(346002)(396003)(39850400004)(136003)(376002)(46966006)(36840700001)(47076005)(2616005)(82740400003)(5660300002)(54906003)(82310400003)(2906002)(83380400001)(36756003)(70586007)(478600001)(7696005)(70206006)(36860700001)(86362001)(336012)(186003)(6666004)(8936002)(110136005)(44832011)(316002)(1076003)(81166007)(26005)(4326008)(8676002)(426003)(356005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1972 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 95eae9fe-66d5-4e4f-d45b-08d9475004ec X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nk5XIr/UKudfI42foSjJ2rNTRwhmPkR/+0gqtjbwg7QILbNblvca2OcvI/FrlR6eCPRhmLePUyUU0es9G9OPePHYVrQh0PAa5GVESZ7vZ4P7wTPQrBLjC628Tz2azp3BMdJqKDdztQJS/8456aW8P22dQwJbuo7LNqI4DUDUUFfFIVErOMzw3JdA06uANpWYjeOR5cCXpoHs7QKZVBYN5vo3dkxs4NDRLTxtSppAm4EB0TELYe5s//OB4CF7d/qkbaUMs6kwFA/vZ/rYluMLA1WXk82KiSqLykEnOdAp5X0iG5BR7qZttBhlIZZWiIZea4ZlaNFIUJhR/d4C/yRV+vsMW3JqMpHzqRUiGfkeXBcH/gFpQGllKOiQXykQwCAfXZTsroJsQKH9DI8xQvmXMo2bnnZ55TcIlByNhe4g5CHjmUkViO+DJoKOCYA17jSkiMDlWZzFAhWC63GFUDujF3AznPCMjGk6VgwHa4dkqGj6EECDapj7VASKHSdvxgH79mlKCsj4Q5/p2SqnlrjT/BoEd3HQKyJmMrqqtea3T5biP9qEuUbhkYDhINw12RGlRT9WONBlChPNTQxlLKqAm58GtXAbTKBcCohIPLiCRAY/4p/3bhaKbFSEUcfS7lgWf/HmgO4m79IzMzFMDKfwCuKUrMX10ER9kQd+Um3bJ40ucG85TpM5KzPb3fm8C1qO5RayyKMiv58820MekyyiAA== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(346002)(136003)(396003)(376002)(39850400004)(36840700001)(46966006)(2616005)(82740400003)(2906002)(26005)(316002)(8676002)(82310400003)(8936002)(336012)(110136005)(47076005)(426003)(44832011)(36860700001)(6666004)(70206006)(70586007)(4326008)(186003)(1076003)(86362001)(54906003)(478600001)(7696005)(83380400001)(81166007)(5660300002)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 05:18:56.3728 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b727ed82-b5cf-4ddc-0ade-08d947500b78 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: VE1EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3523 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1626326387607100002 Content-Type: text/plain; charset="utf-8" In order to deal with the trouble of count-to-order conversion when page nu= mber is not in a power-of-two, this commit re-define assign_pages for nr pages a= nd assign_page for original page with a single order. Backporting confusion could be helped by altering the order of assign_pages parameters, such that the compiler would point out that adjustments at call sites are needed. Signed-off-by: Penny Zheng --- v3 change: - rename assign_pages_nr to assign_pages - alter the order of assign_pages parameters --- xen/arch/x86/pv/dom0_build.c | 2 +- xen/common/grant_table.c | 2 +- xen/common/memory.c | 4 ++-- xen/common/page_alloc.c | 21 +++++++++++++-------- xen/include/xen/mm.h | 6 ++++++ 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index af47615b22..476f8a2012 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_page(d, mfn_to_page(_mfn(mfn++)), 0, 0) ) BUG(); } initrd->mod_end =3D 0; diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index fab77ab9cc..10b23f7e09 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_page(e, page, 0, MEMF_no_refcount)) ) { bool drop_dom_ref; =20 diff --git a/xen/common/memory.c b/xen/common/memory.c index e07bd9a5ea..8c7c9c8fe4 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_page(d, page, 0, 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 15edaca227..3414873679 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -2283,8 +2283,8 @@ void init_domheap_pages(paddr_t ps, paddr_t pe) =20 int assign_pages( struct domain *d, + unsigned long nr, struct page_info *pg, - unsigned int order, 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(d, (1UL << order), pg, 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..65ba1587ad 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 domain *d, + unsigned long nr, + struct page_info *pg, + unsigned int memflags); + +int assign_page( struct domain *d, struct page_info *pg, unsigned int order, --=20 2.25.1 From nobody Sat May 4 12:28:43 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=1626326377; cv=pass; d=zohomail.com; s=zohoarc; b=USUipBF0k4n1RzJlOxJJjTkq1ngu3u1utzjCOeUZmu4SIjO7KqxgyG45Mx9k49/RqOjfeOWsLjTLMBLT+YYk50wUVHVCZg+s7FfRaZsYTlfsdSLd0qn7CJT9UcoHgGTYzaTxDcmdulPKjmFzHr9erz640qtB5JCBDCHXaCV9bUk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626326377; 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=fRL005ZOzyUYob7GB42ihy+z8eRo0qovo722B7cMwsQ=; b=H49r+XGcBJZjwwMmHjgB7RrcX08HQBprfLptU9T8+ZsdIvY+bK/oseoEXdC4hgj4npgjrTybzMLd7bb2Ag9SgUPx7e0gEinnGP9y/dPhvNyO1O2IpGJBzFWfAUVM+INAc8ksfiW3KtBsVj+lSkuW0B3z258RNn2lyiK1KKuED8Q= 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 1626326377275131.3330364039009; Wed, 14 Jul 2021 22:19:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.156306.288459 (Exim 4.92) (envelope-from ) id 1m3tmF-0002IW-5D; Thu, 15 Jul 2021 05:19:15 +0000 Received: by outflank-mailman (output) from mailman id 156306.288459; Thu, 15 Jul 2021 05:19:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tmF-0002IN-1x; Thu, 15 Jul 2021 05:19:15 +0000 Received: by outflank-mailman (input) for mailman id 156306; Thu, 15 Jul 2021 05:19:13 +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 1m3tmD-0000d1-8P for xen-devel@lists.xenproject.org; Thu, 15 Jul 2021 05:19:13 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (unknown [40.107.21.67]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2b421506-e52c-11eb-8891-12813bfff9fa; Thu, 15 Jul 2021 05:19:03 +0000 (UTC) Received: from AM5PR0402CA0006.eurprd04.prod.outlook.com (2603:10a6:203:90::16) by AM8PR08MB5841.eurprd08.prod.outlook.com (2603:10a6:20b:1db::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.24; Thu, 15 Jul 2021 05:18:57 +0000 Received: from AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:90:cafe::bb) by AM5PR0402CA0006.outlook.office365.com (2603:10a6:203:90::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23 via Frontend Transport; Thu, 15 Jul 2021 05:18:57 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT023.mail.protection.outlook.com (10.152.16.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:56 +0000 Received: ("Tessian outbound 664b93226e0b:v99"); Thu, 15 Jul 2021 05:18:55 +0000 Received: from a1ba4e926fae.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FD5AF517-0840-4626-A15A-374C238A8F74.1; Thu, 15 Jul 2021 05:18:50 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a1ba4e926fae.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Jul 2021 05:18:50 +0000 Received: from DB9PR02CA0029.eurprd02.prod.outlook.com (2603:10a6:10:1d9::34) by PAXPR08MB6955.eurprd08.prod.outlook.com (2603:10a6:102:1da::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Thu, 15 Jul 2021 05:18:48 +0000 Received: from DB5EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:1d9:cafe::cf) by DB9PR02CA0029.outlook.office365.com (2603:10a6:10:1d9::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:48 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT051.mail.protection.outlook.com (10.152.21.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:48 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Thu, 15 Jul 2021 05:18:47 +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; Thu, 15 Jul 2021 05:18:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2b421506-e52c-11eb-8891-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=fRL005ZOzyUYob7GB42ihy+z8eRo0qovo722B7cMwsQ=; b=kQep5TAN5tC5JTbbHxBLsPQ4jDg/ieqgx0ESNx8M2w4mCVidLIzFJY2Ty9XmliTjT01VyV7WCxnpYxGc481ngPtA+Je48dx2ZJapWgXWcrN7ohzydKjo5ifoCjVfH2ACt+tfo2CbIPW9aYDfnYRolo/erFoBVXrSwu+86MWf0k4= 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: c255fa28a77e015d X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fl6u5QvhFhkKhpshCA24zksRd/BW9LrFSkq74S6i9qS+OgE1ARTDUBaa673CEwez21e5CE76jLHGahWH7GJqtxOO/uEvtTD8ezwtJoqQjapVx4dcQgAbUhlCNNxPHPV46I2KYyLg0zXFvb9UAzxo9CjBfxCf8aDn810PEuH9wD+81f7apT3S3fTH8EMSOyyIHaFgCWbHsS7UzYIGes7iuielvAhJF9BsXTSyRSWqkqCiLOdkV4W1r4t1qLl5YNZJPKTRk2mfE6yaAm52fOEv4XImWyoqf6PA+MUvSR2T+wkBDeOFjEGKg9WKO8Tpq7zpYH6AemuDmH5EVtpoB49u4A== 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=fRL005ZOzyUYob7GB42ihy+z8eRo0qovo722B7cMwsQ=; b=QeGKdxEPoTxxEpOTp+77EKkua7BWEArxNiTPrtF8L6qgo5SVqQXjIB3SUnZmg8op70mOPu40OsvwXSZYDQnX+PAZKXfTNwVDR0rl+3iHHvLvBihd/tx/WWu2IwIi4f7DBQekyvM2GfFPWa98eJfJ7wDSRiEP4ZTMRy5ri1wuVY/puKxe++K9GM68ErW4Tg4b780pavggjFiSPVw2IKX4qQqZN6oJGWiPAI/XH2QXn8WbgQgApEA+ouHpYFScVSb6Xtbs8gngQcRwE1xyjRad5BD7WHPizSTg5tSoj12tjOhmCEVC02whGcTzDKdlYEM4Ky0nDXUwUouQCeCavi8TMQ== 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=fRL005ZOzyUYob7GB42ihy+z8eRo0qovo722B7cMwsQ=; b=kQep5TAN5tC5JTbbHxBLsPQ4jDg/ieqgx0ESNx8M2w4mCVidLIzFJY2Ty9XmliTjT01VyV7WCxnpYxGc481ngPtA+Je48dx2ZJapWgXWcrN7ohzydKjo5ifoCjVfH2ACt+tfo2CbIPW9aYDfnYRolo/erFoBVXrSwu+86MWf0k4= 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 V3 08/10] xen/arm: introduce acquire_staticmem_pages and acquire_domstatic_pages Date: Thu, 15 Jul 2021 05:18:17 +0000 Message-ID: <20210715051819.3073628-9-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210715051819.3073628-1-penny.zheng@arm.com> References: <20210715051819.3073628-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: 529b03ff-b151-47d0-3ebb-08d947500b83 X-MS-TrafficTypeDiagnostic: PAXPR08MB6955:|AM8PR08MB5841: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:372;OLM:372; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: lw6E0lza0AIft+/iP88Ob9++4lZFOaArxPenzcw96ksOM1b/HhJIK5bx0AKSg6Y4yrzRmFx6VJ8RTX444ubOlRJMFE40KY77TULdTY65zCCfvtTLXSf+RszXMfabtdyDvK/gVPKtjca4xsAnmDYNaZs+Cb2jarEGxSenmgEWhCu1vIoKXwHRu0B86tq4ei+Se1nmpVjOj3b9NWMCft8ARolkUDG1ux9U4wVMuKj5ZhmZPB5F59Zg6iPR10lrz9XD0IMunq+Mqo9KxfLOzoADqSt0WnRsI0TSFQnICHj+jgYilX/nZqO4LyC6nqeKd30rDsjJcndppfyl4G8DE4uUdFt+BCcLZ6JuIxd6ZoXLAd4XeT+GRtkFPgCpDaIjigCrJ/HRewryj0PHVV3JQOkuEZg41b+tnMSk2mmgxxt8rYX5kuCAzIXmmqSDlMLQ3kZYwxA+2FhZjwdiogYjnSuBClB2xPJibDzBfl9YmSSwTuTKG1OGRM+5n7hMwuj3i7E8SU2+gUWNjkZHVxVGaEmBEmBQV9FqpimiziUsnQaTTkryExD9g3DBBe3bhNdmNG6CnzqWeV8rF4hTJ9YobIJpabl1rR7jSzvGiVh9tQg0NoJMQc9Z39YxAuRA0r+jbwSo0GmtTB/ve/mm4jERZVV0ybZLr1z0tm2bWN8zo2EH/PjXQ6Mihm28CsHebtNIYkjr9yE8ldTmoPg11p/YTkwCaxg+zEgOPnNtr6ZGGm15eMk= 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)(86362001)(110136005)(83380400001)(6666004)(2616005)(70586007)(36860700001)(4326008)(70206006)(82310400003)(336012)(2906002)(426003)(54906003)(44832011)(1076003)(478600001)(81166007)(8936002)(7696005)(5660300002)(36756003)(8676002)(47076005)(316002)(186003)(26005)(356005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6955 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 916338f5-50d2-4b80-bfb5-08d9475006c0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bJhryEudsBPP4pPAxxvlf2qWF7sVSWGieSwi3zf5f/LpNK+pVKbUMzu6tmmghr6MTEmSDl/VUUwcrRkc8oja/sPaQZVvewphdCK0TCP6bGlvayxtiwsLzOW2pOZSfKNdx5NdWo/WWInnPbJGD+klPfip119wU6ZEGYabt8WhRKZHK0X0go1zBRNiTskU5twkGauLQlJjLTcc1q2JHx6qfH4K+6Wz7tJ1G+aiRreUeekHUCvUMiS9g9q8NRwUz0QU7FDYP0A4rCQn29xsb9lsSl64FjjY86g91dvobnoh2DrMJr7jhwivUy5g6IeBNrfXmo9fkshzsdKwByJnNaln3SqjKnKeELA7ouyKHm9mbP+hMv7BD/H2EEbtcFmqsMpzeFy6/KidZTlod6oKzW2lBHaEoctPpnYs16nYhFHohXA5mL/nIfYGjCPtFfdb2+mPNN5fs8BGnb6OMn7hACvJB+7gH4BT4yAV8zFJVmDnMrWSmKW1ryz5iFgZEOIVOUDMq+Oes4eYLujSdzXyz3whj2kb6Oab3f6xpqrusOph1ErFrpXUivc6a760weCGEdUCzcvtMYaHS2mFkfis+G5j9QUlWP+ejaR8/OD+Z9TokEy6k7Nzt4Dq6gn+IDmsqVFwE709e/ieCm8+J++hKCRhKb14WxlKXY2N2NVSxTW+Ihyh1KZtwZ4FODr/TNE+Q2Z7lHJTZGFn7O1hWWEWOZJ9rQ== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(346002)(376002)(136003)(396003)(39850400004)(46966006)(36840700001)(81166007)(186003)(316002)(426003)(7696005)(5660300002)(110136005)(36756003)(36860700001)(26005)(4326008)(336012)(8676002)(54906003)(2616005)(44832011)(86362001)(6666004)(8936002)(1076003)(478600001)(82740400003)(70586007)(82310400003)(2906002)(83380400001)(47076005)(70206006);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 05:18:56.5162 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 529b03ff-b151-47d0-3ebb-08d947500b83 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5841 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1626326379142100001 Content-Type: text/plain; charset="utf-8" acquire_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 --- v3 change: - Assuming caller knows the static memory range is reserved (and free), change name from alloc_staticmem_pages/alloc_domstatic_pages to acquire_staticmem_pages and acquire_domstatic_pages. - proper locking moved from the next commit to here. - remove and refine extra verbosity log - remove hunks' #ifdef-ary by introducing PGC_reserved =3D 0 - remove DMA restriction --- xen/common/page_alloc.c | 112 +++++++++++++++++++++++++++++++++++++++- xen/include/xen/mm.h | 3 ++ 2 files changed, 113 insertions(+), 2 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 3414873679..c9702533f4 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 *acquire_staticmem_pages(unsigned long nr_mfns, + mfn_t smfn, + unsigned int memflags) +{ + 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); + + /* + * Ensure cache and RAM are consistent for platforms where the + * guest can control its own visibility of/through the cache. + */ + flush_page_to_ram(mfn_x(page_to_mfn(&pg[i])), + !(memflags & MEMF_no_icache_flush)); + } + + if ( need_tlbflush ) + filtered_flush_tlb_mask(tlbflush_timestamp); + + spin_unlock(&heap_lock); + + 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,42 @@ 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 *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; + + /* Right now, MEMF_no_owner case is meaningless here. */ + ASSERT(d); + if ( memflags & MEMF_no_refcount ) + { + unsigned long i; + + for ( i =3D 0; i < nr_mfns; i++ ) + pg[i].count_info |=3D PGC_extra; + } + if ( assign_pages(d, nr_mfns, pg, 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 65ba1587ad..69e3586d8a 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 Sat May 4 12:28:43 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=1626326807; cv=pass; d=zohomail.com; s=zohoarc; b=FUIYFpOqrXXBq9FEQ2PVKDX1FC0kybe6EFGjZTB0zQh/tq9PHG7XPWHvC9731QoZYH/GcNz0Flk8IqVGijHWvOWQ+bPLLGkAvgbeOOlZt0HWCf9g13UuH39vDKOJzGWKfJ4+ei3MI3WOybh5IP60lcM4TO2H1CtpWnEJh7rRY7M= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626326807; 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=CK13WEPiykjxkYvQEtnQO6uMs6AHKoPn7GF3CJWftbA=; b=BbYrxJAfK9yvVmz3FgrfabOfdEJUzDK7WwZNidB6Q+RBtdWY4bGgeMJYromoUufs8556ZfDlspGUznrFQc6bNd7d8W4bWePhAoQ65RXnfUUhPE+i+dWEDDGxPQccXDrbCft4dnS8WDr0cD1RlEENwYUYxCArmuuJhlRhLoKk67Q= 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 162632680769241.2691479144072; Wed, 14 Jul 2021 22:26:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.156340.288518 (Exim 4.92) (envelope-from ) id 1m3tsi-0007C1-U4; Thu, 15 Jul 2021 05:25:56 +0000 Received: by outflank-mailman (output) from mailman id 156340.288518; Thu, 15 Jul 2021 05:25:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tsi-0007Bn-Qv; Thu, 15 Jul 2021 05:25:56 +0000 Received: by outflank-mailman (input) for mailman id 156340; Thu, 15 Jul 2021 05:25:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tmf-00009P-AW for xen-devel@lists.xenproject.org; Thu, 15 Jul 2021 05:19:41 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (unknown [2a01:111:f400:fe05::61c]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ffe1faf5-1cca-4805-9c45-b9cb706201bc; Thu, 15 Jul 2021 05:19:09 +0000 (UTC) Received: from AM5PR0402CA0008.eurprd04.prod.outlook.com (2603:10a6:203:90::18) by AM6PR08MB4327.eurprd08.prod.outlook.com (2603:10a6:20b:ba::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Thu, 15 Jul 2021 05:19:02 +0000 Received: from AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:90:cafe::db) by AM5PR0402CA0008.outlook.office365.com (2603:10a6:203:90::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:19:02 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT023.mail.protection.outlook.com (10.152.16.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:19:02 +0000 Received: ("Tessian outbound 809237f40a36:v99"); Thu, 15 Jul 2021 05:19:01 +0000 Received: from e52574fcc35f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CA43D9D2-B9F0-4653-8DFD-6424E9771655.1; Thu, 15 Jul 2021 05:18:56 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e52574fcc35f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Jul 2021 05:18:56 +0000 Received: from DBBPR09CA0037.eurprd09.prod.outlook.com (2603:10a6:10:d4::25) by PR3PR08MB5658.eurprd08.prod.outlook.com (2603:10a6:102:88::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.23; Thu, 15 Jul 2021 05:18:52 +0000 Received: from DB5EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:d4:cafe::7f) by DBBPR09CA0037.outlook.office365.com (2603:10a6:10:d4::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:51 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT059.mail.protection.outlook.com (10.152.21.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:51 +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; Thu, 15 Jul 2021 05:18:50 +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; Thu, 15 Jul 2021 05:18:47 +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: ffe1faf5-1cca-4805-9c45-b9cb706201bc 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=CK13WEPiykjxkYvQEtnQO6uMs6AHKoPn7GF3CJWftbA=; b=a5MDWfeo1AQLWgPNoES02n1nb0AJaAyLL7vJ1RR9R+kFUwysSoKogjew+yX4yHDBq/uYZa8eOkrX/Uf/FpJsIuAMvwI7M8l0NAoXG5n8yzZdq/MPSu34tcJb8KJ1xGXu14RRWY09gvkpjrh1DzPDPF2YDce6wxhqep13rRN/gig= 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: bb76193209225271 X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fC7Uma5fVRKFWms6CLHOyyzsl9IqiGSwEJ4+7Qf5zK8pzxy+g/2oX4YAPmpKgffaGt7sdwBvTMjU4zDhLnvbS6xcjKClr89e6VCFWEea2Dt3BAMVHKJfhgd1In84qJ9fs+Pq/eqJbCQCvorpE5Qzm9YzbjwdyGAx9pL07akwDCrH6wG/Mr8U2JxTeUWc1Lbc2E1sTRft4hERRld69QsoRbz+5KFJX3UpQLqgaFnlVwm1+V32kHE1N1Qf6IwkYnA2ylFAfVGKBQfuelLMgtENTXWvyHQqIsxSocsI1kHQV5792M3v4lFFuqChPvX2PepSwgnCrEo/kat8DlGo5vi1Qg== 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=CK13WEPiykjxkYvQEtnQO6uMs6AHKoPn7GF3CJWftbA=; b=F5z5Yth8ptdOpTv7sslxFhTvTiMkIKRZiF5Bab1W1TONYosMLrE2EOj9POHfYjLp0IhyaSca9Uv3bEV4s6znH2CGDAYJGytPnDHQSwzolU9UtUd2dRgP7MICUmQy4N2BDcIgqWBfyrN+O06uQl9ZLPgZcqhEddKKdD08h966KNA3w+Shk+62a43pWk0dZAUCK/k6fIcG7zAzqLXCLnpvv6nG0n/2a8vS4tnM/6WH65Hy6FxCUJ1egggkjrCo++1kYy0O1bI53nCvFVTZ2Ru9Jn/fthMe8oK5fyH03I31nsCTnY/3YJ8LQxf4nZ6mv9cgV6cA8o3hpM/wcLWAHtXvEQ== 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=CK13WEPiykjxkYvQEtnQO6uMs6AHKoPn7GF3CJWftbA=; b=a5MDWfeo1AQLWgPNoES02n1nb0AJaAyLL7vJ1RR9R+kFUwysSoKogjew+yX4yHDBq/uYZa8eOkrX/Uf/FpJsIuAMvwI7M8l0NAoXG5n8yzZdq/MPSu34tcJb8KJ1xGXu14RRWY09gvkpjrh1DzPDPF2YDce6wxhqep13rRN/gig= 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 V3 09/10] xen/arm: check "xen,static-mem" property during domain construction Date: Thu, 15 Jul 2021 05:18:18 +0000 Message-ID: <20210715051819.3073628-10-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210715051819.3073628-1-penny.zheng@arm.com> References: <20210715051819.3073628-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: 0a62aa47-bdd0-42b4-da9a-08d947500f0e X-MS-TrafficTypeDiagnostic: PR3PR08MB5658:|AM6PR08MB4327: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2089;OLM:2089; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 8riS5oYdvVi8mp5n6I7k+m6n0i7pshd6QcHS54ufR/OEnUTQUDj4Y/NCbmMQqecGlU48YY83tAj4JsD38opiLo1w/J7xqt5Hq8qek1ZzwcxKz6IbU9AESUV2YE48WxpXzO4ewvzY+z0MKLTxGmtQPoPbpKXmKWASL2ho9QIUjzAxkPno/qu3+rTZSxOf2CGIUA3r/QQKnM8kdrc2pzFR8vCGAQfUOo+fP/nwOGCxmVQRI6hD0uZQ/C3A96WgrcenaXwsYjcFQNNEPRHBfkwP43nDFgyfpog+0qI6JsyBGzu4VFXLh6Eh5ilX9fddlTQLltnEcxk07R15Hbi8jkxr7ZmLg3CLvXcjs6+IvaSmybCPZq4iSzjNddd0JZBWPWC5S8M7Nbd2pF3HRy8QfXZi7i2zjfKGqOtl+326F3nwF9clu7fx7iIpXN+M7ux+6I/D8ImGm+xj3HM8oJ2aRweJ1ZHZwerxD4m/yv2xGfi/A0QW7OH7sQLvO5zVRsnf9wChiLjFt88QgO9T5E8hwU+yao5qU9yl961L2YaA+rCjeC99I22EycdCMD14gMWHltgMRZ4mcyQdfrwaJlE1HTO1jLbofdT1rTbBY1QBqCywcwbWfvVJCCkA5O5LXjmsMchA5PagYxR8ib+SxJ21V342gFNSwcb6xWdAYE3DW4P4Jv0LOudixCUnSKmK0IIrjL6BFW7ebMZHxMr8khS4NXy1fXylWVcTDWzwDg+wbTRDJkc= 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)(39850400004)(376002)(136003)(346002)(36840700001)(46966006)(6666004)(54906003)(8676002)(316002)(81166007)(83380400001)(426003)(336012)(86362001)(110136005)(4326008)(356005)(8936002)(82740400003)(26005)(7696005)(186003)(70206006)(82310400003)(2616005)(478600001)(5660300002)(47076005)(2906002)(36860700001)(44832011)(1076003)(70586007)(36756003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5658 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 9b187076-24ba-47f9-06ff-08d9475008a5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VTSLaOTEGLRptKXgi4lKzwswGZoHzG2Be9Weh/+rO/vkMqLqrXXWBH88mxEiIkP2au2C28OYch6qv/OiRpV04B9p0FBZIqNriEuyIbkUBZvxDwoja3lvW2Evb3vlWRendWLbpW71IIgApvWS3CjEbQyc7YbkW+U7kxIE0YUz7c9lvML9BNH45kL6PEEaEnEWf0pkD6vsOgbQLgyzO4EF6S3gM1Gx53EorZNWnkIX7mZoULQN/BR57yBrXnLzEQhwcediUyS/FwHner/it/oHJOFsxz3aPvfzhq30X6g7GEV/qabZjOzD72hMlld2CfZqgKyPWENihjdNYY/DJgoes737NZ57+CTCQj/g8eD3M6kTr+RW+FHGezBMeKbXkYWN7EE+sxCxMgGAFsV3HffRvVrEwXIJDQJJu1vdw28GUoFn6CcFDJFicvoVD/iKQvcheuzJ/ttjmCW8IMqGOpGejafO/H8LTCY55a8zerZMiBr8/rCtxZXokmEP0kP56WAdYdqQk7UijaXO0NoOWyprMaVfgtpf5+V6oAzMpap2kq1eMskqdmcQfYO9ZEKX/lI9rtXntd/rgpDbrvIVvUlxE7Lxndx6RKAgi4dlsBSqdssstxVJY5ckg+CU1ktcBSmDe+lf/9RbNqSeyjU/tyE6y+C+SlDrS1y+/MVezj+fLGovEulyp0SOg7ADSzxrzdM+Mjf7W6ZhJpNxutZJWgxvQg== 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)(82310400003)(7696005)(70206006)(110136005)(36756003)(8676002)(2616005)(316002)(4326008)(426003)(336012)(8936002)(5660300002)(83380400001)(86362001)(2906002)(44832011)(47076005)(1076003)(82740400003)(54906003)(70586007)(36860700001)(478600001)(26005)(6666004)(186003)(81166007);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 05:19:02.4703 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a62aa47-bdd0-42b4-da9a-08d947500f0e X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT023.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4327 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1626326809509100001 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 --- v3 change: - parse "xen,static-mem" in way of phandle back to property - The return for dt_property_read_u32() shall be checked. - "memory" property shall be mandatory --- 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 Sat May 4 12:28:43 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=1626326390; cv=pass; d=zohomail.com; s=zohoarc; b=TfYjQXw4XdKvAcWz2BHa2b5pgoAkCR9h8rHlUW4UBKRdySKGPblIKmuoXS4iuqf35/l7djfhwFO98jOqVxYRdBxT+M/TE0a7yFo7cveWFwTohs5gckQ8gWlStzIdNa00S49OouercH2+ZXWH523M+FPSXyD/g2dtfnGNXY8byss= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626326390; 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=BrIS0ljVOjpyPmWzYJmYIt9oJx/MQiYDNEJHUoVAXFo=; b=V9SVMS0gFypomLkA3YCodvrEtxpe93mCa/1Xw1zDIh7AZiSuDa4tpmjmVWC5zPeUI2bCqyj8Ad0+7ZlAMI2Jv/X53nRtekOQdmxaDv+Vk4V1kmb0S/sOdGNis3OhmGIM+awDcWCx23D4uXjgQsmSwoSLThMf/uulNhyaYW10dhY= 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 1626326390821602.9612267742763; Wed, 14 Jul 2021 22:19:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.156313.288493 (Exim 4.92) (envelope-from ) id 1m3tmP-0003cz-DH; Thu, 15 Jul 2021 05:19:25 +0000 Received: by outflank-mailman (output) from mailman id 156313.288493; Thu, 15 Jul 2021 05:19:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tmP-0003ci-8U; Thu, 15 Jul 2021 05:19:25 +0000 Received: by outflank-mailman (input) for mailman id 156313; Thu, 15 Jul 2021 05:19:23 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1m3tmN-0000d1-8t for xen-devel@lists.xenproject.org; Thu, 15 Jul 2021 05:19:23 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (unknown [40.107.4.41]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2d671e94-e52c-11eb-8891-12813bfff9fa; Thu, 15 Jul 2021 05:19:07 +0000 (UTC) Received: from AM6P191CA0077.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::18) by AS8PR08MB6993.eurprd08.prod.outlook.com (2603:10a6:20b:34a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Thu, 15 Jul 2021 05:19:05 +0000 Received: from AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8a:cafe::97) by AM6P191CA0077.outlook.office365.com (2603:10a6:209:8a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:19:05 +0000 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT064.mail.protection.outlook.com (10.152.17.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:19:03 +0000 Received: ("Tessian outbound 57330d0f8f60:v99"); Thu, 15 Jul 2021 05:19:03 +0000 Received: from 19c93b6d551f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6BF246E8-9EBA-44D6-8493-4913E318A1C7.1; Thu, 15 Jul 2021 05:18:57 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 19c93b6d551f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Jul 2021 05:18:57 +0000 Received: from DU2PR04CA0026.eurprd04.prod.outlook.com (2603:10a6:10:3b::31) by DB7PR08MB3004.eurprd08.prod.outlook.com (2603:10a6:5:1c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.24; Thu, 15 Jul 2021 05:18:54 +0000 Received: from DB5EUR03FT058.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3b:cafe::47) by DU2PR04CA0026.outlook.office365.com (2603:10a6:10:3b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:54 +0000 Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT058.mail.protection.outlook.com (10.152.20.255) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4331.21 via Frontend Transport; Thu, 15 Jul 2021 05:18:54 +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; Thu, 15 Jul 2021 05:18:53 +0000 Received: from penny.shanghai.arm.com (10.169.190.66) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Thu, 15 Jul 2021 05:18:50 +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: 2d671e94-e52c-11eb-8891-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=BrIS0ljVOjpyPmWzYJmYIt9oJx/MQiYDNEJHUoVAXFo=; b=zmss8hqp5IJYu0gMTpRawntCFAVuN8+R8YC/2Ed0gHj9566zQCYdL7k5xJCrs5yuehoPV/7WpOqTZKoiToHgzUi2UJIisAOJZMrNJzUiL4AN1Aph03xhOIM6yHV6ctt1Vh5P9UOGbGID8CkvWPCBCimNV47rQeW/k7mOpLyIrjs= 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: e9756453b971cd8c X-CR-MTA-TID: 64aa7808 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l38+/XmSn/wzO6ZBgbOLRYUdIKkpwN/p5GinDDJlfXS/immnfkfMWeoJyGfoBVQrDm2MeNE+x+bBEHAL7dfxC4FO+fc8IaF2jwt46eGmz11L6bEjNiljPdgmF4iSosEHOEGWnOyQSsRSsZDQWsqSukrmbDn9/oeyKEpPEp4VqTjTzobnjdHaAnIgwLs2Q9m00SPd8mj1do77sCBm8ncebIvIiyLjiHDB1RYD8IbxSjPvSL6KFlf06u8cAJPlJF+7/9es9RYPyo5BiPTL/+gl8BQFC7rn8cmOBD76rMdAYYQBUEEN79bUuSLrYUqg0n8s+kift/cW+/ei0tRtpVuibA== 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=BrIS0ljVOjpyPmWzYJmYIt9oJx/MQiYDNEJHUoVAXFo=; b=Z/6wK5CsdKlvyEr2fbyHvpWbrJRxXl/QPMfDhZYz8quAxZ2undWaKp9hKA5erkAIG3+jWYcN1iLAxHziaCQwLj6hLbjy7HtiMPUsYv5p9F/OoXR6ugg8leMXpzEAdUwuAIoEN+X0usPp/c00o6UoKwauB4gc2gdUnmO61DiwyoQ+Sd6NLwpNv/COasWuulZcqFzSVjrUODmY5psxQtQzzu+yJkY8SyJQNg5hU1azq23Nu/sGItud85LUQj6k4T9V5MWeOlTFPWUhx0nQgyBSWpZKFAPCKAagW9szHE7476oVOs2oru0V6KjhRhhhRYOQ2422uQz03P5R70hgXmgF9w== 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=BrIS0ljVOjpyPmWzYJmYIt9oJx/MQiYDNEJHUoVAXFo=; b=zmss8hqp5IJYu0gMTpRawntCFAVuN8+R8YC/2Ed0gHj9566zQCYdL7k5xJCrs5yuehoPV/7WpOqTZKoiToHgzUi2UJIisAOJZMrNJzUiL4AN1Aph03xhOIM6yHV6ctt1Vh5P9UOGbGID8CkvWPCBCimNV47rQeW/k7mOpLyIrjs= 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 V3 10/10] xen/arm: introduce allocate_static_memory Date: Thu, 15 Jul 2021 05:18:19 +0000 Message-ID: <20210715051819.3073628-11-penny.zheng@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210715051819.3073628-1-penny.zheng@arm.com> References: <20210715051819.3073628-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: 4ef8a027-b617-474e-c389-08d947500fc9 X-MS-TrafficTypeDiagnostic: DB7PR08MB3004:|AS8PR08MB6993: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:5797;OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: LJpQTZ/jBUl/ES2zt6QEDxm0DwFNOuKS8lmnasg6Bl0wanvFHnZ1JvIua/PgL9OjyvPjfGQ8SKI6JnhxTGktjvazT8npqC3mWIAD1AC+xR0E9bH1Sdpbw6PsfmGbSS5Ezhp2X6AsqeiNgQb7xWytRrWmqpScqXO7fZgRgBkorL7LvGDfpeaDDWaeXDJA5d1g6bJkp3MlXJBtVkJd+tiln1IwRFYIWUca1xmeNr6uGc7dAmKYYiTTl557NsM+odgetlCaH/DNkTKZ3hR3I3tuAAiSXucqsIF/GhPrWnYMyTYqGtN/E5Kgb1iCRq9/f1WvtjlMtNkVkuChyKd0z225tTjnPA3iDC8LNFG6Ofejrb408CEnkZ3WTP7rxJL/e08M06opZI63RayIwKx8jKCCSaagTZorI16be9YDs0ExYisZeNrl9UEm4i8hKA8mPekIDwVuTqx7pLwrL6SeM0Zzo4SYa67guzNvmKiFNhOWP/5mJjgEsEypKbXAwN48eSmi2AMrdXZSKwLrkjuM0yD/6mzq+GtlnhntU+95unKtBS3QTHmsNxecUM9Kb2FC8luU3ZFIdl/bkK0cER13HV6oWNxb+vkjuF05PVTT+A3DkyL7uyCjGnuoSF9rMuiT4GPf3WBBz2vy8Jw6zdaAXsVR0NF2JksUixA7/TzJp8ptI+ajbKd+JdGxM0W1U9ze7lL6MrXW8u+L+orXPLElwXfukfayHU/8W957L0+A9uTBNC8= 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)(39850400004)(346002)(136003)(376002)(46966006)(36840700001)(186003)(54906003)(8676002)(1076003)(7696005)(478600001)(336012)(70206006)(47076005)(70586007)(356005)(36860700001)(36756003)(26005)(81166007)(82740400003)(5660300002)(44832011)(8936002)(6666004)(86362001)(110136005)(426003)(83380400001)(4326008)(82310400003)(2906002)(316002)(2616005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3004 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: b4ed1b81-d0c2-4aba-0383-08d947500a60 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vEGtfY6nlEQGn8sxf2PmMlltnr81GVz7VhKn3LXs+D9AmwkTyxXIkMzQDjNEfMquWalEgFcVEjQIQKzaz1FBpZtJvsUPXe+mhkPhL6/5yAPEfo7yF1GHOmRQQD0wYdUyfjo0iKPheHslYXGOpvFRsnfShQSSinbOyMEnvAXnjliK4vPAucbNcyPacGfsu3Lv1d8c3IPEl1oGmfkuvWW3mBIF7+pyDmkCKd4bKN81ZMb7e8inunDxkXFHjKwMdhBE+DzbJWjmneKpcETVL0sVWOXlw6dbdXLMiwfRIpjBktzgoxxnJbWKVwE2tmSRy5JpFoEoPzmnEtkgmtRzarrY+mWNGKpOHhAWI1gMaAUM1nCB8gbu3f+KP/2YE78jonTq8D2jhAjJb4kLDsMv+B9C88Mdh4YxqsSqO652nag34UgJVUrwD9gGcl4KtlkKR9Ol2YuIIUgDPc0vXT6IrObhhWorDWM1+iSvKw+s1PLi1zs614S6I6b6tslMX3rurpaau+BPzhRirZv+X//8Jz75Huw0SIsvxc+qtmuKF4xb+hLESphEP+4vWB08w5+Yk1SKoviTSCK015+4WVYgVrXOn2Uv+o+awksX5VjqacWEqzo8jeGIqQz55/Y/UhxXd1B2GuhBFsPdiRgeXqpMZayVVB6kvu3wo6bz5pKsJPom6IxLelHcot0qXovndtKDQNlcj7OwFll1/KYeXVQ1TKyTFj68Cfdws6V6NeO2dISnDnE= 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:ErrorRetry;CAT:NONE;SFS:(4636009)(396003)(376002)(136003)(39850400004)(346002)(36840700001)(46966006)(81166007)(36860700001)(86362001)(478600001)(8936002)(36756003)(83380400001)(47076005)(82310400003)(82740400003)(316002)(2906002)(110136005)(6666004)(2616005)(1076003)(426003)(4326008)(26005)(5660300002)(186003)(44832011)(54906003)(7696005)(70586007)(8676002)(70206006)(336012)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2021 05:19:03.6892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ef8a027-b617-474e-c389-08d947500fc9 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: AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6993 X-ZohoMail-DKIM: pass (identity @armh.onmicrosoft.com) X-ZM-MESSAGEID: 1626326391838100001 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 --- v3 changes: - parse "xen,static-mem" in way of phandle back to property. - use unsigned int for index - rename allocate_static_bank_memory to append_static_memory_to_bank - infer the next GFN from the bank information - simplify the code in double loop. --- 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