From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 61498D801B4 for ; Mon, 9 Oct 2023 00:08:19 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=swosn8WsSC/JBwOvOUa86ORINMJAZLQaLR9OfbxZH08=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1696810098; v=1; b=EHgA/cE6Dup3N5NoCI7uASaIStYpbRbMa/uxK+BnzxpamQX9cmV20jbpd88lpRWD9UUFsmvk 8q0yCZVN1v5tPQB/1Kzd1voTBfsUAHnrOaEx24VOkfVw4d2pycaFELq2uwAAJX9Nkug6h902bDH dh+pmqiQShOAEr51vAy3d6Mw= X-Received: by 127.0.0.2 with SMTP id hvsWYY7687511xrZ2EBHUJrp; Sun, 08 Oct 2023 17:08:18 -0700 X-Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) by mx.groups.io with SMTP id smtpd.web10.50232.1696810091827614370 for ; Sun, 08 Oct 2023 17:08:11 -0700 X-Received: by mail-io1-f44.google.com with SMTP id ca18e2360f4ac-79fb64b5265so175819939f.1 for ; Sun, 08 Oct 2023 17:08:11 -0700 (PDT) X-Gm-Message-State: BB6qlGU8tCRJzwBeyGFwxcvvx7686176AA= X-Google-Smtp-Source: AGHT+IG2tRvZSgqhKuAqzfYWQbl59f0dmaQF4uPvTubbekh4PzuXDwPP6YvHV3jHLMjdCAoluXZ5bQ== X-Received: by 2002:a05:6e02:1521:b0:34a:c618:b904 with SMTP id i1-20020a056e02152100b0034ac618b904mr17483853ilu.22.1696810090976; Sun, 08 Oct 2023 17:08:10 -0700 (PDT) X-Received: from localhost.localdomain ([50.46.253.1]) by smtp.gmail.com with ESMTPSA id t20-20020a62ea14000000b0068fcc7f6b00sm5048320pfh.74.2023.10.08.17.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 17:08:10 -0700 (PDT) From: "Taylor Beebe" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Gerd Hoffmann Subject: [edk2-devel] [PATCH v5 24/28] ArmVirtPkg: Apply Memory Protections via SetMemoryProtectionsLib Date: Sun, 8 Oct 2023 17:07:36 -0700 Message-ID: <20231009000742.1792-25-taylor.d.beebe@gmail.com> In-Reply-To: <20231009000742.1792-1-taylor.d.beebe@gmail.com> References: <20231009000742.1792-1-taylor.d.beebe@gmail.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: 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,taylor.d.beebe@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="EHgA/cE6"; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none) Set the memory protections on Arm virtual platforms. Because the QemuFg parser is not currently available in ArmVirtPkg, use the GrubCompat profile by default. Signed-off-by: Taylor Beebe Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Sami Mujawar Cc: Gerd Hoffmann --- ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c | 7 +++++++ ArmVirtPkg/ArmVirtPkg.dec | 7 +++++++ ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf | 3 +++ 3 files changed, 17 insertions(+) diff --git a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c index ef88a9df1d62..aaf2af9abccf 100644 --- a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c +++ b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -100,5 +101,11 @@ InitializeMemory ( ); ASSERT_EFI_ERROR (Status); + ASSERT (FixedPcdGet8 (PcdDxeMemoryProtectionProfile) < DxeMemoryProtectionSettingsMax); + SetDxeMemoryProtectionSettings ( + NULL, + (DXE_MEMORY_PROTECTION_PROFILE_INDEX)FixedPcdGet8 (PcdDxeMemoryProtectionProfile) + ); + return Status; } diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index 4645c91a8375..d90e492fa56a 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -67,3 +67,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule] # Cloud Hypervisor has no other way to pass Rsdp address to the guest except use a PCD. # gArmVirtTokenSpaceGuid.PcdCloudHvAcpiRsdpBaseAddress|0x0|UINT64|0x00000005 + + ## + # This value will be used to determine the level of memory protection each boot. + # See DXE_MEMORY_PROTECTION_PROFILE_INDEX in + # MdeModulePkg/Include/Library/SetMemoryProtectionsLib.h for index definitions. + # + gArmVirtTokenSpaceGuid.PcdDxeMemoryProtectionProfile|0x3|UINT8|0x00000006 diff --git a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf index 2039f71a0ebe..9cfd10bc44ef 100644 --- a/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf +++ b/ArmVirtPkg/MemoryInitPei/MemoryInitPeim.inf @@ -26,6 +26,7 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec ArmPkg/ArmPkg.dec ArmPlatformPkg/ArmPlatformPkg.dec + ArmVirtPkg/ArmVirtPkg.dec [LibraryClasses] PeimEntryPoint @@ -34,6 +35,7 @@ [LibraryClasses] ArmLib ArmPlatformLib MemoryInitPeiLib + SetMemoryProtectionsLib [Guids] gEfiMemoryTypeInformationGuid @@ -44,6 +46,7 @@ [FeaturePcd] [FixedPcd] gArmTokenSpaceGuid.PcdSystemMemoryBase gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize + gArmVirtTokenSpaceGuid.PcdDxeMemoryProtectionProfile gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS -- 2.42.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109429): https://edk2.groups.io/g/devel/message/109429 Mute This Topic: https://groups.io/mt/101843368/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-