From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.45974.1684319096118959788 for ; Wed, 17 May 2023 03:24:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TgKjafn3; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684319095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JBnaLAyXWNq7tz/M8OhMZ2GiAWqzxCVz7xq2NacXFJA=; b=TgKjafn3HGyCQvXuTHqjh+nuWW4F3sBl27oO4lXmMrZn8Ge5oIloOv3l+Qc2BRkVBdhcxC fxijmJSHzKWnbhyDST7bh2GoIU/wtxjIXgTThbNMzVWDaUop5KpnxTmTV/AUJvgPcUFD8F seIs5mVXyhgCaWHF/LyugtQTW7v4bqw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-492-ZVSsi_05N5akV3Nghw0u8A-1; Wed, 17 May 2023 06:24:50 -0400 X-MC-Unique: ZVSsi_05N5akV3Nghw0u8A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8EDF8101A54F; Wed, 17 May 2023 10:24:50 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.130]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 59FB42026D16; Wed, 17 May 2023 10:24:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 15DC818023A3; Wed, 17 May 2023 12:24:49 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Oliver Steffen , Pawel Polawski , Gerd Hoffmann , Ard Biesheuvel , Jiewen Yao Subject: [PATCH 1/3] OvmfPkg/PlatformInitLib: check PcdUse1GPageTable Date: Wed, 17 May 2023 12:24:47 +0200 Message-Id: <20230517102449.1334621-2-kraxel@redhat.com> In-Reply-To: <20230517102449.1334621-1-kraxel@redhat.com> References: <20230517102449.1334621-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true If PcdUse1GPageTable is not enabled restrict the physical address space used to 1TB, to limit the amount of memory needed for identity mapping page tables. The same already happens in case the processor has no support for gigabyte pages. Signed-off-by: Gerd Hoffmann --- OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf | 1 + OvmfPkg/Library/PlatformInitLib/MemDetect.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf index 86a82ad3e084..5a79d95b689c 100644 --- a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf +++ b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf @@ -58,6 +58,7 @@ [LibraryClasses.X64] [Pcd] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress + gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable [FixedPcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c index acf90b4e93fd..1102b00ecbf0 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -663,6 +663,11 @@ PlatformAddressWidthFromCpuid ( PhysBits = 40; } + if (!FixedPcdGetBool (PcdUse1GPageTable) && (PhysBits > 40)) { + DEBUG ((DEBUG_INFO, "%a: limit PhysBits to 40 (PcdUse1GPageTable is false)\n", __func__)); + PhysBits = 40; + } + PlatformInfoHob->PhysMemAddressWidth = PhysBits; PlatformInfoHob->FirstNonAddress = LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth); } -- 2.40.1