linux_riscv: Move patches to my Linux fork.

All patches there are also submitted upstream and will be removed if
rejected.

Also includes some fixes to get module loading working.

+7 -229
+5 -5
pkgs/os-specific/linux/kernel/linux-riscv.nix
··· 1 1 { stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, libelf, utillinux, ... } @ args: 2 2 3 3 buildLinux (args // rec { 4 - version = "4.16-rc1"; 5 - modDirVersion = "4.16.0-rc1"; 4 + version = "4.16-rc2"; 5 + modDirVersion = "4.16.0-rc2"; 6 6 extraMeta.branch = "4.16"; 7 7 8 8 src = fetchFromGitHub { 9 - owner = "riscv"; 9 + owner = "shlevy"; 10 10 repo ="riscv-linux"; 11 - rev = "a31991a9c6ce2c86fd676cf458a0ec10edc20d37"; 12 - sha256 = "0n97wfbi3pnp5c70xfj7s0fk8zjjkjz6ldxh7n54kbf64l4in01f"; 11 + rev = "f0c42cff9292c0a8e6ca702a54aafa04b35758a6"; 12 + sha256 = "050mdciyz1595z81zsss0v9vqsaysppyzqaqpfs5figackifv3iv"; 13 13 }; 14 14 15 15 # Should the testing kernels ever be built on Hydra?
-29
pkgs/os-specific/linux/kernel/patches.nix
··· 73 73 }; 74 74 }; 75 75 76 - riscv_modules = { 77 - name = "riscv-modules"; 78 - patch = ./riscv-modules.patch; 79 - }; 80 - 81 - # http://lists.infradead.org/pipermail/linux-riscv/2018-February/000054.html 82 - riscv_irq_busy = { 83 - name = "riscv-irq-busy"; 84 - patch = ./riscv-irq-busy.patch; 85 - }; 86 - 87 - # http://lists.infradead.org/pipermail/linux-riscv/2018-February/000059.html 88 - riscv_install = { 89 - name = "riscv-install"; 90 - patch = ./riscv-install.patch; 91 - }; 92 - 93 - # http://lists.infradead.org/pipermail/linux-riscv/2018-February/000056.html 94 - riscv_initrd = { 95 - name = "riscv-initrd"; 96 - patch = ./riscv-initrd.patch; 97 - }; 98 - 99 - # http://lists.infradead.org/pipermail/linux-riscv/2018-February/000058.html 100 - riscv_initrd_free = { 101 - name = "riscv-initrd-free"; 102 - patch = ./riscv-initrd-free.patch; 103 - }; 104 - 105 76 }
-21
pkgs/os-specific/linux/kernel/riscv-initrd-free.patch
··· 1 - commit b1fbec8b74ace263ce1371e6bcfdd1dd71b52070 2 - Author: Shea Levy <shea@shealevy.com> 3 - Date: Tue Feb 20 08:48:12 2018 -0500 4 - 5 - riscv: Implement free_initrd_mem. 6 - 7 - v2: Remove incorrect page alignment. 8 - 9 - Signed-off-by: Shea Levy <shea@shealevy.com> 10 - 11 - diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c 12 - index c77df8142be2..1b6daa5184e0 100644 13 - --- a/arch/riscv/mm/init.c 14 - +++ b/arch/riscv/mm/init.c 15 - @@ -66,5 +66,6 @@ void free_initmem(void) 16 - #ifdef CONFIG_BLK_DEV_INITRD 17 - void free_initrd_mem(unsigned long start, unsigned long end) 18 - { 19 - + free_reserved_area((void *)start, (void *)end, -1, "initrd"); 20 - } 21 - #endif /* CONFIG_BLK_DEV_INITRD */
-48
pkgs/os-specific/linux/kernel/riscv-initrd.patch
··· 1 - commit 1e5f6473492f41355289d022003a049ebf8995fa 2 - Author: Shea Levy <shea@shealevy.com> 3 - Date: Tue Feb 20 07:52:14 2018 -0500 4 - 5 - riscv: Respect the initrd found in the dt, if any. 6 - 7 - Signed-off-by: Shea Levy <shea@shealevy.com> 8 - 9 - diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c 10 - index 41d34008faf6..c4ebc907af34 100644 11 - --- a/arch/riscv/kernel/setup.c 12 - +++ b/arch/riscv/kernel/setup.c 13 - @@ -88,15 +88,20 @@ static void __init setup_initrd(void) 14 - extern unsigned long __initramfs_size; 15 - unsigned long size; 16 - 17 - + if (initrd_start) 18 - + goto found; 19 - + 20 - if (__initramfs_size > 0) { 21 - initrd_start = (unsigned long)(&__initramfs_start); 22 - initrd_end = initrd_start + __initramfs_size; 23 - } 24 - 25 - + initrd_below_start_ok = 1; 26 - if (initrd_start >= initrd_end) { 27 - printk(KERN_INFO "initrd not found or empty"); 28 - goto disable; 29 - } 30 - +found: 31 - if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) { 32 - printk(KERN_ERR "initrd extends beyond end of memory"); 33 - goto disable; 34 - @@ -104,13 +109,13 @@ static void __init setup_initrd(void) 35 - 36 - size = initrd_end - initrd_start; 37 - memblock_reserve(__pa(initrd_start), size); 38 - - initrd_below_start_ok = 1; 39 - 40 - printk(KERN_INFO "Initial ramdisk at: 0x%p (%lu bytes)\n", 41 - (void *)(initrd_start), size); 42 - return; 43 - disable: 44 - pr_cont(" - disabling initrd\n"); 45 - + initrd_below_start_ok = 0; 46 - initrd_start = 0; 47 - initrd_end = 0; 48 - }
-65
pkgs/os-specific/linux/kernel/riscv-install.patch
··· 1 - commit 365fc1312f4911bfae25c5914c398f9aca21948f 2 - Author: Shea Levy <shea@shealevy.com> 3 - Date: Mon Feb 19 10:50:58 2018 -0500 4 - 5 - riscv: Add install target to Makefile. 6 - 7 - Signed-off-by: Shea Levy <shea@shealevy.com> 8 - 9 - diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile 10 - index 6719dd30ec5b..26892daefa05 100644 11 - --- a/arch/riscv/Makefile 12 - +++ b/arch/riscv/Makefile 13 - @@ -70,3 +70,7 @@ core-y += arch/riscv/kernel/ arch/riscv/mm/ 14 - libs-y += arch/riscv/lib/ 15 - 16 - all: vmlinux 17 - + 18 - +PHONY += install 19 - +install: vmlinux 20 - + sh $(srctree)/arch/riscv/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)" 21 - diff --git a/arch/riscv/install.sh b/arch/riscv/install.sh 22 - new file mode 100644 23 - index 000000000000..8b3155a11a4a 24 - --- /dev/null 25 - +++ b/arch/riscv/install.sh 26 - @@ -0,0 +1,39 @@ 27 - +#!/bin/sh 28 - +# 29 - +# arch/riscv/install.sh 30 - +# 31 - +# This file is subject to the terms and conditions of the GNU General Public 32 - +# License. See the file "COPYING" in the main directory of this archive 33 - +# for more details. 34 - +# 35 - +# Copyright (C) 1995 by Linus Torvalds 36 - +# 37 - +# Adapted from code in arch/ia64/Makefile by Shea Levy 38 - +# 39 - +# "make install" script for riscv architecture 40 - +# 41 - +# Arguments: 42 - +# $1 - kernel version 43 - +# $2 - kernel image file 44 - +# $3 - kernel map file 45 - +# $4 - default install path (blank if root directory) 46 - +# 47 - + 48 - +# User may have a custom install script 49 - + 50 - +if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi 51 - +if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi 52 - + 53 - +# Default install - no bootloader configuration (yet?) 54 - +base=$(basename $2) 55 - + 56 - +if [ -f $4/$base ]; then 57 - + mv $4/$base $4/$base.old 58 - +fi 59 - + 60 - +if [ -f $4/System.map ]; then 61 - + mv $4/System.map $4/System.old 62 - +fi 63 - + 64 - +cat $2 > $4/$base 65 - +cp $3 $4/System.map
-42
pkgs/os-specific/linux/kernel/riscv-irq-busy.patch
··· 1 - commit 2603e6087b26e9428b806b267aee6bcb919abcea 2 - Author: Shea Levy <shea@shealevy.com> 3 - Date: Sun Feb 18 20:08:30 2018 -0500 4 - 5 - set_handle_irq: Return EBUSY if the handler has already been registered. 6 - 7 - This is what's expected by the comments and at least by irq-riscv-intc.c 8 - 9 - Signed-off-by: Shea Levy <shea@shealevy.com> 10 - 11 - diff --git a/include/linux/irq.h b/include/linux/irq.h 12 - index 2930fd2572e4..77e97872a13e 100644 13 - --- a/include/linux/irq.h 14 - +++ b/include/linux/irq.h 15 - @@ -1179,7 +1179,7 @@ int ipi_send_mask(unsigned int virq, const struct cpumask *dest); 16 - * Returns 0 on success, or -EBUSY if an IRQ handler has already been 17 - * registered. 18 - */ 19 - -void __init set_handle_irq(void (*handle_irq)(struct pt_regs *)); 20 - +int __init set_handle_irq(void (*handle_irq)(struct pt_regs *)); 21 - 22 - /* 23 - * Allows interrupt handlers to find the irqchip that's been registered as the 24 - diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c 25 - index dee4f9a172ca..3570c715c3e7 100644 26 - --- a/kernel/irq/handle.c 27 - +++ b/kernel/irq/handle.c 28 - @@ -213,11 +213,12 @@ irqreturn_t handle_irq_event(struct irq_desc *desc) 29 - } 30 - 31 - #ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER 32 - -void __init set_handle_irq(void (*handle_irq)(struct pt_regs *)) 33 - +int __init set_handle_irq(void (*handle_irq)(struct pt_regs *)) 34 - { 35 - if (handle_arch_irq) 36 - - return; 37 - + return -EBUSY; 38 - 39 - handle_arch_irq = handle_irq; 40 - + return 0; 41 - } 42 - #endif
-11
pkgs/os-specific/linux/kernel/riscv-modules.patch
··· 1 - diff -Naur linux-4.15.4-orig/arch/riscv/configs/defconfig linux-4.15.4/arch/riscv/configs/defconfig 2 - --- linux-4.15.4-orig/arch/riscv/configs/defconfig 2018-02-16 14:07:01.000000000 -0500 3 - +++ linux-4.15.4/arch/riscv/configs/defconfig 2018-02-18 18:33:09.488431900 -0500 4 - @@ -12,6 +12,7 @@ 5 - CONFIG_NAMESPACES=y 6 - CONFIG_USER_NS=y 7 - CONFIG_BLK_DEV_INITRD=y 8 - +CONFIG_MODULES=y 9 - CONFIG_EXPERT=y 10 - CONFIG_CHECKPOINT_RESTORE=y 11 - CONFIG_BPF_SYSCALL=y
+2 -8
pkgs/top-level/all-packages.nix
··· 13162 13162 kernelPatches = [ 13163 13163 kernelPatches.bridge_stp_helper 13164 13164 kernelPatches.modinst_arg_list_too_long 13165 - ] ++ lib.optionals hostPlatform.isRiscV [ 13166 - kernelPatches.riscv_modules 13167 - kernelPatches.riscv_irq_busy 13168 - kernelPatches.riscv_install 13169 - kernelPatches.riscv_initrd 13170 - kernelPatches.riscv_initrd_free 13171 - ]; 13165 + ]; 13172 13166 }; 13173 13167 13174 13168 linux_samus_4_12 = callPackage ../os-specific/linux/kernel/linux-samus-4.12.nix { ··· 13179 13173 # when adding a new linux version 13180 13174 kernelPatches.cpu-cgroup-v2."4.11" 13181 13175 kernelPatches.modinst_arg_list_too_long 13182 - ]; 13176 + ]; 13183 13177 }; 13184 13178 13185 13179 /* Linux kernel modules are inherently tied to a specific kernel. So