Skip to content

Commit

Permalink
linux_riscv: Add 4.16-rc1.
Browse files Browse the repository at this point in the history
Fixes #35148.
  • Loading branch information
shlevy committed Feb 19, 2018
1 parent 3f9c900 commit 6173f2f
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/systems/platforms.nix
Expand Up @@ -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: {
Expand Down
18 changes: 18 additions & 0 deletions 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 {}))
16 changes: 16 additions & 0 deletions pkgs/os-specific/linux/kernel/patches.nix
Expand Up @@ -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;
};

}
65 changes: 65 additions & 0 deletions 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
42 changes: 42 additions & 0 deletions 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
11 changes: 11 additions & 0 deletions 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
7 changes: 7 additions & 0 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -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
Expand Down

0 comments on commit 6173f2f

Please sign in to comment.