From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c0c::242; helo=mail-wr0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7BCBD20977876 for ; Mon, 28 May 2018 07:40:31 -0700 (PDT) Received: by mail-wr0-x242.google.com with SMTP id w7-v6so8709940wrn.6 for ; Mon, 28 May 2018 07:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=kcCG24izPMZnZVJ1SgSt8V0BZSPwEc8XcUWukwobPrI=; b=aRDj8dsrxNT8cK53xuSHvXr9p7JAM0erQ2AChirU4CezR+IfkfY2wmsvjy2eMekuc+ ogIJaIHSU+oe6v+fhgFCBFC4xgh2QgK3NZS+58ebY5t+NRwHZNiLQKAFSRHkQ+N/D9A7 prwq2gJb53yx1/eMAE3YHMnIUNU3vcEF6FfoQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kcCG24izPMZnZVJ1SgSt8V0BZSPwEc8XcUWukwobPrI=; b=DTEPhWW2Gle9w+anC2YPtD5+rbPKjFQXa3Kek0SC+3w2Sqcim0S9JTBbLqPPatLWXr Roatf0AGM+LYqov2ThaZ6ONu02vHuvr18PRon6O3jTGonN4eDefyYMd8bW7FsLHLOQtx G7FTcwhgsZRD2/2LDYFuzCLa0QVzNro8a9gThsL/vHTjWQOdHwJtBGiHr9hoBKr939tq xkTGzJUpF/e2lzm4C6l18yjenyQJLwF5PTJjUL05XfNiJccRov9iCBHcZEH4FqbuYLHZ qAEg07+o21/ZdSGmG/ozZXmxP7xEj/Em+1Mx35eshv5B3oONmt5WaQPpb1ZTXzrkd7a1 zw9Q== X-Gm-Message-State: ALKqPwdioF+tRVZ1RTZYO8vtxuWGWAu81oOATca8e2sxzKpIamUgC9ke SRv49BbASwLFXshMyG+Yu6K3uPes8QE= X-Google-Smtp-Source: AB8JxZr6RxJIhIQ4B+GKQQtg1wAYtc9hWCaJO5iOR/lZk5X5dn7VmVrSBpGGWYUSLpGF12jH3IHUyQ== X-Received: by 2002:adf:afce:: with SMTP id y14-v6mr11599812wrd.249.1527518429847; Mon, 28 May 2018 07:40:29 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id y18-v6sm4177938wrl.53.2018.05.28.07.40.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 07:40:29 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: Ard Biesheuvel Date: Mon, 28 May 2018 16:40:19 +0200 Message-Id: <20180528144024.10809-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 Subject: [PATCH v3 0/5] Abstract allocation of PEI accessible memory X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 May 2018 14:40:32 -0000 At the moment, FirmwarePerformanceTableDataDxe or DxeCorePerformanceLib are unusable on systems such as AMD Seattle, because they unconditionally attempt to allocate memory below 4 GB, and ASSERT() if this fails. On AMD Seattle, no 32-bit addressable DRAM exists, and so the driver will always assert, and crash a running DEBUG build. The reason for this is that some platforms (i.e., X64 builds consisting of a 32-bit PEI stage and 64-bit remaining stages) require these allocations to be below 4 GB, and for some reason, open coding this practice throughout the code without regard for other architectures has been regarded as an acceptable approach. Instead, I would like to propose the approach implemented in this series: - create an abstracted AllocatePeiAccessiblePages() routine in DxeServicesLib that simply allocates pages from any region on all architectures except X64, and allocate below 4 GB for X64 - update the various call sites with calls to this new function. The above is implemented in patches #3 - #6. Patches #1 and #2 are fixes for issues that I observed in ArmVirtPkg and OvmfPkg while working on these patches. Code can be found here: https://github.com/ardbiesheuvel/edk2/tree/allocate-pei-v3 Changes since v2: - move AllocatePeiAccessiblePages() to a separate .c file, and create a special X64 version (#3) - add back ZeroMem() call to #4 - add Laszlo's ack to #4 - #5 (but not to #3 since it has been updated) Changes since v1: - add Laszlo's ack to #1 - #2 - move EfiAllocatePeiPages() to DxeServicesLib and drop Efi prefix - update implementation to take EfiFreeMemoryTop into account when built for X64 Ard Biesheuvel (5): OvmfPkg/PlatformBootManagerLib: add missing report status code call ArmVirtPkg/PlatformBootManagerLib: add missing report status code call MdePkg/DxeServicesLib: introduce AllocatePeiAccessiblePages routine MdeModulePkg/DxeCorePerformanceLib: use AllocatePeiAccessiblePages MdeModulePkg/FirmwarePerformanceDataTableDxe: use AllocatePeiAccessiblePages .../PlatformBootManagerLib.inf | 1 + .../PlatformBootManagerLib/QemuKernel.c | 4 ++ .../DxeCorePerformanceLib.c | 48 ++----------- .../FirmwarePerformanceDxe.c | 51 +++----------- .../FirmwarePerformanceDxe.inf | 1 + MdePkg/Include/Library/DxeServicesLib.h | 23 ++++++- MdePkg/Library/DxeServicesLib/Allocate.c | 54 +++++++++++++++ .../Library/DxeServicesLib/DxeServicesLib.inf | 11 ++- MdePkg/Library/DxeServicesLib/X64/Allocate.c | 69 +++++++++++++++++++ .../PlatformBootManagerLib.inf | 1 + .../PlatformBootManagerLib/QemuKernel.c | 4 ++ 11 files changed, 182 insertions(+), 85 deletions(-) create mode 100644 MdePkg/Library/DxeServicesLib/Allocate.c create mode 100644 MdePkg/Library/DxeServicesLib/X64/Allocate.c -- 2.17.0