From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.51]) by mx.groups.io with SMTP id smtpd.web10.5340.1588427606393231996 for ; Sat, 02 May 2020 06:53:27 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nxp.com header.s=selector2 header.b=KAZC0fHd; spf=pass (domain: nxp.com, ip: 40.107.6.51, mailfrom: gaurav.jain@nxp.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eTJhIlv9QfzLscav9t6yIE0Nb7Sm9tJWnep7bEpQso9RYtf9F4aqL6mGbXN1LDJ8YFL7WlUw/fWm0Z2v3etF1pKCcmHzjAZo3NooMvu2PwghjrrHtkUN7WK2S6DtvGt7m4x/FQVFGA+HXXP8L4yX9ujqO+MXozJt6uIbuZL3rQeuRuPUbygdVc9SQlNrYT/DP8htkJP0TLOhZdDcR4uZOd5PQak/6PvJUp+5t+EuDGt/kg3LVV5KrMprx3Nn1pb/8R5l5VA8qZmUhhq+R/p6zz+hg3QE9ze/xLX5cX5+MZjwwhhEP6RAG0iU/5r3id5hyEkSj6dz2Cm0kbJ/Q3OF6w== 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=t+Aw/Vh6m2jLjVI0CjQwPm0hFkzWHnFufiF40DrRmCo=; b=ZX+uceAWHzO76cZPXs/WSEseZLzn/uD6ADz+Z9CXSF+qjc4RS1KIVLb9ZFkJLYny7r7Uct14u4lDOHFGwrfAuIcMrVvAFWHWsICsxOA6/j+9zHWQba2BXJ8nw/4/ODSE1DeuAYuLqKWs+R4taVUJPnDeLq3WpzGBpqq6Og+uovyDU0CveDBBQbBEMzztXdi7O6v96gvw9sh0beDrwCZk4ihj093iR5DE5lG3f6inBxkgYaY756iYNRNMGxRgdAJ2dhrFZEk52/u3Kd3yD8fQfg8W69GCvT7eDCrrWlYOgu+8O5idFQpktEXpjiYLd944njm47rTJdX1msx9y+VMffA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t+Aw/Vh6m2jLjVI0CjQwPm0hFkzWHnFufiF40DrRmCo=; b=KAZC0fHdivEKbHk4oouNQLmUvrhfc1oC6sVJ6kMCLdUkwDrXgL8xU6fVku8QboUwlFWNnKUIUy9YJkp5X8ErHr/1Qr1VmlJtEaHvzll7oX4ibyYEoX2iQqohkajDodkenRzmx2m1rfN/hi1++ir3EIz4RkYYTsuM3wtmXiJCs8A= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=nxp.com; Received: from AM5PR04MB3074.eurprd04.prod.outlook.com (2603:10a6:206:4::16) by AM5PR04MB3107.eurprd04.prod.outlook.com (2603:10a6:206:c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.27; Sat, 2 May 2020 13:53:23 +0000 Received: from AM5PR04MB3074.eurprd04.prod.outlook.com ([fe80::e50b:610e:7080:e559]) by AM5PR04MB3074.eurprd04.prod.outlook.com ([fe80::e50b:610e:7080:e559%7]) with mapi id 15.20.2958.027; Sat, 2 May 2020 13:53:23 +0000 From: "Gaurav Jain" To: devel@edk2.groups.io Cc: Eric Jin , Supreeth Venkatesh , Prasanth Pulla , Samer El-Haj-Mahmoud , G Edhaya Chandran , Ard Biesheuvel , Pankaj Bansal , Gaurav Jain Subject: [edk2-test PATCH v2] SctPkg: Updated Start Address Alignment code Date: Sat, 2 May 2020 19:23:04 +0530 Message-Id: <1588427584-31684-1-git-send-email-gaurav.jain@nxp.com> X-Mailer: git-send-email 2.7.4 X-ClientProxiedBy: SG2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:3:17::16) To AM5PR04MB3074.eurprd04.prod.outlook.com (2603:10a6:206:4::16) Return-Path: gaurav.jain@nxp.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03032.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:3:17::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2958.26 via Frontend Transport; Sat, 2 May 2020 13:53:20 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [14.142.151.118] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8e71a51d-880b-4154-02d2-08d7eea02e01 X-MS-TrafficTypeDiagnostic: AM5PR04MB3107:|AM5PR04MB3107: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-Forefront-PRVS: 039178EF4A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p1OWCFU1dtTUqtA9n5J2nrxFKJmScFj1sdRUhxVJbs6wKO62fqPl8bOIH6m+zEcA17shORd6eQIRL2fhkyee7KNkkX4bUdOiJdrWKUivEP2l+8T3ip3ech4f0piYQajnFqjb3zC38rHIMhd94qxHKjitGF8PVS9MOTIcomABZcQkiZhAfqxsQZGLTd4dnMwL70DeYDAwWcbRrqJtGNPF8Ju0BJvYLU84fO5fraEUPrzUXsw/NiTgb499Rw+tw86MVdGkzDWVBmkX3aB5uVs3URx+rryNEfMjoRlzJvtPD9haFZbbk+M3DBycWUgThMFFPNm9/f/hdgVyAnW52HGUplyS4D6rPVdN5BowiHnCB88SuaepU5VWmJrFZyCOZVtNWEQnqrxvPRAXGe9Kqh/exG6JywQ+sNNlfOkGhqex0XJKrU0zuItDFNmtubN48eXpIJqFZMlZO0l0G2+C1lexQao6KL4KIMDRMJi734+3mNJQK0IUki87TJTi9zddbZhXaF3nTTo9Dk42T83OhSmIDnizT4ZruL96TbIa+cxXkytQpOYkdRBXzq3nPnxxrvmwvRy/GOvp81cXnVRd+toJwQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM5PR04MB3074.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(39860400002)(366004)(136003)(346002)(376002)(6486002)(52116002)(7696005)(5660300002)(86362001)(966005)(478600001)(2906002)(15650500001)(6916009)(1006002)(6666004)(66556008)(36756003)(66476007)(4326008)(16526019)(316002)(956004)(44832011)(186003)(55236004)(66946007)(54906003)(2616005)(26005)(8936002)(8676002)(110426005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 68k0rJmSdRJ48BsMXycGpcNRTgQTZywUr9ZOF6vJds0Jst1D/wTR95rhJZRx5YBCGTwTyk79Xurj7/q9bg43C6eglJKWfvjzhc+XlpcD6IrVFjpbLCS7pxn8kuV1y+DSXoLhvPYFVgQVlJnsKgIeEgWhlKogMAC56NfvreuJBm8nncV9vtI00QpnoEQW8pp9mB4xrvf6D/OC/QfmCxtr2+Ea2y8IJHN+bMVM0Y7K8kUvVyi9fOt2rC28n2A0rmeGWYRfhtXqLlq5FAI114neXYhW+RSmtYbfo5r1ZDYLSTkrcchR3bRebsNX2MWyZNcRJT4A5aArBeVrTFH26NnLkI/dZaa7pdtBOtc8W/pVCNGdFWcwH7ihbLe0nPo8FRvtJPb6y6EMrFNJVq++a7ulNrDND/ufIC2Ez4qcNdshYNLw6qamMTUo2LGVMjZbK9fR/xak/ICqdnixRRDK7KKWtbnw2TVn6i7TAT+LZW1AyvPamSMg/oKDNeib26CUhGgxnm4inwKO2z6Q348HCeqXa+STgNpHS+OBh6PsfhNQ76JWdTs01EFSISFTcOsl0X9U9u99VhXF65H3kPhUpNeOlICYaE4bDf47oxg5jK4vFAjg75S9pmvpWQ4ePdqMd1tdCgiSLDXg5NWiAB65XK8WqotI31scul8DU/BC27XbwCIWesiLiZmHl5MWLIVCqgZg910+QWrPVAeLwdU5D2w076wSZfiNEikKpPu2TrRSjVCwwQWJEcJQFwG8Ixk7bC5ooNEAmvnu2zxeCPzm/w/55d3TT4T5dsvhYy9B77vlzCI= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e71a51d-880b-4154-02d2-08d7eea02e01 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2020 13:53:23.4898 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ugC7mHMWCsX0eUJTJ2yWEnw7dA0THKJ0unQY1fMaIN9iuWS8yF/EpCx+KkS1ZESB6CReVAr3EZ1okxjGnDZrng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR04MB3107 Content-Type: text/plain REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2671 AllocatePages Functionality test. Existing Code Increase Start address by 64k, even if Start is already aligned to 64k. Suggested Change will not modify Start, if Start is already aligned to 64k For Eg. Available Memory(Start is aligned to 64k): Start End PageNum(Free Pages) 80000000 EBD6EFFF 6BD6F(Number of Free pages are not 64k Aligned) edk2-test code: Start is increased & aligned by 64k(Equal to 16 pages of size 4k each). Request for Pagenum is minus by 16 Pages. Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000 Start = (0x80000000 + 0x10000) & 0xFFFFFFFFFFFF0000 = 0x80010000 PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000) = 0x6BD6F - 0x10 = 0x6BD5F edk2 memory allocation code to Align the requested pages to 64k boundary: ------------------------------------------------------------------------ NumberOfPages += EFI_SIZE_TO_PAGES(Alignment) - 1 = 0x6BD5F + 0xF = 0x6BD6E NumberOfPages &= ~(EFI_SIZE_TO_PAGES(Alignment) - 1) = 0x6BD6E & 0xFFFFFFF0 = 0x6BD60 We can observe that requested pages is incraesed by 1 page, which results in below error. ConvertPages: range 80010000 - EBD6FFFF covers multiple entries. Signed-off-by: Gaurav Jain --- Notes: v2 Updated Commit Message with an Example .../BlackBoxTest/MemoryAllocationServicesBBTestFunction.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c index d18fe1f..a42cd9a 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c @@ -706,7 +706,7 @@ BBTestAllocatePagesInterfaceTest ( if (PageNum <= 0x10) { break; } - Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000; + Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000); Memory = Start; @@ -836,7 +836,7 @@ BBTestAllocatePagesInterfaceTest ( if (PageNum <= 0x10) { break; } - Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000; + Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000); Memory = Start; @@ -959,7 +959,7 @@ BBTestAllocatePagesInterfaceTest ( if (PageNum <= 0x10) { break; } - Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000; + Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000); Memory = Start + (SctLShiftU64 (PageNum/3, EFI_PAGE_SHIFT) & 0xFFFFFFFFFFFF0000); @@ -1082,7 +1082,7 @@ BBTestAllocatePagesInterfaceTest ( if (PageNum <= 0x10) { break; } - Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000; + Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000); Memory = Start + (SctLShiftU64 (PageNum * 2 / 3, EFI_PAGE_SHIFT) & 0xFFFFFFFFFFFF0000); @@ -1212,7 +1212,7 @@ BBTestAllocatePagesInterfaceTest ( if (PageNum <= 0x10) { break; } - Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000; + Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000); Memory = Start; @@ -1335,7 +1335,7 @@ BBTestAllocatePagesInterfaceTest ( if (PageNum <= 0x10) { break; } - Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000; + Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000); Memory = Start; @@ -1474,7 +1474,7 @@ BBTestAllocatePagesInterfaceTest ( if (PageNum <= 0x10) { break; } - Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000; + Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000; PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000); Memory = Start; -- 2.7.4