From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.43]) by mx.groups.io with SMTP id smtpd.web11.9263.1595557961360278649 for ; Thu, 23 Jul 2020 19:32:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=kAKFgBuC; spf=pass (domain: arm.com, ip: 40.107.22.43, 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=Tt3k9PLwf7f2DrAvVjaOCXz84dtG2Rs1yOrNvnb0804=; b=kAKFgBuC6h+hae3aOWvKn5r0mrbEH0e4dpfVxNlB8sUyakSTPvXx35KMrRtocvPyHHDijMT5X22JDwGJNRrz3WoRaumFGZaaE95HG1gCXB4jmnBWz3V2CbiHUsL1l2N78mFlyjVDgrE5BGN5k/+1ty2LeHPm+Uv4XGxqo6/KhAU= Received: from AM5PR0701CA0016.eurprd07.prod.outlook.com (2603:10a6:203:51::26) by VI1PR08MB3533.eurprd08.prod.outlook.com (2603:10a6:803:84::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.24; Fri, 24 Jul 2020 02:32:39 +0000 Received: from AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:51:cafe::be) by AM5PR0701CA0016.outlook.office365.com (2603:10a6:203:51::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.9 via Frontend Transport; Fri, 24 Jul 2020 02:32:39 +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 AM5EUR03FT018.mail.protection.outlook.com (10.152.16.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10 via Frontend Transport; Fri, 24 Jul 2020 02:32:38 +0000 Received: ("Tessian outbound 73b502bf693a:v62"); Fri, 24 Jul 2020 02:32:38 +0000 X-CR-MTA-TID: 64aa7808 Received: from ce73458c3834.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6125DAD1-438D-45F3-BBDE-AFC5457B2EB9.1; Fri, 24 Jul 2020 02:32:33 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ce73458c3834.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 24 Jul 2020 02:32:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y/hbN+smXy1e4Bb5dUarY8yRo6bIZDWGPhbJfdbKxiCv92HtIVd2vhFQQlzoe/bObMv9AGkjcrq5SelJLKdTMHU9pFsObg+FZtQJPp7bPCJD/aqQzH9otfQofe0V7xY4kLCWSVwGJDYaI0pvlZSV7CgC3h+pv2SckF2Cn4yztKRe/2WBV0e/fqfIR1qcwDYxk6vB3AYZr+r6pfoE9sxHZBnm9wrrpqAoP4Gf/dPMvQRO6JmcZt2n+QGwm8hkbQqW2ZSRIrRjFfBV/EjJO+MsTYNHhajAs36HAEil7yKOfMkJcWNoP/O30tSz1cxcLeXdvqI4uraxcxsj5uzI6TXrHQ== 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=Tt3k9PLwf7f2DrAvVjaOCXz84dtG2Rs1yOrNvnb0804=; b=ZxkIXenFSyaaRHXnYpNL2JR9cGu2ECYKKS7zMTqR7Q/Pz2lM4tVEj7QK+gKihrl66nb68dbFeXz2AZonLDe68PSpbjmuqA2iKCvVTvAWx/ZhfSlLyoeUo5kHuE6mv9gVXOAaDhpjbjxUJF6igqtF8z+Pjjk9bOKj7+g+l6VECiaGMyCvYbkpYUitpQz82JVQ9sDHQdeU08i/RaUDJVka6JB0Wj5iRHlVINlRviZ/Ptt6WVx1h+R5LGbOQQN6zx7z150Rom9L800L54mLjEa/j2FX+vCy5zlxZAQXCfucx+p5CgUF9DuZPC195qM/Q72tx5mEPVABvB839r581xOqyA== 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=Tt3k9PLwf7f2DrAvVjaOCXz84dtG2Rs1yOrNvnb0804=; b=kAKFgBuC6h+hae3aOWvKn5r0mrbEH0e4dpfVxNlB8sUyakSTPvXx35KMrRtocvPyHHDijMT5X22JDwGJNRrz3WoRaumFGZaaE95HG1gCXB4jmnBWz3V2CbiHUsL1l2N78mFlyjVDgrE5BGN5k/+1ty2LeHPm+Uv4XGxqo6/KhAU= Received: from DB7PR08MB3260.eurprd08.prod.outlook.com (2603:10a6:5:21::23) by DB8PR08MB5084.eurprd08.prod.outlook.com (2603:10a6:10:38::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23; Fri, 24 Jul 2020 02:32:32 +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.3195.028; Fri, 24 Jul 2020 02:32:32 +0000 From: "Samer El-Haj-Mahmoud" 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: [PATCH edk2-test 1/1] SctPkg: fix page alignment calculations Thread-Topic: [PATCH edk2-test 1/1] SctPkg: fix page alignment calculations Thread-Index: AQHWUhsw7B7BBYcGw0GFXF8LcjkQr6kWIODQ Date: Fri, 24 Jul 2020 02:32:32 +0000 Message-ID: References: <20200704155224.28526-1-pankaj.bansal@oss.nxp.com> In-Reply-To: <20200704155224.28526-1-pankaj.bansal@oss.nxp.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: a24269eb-f42f-4a43-aaa1-66a68d861879.1 x-checkrecipientchecked: true Authentication-Results-Original: oss.nxp.com; dkim=none (message not signed) header.d=none;oss.nxp.com; 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: ce8b7c5d-b0cd-4083-95eb-08d82f79d549 x-ms-traffictypediagnostic: DB8PR08MB5084:|VI1PR08MB3533: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:1186;OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: DMkkRWl9S4YXXXC0YXgHn8g1o1tEndYGXwxWAhH4lAYxC1Cz8FBSMWDTUfMIawCG9+Se5y4igOaAZU/iyAOQtnZW9P/WRplcUw87YboTWEIJ4h0cbdWUyM7o7+2KaEBzRuBaEaLX1J+BWAOoxfuEMXh/TTupi2N2Uy1PP7ANN9uB1ZJ6L2K7KRivfJo0lLgovId/8o5YbZMCmgY52Q7xAzTyJY1rXTqt7oxNdsF1pd01GaZGWYG9/wuIXGXvjnGx+HdI2iS/S8kUdw8CdCnQn2J2+PDShdzy0XJkJsqJhhzXxweOwveE4l/loX4+sL2Z 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)(39860400002)(396003)(136003)(366004)(346002)(376002)(33656002)(4326008)(55016002)(8936002)(66946007)(2906002)(8676002)(76116006)(52536014)(5660300002)(316002)(54906003)(86362001)(6636002)(9686003)(53546011)(6506007)(26005)(7696005)(186003)(478600001)(83380400001)(71200400001)(66446008)(64756008)(66476007)(66556008)(110136005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: fJd0EDiJ1F8Tz4C6vizzhUNeBOaZfPObwht7zFA/No7etsfjRAsZ2EgQhABg5OYu6JarSbm66bjZiZ0Q52V5kBodiJHFbzqZjt7s8lg++FT+so335r8qNb4PLYAG1WrR4fvBZl/+NZlN0GqtVRlPIhmQKw2vueVNx9u4To3FIaGNSd1DPciGBMLK3cI36UfFlU+SpfBIL41remBrNznV0nvZdXnXJ3a74h7rE0/H4pJEZ5hcZE/XEg2Gq2Tb1aFeJjBBR3c/++s1dOdQTOifgGre00124Gm0oUwR043JViSq1R/prh1HU0SxfHKiQzYkUxOfChFfOGotO99LDZBDRI6EBID5RW4s+ctUjFbncxpBu+Wku3wlCRLJ1pDW/Jpv4f9seyuCGgqcFmQ7tm/jLgQN4laDbE44AIDlFzPJLXtUfPoT0Nh7qrc9CQlA1rrFcaFJC93rDZlQCRKcAVjwFfDEy6zlTpJuVmjkb8/dev0Okyvdl1ceg4VwK5NhfSCX MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5084 Original-Authentication-Results: oss.nxp.com; dkim=none (message not signed) header.d=none;oss.nxp.com; dmarc=none action=none header.from=arm.com; Return-Path: Samer.El-Haj-Mahmoud@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ba6900e0-5653-4ed5-df67-08d82f79d16b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gxtOiS+oxrV4MDfdm/OAJvrlQE09YoP6prMC7TEt20h3QgSmd3pxl+bnqcnQRDq7NhADeahHpVQgkdJLWKX09os9ODEQWH/8bBYHce2wUO2HcuvROIn4Hlrm3BS3y8EIV/ds3eRYdxCEhubKD1srLxpzz5W8dr+y4N13RS95PUPOJBf04tVQUEPSdp2Jj2hYfvMoaGwLOM2uCEgV2f+oVwX1kK5cLszjrqC5JOl0VY66kHNB30g4mEZszEbI5muNIKZhcWsc2CyrP3Wd8FaDPoZmtft7QlOcDZPe4IpK8vommaz0wuY7JLZc8/46w+xe3vo9zGqxK5Y6ImMbHd0zSLpp1L8ywLX03Mf4KIQ9TIinaXDVWzw0EH9KyivoEAkjVf2Hf9okiTG7hoyGjElMQA== 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)(136003)(376002)(396003)(346002)(39860400002)(46966005)(26005)(4326008)(6506007)(478600001)(86362001)(53546011)(316002)(336012)(82310400002)(9686003)(83380400001)(36906005)(55016002)(356005)(186003)(6636002)(8936002)(52536014)(70586007)(70206006)(8676002)(33656002)(2906002)(81166007)(110136005)(54906003)(47076004)(82740400003)(30864003)(7696005)(5660300002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2020 02:32:38.8073 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce8b7c5d-b0cd-4083-95eb-08d82f79d549 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3533 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 Chandra= n > > 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 differen= t > memory types. > While doing so, it tries to fix up the Start and PageNum for 64K Page siz= e. 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 might > not be needed in all cases. > > fix all these issues by correctly doing the alignment in all needed cases= . > > 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/BlackB= o > xTest/MemoryAllocationServicesBBTestFunction.c b/uefi- > sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackB= o > xTest/MemoryAllocationServicesBBTestFunction.c > index d18fe1fc2b94..9ed9e6e0de74 100644 > --- a/uefi- > sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackB= o > xTest/MemoryAllocationServicesBBTestFunction.c > +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationSer > +++ 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 EfiACPIReclaimMem= ory || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryNVS = || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiRuntimeService= sCode || > + 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 EfiACPIReclaimMem= ory || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryNVS = || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiRuntimeService= sCode || > + 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 EfiACPIReclaimMem= ory || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryNVS = || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiRuntimeService= sCode || > + 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 EfiACPIReclaimMem= ory || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryNVS = || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiRuntimeService= sCode || > + 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_SHI= FT) & > 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 EfiACPIReclaimMem= ory || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryNVS = || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiRuntimeService= sCode || > + 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 EfiACPIReclaimMem= ory || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryNVS = || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiRuntimeService= sCode || > + 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 EfiACPIReclaimMem= ory || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiACPIMemoryNVS = || > + AllocatePagesMemoryType[TypeIndex] =3D=3D EfiRuntimeService= sCode || > + 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 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.