From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.54]) by mx.groups.io with SMTP id smtpd.web10.3307.1596540520498651391 for ; Tue, 04 Aug 2020 04:28:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=V5l2XrsK; spf=pass (domain: arm.com, ip: 40.107.8.54, 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=K0l1uhouU9+mxDXqqKk6NLA9HXxBeBrkX5ehabLrZsE=; b=V5l2XrsKy5tF0FjInQg0P3WWXKwjwIzwCwHhtFaL+XWHvdhnHSgsQgx7fkTNkh/c/kItVEBOhR8p94yiX8wahOjYPe0RDZRahloWyRBggcxme1EsF1Qd6YJes8XeMicsE4O3tofhLrN5nAj0SU6ya8PVI6Gnkn9r74Z3gxEiwO8= Received: from DB6PR0402CA0001.eurprd04.prod.outlook.com (2603:10a6:4:91::11) by HE1PR0801MB2108.eurprd08.prod.outlook.com (2603:10a6:3:51::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.21; Tue, 4 Aug 2020 11:28:36 +0000 Received: from DB5EUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:91:cafe::e5) by DB6PR0402CA0001.outlook.office365.com (2603:10a6:4:91::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.17 via Frontend Transport; Tue, 4 Aug 2020 11:28:36 +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=bestguesspass 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 DB5EUR03FT010.mail.protection.outlook.com (10.152.20.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.20 via Frontend Transport; Tue, 4 Aug 2020 11:28:36 +0000 Received: ("Tessian outbound a0fc03de1592:v63"); Tue, 04 Aug 2020 11:28:36 +0000 X-CR-MTA-TID: 64aa7808 Received: from d4bd770bb954.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 59A248E7-4D9D-41D9-A0BA-7F39A09CD512.1; Tue, 04 Aug 2020 11:28:31 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d4bd770bb954.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 04 Aug 2020 11:28:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j0OkN+miY7yYtnSFF5hYKVrjCW278cayWEyyohy5quKJbPXQ0Oxw5B0D/EOXawRXb+V2qb/zCbB1jMFTfD3KRcOtZn1w8befVcjpLFzgl5zey83iZ/qxN6SgR3YLb/GN0PK4GYfeUr2jLD7fNmGPRN2on5Ij+fKWIeBIFZmTJ/eN1alMPoaszhUQ50/8xTzLIEodRmUTsL+sUM0ElOcVMJN9dNFr9T2lWPz/DdcM9aYUx1ZiuZE2dxudRWeF0Hif86V6P9+ZKvnqCgFThFsHAfo15CDNbszfe+gGu7/zcGDcQd40HH3vxqv1dNLUhlJaeFSQeqatRlNCHeK0SBcllQ== 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=K0l1uhouU9+mxDXqqKk6NLA9HXxBeBrkX5ehabLrZsE=; b=ZN2KE+WM49eTYDin+trF3LX5K8xVKXcwj7SxxbimxWBmYxXX1OIMxKkbHU1Of0HcwVheQSThsS+GqhYde9O0QXCsnlKAUlLcqNJ8kofvMJLIwqnLfZURHPnlA3Ae+3mSqdAwzgV1Gx0wWiJpHx+3lWpkOioDJR1NIFx/KzZndPsdxOALI+O7Zh73bEuaQXEDghEltcLGl5lfqf1kcI1ivaC06WhME7O4xSUDG0fE0H0lRN1S5lArvigv+jsIL5jbnEIhjFWve6+lCANzjXCKcKas2jR1IG9MSLU9AmfUjDCu9vbSe9ujNagXQZx/VgUhDTrVoCc4X5qGOQ69zZsKUw== 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=K0l1uhouU9+mxDXqqKk6NLA9HXxBeBrkX5ehabLrZsE=; b=V5l2XrsKy5tF0FjInQg0P3WWXKwjwIzwCwHhtFaL+XWHvdhnHSgsQgx7fkTNkh/c/kItVEBOhR8p94yiX8wahOjYPe0RDZRahloWyRBggcxme1EsF1Qd6YJes8XeMicsE4O3tofhLrN5nAj0SU6ya8PVI6Gnkn9r74Z3gxEiwO8= Received: from DB7PR08MB3260.eurprd08.prod.outlook.com (2603:10a6:5:21::23) by DB6PR0801MB2008.eurprd08.prod.outlook.com (2603:10a6:4:77::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16; Tue, 4 Aug 2020 11:28:28 +0000 Received: from DB7PR08MB3260.eurprd08.prod.outlook.com ([fe80::88ec:d703:3e32:4c6b]) by DB7PR08MB3260.eurprd08.prod.outlook.com ([fe80::88ec:d703:3e32:4c6b%5]) with mapi id 15.20.3239.021; Tue, 4 Aug 2020 11:28:28 +0000 From: "Samer El-Haj-Mahmoud" To: "devel@edk2.groups.io" , Samer El-Haj-Mahmoud , Pankaj Bansal , Eric Jin , G Edhaya Chandran CC: Pankaj Bansal , Paul Yang , Gaurav Jain , Samer El-Haj-Mahmoud Subject: Re: [edk2-devel] [PATCH edk2-test 1/1] SctPkg: fix page alignment calculations Thread-Topic: [edk2-devel] [PATCH edk2-test 1/1] SctPkg: fix page alignment calculations Thread-Index: AQHWUhsw7B7BBYcGw0GFXF8LcjkQr6kWIODQgBHd7kA= Date: Tue, 4 Aug 2020 11:28:28 +0000 Message-ID: References: <20200704155224.28526-1-pankaj.bansal@oss.nxp.com> <16248F836B15C59B.28930@groups.io> In-Reply-To: <16248F836B15C59B.28930@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: c60103c4-c9d9-4ba0-87f5-982ba29cf0f1.1 x-checkrecipientchecked: true x-ts-email-id: fd0a7528-dc06-47a3-9991-69049b1dcbf1 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-originating-ip: [99.132.126.10] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8dfc7f15-a025-4b4f-ad0c-08d838698710 x-ms-traffictypediagnostic: DB6PR0801MB2008:|HE1PR0801MB2108: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:2958;OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: F8A5JmpEF+8aCT73SB2Sa3l/sTRsTDssCuzqx6Kl0VjbPy4ltqrz7W1hwh9nhARgyYv82IRrTYS0WtBAms23/JG8AfU8XRxr1ztC31BSnxbU03ObSShrSLx0C2OTKNsFCFLc2/9xnYe0AVJjIY5oY2qUFfO2SUk/IyMYYPSVo1CgyZP81pCKw+GqfsYE60/ZvB9MskYFk4YNvFmni0j7omg1PzjCJwznhIRkhAWOBGkFcu3x4BrJuCHzi0hmhkuvKZuPNWBYjnH6DyTLNlOmgNjB/duAQiE6t0r2yB3ZBbWwxVamKJaJBHrqsEA+T8NIY7UbVGDS+yCaPjoT4RBGubaSDlR9cgNQWmSkiCTasVaFZnbaPD6dQRa8NYRo8lMreDlfgmaMFO79eQEDENqEKQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR08MB3260.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(346002)(39860400002)(366004)(136003)(396003)(376002)(83380400001)(33656002)(64756008)(8676002)(8936002)(66556008)(66476007)(30864003)(66446008)(76116006)(2906002)(71200400001)(66946007)(5660300002)(52536014)(186003)(4326008)(9686003)(55016002)(6636002)(966005)(478600001)(316002)(110136005)(53546011)(86362001)(6506007)(7696005)(54906003)(26005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: LgLP+dev8X1o7sQzDxsSgCW2tH0Jd2nCGDojuX4TE91eykj04s+7ejPPVDoWYu99ml7bMfkcYGP5yYusU0Umllqjy4jQKBwtEzIJbL5KPtkRZYQwmN/4EtjuYlovTSJXqq7pXAzNNVmy8LwJ3zunB4N1FfKm90N7CIlnJ+G6vHT0wyCjcrY4UfWCGfGOxaRR1ZK2PuqQpcTrcufGVR7bkb/P19/TTnub1lHLa2sL8GR+0glKUv33ui5YMqCkAZFZ/i3qfq57tL6e1Eu7opgc9uMA4zU9fxMjIssZin1dIDWcc9XFKS7ybxwer3PgD2Cg/9XzgGzmOMHm7+4jYSCFpxZgrMNy67hvBAvtNBi84vm1gJNl+jq+EZzGOJjkoD9Fh5YiA/Mpg6vruOyJpGmMliGra6XqN+jsGm52lqh+FWBs0G+8tyGfc9f1eHxIJFmhCPUltBR8YCk3J77mOjNDEfajjUtrYWR1CLVeFb8mAjF5WgEgeH8moRUoxniP7Mjy8OgagkV1iFPt1yUwmXdVTQ/c2l81w7HbI4irs3Fhc1kTvsQEVbGP+Q8ONwOd/w+avUZw8kMKHiQbiPAzijl85JJ4g4PXmXGHHLUDOLlIHSoAr98uIV8j12Dgvh6wOlDkJKlgbRgyZ3DBpwlGR+6nOg== MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB2008 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: DB5EUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: afc1fc15-dc7e-46f9-1846-08d83869826e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EPiXkI/IpluyzrsG38gV2sR1yZhwufZnBOPCFOIjIs1i0FMDwXJNqtAWaMI4wEmQGOElK0wp9m5a+TFx28+WM/PlffeFzPCSB+nxehzjlIwKmsj4DB1bl6NHdAXR4PAEuqkGuRxlvM4oroCcbPZ49Iw8sQm7GtdwM1A7f3/VqHmZKIp1voia4hjhARQafEFx2WQeO7CEdIzbIlwQzIX2dGrUbU4Z8SB7CPCxJ5PG5nZvtwmSYpKL0xBs9cMw7r7fz1uMjV9hPILFZ9bI9mGE24dYN1YiN0A2j/nDah5ITFnSx10xTUHl2js4KAZudc6p4cWOd2EPqvWtGNVHvjhzjhb+4haJyjO3cRDfUVulIkGa+LgTsvR4S0Ed3iFiTGsD1EyQwRj9ol0+FT4D2GIK5ULvbSG2Bv0JlBsdQofnX/IfVPgwMeTdGn7VCU5rhThTAMuKspac3L9XdDascQUnkZ6yi84BZTVtaYpuSdWR/z0= 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;SFTY:;SFS:(4636009)(39860400002)(346002)(396003)(136003)(376002)(46966005)(26005)(6506007)(53546011)(4326008)(186003)(33656002)(70586007)(7696005)(9686003)(8676002)(55016002)(81166007)(82740400003)(316002)(336012)(70206006)(47076004)(82310400002)(83380400001)(356005)(6636002)(110136005)(2906002)(5660300002)(966005)(86362001)(52536014)(8936002)(54906003)(30864003)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2020 11:28:36.1593 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8dfc7f15-a025-4b4f-ad0c-08d838698710 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: DB5EUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB2108 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I verified that this works on multiple platforms Tested-by: Samer El-Haj-Mahmoud > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Samer > El-Haj-Mahmoud via groups.io > Sent: Thursday, July 23, 2020 10:33 PM > To: Pankaj Bansal ; devel@edk2.groups.io; > Eric Jin ; G Edhaya Chandran > > Cc: Pankaj Bansal ; Paul Yang > ; Gaurav Jain ; Samer El-Haj- > Mahmoud > Subject: Re: [edk2-devel] [PATCH edk2-test 1/1] SctPkg: fix page alignme= nt > calculations > > Acked-by: Samer El-Haj-Mahmoud > > > -----Original Message----- > > From: Pankaj Bansal > > Sent: Saturday, July 4, 2020 11:52 AM > > To: devel@edk2.groups.io; Eric Jin ; G Edhaya > > Chandran > > Cc: Pankaj Bansal ; Paul Yang > > ; Samer El-Haj-Mahmoud > Mahmoud@arm.com>; Gaurav Jain > > Subject: [PATCH edk2-test 1/1] SctPkg: fix page alignment calculations > > > > From: Pankaj Bansal > > > > The BBTestAllocatePagesInterfaceTest tries to allocate pages for > > different memory types. > > While doing so, it tries to fix up the Start and PageNum for 64K Page > > size. There are multiple issues with this: > > > > 1. 64K alignment is being done regardless of Processor type and Memory > > type. while this is correct for ARM64 Processor, it might not be so > > for other Processor types. Also 64K alignment for ARM64 Processor > > is needed for some Memory types not all. > > 2. The Start is being incremented by 64K, even if Start is already 64K > > aligned. > > 3. PageNum is being decreased by 16 pages indiscriminately, which migh= t > > not be needed in all cases. > > > > fix all these issues by correctly doing the alignment in all needed ca= ses. > > > > Cc: Paul Yang > > Cc: Samer El-Haj-Mahmoud > > Cc: Gaurav Jain > > Signed-off-by: Pankaj Bansal > > --- > > .../MemoryAllocationServicesBBTestFunction.c | 148 > > +++++++++++++----- > > 1 file changed, 106 insertions(+), 42 deletions(-) > > > > diff --git a/uefi- > > > sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/Bla > > ckBo xTest/MemoryAllocationServicesBBTestFunction.c b/uefi- > > > sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/Bla > > ckBo xTest/MemoryAllocationServicesBBTestFunction.c > > index d18fe1fc2b94..9ed9e6e0de74 100644 > > --- a/uefi- > > > sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/Bla > > ckBo xTest/MemoryAllocationServicesBBTestFunction.c > > +++ b/uefi- > sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationS > > +++ er vices/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c > > @@ -354,6 +354,7 @@ BBTestAllocatePagesInterfaceTest ( > > EFI_TPL OldTpl; > > EFI_MEMORY_DESCRIPTOR Descriptor; > > UINTN PageNum; > > + UINTN Alignment; > > > > // > > // Get the Standard Library Interface @@ -700,14 +701,23 @@ > > BBTestAllocatePagesInterfaceTest ( > > PageNum =3D (UINTN)Descriptor.NumberOfPages; > > Start =3D Descriptor.PhysicalStart; > > > > - // > > - // Some memory types need more alignment than 4K, so > > - // > > - if (PageNum <=3D 0x10) { > > + Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; > > + > > + if (AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiACPIReclaimMemory || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryN= VS > || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiRuntimeServicesCode || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > > + EfiRuntimeServicesData) { > > + > > + Alignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; > > + } > > + > > + Start =3D (Start + Alignment - 1) & ~(Alignment - 1); > > + PageNum -=3D EFI_SIZE_TO_PAGES (Start - > > + Descriptor.PhysicalStart); > > + > > + PageNum &=3D ~(EFI_SIZE_TO_PAGES (Alignment) - 1); > > + if (PageNum <=3D EFI_SIZE_TO_PAGES (Alignment)) { > > break; > > } > > - Start =3D (Start + 0x10000) & 0xFFFFFFFFFFFF0000; > > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > > > > Memory =3D Start; > > > > @@ -830,14 +840,23 @@ BBTestAllocatePagesInterfaceTest ( > > PageNum =3D (UINTN)Descriptor.NumberOfPages; > > Start =3D Descriptor.PhysicalStart; > > > > - // > > - // Some memory types need more alignment than 4K, so > > - // > > - if (PageNum <=3D 0x10) { > > + Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; > > + > > + if (AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiACPIReclaimMemory || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryN= VS > || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiRuntimeServicesCode || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > > + EfiRuntimeServicesData) { > > + > > + Alignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; > > + } > > + > > + Start =3D (Start + Alignment - 1) & ~(Alignment - 1); > > + PageNum -=3D EFI_SIZE_TO_PAGES (Start - > > + Descriptor.PhysicalStart); > > + > > + PageNum &=3D ~(EFI_SIZE_TO_PAGES (Alignment) - 1); > > + if (PageNum <=3D EFI_SIZE_TO_PAGES (Alignment)) { > > break; > > } > > - Start =3D (Start + 0x10000) & 0xFFFFFFFFFFFF0000; > > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > > > > Memory =3D Start; > > > > @@ -953,14 +972,23 @@ BBTestAllocatePagesInterfaceTest ( > > PageNum =3D (UINTN)Descriptor.NumberOfPages; > > Start =3D Descriptor.PhysicalStart; > > > > - // > > - // Some memory types need more alignment than 4K, so > > - // > > - if (PageNum <=3D 0x10) { > > + Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; > > + > > + if (AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiACPIReclaimMemory || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryN= VS > || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiRuntimeServicesCode || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > > + EfiRuntimeServicesData) { > > + > > + Alignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; > > + } > > + > > + Start =3D (Start + Alignment - 1) & ~(Alignment - 1); > > + PageNum -=3D EFI_SIZE_TO_PAGES (Start - > > + Descriptor.PhysicalStart); > > + > > + PageNum &=3D ~(EFI_SIZE_TO_PAGES (Alignment) - 1); > > + if (PageNum <=3D EFI_SIZE_TO_PAGES (Alignment)) { > > break; > > } > > - Start =3D (Start + 0x10000) & 0xFFFFFFFFFFFF0000; > > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > > > > Memory =3D Start + (SctLShiftU64 (PageNum/3, EFI_PAGE_SHIFT) = & > > 0xFFFFFFFFFFFF0000); > > > > @@ -1076,14 +1104,23 @@ BBTestAllocatePagesInterfaceTest ( > > PageNum =3D (UINTN)Descriptor.NumberOfPages; > > Start =3D Descriptor.PhysicalStart; > > > > - // > > - // Some memory types need more alignment than 4K, so > > - // > > - if (PageNum <=3D 0x10) { > > + Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; > > + > > + if (AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiACPIReclaimMemory || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryN= VS > || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiRuntimeServicesCode || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > > + EfiRuntimeServicesData) { > > + > > + Alignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; > > + } > > + > > + Start =3D (Start + Alignment - 1) & ~(Alignment - 1); > > + PageNum -=3D EFI_SIZE_TO_PAGES (Start - > > + Descriptor.PhysicalStart); > > + > > + PageNum &=3D ~(EFI_SIZE_TO_PAGES (Alignment) - 1); > > + if (PageNum <=3D EFI_SIZE_TO_PAGES (Alignment)) { > > break; > > } > > - Start =3D (Start + 0x10000) & 0xFFFFFFFFFFFF0000; > > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > > > > Memory =3D Start + (SctLShiftU64 (PageNum * 2 / 3, > > EFI_PAGE_SHIFT) & 0xFFFFFFFFFFFF0000); > > > > @@ -1206,14 +1243,23 @@ BBTestAllocatePagesInterfaceTest ( > > PageNum =3D (UINTN)Descriptor.NumberOfPages; > > Start =3D Descriptor.PhysicalStart; > > > > - // > > - // Some memory types need more alignment than 4K, so > > - // > > - if (PageNum <=3D 0x10) { > > + Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; > > + > > + if (AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiACPIReclaimMemory || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryN= VS > || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiRuntimeServicesCode || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > > + EfiRuntimeServicesData) { > > + > > + Alignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; > > + } > > + > > + Start =3D (Start + Alignment - 1) & ~(Alignment - 1); > > + PageNum -=3D EFI_SIZE_TO_PAGES (Start - > > + Descriptor.PhysicalStart); > > + > > + PageNum &=3D ~(EFI_SIZE_TO_PAGES (Alignment) - 1); > > + if (PageNum <=3D EFI_SIZE_TO_PAGES (Alignment)) { > > break; > > } > > - Start =3D (Start + 0x10000) & 0xFFFFFFFFFFFF0000; > > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > > > > Memory =3D Start; > > > > @@ -1329,14 +1375,23 @@ BBTestAllocatePagesInterfaceTest ( > > PageNum =3D (UINTN)Descriptor.NumberOfPages; > > Start =3D Descriptor.PhysicalStart; > > > > - // > > - // Some memory types need more alignment than 4K, so > > - // > > - if (PageNum <=3D 0x10) { > > + Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; > > + > > + if (AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiACPIReclaimMemory || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryN= VS > || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiRuntimeServicesCode || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > > + EfiRuntimeServicesData) { > > + > > + Alignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; > > + } > > + > > + Start =3D (Start + Alignment - 1) & ~(Alignment - 1); > > + PageNum -=3D EFI_SIZE_TO_PAGES (Start - > > + Descriptor.PhysicalStart); > > + > > + PageNum &=3D ~(EFI_SIZE_TO_PAGES (Alignment) - 1); > > + if (PageNum <=3D EFI_SIZE_TO_PAGES (Alignment)) { > > break; > > } > > - Start =3D (Start + 0x10000) & 0xFFFFFFFFFFFF0000; > > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > > > > Memory =3D Start; > > > > @@ -1468,14 +1523,23 @@ BBTestAllocatePagesInterfaceTest ( > > PageNum =3D (UINTN)Descriptor.NumberOfPages; > > Start =3D Descriptor.PhysicalStart; > > > > - // > > - // Some memory types need more alignment than 4K, so > > - // > > - if (PageNum <=3D 0x10) { > > + Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY; > > + > > + if (AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiACPIReclaimMemory || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryN= VS > || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > EfiRuntimeServicesCode || > > + AllocatePagesMemoryType[TypeIndex] =3D=3D > > + EfiRuntimeServicesData) { > > + > > + Alignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY; > > + } > > + > > + Start =3D (Start + Alignment - 1) & ~(Alignment - 1); > > + PageNum -=3D EFI_SIZE_TO_PAGES (Start - > > + Descriptor.PhysicalStart); > > + > > + PageNum &=3D ~(EFI_SIZE_TO_PAGES (Alignment) - 1); > > + if (PageNum <=3D EFI_SIZE_TO_PAGES (Alignment)) { > > break; > > } > > - Start =3D (Start + 0x10000) & 0xFFFFFFFFFFFF0000; > > - PageNum =3D PageNum - EFI_SIZE_TO_PAGES(0x10000); > > > > Memory =3D Start; > > > > -- > > 2.17.1 > > IMPORTANT NOTICE: The contents of this email and any attachments are > confidential and may also be privileged. If you are not the intended rec= ipient, > please 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 i= n any > medium. Thank you. > >=20 IMPORTANT NOTICE: The contents of this email and any attachments are confi= dential and may also be privileged. If you are not the intended recipient, = please notify the sender immediately and do not disclose the contents to an= y other person, use it for any purpose, or store or copy the information in= any medium. Thank you.