From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.50]) by mx.groups.io with SMTP id smtpd.web08.6109.1628064860956663866 for ; Wed, 04 Aug 2021 01:14:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=0qouAb6w; spf=pass (domain: arm.com, ip: 40.107.7.50, mailfrom: paul.yang@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=OwIeGe4TvsKe7izdjrrw3BFthtJKr+5ZMC/xEyKSw8Q=; b=0qouAb6wAeRNfHAKAx5dDlOaCmqyDGiXr3LTNV6KPtBKWWn90V6oCytU7tY9ZL10tsyyH25maxzF3v3/zXwsyjb7/37MBmnrAx9xiBn9/BR9BzWiVoIn+F8d5UqB5BuXvaGzDxBhVTELZmaAM+TEfH2Y9XrGIIu22myvD1771AI= Received: from AM6P192CA0025.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:83::38) by DB9PR08MB6700.eurprd08.prod.outlook.com (2603:10a6:10:2a3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.18; Wed, 4 Aug 2021 08:14:17 +0000 Received: from AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:83:cafe::3b) by AM6P192CA0025.outlook.office365.com (2603:10a6:209:83::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Wed, 4 Aug 2021 08:14:17 +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 AM5EUR03FT007.mail.protection.outlook.com (10.152.16.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Wed, 4 Aug 2021 08:14:17 +0000 Received: ("Tessian outbound 79bfeeb089c1:v101"); Wed, 04 Aug 2021 08:14:16 +0000 X-CR-MTA-TID: 64aa7808 Received: from 62922fbc897d.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3A202351-2024-4173-8E67-58FC54C3D987.1; Wed, 04 Aug 2021 08:14:10 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 62922fbc897d.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 04 Aug 2021 08:14:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l5mQNMQ09uMR7ZVJ800RkSrHumTh6s3IZjj22d2is6FAWx9x1Nw5aGW+kcPVwchM6IINMmfH5Cv81eJHIqqaD+qklToLOZY6f1SWjok7CSqDXZl2CYyYC2x8IU2GlmyCw11/o1gyKPDUbfssht5TfegMIii2tvyi8qALnBQA75AuRof2hqYYbtd7LdTSFkiXedXe1O8keMeKh+QxxoZrIPm1e1rMvt5Sica0bI6NAsknKVLza0kkr2zQ/3WdAZFbLFLgfRLL2MeAK6n7lFE4ZlyyRPqOj79aKUE7XX0mjvSq7tALl0a18jFLmZoIP7GbPgjTNGAAQMnsxNk7QpEpCQ== 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=OwIeGe4TvsKe7izdjrrw3BFthtJKr+5ZMC/xEyKSw8Q=; b=kz2UeJQynwkaw2qCHNSNPy6pcThVzrrvQMFsTddi+yBQhFiI+QCUy+UWaEN5mC2byrRPVvuIolf1c9LGvK4PzzrPzkyke9mMqRXh0FDFE705+N/oPmthdtOL1cXIlN9SeC8KEfnuFKljvbEdXgikKJqR61JuNQKRbZuUxuDrFcYpqQw1Ul4EtAqlY/xTfdayxQWAiYFAAzSPQF+OhXR+R8NpeazxRC0XibkmK9UdcORvIcEy4+McUrB2duYUenLFNTUFaeFspqQ8Ra+RZjIG0JDVdVFnxy2hQc6fMSs5dI2yXcdcbZHx4OOM7vFCHVZzivqlrmDtisEPMMg5wwaCXg== 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=OwIeGe4TvsKe7izdjrrw3BFthtJKr+5ZMC/xEyKSw8Q=; b=0qouAb6wAeRNfHAKAx5dDlOaCmqyDGiXr3LTNV6KPtBKWWn90V6oCytU7tY9ZL10tsyyH25maxzF3v3/zXwsyjb7/37MBmnrAx9xiBn9/BR9BzWiVoIn+F8d5UqB5BuXvaGzDxBhVTELZmaAM+TEfH2Y9XrGIIu22myvD1771AI= Received: from PAXPR08MB6862.eurprd08.prod.outlook.com (2603:10a6:102:136::20) by PR3PR08MB5691.eurprd08.prod.outlook.com (2603:10a6:102:82::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15; Wed, 4 Aug 2021 08:14:09 +0000 Received: from PAXPR08MB6862.eurprd08.prod.outlook.com ([fe80::78bf:421f:a993:6e85]) by PAXPR08MB6862.eurprd08.prod.outlook.com ([fe80::78bf:421f:a993:6e85%7]) with mapi id 15.20.4394.016; Wed, 4 Aug 2021 08:14:08 +0000 From: Paul Yang To: "devel@edk2.groups.io" CC: Sunny Wang , Samer El-Haj-Mahmoud , G Edhaya Chandran , Barton Gao Subject: Re: [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Update page alignment calculations Thread-Topic: [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Update page alignment calculations Thread-Index: AQHXfHWUfanaClrBN0ufLXz3dkIu46tjCNTAgAAOrmA= Date: Wed, 4 Aug 2021 08:13:58 +0000 Deferred-Delivery: Wed, 4 Aug 2021 08:13:18 +0000 Message-ID: References: <20210719080759.824-1-Sunny.Wang@arm.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: A180E2326A965A438CFCB4F93019B51F.0 x-checkrecipientchecked: true 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: 7d370975-af69-402f-3f16-08d9571fda88 x-ms-traffictypediagnostic: PR3PR08MB5691:|DB9PR08MB6700: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:9508;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Ui+RjZdyByNDZRI1Nvu0iCG43C22CB+tF7dNbVm5FPAJj8VXRH8Erglzr+pE9ZUIB//N2yFywdVwHuigsbY5W4ggrvRVmvX6oJdLJxrKYMuoOpJn96P36kDf5X7wbeKKquvJ7QKLUlGAAlfLWgDABphk0nIOQZ1YXUy9TixO4t4Ty43jhuF+VF7uqD62INQ3jUCoJJ8Ut+YnAaFSdAFElXkgvDWpfoyYoFiMpSWc2WVJfMBR3osJbnbQ8AnctRruK8soXyCFun+nKjhvPxe+Fj2dlRCtq3KHeEPDrgRWTVhIUpzNEd1sMRjThGZJSQ6A2NKR7akCKWpXjknKCQUIGw8NSFGz3cQBu/p0flggUMWWYb+ZNKqXHnwu9/OjQcFQI/Vi9dkaSjrJD4kw4L4zPtt5CFxcV9Y+/K2MTCRwZXMLBDMT8nvtsohTjGAiYhLVtn4kbKPrWxKwkxNXiLBoQgDrfqqmvflpmCb+CemR8IjyYB9CFQLxEsmJHYGQnIksesfpx2uihB7sAN9KkYOPtnmHAavrga3uSEjKFjMGNyv55ec8svBYVN47yGZQqIig/Ig9GttUo+4uTo/vtfUDRKPwezl6LMAteWzMc6ZczXwozuvoc0P7BpXLzVSuYlYuSOR9TMueSuP6CcRAYPCjBSijN6UICSRdlaM8RJb2DivOhAJ3B2SiTyRraudl1btoCv47IVcnCmrDYYMtvVl1umVeeTQ/w5qJf15L/susNTM= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6862.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(376002)(366004)(39850400004)(53546011)(7696005)(6506007)(6666004)(33656002)(38100700002)(55016002)(122000001)(9686003)(86362001)(15650500001)(71200400001)(54906003)(316002)(83380400001)(186003)(4326008)(478600001)(26005)(6916009)(66946007)(5660300002)(52536014)(76116006)(38070700005)(64756008)(66476007)(66556008)(66446008)(2906002)(8936002)(8676002)(11716005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?eWMFyWvEvhDVi+KZtcaTZkpCrYgxw8dCGofVk9t4YYEYKMGfEO4sX12OldKh?= =?us-ascii?Q?CL/9tHAlE43P4XoBEiR1tGMy/RoNb8nu2ThJokfSDz9f/vpsKkbj6Vaoj5vg?= =?us-ascii?Q?GV9ok/lYDG+sRFwQD4TijIoR/M+1OBD7B13c0jqFR4u4XtU+DciKlt4yxh0d?= =?us-ascii?Q?wnYX9eq7lY0enJjQJPIh2RTsCodXKy1Cuy4i7RLQSVJk3JWSsrYrPe1m4GJI?= =?us-ascii?Q?1ScAMmOTbgyRHhJX2kHyqxtKB57irQl/lj9ZviSqOLY9t/yCJXWIij8BoGjS?= =?us-ascii?Q?ZvNJugeJKDgLTUhgkN8RGgYnurt9WJ453RzwaLNNxEAVo5tbXMIXulAfQtG8?= =?us-ascii?Q?d9eFLOxpHZpzOW1lgUmo45TkPQRUiXNeZHwzv06y9E4mId2xkv16e4gzpOSh?= =?us-ascii?Q?XfLTQQeXwO7qnfq4f/ZNbiThGJTymheFZJg6sGmPhppQH/afGgkBpLX/4YYS?= =?us-ascii?Q?eIPFGmxRRCpdupvtbjp+rjhNPaqV32bBiboaDTK31cLd99O4v7wICLgMxP7b?= =?us-ascii?Q?wCghroWJumD8Rac+azI6xHNF0O4DLxftCF9n3LJWL3G75+XS1NjizHZYRrpN?= =?us-ascii?Q?vZkNP8gHLGYOM/kMK9i0m6hK9AuXMaZ/yp3J4uuqDDVrRW028SJIUI2CQfdy?= =?us-ascii?Q?4fymz17ZEFUoacl2XsjTIFEDtoJLX7BpbPYhdKj7tlpTfQyG7uDQaYvTF7u8?= =?us-ascii?Q?6w2xoGElcQSe28e7HLwZOQOGfMvHjJ+XbsnQXYZOPiED966iaKR71ycDtjbo?= =?us-ascii?Q?pgDj50dVHKzt3tZEdZXdm1Gc1kkF9IBOdJLRbH9GyFgT5/pPLIXpPUuEsTDU?= =?us-ascii?Q?8oRGSdWTPM2o3l6px012aIm2H6ZSU5k4qHHmMfeeuqTsv+SxweAjeYa7ZHmE?= =?us-ascii?Q?GdJgwpiytK+jcFy5+ElJIETDxtFnhTxYZP9+/PjyxAu8RgG5qwCFG8o5DXZ9?= =?us-ascii?Q?BquTcEym80d+8SL5nzUgKIGYyS60d5cJW4nejdhzqpT2iy2Zh/LqlNjtQHnB?= =?us-ascii?Q?OEjJTDfWPbWEXUiq9MlMGOSaQqXc9NDBZbGPFT70xrGz55LQP0vm5986sNPi?= =?us-ascii?Q?1ajf6uaO4MMlRODlFA88rCPOkfHuP4qO7XztDYbcP1zIPxLlU2Fy4BTcxAz7?= =?us-ascii?Q?GF0OxzD6wolKgKi86/M0AsMI0yLSBzS1H4H9Iiibya5Ro8GafpWjZ/7EVABP?= =?us-ascii?Q?UsxjRVTegBPI8i331tfDQ8jzGz0fNWZRFLa5Bv5JyHVkbm4MicTRtiupZbRw?= =?us-ascii?Q?QuDaDFkREMBNs8d9ZIk9g7rDOpxymighsDYVX45jmwz/eNvojvqvtZtVhpQO?= =?us-ascii?Q?CfGyk2T35gcX6s/zmQF40OJl?= MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5691 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: Paul.Yang@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5d02c9a4-6fca-444b-6437-08d9571fd533 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cny49BfEciZM0wol7EzlkX3StQaFiNwTwrD1B2eb3Rj3jB1HvQnvyGfj3aonLT0w+zAaVmNA4QicAj07I2zqrsRnk9xYciz3d0hMDvuscLYX8gCPu/vjhBVhF3Lc9liAgBxxBVGAn2EZwlOXi2JlFnU9Dy2loNzhWRnYYRAYXhpa9bl3TQ596JoLZ7ulRNgKcc4zDZWuqvYxJbXqCQ50y1LWCMiTw9k68RSy/+Kqn5r3pPtq5BzJDUEcexqBNNHBoEx7XhKVUiH1AI3G/rZ+73wHb+CB5LqPlpJTFm6+kc/23He8g56TzXJrhPCT0i1TOG3PLt6V38Pzsgf6NLwNeHaPQgGaQoPtMmxLcLvSJZb9RSgZGAConuTy67XMQsyD9wFXSeXzRl5RujtrPFEvpb514ODX9YONi1eXBGgajvjM2td2pDK7YEnbz36gLhu+h4WwbgZDlB9vR9KeapZnK1UA7WH0HEJpT3z4mXMRMC6oFZBoipw951oIXFekncNpjDDfFTGmbL9LHFai5LLKYgB1H7j7EwMqKK0L0NRvim9HIUrX13ps5EQEBG50zejoe+NP3OdQzWilXiA5jwSsrOpAZfjeqTSzWYXqDLfOorFtbU5tvcroMx4dt2+h4cQpHN9zuBZTVWmCLu+gGGfB+Dq3c+7O3GfC+Ckt5ROkZyx57oVwSr1kWMxcsbNBm7rkzvXq02/ZXLp3+gMUmp/8gQ== 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)(39850400004)(136003)(396003)(36840700001)(46966006)(186003)(55016002)(6916009)(478600001)(33656002)(54906003)(9686003)(8676002)(26005)(5660300002)(356005)(83380400001)(82740400003)(82310400003)(36860700001)(4326008)(15650500001)(70586007)(336012)(7696005)(52536014)(6506007)(2906002)(70206006)(6666004)(86362001)(81166007)(8936002)(316002)(53546011)(107886003)(47076005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 08:14:17.0890 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d370975-af69-402f-3f16-08d9571fda88 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: AM5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6700 Content-Language: zh-TW Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I tested this patch on Ampere Altra system. Tested-by: Paul Yang -----Original Message----- From: Sunny Wang Sent: Monday, July 19, 2021 4:08 PM To: devel@edk2.groups.io Cc: Sunny Wang ; Samer El-Haj-Mahmoud ; G Edhaya Chandran ; Barton Gao ; Sunny Wang Subject: [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Update page alignment c= alculations 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 Pag= eNum - (2 * EFI_SIZE_TO_PAGES(0x10000)) so that we won't get a wrong PageNu= m to allocate a memory with a size larger than available space's size. With this solution, the example above will get 0x696A8 as calculated PageNu= m. 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/MemoryAllocatio= nServices/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c b/uefi-sct/= SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackBoxTest= /MemoryAllocationServicesBBTestFunction.c index bf8cd3b3..cdfac992 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServic= es/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationSer +++ vices/BlackBoxTest/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 BS= D License @@ -24,7 +25,7 @@ Abstract: --*/ -#include "SctLib.h" +#include "SctLib.h" #include "MemoryAllocationServicesBBTestMain.h" #define ALLOCATEPAGES_MEMORYTYPE_NUM 16 @@ -700,14 +701,17 @@ BBTestAlloca= tePagesInterfaceTest ( 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) & 0xF= FFFFFFFFFFF0000); @@ -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_SHIFT= ) & 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 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.