From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by mx.groups.io with SMTP id smtpd.web10.1851.1689119586604197135 for ; Tue, 11 Jul 2023 16:53:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@taylorbeebe.com header.s=google header.b=Tt+JjaDx; spf=pass (domain: taylorbeebe.com, ip: 209.85.210.177, mailfrom: t@taylorbeebe.com) Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-666ecf9a081so5577796b3a.2 for ; Tue, 11 Jul 2023 16:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=taylorbeebe.com; s=google; t=1689119586; x=1691711586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8Ohko55+QmiM+xKPcVzvD5Ymv4hSsQGrxS7Np+jG09o=; b=Tt+JjaDxJY14sAjkG6JysOu6ZX6x71oYBOwVcBpX3DVVeFPdmqmVDlG7w4gOYDsE3c o0uDkxmWbl6a6NYVnaKfQ6O0gg+SUspW3loU/k2CdjDa2zb5eId73CF1jt/QMG/g+asQ 18XghTOReDRmtVcvuG0SUXhNhgtjVp3Xnik1hfZ46jYAJkxbrzRSddWaV4pz4P9L0TZQ rUW1+4jZRV24huiN40QspwNCmAG9UnsIutJjK6PfCPjGvyWgHVNLBpGeFxc057C0P58j lpkRLkxwbf02DwZAStEtNVTPOqmIyQAXeEQFOwlz6klFQWpK5Nb+vW4YBJH+FS2D8duw 229A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689119586; x=1691711586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8Ohko55+QmiM+xKPcVzvD5Ymv4hSsQGrxS7Np+jG09o=; b=LhPTNI3onwb4ouJoYPwHAFYeX+h2Fi9+eYtQ0Px/HZvebs1ODsaCZX9cmHEQp2zHca jNY+UVe+wCQitBs+rH1DHGA+vW75X0tdiyo+p63q092GW8tI7Xfjyor7YvT+M2ekRLiU K8J9bRekT/52aFBjyb1cSLaP0uEUafQuNEB0X6iWnc7K+q2DvoBXPV/Ky4L1yOzSdSCz ipu+n1LGLsIT2eRbD1w4r4Q2Z6FE0hhdgsgf939iJV25ClOhCZzFDgay/DekEzWS2WSV T7iwNmMes9vdrgsl6AMz3P4hJ8aL1ZtZeo9NeGCiVsgGuZzW0OX5kh2M+EIHSohWirFr lxSw== X-Gm-Message-State: ABy/qLaW6DcmfWm7+GZWYKMzPcH+B89xlElE67QR+oqUDdpYiRMswgN7 mG87LHtuOx1qwpLWyeVnKLei+5o3DkN6WMMElrRFiQ== X-Google-Smtp-Source: APBJJlGgyt0mFerwSCQYairm31MkUy/99CzaJhfjAAYvbjRcX3MoknxcWFraiSDqR/Ob6NgO97a6fA== X-Received: by 2002:a05:6a00:22c9:b0:675:8f71:28ee with SMTP id f9-20020a056a0022c900b006758f7128eemr22279602pfj.34.1689119585936; Tue, 11 Jul 2023 16:53:05 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([50.46.230.135]) by smtp.gmail.com with ESMTPSA id a13-20020a62e20d000000b00660d80087a8sm2232677pfi.187.2023.07.11.16.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 16:53:05 -0700 (PDT) From: "Taylor Beebe" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann Subject: [PATCH 04/14] OvmfPkg: Create the memory protection settings HOB Date: Tue, 11 Jul 2023 16:52:41 -0700 Message-ID: X-Mailer: git-send-email 2.41.0.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Taylor Beebe Create the memory protection settings HOB on Ovmf platforms with DEBUG settings. Signed-off-by: Taylor Beebe Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann --- OvmfPkg/AmdSev/AmdSevX64.dsc | 2 ++ OvmfPkg/Bhyve/BhyveX64.dsc | 2 ++ OvmfPkg/CloudHv/CloudHvX64.dsc | 2 ++ .../Dsc/MemoryProtectionLibraries.dsc.inc | 15 +++++++++++ OvmfPkg/IntelTdx/IntelTdxX64.dsc | 2 ++ OvmfPkg/Microvm/MicrovmX64.dsc | 2 ++ OvmfPkg/OvmfPkgIa32.dsc | 2 ++ OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++ OvmfPkg/OvmfPkgX64.dsc | 2 ++ OvmfPkg/OvmfXen.dsc | 2 ++ OvmfPkg/PlatformPei/Platform.c | 27 +++++++++++++++++-- OvmfPkg/PlatformPei/PlatformPei.inf | 2 ++ OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc | 1 + 13 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index 2c6ed7c974..ce028fcb5c 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -370,6 +370,8 @@ !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf +!include OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc + ################################################################################ # # Pcd Section - list of all EDK II PCD Entries defined by this Platform. diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc index 7fa40998ae..248b6020ed 100644 --- a/OvmfPkg/Bhyve/BhyveX64.dsc +++ b/OvmfPkg/Bhyve/BhyveX64.dsc @@ -411,6 +411,8 @@ !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf +!include OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc + ################################################################################ # # Pcd Section - list of all EDK II PCD Entries defined by this Platform. diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc index e000deed9e..8828e298ca 100644 --- a/OvmfPkg/CloudHv/CloudHvX64.dsc +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc @@ -451,6 +451,8 @@ !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf +!include OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc + ################################################################################ # # Pcd Section - list of all EDK II PCD Entries defined by this Platform. diff --git a/OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc b/OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc new file mode 100644 index 0000000000..cd8552de0d --- /dev/null +++ b/OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc @@ -0,0 +1,15 @@ +## +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +# +# Memory Protection Libraries +# +[LibraryClasses.common.DXE_DRIVER, LibraryClasses.common.DXE_CORE, LibraryClasses.common.UEFI_APPLICATION, LibraryClasses.common.UEFI_DRIVER] + DxeMemoryProtectionHobLib|MdeModulePkg/Library/MemoryProtectionHobLib/DxeMemoryProtectionHobLib.inf + +[LibraryClasses.common.SMM_CORE, LibraryClasses.common.DXE_SMM_DRIVER] + MmMemoryProtectionHobLib|MdeModulePkg/Library/MemoryProtectionHobLib/SmmMemoryProtectionHobLib.inf + +[LibraryClasses.common.MM_CORE_STANDALONE, LibraryClasses.common.MM_STANDALONE] + MmMemoryProtectionHobLib|MdeModulePkg/Library/MemoryProtectionHobLib/StandaloneMmMemoryProtectionHobLib.inf diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc index 193657ff2d..27b9d4bf26 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -363,6 +363,8 @@ !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf +!include OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc + ################################################################################ # # Pcd Section - list of all EDK II PCD Entries defined by this Platform. diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc index 2f75856393..611d64a6a0 100644 --- a/OvmfPkg/Microvm/MicrovmX64.dsc +++ b/OvmfPkg/Microvm/MicrovmX64.dsc @@ -452,6 +452,8 @@ PciPcdProducerLib|OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf PciExpressLib|OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf +!include OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc + ################################################################################ # # Pcd Section - list of all EDK II PCD Entries defined by this Platform. diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index ed36935770..810d69651c 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -458,6 +458,8 @@ !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf +!include OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc + ################################################################################ # # Pcd Section - list of all EDK II PCD Entries defined by this Platform. diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 919315e4cb..13e141a352 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -465,6 +465,8 @@ !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf +!include OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc + ################################################################################ # # Pcd Section - list of all EDK II PCD Entries defined by this Platform. diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 823de0d0f9..418c3a0f54 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -484,6 +484,8 @@ !endif PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf +!include OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc + ################################################################################ # # Pcd Section - list of all EDK II PCD Entries defined by this Platform. diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 210578c1d7..94d455e2d6 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -350,6 +350,8 @@ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf +!include OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc + ################################################################################ # # Pcd Section - list of all EDK II PCD Entries defined by this Platform. diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index f5dc41c3a8..075de3fce6 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include "Platform.h" @@ -304,8 +306,29 @@ InitializePlatform ( IN CONST EFI_PEI_SERVICES **PeiServices ) { - EFI_HOB_PLATFORM_INFO *PlatformInfoHob; - EFI_STATUS Status; + EFI_HOB_PLATFORM_INFO *PlatformInfoHob; + EFI_STATUS Status; + DXE_MEMORY_PROTECTION_SETTINGS DxeSettings; + MM_MEMORY_PROTECTION_SETTINGS MmSettings; + + DxeSettings = (DXE_MEMORY_PROTECTION_SETTINGS)DXE_MEMORY_PROTECTION_SETTINGS_DEBUG; + MmSettings = (MM_MEMORY_PROTECTION_SETTINGS)MM_MEMORY_PROTECTION_SETTINGS_DEBUG; + + DxeSettings.NullPointerDetection.DisableEndOfDxe = TRUE; + MmSettings.HeapGuard.PageGuardEnabled = FALSE; + MmSettings.HeapGuard.PoolGuardEnabled = FALSE; + + BuildGuidDataHob ( + &gDxeMemoryProtectionSettingsGuid, + &DxeSettings, + sizeof (DxeSettings) + ); + + BuildGuidDataHob ( + &gMmMemoryProtectionSettingsGuid, + &MmSettings, + sizeof (MmSettings) + ); DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n")); PlatformInfoHob = BuildPlatformInfoHob (); diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf index 3934aeed95..9e30d616eb 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -45,6 +45,8 @@ gEfiMemoryTypeInformationGuid gFdtHobGuid gUefiOvmfPkgPlatformInfoGuid + gDxeMemoryProtectionSettingsGuid + gMmMemoryProtectionSettingsGuid [LibraryClasses] BaseLib diff --git a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc b/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc index 34b2037824..09bb83dc0f 100644 --- a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc +++ b/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc @@ -126,6 +126,7 @@ PciExpressLib|OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf #!include NetworkPkg/NetworkBuildOptions.dsc.inc +!include OvmfPkg/Include/Dsc/MemoryProtectionLibraries.dsc.inc ################################################################################ # -- 2.41.0.windows.2