From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.73]) by mx.groups.io with SMTP id smtpd.web10.4702.1627996235093030893 for ; Tue, 03 Aug 2021 06:10:35 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=Mf2+yGlz; spf=pass (domain: arm.com, ip: 40.107.14.73, mailfrom: samer.el-haj-mahmoud@arm.com) 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=myEU/AqLtxJRfEUcQ02sIJJ15KORFPCC7noxIrPNp24=; b=Mf2+yGlzHvuAg4icYot9+zbWz6ZC1IdaWa+6suSgmYsU8mZZy+qvhPwKYQLqIfq0NXcgRKJqZ5Z/3awSgJZyV/gFcgZtlIIXiCh+PGkULl8dmK6ipr0+qgEutTCP7HARWodsb+Jkmr3qlGSJ/y0X74Hrqy8Tvr6Yw/YIyWZy3mw= Received: from DB6PR07CA0197.eurprd07.prod.outlook.com (2603:10a6:6:42::27) by VI1PR08MB2909.eurprd08.prod.outlook.com (2603:10a6:802:1e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Tue, 3 Aug 2021 13:10:30 +0000 Received: from DB5EUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:42:cafe::5) by DB6PR07CA0197.outlook.office365.com (2603:10a6:6:42::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.10 via Frontend Transport; Tue, 3 Aug 2021 13:10:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT022.mail.protection.outlook.com (10.152.20.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18 via Frontend Transport; Tue, 3 Aug 2021 13:10:30 +0000 Received: ("Tessian outbound 8529ae990a93:v101"); Tue, 03 Aug 2021 13:10:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: da9c64f462adc4c0 X-CR-MTA-TID: 64aa7808 Received: from 9cfed55800d7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 497EF972-C70D-4BE3-AEE4-1F3FE018FF8F.1; Tue, 03 Aug 2021 13:10:20 +0000 Received: from FRA01-PR2-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9cfed55800d7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 03 Aug 2021 13:10:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MmbNK6cl/ITEjF9DBIcGsEtuVhT3ju4aaNo9cYeWA9gyHhkGMzjJTCa6LCH1FIxDHMpQ1HXmLvcuNvx5VOv3jrzBkJUXoodwJWPOweuwAP0cbkv/XcMNBvG+1WnXvoI8V7Ns9Jl9VMBBouLqKBOXy9XV+umsHZ/ItxCPCoO0JBn/a4oRTK93ME1qtRT1HxB/urmBvmv2vz0wKWUZM15izyVb0OOB10p6gg7ji5fnR/a2ctZ5Llg/5Tyzhz2arHfU+iPoNJ6dajeB+vaIw+XC+VkeHElPctSgSP79xe1rDOGIuZejggdmZUkZAutVjQuZs8+5hk0xBttoxy25gQDf6Q== 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=myEU/AqLtxJRfEUcQ02sIJJ15KORFPCC7noxIrPNp24=; b=Gsuj+mzGlseu+kTEgrozjM2lrtM7pMxHtnCvAKGfQSMt9S5BjbIAh3tKTAYfbCbWIEst2mKFwoFLxDEbVATKQ+5dRIgLrJdXogr2QR5/eA+1cYtzVxROb5eegzPpcz6hWJcO68aqHguqa0BHPRUMJeZiOv271GSejOLRUA1XZ7VcCu9My3jD0qnbzIo8FYwfk/TwQhLKF1lxO2Uy2CX10TB3KudF+T6q658e5R/CMGdXYRHpWz58FbpirfmNvagtG56gFI5WfT6UAnfkwzxXeGNV5PXXYTnNaxJmdBqGZkO23T8Oea8PXR7ywWoMrYfFbHzy4PP3S1S6sO24uRfYBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; 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=myEU/AqLtxJRfEUcQ02sIJJ15KORFPCC7noxIrPNp24=; b=Mf2+yGlzHvuAg4icYot9+zbWz6ZC1IdaWa+6suSgmYsU8mZZy+qvhPwKYQLqIfq0NXcgRKJqZ5Z/3awSgJZyV/gFcgZtlIIXiCh+PGkULl8dmK6ipr0+qgEutTCP7HARWodsb+Jkmr3qlGSJ/y0X74Hrqy8Tvr6Yw/YIyWZy3mw= Received: from PAXPR08MB6987.eurprd08.prod.outlook.com (2603:10a6:102:1df::15) by PR2PR08MB4842.eurprd08.prod.outlook.com (2603:10a6:101:22::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Tue, 3 Aug 2021 13:10:17 +0000 Received: from PAXPR08MB6987.eurprd08.prod.outlook.com ([fe80::cdae:9f67:6693:49d4]) by PAXPR08MB6987.eurprd08.prod.outlook.com ([fe80::cdae:9f67:6693:49d4%8]) with mapi id 15.20.4373.026; Tue, 3 Aug 2021 13:10:17 +0000 From: "Samer El-Haj-Mahmoud" To: "devel@edk2.groups.io" , Sunny Wang CC: G Edhaya Chandran , Barton Gao , Heinrich Schuchardt , Samer El-Haj-Mahmoud Subject: Re: [edk2-devel] [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Update page alignment calculations Thread-Topic: [edk2-devel] [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Update page alignment calculations Thread-Index: AQHXfHWONqNOQYoosUWkaHM3y2N5JKth2CIQ Date: Tue, 3 Aug 2021 13:10:17 +0000 Message-ID: References: <20210719080759.824-1-Sunny.Wang@arm.com> In-Reply-To: <20210719080759.824-1-Sunny.Wang@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: acf4b754-3e7e-411a-ddbf-08d9568011b7 x-ms-traffictypediagnostic: PR2PR08MB4842:|VI1PR08MB2909: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:6430;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: YWph7fdo/gUXlFP0ClUsYnphOdsmCXBAEhK8yfTinvLOVCJ3OW0xQ+VvZ32h2KMuFSAa3dBExajA/uKfrY1bRx5z6cgNKCurPaEnm4+P/XlBNNwhLQ88MqhE0ESSd1jZnndHijmphitgCXa/z8OSHBHHwyUR6v+39ny26DXnPVaT4ptAQG3N0AgQyiEKglrOsRHNAvw6Wve3Mg88JOc/2UR5/6pzzdhLQXMQBWQwbXVR0m5LHRIaRPeCBCSdqZLMPgGfTilArxdJk8eEkCYF/7Hdv68TNRP23qt1bXsa7/H5WRIvo41VP9to+FXCH+03rnJOIYYCjIeR8TYrhO0IYxkHRYu/7n5WctJKVZMDCt3M6geyO7Ul00388nn4ZjGt5kYfWOqCueXoJwwUeb0GkO1fmO7FHe5IPWKvepIcYQBA6sQtAH3uESHxIBpNmyDJYnky2cWR6hE6UjMrAFufwcjtnL0WNyoSfOgZ86bMq4aD6G/yd7uI0gsClI5otzrSSVNz3c3sTTGf+Jersd6zwVlIbmn+JBv8aqT/fstyvkgxMjkDfRK/FJuRaRBTUqSEklEAO2f1lwhhH+gyW272N2H86VYLcaiErccCQC0T2EMuxb8tjJNrKg43qI27TBM7NXCJTsN7Fdc63sjobgyQAdeY71mW2ZdDidIZeDZOB8uVfIvfdV3HEvVijAu6R/XgvOKbxIK7dVhhoktkEs/TS0Rf1vwZXHVpnDHYcykpHOT2mJATNZWZMCCcHQ5yRo0nAP0+JPG0fl6tH8LmoaUHV7Fw1TESViU6Oi9PYnirzLgufPPf/le+lWWg3qtO6HDH5aI7kg97G9aCTeBW6B6w7w== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6987.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(366004)(376002)(136003)(396003)(346002)(38070700005)(83380400001)(4326008)(86362001)(66946007)(316002)(33656002)(76116006)(966005)(55016002)(38100700002)(26005)(66446008)(6636002)(52536014)(9686003)(64756008)(54906003)(110136005)(66556008)(66476007)(5660300002)(8936002)(8676002)(186003)(6506007)(478600001)(53546011)(7696005)(71200400001)(122000001)(15650500001)(2906002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?sqhCjSOvbb3EV/Hjo7zzPDYK0ObeNdvYjpUk4KU3RbQNOSDdsuuigcHjoDtM?= =?us-ascii?Q?4mrWbfyR0BQQAL/qGOc+ylzwsBNPFRqwpUQ7xsybFXobhs8Xqk8OO0aewM1J?= =?us-ascii?Q?ftAYQ+nIMTR7RV/BZTsKxVkWYghIWneUgNLpmjVqX3OoJm5LClWKZrQzFavu?= =?us-ascii?Q?c0Rsp3Pvh/Ztf3eIKb3uG4I8rEK4tZ7Lcaa5+3EPzFkGjts+DozvM2aTF+2N?= =?us-ascii?Q?+PQwkaCV9Uud4afOGx1YJ+c+pMwIWSx1ZO1/2XOHSG0N6Ja1XPjWwKRMhTcX?= =?us-ascii?Q?KCFvekE8BlJWMSHH+ck1wvm0k/1TYPZh7mzbcWatKfi0kUBLFBb49WCd1MTL?= =?us-ascii?Q?cSnBMSABdiCIrvv87skHcyIjfYUwW1SzEAbgZfhcoyJ7/SBfbQBd/UNttuCa?= =?us-ascii?Q?JpR3s4DpUP62/FpxQpEC87V/8yW2hxDlNTZqibkTsX6TjFodc72pQ98UN8/m?= =?us-ascii?Q?DNud52IaHRNIWEE/ZZAoISmD9qirXiGoPe5giXJSNdHWrWVPy5/3OhbQS5ni?= =?us-ascii?Q?nIvOFaAwOWEFNeFRbqGm34KYbDQpalFB9NNK0P3Ltr3ztrw7GZx7pLo9B8YI?= =?us-ascii?Q?PFxjl3+gKbHW1q7HAzQMK0Wmg0/W8KcnIWnZmN1enNBD4Jx9T8+PrAbcaklH?= =?us-ascii?Q?zELq/GiFrBsSFPeZ+G1Zib4zMSATWl/z+ovdWYRXArz3mpa7Gto6kYUUhvz8?= =?us-ascii?Q?bXcWBPqZZcwIhKbJoTrUMiklT6QedtT9Nla+oLv+QJ9M9jo6m2scWRzYCiko?= =?us-ascii?Q?xGtImihBIlRwK34CWAAen2S04k9qmHwx44LG+TJP0ljF7QQW9X9luQaPqde6?= =?us-ascii?Q?RI8E1b2+xzKVJx85RGKoC1u+jUVjTtWhwgHcss2ldwfPj1KR8CxlMELYb3OB?= =?us-ascii?Q?OL1poVQTVmqu0DMWHYj8aghOCMk6Qb3msljR2OCwD0kRHUqMeivcvE/595Nx?= =?us-ascii?Q?UWD4rQxLztohE65/c/w2wIBS9VKPtErHvAyKCrYQvKt2zl61cqyKo51S+BFQ?= =?us-ascii?Q?TTOHjTzWgIMSjfPKH5Y1Ub8QFYSLNDRrTBvHPb7eTUEsbZ9F/Nbe4ZoG8Fio?= =?us-ascii?Q?775yaDxDHAItckaeB0atLGmWOToJZOjP9vD3uCuI8PV8yyi8t66MzpXmIyG6?= =?us-ascii?Q?CeYQfEbPZceTXtooEUVlc/VPwYdLW0/yH6UcNlGxc4L5wKcVnEuj0yMwIII1?= =?us-ascii?Q?MZWJrZ9ibZqahN5VctpjQ7xQDraeNeEq5/55EIwr0KBebIyLJZBjoEAJZB22?= =?us-ascii?Q?IjBl5sESxRNZbtBQ6TLzrU2RSWqdnfM4+VX10aE2BRy+fjvOgLQEVwTPEZOF?= =?us-ascii?Q?HHWrEvVUtBOV9ssPSmPVOzaj?= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4842 Original-Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=arm.com; Return-Path: Samer.El-Haj-Mahmoud@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: fe73b735-470f-4765-9f9d-08d9568009fc X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ln3XlpXiMrK+vXGx1aAlDfg0wRWWFnMX+VEyyIGsR1X6BDOQNPPcM9HgqeRYVznZgA88XAWuP9t1IAIQUdI3r+ADR5k9FTaUG7Qf01mZPAZAex0BBsHRisF9usM95kY0vCCvz3GzCo746COygg+xKWCL23n/LKYnWG9aYD0pfWbP/TrAX1Sd7ehyEjV3weiET2q6dwf1kfNdhW5PrNg7pzHmVMQPV496MutxqQJRNanxer2ydEmbzvls2Z+8Ij09NKoIEAA9ZLbrPr0Fsf/lE58Vp0Lwx24iA4uVHamHxvLMRW/OBjjS6/bYvqpCFe33Onbx4GEb2bXAC826pTEk8RwLI2QphaCNtc752R1kEtsZOOH0WogaT+3twrUaKcgBmQHNXYgGduzrJA52k8ZT6bqklM7YsvYl8hvSBpqmpbfFV5tgaPfISL2HiC31caBJJwUe+jhtkV5AxBD3Y0/esqfUjGRsVOTEczp2sCxwwzyOM0BBXERrGzjO9lNh5dKtU/c1VZbxgB1K6Z0cq1o4Hs0iGAj4qzyjhKLm9vb/F1DFN3lCumYMoekHoOA4WTEcmwFcb6L2Bsw0EGWFpkqRPKv2JTZTsWiUpVg2hAh/ydTvker3w45Jf4gnBxIFVxcrXjSeMW1UGBzqS8iusBMbEN/9cKORfNK6pSVS/aDIcN/HcGJLzRAtSslkfsUFBotTDOaOaprwt35+k7J/JWeo7qyByOOPwAzNlNv82jJK9ktPqf0mXLxwZhALGtkB6seIsC/s/TewFdYN14JbZd7B9Az6Vn4HKzXLW3c8QCnZWxVV/Euu7FWIbsdhDEqXJKN8nEew/xPWKo7D/kZ4iVUYlw== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(136003)(396003)(346002)(39860400002)(376002)(36840700001)(46966006)(6506007)(4326008)(82740400003)(5660300002)(70586007)(9686003)(7696005)(70206006)(83380400001)(8676002)(316002)(2906002)(186003)(82310400003)(52536014)(336012)(36860700001)(356005)(33656002)(6636002)(478600001)(55016002)(47076005)(110136005)(54906003)(81166007)(86362001)(966005)(53546011)(15650500001)(8936002)(26005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2021 13:10:30.2611 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: acf4b754-3e7e-411a-ddbf-08d9568011b7 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: DB5EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB2909 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable +Heinrich > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Sunny > Wang via groups.io > Sent: Monday, July 19, 2021 4:08 AM > To: devel@edk2.groups.io > Cc: Sunny Wang ; Samer El-Haj-Mahmoud > ; G Edhaya Chandran > ; Barton Gao ; > Sunny Wang > Subject: [edk2-devel] [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Update > page alignment calculations > > This is to fix the SCT BS.AllocatePages failures (not found) with the > case that the Start address is not aligned to 64k. > For example, > The following is available memory region for testing: > 0000000082012000-00000000EB6D9FFF 00000000000696C8 > With the current page alignment calculation, we will get: > Start address is 0x82020000 > PageNum is 0x696B8 > In BS.AllocatePages, it will make the end address align with 64k, > so PageNum will be changed from 0x696B8 to 0x696C0. Therefore, the > end address will become 0xEB6E0000 which is larger than 0xEB6D9FFF, > so we get not found error in the end. > > Therefore, the calculation for getting the PageNum should be updated > to PageNum - (2 * EFI_SIZE_TO_PAGES(0x10000)) so that we won't get a > wrong PageNum to allocate a memory with a size larger than available > space's size. > > With this solution, the example above will get 0x696A8 as calculated > PageNum. Then, in BS.AllocatePages, the PageNum will be changed from > 0x696A8 to 0x696B0. Therefore, the end address will become 0xEB6D0000 > that is smaller than 0xEB6D9FFF, so we get not found error in the end. > > I also tested this solution on two ARM platforms (NXP1046A and RPi4). > > Cc: Samer El-Haj-Mahmoud > Cc: G Edhaya Chandran > Cc: Barton Gao > Signed-off-by: Sunny Wang > --- > .../MemoryAllocationServicesBBTestFunction.c | 110 +++++++++++------- > 1 file changed, 66 insertions(+), 44 deletions(-) > > diff --git a/uefi- > sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/Blac > kBoxTest/MemoryAllocationServicesBBTestFunction.c b/uefi- > sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/Blac > kBoxTest/MemoryAllocationServicesBBTestFunction.c > index bf8cd3b3..cdfac992 100644 > --- a/uefi- > sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/Blac > kBoxTest/MemoryAllocationServicesBBTestFunction.c > +++ b/uefi- > sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/Blac > kBoxTest/MemoryAllocationServicesBBTestFunction.c > @@ -2,6 +2,7 @@ > > Copyright 2006 - 2013 Unified EFI, Inc.
> Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.
> + Copyright (c) 2021, ARM Limited. All rights reserved. > > This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD > License > @@ -24,7 +25,7 @@ Abstract: > > --*/ > > -#include "SctLib.h" > +#include "SctLib.h" > #include "MemoryAllocationServicesBBTestMain.h" > > #define ALLOCATEPAGES_MEMORYTYPE_NUM 16 > @@ -700,14 +701,17 @@ BBTestAllocatePagesInterfaceTest ( > PageNum =3D (UINTN)Descriptor.NumberOfPages; > Start =3D Descriptor.PhysicalStart; > > - // > - // Some memory types need more alignment than 4K, so > - // > - if (PageNum <=3D 0x10) { > + // > + // Calculate New Start address and PageNum with 64k alignment to > + // cover the case that some memory types' alignment is more than > + // 4k. If the available memory is less than 192k, the memory > + // allocation call will be skipped. > + // > + if (PageNum < (3 * EFI_SIZE_TO_PAGES(0x10000))) { > break; > } > - Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > + Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > + PageNum =3D PageNum - (2 * EFI_SIZE_TO_PAGES(0x10000)); > > Memory =3D Start; > > @@ -830,14 +834,17 @@ BBTestAllocatePagesInterfaceTest ( > PageNum =3D (UINTN)Descriptor.NumberOfPages; > Start =3D Descriptor.PhysicalStart; > > - // > - // Some memory types need more alignment than 4K, so > - // > - if (PageNum <=3D 0x10) { > + // > + // Calculate New Start address and PageNum with 64k alignment to > + // cover the case that some memory types' alignment is more than > + // 4k. If the available memory is less than 192k, the memory > + // allocation call will be skipped. > + // > + if (PageNum < (3 * EFI_SIZE_TO_PAGES(0x10000))) { > break; > } > - Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > + Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > + PageNum =3D PageNum - (2 * EFI_SIZE_TO_PAGES(0x10000)); > > Memory =3D Start; > > @@ -953,14 +960,17 @@ BBTestAllocatePagesInterfaceTest ( > PageNum =3D (UINTN)Descriptor.NumberOfPages; > Start =3D Descriptor.PhysicalStart; > > - // > - // Some memory types need more alignment than 4K, so > - // > - if (PageNum <=3D 0x10) { > + // > + // Calculate New Start address and PageNum with 64k alignment to > + // cover the case that some memory types' alignment is more than > + // 4k. If the available memory is less than 192k, the memory > + // allocation call will be skipped. > + // > + if (PageNum < (3 * EFI_SIZE_TO_PAGES(0x10000))) { > break; > } > - Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > + Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > + PageNum =3D PageNum - (2 * EFI_SIZE_TO_PAGES(0x10000)); > > Memory =3D Start + (SctLShiftU64 (PageNum/3, EFI_PAGE_SHIFT) & > 0xFFFFFFFFFFFF0000); > > @@ -1076,14 +1086,17 @@ BBTestAllocatePagesInterfaceTest ( > PageNum =3D (UINTN)Descriptor.NumberOfPages; > Start =3D Descriptor.PhysicalStart; > > - // > - // Some memory types need more alignment than 4K, so > - // > - if (PageNum <=3D 0x10) { > + // > + // Calculate New Start address and PageNum with 64k alignment to > + // cover the case that some memory types' alignment is more than > + // 4k. If the available memory is less than 192k, the memory > + // allocation call will be skipped. > + // > + if (PageNum < (3 * EFI_SIZE_TO_PAGES(0x10000))) { > break; > } > - Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > + Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > + PageNum =3D PageNum - (2 * EFI_SIZE_TO_PAGES(0x10000)); > > Memory =3D Start + (SctLShiftU64 (PageNum * 2 / 3, EFI_PAGE_SHI= FT) & > 0xFFFFFFFFFFFF0000); > > @@ -1206,14 +1219,17 @@ BBTestAllocatePagesInterfaceTest ( > PageNum =3D (UINTN)Descriptor.NumberOfPages; > Start =3D Descriptor.PhysicalStart; > > - // > - // Some memory types need more alignment than 4K, so > - // > - if (PageNum <=3D 0x10) { > + // > + // Calculate New Start address and PageNum with 64k alignment to > + // cover the case that some memory types' alignment is more than > + // 4k. If the available memory is less than 192k, the memory > + // allocation call will be skipped. > + // > + if (PageNum < (3 * EFI_SIZE_TO_PAGES(0x10000))) { > break; > } > - Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > + Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > + PageNum =3D PageNum - (2 * EFI_SIZE_TO_PAGES(0x10000)); > > Memory =3D Start; > > @@ -1329,14 +1345,17 @@ BBTestAllocatePagesInterfaceTest ( > PageNum =3D (UINTN)Descriptor.NumberOfPages; > Start =3D Descriptor.PhysicalStart; > > - // > - // Some memory types need more alignment than 4K, so > - // > - if (PageNum <=3D 0x10) { > + // > + // Calculate New Start address and PageNum with 64k alignment to > + // cover the case that some memory types' alignment is more than > + // 4k. If the available memory is less than 192k, the memory > + // allocation call will be skipped. > + // > + if (PageNum < (3 * EFI_SIZE_TO_PAGES(0x10000))) { > break; > } > - Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > + Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > + PageNum =3D PageNum - (2 * EFI_SIZE_TO_PAGES(0x10000)); > > Memory =3D Start; > > @@ -1468,14 +1487,17 @@ BBTestAllocatePagesInterfaceTest ( > PageNum =3D (UINTN)Descriptor.NumberOfPages; > Start =3D Descriptor.PhysicalStart; > > - // > - // Some memory types need more alignment than 4K, so > - // > - if (PageNum <=3D 0x10) { > + // > + // Calculate New Start address and PageNum with 64k alignment to > + // cover the case that some memory types' alignment is more than > + // 4k. If the available memory is less than 192k, the memory > + // allocation call will be skipped. > + // > + if (PageNum < (3 * EFI_SIZE_TO_PAGES(0x10000))) { > break; > } > - Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > + Start =3D (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; > + PageNum =3D PageNum - (2 * EFI_SIZE_TO_PAGES(0x10000)); > > Memory =3D Start; > > @@ -1923,4 +1945,4 @@ BBTestFreePoolInterfaceTest ( > > FreeMemoryMap (); > return EFI_SUCCESS; > -} > +} > -- > 2.31.0.windows.1 > > > > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#77876): https://edk2.groups.io/g/devel/message/77876 > Mute This Topic: https://groups.io/mt/84303611/1945644 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [samer.el-haj- > mahmoud@arm.com] > -=3D-=3D-=3D-=3D-=3D-=3D > IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.