uml: Add 4.9 kernel patches
[openwrt/openwrt.git] / target / linux / uml / patches-4.9 / 003-um-Fix-check-for-_xstate-for-older-hosts.patch
1 From 2fb44600fe784449404c6639de26af8361999ec7 Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <f.fainelli@gmail.com>
3 Date: Tue, 18 Jul 2017 16:43:47 -0700
4 Subject: [PATCH] um: Fix check for _xstate for older hosts
5
6 Commit 0a987645672e ("um: Allow building and running on older
7 hosts") attempted to check for PTRACE_{GET,SET}REGSET under the premise
8 that these ptrace(2) parameters were directly linked with the presence
9 of the _xstate structure.
10
11 After Richard's commit 61e8d462457f ("um: Correctly check for
12 PTRACE_GETRESET/SETREGSET") which properly included linux/ptrace.h
13 instead of asm/ptrace.h, we could get into the original build failure
14 that I reported:
15
16 arch/x86/um/user-offsets.c: In function 'foo':
17 arch/x86/um/user-offsets.c:54: error: invalid application of 'sizeof' to
18 incomplete type 'struct _xstate'
19
20 On this particular host, we do have PTRACE_GETREGSET and
21 PTRACE_SETREGSET defined in linux/ptrace.h, but not the structure
22 _xstate that should be pulled from the following include chain: signal.h
23 -> bits/sigcontext.h.
24
25 Correctly fix this by checking for FP_XSTATE_MAGIC1 which is the correct
26 way to see if struct _xstate is available or not on the host.
27
28 Fixes: 61e8d462457f ("um: Correctly check for PTRACE_GETRESET/SETREGSET")
29 Fixes: 0a987645672e ("um: Allow building and running on older hosts")
30 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
31 Signed-off-by: Richard Weinberger <richard@nod.at>
32 ---
33 arch/x86/um/user-offsets.c | 2 +-
34 1 file changed, 1 insertion(+), 1 deletion(-)
35
36 --- a/arch/x86/um/user-offsets.c
37 +++ b/arch/x86/um/user-offsets.c
38 @@ -50,7 +50,7 @@ void foo(void)
39 DEFINE(HOST_GS, GS);
40 DEFINE(HOST_ORIG_AX, ORIG_EAX);
41 #else
42 -#if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET)
43 +#ifdef FP_XSTATE_MAGIC1
44 DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long));
45 #else
46 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));