* [edk2-platforms] Platform/Loongson: Pre-allocate 0-4K memory during the Pei phase
@ 2023-06-01 11:19 xianglai
2023-06-06 1:28 ` [edk2-devel] " Chao Li
0 siblings, 1 reply; 2+ messages in thread
From: xianglai @ 2023-06-01 11:19 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Bibo Mao, Chao Li, Leif Lindholm, Liming Gao,
Michael D Kinney
When 0 address protection is enabled,
0-4k memory needs to be preallocated to
prevent UEFI applications from allocating use,
such as grub.
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Bibo Mao <maobibo@loongson.cn>
Cc: Chao Li <lichao@loongson.cn>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: xianglai li <lixianglai@loongson.cn>
---
.../LoongArchQemuPkg/PlatformPei/MemDetect.c | 13 +++++++++++++
.../LoongArchQemuPkg/PlatformPei/PlatformPei.inf | 1 +
2 files changed, 14 insertions(+)
diff --git a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c
index fad4cff8d8..7e6a4a3aa9 100644
--- a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c
+++ b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c
@@ -101,4 +101,17 @@ InitializeRamRegions (
AddMemoryRangeHob ( pEntry->BaseAddr, pEntry->BaseAddr + pEntry->Length);
}
+
+ //
+ //When 0 address protection is enabled,
+ //0-4k memory needs to be preallocated to prevent UEFI applications from allocating use,
+ //such as grub
+ //
+ if (PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT0) {
+ BuildMemoryAllocationHob (
+ 0,
+ EFI_PAGE_SIZE,
+ EfiBootServicesData
+ );
+ }
}
diff --git a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf
index 268efac585..6cc3513b63 100644
--- a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf
+++ b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf
@@ -59,6 +59,7 @@
gLoongArchQemuPkgTokenSpaceGuid.PcdDeviceTreeBase
gLoongArchQemuPkgTokenSpaceGuid.PcdDeviceTreePadding
gLoongArchQemuPkgTokenSpaceGuid.PcdRtcBaseAddress
+ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask
[FixedPcd]
gLoongArchQemuPkgTokenSpaceGuid.PcdFlashDxeFvBase
--
2.39.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [edk2-devel] [edk2-platforms] Platform/Loongson: Pre-allocate 0-4K memory during the Pei phase
2023-06-01 11:19 [edk2-platforms] Platform/Loongson: Pre-allocate 0-4K memory during the Pei phase xianglai
@ 2023-06-06 1:28 ` Chao Li
0 siblings, 0 replies; 2+ messages in thread
From: Chao Li @ 2023-06-06 1:28 UTC (permalink / raw)
To: devel, lixianglai
Cc: Ard Biesheuvel, Bibo Mao, Leif Lindholm, Liming Gao,
Michael D Kinney
[-- Attachment #1: Type: text/plain, Size: 2233 bytes --]
Reviewed-by: Chao Li <lichao@loongson.cn>
Thanks,
Chao
在 2023/6/1 19:19, xianglai 写道:
> When 0 address protection is enabled,
> 0-4k memory needs to be preallocated to
> prevent UEFI applications from allocating use,
> such as grub.
>
> Cc: Ard Biesheuvel<ardb+tianocore@kernel.org>
> Cc: Bibo Mao<maobibo@loongson.cn>
> Cc: Chao Li<lichao@loongson.cn>
> Cc: Leif Lindholm<quic_llindhol@quicinc.com>
> Cc: Liming Gao<gaoliming@byosoft.com.cn>
> Cc: Michael D Kinney<michael.d.kinney@intel.com>
> Signed-off-by: xianglai li<lixianglai@loongson.cn>
> ---
> .../LoongArchQemuPkg/PlatformPei/MemDetect.c | 13 +++++++++++++
> .../LoongArchQemuPkg/PlatformPei/PlatformPei.inf | 1 +
> 2 files changed, 14 insertions(+)
>
> diff --git a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c
> index fad4cff8d8..7e6a4a3aa9 100644
> --- a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c
> +++ b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c
> @@ -101,4 +101,17 @@ InitializeRamRegions (
>
> AddMemoryRangeHob ( pEntry->BaseAddr, pEntry->BaseAddr + pEntry->Length);
> }
> +
> + //
> + //When 0 address protection is enabled,
> + //0-4k memory needs to be preallocated to prevent UEFI applications from allocating use,
> + //such as grub
> + //
> + if (PcdGet8 (PcdNullPointerDetectionPropertyMask) & BIT0) {
> + BuildMemoryAllocationHob (
> + 0,
> + EFI_PAGE_SIZE,
> + EfiBootServicesData
> + );
> + }
> }
> diff --git a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf
> index 268efac585..6cc3513b63 100644
> --- a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf
> +++ b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf
> @@ -59,6 +59,7 @@
> gLoongArchQemuPkgTokenSpaceGuid.PcdDeviceTreeBase
> gLoongArchQemuPkgTokenSpaceGuid.PcdDeviceTreePadding
> gLoongArchQemuPkgTokenSpaceGuid.PcdRtcBaseAddress
> + gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask
>
> [FixedPcd]
> gLoongArchQemuPkgTokenSpaceGuid.PcdFlashDxeFvBase
[-- Attachment #2: Type: text/html, Size: 3464 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-06 1:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01 11:19 [edk2-platforms] Platform/Loongson: Pre-allocate 0-4K memory during the Pei phase xianglai
2023-06-06 1:28 ` [edk2-devel] " Chao Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox