Commit 4159882e authored by Ma Wupeng's avatar Ma Wupeng Committed by Zheng Zengkai
Browse files

arm64: efi: Add fake memory support

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4PM01


CVE: NA

--------------------------------

Fake memory map is used for faking memory's attribute values.
Commit 0f96a99d ("efi: Add "efi_fake_mem" boot option") introduce the
efi_fake_mem function. Now it can support arm64 with this patch.
For example you can mark 0-6G memory as EFI_MEMORY_MORE_RELIABLE by adding
efi_fake_mem=6G@0:0x10000 in the bootarg. You find more info about
fake memmap in kernel-parameters.txt.

Variable memstart_addr is only confirmed after arm64_memblock_init(). So
efi_fake_memmap() is needed to add after arm64_memblock_init().

Otherwise:

efi_memmap_alloc
   memblock_phys_alloc
     kmemleak_alloc_phys
        kmemleak_alloc(__va(phys), size, min_count, gfp);

this __va() will convert phys to a fault va and lead to a kmemleak error.

Signed-off-by: default avatarMa Wupeng <mawupeng1@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 2e5602aa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1290,7 +1290,7 @@
			you are really sure that your UEFI does sane gc and
			fulfills the spec otherwise your board may brick.

	efi_fake_mem=	nn[KMG]@ss[KMG]:aa[,nn[KMG]@ss[KMG]:aa,..] [EFI; X86]
	efi_fake_mem=	nn[KMG]@ss[KMG]:aa[,nn[KMG]@ss[KMG]:aa,..] [EFI; X86; ARM64]
			Add arbitrary attribute to specific memory range by
			updating original EFI memory map.
			Region of memory which aa attribute is added to is
+2 −0
Original line number Diff line number Diff line
@@ -387,6 +387,8 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)

	arm64_memblock_init();

	efi_fake_memmap();

	paging_init();

	acpi_table_upgrade();
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ config EFI_RUNTIME_MAP

config EFI_FAKE_MEMMAP
	bool "Enable EFI fake memory map"
	depends on EFI && X86
	depends on EFI && (X86 || ARM64)
	default n
	help
	  Saying Y here will enable "efi_fake_mem" boot option.