Skip to content

Commit c26a535

Browse files
committed
Merge tag 'for-3.20' of http://git.linaro.org/people/ard.biesheuvel/linux-arm into upstream
UEFI updates for arm64 This series consists of a reimplementation of the virtual remapping of UEFI Runtime Services in a way that is stable across kexec, including the required preparatory refactoring and other work to set the stage, and some cleaning up afterwards to remove boot services memory and identitity map handling that has now become redundant. * tag 'for-3.20' of http://git.linaro.org/people/ard.biesheuvel/linux-arm: arm64/efi: remove idmap manipulations from UEFI code arm64/efi: remove free_boot_services() and friends arm64/efi: move SetVirtualAddressMap() to UEFI stub arm64/efi: set EFI_ALLOC_ALIGN to 64 KB efi: efistub: allow allocation alignment larger than EFI_PAGE_SIZE efi: split off remapping code from efi_config_init() arm64/mm: add create_pgd_mapping() to create private page tables arm64/mm: add explicit struct_mm argument to __create_mapping()
2 parents eaa27f3 + 9679be1 commit c26a535

File tree

12 files changed

+362
-325
lines changed

12 files changed

+362
-325
lines changed

arch/arm64/include/asm/efi.h

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,35 @@
66

77
#ifdef CONFIG_EFI
88
extern void efi_init(void);
9-
extern void efi_idmap_init(void);
9+
extern void efi_virtmap_init(void);
1010
#else
1111
#define efi_init()
12-
#define efi_idmap_init()
12+
#define efi_virtmap_init()
1313
#endif
1414

1515
#define efi_call_virt(f, ...) \
1616
({ \
17-
efi_##f##_t *__f = efi.systab->runtime->f; \
17+
efi_##f##_t *__f; \
1818
efi_status_t __s; \
1919
\
2020
kernel_neon_begin(); \
21+
efi_virtmap_load(); \
22+
__f = efi.systab->runtime->f; \
2123
__s = __f(__VA_ARGS__); \
24+
efi_virtmap_unload(); \
2225
kernel_neon_end(); \
2326
__s; \
2427
})
2528

2629
#define __efi_call_virt(f, ...) \
2730
({ \
28-
efi_##f##_t *__f = efi.systab->runtime->f; \
31+
efi_##f##_t *__f; \
2932
\
3033
kernel_neon_begin(); \
34+
efi_virtmap_load(); \
35+
__f = efi.systab->runtime->f; \
3136
__f(__VA_ARGS__); \
37+
efi_virtmap_unload(); \
3238
kernel_neon_end(); \
3339
})
3440

@@ -44,4 +50,28 @@ extern void efi_idmap_init(void);
4450

4551
#define efi_call_early(f, ...) sys_table_arg->boottime->f(__VA_ARGS__)
4652

53+
#define EFI_ALLOC_ALIGN SZ_64K
54+
55+
/*
56+
* On ARM systems, virtually remapped UEFI runtime services are set up in three
57+
* distinct stages:
58+
* - The stub retrieves the final version of the memory map from UEFI, populates
59+
* the virt_addr fields and calls the SetVirtualAddressMap() [SVAM] runtime
60+
* service to communicate the new mapping to the firmware (Note that the new
61+
* mapping is not live at this time)
62+
* - During early boot, the page tables are allocated and populated based on the
63+
* virt_addr fields in the memory map, but only if all descriptors with the
64+
* EFI_MEMORY_RUNTIME attribute have a non-zero value for virt_addr. If this
65+
* succeeds, the EFI_VIRTMAP flag is set to indicate that the virtual mappings
66+
* have been installed successfully.
67+
* - During an early initcall(), the UEFI Runtime Services are enabled and the
68+
* EFI_RUNTIME_SERVICES bit set if some conditions are met, i.e., we need a
69+
* non-early mapping of the UEFI system table, and we need to have the virtmap
70+
* installed.
71+
*/
72+
#define EFI_VIRTMAP EFI_ARCH_1
73+
74+
void efi_virtmap_load(void);
75+
void efi_virtmap_unload(void);
76+
4777
#endif /* _ASM_EFI_H */

arch/arm64/include/asm/mmu.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ extern void paging_init(void);
3131
extern void setup_mm_for_reboot(void);
3232
extern void __iomem *early_io_map(phys_addr_t phys, unsigned long virt);
3333
extern void init_mem_pgprot(void);
34-
/* create an identity mapping for memory (or io if map_io is true) */
35-
extern void create_id_mapping(phys_addr_t addr, phys_addr_t size, int map_io);
34+
extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
35+
unsigned long virt, phys_addr_t size,
36+
pgprot_t prot);
3637

3738
#endif

arch/arm64/include/asm/pgtable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ static inline pmd_t pte_pmd(pte_t pte)
264264
return __pmd(pte_val(pte));
265265
}
266266

267+
static inline pgprot_t mk_sect_prot(pgprot_t prot)
268+
{
269+
return __pgprot(pgprot_val(prot) & ~PTE_TABLE_BIT);
270+
}
271+
267272
/*
268273
* THP definitions.
269274
*/

0 commit comments

Comments
 (0)