Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Mon, 23 Oct 2017 16:31:43
Message-Id: 1508776285.f04f7d5137cc4c1e2123c3d450b3e92165cd78fe.mpagano@gentoo
1 commit: f04f7d5137cc4c1e2123c3d450b3e92165cd78fe
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Mon Oct 23 16:31:25 2017 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Mon Oct 23 16:31:25 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=f04f7d51
7
8 Linux 4.14. Patch to support for namespace user.pax.* on tmpfs. Patch to enable link security restrictions by default. Patch that provides Workaround to enable poweroff on Mac Pro 11. See bug #601964. hid-apple patch that enables swapping of the FN and left Control keys and some additional on some apple keyboards. Patch to ensure that /dev/root doesn't appear in /proc/mounts when bootint without an initramfs. Patch to enable control of the unaligned access control policy from sysctl. Patch that adds Gentoo Linux support config settings and defaults. Kernel patch that enables gcc >= v4.9 optimizations for additional CPUs.
9
10 0000_README | 29 ++
11 1500_XATTR_USER_PREFIX.patch | 69 +++
12 ...ble-link-security-restrictions-by-default.patch | 22 +
13 2300_enable-poweroff-on-Mac-Pro-11.patch | 76 +++
14 2600_enable-key-swapping-for-apple-mac.patch | 114 +++++
15 2900_dev-root-proc-mount-fix.patch | 38 ++
16 4400_alpha-sysctl-uac.patch | 142 ++++++
17 ...able-additional-cpu-optimizations-for-gcc.patch | 530 +++++++++++++++++++++
18 8 files changed, 1020 insertions(+)
19
20 diff --git a/0000_README b/0000_README
21 index 9018993..6bcc0b5 100644
22 --- a/0000_README
23 +++ b/0000_README
24 @@ -43,6 +43,35 @@ EXPERIMENTAL
25 Individual Patch Descriptions:
26 --------------------------------------------------------------------------
27
28 +Patch: 1500_XATTR_USER_PREFIX.patch
29 +From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 +Desc: Support for namespace user.pax.* on tmpfs.
31 +
32 +Patch: 1510_fs-enable-link-security-restrictions-by-default.patch
33 +From: http://sources.debian.net/src/linux/3.16.7-ckt4-3/debian/patches/debian/fs-enable-link-security-restrictions-by-default.patch/
34 +Desc: Enable link security restrictions by default.
35 +
36 +Patch: 2300_enable-poweroff-on-Mac-Pro-11.patch
37 +From: http://kernel.ubuntu.com/git/ubuntu/ubuntu-xenial.git/patch/drivers/pci/quirks.c?id=5080ff61a438f3dd80b88b423e1a20791d8a774c
38 +Desc: Workaround to enable poweroff on Mac Pro 11. See bug #601964.
39 +
40 +Patch: 2600_enable-key-swapping-for-apple-mac.patch
41 +From: https://github.com/free5lot/hid-apple-patched
42 +Desc: This hid-apple patch enables swapping of the FN and left Control keys and some additional on some apple keyboards. See bug #622902
43 +
44 +Patch: 2900_dev-root-proc-mount-fix.patch
45 +From: https://bugs.gentoo.org/show_bug.cgi?id=438380
46 +Desc: Ensure that /dev/root doesn't appear in /proc/mounts when bootint without an initramfs.
47 +
48 +Patch: 4400_alpha-sysctl-uac.patch
49 +From: Tobias Klausmann (klausman@g.o) and http://bugs.gentoo.org/show_bug.cgi?id=217323
50 +Desc: Enable control of the unaligned access control policy from sysctl
51 +
52 Patch: 4567_distro-Gentoo-Kconfig.patch
53 From: Tom Wijsman <TomWij@g.o>
54 Desc: Add Gentoo Linux support config settings and defaults.
55 +
56 +Patch: 5010_enable-additional-cpu-optimizations-for-gcc.patch
57 +From: https://github.com/graysky2/kernel_gcc_patch/
58 +Desc: Kernel patch enables gcc >= v4.9 optimizations for additional CPUs.
59 +
60
61 diff --git a/1500_XATTR_USER_PREFIX.patch b/1500_XATTR_USER_PREFIX.patch
62 new file mode 100644
63 index 0000000..bacd032
64 --- /dev/null
65 +++ b/1500_XATTR_USER_PREFIX.patch
66 @@ -0,0 +1,69 @@
67 +From: Anthony G. Basile <blueness@g.o>
68 +
69 +This patch adds support for a restricted user-controlled namespace on
70 +tmpfs filesystem used to house PaX flags. The namespace must be of the
71 +form user.pax.* and its value cannot exceed a size of 8 bytes.
72 +
73 +This is needed even on all Gentoo systems so that XATTR_PAX flags
74 +are preserved for users who might build packages using portage on
75 +a tmpfs system with a non-hardened kernel and then switch to a
76 +hardened kernel with XATTR_PAX enabled.
77 +
78 +The namespace is added to any user with Extended Attribute support
79 +enabled for tmpfs. Users who do not enable xattrs will not have
80 +the XATTR_PAX flags preserved.
81 +
82 +diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
83 +index 1590c49..5eab462 100644
84 +--- a/include/uapi/linux/xattr.h
85 ++++ b/include/uapi/linux/xattr.h
86 +@@ -73,5 +73,9 @@
87 + #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
88 + #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
89 +
90 ++/* User namespace */
91 ++#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
92 ++#define XATTR_PAX_FLAGS_SUFFIX "flags"
93 ++#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
94 +
95 + #endif /* _UAPI_LINUX_XATTR_H */
96 +diff --git a/mm/shmem.c b/mm/shmem.c
97 +index 440e2a7..c377172 100644
98 +--- a/mm/shmem.c
99 ++++ b/mm/shmem.c
100 +@@ -2667,6 +2667,14 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler,
101 + struct shmem_inode_info *info = SHMEM_I(d_inode(dentry));
102 +
103 + name = xattr_full_name(handler, name);
104 ++
105 ++ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
106 ++ if (strcmp(name, XATTR_NAME_PAX_FLAGS))
107 ++ return -EOPNOTSUPP;
108 ++ if (size > 8)
109 ++ return -EINVAL;
110 ++ }
111 ++
112 + return simple_xattr_set(&info->xattrs, name, value, size, flags);
113 + }
114 +
115 +@@ -2682,6 +2690,12 @@ static const struct xattr_handler shmem_trusted_xattr_handler = {
116 + .set = shmem_xattr_handler_set,
117 + };
118 +
119 ++static const struct xattr_handler shmem_user_xattr_handler = {
120 ++ .prefix = XATTR_USER_PREFIX,
121 ++ .get = shmem_xattr_handler_get,
122 ++ .set = shmem_xattr_handler_set,
123 ++};
124 ++
125 + static const struct xattr_handler *shmem_xattr_handlers[] = {
126 + #ifdef CONFIG_TMPFS_POSIX_ACL
127 + &posix_acl_access_xattr_handler,
128 +@@ -2689,6 +2703,7 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
129 + #endif
130 + &shmem_security_xattr_handler,
131 + &shmem_trusted_xattr_handler,
132 ++ &shmem_user_xattr_handler,
133 + NULL
134 + };
135 +
136
137 diff --git a/1510_fs-enable-link-security-restrictions-by-default.patch b/1510_fs-enable-link-security-restrictions-by-default.patch
138 new file mode 100644
139 index 0000000..639fb3c
140 --- /dev/null
141 +++ b/1510_fs-enable-link-security-restrictions-by-default.patch
142 @@ -0,0 +1,22 @@
143 +From: Ben Hutchings <ben@××××××××××××.uk>
144 +Subject: fs: Enable link security restrictions by default
145 +Date: Fri, 02 Nov 2012 05:32:06 +0000
146 +Bug-Debian: https://bugs.debian.org/609455
147 +Forwarded: not-needed
148 +
149 +This reverts commit 561ec64ae67ef25cac8d72bb9c4bfc955edfd415
150 +('VFS: don't do protected {sym,hard}links by default').
151 +
152 +--- a/fs/namei.c
153 ++++ b/fs/namei.c
154 +@@ -651,8 +651,8 @@ static inline void put_link(struct namei
155 + path_put(link);
156 + }
157 +
158 +-int sysctl_protected_symlinks __read_mostly = 0;
159 +-int sysctl_protected_hardlinks __read_mostly = 0;
160 ++int sysctl_protected_symlinks __read_mostly = 1;
161 ++int sysctl_protected_hardlinks __read_mostly = 1;
162 +
163 + /**
164 + * may_follow_link - Check symlink following for unsafe situations
165
166 diff --git a/2300_enable-poweroff-on-Mac-Pro-11.patch b/2300_enable-poweroff-on-Mac-Pro-11.patch
167 new file mode 100644
168 index 0000000..063f2a1
169 --- /dev/null
170 +++ b/2300_enable-poweroff-on-Mac-Pro-11.patch
171 @@ -0,0 +1,76 @@
172 +From 5080ff61a438f3dd80b88b423e1a20791d8a774c Mon Sep 17 00:00:00 2001
173 +From: Chen Yu <yu.c.chen@×××××.com>
174 +Date: Fri, 19 Aug 2016 10:25:57 -0700
175 +Subject: UBUNTU: SAUCE: PCI: Workaround to enable poweroff on Mac Pro 11
176 +
177 +BugLink: http://bugs.launchpad.net/bugs/1587714
178 +
179 +People reported that they can not do a poweroff nor a
180 +suspend to ram on their Mac Pro 11. After some investigations
181 +it was found that, once the PCI bridge 0000:00:1c.0 reassigns its
182 +mm windows to ([mem 0x7fa00000-0x7fbfffff] and
183 +[mem 0x7fc00000-0x7fdfffff 64bit pref]), the region of ACPI
184 +io resource 0x1804 becomes unaccessible immediately, where the
185 +ACPI Sleep register is located, as a result neither poweroff(S5)
186 +nor suspend to ram(S3) works.
187 +
188 +As suggested by Bjorn, further testing shows that, there is an
189 +unreported device may be (using) conflict with above aperture,
190 +which brings unpredictable result such as the failure of accessing
191 +the io port, which blocks the poweroff(S5). Besides if we reassign
192 +the memory aperture to the other place, the poweroff works again.
193 +
194 +As we do not find any resource declared in _CRS which contain above
195 +memory aperture, and Mac OS does not use this pci bridge neither, we
196 +choose a simple workaround to clear the hotplug flag(suggested by
197 +Yinghai Lu), thus do not allocate any resource for this pci bridge,
198 +and thereby no conflict anymore.
199 +
200 +Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=103211
201 +Cc: Bjorn Helgaas <bhelgaas@××××××.com>
202 +Cc: Rafael J. Wysocki <rafael@××××××.org>
203 +Cc: Lukas Wunner <lukas@××××××.de>
204 +Signed-off-by: Chen Yu <yu.c.chen@×××××.com>
205 +Reference: https://patchwork.kernel.org/patch/9289777/
206 +Signed-off-by: Kamal Mostafa <kamal@×××××××××.com>
207 +Acked-by: Brad Figg <brad.figg@×××××××××.com>
208 +Acked-by: Stefan Bader <stefan.bader@×××××××××.com>
209 +Signed-off-by: Tim Gardner <tim.gardner@×××××××××.com>
210 +---
211 + drivers/pci/quirks.c | 20 ++++++++++++++++++++
212 + 1 file changed, 20 insertions(+)
213 +
214 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
215 +index 48cfaa0..23968b6 100644
216 +--- a/drivers/pci/quirks.c
217 ++++ b/drivers/pci/quirks.c
218 +@@ -2750,6 +2750,26 @@ static void quirk_hotplug_bridge(struct pci_dev *dev)
219 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HINT, 0x0020, quirk_hotplug_bridge);
220 +
221 + /*
222 ++ * Apple: Avoid programming the memory/io aperture of 00:1c.0
223 ++ *
224 ++ * BIOS does not declare any resource for 00:1c.0, but with
225 ++ * hotplug flag set, thus the OS allocates:
226 ++ * [mem 0x7fa00000 - 0x7fbfffff]
227 ++ * [mem 0x7fc00000-0x7fdfffff 64bit pref]
228 ++ * which is conflict with an unreported device, which
229 ++ * causes unpredictable result such as accessing io port.
230 ++ * So clear the hotplug flag to work around it.
231 ++ */
232 ++static void quirk_apple_mbp_poweroff(struct pci_dev *dev)
233 ++{
234 ++ if (dmi_match(DMI_PRODUCT_NAME, "MacBookPro11,4") ||
235 ++ dmi_match(DMI_PRODUCT_NAME, "MacBookPro11,5"))
236 ++ dev->is_hotplug_bridge = 0;
237 ++}
238 ++
239 ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x8c10, quirk_apple_mbp_poweroff);
240 ++
241 ++/*
242 + * This is a quirk for the Ricoh MMC controller found as a part of
243 + * some mulifunction chips.
244 +
245 +--
246 +cgit v0.11.2
247 +
248
249 diff --git a/2600_enable-key-swapping-for-apple-mac.patch b/2600_enable-key-swapping-for-apple-mac.patch
250 new file mode 100644
251 index 0000000..ab228d3
252 --- /dev/null
253 +++ b/2600_enable-key-swapping-for-apple-mac.patch
254 @@ -0,0 +1,114 @@
255 +--- a/drivers/hid/hid-apple.c
256 ++++ b/drivers/hid/hid-apple.c
257 +@@ -52,6 +52,22 @@
258 + "(For people who want to keep Windows PC keyboard muscle memory. "
259 + "[0] = as-is, Mac layout. 1 = swapped, Windows layout.)");
260 +
261 ++static unsigned int swap_fn_leftctrl;
262 ++module_param(swap_fn_leftctrl, uint, 0644);
263 ++MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. "
264 ++ "(For people who want to keep PC keyboard muscle memory. "
265 ++ "[0] = as-is, Mac layout, 1 = swapped, PC layout)");
266 ++
267 ++static unsigned int rightalt_as_rightctrl;
268 ++module_param(rightalt_as_rightctrl, uint, 0644);
269 ++MODULE_PARM_DESC(rightalt_as_rightctrl, "Use the right Alt key as a right Ctrl key. "
270 ++ "[0] = as-is, Mac layout. 1 = Right Alt is right Ctrl");
271 ++
272 ++static unsigned int ejectcd_as_delete;
273 ++module_param(ejectcd_as_delete, uint, 0644);
274 ++MODULE_PARM_DESC(ejectcd_as_delete, "Use Eject-CD key as Delete key. "
275 ++ "([0] = disabled, 1 = enabled)");
276 ++
277 + struct apple_sc {
278 + unsigned long quirks;
279 + unsigned int fn_on;
280 +@@ -164,6 +180,21 @@
281 + { }
282 + };
283 +
284 ++static const struct apple_key_translation swapped_fn_leftctrl_keys[] = {
285 ++ { KEY_FN, KEY_LEFTCTRL },
286 ++ { }
287 ++};
288 ++
289 ++static const struct apple_key_translation rightalt_as_rightctrl_keys[] = {
290 ++ { KEY_RIGHTALT, KEY_RIGHTCTRL },
291 ++ { }
292 ++};
293 ++
294 ++static const struct apple_key_translation ejectcd_as_delete_keys[] = {
295 ++ { KEY_EJECTCD, KEY_DELETE },
296 ++ { }
297 ++};
298 ++
299 + static const struct apple_key_translation *apple_find_translation(
300 + const struct apple_key_translation *table, u16 from)
301 + {
302 +@@ -183,9 +214,11 @@
303 + struct apple_sc *asc = hid_get_drvdata(hid);
304 + const struct apple_key_translation *trans, *table;
305 +
306 +- if (usage->code == KEY_FN) {
307 ++ u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN);
308 ++
309 ++ if (usage->code == fn_keycode) {
310 + asc->fn_on = !!value;
311 +- input_event(input, usage->type, usage->code, value);
312 ++ input_event(input, usage->type, KEY_FN, value);
313 + return 1;
314 + }
315 +
316 +@@ -264,6 +297,30 @@
317 + }
318 + }
319 +
320 ++ if (swap_fn_leftctrl) {
321 ++ trans = apple_find_translation(swapped_fn_leftctrl_keys, usage->code);
322 ++ if (trans) {
323 ++ input_event(input, usage->type, trans->to, value);
324 ++ return 1;
325 ++ }
326 ++ }
327 ++
328 ++ if (ejectcd_as_delete) {
329 ++ trans = apple_find_translation(ejectcd_as_delete_keys, usage->code);
330 ++ if (trans) {
331 ++ input_event(input, usage->type, trans->to, value);
332 ++ return 1;
333 ++ }
334 ++ }
335 ++
336 ++ if (rightalt_as_rightctrl) {
337 ++ trans = apple_find_translation(rightalt_as_rightctrl_keys, usage->code);
338 ++ if (trans) {
339 ++ input_event(input, usage->type, trans->to, value);
340 ++ return 1;
341 ++ }
342 ++ }
343 ++
344 + return 0;
345 + }
346 +
347 +@@ -327,6 +384,21 @@
348 +
349 + for (trans = apple_iso_keyboard; trans->from; trans++)
350 + set_bit(trans->to, input->keybit);
351 ++
352 ++ if (swap_fn_leftctrl) {
353 ++ for (trans = swapped_fn_leftctrl_keys; trans->from; trans++)
354 ++ set_bit(trans->to, input->keybit);
355 ++ }
356 ++
357 ++ if (ejectcd_as_delete) {
358 ++ for (trans = ejectcd_as_delete_keys; trans->from; trans++)
359 ++ set_bit(trans->to, input->keybit);
360 ++ }
361 ++
362 ++ if (rightalt_as_rightctrl) {
363 ++ for (trans = rightalt_as_rightctrl_keys; trans->from; trans++)
364 ++ set_bit(trans->to, input->keybit);
365 ++ }
366 + }
367 +
368 + static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
369
370 diff --git a/2900_dev-root-proc-mount-fix.patch b/2900_dev-root-proc-mount-fix.patch
371 new file mode 100644
372 index 0000000..60af1eb
373 --- /dev/null
374 +++ b/2900_dev-root-proc-mount-fix.patch
375 @@ -0,0 +1,38 @@
376 +--- a/init/do_mounts.c 2015-08-19 10:27:16.753852576 -0400
377 ++++ b/init/do_mounts.c 2015-08-19 10:34:25.473850353 -0400
378 +@@ -490,7 +490,11 @@ void __init change_floppy(char *fmt, ...
379 + va_start(args, fmt);
380 + vsprintf(buf, fmt, args);
381 + va_end(args);
382 +- fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
383 ++ if (saved_root_name[0])
384 ++ fd = sys_open(saved_root_name, O_RDWR | O_NDELAY, 0);
385 ++ else
386 ++ fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
387 ++
388 + if (fd >= 0) {
389 + sys_ioctl(fd, FDEJECT, 0);
390 + sys_close(fd);
391 +@@ -534,11 +538,17 @@ void __init mount_root(void)
392 + #endif
393 + #ifdef CONFIG_BLOCK
394 + {
395 +- int err = create_dev("/dev/root", ROOT_DEV);
396 +-
397 +- if (err < 0)
398 +- pr_emerg("Failed to create /dev/root: %d\n", err);
399 +- mount_block_root("/dev/root", root_mountflags);
400 ++ if (saved_root_name[0] == '/') {
401 ++ int err = create_dev(saved_root_name, ROOT_DEV);
402 ++ if (err < 0)
403 ++ pr_emerg("Failed to create %s: %d\n", saved_root_name, err);
404 ++ mount_block_root(saved_root_name, root_mountflags);
405 ++ } else {
406 ++ int err = create_dev("/dev/root", ROOT_DEV);
407 ++ if (err < 0)
408 ++ pr_emerg("Failed to create /dev/root: %d\n", err);
409 ++ mount_block_root("/dev/root", root_mountflags);
410 ++ }
411 + }
412 + #endif
413 + }
414
415 diff --git a/4400_alpha-sysctl-uac.patch b/4400_alpha-sysctl-uac.patch
416 new file mode 100644
417 index 0000000..d42b4ed
418 --- /dev/null
419 +++ b/4400_alpha-sysctl-uac.patch
420 @@ -0,0 +1,142 @@
421 +diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
422 +index 7f312d8..1eb686b 100644
423 +--- a/arch/alpha/Kconfig
424 ++++ b/arch/alpha/Kconfig
425 +@@ -697,6 +697,33 @@ config HZ
426 + default 1200 if HZ_1200
427 + default 1024
428 +
429 ++config ALPHA_UAC_SYSCTL
430 ++ bool "Configure UAC policy via sysctl"
431 ++ depends on SYSCTL
432 ++ default y
433 ++ ---help---
434 ++ Configuring the UAC (unaligned access control) policy on a Linux
435 ++ system usually involves setting a compile time define. If you say
436 ++ Y here, you will be able to modify the UAC policy at runtime using
437 ++ the /proc interface.
438 ++
439 ++ The UAC policy defines the action Linux should take when an
440 ++ unaligned memory access occurs. The action can include printing a
441 ++ warning message (NOPRINT), sending a signal to the offending
442 ++ program to help developers debug their applications (SIGBUS), or
443 ++ disabling the transparent fixing (NOFIX).
444 ++
445 ++ The sysctls will be initialized to the compile-time defined UAC
446 ++ policy. You can change these manually, or with the sysctl(8)
447 ++ userspace utility.
448 ++
449 ++ To disable the warning messages at runtime, you would use
450 ++
451 ++ echo 1 > /proc/sys/kernel/uac/noprint
452 ++
453 ++ This is pretty harmless. Say Y if you're not sure.
454 ++
455 ++
456 + source "drivers/pci/Kconfig"
457 + source "drivers/eisa/Kconfig"
458 +
459 +diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
460 +index 74aceea..cb35d80 100644
461 +--- a/arch/alpha/kernel/traps.c
462 ++++ b/arch/alpha/kernel/traps.c
463 +@@ -103,6 +103,49 @@ static char * ireg_name[] = {"v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
464 + "t10", "t11", "ra", "pv", "at", "gp", "sp", "zero"};
465 + #endif
466 +
467 ++#ifdef CONFIG_ALPHA_UAC_SYSCTL
468 ++
469 ++#include <linux/sysctl.h>
470 ++
471 ++static int enabled_noprint = 0;
472 ++static int enabled_sigbus = 0;
473 ++static int enabled_nofix = 0;
474 ++
475 ++struct ctl_table uac_table[] = {
476 ++ {
477 ++ .procname = "noprint",
478 ++ .data = &enabled_noprint,
479 ++ .maxlen = sizeof (int),
480 ++ .mode = 0644,
481 ++ .proc_handler = &proc_dointvec,
482 ++ },
483 ++ {
484 ++ .procname = "sigbus",
485 ++ .data = &enabled_sigbus,
486 ++ .maxlen = sizeof (int),
487 ++ .mode = 0644,
488 ++ .proc_handler = &proc_dointvec,
489 ++ },
490 ++ {
491 ++ .procname = "nofix",
492 ++ .data = &enabled_nofix,
493 ++ .maxlen = sizeof (int),
494 ++ .mode = 0644,
495 ++ .proc_handler = &proc_dointvec,
496 ++ },
497 ++ { }
498 ++};
499 ++
500 ++static int __init init_uac_sysctl(void)
501 ++{
502 ++ /* Initialize sysctls with the #defined UAC policy */
503 ++ enabled_noprint = (test_thread_flag (TS_UAC_NOPRINT)) ? 1 : 0;
504 ++ enabled_sigbus = (test_thread_flag (TS_UAC_SIGBUS)) ? 1 : 0;
505 ++ enabled_nofix = (test_thread_flag (TS_UAC_NOFIX)) ? 1 : 0;
506 ++ return 0;
507 ++}
508 ++#endif
509 ++
510 + static void
511 + dik_show_code(unsigned int *pc)
512 + {
513 +@@ -785,7 +828,12 @@ do_entUnaUser(void __user * va, unsigned long opcode,
514 + /* Check the UAC bits to decide what the user wants us to do
515 + with the unaliged access. */
516 +
517 ++#ifndef CONFIG_ALPHA_UAC_SYSCTL
518 + if (!(current_thread_info()->status & TS_UAC_NOPRINT)) {
519 ++#else /* CONFIG_ALPHA_UAC_SYSCTL */
520 ++ if (!(current_thread_info()->status & TS_UAC_NOPRINT) &&
521 ++ !(enabled_noprint)) {
522 ++#endif /* CONFIG_ALPHA_UAC_SYSCTL */
523 + if (__ratelimit(&ratelimit)) {
524 + printk("%s(%d): unaligned trap at %016lx: %p %lx %ld\n",
525 + current->comm, task_pid_nr(current),
526 +@@ -1090,3 +1138,6 @@ trap_init(void)
527 + wrent(entSys, 5);
528 + wrent(entDbg, 6);
529 + }
530 ++#ifdef CONFIG_ALPHA_UAC_SYSCTL
531 ++ __initcall(init_uac_sysctl);
532 ++#endif
533 +diff --git a/kernel/sysctl.c b/kernel/sysctl.c
534 +index 87b2fc3..55021a8 100644
535 +--- a/kernel/sysctl.c
536 ++++ b/kernel/sysctl.c
537 +@@ -152,6 +152,11 @@ static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
538 + #ifdef CONFIG_INOTIFY_USER
539 + #include <linux/inotify.h>
540 + #endif
541 ++
542 ++#ifdef CONFIG_ALPHA_UAC_SYSCTL
543 ++extern struct ctl_table uac_table[];
544 ++#endif
545 ++
546 + #ifdef CONFIG_SPARC
547 + #endif
548 +
549 +@@ -1844,6 +1849,13 @@ static struct ctl_table debug_table[] = {
550 + .extra2 = &one,
551 + },
552 + #endif
553 ++#ifdef CONFIG_ALPHA_UAC_SYSCTL
554 ++ {
555 ++ .procname = "uac",
556 ++ .mode = 0555,
557 ++ .child = uac_table,
558 ++ },
559 ++#endif /* CONFIG_ALPHA_UAC_SYSCTL */
560 + { }
561 + };
562 +
563
564 diff --git a/5010_enable-additional-cpu-optimizations-for-gcc.patch b/5010_enable-additional-cpu-optimizations-for-gcc.patch
565 new file mode 100644
566 index 0000000..c68d072
567 --- /dev/null
568 +++ b/5010_enable-additional-cpu-optimizations-for-gcc.patch
569 @@ -0,0 +1,530 @@
570 +WARNING
571 +This patch works with gcc versions 4.9+ and with kernel version 3.15+ and should
572 +NOT be applied when compiling on older versions of gcc due to key name changes
573 +of the march flags introduced with the version 4.9 release of gcc.[1]
574 +
575 +Use the older version of this patch hosted on the same github for older
576 +versions of gcc.
577 +
578 +FEATURES
579 +This patch adds additional CPU options to the Linux kernel accessible under:
580 + Processor type and features --->
581 + Processor family --->
582 +
583 +The expanded microarchitectures include:
584 +* AMD Improved K8-family
585 +* AMD K10-family
586 +* AMD Family 10h (Barcelona)
587 +* AMD Family 14h (Bobcat)
588 +* AMD Family 16h (Jaguar)
589 +* AMD Family 15h (Bulldozer)
590 +* AMD Family 15h (Piledriver)
591 +* AMD Family 15h (Steamroller)
592 +* AMD Family 15h (Excavator)
593 +* AMD Family 17h (Zen)
594 +* Intel Silvermont low-power processors
595 +* Intel 1st Gen Core i3/i5/i7 (Nehalem)
596 +* Intel 1.5 Gen Core i3/i5/i7 (Westmere)
597 +* Intel 2nd Gen Core i3/i5/i7 (Sandybridge)
598 +* Intel 3rd Gen Core i3/i5/i7 (Ivybridge)
599 +* Intel 4th Gen Core i3/i5/i7 (Haswell)
600 +* Intel 5th Gen Core i3/i5/i7 (Broadwell)
601 +* Intel 6th Gen Core i3/i5.i7 (Skylake)
602 +
603 +It also offers to compile passing the 'native' option which, "selects the CPU
604 +to generate code for at compilation time by determining the processor type of
605 +the compiling machine. Using -march=native enables all instruction subsets
606 +supported by the local machine and will produce code optimized for the local
607 +machine under the constraints of the selected instruction set."[3]
608 +
609 +MINOR NOTES
610 +This patch also changes 'atom' to 'bonnell' in accordance with the gcc v4.9
611 +changes. Note that upstream is using the deprecated 'match=atom' flags when I
612 +believe it should use the newer 'march=bonnell' flag for atom processors.[2]
613 +
614 +It is not recommended to compile on Atom-CPUs with the 'native' option.[4] The
615 +recommendation is use to the 'atom' option instead.
616 +
617 +BENEFITS
618 +Small but real speed increases are measurable using a make endpoint comparing
619 +a generic kernel to one built with one of the respective microarchs.
620 +
621 +See the following experimental evidence supporting this statement:
622 +https://github.com/graysky2/kernel_gcc_patch
623 +
624 +REQUIREMENTS
625 +linux version >=3.15
626 +gcc version >=4.9
627 +
628 +ACKNOWLEDGMENTS
629 +This patch builds on the seminal work by Jeroen.[5]
630 +
631 +REFERENCES
632 +1. https://gcc.gnu.org/gcc-4.9/changes.html
633 +2. https://bugzilla.kernel.org/show_bug.cgi?id=77461
634 +3. https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
635 +4. https://github.com/graysky2/kernel_gcc_patch/issues/15
636 +5. http://www.linuxforge.net/docs/linux/linux-gcc.php
637 +
638 +--- a/arch/x86/include/asm/module.h 2017-08-02 11:41:47.442200461 -0400
639 ++++ b/arch/x86/include/asm/module.h 2017-08-02 12:14:21.204358744 -0400
640 +@@ -15,6 +15,24 @@
641 + #define MODULE_PROC_FAMILY "586MMX "
642 + #elif defined CONFIG_MCORE2
643 + #define MODULE_PROC_FAMILY "CORE2 "
644 ++#elif defined CONFIG_MNATIVE
645 ++#define MODULE_PROC_FAMILY "NATIVE "
646 ++#elif defined CONFIG_MNEHALEM
647 ++#define MODULE_PROC_FAMILY "NEHALEM "
648 ++#elif defined CONFIG_MWESTMERE
649 ++#define MODULE_PROC_FAMILY "WESTMERE "
650 ++#elif defined CONFIG_MSILVERMONT
651 ++#define MODULE_PROC_FAMILY "SILVERMONT "
652 ++#elif defined CONFIG_MSANDYBRIDGE
653 ++#define MODULE_PROC_FAMILY "SANDYBRIDGE "
654 ++#elif defined CONFIG_MIVYBRIDGE
655 ++#define MODULE_PROC_FAMILY "IVYBRIDGE "
656 ++#elif defined CONFIG_MHASWELL
657 ++#define MODULE_PROC_FAMILY "HASWELL "
658 ++#elif defined CONFIG_MBROADWELL
659 ++#define MODULE_PROC_FAMILY "BROADWELL "
660 ++#elif defined CONFIG_MSKYLAKE
661 ++#define MODULE_PROC_FAMILY "SKYLAKE "
662 + #elif defined CONFIG_MATOM
663 + #define MODULE_PROC_FAMILY "ATOM "
664 + #elif defined CONFIG_M686
665 +@@ -33,6 +51,26 @@
666 + #define MODULE_PROC_FAMILY "K7 "
667 + #elif defined CONFIG_MK8
668 + #define MODULE_PROC_FAMILY "K8 "
669 ++#elif defined CONFIG_MK8SSE3
670 ++#define MODULE_PROC_FAMILY "K8SSE3 "
671 ++#elif defined CONFIG_MK10
672 ++#define MODULE_PROC_FAMILY "K10 "
673 ++#elif defined CONFIG_MBARCELONA
674 ++#define MODULE_PROC_FAMILY "BARCELONA "
675 ++#elif defined CONFIG_MBOBCAT
676 ++#define MODULE_PROC_FAMILY "BOBCAT "
677 ++#elif defined CONFIG_MBULLDOZER
678 ++#define MODULE_PROC_FAMILY "BULLDOZER "
679 ++#elif defined CONFIG_MPILEDRIVER
680 ++#define MODULE_PROC_FAMILY "PILEDRIVER "
681 ++#elif defined CONFIG_MSTEAMROLLER
682 ++#define MODULE_PROC_FAMILY "STEAMROLLER "
683 ++#elif defined CONFIG_MJAGUAR
684 ++#define MODULE_PROC_FAMILY "JAGUAR "
685 ++#elif defined CONFIG_MEXCAVATOR
686 ++#define MODULE_PROC_FAMILY "EXCAVATOR "
687 ++#elif defined CONFIG_MZEN
688 ++#define MODULE_PROC_FAMILY "ZEN "
689 + #elif defined CONFIG_MELAN
690 + #define MODULE_PROC_FAMILY "ELAN "
691 + #elif defined CONFIG_MCRUSOE
692 +--- a/arch/x86/Kconfig.cpu 2017-08-02 11:41:47.443200463 -0400
693 ++++ b/arch/x86/Kconfig.cpu 2017-08-02 12:14:37.108956741 -0400
694 +@@ -115,6 +115,7 @@ config MPENTIUMM
695 + config MPENTIUM4
696 + bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon"
697 + depends on X86_32
698 ++ select X86_P6_NOP
699 + ---help---
700 + Select this for Intel Pentium 4 chips. This includes the
701 + Pentium 4, Pentium D, P4-based Celeron and Xeon, and
702 +@@ -147,9 +148,8 @@ config MPENTIUM4
703 + -Paxville
704 + -Dempsey
705 +
706 +-
707 + config MK6
708 +- bool "K6/K6-II/K6-III"
709 ++ bool "AMD K6/K6-II/K6-III"
710 + depends on X86_32
711 + ---help---
712 + Select this for an AMD K6-family processor. Enables use of
713 +@@ -157,7 +157,7 @@ config MK6
714 + flags to GCC.
715 +
716 + config MK7
717 +- bool "Athlon/Duron/K7"
718 ++ bool "AMD Athlon/Duron/K7"
719 + depends on X86_32
720 + ---help---
721 + Select this for an AMD Athlon K7-family processor. Enables use of
722 +@@ -165,12 +165,83 @@ config MK7
723 + flags to GCC.
724 +
725 + config MK8
726 +- bool "Opteron/Athlon64/Hammer/K8"
727 ++ bool "AMD Opteron/Athlon64/Hammer/K8"
728 + ---help---
729 + Select this for an AMD Opteron or Athlon64 Hammer-family processor.
730 + Enables use of some extended instructions, and passes appropriate
731 + optimization flags to GCC.
732 +
733 ++config MK8SSE3
734 ++ bool "AMD Opteron/Athlon64/Hammer/K8 with SSE3"
735 ++ ---help---
736 ++ Select this for improved AMD Opteron or Athlon64 Hammer-family processors.
737 ++ Enables use of some extended instructions, and passes appropriate
738 ++ optimization flags to GCC.
739 ++
740 ++config MK10
741 ++ bool "AMD 61xx/7x50/PhenomX3/X4/II/K10"
742 ++ ---help---
743 ++ Select this for an AMD 61xx Eight-Core Magny-Cours, Athlon X2 7x50,
744 ++ Phenom X3/X4/II, Athlon II X2/X3/X4, or Turion II-family processor.
745 ++ Enables use of some extended instructions, and passes appropriate
746 ++ optimization flags to GCC.
747 ++
748 ++config MBARCELONA
749 ++ bool "AMD Barcelona"
750 ++ ---help---
751 ++ Select this for AMD Family 10h Barcelona processors.
752 ++
753 ++ Enables -march=barcelona
754 ++
755 ++config MBOBCAT
756 ++ bool "AMD Bobcat"
757 ++ ---help---
758 ++ Select this for AMD Family 14h Bobcat processors.
759 ++
760 ++ Enables -march=btver1
761 ++
762 ++config MJAGUAR
763 ++ bool "AMD Jaguar"
764 ++ ---help---
765 ++ Select this for AMD Family 16h Jaguar processors.
766 ++
767 ++ Enables -march=btver2
768 ++
769 ++config MBULLDOZER
770 ++ bool "AMD Bulldozer"
771 ++ ---help---
772 ++ Select this for AMD Family 15h Bulldozer processors.
773 ++
774 ++ Enables -march=bdver1
775 ++
776 ++config MPILEDRIVER
777 ++ bool "AMD Piledriver"
778 ++ ---help---
779 ++ Select this for AMD Family 15h Piledriver processors.
780 ++
781 ++ Enables -march=bdver2
782 ++
783 ++config MSTEAMROLLER
784 ++ bool "AMD Steamroller"
785 ++ ---help---
786 ++ Select this for AMD Family 15h Steamroller processors.
787 ++
788 ++ Enables -march=bdver3
789 ++
790 ++config MEXCAVATOR
791 ++ bool "AMD Excavator"
792 ++ ---help---
793 ++ Select this for AMD Family 15h Excavator processors.
794 ++
795 ++ Enables -march=bdver4
796 ++
797 ++config MZEN
798 ++ bool "AMD Zen"
799 ++ ---help---
800 ++ Select this for AMD Family 17h Zen processors.
801 ++
802 ++ Enables -march=znver1
803 ++
804 + config MCRUSOE
805 + bool "Crusoe"
806 + depends on X86_32
807 +@@ -252,6 +323,7 @@ config MVIAC7
808 +
809 + config MPSC
810 + bool "Intel P4 / older Netburst based Xeon"
811 ++ select X86_P6_NOP
812 + depends on X86_64
813 + ---help---
814 + Optimize for Intel Pentium 4, Pentium D and older Nocona/Dempsey
815 +@@ -261,8 +333,19 @@ config MPSC
816 + using the cpu family field
817 + in /proc/cpuinfo. Family 15 is an older Xeon, Family 6 a newer one.
818 +
819 ++config MATOM
820 ++ bool "Intel Atom"
821 ++ select X86_P6_NOP
822 ++ ---help---
823 ++
824 ++ Select this for the Intel Atom platform. Intel Atom CPUs have an
825 ++ in-order pipelining architecture and thus can benefit from
826 ++ accordingly optimized code. Use a recent GCC with specific Atom
827 ++ support in order to fully benefit from selecting this option.
828 ++
829 + config MCORE2
830 +- bool "Core 2/newer Xeon"
831 ++ bool "Intel Core 2"
832 ++ select X86_P6_NOP
833 + ---help---
834 +
835 + Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and
836 +@@ -270,14 +353,79 @@ config MCORE2
837 + family in /proc/cpuinfo. Newer ones have 6 and older ones 15
838 + (not a typo)
839 +
840 +-config MATOM
841 +- bool "Intel Atom"
842 ++ Enables -march=core2
843 ++
844 ++config MNEHALEM
845 ++ bool "Intel Nehalem"
846 ++ select X86_P6_NOP
847 + ---help---
848 +
849 +- Select this for the Intel Atom platform. Intel Atom CPUs have an
850 +- in-order pipelining architecture and thus can benefit from
851 +- accordingly optimized code. Use a recent GCC with specific Atom
852 +- support in order to fully benefit from selecting this option.
853 ++ Select this for 1st Gen Core processors in the Nehalem family.
854 ++
855 ++ Enables -march=nehalem
856 ++
857 ++config MWESTMERE
858 ++ bool "Intel Westmere"
859 ++ select X86_P6_NOP
860 ++ ---help---
861 ++
862 ++ Select this for the Intel Westmere formerly Nehalem-C family.
863 ++
864 ++ Enables -march=westmere
865 ++
866 ++config MSILVERMONT
867 ++ bool "Intel Silvermont"
868 ++ select X86_P6_NOP
869 ++ ---help---
870 ++
871 ++ Select this for the Intel Silvermont platform.
872 ++
873 ++ Enables -march=silvermont
874 ++
875 ++config MSANDYBRIDGE
876 ++ bool "Intel Sandy Bridge"
877 ++ select X86_P6_NOP
878 ++ ---help---
879 ++
880 ++ Select this for 2nd Gen Core processors in the Sandy Bridge family.
881 ++
882 ++ Enables -march=sandybridge
883 ++
884 ++config MIVYBRIDGE
885 ++ bool "Intel Ivy Bridge"
886 ++ select X86_P6_NOP
887 ++ ---help---
888 ++
889 ++ Select this for 3rd Gen Core processors in the Ivy Bridge family.
890 ++
891 ++ Enables -march=ivybridge
892 ++
893 ++config MHASWELL
894 ++ bool "Intel Haswell"
895 ++ select X86_P6_NOP
896 ++ ---help---
897 ++
898 ++ Select this for 4th Gen Core processors in the Haswell family.
899 ++
900 ++ Enables -march=haswell
901 ++
902 ++config MBROADWELL
903 ++ bool "Intel Broadwell"
904 ++ select X86_P6_NOP
905 ++ ---help---
906 ++
907 ++ Select this for 5th Gen Core processors in the Broadwell family.
908 ++
909 ++ Enables -march=broadwell
910 ++
911 ++config MSKYLAKE
912 ++ bool "Intel Skylake"
913 ++ select X86_P6_NOP
914 ++ ---help---
915 ++
916 ++ Select this for 6th Gen Core processors in the Skylake family.
917 ++
918 ++ Enables -march=skylake
919 +
920 + config GENERIC_CPU
921 + bool "Generic-x86-64"
922 +@@ -286,6 +434,19 @@ config GENERIC_CPU
923 + Generic x86-64 CPU.
924 + Run equally well on all x86-64 CPUs.
925 +
926 ++config MNATIVE
927 ++ bool "Native optimizations autodetected by GCC"
928 ++ ---help---
929 ++
930 ++ GCC 4.2 and above support -march=native, which automatically detects
931 ++ the optimum settings to use based on your processor. -march=native
932 ++ also detects and applies additional settings beyond -march specific
933 ++ to your CPU, (eg. -msse4). Unless you have a specific reason not to
934 ++ (e.g. distcc cross-compiling), you should probably be using
935 ++ -march=native rather than anything listed below.
936 ++
937 ++ Enables -march=native
938 ++
939 + endchoice
940 +
941 + config X86_GENERIC
942 +@@ -310,7 +471,7 @@ config X86_INTERNODE_CACHE_SHIFT
943 + config X86_L1_CACHE_SHIFT
944 + int
945 + default "7" if MPENTIUM4 || MPSC
946 +- default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
947 ++ default "6" if MK7 || MK8 || MK8SSE3 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MSTEAMROLLER || MEXCAVATOR || MZEN || MJAGUAR || MPENTIUMM || MCORE2 || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MNATIVE || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
948 + default "4" if MELAN || M486 || MGEODEGX1
949 + default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
950 +
951 +@@ -341,45 +502,46 @@ config X86_ALIGNMENT_16
952 +
953 + config X86_INTEL_USERCOPY
954 + def_bool y
955 +- depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON || MCORE2
956 ++ depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK8SSE3 || MK7 || MEFFICEON || MCORE2 || MK10 || MBARCELONA || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MNATIVE
957 +
958 + config X86_USE_PPRO_CHECKSUM
959 + def_bool y
960 +- depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MATOM
961 ++ depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MK10 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MK8SSE3 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MATOM || MNATIVE
962 +
963 + config X86_USE_3DNOW
964 + def_bool y
965 + depends on (MCYRIXIII || MK7 || MGEODE_LX) && !UML
966 +
967 +-#
968 +-# P6_NOPs are a relatively minor optimization that require a family >=
969 +-# 6 processor, except that it is broken on certain VIA chips.
970 +-# Furthermore, AMD chips prefer a totally different sequence of NOPs
971 +-# (which work on all CPUs). In addition, it looks like Virtual PC
972 +-# does not understand them.
973 +-#
974 +-# As a result, disallow these if we're not compiling for X86_64 (these
975 +-# NOPs do work on all x86-64 capable chips); the list of processors in
976 +-# the right-hand clause are the cores that benefit from this optimization.
977 +-#
978 + config X86_P6_NOP
979 +- def_bool y
980 +- depends on X86_64
981 +- depends on (MCORE2 || MPENTIUM4 || MPSC)
982 ++ default n
983 ++ bool "Support for P6_NOPs on Intel chips"
984 ++ depends on (MCORE2 || MPENTIUM4 || MPSC || MATOM || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MNATIVE)
985 ++ ---help---
986 ++ P6_NOPs are a relatively minor optimization that require a family >=
987 ++ 6 processor, except that it is broken on certain VIA chips.
988 ++ Furthermore, AMD chips prefer a totally different sequence of NOPs
989 ++ (which work on all CPUs). In addition, it looks like Virtual PC
990 ++ does not understand them.
991 ++
992 ++ As a result, disallow these if we're not compiling for X86_64 (these
993 ++ NOPs do work on all x86-64 capable chips); the list of processors in
994 ++ the right-hand clause are the cores that benefit from this optimization.
995 ++
996 ++ Say Y if you have Intel CPU newer than Pentium Pro, N otherwise.
997 +
998 + config X86_TSC
999 + def_bool y
1000 +- depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MATOM) || X86_64
1001 ++ depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MK8SSE3 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MNATIVE || MATOM) || X86_64
1002 +
1003 + config X86_CMPXCHG64
1004 + def_bool y
1005 +- depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM
1006 ++ depends on X86_PAE || X86_64 || MCORE2 || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM || MNATIVE
1007 +
1008 + # this should be set for all -march=.. options where the compiler
1009 + # generates cmov.
1010 + config X86_CMOV
1011 + def_bool y
1012 +- depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
1013 ++ depends on (MK8 || MK8SSE3 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MSTEAMROLLER || MEXCAVATOR || MZEN || MJAGUAR || MK7 || MCORE2 || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MNATIVE || MATOM || MGEODE_LX)
1014 +
1015 + config X86_MINIMUM_CPU_FAMILY
1016 + int
1017 +--- a/arch/x86/Makefile 2017-08-02 11:41:47.443200463 -0400
1018 ++++ b/arch/x86/Makefile 2017-08-02 12:14:46.373727353 -0400
1019 +@@ -121,13 +121,40 @@ else
1020 + KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
1021 +
1022 + # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
1023 ++ cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
1024 + cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
1025 ++ cflags-$(CONFIG_MK8SSE3) += $(call cc-option,-march=k8-sse3,-mtune=k8)
1026 ++ cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10)
1027 ++ cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona)
1028 ++ cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1)
1029 ++ cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2)
1030 ++ cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1)
1031 ++ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2)
1032 ++ cflags-$(CONFIG_MSTEAMROLLER) += $(call cc-option,-march=bdver3)
1033 ++ cflags-$(CONFIG_MEXCAVATOR) += $(call cc-option,-march=bdver4)
1034 ++ cflags-$(CONFIG_MZEN) += $(call cc-option,-march=znver1)
1035 + cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
1036 +
1037 + cflags-$(CONFIG_MCORE2) += \
1038 +- $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
1039 +- cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
1040 +- $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
1041 ++ $(call cc-option,-march=core2,$(call cc-option,-mtune=core2))
1042 ++ cflags-$(CONFIG_MNEHALEM) += \
1043 ++ $(call cc-option,-march=nehalem,$(call cc-option,-mtune=nehalem))
1044 ++ cflags-$(CONFIG_MWESTMERE) += \
1045 ++ $(call cc-option,-march=westmere,$(call cc-option,-mtune=westmere))
1046 ++ cflags-$(CONFIG_MSILVERMONT) += \
1047 ++ $(call cc-option,-march=silvermont,$(call cc-option,-mtune=silvermont))
1048 ++ cflags-$(CONFIG_MSANDYBRIDGE) += \
1049 ++ $(call cc-option,-march=sandybridge,$(call cc-option,-mtune=sandybridge))
1050 ++ cflags-$(CONFIG_MIVYBRIDGE) += \
1051 ++ $(call cc-option,-march=ivybridge,$(call cc-option,-mtune=ivybridge))
1052 ++ cflags-$(CONFIG_MHASWELL) += \
1053 ++ $(call cc-option,-march=haswell,$(call cc-option,-mtune=haswell))
1054 ++ cflags-$(CONFIG_MBROADWELL) += \
1055 ++ $(call cc-option,-march=broadwell,$(call cc-option,-mtune=broadwell))
1056 ++ cflags-$(CONFIG_MSKYLAKE) += \
1057 ++ $(call cc-option,-march=skylake,$(call cc-option,-mtune=skylake))
1058 ++ cflags-$(CONFIG_MATOM) += $(call cc-option,-march=bonnell) \
1059 ++ $(call cc-option,-mtune=bonnell,$(call cc-option,-mtune=generic))
1060 + cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
1061 + KBUILD_CFLAGS += $(cflags-y)
1062 +
1063 +--- a/arch/x86/Makefile_32.cpu 2017-08-02 11:41:47.444200464 -0400
1064 ++++ b/arch/x86/Makefile_32.cpu 2017-08-02 12:23:41.636760695 -0400
1065 +@@ -22,7 +22,18 @@ cflags-$(CONFIG_MK6) += -march=k6
1066 + # Please note, that patches that add -march=athlon-xp and friends are pointless.
1067 + # They make zero difference whatsosever to performance at this time.
1068 + cflags-$(CONFIG_MK7) += -march=athlon
1069 ++cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
1070 + cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8,-march=athlon)
1071 ++cflags-$(CONFIG_MK8SSE3) += $(call cc-option,-march=k8-sse3,-march=athlon)
1072 ++cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10,-march=athlon)
1073 ++cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona,-march=athlon)
1074 ++cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1,-march=athlon)
1075 ++cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2,-march=athlon)
1076 ++cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1,-march=athlon)
1077 ++cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2,-march=athlon)
1078 ++cflags-$(CONFIG_MSTEAMROLLER) += $(call cc-option,-march=bdver3,-march=athlon)
1079 ++cflags-$(CONFIG_MEXCAVATOR) += $(call cc-option,-march=bdver4,-march=athlon)
1080 ++cflags-$(CONFIG_MZEN) += $(call cc-option,-march=znver1,-march=athlon)
1081 + cflags-$(CONFIG_MCRUSOE) += -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
1082 + cflags-$(CONFIG_MEFFICEON) += -march=i686 $(call tune,pentium3) -falign-functions=0 -falign-jumps=0 -falign-loops=0
1083 + cflags-$(CONFIG_MWINCHIPC6) += $(call cc-option,-march=winchip-c6,-march=i586)
1084 +@@ -31,9 +42,12 @@ cflags-$(CONFIG_MCYRIXIII) += $(call cc-
1085 + cflags-$(CONFIG_MVIAC3_2) += $(call cc-option,-march=c3-2,-march=i686)
1086 + cflags-$(CONFIG_MVIAC7) += -march=i686
1087 + cflags-$(CONFIG_MCORE2) += -march=i686 $(call tune,core2)
1088 +-cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \
1089 +- $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
1090 +-
1091 ++cflags-$(CONFIG_MNEHALEM) += -march=i686 $(call tune,nehalem)
1092 ++cflags-$(CONFIG_MWESTMERE) += -march=i686 $(call tune,westmere)
1093 ++cflags-$(CONFIG_MSILVERMONT) += -march=i686 $(call tune,silvermont)
1094 ++cflags-$(CONFIG_MSANDYBRIDGE) += -march=i686 $(call tune,sandybridge)
1095 ++cflags-$(CONFIG_MIVYBRIDGE) += -march=i686 $(call tune,ivybridge)
1096 ++cflags-$(CONFIG_MHASWELL) += -march=i686 $(call tune,haswell)
1097 + # AMD Elan support
1098 + cflags-$(CONFIG_MELAN) += -march=i486
1099 +