efi_32.c 2.7 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0
L
Linus Torvalds 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*
 * Extensible Firmware Interface
 *
 * Based on Extensible Firmware Interface Specification version 1.0
 *
 * Copyright (C) 1999 VA Linux Systems
 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
 * Copyright (C) 1999-2002 Hewlett-Packard Co.
 *	David Mosberger-Tang <davidm@hpl.hp.com>
 *	Stephane Eranian <eranian@hpl.hp.com>
 *
 * All EFI Runtime Services are not implemented yet as EFI only
 * supports physical mode addressing on SoftSDV. This is to be fixed
 * in a future version.  --drummond 1999-07-20
 *
 * Implemented EFI runtime services and virtual mode calls.  --davidm
 *
 * Goutham Rao: <goutham.rao@intel.com>
 *	Skip non-WB memory and ignore empty memory ranges.
 */

#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/ioport.h>
#include <linux/efi.h>

#include <asm/io.h>
29
#include <asm/desc.h>
L
Linus Torvalds 已提交
30 31 32
#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/tlbflush.h>
H
Harvey Harrison 已提交
33
#include <asm/efi.h>
L
Linus Torvalds 已提交
34 35 36

/*
 * To make EFI call EFI runtime service in physical addressing mode we need
37 38 39
 * prolog/epilog before/after the invocation to claim the EFI runtime service
 * handler exclusively and to duplicate a memory mapping in low memory space,
 * say 0 - 3G.
L
Linus Torvalds 已提交
40 41
 */

42 43 44 45 46
int __init efi_alloc_page_tables(void)
{
	return 0;
}

47
void efi_sync_low_kernel_mappings(void) {}
48 49 50 51

void __init efi_dump_pagetable(void)
{
#ifdef CONFIG_EFI_PGT_DUMP
52
	ptdump_walk_pgd_level(NULL, &init_mm);
53 54 55
#endif
}

56
int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
57 58 59
{
	return 0;
}
60 61 62 63 64 65

void __init efi_map_region(efi_memory_desc_t *md)
{
	old_map_region(md);
}

66
void __init efi_map_region_fixed(efi_memory_desc_t *md) {}
67
void __init parse_efi_setup(u64 phys_addr, u32 data_len) {}
68

69 70
efi_status_t efi_call_svam(efi_set_virtual_address_map_t *__efiapi *,
			   u32, u32, u32, void *);
71 72 73 74 75

efi_status_t __init efi_set_virtual_address_map(unsigned long memory_map_size,
						unsigned long descriptor_size,
						u32 descriptor_version,
						efi_memory_desc_t *virtual_map)
L
Linus Torvalds 已提交
76
{
77
	struct desc_ptr gdt_descr;
78 79
	efi_status_t status;
	unsigned long flags;
80
	pgd_t *save_pgd;
L
Linus Torvalds 已提交
81

82 83
	/* Current pgd is swapper_pg_dir, we'll restore it later: */
	save_pgd = swapper_pg_dir;
84
	load_cr3(initial_page_table);
85
	__flush_tlb_all();
L
Linus Torvalds 已提交
86

87
	gdt_descr.address = get_cpu_gdt_paddr(0);
R
Rusty Russell 已提交
88 89
	gdt_descr.size = GDT_SIZE - 1;
	load_gdt(&gdt_descr);
90

91 92
	/* Disable interrupts around EFI calls: */
	local_irq_save(flags);
93
	status = efi_call_svam(&efi.systab->runtime->set_virtual_address_map,
94 95 96
			       memory_map_size, descriptor_size,
			       descriptor_version, virtual_map);
	local_irq_restore(flags);
L
Linus Torvalds 已提交
97

98
	load_fixmap_gdt(0);
99
	load_cr3(save_pgd);
100
	__flush_tlb_all();
101 102

	return status;
L
Linus Torvalds 已提交
103
}
B
Borislav Petkov 已提交
104

105
void __init efi_runtime_update_mappings(void)
B
Borislav Petkov 已提交
106 107 108 109
{
	if (__supported_pte_mask & _PAGE_NX)
		runtime_code_page_mkexec();
}