From b95a1c4f774e37ee605c3c196e1b0d3143d268cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Fri, 25 Mar 2016 09:50:08 +0000 Subject: [PATCH] kernel: fix build of 3.10 and 3.12 on i686 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 23730413fef4be7fe365f452fcaef16c5f4e4b1b) Signed-off-by: Domen Kožar --- .../linux/kernel/gcc5-link-apm.patch | 29 ++++++++++++ .../linux/kernel/gcc5-link-lguest.patch | 46 +++++++++++++++++++ pkgs/os-specific/linux/kernel/patches.nix | 10 ++++ pkgs/top-level/all-packages.nix | 4 +- 4 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 pkgs/os-specific/linux/kernel/gcc5-link-apm.patch create mode 100644 pkgs/os-specific/linux/kernel/gcc5-link-lguest.patch diff --git a/pkgs/os-specific/linux/kernel/gcc5-link-apm.patch b/pkgs/os-specific/linux/kernel/gcc5-link-apm.patch new file mode 100644 index 000000000000..e415c2d9f2b4 --- /dev/null +++ b/pkgs/os-specific/linux/kernel/gcc5-link-apm.patch @@ -0,0 +1,29 @@ +From 54c2f3fdb941204cad136024c7b854b7ad112ab6 Mon Sep 17 00:00:00 2001 +From: Andi Kleen +Date: Mon, 5 Aug 2013 15:02:45 -0700 +Subject: x86, asmlinkage, apm: Make APM data structure used from assembler + visible + +Signed-off-by: Andi Kleen +Link: http://lkml.kernel.org/r/1375740170-7446-12-git-send-email-andi@firstfloor.org +Signed-off-by: H. Peter Anvin +--- + arch/x86/kernel/apm_32.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c +index 53a4e27..3ab0343 100644 +--- a/arch/x86/kernel/apm_32.c ++++ b/arch/x86/kernel/apm_32.c +@@ -392,7 +392,7 @@ static struct cpuidle_device apm_cpuidle_device; + /* + * Local variables + */ +-static struct { ++__visible struct { + unsigned long offset; + unsigned short segment; + } apm_bios_entry; +-- +cgit v0.12 + diff --git a/pkgs/os-specific/linux/kernel/gcc5-link-lguest.patch b/pkgs/os-specific/linux/kernel/gcc5-link-lguest.patch new file mode 100644 index 000000000000..b2474f572ae1 --- /dev/null +++ b/pkgs/os-specific/linux/kernel/gcc5-link-lguest.patch @@ -0,0 +1,46 @@ +From cdd77e87eae52b7251acc5990207a1c4500a84ce Mon Sep 17 00:00:00 2001 +From: Andi Kleen +Date: Tue, 5 Nov 2013 21:22:28 +1030 +Subject: x86, asmlinkage, lguest: Pass in globals into assembler statement + +Tell the compiler that the inline assembler statement +references lguest_entry. + +This fixes compile problems with LTO where the variable +and the assembler code may end up in different files. + +Cc: x86@kernel.org +Cc: rusty@rustcorp.com.au +Signed-off-by: Andi Kleen +Signed-off-by: Rusty Russell +--- + drivers/lguest/x86/core.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c +index 5169239..922a1ac 100644 +--- a/drivers/lguest/x86/core.c ++++ b/drivers/lguest/x86/core.c +@@ -157,7 +157,7 @@ static void run_guest_once(struct lg_cpu *cpu, struct lguest_pages *pages) + * stack, then the address of this call. This stack layout happens to + * exactly match the stack layout created by an interrupt... + */ +- asm volatile("pushf; lcall *lguest_entry" ++ asm volatile("pushf; lcall *%4" + /* + * This is how we tell GCC that %eax ("a") and %ebx ("b") + * are changed by this routine. The "=" means output. +@@ -169,7 +169,9 @@ static void run_guest_once(struct lg_cpu *cpu, struct lguest_pages *pages) + * physical address of the Guest's top-level page + * directory. + */ +- : "0"(pages), "1"(__pa(cpu->lg->pgdirs[cpu->cpu_pgd].pgdir)) ++ : "0"(pages), ++ "1"(__pa(cpu->lg->pgdirs[cpu->cpu_pgd].pgdir)), ++ "m"(lguest_entry) + /* + * We tell gcc that all these registers could change, + * which means we don't have to save and restore them in +-- +cgit v0.12 + diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix index 67f6ad9c94a1..a8fb1598af7e 100644 --- a/pkgs/os-specific/linux/kernel/patches.nix +++ b/pkgs/os-specific/linux/kernel/patches.nix @@ -35,6 +35,16 @@ in rec { + link_lguest = + { name = "gcc5-link-lguest"; + patch = ./gcc5-link-lguest.patch; + }; + + link_apm = + { name = "gcc5-link-apm"; + patch = ./gcc5-link-apm.patch; + }; + bridge_stp_helper = { name = "bridge-stp-helper"; patch = ./bridge-stp-helper.patch; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 40984e5ea022..f8a5bdb8605f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10378,7 +10378,7 @@ in }; linux_3_10 = callPackage ../os-specific/linux/kernel/linux-3.10.nix { - kernelPatches = [ kernelPatches.bridge_stp_helper ] + kernelPatches = with kernelPatches; [ bridge_stp_helper link_lguest link_apm ] ++ lib.optionals ((platform.kernelArch or null) == "mips") [ kernelPatches.mips_fpureg_emu kernelPatches.mips_fpu_sigill @@ -10387,7 +10387,7 @@ in }; linux_3_12 = callPackage ../os-specific/linux/kernel/linux-3.12.nix { - kernelPatches = [ kernelPatches.bridge_stp_helper kernelPatches.crc_regression ] + kernelPatches = with kernelPatches; [ bridge_stp_helper crc_regression link_lguest ] ++ lib.optionals ((platform.kernelArch or null) == "mips") [ kernelPatches.mips_fpureg_emu kernelPatches.mips_fpu_sigill