2019-06-04 08:11:33 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-09-24 20:49:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Linaro Ltd <ard.biesheuvel@linaro.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ASM_ARM_EFI_H
|
|
|
|
#define __ASM_ARM_EFI_H
|
|
|
|
|
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
#include <asm/cachetype.h>
|
|
|
|
#include <asm/early_ioremap.h>
|
|
|
|
#include <asm/fixmap.h>
|
|
|
|
#include <asm/highmem.h>
|
|
|
|
#include <asm/mach/map.h>
|
|
|
|
#include <asm/mmu_context.h>
|
2016-04-25 20:07:10 +00:00
|
|
|
#include <asm/ptrace.h>
|
2015-09-24 20:49:52 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_EFI
|
|
|
|
void efi_init(void);
|
|
|
|
|
|
|
|
int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
|
2016-04-25 20:06:42 +00:00
|
|
|
int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
|
2015-09-24 20:49:52 +00:00
|
|
|
|
2016-04-25 20:07:05 +00:00
|
|
|
#define arch_efi_call_virt_setup() efi_virtmap_load()
|
|
|
|
#define arch_efi_call_virt_teardown() efi_virtmap_unload()
|
2015-09-24 20:49:52 +00:00
|
|
|
|
2016-06-25 07:20:27 +00:00
|
|
|
#define arch_efi_call_virt(p, f, args...) \
|
2015-09-24 20:49:52 +00:00
|
|
|
({ \
|
|
|
|
efi_##f##_t *__f; \
|
2016-06-25 07:20:27 +00:00
|
|
|
__f = p->f; \
|
2016-04-25 20:07:05 +00:00
|
|
|
__f(args); \
|
2015-09-24 20:49:52 +00:00
|
|
|
})
|
|
|
|
|
2016-04-25 20:07:10 +00:00
|
|
|
#define ARCH_EFI_IRQ_FLAGS_MASK \
|
|
|
|
(PSR_J_BIT | PSR_E_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | \
|
|
|
|
PSR_T_BIT | MODE_MASK)
|
|
|
|
|
2015-09-24 20:49:52 +00:00
|
|
|
static inline void efi_set_pgd(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
check_and_switch_context(mm, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void efi_virtmap_load(void);
|
|
|
|
void efi_virtmap_unload(void);
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define efi_init()
|
|
|
|
#endif /* CONFIG_EFI */
|
|
|
|
|
2015-09-24 03:17:54 +00:00
|
|
|
/* arch specific definitions used by the stub code */
|
|
|
|
|
2019-12-24 15:10:19 +00:00
|
|
|
struct screen_info *alloc_screen_info(void);
|
|
|
|
void free_screen_info(struct screen_info *si);
|
2016-04-25 20:06:53 +00:00
|
|
|
|
2015-09-24 03:17:54 +00:00
|
|
|
/*
|
|
|
|
* A reasonable upper bound for the uncompressed kernel size is 32 MBytes,
|
|
|
|
* so we will reserve that amount of memory. We have no easy way to tell what
|
|
|
|
* the actuall size of code + data the uncompressed kernel will use.
|
|
|
|
* If this is insufficient, the decompressor will relocate itself out of the
|
|
|
|
* way before performing the decompression.
|
|
|
|
*/
|
|
|
|
#define MAX_UNCOMP_KERNEL_SIZE SZ_32M
|
|
|
|
|
|
|
|
/*
|
2020-11-12 14:42:27 +00:00
|
|
|
* phys-to-virt patching requires that the physical to virtual offset is a
|
|
|
|
* multiple of 2 MiB. However, using an alignment smaller than TEXT_OFFSET
|
|
|
|
* here throws off the memory allocation logic, so let's use the lowest power
|
|
|
|
* of two greater than 2 MiB and greater than TEXT_OFFSET.
|
2015-09-24 03:17:54 +00:00
|
|
|
*/
|
2020-12-13 15:07:03 +00:00
|
|
|
#define EFI_PHYS_ALIGN max(UL(SZ_2M), roundup_pow_of_two(TEXT_OFFSET))
|
2017-04-04 16:02:37 +00:00
|
|
|
|
|
|
|
/* on ARM, the initrd should be loaded in a lowmem region */
|
2020-09-10 14:09:45 +00:00
|
|
|
static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr)
|
2017-04-04 16:02:37 +00:00
|
|
|
{
|
2020-11-12 14:42:27 +00:00
|
|
|
return round_down(image_addr, SZ_4M) + SZ_512M;
|
2017-04-04 16:02:37 +00:00
|
|
|
}
|
2015-09-24 03:17:54 +00:00
|
|
|
|
efi/libstub: arm: Print CPU boot mode and MMU state at boot
On 32-bit ARM, we may boot at HYP mode, or with the MMU and caches off
(or both), even though the EFI spec does not actually support this.
While booting at HYP mode is something we might tolerate, fiddling
with the caches is a more serious issue, as disabling the caches is
tricky to do safely from C code, and running without the Dcache makes
it impossible to support unaligned memory accesses, which is another
explicit requirement imposed by the EFI spec.
So take note of the CPU mode and MMU state in the EFI stub diagnostic
output so that we can easily diagnose any issues that may arise from
this. E.g.,
EFI stub: Entering in SVC mode with MMU enabled
Also, capture the CPSR and SCTLR system register values at EFI stub
entry, and after ExitBootServices() returns, and check whether the
MMU and Dcache were disabled at any point. If this is the case, a
diagnostic message like the following will be emitted:
efi: [Firmware Bug]: EFI stub was entered with MMU and Dcache disabled, please fix your firmware!
efi: CPSR at EFI stub entry : 0x600001d3
efi: SCTLR at EFI stub entry : 0x00c51838
efi: CPSR after ExitBootServices() : 0x600001d3
efi: SCTLR after ExitBootServices(): 0x00c50838
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
2020-06-07 13:41:35 +00:00
|
|
|
struct efi_arm_entry_state {
|
|
|
|
u32 cpsr_before_ebs;
|
|
|
|
u32 sctlr_before_ebs;
|
|
|
|
u32 cpsr_after_ebs;
|
|
|
|
u32 sctlr_after_ebs;
|
|
|
|
};
|
|
|
|
|
2020-12-07 17:40:53 +00:00
|
|
|
static inline void efi_capsule_flush_cache_range(void *addr, int size)
|
|
|
|
{
|
|
|
|
__cpuc_flush_dcache_area(addr, size);
|
|
|
|
}
|
|
|
|
|
2015-09-24 20:49:52 +00:00
|
|
|
#endif /* _ASM_ARM_EFI_H */
|