From patchwork Mon May 28 14:40:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 137081 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2908813lji; Mon, 28 May 2018 07:40:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq4AY+5Tfrd/sXsvj1UefyTh1LP4VFkI+wQ43NWFq3VoRRm12/VGDXWLNGU0jawUR7eTIjA X-Received: by 2002:a17:902:6f16:: with SMTP id w22-v6mr13680425plk.216.1527518434680; Mon, 28 May 2018 07:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527518434; cv=none; d=google.com; s=arc-20160816; b=ctA7EgkH4iheci64tyASLHpsbiL1YHXX/n6SlTCDhvPif6g1sC4zZsq69AIlQhJuHr a8Kz4EuZnLpeO18e/wG2gJw/CUNS78M9PAmN2bHpj4QscNmsFfw1loklmG70ZM8dhflL zpDMFNSv3dD+MbRCCocIo0LAyeD/F67aJrBOa/4wJMofUkzIw97x2RsZhyNsuwpHsorO pNqtHdN43FUzgwruazZFK25BCKSakFxW+JLNePBJym+OcX+fsHuQwqDlSDlvgm9gjf5+ vQOvqnfoHv+qeORy7gBo5+33rX0hnu8lOc8/qQpoDoFkq/tgj87eKxA2Xg07ByIv+vxZ YKkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=YOkknSqrUJsvXJz2OGAReiZrGXOWdb3SPx7eJ7Bqlk4=; b=HdCNbgssZMNRC9jcI2VxxecYK8fb08qndIStSyUrdu0zLx5vqM0a/CSgBE6nhVW/Qm Z6k2cRMiJxvpTRPUyNuirPweQ7vaBcyMhIofj4b6VA9zKyoZQYp36Xl7/ZcXxP/7hntI XTPSRF1YVmCLJrJqENVKyFjVddMyIx20e+IHMcUt24LdJII6KzDxn+arSDypLxFXCGD/ bo/+63HuGjzfTy5iqIKBcZB0U0yNcNw2C0K3+P3uXh7BRp2JUy+hKuWfQFTqqqQjFx+V 8f3FfuF9TH9sNYVrC7usrFOsmbDMIzDF8kYfh15pLHUkN+GFX22I+vuQrMg9GjdZa/2Z 5/fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aRDj8dsr; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id k90-v6si31401114pfh.50.2018.05.28.07.40.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 07:40:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aRDj8dsr; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D847C2097787F; Mon, 28 May 2018 07:40:33 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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-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 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: [edk2] [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: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel