From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by mx.groups.io with SMTP id smtpd.web10.1852.1689119587322181098 for ; Tue, 11 Jul 2023 16:53:07 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@taylorbeebe.com header.s=google header.b=UnSloYnk; spf=pass (domain: taylorbeebe.com, ip: 209.85.210.178, mailfrom: t@taylorbeebe.com) Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-666eec46206so5569233b3a.3 for ; Tue, 11 Jul 2023 16:53:07 -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=H/qRk+U+7i/FY6ig5N8OgZX+DQdd8GIbqegVCr0ksQs=; b=UnSloYnkFnrVlxvjbIvnthVjYxx+3m4mftVgKeisipPEcoBbP1KnMX0NUBaor5I/Xq veI2ifzMvReEM4OSbMhTbNIOFe0l0MjU/lDzmKngACc8EwzPBXYaxZRaxEx4qB0nMqmJ q2tkKjK+yJW3YTKN2orCHUn8PV67o1K3SgfW4Y+V0Kzem+klKfhOdguvoVnrSPplXvrE Gn+WEE55vfoB0UXnMY9Pn6hCz+3shKVOYY3yH6cv9Mz+5Z+Hbzmxt781WI8zywsyYr4x WhgW4UN65nlAirFSeQqksMj/TeqKXbh0xVwTeQ4uH/Kdukv6ALX/E23CA9bZl5c+9VmL zDlg== 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=H/qRk+U+7i/FY6ig5N8OgZX+DQdd8GIbqegVCr0ksQs=; b=O74TAoCYDHR4M674kII1SzsAYvjy7ZnA2IGiDrPFfLKDJup0xZNw7yOuga22qNbj+p CTL7lwxl9353NsOxDhT/5ZkDxr5KTnaXRfwUB1MWgj3HCc+j3iPU9yiVJ3OZr2yCctYH vveRHyId8WDcMBw4aOOkeVgpIEOZPVbKyELrNFzKHwbZIfNw9cUx0LTuLwvt8UGTJNuy /CiBxz8R9WEvTbjbLJL7jDq3CYYS/11uUQtd9/BNssBOu0j73YOWKzFt82wC60lPW/WA cjOaDkg/nD5oRRgmEfDYPPpJ6k9pNVoGEJj8MvUfsRp6QeYsxYVhcOgYnZPj6mo38KiB hyjw== X-Gm-Message-State: ABy/qLZBf9qs3pLDnulK637xtxiRTa4ag2mx9MfNY794ryhpXZMEnx3M 45t8u8VDrFZF7ec8oRZxFGQgXxfA1IL0Ry0lE6vIcA== X-Google-Smtp-Source: APBJJlENJrm3968bcRhCXKwn+m1vO9XPcXR2EQNmb1ZXnxhQ0I8yMstoSv4YDpy3OnZwlFHTBHTKSg== X-Received: by 2002:aa7:8883:0:b0:666:7bc5:531c with SMTP id z3-20020aa78883000000b006667bc5531cmr20789247pfe.24.1689119586561; Tue, 11 Jul 2023 16:53:06 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 16:53:06 -0700 (PDT) From: "Taylor Beebe" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Gerd Hoffmann Subject: [PATCH 05/14] ArmVirtPkg: Create memory protection settings HOB Date: Tue, 11 Jul 2023 16:52:42 -0700 Message-ID: <38cbafe5c97df5be8443cade7271f29990c20117.1689101263.git.t@taylorbeebe.com> 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 HOBs on Arm virtual platforms. These platforms will use the DEBUG memory protection profile. Signed-off-by: Taylor Beebe Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Sami Mujawar Cc: Gerd Hoffmann --- ArmVirtPkg/ArmVirt.dsc.inc | 9 ++++++++ ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c | 25 +++++++++++++++++++-- ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 2443e8351c..3174b19e51 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -256,6 +256,15 @@ [LibraryClasses.ARM] ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf +[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 + [BuildOptions] GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG diff --git a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c index ef88a9df1d..2033df1a01 100644 --- a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c +++ b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c @@ -14,7 +14,9 @@ #include #include #include +#include #include +#include EFI_STATUS EFIAPI @@ -76,8 +78,10 @@ InitializeMemory ( IN CONST EFI_PEI_SERVICES **PeiServices ) { - UINTN UefiMemoryBase; - EFI_STATUS Status; + UINTN UefiMemoryBase; + EFI_STATUS Status; + DXE_MEMORY_PROTECTION_SETTINGS DxeSettings; + MM_MEMORY_PROTECTION_SETTINGS MmSettings; ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) < (UINT64)MAX_ALLOC_ADDRESS); @@ -100,5 +104,22 @@ InitializeMemory ( ); ASSERT_EFI_ERROR (Status); + DxeSettings = (DXE_MEMORY_PROTECTION_SETTINGS)DXE_MEMORY_PROTECTION_SETTINGS_DEBUG; + MmSettings = (MM_MEMORY_PROTECTION_SETTINGS)MM_MEMORY_PROTECTION_SETTINGS_DEBUG; + + DxeSettings.NullPointerDetection.DisableEndOfDxe = TRUE; + + BuildGuidDataHob ( + &gDxeMemoryProtectionSettingsGuid, + &DxeSettings, + sizeof (DxeSettings) + ); + + BuildGuidDataHob ( + &gMmMemoryProtectionSettingsGuid, + &MmSettings, + sizeof (MmSettings) + ); + return Status; } diff --git a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf index 2039f71a0e..044542ecb2 100644 --- a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf +++ b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf @@ -37,6 +37,8 @@ [Guids] gEfiMemoryTypeInformationGuid + gDxeMemoryProtectionSettingsGuid + gMmMemoryProtectionSettingsGuid [FeaturePcd] gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob -- 2.41.0.windows.2