Merge tag 'usb-ci-v5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/peter...
[linux-block.git] / arch / x86 / platform / efi / efi_32.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
1da177e4
LT
2/*
3 * Extensible Firmware Interface
4 *
5 * Based on Extensible Firmware Interface Specification version 1.0
6 *
7 * Copyright (C) 1999 VA Linux Systems
8 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
9 * Copyright (C) 1999-2002 Hewlett-Packard Co.
10 * David Mosberger-Tang <davidm@hpl.hp.com>
11 * Stephane Eranian <eranian@hpl.hp.com>
12 *
13 * All EFI Runtime Services are not implemented yet as EFI only
14 * supports physical mode addressing on SoftSDV. This is to be fixed
15 * in a future version. --drummond 1999-07-20
16 *
17 * Implemented EFI runtime services and virtual mode calls. --davidm
18 *
19 * Goutham Rao: <goutham.rao@intel.com>
20 * Skip non-WB memory and ignore empty memory ranges.
21 */
22
1da177e4 23#include <linux/kernel.h>
1da177e4 24#include <linux/types.h>
1da177e4 25#include <linux/ioport.h>
1da177e4 26#include <linux/efi.h>
65fddcfc 27#include <linux/pgtable.h>
1da177e4 28
1da177e4 29#include <asm/io.h>
783ac47c 30#include <asm/desc.h>
1da177e4 31#include <asm/page.h>
1da177e4 32#include <asm/tlbflush.h>
cc7e73f3 33#include <asm/efi.h>
1da177e4 34
1da177e4
LT
35/*
36 * To make EFI call EFI runtime service in physical addressing mode we need
23a0d4e8
IM
37 * prolog/epilog before/after the invocation to claim the EFI runtime service
38 * handler exclusively and to duplicate a memory mapping in low memory space,
39 * say 0 - 3G.
1da177e4 40 */
1da177e4 41
67a9108e
MF
42int __init efi_alloc_page_tables(void)
43{
44 return 0;
45}
46
d2f7cbe7 47void efi_sync_low_kernel_mappings(void) {}
ac81d3de
SP
48
49void __init efi_dump_pagetable(void)
50{
51#ifdef CONFIG_EFI_PGT_DUMP
e455248d 52 ptdump_walk_pgd_level(NULL, &init_mm);
ac81d3de
SP
53#endif
54}
55
4e78eb05 56int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
b7b898ae
BP
57{
58 return 0;
59}
d2f7cbe7
BP
60
61void __init efi_map_region(efi_memory_desc_t *md)
62{
63 old_map_region(md);
64}
65
3b266496 66void __init efi_map_region_fixed(efi_memory_desc_t *md) {}
1fec0533 67void __init parse_efi_setup(u64 phys_addr, u32 data_len) {}
3b266496 68
59f2a619
AB
69efi_status_t efi_call_svam(efi_runtime_services_t * const *,
70 u32, u32, u32, void *, u32);
69829470
AB
71
72efi_status_t __init efi_set_virtual_address_map(unsigned long memory_map_size,
73 unsigned long descriptor_size,
74 u32 descriptor_version,
59f2a619
AB
75 efi_memory_desc_t *virtual_map,
76 unsigned long systab_phys)
1da177e4 77{
59f2a619 78 const efi_system_table_t *systab = (efi_system_table_t *)systab_phys;
6b68f01b 79 struct desc_ptr gdt_descr;
69829470
AB
80 efi_status_t status;
81 unsigned long flags;
744937b0 82 pgd_t *save_pgd;
1da177e4 83
744937b0
IM
84 /* Current pgd is swapper_pg_dir, we'll restore it later: */
85 save_pgd = swapper_pg_dir;
6d3e32e6 86 load_cr3(initial_page_table);
8b2cb7a8 87 __flush_tlb_all();
1da177e4 88
3fa1cabb 89 gdt_descr.address = get_cpu_gdt_paddr(0);
4fbb5968
RR
90 gdt_descr.size = GDT_SIZE - 1;
91 load_gdt(&gdt_descr);
744937b0 92
69829470
AB
93 /* Disable interrupts around EFI calls: */
94 local_irq_save(flags);
59f2a619 95 status = efi_call_svam(&systab->runtime,
69829470 96 memory_map_size, descriptor_size,
59f2a619
AB
97 descriptor_version, virtual_map,
98 __pa(&efi.runtime));
69829470 99 local_irq_restore(flags);
1da177e4 100
cf40361e 101 load_fixmap_gdt(0);
744937b0 102 load_cr3(save_pgd);
8b2cb7a8 103 __flush_tlb_all();
69829470
AB
104
105 return status;
1da177e4 106}
c55d016f 107
6d0cc887 108void __init efi_runtime_update_mappings(void)
c55d016f
BP
109{
110 if (__supported_pte_mask & _PAGE_NX)
111 runtime_code_page_mkexec();
112}