From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53534+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53534+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1580334267949608.4091342420369; Wed, 29 Jan 2020 13:44:27 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZcLJYY1788612xqQWBrbQbt5; Wed, 29 Jan 2020 13:44:27 -0800 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web09.592.1580334264556353369 for ; Wed, 29 Jan 2020 13:44:24 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-187-6RTWwOP7NUm2ajoGfbhtvg-1; Wed, 29 Jan 2020 16:44:18 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 81164100550E; Wed, 29 Jan 2020 21:44:17 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8839E5DA75; Wed, 29 Jan 2020 21:44:16 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen Subject: [edk2-devel] [PATCH v2 01/11] OvmfPkg: introduce PcdQ35SmramAtDefaultSmbase Date: Wed, 29 Jan 2020 22:44:02 +0100 Message-Id: <20200129214412.2361-2-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 6RTWwOP7NUm2ajoGfbhtvg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: SNFVnr4Y7LiOo4Kg9LTXt0D8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334267; bh=1WUbzxX23nEswGxvaC3LuKNHJL1cn1nhIbYeFtwIVok=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Opy1MWdhuOJD64QyE6s1/nt36eZ5vtH5/UV97ROrAUViM8jeBmkSy8yrtQsxCBcK28Q zCKf4+UlmvaQoMfSWxj2nvqQS2fb2Ql7eYnHv2kCsDPUleczn/915UaL5v3u2aWmqLfPG lMFW1jde6gg+ZC3lwZyrfmPaMxK7euxiclU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" For supporting VCPU hotplug with SMM enabled/required, QEMU offers the (dynamically detectable) feature called "SMRAM at default SMBASE". When the feature is enabled, the firmware can lock down the 128 KB range starting at the default SMBASE; that is, the [0x3_0000, 0x4_FFFF] interval. The goal is to shield the very first SMI handler of the hotplugged VCPU from OS influence. Multiple modules in OVMF will have to inter-operate for locking down this range. Introduce a dynamic PCD that will reflect the feature (to be negotiated by PlatformPei), for coordination between drivers. Cc: Ard Biesheuvel Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Jiewen Yao Reviewed-by: Ard Biesheuvel --- Notes: v2: - trim Cc list - pick up Jiewen's R-b OvmfPkg/OvmfPkg.dec | 6 ++++++ OvmfPkg/OvmfPkgIa32.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgX64.dsc | 1 + 4 files changed, 9 insertions(+) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index d5fee805ef4a..57034c784f88 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -257,6 +257,12 @@ [PcdsDynamic, PcdsDynamicEx] # This PCD is only accessed if PcdSmmSmramRequire is TRUE (see below). gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8|UINT16|0x20 =20 + ## Set to TRUE by PlatformPei if the Q35 board supports the "SMRAM at de= fault + # SMBASE" feature. + # + # This PCD is only accessed if PcdSmmSmramRequire is TRUE (see below). + gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE|BOOLEAN|0x34 + [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0= x1c gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN= |0x1d diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 4568b78cadf1..43ff51933609 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -565,6 +565,7 @@ [PcdsDynamicDefault] =20 !if $(SMM_REQUIRE) =3D=3D TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 + gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01 gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|100000 !endif diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 152b5d067116..5b3e217e9220 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -577,6 +577,7 @@ [PcdsDynamicDefault] =20 !if $(SMM_REQUIRE) =3D=3D TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 + gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01 gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|100000 !endif diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 4bfad441bd9f..a378d0a449aa 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -576,6 +576,7 @@ [PcdsDynamicDefault] =20 !if $(SMM_REQUIRE) =3D=3D TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 + gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01 gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmApSyncTimeout|100000 !endif --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53534): https://edk2.groups.io/g/devel/message/53534 Mute This Topic: https://groups.io/mt/70252351/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53535+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53535+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1580334268024471.12904937032056; Wed, 29 Jan 2020 13:44:28 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id KtP0YY1788612xsUElqpewMJ; Wed, 29 Jan 2020 13:44:26 -0800 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web10.614.1580334265461615839 for ; Wed, 29 Jan 2020 13:44:25 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-BBqG-SJfOEmJ8GZfPyW3_Q-1; Wed, 29 Jan 2020 16:44:20 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C499F13E1; Wed, 29 Jan 2020 21:44:18 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2ED45DA75; Wed, 29 Jan 2020 21:44:17 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen Subject: [edk2-devel] [PATCH v2 02/11] OvmfPkg/IndustryStandard: increase vertical whitespace in Q35 macro defs Date: Wed, 29 Jan 2020 22:44:03 +0100 Message-Id: <20200129214412.2361-3-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: BBqG-SJfOEmJ8GZfPyW3_Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: 9c5D6YEUYRBFwRSH1UW3tpFqx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334266; bh=3ppDGY2xi/Wsjdi42K6HDhfAEC5xr8c2ij5Bn4RJPVQ=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=hKlLx3XZAxguVhkSaHNJik6wZCr+5tBw9NL/UI21znqzwbcZub2qmwUPFtN1RXFjMSk n9kpqCIFDh/X+bf3EJ6TA3tR/gHhoP8c4KyUeIMrchG1G0e/4Et2Qz46woJJXfdSzVmV9 p0DiVdnBsjbhAMdL2nTtrUpQGlMbUzdmx+0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In a subsequent patch, we'll introduce new DRAM controller macros in "Q35MchIch9.h". Their names are too long for the currently available vertical whitespace, so increase the latter first. There is no functional change in this patch ("git show -b" displays nothing). Cc: Ard Biesheuvel Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Jiewen Yao Reviewed-by: Ard Biesheuvel --- Notes: v2: - trim Cc list - pick up Jiewen's R-b OvmfPkg/Include/IndustryStandard/Q35MchIch9.h | 100 ++++++++++---------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/OvmfPkg/Include/IndustryStandard/Q35MchIch9.h b/OvmfPkg/Includ= e/IndustryStandard/Q35MchIch9.h index 2ac16f19c62e..80379c223a1c 100644 --- a/OvmfPkg/Include/IndustryStandard/Q35MchIch9.h +++ b/OvmfPkg/Include/IndustryStandard/Q35MchIch9.h @@ -27,56 +27,56 @@ // #define DRAMC_REGISTER_Q35(Offset) PCI_LIB_ADDRESS (0, 0, 0, (Offset)) =20 -#define MCH_EXT_TSEG_MB 0x50 -#define MCH_EXT_TSEG_MB_QUERY 0xFFFF - -#define MCH_GGC 0x52 -#define MCH_GGC_IVD BIT1 - -#define MCH_PCIEXBAR_LOW 0x60 -#define MCH_PCIEXBAR_LOWMASK 0x0FFFFFFF -#define MCH_PCIEXBAR_BUS_FF 0 -#define MCH_PCIEXBAR_EN BIT0 - -#define MCH_PCIEXBAR_HIGH 0x64 -#define MCH_PCIEXBAR_HIGHMASK 0xFFFFFFF0 - -#define MCH_PAM0 0x90 -#define MCH_PAM1 0x91 -#define MCH_PAM2 0x92 -#define MCH_PAM3 0x93 -#define MCH_PAM4 0x94 -#define MCH_PAM5 0x95 -#define MCH_PAM6 0x96 - -#define MCH_SMRAM 0x9D -#define MCH_SMRAM_D_LCK BIT4 -#define MCH_SMRAM_G_SMRAME BIT3 - -#define MCH_ESMRAMC 0x9E -#define MCH_ESMRAMC_H_SMRAME BIT7 -#define MCH_ESMRAMC_E_SMERR BIT6 -#define MCH_ESMRAMC_SM_CACHE BIT5 -#define MCH_ESMRAMC_SM_L1 BIT4 -#define MCH_ESMRAMC_SM_L2 BIT3 -#define MCH_ESMRAMC_TSEG_EXT (BIT2 | BIT1) -#define MCH_ESMRAMC_TSEG_8MB BIT2 -#define MCH_ESMRAMC_TSEG_2MB BIT1 -#define MCH_ESMRAMC_TSEG_1MB 0 -#define MCH_ESMRAMC_TSEG_MASK (BIT2 | BIT1) -#define MCH_ESMRAMC_T_EN BIT0 - -#define MCH_GBSM 0xA4 -#define MCH_GBSM_MB_SHIFT 20 - -#define MCH_BGSM 0xA8 -#define MCH_BGSM_MB_SHIFT 20 - -#define MCH_TSEGMB 0xAC -#define MCH_TSEGMB_MB_SHIFT 20 - -#define MCH_TOLUD 0xB0 -#define MCH_TOLUD_MB_SHIFT 4 +#define MCH_EXT_TSEG_MB 0x50 +#define MCH_EXT_TSEG_MB_QUERY 0xFFFF + +#define MCH_GGC 0x52 +#define MCH_GGC_IVD BIT1 + +#define MCH_PCIEXBAR_LOW 0x60 +#define MCH_PCIEXBAR_LOWMASK 0x0FFFFFFF +#define MCH_PCIEXBAR_BUS_FF 0 +#define MCH_PCIEXBAR_EN BIT0 + +#define MCH_PCIEXBAR_HIGH 0x64 +#define MCH_PCIEXBAR_HIGHMASK 0xFFFFFFF0 + +#define MCH_PAM0 0x90 +#define MCH_PAM1 0x91 +#define MCH_PAM2 0x92 +#define MCH_PAM3 0x93 +#define MCH_PAM4 0x94 +#define MCH_PAM5 0x95 +#define MCH_PAM6 0x96 + +#define MCH_SMRAM 0x9D +#define MCH_SMRAM_D_LCK BIT4 +#define MCH_SMRAM_G_SMRAME BIT3 + +#define MCH_ESMRAMC 0x9E +#define MCH_ESMRAMC_H_SMRAME BIT7 +#define MCH_ESMRAMC_E_SMERR BIT6 +#define MCH_ESMRAMC_SM_CACHE BIT5 +#define MCH_ESMRAMC_SM_L1 BIT4 +#define MCH_ESMRAMC_SM_L2 BIT3 +#define MCH_ESMRAMC_TSEG_EXT (BIT2 | BIT1) +#define MCH_ESMRAMC_TSEG_8MB BIT2 +#define MCH_ESMRAMC_TSEG_2MB BIT1 +#define MCH_ESMRAMC_TSEG_1MB 0 +#define MCH_ESMRAMC_TSEG_MASK (BIT2 | BIT1) +#define MCH_ESMRAMC_T_EN BIT0 + +#define MCH_GBSM 0xA4 +#define MCH_GBSM_MB_SHIFT 20 + +#define MCH_BGSM 0xA8 +#define MCH_BGSM_MB_SHIFT 20 + +#define MCH_TSEGMB 0xAC +#define MCH_TSEGMB_MB_SHIFT 20 + +#define MCH_TOLUD 0xB0 +#define MCH_TOLUD_MB_SHIFT 4 =20 // // B/D/F/Type: 0/0x1f/0/PCI --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53535): https://edk2.groups.io/g/devel/message/53535 Mute This Topic: https://groups.io/mt/70252352/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53537+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53537+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1580334268529142.17697390344415; Wed, 29 Jan 2020 13:44:28 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id C1LcYY1788612xKaaa0nqYNr; Wed, 29 Jan 2020 13:44:27 -0800 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web09.594.1580334266926465901 for ; Wed, 29 Jan 2020 13:44:27 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-W3t-7iZdMNaIZsk4p_A46Q-1; Wed, 29 Jan 2020 16:44:21 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E92F107ACC9; Wed, 29 Jan 2020 21:44:20 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26BC95DA75; Wed, 29 Jan 2020 21:44:18 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen Subject: [edk2-devel] [PATCH v2 03/11] OvmfPkg/IndustryStandard: add MCH_DEFAULT_SMBASE* register macros Date: Wed, 29 Jan 2020 22:44:04 +0100 Message-Id: <20200129214412.2361-4-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: W3t-7iZdMNaIZsk4p_A46Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: bHMzG0uo5kjV4q5qiycSthK4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334267; bh=SgF8+SoucRYkIqQ26Djb6a/DWxWCfrE5G0eOYGfaZeQ=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=okb1UN62AgGvyUbOafLyFjg6dZnd1ui6Za0vL3CfpWF6ZVq0av2dXmx+k0WcBk7KMWx 5Z+zsULyXIg5bl9ZPVN6Py29GmcVI+i6iKKBQfM7X30YSSVrJQjLMJXOahOuolGsl9jq2 MX/qO0D9a0YoG7XfqOELmZrPkwN+/cLFqaA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In Intel datasheet 316966-002 (the "q35 spec"), Table 5-1 "DRAM Controller Register Address Map (D0:F0)" leaves the byte register at config space offset 0x9C unused. On QEMU's Q35 board, for detecting the "SMRAM at default SMBASE" feature, firmware is expected to write MCH_DEFAULT_SMBASE_QUERY (0xFF) to offset MCH_DEFAULT_SMBASE_CTL (0x9C), and read back the register. If the value is MCH_DEFAULT_SMBASE_IN_RAM (0x01), then the feature is available, and the range mentioned below is open (accessible to code running outside of SMM). Then, once firmware writes MCH_DEFAULT_SMBASE_LCK (0x02) to the register, the MCH_DEFAULT_SMBASE_SIZE (128KB) range at 0x3_0000 (SMM_DEFAULT_SMBASE) gets closed and locked down, and the register becomes read-only. The area is reopened, and the register becomes read/write, at platform reset. Add the above-listed macros to "Q35MchIch9.h". (There are some other unused offsets in Table 5-1; for example we had scavenged 0x50 for implementing the extended TSEG feature. 0x9C is the first byte-wide register standing in isolation after 0x50.) Cc: Ard Biesheuvel Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Jiewen Yao Reviewed-by: Ard Biesheuvel --- Notes: v2: - trim Cc list - pick up Jiewen's R-b OvmfPkg/Include/IndustryStandard/Q35MchIch9.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OvmfPkg/Include/IndustryStandard/Q35MchIch9.h b/OvmfPkg/Includ= e/IndustryStandard/Q35MchIch9.h index 80379c223a1c..cb705fee92ca 100644 --- a/OvmfPkg/Include/IndustryStandard/Q35MchIch9.h +++ b/OvmfPkg/Include/IndustryStandard/Q35MchIch9.h @@ -49,6 +49,12 @@ #define MCH_PAM5 0x95 #define MCH_PAM6 0x96 =20 +#define MCH_DEFAULT_SMBASE_CTL 0x9C +#define MCH_DEFAULT_SMBASE_QUERY 0xFF +#define MCH_DEFAULT_SMBASE_IN_RAM 0x01 +#define MCH_DEFAULT_SMBASE_LCK 0x02 +#define MCH_DEFAULT_SMBASE_SIZE SIZE_128KB + #define MCH_SMRAM 0x9D #define MCH_SMRAM_D_LCK BIT4 #define MCH_SMRAM_G_SMRAME BIT3 --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53537): https://edk2.groups.io/g/devel/message/53537 Mute This Topic: https://groups.io/mt/70252354/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53536+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53536+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1580334267971951.0929866649313; Wed, 29 Jan 2020 13:44:27 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id R6TtYY1788612xVtdQ7tYxtL; Wed, 29 Jan 2020 13:44:27 -0800 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web11.612.1580334265699648796 for ; Wed, 29 Jan 2020 13:44:25 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-387-UX0SOLB4NqqGR-R7iTCR_Q-1; Wed, 29 Jan 2020 16:44:22 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66D3F18A6EC0; Wed, 29 Jan 2020 21:44:21 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 736535DA75; Wed, 29 Jan 2020 21:44:20 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen Subject: [edk2-devel] [PATCH v2 04/11] OvmfPkg/PlatformPei: factor out Q35BoardVerification() Date: Wed, 29 Jan 2020 22:44:05 +0100 Message-Id: <20200129214412.2361-5-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: UX0SOLB4NqqGR-R7iTCR_Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: r1xvGBp7FRQd9WhJ2K7Iq7nRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334267; bh=eOVx3JuPgmYMOtHfGhyCp8XNTcAfieQU/AJlxlJzt7U=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=l9dK60cziDoamQUhp7Xg2uZOXfV2MyRhDekiY+VMMDlbt7qoS8hmtTo4icZAnwBtY5z s9p+kIvZ1TvAOrrLQ5Exvjc69g6+FTbwK2/iTcUWNXtwDSQqmT0bKsafDYfbIAZjWbbme JJ9qYYGDB3hcaw+qYvddiCNE56qTBaBeMgk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Before adding another SMM-related, and therefore Q35-only, dynamically detectable feature, extract the current board type check from Q35TsegMbytesInitialization() to a standalone function. Cc: Ard Biesheuvel Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Jiewen Yao Reviewed-by: Ard Biesheuvel --- Notes: v2: - trim Cc list - pick up Jiewen's R-b OvmfPkg/PlatformPei/MemDetect.c | 13 +---------- OvmfPkg/PlatformPei/Platform.c | 23 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index d451989f31c9..58b171fba1c8 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -53,18 +53,7 @@ Q35TsegMbytesInitialization ( UINT16 ExtendedTsegMbytes; RETURN_STATUS PcdStatus; =20 - if (mHostBridgeDevId !=3D INTEL_Q35_MCH_DEVICE_ID) { - DEBUG (( - DEBUG_ERROR, - "%a: no TSEG (SMRAM) on host bridge DID=3D0x%04x; " - "only DID=3D0x%04x (Q35) is supported\n", - __FUNCTION__, - mHostBridgeDevId, - INTEL_Q35_MCH_DEVICE_ID - )); - ASSERT (FALSE); - CpuDeadLoop (); - } + ASSERT (mHostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID); =20 // // Check if QEMU offers an extended TSEG. diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index e5e8581752b5..510d6d7477ec 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -566,6 +566,28 @@ S3Verification ( } =20 =20 +VOID +Q35BoardVerification ( + VOID + ) +{ + if (mHostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID) { + return; + } + + DEBUG (( + DEBUG_ERROR, + "%a: no TSEG (SMRAM) on host bridge DID=3D0x%04x; " + "only DID=3D0x%04x (Q35) is supported\n", + __FUNCTION__, + mHostBridgeDevId, + INTEL_Q35_MCH_DEVICE_ID + )); + ASSERT (FALSE); + CpuDeadLoop (); +} + + /** Fetch the boot CPU count and the possible CPU count from QEMU, and expose them to UefiCpuPkg modules. Set the mMaxCpuCount variable. @@ -768,6 +790,7 @@ InitializePlatform ( MaxCpuCountInitialization (); =20 if (FeaturePcdGet (PcdSmmSmramRequire)) { + Q35BoardVerification (); Q35TsegMbytesInitialization (); } =20 --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53536): https://edk2.groups.io/g/devel/message/53536 Mute This Topic: https://groups.io/mt/70252353/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53538+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53538+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1580334269726979.0024848042458; Wed, 29 Jan 2020 13:44:29 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id UpC1YY1788612x8ynMRZ8zYm; Wed, 29 Jan 2020 13:44:28 -0800 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web10.615.1580334268133561698 for ; Wed, 29 Jan 2020 13:44:28 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-159-8b7_X8o0M8KNzCzAcPDiAQ-1; Wed, 29 Jan 2020 16:44:23 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0A2A18A6EC1; Wed, 29 Jan 2020 21:44:22 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC9315DA75; Wed, 29 Jan 2020 21:44:21 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen Subject: [edk2-devel] [PATCH v2 05/11] OvmfPkg/PlatformPei: detect SMRAM at default SMBASE (skeleton) Date: Wed, 29 Jan 2020 22:44:06 +0100 Message-Id: <20200129214412.2361-6-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 8b7_X8o0M8KNzCzAcPDiAQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: SMl4c0gowmBH1Q2Laia9c7Ogx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334268; bh=WexKzO4leZE6WKMxGE5XnPim8d1PfuAx/eU3S36Uzd4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=cfBxT3+/oYmuO+cUa2LWHAqWTYolvF0KFsYMtAYRPEaiGr4xWyGunnkIHN0iCOvi6xO /KkksQMaskk8kZNnV1HUOqn0bYV+pNlMyPJqpTGEmZ6IaMYHmCUCa7dzc1C/8EusI4GsP pBQ96iIj6dmFKSu+80gJ6X2Rszr9V45JpBk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Introduce the Q35SmramAtDefaultSmbaseInitialization() function for detecting the "SMRAM at default SMBASE" feature. For now, the function is only a skeleton, so that we can gradually build upon the result while the result is hard-coded as FALSE. The actual detection will occur in a later patch. Cc: Ard Biesheuvel Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Jiewen Yao Reviewed-by: Ard Biesheuvel --- Notes: v2: - trim Cc list - pick up Jiewen's R-b OvmfPkg/PlatformPei/PlatformPei.inf | 1 + OvmfPkg/PlatformPei/Platform.h | 7 +++++++ OvmfPkg/PlatformPei/MemDetect.c | 18 ++++++++++++++++++ OvmfPkg/PlatformPei/Platform.c | 1 + 4 files changed, 27 insertions(+) diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index 30eaebdfae63..25229618ed13 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -84,6 +84,7 @@ [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes + gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h index 2f3cebcd3a6a..43f20f067f22 100644 --- a/OvmfPkg/PlatformPei/Platform.h +++ b/OvmfPkg/PlatformPei/Platform.h @@ -52,6 +52,11 @@ Q35TsegMbytesInitialization ( VOID ); =20 +VOID +Q35SmramAtDefaultSmbaseInitialization ( + VOID + ); + EFI_STATUS PublishPeiMemory ( VOID @@ -119,6 +124,8 @@ extern UINT32 mMaxCpuCount; =20 extern UINT16 mHostBridgeDevId; =20 +extern BOOLEAN mQ35SmramAtDefaultSmbase; + extern UINT32 mQemuUc32Base; =20 #endif // _PLATFORM_PEI_H_INCLUDED_ diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 58b171fba1c8..2bc1c46dffc2 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -43,6 +43,8 @@ STATIC UINT32 mS3AcpiReservedMemorySize; =20 STATIC UINT16 mQ35TsegMbytes; =20 +BOOLEAN mQ35SmramAtDefaultSmbase; + UINT32 mQemuUc32Base; =20 VOID @@ -90,6 +92,22 @@ Q35TsegMbytesInitialization ( } =20 =20 +VOID +Q35SmramAtDefaultSmbaseInitialization ( + VOID + ) +{ + RETURN_STATUS PcdStatus; + + ASSERT (mHostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID); + + mQ35SmramAtDefaultSmbase =3D FALSE; + PcdStatus =3D PcdSetBoolS (PcdQ35SmramAtDefaultSmbase, + mQ35SmramAtDefaultSmbase); + ASSERT_RETURN_ERROR (PcdStatus); +} + + VOID QemuUc32BaseInitialization ( VOID diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 510d6d7477ec..473af102783a 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -792,6 +792,7 @@ InitializePlatform ( if (FeaturePcdGet (PcdSmmSmramRequire)) { Q35BoardVerification (); Q35TsegMbytesInitialization (); + Q35SmramAtDefaultSmbaseInitialization (); } =20 PublishPeiMemory (); --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53538): https://edk2.groups.io/g/devel/message/53538 Mute This Topic: https://groups.io/mt/70252356/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53543+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53543+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 158033427757588.46112766589329; Wed, 29 Jan 2020 13:44:37 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id drZqYY1788612xrW3dblXiWa; Wed, 29 Jan 2020 13:44:36 -0800 X-Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web09.602.1580334275787020009 for ; Wed, 29 Jan 2020 13:44:35 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-73-0NSbPSUeMbuUfoxcZ-LudA-1; Wed, 29 Jan 2020 16:44:26 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 04103800D4C; Wed, 29 Jan 2020 21:44:25 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10C8D5DA75; Wed, 29 Jan 2020 21:44:22 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen Subject: [edk2-devel] [PATCH v2 06/11] OvmfPkg/PlatformPei: assert there's no permanent PEI RAM at default SMBASE Date: Wed, 29 Jan 2020 22:44:07 +0100 Message-Id: <20200129214412.2361-7-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 0NSbPSUeMbuUfoxcZ-LudA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: Wte54Jy6yzM0zvWTBsEEKTGEx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334276; bh=5UBWc3Fm5FibDRYkAPbXYUarIJ6gZGm0KALB8MDNy9M=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=AF9Sv5lwGd8uFF1tK7XdUXfOz9oObFhD9rPPmRR9jvqcr50mnl9v1rUcW6uAJR/USLb z83eL7o6NJZNbYnz+nknec7UCbO6u23OztJT4OFoB+Vfun1vVforFf9BMyFo3Dd7skzHK 9kxeGzOvg6J8ZxByoVGCUar1ypvZPanjF+c= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The permanent PEI RAM that is published on the normal boot path starts strictly above MEMFD_BASE_ADDRESS (8 MB -- see the FDF files), regardless of whether PEI decompression will be necessary on S3 resume due to SMM_REQUIRE. Therefore the normal boot permanent PEI RAM never overlaps with the SMRAM at the default SMBASE (192 KB). The S3 resume permanent PEI RAM is strictly above the normal boot one. Therefore the no-overlap statement holds true on the S3 resume path as well. Assert the no-overlap condition commonly for both boot paths in PublishPeiMemory(). Cc: Ard Biesheuvel Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Jiewen Yao Reviewed-by: Ard Biesheuvel --- Notes: v2: - trim Cc list - pick up Jiewen's R-b OvmfPkg/PlatformPei/MemDetect.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 2bc1c46dffc2..4879ee87b797 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -17,6 +17,7 @@ Module Name: #include #include #include +#include =20 // // The Library classes this module consumes @@ -626,6 +627,15 @@ PublishPeiMemory ( } } =20 + // + // MEMFD_BASE_ADDRESS separates the SMRAM at the default SMBASE from the + // normal boot permanent PEI RAM. Regarding the S3 boot path, the S3 + // permanent PEI RAM is located even higher. + // + if (FeaturePcdGet (PcdSmmSmramRequire) && mQ35SmramAtDefaultSmbase) { + ASSERT (SMM_DEFAULT_SMBASE + MCH_DEFAULT_SMBASE_SIZE <=3D MemoryBase); + } + // // Publish this memory to the PEI Core // --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53543): https://edk2.groups.io/g/devel/message/53543 Mute This Topic: https://groups.io/mt/70252362/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53539+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53539+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1580334273563200.48672371220425; Wed, 29 Jan 2020 13:44:33 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id mLBhYY1788612xwqsjis8yHS; Wed, 29 Jan 2020 13:44:32 -0800 X-Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web12.604.1580334271962940484 for ; Wed, 29 Jan 2020 13:44:32 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-59-LYxUjlu_PB6yWebQak3rlA-1; Wed, 29 Jan 2020 16:44:27 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4AAFE107ACC5; Wed, 29 Jan 2020 21:44:26 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5997B5DA75; Wed, 29 Jan 2020 21:44:25 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen Subject: [edk2-devel] [PATCH v2 07/11] OvmfPkg/PlatformPei: reserve the SMRAM at the default SMBASE, if it exists Date: Wed, 29 Jan 2020 22:44:08 +0100 Message-Id: <20200129214412.2361-8-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: LYxUjlu_PB6yWebQak3rlA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: t5zncjQ1iboANB6vy0bW6XoZx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334272; bh=2ISmvVOk7qyuzG+svGsU83rsd2aw9jGdq9cYs3a6RY0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=FJxAwskL2slz0C9BC5qvWOP6l/D9cNWUdro1gmnUa69Uw8o0MuYmSgecORWwvxIDSaH CooC6o6Ztc6LYUemw9h01SY6lEGvmkX61YneLt3bb+9xpz9+8zeYdnUEf0KzYYBJxqK0B MPuBLHppdxGfc9FWBWWN6psorgoNeCEouDQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The 128KB SMRAM at the default SMBASE will be used for protecting the initial SMI handler for hot-plugged VCPUs. After platform reset, the SMRAM in question is open (and looks just like RAM). When BDS signals EFI_DXE_MM_READY_TO_LOCK_PROTOCOL (and so TSEG is locked down), we're going to lock the SMRAM at the default SMBASE too. For this, we have to reserve said SMRAM area as early as possible, from components in PEI, DXE, and OS runtime. * QemuInitializeRam() currently produces a single resource descriptor HOB, for exposing the system RAM available under 1GB. This occurs during both normal boot and S3 resume identically (the latter only for the sake of CpuMpPei borrowing low RAM for the AP startup vector). But, the SMRAM at the default SMBASE falls in the middle of the current system RAM HOB. Split the HOB, and cover the SMRAM with a reserved memory HOB in the middle. CpuMpPei (via MpInitLib) skips reserved memory HOBs. * InitializeRamRegions() is responsible for producing memory allocation HOBs, carving out parts of the resource descriptor HOBs produced in QemuInitializeRam(). Allocate the above-introduced reserved memory region in full, similarly to how we treat TSEG, so that DXE and the OS avoid the locked SMRAM (black hole) in this area. (Note that these allocations only occur on the normal boot path, as they matter for the UEFI memory map, which cannot be changed during S3 resume.) Cc: Ard Biesheuvel Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Jiewen Yao Reviewed-by: Ard Biesheuvel --- Notes: v2: - trim Cc list - pick up Jiewen's R-b OvmfPkg/PlatformPei/MemDetect.c | 37 ++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 4879ee87b797..8fdc9c2ed7c9 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -646,6 +646,28 @@ PublishPeiMemory ( } =20 =20 +STATIC +VOID +QemuInitializeRamBelow1gb ( + VOID + ) +{ + if (FeaturePcdGet (PcdSmmSmramRequire) && mQ35SmramAtDefaultSmbase) { + AddMemoryRangeHob (0, SMM_DEFAULT_SMBASE); + AddReservedMemoryBaseSizeHob (SMM_DEFAULT_SMBASE, MCH_DEFAULT_SMBASE_S= IZE, + TRUE /* Cacheable */); + STATIC_ASSERT ( + SMM_DEFAULT_SMBASE + MCH_DEFAULT_SMBASE_SIZE < BASE_512KB + BASE_128= KB, + "end of SMRAM at default SMBASE ends at, or exceeds, 640KB" + ); + AddMemoryRangeHob (SMM_DEFAULT_SMBASE + MCH_DEFAULT_SMBASE_SIZE, + BASE_512KB + BASE_128KB); + } else { + AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); + } +} + + /** Peform Memory Detection for QEMU / KVM =20 @@ -690,12 +712,12 @@ QemuInitializeRam ( // allocation HOBs, and to honor preexistent memory allocation HOBs wh= en // looking for an area to borrow. // - AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); + QemuInitializeRamBelow1gb (); } else { // // Create memory HOBs // - AddMemoryRangeHob (0, BASE_512KB + BASE_128KB); + QemuInitializeRamBelow1gb (); =20 if (FeaturePcdGet (PcdSmmSmramRequire)) { UINT32 TsegSize; @@ -861,6 +883,17 @@ InitializeRamRegions ( TsegSize, EfiReservedMemoryType ); + // + // Similarly, allocate away the (already reserved) SMRAM at the defa= ult + // SMBASE, if it exists. + // + if (mQ35SmramAtDefaultSmbase) { + BuildMemoryAllocationHob ( + SMM_DEFAULT_SMBASE, + MCH_DEFAULT_SMBASE_SIZE, + EfiReservedMemoryType + ); + } } } } --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53539): https://edk2.groups.io/g/devel/message/53539 Mute This Topic: https://groups.io/mt/70252358/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53541+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53541+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1580334275189457.8743181605686; Wed, 29 Jan 2020 13:44:35 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id GkquYY1788612xOPgiYp1pWW; Wed, 29 Jan 2020 13:44:34 -0800 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web09.600.1580334273656485248 for ; Wed, 29 Jan 2020 13:44:33 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-3ulWbvtKPpCgYUu3Z6aL9Q-1; Wed, 29 Jan 2020 16:44:28 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 99361801E67; Wed, 29 Jan 2020 21:44:27 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id A30795DA75; Wed, 29 Jan 2020 21:44:26 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen Subject: [edk2-devel] [PATCH v2 08/11] OvmfPkg/SEV: don't manage the lifecycle of the SMRAM at the default SMBASE Date: Wed, 29 Jan 2020 22:44:09 +0100 Message-Id: <20200129214412.2361-9-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 3ulWbvtKPpCgYUu3Z6aL9Q-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: qvsdfiMGFsYmPkCSMf8Uj2Uzx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334274; bh=TsXZnGKcwvGhEs7+an3G1MI7EIdfWGuH7KvbVRC4JiA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=iqxBBh2A8QjMkhpKOWY3cpNrkNE/2yFOmBoBJnuRQSeXR/uH00G23iuu/SKhuweoMGf +ZkGWE03wsyFXyY0Eo2G5DHJygcNST2zoMrHbfRowJJzmPPh0YdrxBbapqrS2b16we5dx YhorrANQincuOcjD539GFCHaLexfmlEL07I= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" When OVMF runs in a SEV guest, the initial SMM Save State Map is (1) allocated as EfiBootServicesData type memory in OvmfPkg/PlatformPei, function AmdSevInitialize(), for preventing unintended information sharing with the hypervisor; (2) decrypted in AmdSevDxe; (3) re-encrypted in OvmfPkg/Library/SmmCpuFeaturesLib, function SmmCpuFeaturesSmmRelocationComplete(), which is called by PiSmmCpuDxeSmm right after initial SMBASE relocation; (4) released to DXE at the same location. The SMRAM at the default SMBASE is a superset of the initial Save State Map. The reserved memory allocation in InitializeRamRegions(), from the previous patch, must override the allocating and freeing in (1) and (4), respectively. (Note: the decrypting and re-encrypting in (2) and (3) are unaffected.) In AmdSevInitialize(), only assert the containment of the initial Save State Map, in the larger area already allocated by InitializeRamRegions(). In SmmCpuFeaturesSmmRelocationComplete(), preserve the allocation of the initial Save State Map into OS runtime, as part of the allocation done by InitializeRamRegions(). Only assert containment. These changes only affect the normal boot path (the UEFI memory map is untouched during S3 resume). Cc: Ard Biesheuvel Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Jiewen Yao Reviewed-by: Ard Biesheuvel --- Notes: v2: - trim Cc list - pick up Jiewen's R-b OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 4 ++++ OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 21 +++++++++++++= ++-- OvmfPkg/PlatformPei/AmdSev.c | 24 +++++++++++++= +++---- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/Ovmf= Pkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index dd316f2b1bd8..97a10afb6e27 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -30,5 +30,9 @@ [LibraryClasses] BaseMemoryLib DebugLib MemEncryptSevLib + PcdLib SmmServicesTableLib UefiBootServicesTableLib + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 0bfdeda78d33..7ef7ed98342e 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -6,14 +6,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 +#include #include #include #include #include +#include #include #include #include #include +#include #include =20 // @@ -215,8 +218,22 @@ SmmCpuFeaturesSmmRelocationComplete ( =20 ZeroMem ((VOID *)MapPagesBase, EFI_PAGES_TO_SIZE (MapPagesCount)); =20 - Status =3D gBS->FreePages (MapPagesBase, MapPagesCount); - ASSERT_EFI_ERROR (Status); + if (PcdGetBool (PcdQ35SmramAtDefaultSmbase)) { + // + // The initial SMRAM Save State Map has been covered as part of a larg= er + // reserved memory allocation in PlatformPei's InitializeRamRegions().= That + // allocation is supposed to survive into OS runtime; we must not rele= ase + // any part of it. Only re-assert the containment here. + // + ASSERT (SMM_DEFAULT_SMBASE <=3D MapPagesBase); + ASSERT ( + (MapPagesBase + EFI_PAGES_TO_SIZE (MapPagesCount) <=3D + SMM_DEFAULT_SMBASE + MCH_DEFAULT_SMBASE_SIZE) + ); + } else { + Status =3D gBS->FreePages (MapPagesBase, MapPagesCount); + ASSERT_EFI_ERROR (Status); + } } =20 /** diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c index 2ae8126ccf8a..e484f4b311fe 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -9,6 +9,7 @@ // // The package level header files this module uses // +#include #include #include #include @@ -16,6 +17,7 @@ #include #include #include +#include =20 #include "Platform.h" =20 @@ -83,10 +85,22 @@ AmdSevInitialize ( ); ASSERT_RETURN_ERROR (LocateMapStatus); =20 - BuildMemoryAllocationHob ( - MapPagesBase, // BaseAddress - EFI_PAGES_TO_SIZE (MapPagesCount), // Length - EfiBootServicesData // MemoryType - ); + if (mQ35SmramAtDefaultSmbase) { + // + // The initial SMRAM Save State Map has been covered as part of a la= rger + // reserved memory allocation in InitializeRamRegions(). + // + ASSERT (SMM_DEFAULT_SMBASE <=3D MapPagesBase); + ASSERT ( + (MapPagesBase + EFI_PAGES_TO_SIZE (MapPagesCount) <=3D + SMM_DEFAULT_SMBASE + MCH_DEFAULT_SMBASE_SIZE) + ); + } else { + BuildMemoryAllocationHob ( + MapPagesBase, // BaseAddress + EFI_PAGES_TO_SIZE (MapPagesCount), // Length + EfiBootServicesData // MemoryType + ); + } } } --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53541): https://edk2.groups.io/g/devel/message/53541 Mute This Topic: https://groups.io/mt/70252360/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53540+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53540+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 15803342747852.917113599570257; Wed, 29 Jan 2020 13:44:34 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id I5qdYY1788612xIYbi8OKDfd; Wed, 29 Jan 2020 13:44:33 -0800 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web11.617.1580334272846669256 for ; Wed, 29 Jan 2020 13:44:33 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-192--UM4TPm8PEiA_IhY3VDccw-1; Wed, 29 Jan 2020 16:44:29 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DE08F1007268; Wed, 29 Jan 2020 21:44:28 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB7115DA75; Wed, 29 Jan 2020 21:44:27 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen Subject: [edk2-devel] [PATCH v2 09/11] OvmfPkg/SmmAccess: close and lock SMRAM at default SMBASE Date: Wed, 29 Jan 2020 22:44:10 +0100 Message-Id: <20200129214412.2361-10-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: -UM4TPm8PEiA_IhY3VDccw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: 2stSm1eV3xwYRAVfVWZBVy6Wx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334273; bh=eoDVMmcXau4Wu5PWYEUemPRaPZAiVPqjB1sPiQCIYbc=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=sP8myCQrzvshHWHtc9odoeLj5rQfrgZw3R5NCFaGEUTPS5sA3PdwibJ2o3/dLJGn4f2 bC3JZ5sxvT3laTjofgumDJ+j6aruzNaOjHf8FnVXl22MRA5aKX/V5aUiQrLULw0qeVztm eP+af/HX1FWgflbq/Xch20QaExFfSkAFLL8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" During normal boot, when EFI_DXE_SMM_READY_TO_LOCK_PROTOCOL is installed by platform BDS, the SMM IPL locks SMRAM (TSEG) through EFI_SMM_ACCESS2_PROTOCOL.Lock(). See SmmIplReadyToLockEventNotify() in "MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c". During S3 resume, S3Resume2Pei locks SMRAM (TSEG) through PEI_SMM_ACCESS_PPI.Lock(), before executing the boot script. See S3ResumeExecuteBootScript() in "UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c". Those are precisely the places where the SMRAM at the default SMBASE should be locked too. Add such an action to SmramAccessLock(). Notes: - The SMRAM at the default SMBASE doesn't support the "closed and unlocked" state (and so it can't be closed without locking it, and it cannot be opened after closing it). - The SMRAM at the default SMBASE isn't (and shouldn't) be exposed with another EFI_SMRAM_DESCRIPTOR in the GetCapabilities() members of EFI_SMM_ACCESS2_PROTOCOL / PEI_SMM_ACCESS_PPI. That's because the SMRAM in question is not "general purpose"; it's only QEMU's solution to protect the initial SMI handler from the OS, when a VCPU is hot-plugged. Consequently, the state of the SMRAM at the default SMBASE is not reflected in the "OpenState" / "LockState" fields of the protocol and PPI. - An alternative to extending SmramAccessLock() would be to register an EFI_DXE_SMM_READY_TO_LOCK_PROTOCOL notify in SmmAccess2Dxe (for locking at normal boot), and an EDKII_S3_SMM_INIT_DONE_GUID PPI notify in SmmAccessPei (for locking at S3 resume). Cc: Ard Biesheuvel Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Jiewen Yao Reviewed-by: Ard Biesheuvel --- Notes: v2: - trim Cc list - pick up Jiewen's R-b OvmfPkg/SmmAccess/SmmAccess2Dxe.inf | 1 + OvmfPkg/SmmAccess/SmmAccessPei.inf | 1 + OvmfPkg/SmmAccess/SmramInternal.h | 8 +++++++ OvmfPkg/SmmAccess/SmmAccess2Dxe.c | 7 ++++++ OvmfPkg/SmmAccess/SmmAccessPei.c | 6 +++++ OvmfPkg/SmmAccess/SmramInternal.c | 25 ++++++++++++++++++++ 6 files changed, 48 insertions(+) diff --git a/OvmfPkg/SmmAccess/SmmAccess2Dxe.inf b/OvmfPkg/SmmAccess/SmmAcc= ess2Dxe.inf index 7ced6b4e7ff4..d86381d0fbe2 100644 --- a/OvmfPkg/SmmAccess/SmmAccess2Dxe.inf +++ b/OvmfPkg/SmmAccess/SmmAccess2Dxe.inf @@ -49,6 +49,7 @@ [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire =20 [Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes =20 [Depex] diff --git a/OvmfPkg/SmmAccess/SmmAccessPei.inf b/OvmfPkg/SmmAccess/SmmAcce= ssPei.inf index d73a029cc790..1698c4ce6c92 100644 --- a/OvmfPkg/SmmAccess/SmmAccessPei.inf +++ b/OvmfPkg/SmmAccess/SmmAccessPei.inf @@ -54,6 +54,7 @@ [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire =20 [Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes =20 [Ppis] diff --git a/OvmfPkg/SmmAccess/SmramInternal.h b/OvmfPkg/SmmAccess/SmramInt= ernal.h index 74d962b4ecae..a4d8827adfe4 100644 --- a/OvmfPkg/SmmAccess/SmramInternal.h +++ b/OvmfPkg/SmmAccess/SmramInternal.h @@ -38,6 +38,14 @@ InitQ35TsegMbytes ( VOID ); =20 +/** + Save PcdQ35SmramAtDefaultSmbase into mQ35SmramAtDefaultSmbase. +**/ +VOID +InitQ35SmramAtDefaultSmbase ( + VOID + ); + /** Read the MCH_SMRAM and ESMRAMC registers, and update the LockState and OpenState fields in the PEI_SMM_ACCESS_PPI / EFI_SMM_ACCESS2_PROTOCOL ob= ject, diff --git a/OvmfPkg/SmmAccess/SmmAccess2Dxe.c b/OvmfPkg/SmmAccess/SmmAcces= s2Dxe.c index e098f6f15f77..3691a6cd1f10 100644 --- a/OvmfPkg/SmmAccess/SmmAccess2Dxe.c +++ b/OvmfPkg/SmmAccess/SmmAccess2Dxe.c @@ -145,6 +145,13 @@ SmmAccess2DxeEntryPoint ( =20 InitQ35TsegMbytes (); GetStates (&mAccess2.LockState, &mAccess2.OpenState); + + // + // SmramAccessLock() depends on "mQ35SmramAtDefaultSmbase"; init the lat= ter + // just before exposing the former via EFI_SMM_ACCESS2_PROTOCOL.Lock(). + // + InitQ35SmramAtDefaultSmbase (); + return gBS->InstallMultipleProtocolInterfaces (&ImageHandle, &gEfiSmmAccess2ProtocolGuid, &mAccess2, NULL); diff --git a/OvmfPkg/SmmAccess/SmmAccessPei.c b/OvmfPkg/SmmAccess/SmmAccess= Pei.c index d67850651c58..c8bbc17e907a 100644 --- a/OvmfPkg/SmmAccess/SmmAccessPei.c +++ b/OvmfPkg/SmmAccess/SmmAccessPei.c @@ -372,6 +372,12 @@ SmmAccessPeiEntryPoint ( CopyMem (GuidHob, &SmramMap[DescIdxSmmS3ResumeState], sizeof SmramMap[DescIdxSmmS3ResumeState]); =20 + // + // SmramAccessLock() depends on "mQ35SmramAtDefaultSmbase"; init the lat= ter + // just before exposing the former via PEI_SMM_ACCESS_PPI.Lock(). + // + InitQ35SmramAtDefaultSmbase (); + // // We're done. The next step should succeed, but even if it fails, we ca= n't // roll back the above BuildGuidHob() allocation, because PEI doesn't su= pport diff --git a/OvmfPkg/SmmAccess/SmramInternal.c b/OvmfPkg/SmmAccess/SmramInt= ernal.c index 09657d0f9b0f..0b07dc667b3f 100644 --- a/OvmfPkg/SmmAccess/SmramInternal.c +++ b/OvmfPkg/SmmAccess/SmramInternal.c @@ -21,6 +21,12 @@ // UINT16 mQ35TsegMbytes; =20 +// +// The value of PcdQ35SmramAtDefaultSmbase is saved into this variable at +// module startup. +// +STATIC BOOLEAN mQ35SmramAtDefaultSmbase; + /** Save PcdQ35TsegMbytes into mQ35TsegMbytes. **/ @@ -32,6 +38,17 @@ InitQ35TsegMbytes ( mQ35TsegMbytes =3D PcdGet16 (PcdQ35TsegMbytes); } =20 +/** + Save PcdQ35SmramAtDefaultSmbase into mQ35SmramAtDefaultSmbase. +**/ +VOID +InitQ35SmramAtDefaultSmbase ( + VOID + ) +{ + mQ35SmramAtDefaultSmbase =3D PcdGetBool (PcdQ35SmramAtDefaultSmbase); +} + /** Read the MCH_SMRAM and ESMRAMC registers, and update the LockState and OpenState fields in the PEI_SMM_ACCESS_PPI / EFI_SMM_ACCESS2_PROTOCOL ob= ject, @@ -125,6 +142,14 @@ SmramAccessLock ( PciOr8 (DRAMC_REGISTER_Q35 (MCH_ESMRAMC), MCH_ESMRAMC_T_EN); PciOr8 (DRAMC_REGISTER_Q35 (MCH_SMRAM), MCH_SMRAM_D_LCK); =20 + // + // Close & lock the SMRAM at the default SMBASE, if it exists. + // + if (mQ35SmramAtDefaultSmbase) { + PciWrite8 (DRAMC_REGISTER_Q35 (MCH_DEFAULT_SMBASE_CTL), + MCH_DEFAULT_SMBASE_LCK); + } + GetStates (LockState, OpenState); if (*OpenState || !*LockState) { return EFI_DEVICE_ERROR; --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53540): https://edk2.groups.io/g/devel/message/53540 Mute This Topic: https://groups.io/mt/70252359/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53542+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53542+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 15803342773552.3411127545429053; Wed, 29 Jan 2020 13:44:37 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0jyZYY1788612xl7rMg3xS1N; Wed, 29 Jan 2020 13:44:36 -0800 X-Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web11.619.1580334275260495113 for ; Wed, 29 Jan 2020 13:44:35 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-367-RaKMtWSzOym6kFxiVZ7YrQ-1; Wed, 29 Jan 2020 16:44:32 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BDC008010CB; Wed, 29 Jan 2020 21:44:30 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 405B95DA75; Wed, 29 Jan 2020 21:44:29 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Anthony Perard , Ard Biesheuvel , Jiewen Yao , Jordan Justen , Julien Grall Subject: [edk2-devel] [PATCH v2 10/11] OvmfPkg: introduce PcdCsmEnable feature flag Date: Wed, 29 Jan 2020 22:44:11 +0100 Message-Id: <20200129214412.2361-11-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: RaKMtWSzOym6kFxiVZ7YrQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: i23lhwXmmSimIrm5c7IBALMYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334276; bh=VEmx9nzA7aa9sPz/It/x2a3ZkKK363Mz+XT2cBnXAo0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Sal3WvIeh8lnkHGGh/7ZybSzmECNg9fUY8dFF5yDWS/G+HVeXu9S/UU46trPSs+OV4K lE98cXo+YX+qL+69qdu8Y/qPILTh+okxDRXS8+/l/WdQ6Yzc7WVP1fbMDJlAdQBxehRBz pqgfDTeSiHagIO6et3xspHgKSWjG9d6KGJE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In the DXE phase and later, it is possible for a module to dynamically determine whether a CSM is enabled. An example can be seen in commit 855743f71774 ("OvmfPkg: prevent 64-bit MMIO BAR degradation if there is no CSM", 2016-05-25). SEC and PEI phase modules cannot check the Legacy BIOS Protocol however. For their sake, introduce a new feature PCD that simply reflects the CSM_ENABLE build flag. Cc: Anthony Perard Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Julien Grall Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel --- Notes: v2: - new patch OvmfPkg/OvmfPkg.dec | 5 +++++ OvmfPkg/OvmfPkgIa32.dsc | 3 +++ OvmfPkg/OvmfPkgIa32X64.dsc | 3 +++ OvmfPkg/OvmfPkgX64.dsc | 3 +++ OvmfPkg/OvmfXen.dsc | 3 +++ 5 files changed, 17 insertions(+) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 57034c784f88..4c5b6511cb97 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -276,3 +276,8 @@ [PcdsFeatureFlag] # runtime OS from tampering with firmware structures (special memory ra= nges # used by OVMF, the varstore pflash chip, LockBox etc). gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|FALSE|BOOLEAN|0x1e + + ## Informs modules (including pre-DXE-phase modules) whether the platform + # firmware contains a CSM (Compatibility Support Module). + # + gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|FALSE|BOOLEAN|0x35 diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 43ff51933609..19728f20b34e 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -428,6 +428,9 @@ [PcdsFeatureFlag] gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE +!ifdef $(CSM_ENABLE) + gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE +!endif !if $(SMM_REQUIRE) =3D=3D TRUE gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 5b3e217e9220..3c0c229e3a72 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -433,6 +433,9 @@ [PcdsFeatureFlag] gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE +!ifdef $(CSM_ENABLE) + gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE +!endif !if $(SMM_REQUIRE) =3D=3D TRUE gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index a378d0a449aa..f6c1d8d228c6 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -433,6 +433,9 @@ [PcdsFeatureFlag] gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE +!ifdef $(CSM_ENABLE) + gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE +!endif !if $(SMM_REQUIRE) =3D=3D TRUE gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|TRUE gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 1b18f1769bbc..5751ff1f0352 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -361,6 +361,9 @@ [PcdsFeatureFlag] gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE +!ifdef $(CSM_ENABLE) + gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE +!endif =20 [PcdsFixedAtBuild] gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1 --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53542): https://edk2.groups.io/g/devel/message/53542 Mute This Topic: https://groups.io/mt/70252361/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon May 6 03:59:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53544+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53544+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1580334282398308.6064474307419; Wed, 29 Jan 2020 13:44:42 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Mij0YY1788612x3tykZO6BUJ; Wed, 29 Jan 2020 13:44:41 -0800 X-Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web11.620.1580334280818508020 for ; Wed, 29 Jan 2020 13:44:41 -0800 X-Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-106-U_AHFL1HNiWLw5Vmz82GrA-1; Wed, 29 Jan 2020 16:44:33 -0500 X-Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E10718A6EC8; Wed, 29 Jan 2020 21:44:32 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DB995DA75; Wed, 29 Jan 2020 21:44:30 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Jiewen Yao , Jordan Justen Subject: [edk2-devel] [PATCH v2 11/11] OvmfPkg/PlatformPei: detect SMRAM at default SMBASE (for real) Date: Wed, 29 Jan 2020 22:44:12 +0100 Message-Id: <20200129214412.2361-12-lersek@redhat.com> In-Reply-To: <20200129214412.2361-1-lersek@redhat.com> References: <20200129214412.2361-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: U_AHFL1HNiWLw5Vmz82GrA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com X-Gm-Message-State: GI2sxn39dgwKuWCHIf4uKyTHx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1580334281; bh=xi7LG0K/wDnQfPlxR0G0VLuz4abXy7qppx7XhOufbIg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=UMy2pxKOsr4fjmDwbXC0c/RindExlusNl772rXBJqcVA6cBOZaiG+f5Cj25tzG0Dant 0OhCzvsj9YENb1kUU5YM1NqrCcvIstLdTyVX79SzgRnJagwu0x7BlwbdH2PwseJuO2gmT gxZg0NO0NueW9QpbrjW27IKZLI0tVNfI8kw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Now that the SMRAM at the default SMBASE is honored everywhere necessary, implement the actual detection. The (simple) steps are described in previous patch "OvmfPkg/IndustryStandard: add MCH_DEFAULT_SMBASE* register macros". Regarding CSM_ENABLE builds: according to the discussion with Jiewen at https://edk2.groups.io/g/devel/message/48082 http://mid.mail-archive.com/74D8A39837DF1E4DA445A8C0B3885C503F7C9D2F@shsm= sx102.ccr.corp.intel.com if the platform has SMRAM at the default SMBASE, then we have to (a) either punch a hole in the legacy E820 map as well, in LegacyBiosBuildE820() [OvmfPkg/Csm/LegacyBiosDxe/LegacyBootSupport.c], (b) or document, or programmatically catch, the incompatibility between the "SMRAM at default SMBASE" and "CSM" features. Because CSM is out of scope for the larger "VCPU hotplug with SMM" feature, option (b) applies. Therefore, if the CSM is enabled in the OVMF build, then PlatformPei will not attempt to detect SMRAM at the default SMBASE, at all. This is approach (4) -- the most flexible one, for end-users -- from: http://mid.mail-archive.com/868dcff2-ecaa-e1c6-f018-abe7087d640c@redhat.c= om https://edk2.groups.io/g/devel/message/48348 Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Ard Biesheuvel --- Notes: v2: - In CSM_ENABLE builds, pretend that SMRAM never exists at the default SMBASE [Jiewen] - trim Cc list OvmfPkg/PlatformPei/PlatformPei.inf | 1 + OvmfPkg/PlatformPei/MemDetect.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index 25229618ed13..c51a6176aa2e 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -106,6 +106,7 @@ [FixedPcd] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress =20 [FeaturePcd] + gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire =20 [Ppis] diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 8fdc9c2ed7c9..47dc9c543719 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -103,6 +103,22 @@ Q35SmramAtDefaultSmbaseInitialization ( ASSERT (mHostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID); =20 mQ35SmramAtDefaultSmbase =3D FALSE; + if (FeaturePcdGet (PcdCsmEnable)) { + DEBUG ((DEBUG_INFO, "%a: SMRAM at default SMBASE not checked due to CS= M\n", + __FUNCTION__)); + } else { + UINTN CtlReg; + UINT8 CtlRegVal; + + CtlReg =3D DRAMC_REGISTER_Q35 (MCH_DEFAULT_SMBASE_CTL); + PciWrite8 (CtlReg, MCH_DEFAULT_SMBASE_QUERY); + CtlRegVal =3D PciRead8 (CtlReg); + mQ35SmramAtDefaultSmbase =3D (BOOLEAN)(CtlRegVal =3D=3D + MCH_DEFAULT_SMBASE_IN_RAM); + DEBUG ((DEBUG_INFO, "%a: SMRAM at default SMBASE %a\n", __FUNCTION__, + mQ35SmramAtDefaultSmbase ? "found" : "not found")); + } + PcdStatus =3D PcdSetBoolS (PcdQ35SmramAtDefaultSmbase, mQ35SmramAtDefaultSmbase); ASSERT_RETURN_ERROR (PcdStatus); --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53544): https://edk2.groups.io/g/devel/message/53544 Mute This Topic: https://groups.io/mt/70252365/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-