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::241; helo=mail-wr0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) (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 81744207E6376 for ; Thu, 24 May 2018 02:09:52 -0700 (PDT) Received: by mail-wr0-x241.google.com with SMTP id i12-v6so1695950wrc.4 for ; Thu, 24 May 2018 02:09:52 -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=Uzz0QyLt4Fr8pKPiHZYf9hT1+XiwIbv2OCEoNsHYP3Y=; b=iptXnlA5ZX9dyr3DbjHaXLQtEBRkooUkFh66CQLkvXMbqnkVsEF3Ysce7hq02oD4lR HkYnaBzO+MhO+19IBjAocsdC64vH4M0AGPLCdu/CeTeoYrtANuS412hquZ7N7Nh3vDlp fd8aKPlurs/W2sMZm4GNmWdqigtYwQUqFSikA= 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=Uzz0QyLt4Fr8pKPiHZYf9hT1+XiwIbv2OCEoNsHYP3Y=; b=tO/xBjYapw12MVzGV885rtAwpQ1hQa9141Nb7D52c0epaxQIJ6IGP2u30dqzlEYFck CAF7SawnXCkDcT/199KYoE/AUxgtgMG3GAd+xwHY/9tec+zdeepdNh/38l9pzhQwR8mJ eq1Obxm+SwD03zo4mQLtP+zxlwyWMYc/4+claaFff9VXe7SCwOnBV7Hk15ITusXmwZAq usILm0vbOPz7DgTtwDTkLnTQnrk5xtaPUafosKC71En8BtmOBtXujBCIiJsvJqec8vSB DMZAe8jx4J8a5CqnrrT8rm3K7DpFK7vY0xAWplgcII37nGsX5tp+3ePqvMxIuXUc+Rl2 A4Hg== X-Gm-Message-State: ALKqPwef/+psQ6A8AwwbWQRzUntRQagJGXd0SJaqmUCo90pTjk9OzQHp 0EFcHJgbxWnEuESAi46KfnMQixMXUH8= X-Google-Smtp-Source: AB8JxZpyEmGg2Qq56X1ScrrG8xBxbPPzg4IXE/E0vu0uZr1ZFQgJXVFs93QuWCaiwquYpR7ZXICiuA== X-Received: by 2002:adf:a9aa:: with SMTP id b39-v6mr5782942wrd.36.1527152989809; Thu, 24 May 2018 02:09:49 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id x16-v6sm8505467wmc.2.2018.05.24.02.09.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 02:09:48 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: Ard Biesheuvel , Laszlo Ersek , Leif Lindholm , Michael D Kinney , Liming Gao , Star Zeng , Eric Dong , Dandan Bi Date: Thu, 24 May 2018 11:09:40 +0200 Message-Id: <20180524090945.10289-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 Subject: [PATCH v2 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: Thu, 24 May 2018 09:09:52 -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 EfiAllocatePeiAccessiblePages() routine in UefiLib 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-v2 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 Cc: Laszlo Ersek Cc: Leif Lindholm Cc: Michael D Kinney Cc: Liming Gao Cc: Star Zeng Cc: Eric Dong Cc: Dandan Bi 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 | 45 ++------------- .../FirmwarePerformanceDxe.c | 51 +++-------------- .../FirmwarePerformanceDxe.inf | 1 + MdePkg/Include/Library/DxeServicesLib.h | 23 +++++++- .../Library/DxeServicesLib/DxeServicesLib.c | 55 +++++++++++++++++++ .../Library/DxeServicesLib/DxeServicesLib.inf | 3 + .../PlatformBootManagerLib.inf | 1 + .../PlatformBootManagerLib/QemuKernel.c | 4 ++ 10 files changed, 104 insertions(+), 84 deletions(-) -- 2.17.0