Skip to content

Commit 0570bc8

Browse files
committed
Merge tag 'riscv/for-v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Paul Walmsley: - Hugepage support - "Image" header support for RISC-V kernel binaries, compatible with the current ARM64 "Image" header - Initial page table setup now split into two stages - CONFIG_SOC support (starting with SiFive SoCs) - Avoid reserving memory between RAM start and the kernel in setup_bootmem() - Enable high-res timers and dynamic tick in the RV64 defconfig - Remove long-deprecated gate area stubs - MAINTAINERS updates to switch to the newly-created shared RISC-V git tree, and to fix a get_maintainers.pl issue for patches involving SiFive E-mail addresses Also, one integration fix to resolve a build problem introduced during in the v5.3-rc1 merge window: - Fix build break after macro-to-function conversion in asm-generic/cacheflush.h * tag 'riscv/for-v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: fix build break after macro-to-function conversion in generic cacheflush.h RISC-V: Add an Image header that boot loader can parse. RISC-V: Setup initial page tables in two stages riscv: remove free_initrd_mem riscv: ccache: Remove unused variable riscv: Introduce huge page support for 32/64bit kernel x86, arm64: Move ARCH_WANT_HUGE_PMD_SHARE config in arch/Kconfig RISC-V: Fix memory reservation in setup_bootmem() riscv: defconfig: enable SOC_SIFIVE riscv: select SiFive platform drivers with SOC_SIFIVE arch: riscv: add config option for building SiFive's SoC resource riscv: Remove gate area stubs MAINTAINERS: change the arch/riscv git tree to the new shared tree MAINTAINERS: don't automatically patches involving SiFive to the linux-riscv list RISC-V: defconfig: Enable NO_HZ_IDLE and HIGH_RES_TIMERS
2 parents 0e2a5b5 + 2d69fbf commit 0570bc8

File tree

24 files changed

+620
-121
lines changed

24 files changed

+620
-121
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Boot image header in RISC-V Linux
2+
=============================================
3+
4+
Author: Atish Patra <[email protected]>
5+
Date : 20 May 2019
6+
7+
This document only describes the boot image header details for RISC-V Linux.
8+
The complete booting guide will be available at Documentation/riscv/booting.txt.
9+
10+
The following 64-byte header is present in decompressed Linux kernel image.
11+
12+
u32 code0; /* Executable code */
13+
u32 code1; /* Executable code */
14+
u64 text_offset; /* Image load offset, little endian */
15+
u64 image_size; /* Effective Image size, little endian */
16+
u64 flags; /* kernel flags, little endian */
17+
u32 version; /* Version of this header */
18+
u32 res1 = 0; /* Reserved */
19+
u64 res2 = 0; /* Reserved */
20+
u64 magic = 0x5643534952; /* Magic number, little endian, "RISCV" */
21+
u32 res3; /* Reserved for additional RISC-V specific header */
22+
u32 res4; /* Reserved for PE COFF offset */
23+
24+
This header format is compliant with PE/COFF header and largely inspired from
25+
ARM64 header. Thus, both ARM64 & RISC-V header can be combined into one common
26+
header in future.
27+
28+
Notes:
29+
- This header can also be reused to support EFI stub for RISC-V in future. EFI
30+
specification needs PE/COFF image header in the beginning of the kernel image
31+
in order to load it as an EFI application. In order to support EFI stub,
32+
code0 should be replaced with "MZ" magic string and res5(at offset 0x3c) should
33+
point to the rest of the PE/COFF header.
34+
35+
- version field indicate header version number.
36+
Bits 0:15 - Minor version
37+
Bits 16:31 - Major version
38+
39+
This preserves compatibility across newer and older version of the header.
40+
The current version is defined as 0.1.
41+
42+
- res3 is reserved for offset to any other additional fields. This makes the
43+
header extendible in future. One example would be to accommodate ISA
44+
extension for RISC-V in future. For current version, it is set to be zero.
45+
46+
- In current header, the flag field has only one field.
47+
Bit 0: Kernel endianness. 1 if BE, 0 if LE.
48+
49+
- Image size is mandatory for boot loader to load kernel image. Booting will
50+
fail otherwise.

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13720,7 +13720,7 @@ RISC-V ARCHITECTURE
1372013720
M: Palmer Dabbelt <[email protected]>
1372113721
M: Albert Ou <[email protected]>
1372213722
13723-
T: git git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux.git
13723+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git
1372413724
S: Supported
1372513725
F: arch/riscv/
1372613726
K: riscv
@@ -14582,7 +14582,7 @@ M: Paul Walmsley <[email protected]>
1458214582
1458314583
T: git git://github.com/sifive/riscv-linux.git
1458414584
S: Supported
14585-
K: sifive
14585+
K: [^@]sifive
1458614586
N: sifive
1458714587

1458814588
SIFIVE FU540 SYSTEM-ON-CHIP

arch/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ config HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
569569
config HAVE_ARCH_HUGE_VMAP
570570
bool
571571

572+
config ARCH_WANT_HUGE_PMD_SHARE
573+
bool
574+
572575
config HAVE_ARCH_SOFT_DIRTY
573576
bool
574577

arch/arm64/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ config ARM64
7373
select ARCH_SUPPORTS_NUMA_BALANCING
7474
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION if COMPAT
7575
select ARCH_WANT_FRAME_POINTERS
76+
select ARCH_WANT_HUGE_PMD_SHARE if ARM64_4K_PAGES || (ARM64_16K_PAGES && !ARM64_VA_BITS_36)
7677
select ARCH_HAS_UBSAN_SANITIZE_ALL
7778
select ARM_AMBA
7879
select ARM_ARCH_TIMER
@@ -906,7 +907,6 @@ config SYS_SUPPORTS_HUGETLBFS
906907
def_bool y
907908

908909
config ARCH_WANT_HUGE_PMD_SHARE
909-
def_bool y if ARM64_4K_PAGES || (ARM64_16K_PAGES && !ARM64_VA_BITS_36)
910910

911911
config ARCH_HAS_CACHE_LINE_SIZE
912912
def_bool y

arch/riscv/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ config RISCV
5252
select ARCH_HAS_MMIOWB
5353
select HAVE_EBPF_JIT if 64BIT
5454
select EDAC_SUPPORT
55+
select ARCH_HAS_GIGANTIC_PAGE
56+
select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
5557

5658
config MMU
5759
def_bool y
@@ -66,6 +68,12 @@ config PAGE_OFFSET
6668
default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
6769
default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB
6870

71+
config ARCH_WANT_GENERAL_HUGETLB
72+
def_bool y
73+
74+
config SYS_SUPPORTS_HUGETLBFS
75+
def_bool y
76+
6977
config STACKTRACE_SUPPORT
7078
def_bool y
7179

@@ -97,6 +105,8 @@ config PGTABLE_LEVELS
97105
default 3 if 64BIT
98106
default 2
99107

108+
source "arch/riscv/Kconfig.socs"
109+
100110
menu "Platform type"
101111

102112
choice

arch/riscv/Kconfig.socs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
menu "SoC selection"
2+
3+
config SOC_SIFIVE
4+
bool "SiFive SoCs"
5+
select SERIAL_SIFIVE
6+
select SERIAL_SIFIVE_CONSOLE
7+
select CLK_SIFIVE
8+
select CLK_SIFIVE_FU540_PRCI
9+
select SIFIVE_PLIC
10+
help
11+
This enables support for SiFive SoC platform hardware.
12+
13+
endmenu

arch/riscv/boot/dts/sifive/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
dtb-y += hifive-unleashed-a00.dtb
2+
dtb-$(CONFIG_SOC_SIFIVE) += hifive-unleashed-a00.dtb

arch/riscv/configs/defconfig

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
CONFIG_SYSVIPC=y
22
CONFIG_POSIX_MQUEUE=y
3+
CONFIG_NO_HZ_IDLE=y
4+
CONFIG_HIGH_RES_TIMERS=y
35
CONFIG_IKCONFIG=y
46
CONFIG_IKCONFIG_PROC=y
57
CONFIG_CGROUPS=y
@@ -12,6 +14,7 @@ CONFIG_CHECKPOINT_RESTORE=y
1214
CONFIG_BLK_DEV_INITRD=y
1315
CONFIG_EXPERT=y
1416
CONFIG_BPF_SYSCALL=y
17+
CONFIG_SOC_SIFIVE=y
1518
CONFIG_SMP=y
1619
CONFIG_MODULES=y
1720
CONFIG_MODULE_UNLOAD=y
@@ -49,8 +52,6 @@ CONFIG_SERIAL_8250=y
4952
CONFIG_SERIAL_8250_CONSOLE=y
5053
CONFIG_SERIAL_OF_PLATFORM=y
5154
CONFIG_SERIAL_EARLYCON_RISCV_SBI=y
52-
CONFIG_SERIAL_SIFIVE=y
53-
CONFIG_SERIAL_SIFIVE_CONSOLE=y
5455
CONFIG_HVC_RISCV_SBI=y
5556
# CONFIG_PTP_1588_CLOCK is not set
5657
CONFIG_DRM=y
@@ -66,9 +67,6 @@ CONFIG_USB_OHCI_HCD_PLATFORM=y
6667
CONFIG_USB_STORAGE=y
6768
CONFIG_USB_UAS=y
6869
CONFIG_VIRTIO_MMIO=y
69-
CONFIG_CLK_SIFIVE=y
70-
CONFIG_CLK_SIFIVE_FU540_PRCI=y
71-
CONFIG_SIFIVE_PLIC=y
7270
CONFIG_SPI_SIFIVE=y
7371
CONFIG_EXT4_FS=y
7472
CONFIG_EXT4_FS_POSIX_ACL=y

arch/riscv/configs/rv32_defconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
CONFIG_SYSVIPC=y
22
CONFIG_POSIX_MQUEUE=y
3+
CONFIG_NO_HZ_IDLE=y
4+
CONFIG_HIGH_RES_TIMERS=y
35
CONFIG_IKCONFIG=y
46
CONFIG_IKCONFIG_PROC=y
57
CONFIG_CGROUPS=y

arch/riscv/include/asm/cacheflush.h

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,66 @@
66
#ifndef _ASM_RISCV_CACHEFLUSH_H
77
#define _ASM_RISCV_CACHEFLUSH_H
88

9-
#include <asm-generic/cacheflush.h>
9+
#include <linux/mm.h>
1010

11-
#undef flush_icache_range
12-
#undef flush_icache_user_range
13-
#undef flush_dcache_page
11+
#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
12+
13+
/*
14+
* The cache doesn't need to be flushed when TLB entries change when
15+
* the cache is mapped to physical memory, not virtual memory
16+
*/
17+
static inline void flush_cache_all(void)
18+
{
19+
}
20+
21+
static inline void flush_cache_mm(struct mm_struct *mm)
22+
{
23+
}
24+
25+
static inline void flush_cache_dup_mm(struct mm_struct *mm)
26+
{
27+
}
28+
29+
static inline void flush_cache_range(struct vm_area_struct *vma,
30+
unsigned long start,
31+
unsigned long end)
32+
{
33+
}
34+
35+
static inline void flush_cache_page(struct vm_area_struct *vma,
36+
unsigned long vmaddr,
37+
unsigned long pfn)
38+
{
39+
}
40+
41+
static inline void flush_dcache_mmap_lock(struct address_space *mapping)
42+
{
43+
}
44+
45+
static inline void flush_dcache_mmap_unlock(struct address_space *mapping)
46+
{
47+
}
48+
49+
static inline void flush_icache_page(struct vm_area_struct *vma,
50+
struct page *page)
51+
{
52+
}
53+
54+
static inline void flush_cache_vmap(unsigned long start, unsigned long end)
55+
{
56+
}
57+
58+
static inline void flush_cache_vunmap(unsigned long start, unsigned long end)
59+
{
60+
}
61+
62+
#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
63+
do { \
64+
memcpy(dst, src, len); \
65+
flush_icache_user_range(vma, page, vaddr, len); \
66+
} while (0)
67+
#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
68+
memcpy(dst, src, len)
1469

1570
static inline void local_flush_icache_all(void)
1671
{

arch/riscv/include/asm/fixmap.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
*/
2222
enum fixed_addresses {
2323
FIX_HOLE,
24+
#define FIX_FDT_SIZE SZ_1M
25+
FIX_FDT_END,
26+
FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1,
27+
FIX_PTE,
28+
FIX_PMD,
2429
FIX_EARLYCON_MEM_BASE,
2530
__end_of_fixed_addresses
2631
};

arch/riscv/include/asm/hugetlb.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_RISCV_HUGETLB_H
3+
#define _ASM_RISCV_HUGETLB_H
4+
5+
#include <asm-generic/hugetlb.h>
6+
#include <asm/page.h>
7+
8+
static inline int is_hugepage_only_range(struct mm_struct *mm,
9+
unsigned long addr,
10+
unsigned long len) {
11+
return 0;
12+
}
13+
14+
static inline void arch_clear_hugepage_flags(struct page *page)
15+
{
16+
}
17+
18+
#endif /* _ASM_RISCV_HUGETLB_H */

arch/riscv/include/asm/image.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#ifndef __ASM_IMAGE_H
4+
#define __ASM_IMAGE_H
5+
6+
#define RISCV_IMAGE_MAGIC "RISCV"
7+
8+
#define RISCV_IMAGE_FLAG_BE_SHIFT 0
9+
#define RISCV_IMAGE_FLAG_BE_MASK 0x1
10+
11+
#define RISCV_IMAGE_FLAG_LE 0
12+
#define RISCV_IMAGE_FLAG_BE 1
13+
14+
#ifdef CONFIG_CPU_BIG_ENDIAN
15+
#error conversion of header fields to LE not yet implemented
16+
#else
17+
#define __HEAD_FLAG_BE RISCV_IMAGE_FLAG_LE
18+
#endif
19+
20+
#define __HEAD_FLAG(field) (__HEAD_FLAG_##field << \
21+
RISCV_IMAGE_FLAG_##field##_SHIFT)
22+
23+
#define __HEAD_FLAGS (__HEAD_FLAG(BE))
24+
25+
#define RISCV_HEADER_VERSION_MAJOR 0
26+
#define RISCV_HEADER_VERSION_MINOR 1
27+
28+
#define RISCV_HEADER_VERSION (RISCV_HEADER_VERSION_MAJOR << 16 | \
29+
RISCV_HEADER_VERSION_MINOR)
30+
31+
#ifndef __ASSEMBLY__
32+
/**
33+
* struct riscv_image_header - riscv kernel image header
34+
* @code0: Executable code
35+
* @code1: Executable code
36+
* @text_offset: Image load offset (little endian)
37+
* @image_size: Effective Image size (little endian)
38+
* @flags: kernel flags (little endian)
39+
* @version: version
40+
* @res1: reserved
41+
* @res2: reserved
42+
* @magic: Magic number
43+
* @res3: reserved (will be used for additional RISC-V specific
44+
* header)
45+
* @res4: reserved (will be used for PE COFF offset)
46+
*
47+
* The intention is for this header format to be shared between multiple
48+
* architectures to avoid a proliferation of image header formats.
49+
*/
50+
51+
struct riscv_image_header {
52+
u32 code0;
53+
u32 code1;
54+
u64 text_offset;
55+
u64 image_size;
56+
u64 flags;
57+
u32 version;
58+
u32 res1;
59+
u64 res2;
60+
u64 magic;
61+
u32 res3;
62+
u32 res4;
63+
};
64+
#endif /* __ASSEMBLY__ */
65+
#endif /* __ASM_IMAGE_H */

arch/riscv/include/asm/page.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
1717
#define PAGE_MASK (~(PAGE_SIZE - 1))
1818

19+
#ifdef CONFIG_64BIT
20+
#define HUGE_MAX_HSTATE 2
21+
#else
22+
#define HUGE_MAX_HSTATE 1
23+
#endif
24+
#define HPAGE_SHIFT PMD_SHIFT
25+
#define HPAGE_SIZE (_AC(1, UL) << HPAGE_SHIFT)
26+
#define HPAGE_MASK (~(HPAGE_SIZE - 1))
27+
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
28+
1929
/*
2030
* PAGE_OFFSET -- the first address of the first page of memory.
2131
* When not using MMU this corresponds to the first free page in
@@ -115,8 +125,4 @@ extern unsigned long min_low_pfn;
115125
#include <asm-generic/memory_model.h>
116126
#include <asm-generic/getorder.h>
117127

118-
/* vDSO support */
119-
/* We do define AT_SYSINFO_EHDR but don't use the gate mechanism */
120-
#define __HAVE_ARCH_GATE_AREA
121-
122128
#endif /* _ASM_RISCV_PAGE_H */

arch/riscv/include/asm/pgtable-64.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ static inline pmd_t pfn_pmd(unsigned long pfn, pgprot_t prot)
7070
return __pmd((pfn << _PAGE_PFN_SHIFT) | pgprot_val(prot));
7171
}
7272

73+
static inline unsigned long _pmd_pfn(pmd_t pmd)
74+
{
75+
return pmd_val(pmd) >> _PAGE_PFN_SHIFT;
76+
}
77+
7378
#define pmd_ERROR(e) \
7479
pr_err("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e))
7580

0 commit comments

Comments
 (0)