summary refs log tree commit diff
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2018-02-19 12:14:22 -0500
committerShea Levy <shea@shealevy.com>2018-02-19 12:14:22 -0500
commit6173f2f945a2a62fb20caa86947e5f68ccacfdd8 (patch)
treee689a2685a612bef33ba207c52e5c3aec5cb01ac
parent3f9c900e42bb84706a61d43250dc9ef61904f500 (diff)
downloadnixlib-6173f2f945a2a62fb20caa86947e5f68ccacfdd8.tar
nixlib-6173f2f945a2a62fb20caa86947e5f68ccacfdd8.tar.gz
nixlib-6173f2f945a2a62fb20caa86947e5f68ccacfdd8.tar.bz2
nixlib-6173f2f945a2a62fb20caa86947e5f68ccacfdd8.tar.lz
nixlib-6173f2f945a2a62fb20caa86947e5f68ccacfdd8.tar.xz
nixlib-6173f2f945a2a62fb20caa86947e5f68ccacfdd8.tar.zst
nixlib-6173f2f945a2a62fb20caa86947e5f68ccacfdd8.zip
linux_riscv: Add 4.16-rc1.
Fixes #35148.
-rw-r--r--lib/systems/platforms.nix6
-rw-r--r--pkgs/os-specific/linux/kernel/linux-riscv.nix18
-rw-r--r--pkgs/os-specific/linux/kernel/patches.nix16
-rw-r--r--pkgs/os-specific/linux/kernel/riscv-install.patch65
-rw-r--r--pkgs/os-specific/linux/kernel/riscv-irq-busy.patch42
-rw-r--r--pkgs/os-specific/linux/kernel/riscv-modules.patch11
-rw-r--r--pkgs/top-level/all-packages.nix7
7 files changed, 165 insertions, 0 deletions
diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix
index 3106c05dd5d2..938368db02f0 100644
--- a/lib/systems/platforms.nix
+++ b/lib/systems/platforms.nix
@@ -545,6 +545,12 @@ rec {
     name = "riscv-multiplatform";
     kernelArch = "riscv";
     bfdEmulation = "elf${bits}lriscv";
+    kernelTarget = "vmlinux";
+    kernelAutoModules = true;
+    kernelBaseConfig = "defconfig";
+    kernelExtraConfig = ''
+      FTRACE n
+    '';
   };
 
   selectBySystem = system: {
diff --git a/pkgs/os-specific/linux/kernel/linux-riscv.nix b/pkgs/os-specific/linux/kernel/linux-riscv.nix
new file mode 100644
index 000000000000..b2eb0a69a8ec
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/linux-riscv.nix
@@ -0,0 +1,18 @@
+{ stdenv, buildPackages, hostPlatform, fetchFromGitHub, perl, buildLinux, libelf, utillinux, ... } @ args:
+
+buildLinux (args // rec {
+  version = "4.16-rc1";
+  modDirVersion = "4.16.0-rc1";
+  extraMeta.branch = "4.16";
+
+  src = fetchFromGitHub {
+    owner = "riscv";
+    repo ="riscv-linux";
+    rev = "a31991a9c6ce2c86fd676cf458a0ec10edc20d37";
+    sha256 = "0n97wfbi3pnp5c70xfj7s0fk8zjjkjz6ldxh7n54kbf64l4in01f";
+  };
+
+  # Should the testing kernels ever be built on Hydra?
+  extraMeta.hydraPlatforms = [];
+
+} // (args.argsOverride or {}))
diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix
index 754a2372c6d8..39af0a679361 100644
--- a/pkgs/os-specific/linux/kernel/patches.nix
+++ b/pkgs/os-specific/linux/kernel/patches.nix
@@ -72,4 +72,20 @@ rec {
       sha256 = "09096npxpgvlwdz3pb3m9brvxh7vy0xc9z9p8hh85xyczyzcsjhr";
     };
   };
+
+  riscv_modules = {
+    name = "riscv-modules";
+    patch = ./riscv-modules.patch;
+  };
+
+  riscv_irq_busy = {
+    name = "riscv-irq-busy";
+    patch = ./riscv-irq-busy.patch;
+  };
+
+  riscv_install = {
+    name = "riscv-install";
+    patch = ./riscv-install.patch;
+  };
+
 }
diff --git a/pkgs/os-specific/linux/kernel/riscv-install.patch b/pkgs/os-specific/linux/kernel/riscv-install.patch
new file mode 100644
index 000000000000..707230e9a336
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/riscv-install.patch
@@ -0,0 +1,65 @@
+commit 365fc1312f4911bfae25c5914c398f9aca21948f
+Author: Shea Levy <shea@shealevy.com>
+Date:   Mon Feb 19 10:50:58 2018 -0500
+
+    riscv: Add install target to Makefile.
+    
+    Signed-off-by: Shea Levy <shea@shealevy.com>
+
+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
new file mode 100644
index 000000000000..5f5e8f0c8b7b
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/riscv-irq-busy.patch
@@ -0,0 +1,42 @@
+commit 2603e6087b26e9428b806b267aee6bcb919abcea
+Author: Shea Levy <shea@shealevy.com>
+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 <shea@shealevy.com>
+
+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
new file mode 100644
index 000000000000..6d5356e0e46f
--- /dev/null
+++ b/pkgs/os-specific/linux/kernel/riscv-modules.patch
@@ -0,0 +1,11 @@
+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 82a908c69fc8..632a67a6fb11 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -13107,6 +13107,13 @@ with pkgs;
       ];
   };
 
+  linux_riscv = callPackage ../os-specific/linux/kernel/linux-riscv.nix {
+    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 ];
+  };
+
   linux_samus_4_12 = callPackage ../os-specific/linux/kernel/linux-samus-4.12.nix {
     kernelPatches =
       [ kernelPatches.bridge_stp_helper