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.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:
"There are a few more fixes than a normal rc4, largely due to the
bubble introduced by the holiday break:

- return -ENOSYS for syscall number -1, which previously returned an
uninitialized value.

- ensure of_clk_init() has been called in time_init(), without which
clock drivers may not be initialized.

- fix sifive,uart0 driver to properly display the baud rate. A fix to
initialize MPIE that allows interrupts to be processed during
system calls.

- avoid erronously begin tracing IRQs when interrupts are disabled,
which at least triggers suprious lockdep failures.

- workaround for a warning related to calling smp_processor_id()
while preemptible. The warning itself is suprious on currently
availiable systems.

- properly include the generic time VDSO calls. A fix to our kasan
address mapping. A fix to the HiFive Unleashed device tree, which
allows the Ethernet PHY to be properly initialized by Linux (as
opposed to relying on the bootloader).

- defconfig update to include SiFive's GPIO driver, which is present
on the HiFive Unleashed and necessary to initialize the PHY.

- avoid allocating memory while initializing reserved memory.

- avoid allocating the last 4K of memory, as pointers there alias
with syscall errors.

There are also two cleanups that should have no functional effect but
do fix build warnings:

- drop a duplicated definition of PAGE_KERNEL_EXEC.

- properly declare the asm register SP shim.

- cleanup the rv32 memory size Kconfig entry, to reflect the actual
size of memory availiable"

* tag 'riscv-for-linus-5.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
RISC-V: Fix maximum allowed phsyical memory for RV32
RISC-V: Set current memblock limit
RISC-V: Do not allocate memblock while iterating reserved memblocks
riscv: stacktrace: Move register keyword to beginning of declaration
riscv: defconfig: enable gpio support for HiFive Unleashed
dts: phy: add GPIO number and active state used for phy reset
dts: phy: fix missing mdio device and probe failure of vsc8541-01 device
riscv: Fix KASAN memory mapping.
riscv: Fixup CONFIG_GENERIC_TIME_VSYSCALL
riscv: cacheinfo: Fix using smp_processor_id() in preemptible
riscv: Trace irq on only interrupt is enabled
riscv: Drop a duplicated PAGE_KERNEL_EXEC
riscv: Enable interrupts during syscalls with M-Mode
riscv: Fix sifive serial driver
riscv: Fix kernel time_init()
riscv: return -ENOSYS for syscall -1

+68 -35
+4 -2
arch/riscv/Kconfig
··· 137 137 138 138 config PAGE_OFFSET 139 139 hex 140 - default 0xC0000000 if 32BIT && MAXPHYSMEM_2GB 140 + default 0xC0000000 if 32BIT && MAXPHYSMEM_1GB 141 141 default 0x80000000 if 64BIT && !MMU 142 142 default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB 143 143 default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB ··· 247 247 248 248 choice 249 249 prompt "Maximum Physical Memory" 250 - default MAXPHYSMEM_2GB if 32BIT 250 + default MAXPHYSMEM_1GB if 32BIT 251 251 default MAXPHYSMEM_2GB if 64BIT && CMODEL_MEDLOW 252 252 default MAXPHYSMEM_128GB if 64BIT && CMODEL_MEDANY 253 253 254 + config MAXPHYSMEM_1GB 255 + bool "1GiB" 254 256 config MAXPHYSMEM_2GB 255 257 bool "2GiB" 256 258 config MAXPHYSMEM_128GB
+2
arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts
··· 88 88 phy-mode = "gmii"; 89 89 phy-handle = <&phy0>; 90 90 phy0: ethernet-phy@0 { 91 + compatible = "ethernet-phy-id0007.0771"; 91 92 reg = <0>; 93 + reset-gpios = <&gpio 12 GPIO_ACTIVE_LOW>; 92 94 }; 93 95 }; 94 96
+2
arch/riscv/configs/defconfig
··· 64 64 CONFIG_HW_RANDOM_VIRTIO=y 65 65 CONFIG_SPI=y 66 66 CONFIG_SPI_SIFIVE=y 67 + CONFIG_GPIOLIB=y 68 + CONFIG_GPIO_SIFIVE=y 67 69 # CONFIG_PTP_1588_CLOCK is not set 68 70 CONFIG_POWER_RESET=y 69 71 CONFIG_DRM=y
-1
arch/riscv/include/asm/pgtable.h
··· 99 99 | _PAGE_DIRTY) 100 100 101 101 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL) 102 - #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL | _PAGE_EXEC) 103 102 #define PAGE_KERNEL_READ __pgprot(_PAGE_KERNEL & ~_PAGE_WRITE) 104 103 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL | _PAGE_EXEC) 105 104 #define PAGE_KERNEL_READ_EXEC __pgprot((_PAGE_KERNEL & ~_PAGE_WRITE) \
+1 -1
arch/riscv/include/asm/vdso.h
··· 10 10 11 11 #include <linux/types.h> 12 12 13 - #ifndef GENERIC_TIME_VSYSCALL 13 + #ifndef CONFIG_GENERIC_TIME_VSYSCALL 14 14 struct vdso_data { 15 15 }; 16 16 #endif
+10 -1
arch/riscv/kernel/cacheinfo.c
··· 26 26 27 27 static struct cacheinfo *get_cacheinfo(u32 level, enum cache_type type) 28 28 { 29 - struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(smp_processor_id()); 29 + /* 30 + * Using raw_smp_processor_id() elides a preemptability check, but this 31 + * is really indicative of a larger problem: the cacheinfo UABI assumes 32 + * that cores have a homonogenous view of the cache hierarchy. That 33 + * happens to be the case for the current set of RISC-V systems, but 34 + * likely won't be true in general. Since there's no way to provide 35 + * correct information for these systems via the current UABI we're 36 + * just eliding the check for now. 37 + */ 38 + struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(raw_smp_processor_id()); 30 39 struct cacheinfo *this_leaf; 31 40 int index; 32 41
+13 -11
arch/riscv/kernel/entry.S
··· 124 124 REG_L a1, (a1) 125 125 jr a1 126 126 1: 127 - #ifdef CONFIG_TRACE_IRQFLAGS 128 - call trace_hardirqs_on 129 - #endif 130 127 /* 131 128 * Exceptions run with interrupts enabled or disabled depending on the 132 129 * state of SR_PIE in m/sstatus. 133 130 */ 134 131 andi t0, s1, SR_PIE 135 132 beqz t0, 1f 133 + #ifdef CONFIG_TRACE_IRQFLAGS 134 + call trace_hardirqs_on 135 + #endif 136 136 csrs CSR_STATUS, SR_IE 137 137 138 138 1: ··· 155 155 tail do_trap_unknown 156 156 157 157 handle_syscall: 158 + #ifdef CONFIG_RISCV_M_MODE 159 + /* 160 + * When running is M-Mode (no MMU config), MPIE does not get set. 161 + * As a result, we need to force enable interrupts here because 162 + * handle_exception did not do set SR_IE as it always sees SR_PIE 163 + * being cleared. 164 + */ 165 + csrs CSR_STATUS, SR_IE 166 + #endif 158 167 #if defined(CONFIG_TRACE_IRQFLAGS) || defined(CONFIG_CONTEXT_TRACKING) 159 168 /* Recover a0 - a7 for system calls */ 160 169 REG_L a0, PT_A0(sp) ··· 195 186 * Syscall number held in a7. 196 187 * If syscall number is above allowed value, redirect to ni_syscall. 197 188 */ 198 - bge a7, t0, 1f 199 - /* 200 - * Check if syscall is rejected by tracer, i.e., a7 == -1. 201 - * If yes, we pretend it was executed. 202 - */ 203 - li t1, -1 204 - beq a7, t1, ret_from_syscall_rejected 205 - blt a7, t1, 1f 189 + bgeu a7, t0, 1f 206 190 /* Call syscall */ 207 191 la s0, sys_call_table 208 192 slli t0, a7, RISCV_LGPTR
+13 -11
arch/riscv/kernel/setup.c
··· 127 127 { 128 128 struct memblock_region *region = NULL; 129 129 struct resource *res = NULL; 130 - int ret = 0; 130 + struct resource *mem_res = NULL; 131 + size_t mem_res_sz = 0; 132 + int ret = 0, i = 0; 131 133 132 134 code_res.start = __pa_symbol(_text); 133 135 code_res.end = __pa_symbol(_etext) - 1; ··· 147 145 bss_res.end = __pa_symbol(__bss_stop) - 1; 148 146 bss_res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; 149 147 148 + mem_res_sz = (memblock.memory.cnt + memblock.reserved.cnt) * sizeof(*mem_res); 149 + mem_res = memblock_alloc(mem_res_sz, SMP_CACHE_BYTES); 150 + if (!mem_res) 151 + panic("%s: Failed to allocate %zu bytes\n", __func__, mem_res_sz); 150 152 /* 151 153 * Start by adding the reserved regions, if they overlap 152 154 * with /memory regions, insert_resource later on will take 153 155 * care of it. 154 156 */ 155 157 for_each_reserved_mem_region(region) { 156 - res = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES); 157 - if (!res) 158 - panic("%s: Failed to allocate %zu bytes\n", __func__, 159 - sizeof(struct resource)); 158 + res = &mem_res[i++]; 160 159 161 160 res->name = "Reserved"; 162 161 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; ··· 174 171 * Ignore any other reserved regions within 175 172 * system memory. 176 173 */ 177 - if (memblock_is_memory(res->start)) 174 + if (memblock_is_memory(res->start)) { 175 + memblock_free((phys_addr_t) res, sizeof(struct resource)); 178 176 continue; 177 + } 179 178 180 179 ret = add_resource(&iomem_resource, res); 181 180 if (ret < 0) ··· 186 181 187 182 /* Add /memory regions to the resource tree */ 188 183 for_each_mem_region(region) { 189 - res = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES); 190 - if (!res) 191 - panic("%s: Failed to allocate %zu bytes\n", __func__, 192 - sizeof(struct resource)); 184 + res = &mem_res[i++]; 193 185 194 186 if (unlikely(memblock_is_nomap(region))) { 195 187 res->name = "Reserved"; ··· 207 205 return; 208 206 209 207 error: 210 - memblock_free((phys_addr_t) res, sizeof(struct resource)); 211 208 /* Better an empty resource tree than an inconsistent one */ 212 209 release_child_resources(&iomem_resource); 210 + memblock_free((phys_addr_t) mem_res, mem_res_sz); 213 211 } 214 212 215 213
+2 -3
arch/riscv/kernel/stacktrace.c
··· 14 14 15 15 #include <asm/stacktrace.h> 16 16 17 - register unsigned long sp_in_global __asm__("sp"); 17 + register const unsigned long sp_in_global __asm__("sp"); 18 18 19 19 #ifdef CONFIG_FRAME_POINTER 20 20 ··· 28 28 sp = user_stack_pointer(regs); 29 29 pc = instruction_pointer(regs); 30 30 } else if (task == NULL || task == current) { 31 - const register unsigned long current_sp = sp_in_global; 32 31 fp = (unsigned long)__builtin_frame_address(0); 33 - sp = current_sp; 32 + sp = sp_in_global; 34 33 pc = (unsigned long)walk_stackframe; 35 34 } else { 36 35 /* task blocked in __switch_to */
+3
arch/riscv/kernel/time.c
··· 4 4 * Copyright (C) 2017 SiFive 5 5 */ 6 6 7 + #include <linux/of_clk.h> 7 8 #include <linux/clocksource.h> 8 9 #include <linux/delay.h> 9 10 #include <asm/sbi.h> ··· 25 24 riscv_timebase = prop; 26 25 27 26 lpj_fine = riscv_timebase / HZ; 27 + 28 + of_clk_init(NULL); 28 29 timer_probe(); 29 30 } 30 31
+1 -1
arch/riscv/kernel/vdso.c
··· 12 12 #include <linux/binfmts.h> 13 13 #include <linux/err.h> 14 14 #include <asm/page.h> 15 - #ifdef GENERIC_TIME_VSYSCALL 15 + #ifdef CONFIG_GENERIC_TIME_VSYSCALL 16 16 #include <vdso/datapage.h> 17 17 #else 18 18 #include <asm/vdso.h>
+14 -2
arch/riscv/mm/init.c
··· 157 157 void __init setup_bootmem(void) 158 158 { 159 159 phys_addr_t mem_start = 0; 160 - phys_addr_t start, end = 0; 160 + phys_addr_t start, dram_end, end = 0; 161 161 phys_addr_t vmlinux_end = __pa_symbol(&_end); 162 162 phys_addr_t vmlinux_start = __pa_symbol(&_start); 163 + phys_addr_t max_mapped_addr = __pa(~(ulong)0); 163 164 u64 i; 164 165 165 166 /* Find the memory region containing the kernel */ ··· 182 181 /* Reserve from the start of the kernel to the end of the kernel */ 183 182 memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start); 184 183 185 - max_pfn = PFN_DOWN(memblock_end_of_DRAM()); 184 + dram_end = memblock_end_of_DRAM(); 185 + 186 + /* 187 + * memblock allocator is not aware of the fact that last 4K bytes of 188 + * the addressable memory can not be mapped because of IS_ERR_VALUE 189 + * macro. Make sure that last 4k bytes are not usable by memblock 190 + * if end of dram is equal to maximum addressable memory. 191 + */ 192 + if (max_mapped_addr == (dram_end - 1)) 193 + memblock_set_current_limit(max_mapped_addr - 4096); 194 + 195 + max_pfn = PFN_DOWN(dram_end); 186 196 max_low_pfn = max_pfn; 187 197 dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn)); 188 198 set_max_mapnr(max_low_pfn);
+2 -2
arch/riscv/mm/kasan_init.c
··· 93 93 VMALLOC_END)); 94 94 95 95 for_each_mem_range(i, &_start, &_end) { 96 - void *start = (void *)_start; 97 - void *end = (void *)_end; 96 + void *start = (void *)__va(_start); 97 + void *end = (void *)__va(_end); 98 98 99 99 if (start >= end) 100 100 break;
+1
drivers/tty/serial/sifive.c
··· 1000 1000 /* Set up clock divider */ 1001 1001 ssp->clkin_rate = clk_get_rate(ssp->clk); 1002 1002 ssp->baud_rate = SIFIVE_DEFAULT_BAUD_RATE; 1003 + ssp->port.uartclk = ssp->baud_rate * 16; 1003 1004 __ssp_update_div(ssp); 1004 1005 1005 1006 platform_set_drvdata(pdev, ssp);