kernel: bump 4.9 to 4.9.63
[openwrt/openwrt.git] / target / linux / uml / patches-4.9 / 001-um-Allow-building-and-running-on-older-hosts.patch
1 From 0a987645672ebde7844a9c0732a5a25f3d4bb6c6 Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <f.fainelli@gmail.com>
3 Date: Thu, 25 May 2017 11:36:26 -0700
4 Subject: [PATCH] um: Allow building and running on older hosts
5
6 [ Upstream commit 0a987645672ebde7844a9c0732a5a25f3d4bb6c6 ]
7
8 Commit a78ff1112263 ("um: add extended processor state save/restore
9 support") and b6024b21fec8 ("um: extend fpstate to _xstate to support
10 YMM registers") forced the use of the x86 FP _xstate and
11 PTRACE_GETREGSET/SETREGSET. On older hosts, we would neither be able to
12 build UML nor run it anymore with these two commits applied because we
13 don't have definitions for struct _xstate nor these two ptrace requests.
14
15 We can determine at build time which fp context structure to check
16 against, just like we can keep using the old i387 fp save/restore if
17 PTRACE_GETRESET/SETREGSET are not defined.
18
19 Fixes: a78ff1112263 ("um: add extended processor state save/restore support")
20 Fixes: b6024b21fec8 ("um: extend fpstate to _xstate to support YMM registers")
21 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
22 Signed-off-by: Richard Weinberger <richard@nod.at>
23 ---
24 arch/x86/um/os-Linux/registers.c | 12 ++++++++----
25 arch/x86/um/user-offsets.c | 4 ++++
26 2 files changed, 12 insertions(+), 4 deletions(-)
27
28 --- a/arch/x86/um/os-Linux/registers.c
29 +++ b/arch/x86/um/os-Linux/registers.c
30 @@ -26,6 +26,7 @@ int save_i387_registers(int pid, unsigne
31
32 int save_fp_registers(int pid, unsigned long *fp_regs)
33 {
34 +#ifdef PTRACE_GETREGSET
35 struct iovec iov;
36
37 if (have_xstate_support) {
38 @@ -34,9 +35,9 @@ int save_fp_registers(int pid, unsigned
39 if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) < 0)
40 return -errno;
41 return 0;
42 - } else {
43 + } else
44 +#endif
45 return save_i387_registers(pid, fp_regs);
46 - }
47 }
48
49 int restore_i387_registers(int pid, unsigned long *fp_regs)
50 @@ -48,6 +49,7 @@ int restore_i387_registers(int pid, unsi
51
52 int restore_fp_registers(int pid, unsigned long *fp_regs)
53 {
54 +#ifdef PTRACE_SETREGSET
55 struct iovec iov;
56
57 if (have_xstate_support) {
58 @@ -56,9 +58,9 @@ int restore_fp_registers(int pid, unsign
59 if (ptrace(PTRACE_SETREGSET, pid, NT_X86_XSTATE, &iov) < 0)
60 return -errno;
61 return 0;
62 - } else {
63 + } else
64 +#endif
65 return restore_i387_registers(pid, fp_regs);
66 - }
67 }
68
69 #ifdef __i386__
70 @@ -122,6 +124,7 @@ int put_fp_registers(int pid, unsigned l
71
72 void arch_init_registers(int pid)
73 {
74 +#ifdef PTRACE_GETREGSET
75 struct _xstate fp_regs;
76 struct iovec iov;
77
78 @@ -129,6 +132,7 @@ void arch_init_registers(int pid)
79 iov.iov_len = sizeof(struct _xstate);
80 if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) == 0)
81 have_xstate_support = 1;
82 +#endif
83 }
84 #endif
85
86 --- a/arch/x86/um/user-offsets.c
87 +++ b/arch/x86/um/user-offsets.c
88 @@ -50,7 +50,11 @@ void foo(void)
89 DEFINE(HOST_GS, GS);
90 DEFINE(HOST_ORIG_AX, ORIG_EAX);
91 #else
92 +#if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET)
93 DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long));
94 +#else
95 + DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
96 +#endif
97 DEFINE_LONGS(HOST_BX, RBX);
98 DEFINE_LONGS(HOST_CX, RCX);
99 DEFINE_LONGS(HOST_DI, RDI);