From cb025f228534c7519a016a5eac6523f961f366cf Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Fri, 23 Feb 2018 05:53:31 -0500 Subject: [PATCH] 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. --- pkgs/os-specific/linux/kernel/linux-riscv.nix | 10 +-- pkgs/os-specific/linux/kernel/patches.nix | 29 --------- .../linux/kernel/riscv-initrd-free.patch | 21 ------ .../linux/kernel/riscv-initrd.patch | 48 -------------- .../linux/kernel/riscv-install.patch | 65 ------------------- .../linux/kernel/riscv-irq-busy.patch | 42 ------------ .../linux/kernel/riscv-modules.patch | 11 ---- pkgs/top-level/all-packages.nix | 10 +-- 8 files changed, 7 insertions(+), 229 deletions(-) delete mode 100644 pkgs/os-specific/linux/kernel/riscv-initrd-free.patch delete mode 100644 pkgs/os-specific/linux/kernel/riscv-initrd.patch delete mode 100644 pkgs/os-specific/linux/kernel/riscv-install.patch delete mode 100644 pkgs/os-specific/linux/kernel/riscv-irq-busy.patch delete mode 100644 pkgs/os-specific/linux/kernel/riscv-modules.patch diff --git a/pkgs/os-specific/linux/kernel/linux-riscv.nix b/pkgs/os-specific/linux/kernel/linux-riscv.nix index b2eb0a69a8e..45795e24c54 100644 --- a/pkgs/os-specific/linux/kernel/linux-riscv.nix +++ b/pkgs/os-specific/linux/kernel/linux-riscv.nix @@ -1,15 +1,15 @@ { stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, libelf, utillinux, ... } @ args: buildLinux (args // rec { - version = "4.16-rc1"; - modDirVersion = "4.16.0-rc1"; + version = "4.16-rc2"; + modDirVersion = "4.16.0-rc2"; extraMeta.branch = "4.16"; src = fetchFromGitHub { - owner = "riscv"; + owner = "shlevy"; repo ="riscv-linux"; - rev = "a31991a9c6ce2c86fd676cf458a0ec10edc20d37"; - sha256 = "0n97wfbi3pnp5c70xfj7s0fk8zjjkjz6ldxh7n54kbf64l4in01f"; + rev = "f0c42cff9292c0a8e6ca702a54aafa04b35758a6"; + sha256 = "050mdciyz1595z81zsss0v9vqsaysppyzqaqpfs5figackifv3iv"; }; # Should the testing kernels ever be built on Hydra? diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix index 42e14ad7c40..e163459d7f4 100644 --- a/pkgs/os-specific/linux/kernel/patches.nix +++ b/pkgs/os-specific/linux/kernel/patches.nix @@ -73,33 +73,4 @@ rec { }; }; - riscv_modules = { - name = "riscv-modules"; - patch = ./riscv-modules.patch; - }; - - # http://lists.infradead.org/pipermail/linux-riscv/2018-February/000054.html - riscv_irq_busy = { - name = "riscv-irq-busy"; - patch = ./riscv-irq-busy.patch; - }; - - # http://lists.infradead.org/pipermail/linux-riscv/2018-February/000059.html - riscv_install = { - name = "riscv-install"; - patch = ./riscv-install.patch; - }; - - # http://lists.infradead.org/pipermail/linux-riscv/2018-February/000056.html - riscv_initrd = { - name = "riscv-initrd"; - patch = ./riscv-initrd.patch; - }; - - # http://lists.infradead.org/pipermail/linux-riscv/2018-February/000058.html - riscv_initrd_free = { - name = "riscv-initrd-free"; - patch = ./riscv-initrd-free.patch; - }; - } diff --git a/pkgs/os-specific/linux/kernel/riscv-initrd-free.patch b/pkgs/os-specific/linux/kernel/riscv-initrd-free.patch deleted file mode 100644 index 68044838524..00000000000 --- a/pkgs/os-specific/linux/kernel/riscv-initrd-free.patch +++ /dev/null @@ -1,21 +0,0 @@ -commit b1fbec8b74ace263ce1371e6bcfdd1dd71b52070 -Author: Shea Levy -Date: Tue Feb 20 08:48:12 2018 -0500 - - riscv: Implement free_initrd_mem. - - v2: Remove incorrect page alignment. - - Signed-off-by: Shea Levy - -diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c -index c77df8142be2..1b6daa5184e0 100644 ---- a/arch/riscv/mm/init.c -+++ b/arch/riscv/mm/init.c -@@ -66,5 +66,6 @@ void free_initmem(void) - #ifdef CONFIG_BLK_DEV_INITRD - void free_initrd_mem(unsigned long start, unsigned long end) - { -+ free_reserved_area((void *)start, (void *)end, -1, "initrd"); - } - #endif /* CONFIG_BLK_DEV_INITRD */ diff --git a/pkgs/os-specific/linux/kernel/riscv-initrd.patch b/pkgs/os-specific/linux/kernel/riscv-initrd.patch deleted file mode 100644 index 2313e764584..00000000000 --- a/pkgs/os-specific/linux/kernel/riscv-initrd.patch +++ /dev/null @@ -1,48 +0,0 @@ -commit 1e5f6473492f41355289d022003a049ebf8995fa -Author: Shea Levy -Date: Tue Feb 20 07:52:14 2018 -0500 - - riscv: Respect the initrd found in the dt, if any. - - Signed-off-by: Shea Levy - -diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c -index 41d34008faf6..c4ebc907af34 100644 ---- a/arch/riscv/kernel/setup.c -+++ b/arch/riscv/kernel/setup.c -@@ -88,15 +88,20 @@ static void __init setup_initrd(void) - extern unsigned long __initramfs_size; - unsigned long size; - -+ if (initrd_start) -+ goto found; -+ - if (__initramfs_size > 0) { - initrd_start = (unsigned long)(&__initramfs_start); - initrd_end = initrd_start + __initramfs_size; - } - -+ initrd_below_start_ok = 1; - if (initrd_start >= initrd_end) { - printk(KERN_INFO "initrd not found or empty"); - goto disable; - } -+found: - if (__pa(initrd_end) > PFN_PHYS(max_low_pfn)) { - printk(KERN_ERR "initrd extends beyond end of memory"); - goto disable; -@@ -104,13 +109,13 @@ static void __init setup_initrd(void) - - size = initrd_end - initrd_start; - memblock_reserve(__pa(initrd_start), size); -- initrd_below_start_ok = 1; - - printk(KERN_INFO "Initial ramdisk at: 0x%p (%lu bytes)\n", - (void *)(initrd_start), size); - return; - disable: - pr_cont(" - disabling initrd\n"); -+ initrd_below_start_ok = 0; - initrd_start = 0; - initrd_end = 0; - } diff --git a/pkgs/os-specific/linux/kernel/riscv-install.patch b/pkgs/os-specific/linux/kernel/riscv-install.patch deleted file mode 100644 index 707230e9a33..00000000000 --- a/pkgs/os-specific/linux/kernel/riscv-install.patch +++ /dev/null @@ -1,65 +0,0 @@ -commit 365fc1312f4911bfae25c5914c398f9aca21948f -Author: Shea Levy -Date: Mon Feb 19 10:50:58 2018 -0500 - - riscv: Add install target to Makefile. - - Signed-off-by: Shea Levy - -diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile -index 6719dd30ec5b..26892daefa05 100644 ---- a/arch/riscv/Makefile -+++ b/arch/riscv/Makefile -@@ -70,3 +70,7 @@ core-y += arch/riscv/kernel/ arch/riscv/mm/ - libs-y += arch/riscv/lib/ - - all: vmlinux -+ -+PHONY += install -+install: vmlinux -+ sh $(srctree)/arch/riscv/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)" -diff --git a/arch/riscv/install.sh b/arch/riscv/install.sh -new file mode 100644 -index 000000000000..8b3155a11a4a ---- /dev/null -+++ b/arch/riscv/install.sh -@@ -0,0 +1,39 @@ -+#!/bin/sh -+# -+# arch/riscv/install.sh -+# -+# This file is subject to the terms and conditions of the GNU General Public -+# License. See the file "COPYING" in the main directory of this archive -+# for more details. -+# -+# Copyright (C) 1995 by Linus Torvalds -+# -+# Adapted from code in arch/ia64/Makefile by Shea Levy -+# -+# "make install" script for riscv architecture -+# -+# Arguments: -+# $1 - kernel version -+# $2 - kernel image file -+# $3 - kernel map file -+# $4 - default install path (blank if root directory) -+# -+ -+# User may have a custom install script -+ -+if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -+if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi -+ -+# Default install - no bootloader configuration (yet?) -+base=$(basename $2) -+ -+if [ -f $4/$base ]; then -+ mv $4/$base $4/$base.old -+fi -+ -+if [ -f $4/System.map ]; then -+ mv $4/System.map $4/System.old -+fi -+ -+cat $2 > $4/$base -+cp $3 $4/System.map diff --git a/pkgs/os-specific/linux/kernel/riscv-irq-busy.patch b/pkgs/os-specific/linux/kernel/riscv-irq-busy.patch deleted file mode 100644 index 5f5e8f0c8b7..00000000000 --- a/pkgs/os-specific/linux/kernel/riscv-irq-busy.patch +++ /dev/null @@ -1,42 +0,0 @@ -commit 2603e6087b26e9428b806b267aee6bcb919abcea -Author: Shea Levy -Date: Sun Feb 18 20:08:30 2018 -0500 - - set_handle_irq: Return EBUSY if the handler has already been registered. - - This is what's expected by the comments and at least by irq-riscv-intc.c - - Signed-off-by: Shea Levy - -diff --git a/include/linux/irq.h b/include/linux/irq.h -index 2930fd2572e4..77e97872a13e 100644 ---- a/include/linux/irq.h -+++ b/include/linux/irq.h -@@ -1179,7 +1179,7 @@ int ipi_send_mask(unsigned int virq, const struct cpumask *dest); - * Returns 0 on success, or -EBUSY if an IRQ handler has already been - * registered. - */ --void __init set_handle_irq(void (*handle_irq)(struct pt_regs *)); -+int __init set_handle_irq(void (*handle_irq)(struct pt_regs *)); - - /* - * Allows interrupt handlers to find the irqchip that's been registered as the -diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c -index dee4f9a172ca..3570c715c3e7 100644 ---- a/kernel/irq/handle.c -+++ b/kernel/irq/handle.c -@@ -213,11 +213,12 @@ irqreturn_t handle_irq_event(struct irq_desc *desc) - } - - #ifdef CONFIG_GENERIC_IRQ_MULTI_HANDLER --void __init set_handle_irq(void (*handle_irq)(struct pt_regs *)) -+int __init set_handle_irq(void (*handle_irq)(struct pt_regs *)) - { - if (handle_arch_irq) -- return; -+ return -EBUSY; - - handle_arch_irq = handle_irq; -+ return 0; - } - #endif diff --git a/pkgs/os-specific/linux/kernel/riscv-modules.patch b/pkgs/os-specific/linux/kernel/riscv-modules.patch deleted file mode 100644 index 6d5356e0e46..00000000000 --- a/pkgs/os-specific/linux/kernel/riscv-modules.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff -Naur linux-4.15.4-orig/arch/riscv/configs/defconfig linux-4.15.4/arch/riscv/configs/defconfig ---- linux-4.15.4-orig/arch/riscv/configs/defconfig 2018-02-16 14:07:01.000000000 -0500 -+++ linux-4.15.4/arch/riscv/configs/defconfig 2018-02-18 18:33:09.488431900 -0500 -@@ -12,6 +12,7 @@ - CONFIG_NAMESPACES=y - CONFIG_USER_NS=y - CONFIG_BLK_DEV_INITRD=y -+CONFIG_MODULES=y - CONFIG_EXPERT=y - CONFIG_CHECKPOINT_RESTORE=y - CONFIG_BPF_SYSCALL=y diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7dcaf5f6433..b889a0328d7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13162,13 +13162,7 @@ with pkgs; kernelPatches = [ kernelPatches.bridge_stp_helper kernelPatches.modinst_arg_list_too_long - ] ++ lib.optionals hostPlatform.isRiscV [ - kernelPatches.riscv_modules - kernelPatches.riscv_irq_busy - kernelPatches.riscv_install - kernelPatches.riscv_initrd - kernelPatches.riscv_initrd_free - ]; + ]; }; linux_samus_4_12 = callPackage ../os-specific/linux/kernel/linux-samus-4.12.nix { @@ -13179,7 +13173,7 @@ with pkgs; # when adding a new linux version kernelPatches.cpu-cgroup-v2."4.11" kernelPatches.modinst_arg_list_too_long - ]; + ]; }; /* Linux kernel modules are inherently tied to a specific kernel. So