Skip to content

Commit 270315b

Browse files
committed
Merge tag 'riscv-for-linus-5.10-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Palmer Dabbelt: "A handful of cleanups and new features: - A handful of cleanups for our page fault handling - Improvements to how we fill out cacheinfo - Support for EFI-based systems" * tag 'riscv-for-linus-5.10-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (22 commits) RISC-V: Add page table dump support for uefi RISC-V: Add EFI runtime services RISC-V: Add EFI stub support. RISC-V: Add PE/COFF header for EFI stub RISC-V: Implement late mapping page table allocation functions RISC-V: Add early ioremap support RISC-V: Move DT mapping outof fixmap RISC-V: Fix duplicate included thread_info.h riscv/mm/fault: Set FAULT_FLAG_INSTRUCTION flag in do_page_fault() riscv/mm/fault: Fix inline placement in vmalloc_fault() declaration riscv: Add cache information in AUX vector riscv: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO riscv: Set more data to cacheinfo riscv/mm/fault: Move access error check to function riscv/mm/fault: Move FAULT_FLAG_WRITE handling in do_page_fault() riscv/mm/fault: Simplify mm_fault_error() riscv/mm/fault: Move fault error handling to mm_fault_error() riscv/mm/fault: Simplify fault error handling riscv/mm/fault: Move vmalloc fault handling to vmalloc_fault() riscv/mm/fault: Move bad area handling to bad_area() ...
2 parents d3876ff + de22d21 commit 270315b

31 files changed

+1212
-241
lines changed

arch/riscv/Kconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ config RISCV
3838
select GENERIC_ARCH_TOPOLOGY if SMP
3939
select GENERIC_ATOMIC64 if !64BIT
4040
select GENERIC_CLOCKEVENTS
41+
select GENERIC_EARLY_IOREMAP
4142
select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
4243
select GENERIC_IOREMAP
4344
select GENERIC_IRQ_MULTI_HANDLER
@@ -388,6 +389,28 @@ config CMDLINE_FORCE
388389

389390
endchoice
390391

392+
config EFI_STUB
393+
bool
394+
395+
config EFI
396+
bool "UEFI runtime support"
397+
depends on OF
398+
select LIBFDT
399+
select UCS2_STRING
400+
select EFI_PARAMS_FROM_FDT
401+
select EFI_STUB
402+
select EFI_GENERIC_STUB
403+
select EFI_RUNTIME_WRAPPERS
404+
select RISCV_ISA_C
405+
depends on MMU
406+
default y
407+
help
408+
This option provides support for runtime services provided
409+
by UEFI firmware (such as non-volatile variables, realtime
410+
clock, and platform reset). A UEFI stub is also provided to
411+
allow the kernel to be booted as an EFI application. This
412+
is only useful on systems that have UEFI firmware.
413+
391414
endmenu
392415

393416
config BUILTIN_DTB
@@ -400,3 +423,5 @@ menu "Power management options"
400423
source "kernel/power/Kconfig"
401424

402425
endmenu
426+
427+
source "drivers/firmware/Kconfig"

arch/riscv/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ head-y := arch/riscv/kernel/head.o
8080
core-y += arch/riscv/
8181

8282
libs-y += arch/riscv/lib/
83+
libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
8384

8485
PHONY += vdso_install
8586
vdso_install:

arch/riscv/configs/defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,4 @@ CONFIG_DEBUG_BLOCK_EXT_DEVT=y
130130
# CONFIG_RUNTIME_TESTING_MENU is not set
131131
CONFIG_MEMTEST=y
132132
# CONFIG_SYSFS_SYSCALL is not set
133+
CONFIG_EFI=y

arch/riscv/include/asm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
generic-y += early_ioremap.h
23
generic-y += extable.h
34
generic-y += flat.h
45
generic-y += kvm_para.h

arch/riscv/include/asm/cacheinfo.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2020 SiFive
4+
*/
25

36
#ifndef _ASM_RISCV_CACHEINFO_H
47
#define _ASM_RISCV_CACHEINFO_H
@@ -11,5 +14,7 @@ struct riscv_cacheinfo_ops {
1114
};
1215

1316
void riscv_set_cacheinfo_ops(struct riscv_cacheinfo_ops *ops);
17+
uintptr_t get_cache_size(u32 level, enum cache_type type);
18+
uintptr_t get_cache_geometry(u32 level, enum cache_type type);
1419

1520
#endif /* _ASM_RISCV_CACHEINFO_H */

arch/riscv/include/asm/efi.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2020 Western Digital Corporation or its affiliates.
4+
*/
5+
#ifndef _ASM_EFI_H
6+
#define _ASM_EFI_H
7+
8+
#include <asm/csr.h>
9+
#include <asm/io.h>
10+
#include <asm/mmu_context.h>
11+
#include <asm/ptrace.h>
12+
#include <asm/tlbflush.h>
13+
14+
#ifdef CONFIG_EFI
15+
extern void efi_init(void);
16+
#else
17+
#define efi_init()
18+
#endif
19+
20+
int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
21+
int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);
22+
23+
#define arch_efi_call_virt_setup() efi_virtmap_load()
24+
#define arch_efi_call_virt_teardown() efi_virtmap_unload()
25+
26+
#define arch_efi_call_virt(p, f, args...) p->f(args)
27+
28+
#define ARCH_EFI_IRQ_FLAGS_MASK (SR_IE | SR_SPIE)
29+
30+
/* on RISC-V, the FDT may be located anywhere in system RAM */
31+
static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr)
32+
{
33+
return ULONG_MAX;
34+
}
35+
36+
/* Load initrd at enough distance from DRAM start */
37+
static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr)
38+
{
39+
return image_addr + SZ_256M;
40+
}
41+
42+
#define alloc_screen_info(x...) (&screen_info)
43+
44+
static inline void free_screen_info(struct screen_info *si)
45+
{
46+
}
47+
48+
static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
49+
{
50+
}
51+
52+
void efi_virtmap_load(void);
53+
void efi_virtmap_unload(void);
54+
55+
#endif /* _ASM_EFI_H */

arch/riscv/include/asm/elf.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <uapi/asm/elf.h>
1212
#include <asm/auxvec.h>
1313
#include <asm/byteorder.h>
14+
#include <asm/cacheinfo.h>
1415

1516
/*
1617
* These are used to set parameters in the core dumps.
@@ -61,6 +62,18 @@ extern unsigned long elf_hwcap;
6162
do { \
6263
NEW_AUX_ENT(AT_SYSINFO_EHDR, \
6364
(elf_addr_t)current->mm->context.vdso); \
65+
NEW_AUX_ENT(AT_L1I_CACHESIZE, \
66+
get_cache_size(1, CACHE_TYPE_INST)); \
67+
NEW_AUX_ENT(AT_L1I_CACHEGEOMETRY, \
68+
get_cache_geometry(1, CACHE_TYPE_INST)); \
69+
NEW_AUX_ENT(AT_L1D_CACHESIZE, \
70+
get_cache_size(1, CACHE_TYPE_DATA)); \
71+
NEW_AUX_ENT(AT_L1D_CACHEGEOMETRY, \
72+
get_cache_geometry(1, CACHE_TYPE_DATA)); \
73+
NEW_AUX_ENT(AT_L2_CACHESIZE, \
74+
get_cache_size(2, CACHE_TYPE_UNIFIED)); \
75+
NEW_AUX_ENT(AT_L2_CACHEGEOMETRY, \
76+
get_cache_geometry(2, CACHE_TYPE_UNIFIED)); \
6477
} while (0)
6578
#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
6679
struct linux_binprm;

arch/riscv/include/asm/fixmap.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,24 @@
2222
*/
2323
enum fixed_addresses {
2424
FIX_HOLE,
25-
#define FIX_FDT_SIZE SZ_1M
26-
FIX_FDT_END,
27-
FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1,
2825
FIX_PTE,
2926
FIX_PMD,
3027
FIX_TEXT_POKE1,
3128
FIX_TEXT_POKE0,
3229
FIX_EARLYCON_MEM_BASE,
30+
31+
__end_of_permanent_fixed_addresses,
32+
/*
33+
* Temporary boot-time mappings, used by early_ioremap(),
34+
* before ioremap() is functional.
35+
*/
36+
#define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE)
37+
#define FIX_BTMAPS_SLOTS 7
38+
#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS)
39+
40+
FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
41+
FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1,
42+
3343
__end_of_fixed_addresses
3444
};
3545

arch/riscv/include/asm/io.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/types.h>
1515
#include <linux/pgtable.h>
1616
#include <asm/mmiowb.h>
17+
#include <asm/early_ioremap.h>
1718

1819
/*
1920
* MMIO access functions are separated out to break dependency cycles

arch/riscv/include/asm/mmu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ typedef struct {
2020
#endif
2121
} mm_context_t;
2222

23+
void __init create_pgd_mapping(pgd_t *pgdp, uintptr_t va, phys_addr_t pa,
24+
phys_addr_t sz, pgprot_t prot);
2325
#endif /* __ASSEMBLY__ */
2426

2527
#endif /* _ASM_RISCV_MMU_H */

0 commit comments

Comments
 (0)