Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'riscv-for-linus-5.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:
"A smattering of fixes and cleanups:

- Dead code removal.

- Exporting riscv_cpuid_to_hartid_mask for modules.

- Per-CPU tracking of ISA features.

- Setting max_pfn correctly when probing memory.

- Adding a note to the VDSO so glibc can check the kernel's version
without a uname().

- A fix to force the bootloader to initialize the boot spin tables,
which still get used as a fallback when SBI-0.1 is enabled"

* tag 'riscv-for-linus-5.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
RISC-V: Remove unused code from STRICT_KERNEL_RWX
riscv: force __cpu_up_ variables to put in data section
riscv: add Linux note to vdso
riscv: set max_pfn to the PFN of the last page
RISC-V: Remove N-extension related defines
RISC-V: Add bitmap reprensenting ISA features common across CPUs
RISC-V: Export riscv_cpuid_to_hartid_mask() API

+121 -34
-3
arch/riscv/include/asm/csr.h
··· 51 51 #define CAUSE_IRQ_FLAG (_AC(1, UL) << (__riscv_xlen - 1)) 52 52 53 53 /* Interrupt causes (minus the high bit) */ 54 - #define IRQ_U_SOFT 0 55 54 #define IRQ_S_SOFT 1 56 55 #define IRQ_M_SOFT 3 57 - #define IRQ_U_TIMER 4 58 56 #define IRQ_S_TIMER 5 59 57 #define IRQ_M_TIMER 7 60 - #define IRQ_U_EXT 8 61 58 #define IRQ_S_EXT 9 62 59 #define IRQ_M_EXT 11 63 60
+22
arch/riscv/include/asm/hwcap.h
··· 8 8 #ifndef _ASM_RISCV_HWCAP_H 9 9 #define _ASM_RISCV_HWCAP_H 10 10 11 + #include <linux/bits.h> 11 12 #include <uapi/asm/hwcap.h> 12 13 13 14 #ifndef __ASSEMBLY__ ··· 23 22 }; 24 23 25 24 extern unsigned long elf_hwcap; 25 + 26 + #define RISCV_ISA_EXT_a ('a' - 'a') 27 + #define RISCV_ISA_EXT_c ('c' - 'a') 28 + #define RISCV_ISA_EXT_d ('d' - 'a') 29 + #define RISCV_ISA_EXT_f ('f' - 'a') 30 + #define RISCV_ISA_EXT_h ('h' - 'a') 31 + #define RISCV_ISA_EXT_i ('i' - 'a') 32 + #define RISCV_ISA_EXT_m ('m' - 'a') 33 + #define RISCV_ISA_EXT_s ('s' - 'a') 34 + #define RISCV_ISA_EXT_u ('u' - 'a') 35 + 36 + #define RISCV_ISA_EXT_MAX 64 37 + 38 + unsigned long riscv_isa_extension_base(const unsigned long *isa_bitmap); 39 + 40 + #define riscv_isa_extension_mask(ext) BIT_MASK(RISCV_ISA_EXT_##ext) 41 + 42 + bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, int bit); 43 + #define riscv_isa_extension_available(isa_bitmap, ext) \ 44 + __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_##ext) 45 + 26 46 #endif 27 47 28 48 #endif /* _ASM_RISCV_HWCAP_H */
-8
arch/riscv/include/asm/set_memory.h
··· 22 22 static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; } 23 23 #endif 24 24 25 - #ifdef CONFIG_STRICT_KERNEL_RWX 26 - void set_kernel_text_ro(void); 27 - void set_kernel_text_rw(void); 28 - #else 29 - static inline void set_kernel_text_ro(void) { } 30 - static inline void set_kernel_text_rw(void) { } 31 - #endif 32 - 33 25 int set_direct_map_invalid_noflush(struct page *page); 34 26 int set_direct_map_default_noflush(struct page *page); 35 27
+2 -2
arch/riscv/kernel/cpu_ops.c
··· 15 15 16 16 const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init; 17 17 18 - void *__cpu_up_stack_pointer[NR_CPUS]; 19 - void *__cpu_up_task_pointer[NR_CPUS]; 18 + void *__cpu_up_stack_pointer[NR_CPUS] __section(.data); 19 + void *__cpu_up_task_pointer[NR_CPUS] __section(.data); 20 20 21 21 extern const struct cpu_operations cpu_ops_sbi; 22 22 extern const struct cpu_operations cpu_ops_spinwait;
+80 -3
arch/riscv/kernel/cpufeature.c
··· 6 6 * Copyright (C) 2017 SiFive 7 7 */ 8 8 9 + #include <linux/bitmap.h> 9 10 #include <linux/of.h> 10 11 #include <asm/processor.h> 11 12 #include <asm/hwcap.h> ··· 14 13 #include <asm/switch_to.h> 15 14 16 15 unsigned long elf_hwcap __read_mostly; 16 + 17 + /* Host ISA bitmap */ 18 + static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly; 19 + 17 20 #ifdef CONFIG_FPU 18 21 bool has_fpu __read_mostly; 19 22 #endif 23 + 24 + /** 25 + * riscv_isa_extension_base() - Get base extension word 26 + * 27 + * @isa_bitmap: ISA bitmap to use 28 + * Return: base extension word as unsigned long value 29 + * 30 + * NOTE: If isa_bitmap is NULL then Host ISA bitmap will be used. 31 + */ 32 + unsigned long riscv_isa_extension_base(const unsigned long *isa_bitmap) 33 + { 34 + if (!isa_bitmap) 35 + return riscv_isa[0]; 36 + return isa_bitmap[0]; 37 + } 38 + EXPORT_SYMBOL_GPL(riscv_isa_extension_base); 39 + 40 + /** 41 + * __riscv_isa_extension_available() - Check whether given extension 42 + * is available or not 43 + * 44 + * @isa_bitmap: ISA bitmap to use 45 + * @bit: bit position of the desired extension 46 + * Return: true or false 47 + * 48 + * NOTE: If isa_bitmap is NULL then Host ISA bitmap will be used. 49 + */ 50 + bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, int bit) 51 + { 52 + const unsigned long *bmap = (isa_bitmap) ? isa_bitmap : riscv_isa; 53 + 54 + if (bit >= RISCV_ISA_EXT_MAX) 55 + return false; 56 + 57 + return test_bit(bit, bmap) ? true : false; 58 + } 59 + EXPORT_SYMBOL_GPL(__riscv_isa_extension_available); 20 60 21 61 void riscv_fill_hwcap(void) 22 62 { 23 63 struct device_node *node; 24 64 const char *isa; 25 - size_t i; 65 + char print_str[BITS_PER_LONG + 1]; 66 + size_t i, j, isa_len; 26 67 static unsigned long isa2hwcap[256] = {0}; 27 68 28 69 isa2hwcap['i'] = isa2hwcap['I'] = COMPAT_HWCAP_ISA_I; ··· 76 33 77 34 elf_hwcap = 0; 78 35 36 + bitmap_zero(riscv_isa, RISCV_ISA_EXT_MAX); 37 + 79 38 for_each_of_cpu_node(node) { 80 39 unsigned long this_hwcap = 0; 40 + unsigned long this_isa = 0; 81 41 82 42 if (riscv_of_processor_hartid(node) < 0) 83 43 continue; ··· 90 44 continue; 91 45 } 92 46 93 - for (i = 0; i < strlen(isa); ++i) 47 + i = 0; 48 + isa_len = strlen(isa); 49 + #if IS_ENABLED(CONFIG_32BIT) 50 + if (!strncmp(isa, "rv32", 4)) 51 + i += 4; 52 + #elif IS_ENABLED(CONFIG_64BIT) 53 + if (!strncmp(isa, "rv64", 4)) 54 + i += 4; 55 + #endif 56 + for (; i < isa_len; ++i) { 94 57 this_hwcap |= isa2hwcap[(unsigned char)(isa[i])]; 58 + /* 59 + * TODO: X, Y and Z extension parsing for Host ISA 60 + * bitmap will be added in-future. 61 + */ 62 + if ('a' <= isa[i] && isa[i] < 'x') 63 + this_isa |= (1UL << (isa[i] - 'a')); 64 + } 95 65 96 66 /* 97 67 * All "okay" hart should have same isa. Set HWCAP based on ··· 118 56 elf_hwcap &= this_hwcap; 119 57 else 120 58 elf_hwcap = this_hwcap; 59 + 60 + if (riscv_isa[0]) 61 + riscv_isa[0] &= this_isa; 62 + else 63 + riscv_isa[0] = this_isa; 121 64 } 122 65 123 66 /* We don't support systems with F but without D, so mask those out ··· 132 65 elf_hwcap &= ~COMPAT_HWCAP_ISA_F; 133 66 } 134 67 135 - pr_info("elf_hwcap is 0x%lx\n", elf_hwcap); 68 + memset(print_str, 0, sizeof(print_str)); 69 + for (i = 0, j = 0; i < BITS_PER_LONG; i++) 70 + if (riscv_isa[0] & BIT_MASK(i)) 71 + print_str[j++] = (char)('a' + i); 72 + pr_info("riscv: ISA extensions %s\n", print_str); 73 + 74 + memset(print_str, 0, sizeof(print_str)); 75 + for (i = 0, j = 0; i < BITS_PER_LONG; i++) 76 + if (elf_hwcap & BIT_MASK(i)) 77 + print_str[j++] = (char)('a' + i); 78 + pr_info("riscv: ELF capabilities %s\n", print_str); 136 79 137 80 #ifdef CONFIG_FPU 138 81 if (elf_hwcap & (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D))
+2
arch/riscv/kernel/smp.c
··· 10 10 11 11 #include <linux/cpu.h> 12 12 #include <linux/interrupt.h> 13 + #include <linux/module.h> 13 14 #include <linux/profile.h> 14 15 #include <linux/smp.h> 15 16 #include <linux/sched.h> ··· 64 63 for_each_cpu(cpu, in) 65 64 cpumask_set_cpu(cpuid_to_hartid_map(cpu), out); 66 65 } 66 + EXPORT_SYMBOL_GPL(riscv_cpuid_to_hartid_mask); 67 67 68 68 bool arch_match_cpu_phys_id(int cpu, u64 phys_id) 69 69 {
+1 -1
arch/riscv/kernel/vdso/Makefile
··· 12 12 vdso-syms += flush_icache 13 13 14 14 # Files to link into the vdso 15 - obj-vdso = $(patsubst %, %.o, $(vdso-syms)) 15 + obj-vdso = $(patsubst %, %.o, $(vdso-syms)) note.o 16 16 17 17 # Build rules 18 18 targets := $(obj-vdso) vdso.so vdso.so.dbg vdso.lds vdso-dummy.o
+12
arch/riscv/kernel/vdso/note.S
··· 1 + /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 + /* 3 + * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text. 4 + * Here we can supply some information useful to userland. 5 + */ 6 + 7 + #include <linux/elfnote.h> 8 + #include <linux/version.h> 9 + 10 + ELFNOTE_START(Linux, 0, "a") 11 + .long LINUX_VERSION_CODE 12 + ELFNOTE_END
+2 -17
arch/riscv/mm/init.c
··· 150 150 memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start); 151 151 152 152 set_max_mapnr(PFN_DOWN(mem_size)); 153 - max_low_pfn = PFN_DOWN(memblock_end_of_DRAM()); 153 + max_pfn = PFN_DOWN(memblock_end_of_DRAM()); 154 + max_low_pfn = max_pfn; 154 155 155 156 #ifdef CONFIG_BLK_DEV_INITRD 156 157 setup_initrd(); ··· 502 501 #endif /* CONFIG_MMU */ 503 502 504 503 #ifdef CONFIG_STRICT_KERNEL_RWX 505 - void set_kernel_text_rw(void) 506 - { 507 - unsigned long text_start = (unsigned long)_text; 508 - unsigned long text_end = (unsigned long)_etext; 509 - 510 - set_memory_rw(text_start, (text_end - text_start) >> PAGE_SHIFT); 511 - } 512 - 513 - void set_kernel_text_ro(void) 514 - { 515 - unsigned long text_start = (unsigned long)_text; 516 - unsigned long text_end = (unsigned long)_etext; 517 - 518 - set_memory_ro(text_start, (text_end - text_start) >> PAGE_SHIFT); 519 - } 520 - 521 504 void mark_rodata_ro(void) 522 505 { 523 506 unsigned long text_start = (unsigned long)_text;