Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2eec5ded authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Ingo Molnar
Browse files

efi/arm-init: Use read-only early mappings



The early mappings of the EFI system table contents and the UEFI memory
map are read-only from the OS point of view. So map them read-only to
protect them from inadvertent modification.

Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarMatt Fleming <matt@codeblueprint.co.uk>
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/1455712566-16727-8-git-send-email-matt@codeblueprint.co.uk


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 07e83dbb
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -61,7 +61,7 @@ static int __init uefi_init(void)
	char vendor[100] = "unknown";
	char vendor[100] = "unknown";
	int i, retval;
	int i, retval;


	efi.systab = early_memremap(efi_system_table,
	efi.systab = early_memremap_ro(efi_system_table,
				       sizeof(efi_system_table_t));
				       sizeof(efi_system_table_t));
	if (efi.systab == NULL) {
	if (efi.systab == NULL) {
		pr_warn("Unable to map EFI system table.\n");
		pr_warn("Unable to map EFI system table.\n");
@@ -86,7 +86,7 @@ static int __init uefi_init(void)
			efi.systab->hdr.revision & 0xffff);
			efi.systab->hdr.revision & 0xffff);


	/* Show what we know for posterity */
	/* Show what we know for posterity */
	c16 = early_memremap(efi_to_phys(efi.systab->fw_vendor),
	c16 = early_memremap_ro(efi_to_phys(efi.systab->fw_vendor),
				sizeof(vendor) * sizeof(efi_char16_t));
				sizeof(vendor) * sizeof(efi_char16_t));
	if (c16) {
	if (c16) {
		for (i = 0; i < (int) sizeof(vendor) - 1 && *c16; ++i)
		for (i = 0; i < (int) sizeof(vendor) - 1 && *c16; ++i)
@@ -100,7 +100,7 @@ static int __init uefi_init(void)
		efi.systab->hdr.revision & 0xffff, vendor);
		efi.systab->hdr.revision & 0xffff, vendor);


	table_size = sizeof(efi_config_table_64_t) * efi.systab->nr_tables;
	table_size = sizeof(efi_config_table_64_t) * efi.systab->nr_tables;
	config_tables = early_memremap(efi_to_phys(efi.systab->tables),
	config_tables = early_memremap_ro(efi_to_phys(efi.systab->tables),
					  table_size);
					  table_size);
	if (config_tables == NULL) {
	if (config_tables == NULL) {
		pr_warn("Unable to map EFI config table array.\n");
		pr_warn("Unable to map EFI config table array.\n");
@@ -185,7 +185,7 @@ void __init efi_init(void)
	efi_system_table = params.system_table;
	efi_system_table = params.system_table;


	memmap.phys_map = params.mmap;
	memmap.phys_map = params.mmap;
	memmap.map = early_memremap(params.mmap, params.mmap_size);
	memmap.map = early_memremap_ro(params.mmap, params.mmap_size);
	if (memmap.map == NULL) {
	if (memmap.map == NULL) {
		/*
		/*
		* If we are booting via UEFI, the UEFI memory map is the only
		* If we are booting via UEFI, the UEFI memory map is the only