From nobody Sun May 5 06:57:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47925+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47925+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569324915; cv=none; d=zoho.com; s=zohoarc; b=n7rezhQlngQCyGxbVMXbOJMOR2ZbsVaDbPZ5Sjq4S9L3uckVCqAKqzU/yS/8ANL0nzA5d6rus6wN/1Ca84EUoZApyi1ARfhVkorE75wFYLkGcw3wz5rwmPh0xDorMrPrF5t8srOBILUdXbfOYMAeQJmSeOhRY82LzwHlkEbM0GM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324915; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=JSru1tkgtYZMJKS3OntgvUec1EtFvr3H5n/OTi6pSZQ=; b=mP3+z7bR+0nqP2MUi269zFUP1tZd0ADLf+PPoRllhO+hEvpO4rgj6G9ZAvqs9mc2EJX5/l1TVWPCD6e/9bvv8y0N3lV2ntgOijF3clSA73nnNhe0bSnjjTL34NnmE+m3X/8UbRtQrDfvoiGgpT7TkSk0dh5FIckBls/LQ9UgdGw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47925+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 156932491556621.089177131791416; Tue, 24 Sep 2019 04:35:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VhNKYY1788612xKLvBLCNTxV; Tue, 24 Sep 2019 04:35:15 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 04:35:14 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35E6D300D1CA; Tue, 24 Sep 2019 11:35:14 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8832A6012D; Tue, 24 Sep 2019 11:35:11 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Brijesh Singh , Igor Mammedov , Jiewen Yao , Joao M Martins , Jordan Justen , Jun Nakajima , Michael Kinney , Paolo Bonzini , Phillip Goerl , Yingwen Chen Subject: [edk2-devel] [PATCH wave 1 01/10] OvmfPkg: introduce PcdQ35SmramAtDefaultSmbase Date: Tue, 24 Sep 2019 13:34:56 +0200 Message-Id: <20190924113505.27272-2-lersek@redhat.com> In-Reply-To: <20190924113505.27272-1-lersek@redhat.com> References: <20190924113505.27272-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 24 Sep 2019 11:35:14 +0000 (UTC) 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: 2vEORZ0MTMVlUNlOKN77nbjLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569324915; bh=Cz6/qPsgiiCVx9nvjrmSxf5DE4Cn5i2j2gsNmK9Qqjo=; h=Cc:Date:From:Reply-To:Subject:To; b=p03NqqTks5jwMnf9H24RpKW7nRRNjgiXb/yaEFaIHEh80JoApAKDDxZSFn2AN/R2aBV GaBGqZXZ/T8Ixl3+ZDqD9AQm+qVKKTwZlHHzrVdb9yLCVoBAMsghWKXvDiTqp6ZDbM6jy EqWL2QJ3DYoM2wSHGvYbgwdC4aNfX4bNMSU= 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: Boris Ostrovsky Cc: Brijesh Singh Cc: Igor Mammedov Cc: Jiewen Yao Cc: Joao M Martins Cc: Jordan Justen Cc: Jun Nakajima Cc: Michael Kinney Cc: Paolo Bonzini Cc: Phillip Goerl Cc: Yingwen Chen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek --- 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 66e944436a69..8a970a40cc62 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -561,6 +561,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 51c2bfb44f14..2a3ba9ec2ca1 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -573,6 +573,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 ba7a75884490..17a135a8edfe 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -572,6 +572,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 (#47925): https://edk2.groups.io/g/devel/message/47925 Mute This Topic: https://groups.io/mt/34274936/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 Sun May 5 06:57:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47926+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47926+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569324919; cv=none; d=zoho.com; s=zohoarc; b=LkNw5fzKSi+ynGxL9R46SwSfxtr38MDWf4G13RBB2tnKszVJ/K50trsL1ZOtCEcouo0NhxFgjDH/2lkGhVo7XL7+BuV6D2w4OgMokCuK1+5M58E77RRFm0lM4VipUtIMXS4ElRGBs5ZXLMrW/uI2gWTGW1algBNlK/lsnuRjz+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324919; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=fH0QJrOj80vqCx7qiSimpct34JIU8I4oujhN0aj1wMk=; b=OJbZHX46i71QufLLwGAxPczAI1Uyag68cseLLztCX9pTGIeGOwgzBiEsN8tauYxRZzzEZBjdi+wn737AZyKMDzAAqA9B1LDCOaGDNNYOGTDuoQ5LtwwagSR4VEp+I0sJi84dVVtL5NNpFyoxZ0KPqUPqXi+yHX4/d8mrj0JS+xg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47926+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1569324919290645.791028412275; Tue, 24 Sep 2019 04:35:19 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id jZVFYY1788612xXGCu5XpEie; Tue, 24 Sep 2019 04:35:18 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 04:35:17 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2C5EB18C4285; Tue, 24 Sep 2019 11:35:17 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82885600CC; Tue, 24 Sep 2019 11:35:14 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Brijesh Singh , Igor Mammedov , Jiewen Yao , Joao M Martins , Jordan Justen , Jun Nakajima , Michael Kinney , Paolo Bonzini , Phillip Goerl , Yingwen Chen Subject: [edk2-devel] [PATCH wave 1 02/10] OvmfPkg/IndustryStandard: increase vertical whitespace in Q35 macro defs Date: Tue, 24 Sep 2019 13:34:57 +0200 Message-Id: <20190924113505.27272-3-lersek@redhat.com> In-Reply-To: <20190924113505.27272-1-lersek@redhat.com> References: <20190924113505.27272-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Tue, 24 Sep 2019 11:35:17 +0000 (UTC) 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: i38BF976BYmoru8hgssWkK8ox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569324918; bh=3VL3HROqrXu2yXED/7Z2KYUNYjuuB6tNUPmmhDCoH0A=; h=Cc:Date:From:Reply-To:Subject:To; b=cJ68JmeRs2WEVksdfolt6e9uCdslq/JwYtcP9MADYssOBaVNPcABO6eKVZTI/TV0S4M ggd5Kbyk8TieVvE0JMEA1DJ/oo8DYpJSKGEJeEYWNdGGM2qtAKkN95oclVtObHHVFCE8P mk2hVxroZWbcM5uNCGWhs5TSbpQaDg8Qwyc= 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: Boris Ostrovsky Cc: Brijesh Singh Cc: Igor Mammedov Cc: Jiewen Yao Cc: Joao M Martins Cc: Jordan Justen Cc: Jun Nakajima Cc: Michael Kinney Cc: Paolo Bonzini Cc: Phillip Goerl Cc: Yingwen Chen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daude Tested-by: Philippe Mathieu-Daude --- 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 391cb4622226..614699ab38f1 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 (#47926): https://edk2.groups.io/g/devel/message/47926 Mute This Topic: https://groups.io/mt/34274937/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 Sun May 5 06:57:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47927+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47927+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569324921; cv=none; d=zoho.com; s=zohoarc; b=lUs3HhjgQmJm2GOPN6Eyty1q2IWOjV+CK62RVxSX4Cqecv0eddYqg7A6AuQ606k3NokwRFIVeEuNNFoSVBZEH5A2j7+XgUD3YHXXXYe2kKafExpT5Of9EfUbpbKdzDxsJ2CcKjhBb19Icy7fuP7akXl1pwmznF8HSoaZiUKfcHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324921; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=N329VGJwAoeXHJJcnABRbZlwcF/geo4Nv1EQbXgOqmY=; b=XAibyhhd4bKVFRWg/d1PTq0WDd8g9O+K033QVwHosHqbtaWKIhE4nrGG600rh0Op1QldzEm+BgUdAIw44ZoJDyW0AphsyuysE8LGtUtSA60jJSQEjXOzc56D0kAzHVXXLtmw52G/fr7cgRX2AtsFiBHb4egzt5cV0/PF8czgRYM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47927+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1569324921663535.8100127976985; Tue, 24 Sep 2019 04:35:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8IrYYY1788612xWsJqPZzGTs; Tue, 24 Sep 2019 04:35:21 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 04:35:20 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2CEB7307D923; Tue, 24 Sep 2019 11:35:20 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C722600CC; Tue, 24 Sep 2019 11:35:17 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Brijesh Singh , Igor Mammedov , Jiewen Yao , Joao M Martins , Jordan Justen , Jun Nakajima , Michael Kinney , Paolo Bonzini , Phillip Goerl , Yingwen Chen Subject: [edk2-devel] [PATCH wave 1 03/10] OvmfPkg/IndustryStandard: add MCH_DEFAULT_SMBASE* register macros Date: Tue, 24 Sep 2019 13:34:58 +0200 Message-Id: <20190924113505.27272-4-lersek@redhat.com> In-Reply-To: <20190924113505.27272-1-lersek@redhat.com> References: <20190924113505.27272-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 24 Sep 2019 11:35:20 +0000 (UTC) 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: Ip4WqAzzOeucomFGhaxpkOKvx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569324921; bh=BEgO33/P8i++Cb4v9jR3ARIcC6wwI+2zXZqlLKKS1Qc=; h=Cc:Date:From:Reply-To:Subject:To; b=p0/3ir/1CYmBwlRvPsEQwjS2eo9oiFFvXWckkhbR22jOUT989g1cOOU2ZygKr9fJkZn PECuCMWQl4O8DanuFwhy7BsHXGm1ykeOG3fxi6SLNvZXS7sLthZiqEyTZE2269063HX3A t9/EKNCU6CVlYc+FkNMSoyiOdftPA9CYV78= 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: Boris Ostrovsky Cc: Brijesh Singh Cc: Igor Mammedov Cc: Jiewen Yao Cc: Joao M Martins Cc: Jordan Justen Cc: Jun Nakajima Cc: Michael Kinney Cc: Paolo Bonzini Cc: Phillip Goerl Cc: Yingwen Chen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek --- 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 614699ab38f1..eac57b10d77e 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 (#47927): https://edk2.groups.io/g/devel/message/47927 Mute This Topic: https://groups.io/mt/34274938/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 Sun May 5 06:57:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47928+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47928+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569324924; cv=none; d=zoho.com; s=zohoarc; b=EZjCSB4LIkyOEmE8jwvN6U7u9sUFeHlZ4H0baZctdyzKArxeIkBTrkqd9AsA2FUFPN3Y4fxahseFQcQhFH9V1S1QXkzNyueKfskgcHhiRsdNfrmX/loVwG5rP0YIq69dazE1LHh+UuQ6astZGQxi37B3bMMlobJU1MJuLyrzMCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324924; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZbmsY9CiPg0fIptaCjXkqbg51yLMHD9MMyEtxEKE35s=; b=Fduy1NFLuSkukKo4ZYTB93Wjw9ObPeFx+BSy7MHNQ+LCvK8o0QJEUXgZa0v2xMfibKogtZljd4j+7xyY+GYw3p4B7EB3z1/wCJIi+mRregAzc5gZD/df/1Cn/EooceOT2X46YUDezAeeJLsSb3rbgjcLePjVBQZfLnqLMAb8UiA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47928+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1569324924852489.0938763482907; Tue, 24 Sep 2019 04:35:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9mdPYY1788612xlMIqng1SyM; Tue, 24 Sep 2019 04:35:24 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 04:35:23 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27E6089AC0; Tue, 24 Sep 2019 11:35:23 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A4B7600CC; Tue, 24 Sep 2019 11:35:20 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Brijesh Singh , Igor Mammedov , Jiewen Yao , Joao M Martins , Jordan Justen , Jun Nakajima , Michael Kinney , Paolo Bonzini , Phillip Goerl , Yingwen Chen Subject: [edk2-devel] [PATCH wave 1 04/10] OvmfPkg/PlatformPei: factor out Q35BoardVerification() Date: Tue, 24 Sep 2019 13:34:59 +0200 Message-Id: <20190924113505.27272-5-lersek@redhat.com> In-Reply-To: <20190924113505.27272-1-lersek@redhat.com> References: <20190924113505.27272-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 24 Sep 2019 11:35:23 +0000 (UTC) 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: 5k5iF0rzugmUUGnPSfUlTQYox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569324924; bh=NUKx1Bonmpm+dMr2TSOIG08IG7ZCBQ+88ereZea3gtA=; h=Cc:Date:From:Reply-To:Subject:To; b=vC+IObsmNNHDry9L2v6HfhSydWS7oAh0YPhowmEwcb7SEDdKAj/dgm04O2f385PISvx wwiUe2DwPC1CIhRkjcAb8orpD7fCoBTzSPOuFwvyCksIVABVtLLjXMSmuijmX3Ejhd87t 0TpoOX8W/vC3vGpRUtvTnnzeLin3FV+/jKs= 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: Boris Ostrovsky Cc: Brijesh Singh Cc: Igor Mammedov Cc: Jiewen Yao Cc: Joao M Martins Cc: Jordan Justen Cc: Jun Nakajima Cc: Michael Kinney Cc: Paolo Bonzini Cc: Phillip Goerl Cc: Yingwen Chen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daude --- 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 3ba2459872d9..ca6d37cb1549 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -563,6 +563,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 number of boot CPUs from QEMU and expose it to UefiCpuPkg modu= les. Set the mMaxCpuCount variable. @@ -646,6 +668,7 @@ InitializePlatform ( mHostBridgeDevId =3D PciRead16 (OVMF_HOSTBRIDGE_DID); =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 (#47928): https://edk2.groups.io/g/devel/message/47928 Mute This Topic: https://groups.io/mt/34274939/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 Sun May 5 06:57:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47929+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47929+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569324927; cv=none; d=zoho.com; s=zohoarc; b=CfMaNZpAflnIDz4Zzvy4lSuZyUMJrV1IYJH7kXkhTbLMGXSj6ngr7nXG+xKpsP5Qg+H1CwcKJfggo2bMwYhE+mJTCYesPcqe0W16cSDVMjCNvsoGYmaK0nceBqEdUVhToRWsiV9WaAwjNHjBGJkwkG4VvxtUyMFuByV+gpMgSBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324927; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=K6YIOZbh3VY9EWEsixX6RIcpoY0d4DOO8iOX4nJZBM8=; b=MJ8O+K8BDZa8fyZDzdCjws9KPsLvW7XVG5JOByFsqpPxKXgFhIdLhy355aRRbCKbCAsR82dTQ+fG3K/m6NIH+i7liK0fymeazwPu4CFoEivC8SXzi4B75RZCTnHh20Aw4NOVh4MjKmX39SXgGY1bYLUBRgvZCcvoiu2ITTuarh8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47929+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1569324927322164.58100014172032; Tue, 24 Sep 2019 04:35:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id sqb1YY1788612xRICsP2J2PA; Tue, 24 Sep 2019 04:35:26 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 04:35:26 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 22930804F2; Tue, 24 Sep 2019 11:35:26 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 799D9600CC; Tue, 24 Sep 2019 11:35:23 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Brijesh Singh , Igor Mammedov , Jiewen Yao , Joao M Martins , Jordan Justen , Jun Nakajima , Michael Kinney , Paolo Bonzini , Phillip Goerl , Yingwen Chen Subject: [edk2-devel] [PATCH wave 1 05/10] OvmfPkg/PlatformPei: detect SMRAM at default SMBASE (skeleton) Date: Tue, 24 Sep 2019 13:35:00 +0200 Message-Id: <20190924113505.27272-6-lersek@redhat.com> In-Reply-To: <20190924113505.27272-1-lersek@redhat.com> References: <20190924113505.27272-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 24 Sep 2019 11:35:26 +0000 (UTC) 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: UsEMre9sdsX55dmALUCOTyITx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569324926; bh=RQFLz0YzZTNgY78DDTNCvxTbq52VVnAkyEYXleAAFBY=; h=Cc:Date:From:Reply-To:Subject:To; b=HrxghLCmode2XyigbrrXFbwCBmvEdLQI+Iw9nj1taqQIylkEeu7YzBrA4SV40OiwzK2 F4P3c2wpyB4K4GzN3At9hoepskObkn3v2c9VXC4AHKZhSg9jeD1iXhp6l3nSRR5kr+OR7 kgADe4Hc6dRfcVurQ2XGkzMgg/zWXNPasJk= 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: Boris Ostrovsky Cc: Brijesh Singh Cc: Igor Mammedov Cc: Jiewen Yao Cc: Joao M Martins Cc: Jordan Justen Cc: Jun Nakajima Cc: Michael Kinney Cc: Paolo Bonzini Cc: Phillip Goerl Cc: Yingwen Chen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek --- 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 d9fd9c8f05b3..2b0c2c886929 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 ca6d37cb1549..6989712b0645 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -670,6 +670,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 (#47929): https://edk2.groups.io/g/devel/message/47929 Mute This Topic: https://groups.io/mt/34274940/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 Sun May 5 06:57:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47930+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47930+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569324930; cv=none; d=zoho.com; s=zohoarc; b=D5cZEooKuistCoZa3d7/xQXQ9YGtt5iAoLTlUKiVpXOseKf6SD/SFCIuBtotzoSFf76dpqwkuAZ8S6g02STOjEoc57kWGb5xu3HGMlXd48rNesKKCzmDHC5wConBV7VLBI3fLCmv6mfJ3lk3lMlR5RxffqbkQtpiCZUd6SU1RoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324930; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=eryMwb1ARvHRt7e3j94H0oHegtXaE3lorn8QtpqtR9A=; b=Gwdm29CoPtRl9pbqn2jAhgtmUzST3RhHexlDl7kqeaNAZuBgj8ihaHJykmvELyU5kiNiiUfHV1mlgM3UjDQjEjSGIFjHnv4SiXWvWosfHl58jzx1Msg9r3W4FkEwqH5qgaY6BTY9WJ7XF0TGEG4us7ufDrFTOJBQUmfzu0HyXck= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47930+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1569324930274215.35312663483865; Tue, 24 Sep 2019 04:35:30 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id L5vrYY1788612xhaRBqn4sgI; Tue, 24 Sep 2019 04:35:29 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 04:35:29 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E0161107; Tue, 24 Sep 2019 11:35:29 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 722DA600CC; Tue, 24 Sep 2019 11:35:26 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Brijesh Singh , Igor Mammedov , Jiewen Yao , Joao M Martins , Jordan Justen , Jun Nakajima , Michael Kinney , Paolo Bonzini , Phillip Goerl , Yingwen Chen Subject: [edk2-devel] [PATCH wave 1 06/10] OvmfPkg/PlatformPei: assert there's no permanent PEI RAM at default SMBASE Date: Tue, 24 Sep 2019 13:35:01 +0200 Message-Id: <20190924113505.27272-7-lersek@redhat.com> In-Reply-To: <20190924113505.27272-1-lersek@redhat.com> References: <20190924113505.27272-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 24 Sep 2019 11:35:29 +0000 (UTC) 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: KmbZS37O5VsjucW8M6UQ7J1Hx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569324929; bh=NOIJcbqc3NmyY2uts1vEeZeHqS1Ug+W8CEAilu9jajY=; h=Cc:Date:From:Reply-To:Subject:To; b=Nbzl4ddhV2murzCYbMZoxv93x+vmPTKPSqcP6gJSJHNckIpImUK25Llh/3j0HPcQYzJ WlPk0yPkar+0KGy90dHM7eiBMI/+cb0CuV2xdZpF9Pk1VwyQZB9N8VIwzGI5pSoCw4B3Z 7a+fHzTcMpYbmFPXDxZ0dLfvztvSFnWc5jc= 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: Boris Ostrovsky Cc: Brijesh Singh Cc: Igor Mammedov Cc: Jiewen Yao Cc: Joao M Martins Cc: Jordan Justen Cc: Jun Nakajima Cc: Michael Kinney Cc: Paolo Bonzini Cc: Phillip Goerl Cc: Yingwen Chen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek --- 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 (#47930): https://edk2.groups.io/g/devel/message/47930 Mute This Topic: https://groups.io/mt/34274941/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 Sun May 5 06:57:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47931+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47931+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569324934; cv=none; d=zoho.com; s=zohoarc; b=mJuOIVKExEV3aTRD1yHYYHbdG/00G8M6ClS6qJC9s4kHZHaoTSw783QMtJq5Xc2hY5nhFlMlDr2yS9g2oZ23TdWEVQ8aGOI8HUhd8Il7XAI9CGncWCM6gc7zDA47Fi0Wiu4pikBXcGiIoL1DNmxj/98fmLJNArTpWX8ycgE/Tbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324934; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=wvwnHvGy9fm6O2iH67xNxRUq9Jl5yDsIGcJ+PknQq4I=; b=N0c3RA24jgdL7qhuynYC8gqG8lWVau/0Ej4g6iaZbyfmlqV9OOMLH9OCnCHUFr/zZnqop+yC1i57HGcF9lvfj7yo6Np9aiqIL0D+SruHGC0EuHsrhFtPHXv1Yc6Pa5kpYCVlJodDyKwKiP2QEvCnnXGf5ioSbTxmS/XknJqbOOA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47931+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1569324934068864.3155955024117; Tue, 24 Sep 2019 04:35:34 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vCzcYY1788612xwKJspISsvH; Tue, 24 Sep 2019 04:35:33 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 04:35:32 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19C4A8BA2DA; Tue, 24 Sep 2019 11:35:32 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E681600CC; Tue, 24 Sep 2019 11:35:29 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Brijesh Singh , Igor Mammedov , Jiewen Yao , Joao M Martins , Jordan Justen , Jun Nakajima , Michael Kinney , Paolo Bonzini , Phillip Goerl , Yingwen Chen Subject: [edk2-devel] [PATCH wave 1 07/10] OvmfPkg/PlatformPei: reserve the SMRAM at the default SMBASE, if it exists Date: Tue, 24 Sep 2019 13:35:02 +0200 Message-Id: <20190924113505.27272-8-lersek@redhat.com> In-Reply-To: <20190924113505.27272-1-lersek@redhat.com> References: <20190924113505.27272-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Tue, 24 Sep 2019 11:35:32 +0000 (UTC) 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: S6u9BhY73jLkhCMRlfLgb9urx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569324933; bh=PqjAMtTRzfuSXXaLnnkeCWm7lZnLZF3liFv5LkfyUeE=; h=Cc:Date:From:Reply-To:Subject:To; b=xBUompIPCorj5t3P6jJV/h9CbWcsMZuvEhir5geJsjxOncJPxM+f7DZcH2cSsRFuite NptTb0bXeruSIIdQmyarQVBgcs4ScYGBYQbZLB3q7NmGoluop5FPEyFFdcxhQz+K6d3MF wPCgCrdZXlr1x7X88asArQTCcG1v5edz4wo= 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: Boris Ostrovsky Cc: Brijesh Singh Cc: Igor Mammedov Cc: Jiewen Yao Cc: Joao M Martins Cc: Jordan Justen Cc: Jun Nakajima Cc: Michael Kinney Cc: Paolo Bonzini Cc: Phillip Goerl Cc: Yingwen Chen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek --- 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 (#47931): https://edk2.groups.io/g/devel/message/47931 Mute This Topic: https://groups.io/mt/34274942/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 Sun May 5 06:57:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47932+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47932+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569324936; cv=none; d=zoho.com; s=zohoarc; b=DZgbHEtCg6fuCZRU+r1fPJs9uz7sSIKorjP1EYjYRzrWkt292x3YqqpLlywxzCC9uUH6MZ3p4F9M+JkuElSOKoquZN3+IzRLLfDSwbSHkx8jOAgfdB5J8uZT4fDzvjnhGqlwn4pd6CfwXXlN/xrWa9jrhfyAFa7uIzl/P7BzYyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324936; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=aMSIQBY0KiFA2apml2ZSmy1UA4QAkAzKaHVHPY9qFxQ=; b=ddlawrHIPuet5VgCSKnnXS2NmyRF7Ds/MVcLCTfvhcbVKXPqbFKG/S2aXlSGJFwbNOHZWOeK8yGu43phsJFpoyfIr8HHVDKHdXkmly3vFYwU96Mg8xWiqLqNsFKoqAMYD44CZHnAxeujnHHYGVQi+FwLPhdaNywzDFsTQF07fIM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47932+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 156932493627741.92952878519611; Tue, 24 Sep 2019 04:35:36 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kilLYY1788612x2pDtZ5qqRq; Tue, 24 Sep 2019 04:35:35 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 04:35:35 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11FF569080; Tue, 24 Sep 2019 11:35:35 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 678CC600CC; Tue, 24 Sep 2019 11:35:32 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Brijesh Singh , Igor Mammedov , Jiewen Yao , Joao M Martins , Jordan Justen , Jun Nakajima , Michael Kinney , Paolo Bonzini , Phillip Goerl , Yingwen Chen Subject: [edk2-devel] [PATCH wave 1 08/10] OvmfPkg/SEV: don't manage the lifecycle of the SMRAM at the default SMBASE Date: Tue, 24 Sep 2019 13:35:03 +0200 Message-Id: <20190924113505.27272-9-lersek@redhat.com> In-Reply-To: <20190924113505.27272-1-lersek@redhat.com> References: <20190924113505.27272-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 24 Sep 2019 11:35:35 +0000 (UTC) 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: dxHZ67kHZ6T6NtNLZhmxTTD9x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569324935; bh=HpZ/VdfxUNnbb12MOx63L4YWnwXbi+7j85qD7LbEDcU=; h=Cc:Date:From:Reply-To:Subject:To; b=szJeSuTfo+uTPsaRqd/7HsOhaiUewu1Qd035DDRuk43V1nGhAWDtjg6e3i8AYFfiATf tu2BkjJ3ofLCYmcPW4siLlFTibvre0Tkp3ImTepx9dzmJoyM1tliNTD1KaWzCnGgACA/c U/ZHCCV6bPkf65C/trC8cGQl3sl5DlOFBWI= 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: Boris Ostrovsky Cc: Brijesh Singh Cc: Igor Mammedov Cc: Jiewen Yao Cc: Joao M Martins Cc: Jordan Justen Cc: Jun Nakajima Cc: Michael Kinney Cc: Paolo Bonzini Cc: Phillip Goerl Cc: Yingwen Chen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek --- 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 (#47932): https://edk2.groups.io/g/devel/message/47932 Mute This Topic: https://groups.io/mt/34274943/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 Sun May 5 06:57:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47933+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47933+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569324939; cv=none; d=zoho.com; s=zohoarc; b=SXcoEOEwMcafoB43HQdTIcq7YakiP90iGKxdyTwt3QpwYniE0Xu7F43tR3TWIa/KylqQwrlZZun+3jXINIPMMtHK+ewoH+JZ21/uVn1kjqXCrAbF33aiGM2YIiqHJwlhPolzIJCkQictqH6qMeFg1O22LLO9V/qQpQshtBdYflo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324939; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=hkUp0yV9y6NXl6G9eHPXNW0uewHedKkzbFNilB/LnKQ=; b=WHRVp0l7lozHrtYZSJPGSDpN2tUd8oZ5a4wgzyLVxgr3mOKwqrVc5NDKez4aLG1VoUco9wvuTlkByR6H7EWjiuqvjIl0BJS6f5jts9tkwDszk9KhsHTF0UHqtD9qn16dEtZiLEFLGVUXxaa47EK2NCl7/0CkjyvX3xm4lwzn8wk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47933+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1569324939769445.1654955893208; Tue, 24 Sep 2019 04:35:39 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dSb9YY1788612xWqDGt8i8c9; Tue, 24 Sep 2019 04:35:38 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 04:35:38 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0DBDA877A64; Tue, 24 Sep 2019 11:35:38 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 621436012D; Tue, 24 Sep 2019 11:35:35 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Brijesh Singh , Igor Mammedov , Jiewen Yao , Joao M Martins , Jordan Justen , Jun Nakajima , Michael Kinney , Paolo Bonzini , Phillip Goerl , Yingwen Chen Subject: [edk2-devel] [PATCH wave 1 09/10] OvmfPkg/SmmAccess: close and lock SMRAM at default SMBASE Date: Tue, 24 Sep 2019 13:35:04 +0200 Message-Id: <20190924113505.27272-10-lersek@redhat.com> In-Reply-To: <20190924113505.27272-1-lersek@redhat.com> References: <20190924113505.27272-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Tue, 24 Sep 2019 11:35:38 +0000 (UTC) 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: CvWVoR02ZxpjQ0xV1eVzLPZex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569324938; bh=AvWFUnmxPw+xrcHOrWA4WYq7/k1evx3yIYzgHawdbZM=; h=Cc:Date:From:Reply-To:Subject:To; b=cO1yXweRZ/Tdt4cK3atcSn15orft/jek4baS4j7Km6hWlGJEydFeIKRE5LxDl/i2o54 +wjb41QdzxvTC+3mjqiUtaQKes/8mVUI2HvHPZJqSSArrVM9cFDlLvrS8elHpQgG/ssuJ lRZs5bXMNRjWrYjlk/+Whwc9+kw1VYpgHEc= 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: Boris Ostrovsky Cc: Brijesh Singh Cc: Igor Mammedov Cc: Jiewen Yao Cc: Joao M Martins Cc: Jordan Justen Cc: Jun Nakajima Cc: Michael Kinney Cc: Paolo Bonzini Cc: Phillip Goerl Cc: Yingwen Chen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek --- 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 (#47933): https://edk2.groups.io/g/devel/message/47933 Mute This Topic: https://groups.io/mt/34274944/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 Sun May 5 06:57:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47934+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47934+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1569324942; cv=none; d=zoho.com; s=zohoarc; b=Umcwv67oOJZ1k2lkUdxAlENytb4DjLbfNOPEWyDvVxsQ+FqdVh2pOdZt35LIgNV2eMCF7WX1zaw+wIOkUkMl4ZNEaa3QJm0TTJfoaatsp7vk+y3fC2ROcW0Svi+Vo93+xB6rVryLMOyNLyiU2t1Wbep+m1sr0sFMh/BI62+23Z4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569324942; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=r7t4BtasHgSLLgjgo1ji0ix1hYRTIR+NzB16yy3PHjw=; b=De2j6amaRtlP4t1zYzURAmB1CbyPJLQ2jW+FwlP/c5C1gHqXXtjwL5Pz+2dXTzh0JaR5oNbzia6BDvwqdBFj2bVTvVJFaaWjTBwQyApJwQ7RuXt4VASN1HB3ZEuTbTEVci54XiF0vIhGikbWfjQEnSSGgIsAtPBHPCWgzus68AQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47934+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1569324942204442.1387251228631; Tue, 24 Sep 2019 04:35:42 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id FCuvYY1788612xF7b02C261m; Tue, 24 Sep 2019 04:35:41 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 04:35:41 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0335AC057FA6; Tue, 24 Sep 2019 11:35:41 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-118.rdu2.redhat.com [10.10.120.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B494600CC; Tue, 24 Sep 2019 11:35:38 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Boris Ostrovsky , Brijesh Singh , Igor Mammedov , Jiewen Yao , Joao M Martins , Jordan Justen , Jun Nakajima , Michael Kinney , Paolo Bonzini , Phillip Goerl , Yingwen Chen Subject: [edk2-devel] [PATCH wave 1 10/10] OvmfPkg/PlatformPei: detect SMRAM at default SMBASE (for real) Date: Tue, 24 Sep 2019 13:35:05 +0200 Message-Id: <20190924113505.27272-11-lersek@redhat.com> In-Reply-To: <20190924113505.27272-1-lersek@redhat.com> References: <20190924113505.27272-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 24 Sep 2019 11:35:41 +0000 (UTC) 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: jTi8EswaoVD5bX7kqaGfeIBRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569324941; bh=jXPIsr2U1ZA8E7GN+pf8qpdnSJx6yL6GP0R/dKhUd1s=; h=Cc:Date:From:Reply-To:Subject:To; b=LbQtP0BOxnChyAJoi4l7PxBKZE+zxviMX5xZQsmZ0txOfI+qLmOQPwPos1QQ/kvNNN2 oUkfvJiFcUKT7tz0uHIzEvBBfEnPjjLSfeLYypxBPaRHbaZt0E7o0zAlYzqhX6xNIW8R5 4nQyovRp+Wj9+7KRkHNH+sNL6+nsVaGbI0M= 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". Cc: Ard Biesheuvel Cc: Boris Ostrovsky Cc: Brijesh Singh Cc: Igor Mammedov Cc: Jiewen Yao Cc: Joao M Martins Cc: Jordan Justen Cc: Jun Nakajima Cc: Michael Kinney Cc: Paolo Bonzini Cc: Phillip Goerl Cc: Yingwen Chen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1512 Signed-off-by: Laszlo Ersek --- OvmfPkg/PlatformPei/MemDetect.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 8fdc9c2ed7c9..3364193b4952 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -98,14 +98,23 @@ Q35SmramAtDefaultSmbaseInitialization ( VOID ) { + UINTN CtlReg; + UINT8 CtlRegVal; RETURN_STATUS PcdStatus; =20 ASSERT (mHostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID); =20 - mQ35SmramAtDefaultSmbase =3D FALSE; + 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_SMBA= SE_IN_RAM); PcdStatus =3D PcdSetBoolS (PcdQ35SmramAtDefaultSmbase, mQ35SmramAtDefaultSmbase); ASSERT_RETURN_ERROR (PcdStatus); + if (mQ35SmramAtDefaultSmbase) { + DEBUG ((DEBUG_INFO, "%a: SMRAM at default SMBASE found\n", __FUNCTION_= _)); + } } =20 =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 (#47934): https://edk2.groups.io/g/devel/message/47934 Mute This Topic: https://groups.io/mt/34274946/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-