cpupowertools 5.4.6

This commit is contained in:
idriskalp
2019-12-27 18:59:55 +03:00
parent 1aaba423d3
commit 1985ece49d
78 changed files with 68113 additions and 272 deletions
@@ -0,0 +1,11 @@
--- linux-3.16/include/linux/printk.h.old 2014-08-04 18:48:30.686043266 +0200
+++ linux-3.16/include/linux/printk.h 2014-08-04 18:48:47.706218528 +0200
@@ -37,7 +37,7 @@
#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
#define CONSOLE_LOGLEVEL_QUIET 4 /* Shhh ..., when booted with "quiet" */
-#define CONSOLE_LOGLEVEL_DEFAULT 7 /* anything MORE serious than KERN_DEBUG */
+#define CONSOLE_LOGLEVEL_DEFAULT 4 /* anything MORE serious than KERN_DEBUG */
#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
@@ -0,0 +1,21 @@
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index dd9d6190b08d..181e42bd85d3 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -85,6 +85,7 @@
#include <linux/syscore_ops.h>
#include <asm/microcode.h>
+#include <asm/microcode_intel.h>
#include <asm/processor.h>
#include <asm/cpu_device_id.h>
#include <asm/perf_event.h>
@@ -465,6 +466,8 @@ static void mc_bp_resume(void)
if (uci->valid && uci->mc)
microcode_ops->apply_microcode(cpu);
+ else if (!uci->mc)
+ load_ucode_intel_ap();
}
static struct syscore_ops mc_syscore_ops = {
@@ -0,0 +1,54 @@
From: Anthony G. Basile <blueness@gentoo.org>
This patch adds support for a restricted user-controlled namespace on
tmpfs filesystem used to house PaX flags. The namespace must be of the
form user.pax.* and its value cannot exceed a size of 8 bytes.
This is needed even on all Gentoo systems so that XATTR_PAX flags
are preserved for users who might build packages using portage on
a tmpfs system with a non-hardened kernel and then switch to a
hardened kernel with XATTR_PAX enabled.
The namespace is added to any user with Extended Attribute support
enabled for tmpfs. Users who do not enable xattrs will not have
the XATTR_PAX flags preserved.
diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
index e4629b9..6958086 100644
--- a/include/uapi/linux/xattr.h
+++ b/include/uapi/linux/xattr.h
@@ -63,5 +63,9 @@
#define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
#define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
+/* User namespace */
+#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
+#define XATTR_PAX_FLAGS_SUFFIX "flags"
+#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
#endif /* _UAPI_LINUX_XATTR_H */
diff --git a/mm/shmem.c b/mm/shmem.c
index 1c44af7..f23bb1b 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2201,6 +2201,7 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
static int shmem_xattr_validate(const char *name)
{
struct { const char *prefix; size_t len; } arr[] = {
+ { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
{ XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
{ XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
};
@@ -2256,6 +2257,12 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
if (err)
return err;
+ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
+ if (strcmp(name, XATTR_NAME_PAX_FLAGS))
+ return -EOPNOTSUPP;
+ if (size > 8)
+ return -EINVAL;
+ }
return simple_xattr_set(&info->xattrs, name, value, size, flags);
}
@@ -0,0 +1,22 @@
From: Ben Hutchings <ben@decadent.org.uk>
Subject: fs: Enable link security restrictions by default
Date: Fri, 02 Nov 2012 05:32:06 +0000
Bug-Debian: https://bugs.debian.org/609455
Forwarded: not-needed
This reverts commit 561ec64ae67ef25cac8d72bb9c4bfc955edfd415
('VFS: don't do protected {sym,hard}links by default').
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -651,8 +651,8 @@ static inline void put_link(struct namei
path_put(link);
}
-int sysctl_protected_symlinks __read_mostly = 0;
-int sysctl_protected_hardlinks __read_mostly = 0;
+int sysctl_protected_symlinks __read_mostly = 1;
+int sysctl_protected_hardlinks __read_mostly = 1;
/**
* may_follow_link - Check symlink following for unsafe situations
@@ -0,0 +1,67 @@
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index cb96296..6c242ed 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -269,6 +276,61 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
},
/*
+ * The following Lenovo models have a broken workaround in the
+ * acpi_video backlight implementation to meet the Windows 8
+ * requirement of 101 backlight levels. Reverting to pre-Win8
+ * behavior fixes the problem.
+ */
+ {
+ .callback = dmi_disable_osi_win8,
+ .ident = "Lenovo ThinkPad L430",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L430"),
+ },
+ },
+ {
+ .callback = dmi_disable_osi_win8,
+ .ident = "Lenovo ThinkPad T430s",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T430s"),
+ },
+ },
+ {
+ .callback = dmi_disable_osi_win8,
+ .ident = "Lenovo ThinkPad T530",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T530"),
+ },
+ },
+ {
+ .callback = dmi_disable_osi_win8,
+ .ident = "Lenovo ThinkPad W530",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W530"),
+ },
+ },
+ {
+ .callback = dmi_disable_osi_win8,
+ .ident = "Lenovo ThinkPad X1 Carbon",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X1 Carbon"),
+ },
+ },
+ {
+ .callback = dmi_disable_osi_win8,
+ .ident = "Lenovo ThinkPad X230",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X230"),
+ },
+ },
+
+ /*
* BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
* Linux ignores it, except for the machines enumerated below.
*/
@@ -0,0 +1,30 @@
--- a/init/do_mounts.c 2014-08-26 08:03:30.000013100 -0400
+++ b/init/do_mounts.c 2014-08-26 08:11:19.720014712 -0400
@@ -484,7 +484,10 @@ void __init change_floppy(char *fmt, ...
va_start(args, fmt);
vsprintf(buf, fmt, args);
va_end(args);
- fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
+ if (saved_root_name[0])
+ fd = sys_open(saved_root_name, O_RDWR | O_NDELAY, 0);
+ else
+ fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
if (fd >= 0) {
sys_ioctl(fd, FDEJECT, 0);
sys_close(fd);
@@ -527,8 +530,13 @@ void __init mount_root(void)
}
#endif
#ifdef CONFIG_BLOCK
- create_dev("/dev/root", ROOT_DEV);
- mount_block_root("/dev/root", root_mountflags);
+ if (saved_root_name[0]) {
+ create_dev(saved_root_name, ROOT_DEV);
+ mount_block_root(saved_root_name, root_mountflags);
+ } else {
+ create_dev("/dev/root", ROOT_DEV);
+ mount_block_root("/dev/root", root_mountflags);
+ }
#endif
}
@@ -0,0 +1,24 @@
diff --git a/kernel/kmod.c b/kernel/kmod.c
index fb32636..d968882 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -575,7 +575,8 @@
call_usermodehelper_freeinfo(sub_info);
return -EINVAL;
}
- helper_lock();
+ if (!(current->flags & PF_FREEZER_SKIP))
+ helper_lock();
if (!khelper_wq || usermodehelper_disabled) {
retval = -EBUSY;
goto out;
@@ -611,7 +612,8 @@ wait_done:
out:
call_usermodehelper_freeinfo(sub_info);
unlock:
- helper_unlock();
+ if (!(current->flags & PF_FREEZER_SKIP))
+ helper_unlock();
return retval;
}
EXPORT_SYMBOL(call_usermodehelper_exec);
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,143 @@
--- a/Kconfig
+++ b/Kconfig
@@ -8,4 +8,6 @@ config SRCARCH
string
option env="SRCARCH"
+source "distro/Kconfig"
+
source "arch/$SRCARCH/Kconfig"
--- /dev/null
+++ b/distro/Kconfig
@@ -0,0 +1,131 @@
+menu "Gentoo Linux"
+
+config GENTOO_LINUX
+ bool "Gentoo Linux support"
+
+ default y
+
+ help
+ In order to boot Gentoo Linux a minimal set of config settings needs to
+ be enabled in the kernel; to avoid the users from having to enable them
+ manually as part of a Gentoo Linux installation or a new clean config,
+ we enable these config settings by default for convenience.
+
+ See the settings that become available for more details and fine-tuning.
+
+config GENTOO_LINUX_UDEV
+ bool "Linux dynamic and persistent device naming (userspace devfs) support"
+
+ depends on GENTOO_LINUX
+ default y if GENTOO_LINUX
+
+ select DEVTMPFS
+ select TMPFS
+
+ select MMU
+ select SHMEM
+
+ help
+ In order to boot Gentoo Linux a minimal set of config settings needs to
+ be enabled in the kernel; to avoid the users from having to enable them
+ manually as part of a Gentoo Linux installation or a new clean config,
+ we enable these config settings by default for convenience.
+
+ Currently this only selects TMPFS, DEVTMPFS and their dependencies.
+ TMPFS is enabled to maintain a tmpfs file system at /dev/shm, /run and
+ /sys/fs/cgroup; DEVTMPFS to maintain a devtmpfs file system at /dev.
+
+ Some of these are critical files that need to be available early in the
+ boot process; if not available, it causes sysfs and udev to malfunction.
+
+ To ensure Gentoo Linux boots, it is best to leave this setting enabled;
+ if you run a custom setup, you could consider whether to disable this.
+
+config GENTOO_LINUX_PORTAGE
+ bool "Select options required by Portage features"
+
+ depends on GENTOO_LINUX
+ default y if GENTOO_LINUX
+
+ select CGROUPS
+ select NAMESPACES
+ select IPC_NS
+ select NET_NS
+
+ help
+ This enables options required by various Portage FEATURES.
+ Currently this selects:
+
+ CGROUPS (required for FEATURES=cgroup)
+ IPC_NS (required for FEATURES=ipc-sandbox)
+ NET_NS (required for FEATURES=network-sandbox)
+
+ It is highly recommended that you leave this enabled as these FEATURES
+ are, or will soon be, enabled by default.
+
+menu "Support for init systems, system and service managers"
+ visible if GENTOO_LINUX
+
+config GENTOO_LINUX_INIT_SCRIPT
+ bool "OpenRC, runit and other script based systems and managers"
+
+ default y if GENTOO_LINUX
+
+ depends on GENTOO_LINUX
+
+ select BINFMT_SCRIPT
+
+ help
+ The init system is the first thing that loads after the kernel booted.
+
+ These config settings allow you to select which init systems to support;
+ instead of having to select all the individual settings all over the
+ place, these settings allows you to select all the settings at once.
+
+ This particular setting enables all the known requirements for OpenRC,
+ runit and similar script based systems and managers.
+
+ If you are unsure about this, it is best to leave this setting enabled.
+
+config GENTOO_LINUX_INIT_SYSTEMD
+ bool "systemd"
+
+ default n
+
+ depends on GENTOO_LINUX && GENTOO_LINUX_UDEV
+
+ select AUTOFS4_FS
+ select BLK_DEV_BSG
+ select CGROUPS
+ select DEVPTS_MULTIPLE_INSTANCES
+ select EPOLL
+ select FANOTIFY
+ select FHANDLE
+ select INOTIFY_USER
+ select NET
+ select NET_NS
+ select PROC_FS
+ select SIGNALFD
+ select SYSFS
+ select TIMERFD
+
+ select ANON_INODES
+ select BLOCK
+ select EVENTFD
+ select FSNOTIFY
+ select INET
+ select NLATTR
+
+ help
+ The init system is the first thing that loads after the kernel booted.
+
+ These config settings allow you to select which init systems to support;
+ instead of having to select all the individual settings all over the
+ place, these settings allows you to select all the settings at once.
+
+ This particular setting enables all the known requirements for systemd;
+ it also enables suggested optional settings, as the package suggests to.
+
+endmenu
+
+endmenu
@@ -0,0 +1,104 @@
From a828d56aebc0735676be23734cccf31e279c0d1b Mon Sep 17 00:00:00 2001
From: Paolo Valente <paolo.valente@unimore.it>
Date: Mon, 8 Dec 2014 16:04:25 +0100
Subject: [PATCH 1/3] block: cgroups, kconfig, build bits for BFQ-v7r7-3.19
Update Kconfig.iosched and do the related Makefile changes to include
kernel configuration options for BFQ. Also add the bfqio controller
to the cgroups subsystem.
Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
---
block/Kconfig.iosched | 32 ++++++++++++++++++++++++++++++++
block/Makefile | 1 +
include/linux/cgroup_subsys.h | 4 ++++
3 files changed, 37 insertions(+)
diff --git a/block/Kconfig.iosched b/block/Kconfig.iosched
index 421bef9..0ee5f0f 100644
--- a/block/Kconfig.iosched
+++ b/block/Kconfig.iosched
@@ -39,6 +39,27 @@ config CFQ_GROUP_IOSCHED
---help---
Enable group IO scheduling in CFQ.
+config IOSCHED_BFQ
+ tristate "BFQ I/O scheduler"
+ default n
+ ---help---
+ The BFQ I/O scheduler tries to distribute bandwidth among
+ all processes according to their weights.
+ It aims at distributing the bandwidth as desired, independently of
+ the disk parameters and with any workload. It also tries to
+ guarantee low latency to interactive and soft real-time
+ applications. If compiled built-in (saying Y here), BFQ can
+ be configured to support hierarchical scheduling.
+
+config CGROUP_BFQIO
+ bool "BFQ hierarchical scheduling support"
+ depends on CGROUPS && IOSCHED_BFQ=y
+ default n
+ ---help---
+ Enable hierarchical scheduling in BFQ, using the cgroups
+ filesystem interface. The name of the subsystem will be
+ bfqio.
+
choice
prompt "Default I/O scheduler"
default DEFAULT_CFQ
@@ -52,6 +73,16 @@ choice
config DEFAULT_CFQ
bool "CFQ" if IOSCHED_CFQ=y
+ config DEFAULT_BFQ
+ bool "BFQ" if IOSCHED_BFQ=y
+ help
+ Selects BFQ as the default I/O scheduler which will be
+ used by default for all block devices.
+ The BFQ I/O scheduler aims at distributing the bandwidth
+ as desired, independently of the disk parameters and with
+ any workload. It also tries to guarantee low latency to
+ interactive and soft real-time applications.
+
config DEFAULT_NOOP
bool "No-op"
@@ -61,6 +92,7 @@ config DEFAULT_IOSCHED
string
default "deadline" if DEFAULT_DEADLINE
default "cfq" if DEFAULT_CFQ
+ default "bfq" if DEFAULT_BFQ
default "noop" if DEFAULT_NOOP
endmenu
diff --git a/block/Makefile b/block/Makefile
index 00ecc97..1ed86d5 100644
--- a/block/Makefile
+++ b/block/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_BLK_DEV_THROTTLING) += blk-throttle.o
obj-$(CONFIG_IOSCHED_NOOP) += noop-iosched.o
obj-$(CONFIG_IOSCHED_DEADLINE) += deadline-iosched.o
obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o
+obj-$(CONFIG_IOSCHED_BFQ) += bfq-iosched.o
obj-$(CONFIG_BLOCK_COMPAT) += compat_ioctl.o
obj-$(CONFIG_BLK_CMDLINE_PARSER) += cmdline-parser.o
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index 98c4f9b..13b010d 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -35,6 +35,10 @@ SUBSYS(net_cls)
SUBSYS(blkio)
#endif
+#if IS_ENABLED(CONFIG_CGROUP_BFQIO)
+SUBSYS(bfqio)
+#endif
+
#if IS_ENABLED(CONFIG_CGROUP_PERF)
SUBSYS(perf_event)
#endif
--
2.3.0
@@ -0,0 +1,387 @@
WARNING - this version of the patch works with version 4.9+ of gcc and with
kernel version 3.15.x+ and should NOT be applied when compiling on older
versions due to name changes of the flags with the 4.9 release of gcc.
Use the older version of this patch hosted on the same github for older
versions of gcc. For example:
corei7 --> nehalem
corei7-avx --> sandybridge
core-avx-i --> ivybridge
core-avx2 --> haswell
For more, see: https://gcc.gnu.org/gcc-4.9/changes.html
It also changes 'atom' to 'bonnell' in accordance with the gcc v4.9 changes.
Note that upstream is using the deprecated 'match=atom' flags when I believe it
should use the newer 'march=bonnell' flag for atom processors.
I have made that change to this patch set as well. See the following kernel
bug report to see if I'm right: https://bugzilla.kernel.org/show_bug.cgi?id=77461
This patch will expand the number of microarchitectures to include new
processors including: AMD K10-family, AMD Family 10h (Barcelona), AMD Family
14h (Bobcat), AMD Family 15h (Bulldozer), AMD Family 15h (Piledriver), AMD
Family 16h (Jaguar), Intel 1st Gen Core i3/i5/i7 (Nehalem), Intel 1.5 Gen Core
i3/i5/i7 (Westmere), Intel 2nd Gen Core i3/i5/i7 (Sandybridge), Intel 3rd Gen
Core i3/i5/i7 (Ivybridge), Intel 4th Gen Core i3/i5/i7 (Haswell), and Intel 5th
Gen Core i3/i5/i7 (Broadwell). It also offers the compiler the 'native' flag.
Small but real speed increases are measurable using a make endpoint comparing
a generic kernel to one built with one of the respective microarchs.
See the following experimental evidence supporting this statement:
https://github.com/graysky2/kernel_gcc_patch
REQUIREMENTS
linux version >=3.15
gcc version >=4.9
--- a/arch/x86/include/asm/module.h 2014-08-03 18:25:02.000000000 -0400
+++ b/arch/x86/include/asm/module.h 2014-09-13 09:37:16.721385247 -0400
@@ -15,6 +15,20 @@
#define MODULE_PROC_FAMILY "586MMX "
#elif defined CONFIG_MCORE2
#define MODULE_PROC_FAMILY "CORE2 "
+#elif defined CONFIG_MNATIVE
+#define MODULE_PROC_FAMILY "NATIVE "
+#elif defined CONFIG_MNEHALEM
+#define MODULE_PROC_FAMILY "NEHALEM "
+#elif defined CONFIG_MWESTMERE
+#define MODULE_PROC_FAMILY "WESTMERE "
+#elif defined CONFIG_MSANDYBRIDGE
+#define MODULE_PROC_FAMILY "SANDYBRIDGE "
+#elif defined CONFIG_MIVYBRIDGE
+#define MODULE_PROC_FAMILY "IVYBRIDGE "
+#elif defined CONFIG_MHASWELL
+#define MODULE_PROC_FAMILY "HASWELL "
+#elif defined CONFIG_MBROADWELL
+#define MODULE_PROC_FAMILY "BROADWELL "
#elif defined CONFIG_MATOM
#define MODULE_PROC_FAMILY "ATOM "
#elif defined CONFIG_M686
@@ -33,6 +47,20 @@
#define MODULE_PROC_FAMILY "K7 "
#elif defined CONFIG_MK8
#define MODULE_PROC_FAMILY "K8 "
+#elif defined CONFIG_MK8SSE3
+#define MODULE_PROC_FAMILY "K8SSE3 "
+#elif defined CONFIG_MK10
+#define MODULE_PROC_FAMILY "K10 "
+#elif defined CONFIG_MBARCELONA
+#define MODULE_PROC_FAMILY "BARCELONA "
+#elif defined CONFIG_MBOBCAT
+#define MODULE_PROC_FAMILY "BOBCAT "
+#elif defined CONFIG_MBULLDOZER
+#define MODULE_PROC_FAMILY "BULLDOZER "
+#elif defined CONFIG_MPILEDRIVER
+#define MODULE_PROC_FAMILY "PILEDRIVER "
+#elif defined CONFIG_MJAGUAR
+#define MODULE_PROC_FAMILY "JAGUAR "
#elif defined CONFIG_MELAN
#define MODULE_PROC_FAMILY "ELAN "
#elif defined CONFIG_MCRUSOE
--- a/arch/x86/Kconfig.cpu 2014-08-03 18:25:02.000000000 -0400
+++ b/arch/x86/Kconfig.cpu 2014-09-13 09:37:16.721385247 -0400
@@ -137,9 +137,8 @@ config MPENTIUM4
-Paxville
-Dempsey
-
config MK6
- bool "K6/K6-II/K6-III"
+ bool "AMD K6/K6-II/K6-III"
depends on X86_32
---help---
Select this for an AMD K6-family processor. Enables use of
@@ -147,7 +146,7 @@ config MK6
flags to GCC.
config MK7
- bool "Athlon/Duron/K7"
+ bool "AMD Athlon/Duron/K7"
depends on X86_32
---help---
Select this for an AMD Athlon K7-family processor. Enables use of
@@ -155,12 +154,62 @@ config MK7
flags to GCC.
config MK8
- bool "Opteron/Athlon64/Hammer/K8"
+ bool "AMD Opteron/Athlon64/Hammer/K8"
---help---
Select this for an AMD Opteron or Athlon64 Hammer-family processor.
Enables use of some extended instructions, and passes appropriate
optimization flags to GCC.
+config MK8SSE3
+ bool "AMD Opteron/Athlon64/Hammer/K8 with SSE3"
+ ---help---
+ Select this for improved AMD Opteron or Athlon64 Hammer-family processors.
+ Enables use of some extended instructions, and passes appropriate
+ optimization flags to GCC.
+
+config MK10
+ bool "AMD 61xx/7x50/PhenomX3/X4/II/K10"
+ ---help---
+ Select this for an AMD 61xx Eight-Core Magny-Cours, Athlon X2 7x50,
+ Phenom X3/X4/II, Athlon II X2/X3/X4, or Turion II-family processor.
+ Enables use of some extended instructions, and passes appropriate
+ optimization flags to GCC.
+
+config MBARCELONA
+ bool "AMD Barcelona"
+ ---help---
+ Select this for AMD Barcelona and newer processors.
+
+ Enables -march=barcelona
+
+config MBOBCAT
+ bool "AMD Bobcat"
+ ---help---
+ Select this for AMD Bobcat processors.
+
+ Enables -march=btver1
+
+config MBULLDOZER
+ bool "AMD Bulldozer"
+ ---help---
+ Select this for AMD Bulldozer processors.
+
+ Enables -march=bdver1
+
+config MPILEDRIVER
+ bool "AMD Piledriver"
+ ---help---
+ Select this for AMD Piledriver processors.
+
+ Enables -march=bdver2
+
+config MJAGUAR
+ bool "AMD Jaguar"
+ ---help---
+ Select this for AMD Jaguar processors.
+
+ Enables -march=btver2
+
config MCRUSOE
bool "Crusoe"
depends on X86_32
@@ -251,8 +300,17 @@ config MPSC
using the cpu family field
in /proc/cpuinfo. Family 15 is an older Xeon, Family 6 a newer one.
+config MATOM
+ bool "Intel Atom"
+ ---help---
+
+ Select this for the Intel Atom platform. Intel Atom CPUs have an
+ in-order pipelining architecture and thus can benefit from
+ accordingly optimized code. Use a recent GCC with specific Atom
+ support in order to fully benefit from selecting this option.
+
config MCORE2
- bool "Core 2/newer Xeon"
+ bool "Intel Core 2"
---help---
Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and
@@ -260,14 +318,55 @@ config MCORE2
family in /proc/cpuinfo. Newer ones have 6 and older ones 15
(not a typo)
-config MATOM
- bool "Intel Atom"
+ Enables -march=core2
+
+config MNEHALEM
+ bool "Intel Nehalem"
---help---
- Select this for the Intel Atom platform. Intel Atom CPUs have an
- in-order pipelining architecture and thus can benefit from
- accordingly optimized code. Use a recent GCC with specific Atom
- support in order to fully benefit from selecting this option.
+ Select this for 1st Gen Core processors in the Nehalem family.
+
+ Enables -march=nehalem
+
+config MWESTMERE
+ bool "Intel Westmere"
+ ---help---
+
+ Select this for the Intel Westmere formerly Nehalem-C family.
+
+ Enables -march=westmere
+
+config MSANDYBRIDGE
+ bool "Intel Sandy Bridge"
+ ---help---
+
+ Select this for 2nd Gen Core processors in the Sandy Bridge family.
+
+ Enables -march=sandybridge
+
+config MIVYBRIDGE
+ bool "Intel Ivy Bridge"
+ ---help---
+
+ Select this for 3rd Gen Core processors in the Ivy Bridge family.
+
+ Enables -march=ivybridge
+
+config MHASWELL
+ bool "Intel Haswell"
+ ---help---
+
+ Select this for 4th Gen Core processors in the Haswell family.
+
+ Enables -march=haswell
+
+config MBROADWELL
+ bool "Intel Broadwell"
+ ---help---
+
+ Select this for 5th Gen Core processors in the Broadwell family.
+
+ Enables -march=broadwell
config GENERIC_CPU
bool "Generic-x86-64"
@@ -276,6 +375,19 @@ config GENERIC_CPU
Generic x86-64 CPU.
Run equally well on all x86-64 CPUs.
+config MNATIVE
+ bool "Native optimizations autodetected by GCC"
+ ---help---
+
+ GCC 4.2 and above support -march=native, which automatically detects
+ the optimum settings to use based on your processor. -march=native
+ also detects and applies additional settings beyond -march specific
+ to your CPU, (eg. -msse4). Unless you have a specific reason not to
+ (e.g. distcc cross-compiling), you should probably be using
+ -march=native rather than anything listed below.
+
+ Enables -march=native
+
endchoice
config X86_GENERIC
@@ -300,7 +412,7 @@ config X86_INTERNODE_CACHE_SHIFT
config X86_L1_CACHE_SHIFT
int
default "7" if MPENTIUM4 || MPSC
- default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
+ default "6" if MK7 || MK8 || MK8SSE3 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MJAGUAR || MPENTIUMM || MCORE2 || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || BROADWELL || MNATIVE || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
default "4" if MELAN || M486 || MGEODEGX1
default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
@@ -331,11 +443,11 @@ config X86_ALIGNMENT_16
config X86_INTEL_USERCOPY
def_bool y
- depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON || MCORE2
+ depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK8SSE3 || MK7 || MEFFICEON || MCORE2 || MK10 || MBARCELONA || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MNATIVE
config X86_USE_PPRO_CHECKSUM
def_bool y
- depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MATOM
+ depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MK10 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MK8SSE3 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MATOM || MNATIVE
config X86_USE_3DNOW
def_bool y
@@ -359,17 +471,17 @@ config X86_P6_NOP
config X86_TSC
def_bool y
- 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
+ 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 || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MNATIVE || MATOM) || X86_64
config X86_CMPXCHG64
def_bool y
- depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM
+ depends on X86_PAE || X86_64 || MCORE2 || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MATOM || MNATIVE
# this should be set for all -march=.. options where the compiler
# generates cmov.
config X86_CMOV
def_bool y
- depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
+ depends on (MK8 || MK8SSE3 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MJAGUAR || MK7 || MCORE2 || MNEHALEM || MWESTMERE || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MNATIVE || MATOM || MGEODE_LX)
config X86_MINIMUM_CPU_FAMILY
int
--- a/arch/x86/Makefile 2014-08-03 18:25:02.000000000 -0400
+++ b/arch/x86/Makefile 2014-09-13 09:37:16.721385247 -0400
@@ -92,13 +92,33 @@ else
KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
# FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
+ cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
+ cflags-$(CONFIG_MK8SSE3) += $(call cc-option,-march=k8-sse3,-mtune=k8)
+ cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10)
+ cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona)
+ cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1)
+ cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1)
+ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2)
+ cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2)
cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
cflags-$(CONFIG_MCORE2) += \
- $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
- cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
- $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
+ $(call cc-option,-march=core2,$(call cc-option,-mtune=core2))
+ cflags-$(CONFIG_MNEHALEM) += \
+ $(call cc-option,-march=nehalem,$(call cc-option,-mtune=nehalem))
+ cflags-$(CONFIG_MWESTMERE) += \
+ $(call cc-option,-march=westmere,$(call cc-option,-mtune=westmere))
+ cflags-$(CONFIG_MSANDYBRIDGE) += \
+ $(call cc-option,-march=sandybridge,$(call cc-option,-mtune=sandybridge))
+ cflags-$(CONFIG_MIVYBRIDGE) += \
+ $(call cc-option,-march=ivybridge,$(call cc-option,-mtune=ivybridge))
+ cflags-$(CONFIG_MHASWELL) += \
+ $(call cc-option,-march=haswell,$(call cc-option,-mtune=haswell))
+ cflags-$(CONFIG_MBROADWELL) += \
+ $(call cc-option,-march=broadwell,$(call cc-option,-mtune=broadwell))
+ cflags-$(CONFIG_MATOM) += $(call cc-option,-march=bonnell) \
+ $(call cc-option,-mtune=bonnell,$(call cc-option,-mtune=generic))
cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
KBUILD_CFLAGS += $(cflags-y)
--- a/arch/x86/Makefile_32.cpu 2014-08-03 18:25:02.000000000 -0400
+++ b/arch/x86/Makefile_32.cpu 2014-09-13 09:37:16.721385247 -0400
@@ -23,7 +23,15 @@ cflags-$(CONFIG_MK6) += -march=k6
# Please note, that patches that add -march=athlon-xp and friends are pointless.
# They make zero difference whatsosever to performance at this time.
cflags-$(CONFIG_MK7) += -march=athlon
+cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8,-march=athlon)
+cflags-$(CONFIG_MK8SSE3) += $(call cc-option,-march=k8-sse3,-march=athlon)
+cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10,-march=athlon)
+cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona,-march=athlon)
+cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1,-march=athlon)
+cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1,-march=athlon)
+cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2,-march=athlon)
+cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2,-march=athlon)
cflags-$(CONFIG_MCRUSOE) += -march=i686 $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
cflags-$(CONFIG_MEFFICEON) += -march=i686 $(call tune,pentium3) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
cflags-$(CONFIG_MWINCHIPC6) += $(call cc-option,-march=winchip-c6,-march=i586)
@@ -32,8 +40,14 @@ cflags-$(CONFIG_MCYRIXIII) += $(call cc-
cflags-$(CONFIG_MVIAC3_2) += $(call cc-option,-march=c3-2,-march=i686)
cflags-$(CONFIG_MVIAC7) += -march=i686
cflags-$(CONFIG_MCORE2) += -march=i686 $(call tune,core2)
-cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \
- $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
+cflags-$(CONFIG_MNEHALEM) += -march=i686 $(call tune,nehalem)
+cflags-$(CONFIG_MWESTMERE) += -march=i686 $(call tune,westmere)
+cflags-$(CONFIG_MSANDYBRIDGE) += -march=i686 $(call tune,sandybridge)
+cflags-$(CONFIG_MIVYBRIDGE) += -march=i686 $(call tune,ivybridge)
+cflags-$(CONFIG_MHASWELL) += -march=i686 $(call tune,haswell)
+cflags-$(CONFIG_MBROADWELL) += -march=i686 $(call tune,broadwell)
+cflags-$(CONFIG_MATOM) += $(call cc-option,-march=bonnell,$(call cc-option,-march=core2,-march=i686)) \
+ $(call cc-option,-mtune=bonnell,$(call cc-option,-mtune=generic))
# AMD Elan support
cflags-$(CONFIG_MELAN) += -march=i486
@@ -0,0 +1,37 @@
From 84ecc2f6eb1cb12e6d44818f94fa49b50f06e6ac Mon Sep 17 00:00:00 2001
From: Gen Zhang <blackgod016574@gmail.com>
Date: Thu, 23 May 2019 08:34:52 +0800
Subject: consolemap: Fix a memory leaking bug in drivers/tty/vt/consolemap.c
In function con_insert_unipair(), when allocation for p2 and p1[n]
fails, ENOMEM is returned, but previously allocated p1 is not freed,
remains as leaking memory. Thus we should free p1 as well when this
allocation fails.
Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/tty/vt/consolemap.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
index b28aa0d289f8..79fcc96cc7c0 100644
--- a/drivers/tty/vt/consolemap.c
+++ b/drivers/tty/vt/consolemap.c
@@ -489,7 +489,11 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos)
p2 = p1[n = (unicode >> 6) & 0x1f];
if (!p2) {
p2 = p1[n] = kmalloc_array(64, sizeof(u16), GFP_KERNEL);
- if (!p2) return -ENOMEM;
+ if (!p2) {
+ kfree(p1);
+ p->uni_pgdir[n] = NULL;
+ return -ENOMEM;
+ }
memset(p2, 0xff, 64*sizeof(u16)); /* No glyphs for the characters (yet) */
}
--
cgit 1.2-0.3.lf.el7
@@ -0,0 +1,34 @@
From: Hans de Goede <hdegoede@redhat.com>
Subject: [PATCH 2/2] PCI: Add function 1 DMA alias quirk for Highpoint RocketRAID 644L
Date: Fri, 2 Mar 2018 11:36:33 +0100
The Highpoint RocketRAID 644L uses a Marvel 88SE9235 controller, as with
other Marvel controllers this needs a function 1 DMA alias quirk.
Note the RocketRAID 642L uses the same Marvel 88SE9235 controller and
already is listed with a function 1 DMA alias quirk.
Cc: stable@vger.kernel.org
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1534106
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/pci/quirks.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 8b14bd326d4a..46d47bd6ca1f 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3908,6 +3908,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9230,
quirk_dma_func1_alias);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0642,
quirk_dma_func1_alias);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0645,
+ quirk_dma_func1_alias);
/* https://bugs.gentoo.org/show_bug.cgi?id=497630 */
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_JMICRON,
PCI_DEVICE_ID_JMICRON_JMB388_ESD,
--
2.14.3
@@ -0,0 +1,46 @@
From 863204cfdae98626a92535ac928ad79f4d6b74ff Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <arnd@arndb.de>
Date: Wed, 6 Dec 2017 14:17:17 +0100
Subject: [PATCH] ARM: omap2: hide omap3_save_secure_ram on non-OMAP3 builds
In configurations without CONFIG_OMAP3 but with secure RAM support,
we now run into a link failure:
arch/arm/mach-omap2/omap-secure.o: In function `omap3_save_secure_ram':
omap-secure.c:(.text+0x130): undefined reference to `save_secure_ram_context'
The omap3_save_secure_ram() function is only called from the OMAP34xx
power management code, so we can simply hide that function in the
appropriate #ifdef.
Fixes: d09220a887f7 ("ARM: OMAP2+: Fix SRAM virt to phys translation for save_secure_ram_context")
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/arm/mach-omap2/omap-secure.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/arm/mach-omap2/omap-secure.c b/arch/arm/mach-omap2/omap-secure.c
index 9ff92050053c..fa7f308c9027 100644
--- a/arch/arm/mach-omap2/omap-secure.c
+++ b/arch/arm/mach-omap2/omap-secure.c
@@ -73,6 +73,7 @@ phys_addr_t omap_secure_ram_mempool_base(void)
return omap_secure_memblock_base;
}
+#if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_PM)
u32 omap3_save_secure_ram(void __iomem *addr, int size)
{
u32 ret;
@@ -91,6 +92,7 @@ u32 omap3_save_secure_ram(void __iomem *addr, int size)
return ret;
}
+#endif
/**
* rx51_secure_dispatcher: Routine to dispatch secure PPA API calls
--
2.16.2
@@ -0,0 +1,37 @@
From: Hans de Goede <hdegoede@redhat.com>
Subject: [PATCH 1/2] ahci: Add PCI-id for the Highpoint Rocketraid 644L card
Date: Fri, 2 Mar 2018 11:36:32 +0100
Like the Highpoint Rocketraid 642L and cards using a Marvel 88SE9235
controller in general, this RAID card also supports AHCI mode and short
of a custom driver, this is the only way to make it work under Linux.
Note that even though the card is called to 644L, it has a product-id
of 0x0645.
Cc: stable@vger.kernel.org
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1534106
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/ata/ahci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 355a95a83a34..1ff17799769d 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -550,7 +550,9 @@ static const struct pci_device_id ahci_pci_tbl[] = {
.driver_data = board_ahci_yes_fbs },
{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230),
.driver_data = board_ahci_yes_fbs },
- { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642),
+ { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642), /* highpoint rocketraid 642L */
+ .driver_data = board_ahci_yes_fbs },
+ { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0645), /* highpoint rocketraid 644L */
.driver_data = board_ahci_yes_fbs },
/* Promise */
--
2.14.3
@@ -0,0 +1,74 @@
Makefile | 18 +++++-------------
scripts/kconfig/Makefile | 4 ----
2 files changed, 5 insertions(+), 17 deletions(-)
diff -Nurp linux-5.4.orig/Makefile linux-5.4/Makefile
--- linux-5.4.orig/Makefile 2019-11-30 23:06:49.394199628 +0200
+++ linux-5.4/Makefile 2019-11-30 23:08:00.927203318 +0200
@@ -1093,8 +1093,7 @@ include/config/kernel.release: FORCE
# Carefully list dependencies so we do not try to build scripts twice
# in parallel
PHONY += scripts
-scripts: scripts_basic scripts_dtc
- $(Q)$(MAKE) $(build)=$(@)
+scripts:
# Things we need to do before we recursively start building the kernel
# or the modules are listed in "prepare".
@@ -1112,7 +1111,7 @@ prepare0: archprepare
$(Q)$(MAKE) $(build)=.
# All the preparing..
-prepare: prepare0 prepare-objtool
+prepare:
# Support for using generic headers in asm-generic
asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
@@ -1363,15 +1362,8 @@ CLEAN_DIRS += include/ksym
CLEAN_FILES += modules.builtin.modinfo
# Directories & files removed with 'make mrproper'
-MRPROPER_DIRS += include/config include/generated \
- arch/$(SRCARCH)/include/generated .tmp_objdiff \
- debian/ snap/ tar-install/
-MRPROPER_FILES += .config .config.old .version \
- Module.symvers \
- signing_key.pem signing_key.priv signing_key.x509 \
- x509.genkey extra_certificates signing_key.x509.keyid \
- signing_key.x509.signer vmlinux-gdb.py \
- *.spec
+MRPROPER_DIRS += ""
+MRPROPER_FILES += ""
# Directories & files removed with 'make distclean'
DISTCLEAN_DIRS +=
@@ -1394,7 +1386,7 @@ clean: archclean vmlinuxclean
#
mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
-mrproper-dirs := $(addprefix _mrproper_,scripts)
+mrproper-dirs := $(addprefix _mrproper_,scripts)
PHONY += $(mrproper-dirs) mrproper
$(mrproper-dirs):
diff -Nurp linux-5.4.orig/scripts/kconfig/Makefile linux-5.4/scripts/kconfig/Makefile
--- linux-5.4.orig/scripts/kconfig/Makefile 2019-11-25 02:32:01.000000000 +0200
+++ linux-5.4/scripts/kconfig/Makefile 2019-11-30 23:07:24.957201462 +0200
@@ -24,16 +24,12 @@ endif
unexport CONFIG_
xconfig: $(obj)/qconf
- $< $(silent) $(Kconfig)
gconfig: $(obj)/gconf
- $< $(silent) $(Kconfig)
menuconfig: $(obj)/mconf
- $< $(silent) $(Kconfig)
config: $(obj)/conf
- $< $(silent) --oldaskconfig $(Kconfig)
nconfig: $(obj)/nconf
$< $(silent) $(Kconfig)
@@ -90,7 +90,7 @@
fs/aufs/wkq.c | 378 ++++
fs/aufs/wkq.h | 81 +
fs/aufs/xattr.c | 343 ++++
fs/aufs/xino.c | 1406 +++++++++++++++
fs/aufs/xino.c | 1457 +++++++++++++++
fs/dcache.c | 2 +-
fs/fcntl.c | 4 +-
fs/inode.c | 2 +-
@@ -117,7 +117,7 @@
mm/mmap.c | 33 +-
mm/nommu.c | 10 +-
mm/prfile.c | 86 +
119 files changed, 35967 insertions(+), 31 deletions(-)
119 files changed, 36018 insertions(+), 31 deletions(-)
diff --git a/Documentation/ABI/testing/debugfs-aufs b/Documentation/ABI/testing/debugfs-aufs
new file mode 100644
@@ -34595,10 +34595,10 @@ index 000000000000..dbe452868cd5
+}
diff --git a/fs/aufs/xino.c b/fs/aufs/xino.c
new file mode 100644
index 000000000000..74aecb7193ab
index 000000000000..eea2c34cabf4
--- /dev/null
+++ b/fs/aufs/xino.c
@@ -0,0 +1,1406 @@
@@ -0,0 +1,1457 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ * Copyright (C) 2005-2017 Junjiro R. Okajima
@@ -34612,6 +34612,9 @@ index 000000000000..74aecb7193ab
+#include <linux/statfs.h>
+#include "aufs.h"
+
+static ssize_t xino_fread_wkq(vfs_readf_t func, struct file *file, void *buf,
+ size_t size, loff_t *pos);
+
+/* todo: unnecessary to support mmap_sem since kernel-space? */
+ssize_t xino_fread(vfs_readf_t func, struct file *file, void *kbuf, size_t size,
+ loff_t *pos)
@@ -34622,14 +34625,26 @@ index 000000000000..74aecb7193ab
+ void *k;
+ char __user *u;
+ } buf;
+ int i;
+ const int prevent_endless = 10;
+
+ i = 0;
+ buf.k = kbuf;
+ oldfs = get_fs();
+ set_fs(KERNEL_DS);
+ do {
+ /* todo: signal_pending? */
+ err = func(file, buf.u, size, pos);
+ } while (err == -EAGAIN || err == -EINTR);
+ if (err == -EINTR
+ && !au_wkq_test()
+ && fatal_signal_pending(current)) {
+ set_fs(oldfs);
+ err = xino_fread_wkq(func, file, kbuf, size, pos);
+ BUG_ON(err == -EINTR);
+ oldfs = get_fs();
+ set_fs(KERNEL_DS);
+ }
+ } while (i++ < prevent_endless
+ && (err == -EAGAIN || err == -EINTR));
+ set_fs(oldfs);
+
+#if 0 /* reserved for future use */
@@ -34640,6 +34655,42 @@ index 000000000000..74aecb7193ab
+ return err;
+}
+
+struct xino_fread_args {
+ ssize_t *errp;
+ vfs_readf_t func;
+ struct file *file;
+ void *buf;
+ size_t size;
+ loff_t *pos;
+};
+
+static void call_xino_fread(void *args)
+{
+ struct xino_fread_args *a = args;
+ *a->errp = xino_fread(a->func, a->file, a->buf, a->size, a->pos);
+}
+
+static ssize_t xino_fread_wkq(vfs_readf_t func, struct file *file, void *buf,
+ size_t size, loff_t *pos)
+{
+ ssize_t err;
+ int wkq_err;
+ struct xino_fread_args args = {
+ .errp = &err,
+ .func = func,
+ .file = file,
+ .buf = buf,
+ .size = size,
+ .pos = pos
+ };
+
+ wkq_err = au_wkq_wait(call_xino_fread, &args);
+ if (unlikely(wkq_err))
+ err = wkq_err;
+
+ return err;
+}
+
+/* ---------------------------------------------------------------------- */
+
+static ssize_t xino_fwrite_wkq(vfs_writef_t func, struct file *file, void *buf,
@@ -0,0 +1,321 @@
fs/aufs/Kconfig | 2 +-
fs/dcache.c | 2 ++
fs/exec.c | 1 +
fs/fcntl.c | 1 +
fs/file_table.c | 2 ++
fs/inode.c | 1 +
fs/namespace.c | 3 +++
fs/notify/group.c | 1 +
fs/open.c | 1 +
fs/read_write.c | 4 ++++
fs/splice.c | 2 ++
fs/sync.c | 1 +
fs/xattr.c | 1 +
kernel/locking/lockdep.c | 1 +
kernel/task_work.c | 1 +
security/device_cgroup.c | 1 +
security/security.c | 8 ++++++++
17 files changed, 32 insertions(+), 1 deletion(-)
diff -Nurp linux-5.4-aufs/fs/aufs/Kconfig linux-5.4-aufs-mod/fs/aufs/Kconfig
--- linux-5.4-aufs/fs/aufs/Kconfig 2019-11-28 01:25:59.062925618 +0200
+++ linux-5.4-aufs-mod/fs/aufs/Kconfig 2019-11-28 01:38:40.564895255 +0200
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
config AUFS_FS
- bool "Aufs (Advanced multi layered unification filesystem) support"
+ tristate "Aufs (Advanced multi layered unification filesystem) support"
help
Aufs is a stackable unification filesystem such as Unionfs,
which unifies several directories and provides a merged single
diff -Nurp linux-5.4-aufs/fs/dcache.c linux-5.4-aufs-mod/fs/dcache.c
--- linux-5.4-aufs/fs/dcache.c 2019-11-28 01:25:59.069925618 +0200
+++ linux-5.4-aufs-mod/fs/dcache.c 2019-11-28 01:38:40.585895254 +0200
@@ -1369,6 +1369,7 @@ rename_retry:
seq = 1;
goto again;
}
+EXPORT_SYMBOL_GPL(d_walk);
struct check_mount {
struct vfsmount *mnt;
@@ -2914,6 +2915,7 @@ void d_exchange(struct dentry *dentry1,
write_sequnlock(&rename_lock);
}
+EXPORT_SYMBOL_GPL(d_exchange);
/**
* d_ancestor - search for an ancestor
diff -Nurp linux-5.4-aufs/fs/exec.c linux-5.4-aufs-mod/fs/exec.c
--- linux-5.4-aufs/fs/exec.c 2019-11-25 02:32:01.000000000 +0200
+++ linux-5.4-aufs-mod/fs/exec.c 2019-11-28 01:38:40.589895254 +0200
@@ -110,6 +110,7 @@ bool path_noexec(const struct path *path
return (path->mnt->mnt_flags & MNT_NOEXEC) ||
(path->mnt->mnt_sb->s_iflags & SB_I_NOEXEC);
}
+EXPORT_SYMBOL_GPL(path_noexec);
#ifdef CONFIG_USELIB
/*
diff -Nurp linux-5.4-aufs/fs/fcntl.c linux-5.4-aufs-mod/fs/fcntl.c
--- linux-5.4-aufs/fs/fcntl.c 2019-11-28 01:25:59.069925618 +0200
+++ linux-5.4-aufs-mod/fs/fcntl.c 2019-11-28 01:38:40.589895254 +0200
@@ -85,6 +85,7 @@ int setfl(int fd, struct file * filp, un
out:
return error;
}
+EXPORT_SYMBOL_GPL(setfl);
static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
int force)
diff -Nurp linux-5.4-aufs/fs/file_table.c linux-5.4-aufs-mod/fs/file_table.c
--- linux-5.4-aufs/fs/file_table.c 2019-11-25 02:32:01.000000000 +0200
+++ linux-5.4-aufs-mod/fs/file_table.c 2019-11-28 01:38:40.589895254 +0200
@@ -162,6 +162,7 @@ over:
}
return ERR_PTR(-ENFILE);
}
+EXPORT_SYMBOL_GPL(alloc_empty_file);
/*
* Variant of alloc_empty_file() that doesn't check and modify nr_files.
@@ -375,6 +377,7 @@ void __fput_sync(struct file *file)
}
EXPORT_SYMBOL(fput);
+EXPORT_SYMBOL_GPL(__fput_sync);
void __init files_init(void)
{
diff -Nurp linux-5.4-aufs/fs/inode.c linux-5.4-aufs-mod/fs/inode.c
--- linux-5.4-aufs/fs/inode.c 2019-11-28 01:25:59.070925617 +0200
+++ linux-5.4-aufs-mod/fs/inode.c 2019-11-28 01:38:40.589895254 +0200
@@ -1682,6 +1682,7 @@ int update_time(struct inode *inode, str
return update_time(inode, time, flags);
}
+EXPORT_SYMBOL_GPL(update_time);
/**
* touch_atime - update the access time
diff -Nurp linux-5.4-aufs/fs/namespace.c linux-5.4-aufs-mod/fs/namespace.c
--- linux-5.4-aufs/fs/namespace.c 2019-11-28 01:25:59.070925617 +0200
+++ linux-5.4-aufs-mod/fs/namespace.c 2019-11-28 01:38:40.589895254 +0200
@@ -431,6 +431,7 @@ void __mnt_drop_write(struct vfsmount *m
mnt_dec_writers(real_mount(mnt));
preempt_enable();
}
+EXPORT_SYMBOL_GPL(__mnt_drop_write);
/**
* mnt_drop_write - give up write access to a mount
@@ -781,6 +782,7 @@ int is_current_mnt_ns(struct vfsmount *m
{
return check_mnt(real_mount(mnt));
}
+EXPORT_SYMBOL_GPL(is_current_mnt_ns);
/*
* vfsmount lock must be held for write
@@ -1903,6 +1905,7 @@ int iterate_mounts(int (*f)(struct vfsmo
}
return 0;
}
+EXPORT_SYMBOL_GPL(iterate_mounts);
static void lock_mnt_tree(struct mount *mnt)
{
diff -Nurp linux-5.4-aufs/fs/notify/group.c linux-5.4-aufs-mod/fs/notify/group.c
--- linux-5.4-aufs/fs/notify/group.c 2019-11-25 02:32:01.000000000 +0200
+++ linux-5.4-aufs-mod/fs/notify/group.c 2019-11-28 01:38:40.590895253 +0200
@@ -99,6 +99,7 @@ void fsnotify_get_group(struct fsnotify_
{
refcount_inc(&group->refcnt);
}
+EXPORT_SYMBOL_GPL(fsnotify_get_group);
/*
* Drop a reference to a group. Free it if it's through.
diff -Nurp linux-5.4-aufs/fs/open.c linux-5.4-aufs-mod/fs/open.c
--- linux-5.4-aufs/fs/open.c 2019-11-25 02:32:01.000000000 +0200
+++ linux-5.4-aufs-mod/fs/open.c 2019-11-28 01:38:48.762894928 +0200
@@ -65,6 +65,7 @@ int do_truncate(struct dentry *dentry, l
inode_unlock(dentry->d_inode);
return ret;
}
+EXPORT_SYMBOL_GPL(do_truncate);
long vfs_truncate(const struct path *path, loff_t length)
{
diff -Nurp linux-5.4-aufs/fs/read_write.c linux-5.4-aufs-mod/fs/read_write.c
--- linux-5.4-aufs/fs/read_write.c 2019-11-28 01:25:59.070925617 +0200
+++ linux-5.4-aufs-mod/fs/read_write.c 2019-11-28 01:38:48.780894927 +0200
@@ -468,6 +468,7 @@ ssize_t vfs_read(struct file *file, char
return ret;
}
+EXPORT_SYMBOL_GPL(vfs_read);
static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos)
{
@@ -508,6 +509,7 @@ vfs_readf_t vfs_readf(struct file *file)
return new_sync_read;
return ERR_PTR(-ENOSYS);
}
+EXPORT_SYMBOL_GPL(vfs_readf);
vfs_writef_t vfs_writef(struct file *file)
{
@@ -519,6 +521,7 @@ vfs_writef_t vfs_writef(struct file *fil
return new_sync_write;
return ERR_PTR(-ENOSYS);
}
+EXPORT_SYMBOL_GPL(vfs_writef);
ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t *pos)
{
@@ -588,6 +591,7 @@ ssize_t vfs_write(struct file *file, con
return ret;
}
+EXPORT_SYMBOL_GPL(vfs_write);
/* file_ppos returns &file->f_pos or NULL if file is stream */
static inline loff_t *file_ppos(struct file *file)
diff -Nurp linux-5.4-aufs/fs/splice.c linux-5.4-aufs-mod/fs/splice.c
--- linux-5.4-aufs/fs/splice.c 2019-11-28 01:25:59.071925617 +0200
+++ linux-5.4-aufs-mod/fs/splice.c 2019-11-28 01:38:48.780894927 +0200
@@ -847,6 +847,7 @@ long do_splice_from(struct pipe_inode_in
return splice_write(pipe, out, ppos, len, flags);
}
+EXPORT_SYMBOL_GPL(do_splice_from);
/*
* Attempt to initiate a splice from a file to a pipe.
@@ -876,6 +877,7 @@ long do_splice_to(struct file *in, loff_
return splice_read(in, ppos, pipe, len, flags);
}
+EXPORT_SYMBOL_GPL(do_splice_to);
/**
* splice_direct_to_actor - splices data directly between two non-pipes
diff -Nurp linux-5.4-aufs/fs/sync.c linux-5.4-aufs-mod/fs/sync.c
--- linux-5.4-aufs/fs/sync.c 2019-11-28 01:25:59.071925617 +0200
+++ linux-5.4-aufs-mod/fs/sync.c 2019-11-28 01:38:48.780894927 +0200
@@ -39,6 +39,7 @@ int __sync_filesystem(struct super_block
sb->s_op->sync_fs(sb, wait);
return __sync_blockdev(sb->s_bdev, wait);
}
+EXPORT_SYMBOL_GPL(__sync_filesystem);
/*
* Write out and wait upon all dirty data associated with this
diff -Nurp linux-5.4-aufs/fs/xattr.c linux-5.4-aufs-mod/fs/xattr.c
--- linux-5.4-aufs/fs/xattr.c 2019-11-25 02:32:01.000000000 +0200
+++ linux-5.4-aufs-mod/fs/xattr.c 2019-11-28 01:38:48.780894927 +0200
@@ -296,6 +296,7 @@ vfs_getxattr_alloc(struct dentry *dentry
*xattr_value = value;
return error;
}
+EXPORT_SYMBOL_GPL(vfs_getxattr_alloc);
ssize_t
__vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name,
diff -Nurp linux-5.4-aufs/kernel/locking/lockdep.c linux-5.4-aufs-mod/kernel/locking/lockdep.c
--- linux-5.4-aufs/kernel/locking/lockdep.c 2019-11-28 01:25:59.072925617 +0200
+++ linux-5.4-aufs-mod/kernel/locking/lockdep.c 2019-11-28 01:38:48.780894927 +0200
@@ -174,6 +174,7 @@ inline struct lock_class *lockdep_hlock_
*/
return lock_classes + class_idx;
}
+EXPORT_SYMBOL_GPL(lockdep_hlock_class);
#define hlock_class(hlock) lockdep_hlock_class(hlock)
#ifdef CONFIG_LOCK_STAT
diff -Nurp linux-5.4-aufs/kernel/task_work.c linux-5.4-aufs-mod/kernel/task_work.c
--- linux-5.4-aufs/kernel/task_work.c 2019-11-25 02:32:01.000000000 +0200
+++ linux-5.4-aufs-mod/kernel/task_work.c 2019-11-28 01:38:48.786894927 +0200
@@ -116,3 +116,4 @@ void task_work_run(void)
} while (work);
}
}
+EXPORT_SYMBOL_GPL(task_work_run);
diff -Nurp linux-5.4-aufs/security/device_cgroup.c linux-5.4-aufs-mod/security/device_cgroup.c
--- linux-5.4-aufs/security/device_cgroup.c 2019-11-25 02:32:01.000000000 +0200
+++ linux-5.4-aufs-mod/security/device_cgroup.c 2019-11-28 01:38:48.790894927 +0200
@@ -824,3 +824,4 @@ int __devcgroup_check_permission(short t
return 0;
}
+EXPORT_SYMBOL_GPL(__devcgroup_check_permission);
diff -Nurp linux-5.4-aufs/security/security.c linux-5.4-aufs-mod/security/security.c
--- linux-5.4-aufs/security/security.c 2019-11-25 02:32:01.000000000 +0200
+++ linux-5.4-aufs-mod/security/security.c 2019-11-28 01:38:48.794894926 +0200
@@ -1036,6 +1036,7 @@ int security_path_rmdir(const struct pat
return 0;
return call_int_hook(path_rmdir, 0, dir, dentry);
}
+EXPORT_SYMBOL_GPL(security_path_rmdir);
int security_path_unlink(const struct path *dir, struct dentry *dentry)
{
@@ -1052,6 +1053,7 @@ int security_path_symlink(const struct p
return 0;
return call_int_hook(path_symlink, 0, dir, dentry, old_name);
}
+EXPORT_SYMBOL_GPL(security_path_symlink);
int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
struct dentry *new_dentry)
@@ -1060,6 +1062,7 @@ int security_path_link(struct dentry *ol
return 0;
return call_int_hook(path_link, 0, old_dentry, new_dir, new_dentry);
}
+EXPORT_SYMBOL_GPL(security_path_link);
int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
const struct path *new_dir, struct dentry *new_dentry,
@@ -1087,6 +1090,7 @@ int security_path_truncate(const struct
return 0;
return call_int_hook(path_truncate, 0, path);
}
+EXPORT_SYMBOL_GPL(security_path_truncate);
int security_path_chmod(const struct path *path, umode_t mode)
{
@@ -1094,6 +1098,7 @@ int security_path_chmod(const struct pat
return 0;
return call_int_hook(path_chmod, 0, path, mode);
}
+EXPORT_SYMBOL_GPL(security_path_chmod);
int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
{
@@ -1101,6 +1106,7 @@ int security_path_chown(const struct pat
return 0;
return call_int_hook(path_chown, 0, path, uid, gid);
}
+EXPORT_SYMBOL_GPL(security_path_chown);
int security_path_chroot(const struct path *path)
{
@@ -1201,6 +1207,7 @@ int security_inode_permission(struct ino
return 0;
return call_int_hook(inode_permission, 0, inode, mask);
}
+EXPORT_SYMBOL_GPL(security_inode_permission);
int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
{
@@ -1378,6 +1385,7 @@ int security_file_permission(struct file
return fsnotify_perm(file, mask);
}
+EXPORT_SYMBOL_GPL(security_file_permission);
int security_file_alloc(struct file *file)
{
@@ -0,0 +1,12 @@
diff -Nurp linux-5.3-aufs/include/uapi/linux/aufs_type.h linux-5.3-aufs-ver/include/uapi/linux/aufs_type.h
--- linux-5.3-aufs/include/uapi/linux/aufs_type.h 2019-09-24 16:13:44.012259519 +0300
+++ linux-5.3-aufs-ver/include/uapi/linux/aufs_type.h 2019-09-24 20:04:21.924707762 +0300
@@ -27,7 +27,7 @@
#include <linux/limits.h>
-#define AUFS_VERSION "5.x-rcN"
+#define AUFS_VERSION "5.4"
/* todo? move this to linux-2.6.19/include/magic.h */
#define AUFS_SUPER_MAGIC ('a' << 24 | 'u' << 16 | 'f' << 8 | 's')
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,18 @@
--- a/drivers/input/touchscreen/goodix.c
+++ a/drivers/input/touchscreen/goodix.c
@@ -947,6 +954,7 @@ static SIMPLE_DEV_PM_OPS(goodix_pm_ops, goodix_suspend, goodix_resume);
static const struct i2c_device_id goodix_ts_id[] = {
{ "GDIX1001:00", 0 },
+ { "GDIX1002:00", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, goodix_ts_id);
@@ -954,6 +962,7 @@ MODULE_DEVICE_TABLE(i2c, goodix_ts_id);
#ifdef CONFIG_ACPI
static const struct acpi_device_id goodix_acpi_match[] = {
{ "GDIX1001", 0 },
+ { "GDIX1002", 0 },
{ }
};
MODULE_DEVICE_TABLE(acpi, goodix_acpi_match);
@@ -0,0 +1,60 @@
From faec44b6838312484d63e82286087cf2d5ebb891 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 12 Jan 2018 00:36:48 -0800
Subject: [PATCH] Input: goodix - disable IRQs while suspended
We should not try to do any i2c transfers before the controller is
resumed (which happens before our resume method gets called).
So we need to disable our IRQ while suspended to enforce this. The
code paths for devices with GPIOs for the int and reset pins already
disable the IRQ the through goodix_free_irq().
This commit also disables the IRQ while suspended for devices without
GPIOs for the int and reset pins.
This fixes the i2c bus sometimes getting stuck after a suspend/resume
causing the touchscreen to sometimes not work after a suspend/resume.
This has been tested on a GPD pocked device.
BugLink: https://github.com/nexus511/gpd-ubuntu-packages/issues/10
BugLink: https://www.reddit.com/r/GPDPocket/comments/7niut2/fix_for_broken_touch_after_resume_all_linux/
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Bastien Nocera <hadess@hadess.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/goodix.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index 69d0b8cbc71f..ecec8eb17f28 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -878,8 +878,10 @@ static int __maybe_unused goodix_suspend(struct device *dev)
int error;
/* We need gpio pins to suspend/resume */
- if (!ts->gpiod_int || !ts->gpiod_rst)
+ if (!ts->gpiod_int || !ts->gpiod_rst) {
+ disable_irq(client->irq);
return 0;
+ }
wait_for_completion(&ts->firmware_loading_complete);
@@ -919,8 +921,10 @@ static int __maybe_unused goodix_resume(struct device *dev)
struct goodix_ts_data *ts = i2c_get_clientdata(client);
int error;
- if (!ts->gpiod_int || !ts->gpiod_rst)
+ if (!ts->gpiod_int || !ts->gpiod_rst) {
+ enable_irq(client->irq);
return 0;
+ }
/*
* Exit sleep mode by outputting HIGH level to INT pin
--
2.16.2
@@ -1,6 +1,6 @@
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/allowedips.c 2018-02-18 22:22:31.000000000 +0200
@@ -0,0 +1,327 @@
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/allowedips.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,328 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
@@ -142,7 +142,8 @@
+/* This could be much faster if it actually just compared the common bits properly,
+ * by precomputing a mask bswap(~0 << (32 - cidr)), and the rest, but it turns out that
+ * common_bits is already super fast on modern processors, even taking into account
+ * the unfortunate bswap. So, we just inline it like this instead. */
+ * the unfortunate bswap. So, we just inline it like this instead.
+ */
+#define prefix_matches(node, key, bits) (common_bits(node, key, bits) >= node->cidr)
+
+static __always_inline struct allowedips_node *find_node(struct allowedips_node *trie, u8 bits, const u8 *key)
@@ -328,8 +329,8 @@
+}
+
+#include "selftest/allowedips.h"
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/cookie.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/cookie.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,195 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -526,8 +527,8 @@
+out:
+ peer_put(entry->peer);
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/device.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/device.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,421 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -950,8 +951,8 @@
+#endif
+ rcu_barrier_bh();
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/hashtables.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/hashtables.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,168 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -1121,8 +1122,8 @@
+ rcu_read_unlock_bh();
+ return entry;
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/main.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/main.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,69 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -1193,8 +1194,8 @@
+MODULE_VERSION(WIREGUARD_VERSION);
+MODULE_ALIAS_RTNL_LINK(KBUILD_MODNAME);
+MODULE_ALIAS_GENL_FAMILY(WG_GENL_NAME);
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/netlink.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/netlink.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,517 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -1713,8 +1714,8 @@
+{
+ genl_unregister_family(&genl_family);
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/noise.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/noise.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,635 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -2351,8 +2352,8 @@
+ up_write(&handshake->lock);
+ return false;
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/peer.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/peer.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,136 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -2490,8 +2491,8 @@
+ list_for_each_entry_safe(peer, temp, &wg->peer_list, peer_list)
+ peer_remove(peer);
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/queueing.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/queueing.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -2539,8 +2540,8 @@
+ WARN_ON(!ptr_ring_empty_bh(&queue->ring));
+ ptr_ring_cleanup(&queue->ring, NULL);
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/ratelimiter.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/ratelimiter.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,199 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -2741,8 +2742,8 @@
+}
+
+#include "selftest/ratelimiter.h"
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/receive.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/receive.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,490 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -3234,8 +3235,8 @@
+err:
+ dev_kfree_skb(skb);
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/send.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/send.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,348 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -3585,8 +3586,8 @@
+ */
+ packet_send_queued_handshake_initiation(peer, false);
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/socket.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/socket.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,393 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -3981,8 +3982,8 @@
+ sock_free(old4);
+ sock_free(old6);
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/timers.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/timers.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,199 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4183,8 +4184,8 @@
+ del_timer_sync(&peer->timer_persistent_keepalive);
+ flush_work(&peer->clear_peer_work);
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/allowedips.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/allowedips.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4230,8 +4231,8 @@
+#endif
+
+#endif /* _WG_ALLOWEDIPS_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/cookie.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/cookie.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4285,8 +4286,8 @@
+void cookie_message_consume(struct message_handshake_cookie *src, struct wireguard_device *wg);
+
+#endif /* _WG_COOKIE_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/device.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/device.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4352,8 +4353,8 @@
+void device_uninit(void);
+
+#endif /* _WG_DEVICE_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/hashtables.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/hashtables.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4407,9 +4408,9 @@
+struct index_hashtable_entry *index_hashtable_lookup(struct index_hashtable *table, const enum index_hashtable_type type_mask, const __le32 index);
+
+#endif /* _WG_HASHTABLES_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/messages.h 2018-02-18 22:22:31.000000000 +0200
@@ -0,0 +1,129 @@
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/messages.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,128 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
@@ -4472,8 +4473,7 @@
+ MESSAGE_HANDSHAKE_INITIATION = 1,
+ MESSAGE_HANDSHAKE_RESPONSE = 2,
+ MESSAGE_HANDSHAKE_COOKIE = 3,
+ MESSAGE_DATA = 4,
+ MESSAGE_TOTAL = 5
+ MESSAGE_DATA = 4
+};
+
+struct message_header {
@@ -4539,8 +4539,8 @@
+};
+
+#endif /* _WG_MESSAGES_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/netlink.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/netlink.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4554,8 +4554,8 @@
+void genetlink_uninit(void);
+
+#endif /* _WG_NETLINK_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/noise.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/noise.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,117 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4613,10 +4613,10 @@
+};
+
+struct noise_static_identity {
+ bool has_identity;
+ u8 static_public[NOISE_PUBLIC_KEY_LEN];
+ u8 static_private[NOISE_PUBLIC_KEY_LEN];
+ struct rw_semaphore lock;
+ bool has_identity;
+};
+
+enum noise_handshake_state {
@@ -4668,14 +4668,14 @@
+bool noise_handshake_create_initiation(struct message_handshake_initiation *dst, struct noise_handshake *handshake);
+struct wireguard_peer *noise_handshake_consume_initiation(struct message_handshake_initiation *src, struct wireguard_device *wg);
+
+bool noise_handshake_create_response(struct message_handshake_response *dst, struct noise_handshake *peer);
+bool noise_handshake_create_response(struct message_handshake_response *dst, struct noise_handshake *handshake);
+struct wireguard_peer *noise_handshake_consume_response(struct message_handshake_response *src, struct wireguard_device *wg);
+
+bool noise_handshake_begin_session(struct noise_handshake *handshake, struct noise_keypairs *keypairs);
+
+#endif /* _WG_NOISE_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/peer.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/peer.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4750,8 +4750,8 @@
+struct wireguard_peer *peer_lookup_by_index(struct wireguard_device *wg, u32 index);
+
+#endif /* _WG_PEER_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/queueing.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/queueing.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,142 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4818,7 +4818,7 @@
+
+static inline void skb_reset(struct sk_buff *skb)
+{
+ skb_scrub_packet(skb, false);
+ skb_scrub_packet(skb, true);
+ memset(&skb->headers_start, 0, offsetof(struct sk_buff, headers_end) - offsetof(struct sk_buff, headers_start));
+ skb->queue_mapping = 0;
+ skb->nohdr = 0;
@@ -4895,8 +4895,8 @@
+#endif
+
+#endif /* _WG_QUEUEING_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/ratelimiter.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/ratelimiter.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4917,8 +4917,8 @@
+#endif
+
+#endif /* _WG_RATELIMITER_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/socket.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/socket.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4955,8 +4955,8 @@
+#endif
+
+#endif /* _WG_SOCKET_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/timers.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/timers.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -4979,12 +4979,12 @@
+void timers_any_authenticated_packet_traversal(struct wireguard_peer *peer);
+
+#endif /* _WG_TIMERS_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/version.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/version.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1 @@
+#define WIREGUARD_VERSION "0.0.20180218"
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/uapi/wireguard.h 2018-02-18 22:22:31.000000000 +0200
+#define WIREGUARD_VERSION "0.0.20180304"
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/uapi/wireguard.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,182 @@
+/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR MIT)
+ *
@@ -5168,8 +5168,8 @@
+#define WGALLOWEDIP_A_MAX (__WGALLOWEDIP_A_LAST - 1)
+
+#endif /* _WG_UAPI_WIREGUARD_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/selftest/allowedips.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/selftest/allowedips.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,514 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -5685,8 +5685,8 @@
+#undef init_peer
+
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/selftest/blake2s.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/selftest/blake2s.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,559 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -6247,8 +6247,8 @@
+ return success;
+}
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/selftest/chacha20poly1305.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/selftest/chacha20poly1305.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,333 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -6583,8 +6583,8 @@
+ return success;
+}
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/selftest/counter.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/selftest/counter.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,92 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -6678,8 +6678,8 @@
+ return success;
+}
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/selftest/curve25519.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/selftest/curve25519.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,103 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -6784,8 +6784,8 @@
+ return success;
+}
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/selftest/poly1305.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/selftest/poly1305.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,1566 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -8353,8 +8353,8 @@
+ return success;
+}
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/selftest/ratelimiter.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/selftest/ratelimiter.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,157 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -8513,8 +8513,8 @@
+ return ret;
+}
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/blake2s.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/blake2s.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,294 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -8631,8 +8631,8 @@
+#include <asm/processor.h>
+#include <asm/fpu/api.h>
+#include <asm/simd.h>
+static bool blake2s_use_avx __read_mostly;
+static bool blake2s_use_avx512 __read_mostly;
+static bool blake2s_use_avx __ro_after_init;
+static bool blake2s_use_avx512 __ro_after_init;
+void __init blake2s_fpu_init(void)
+{
+#ifndef CONFIG_UML
@@ -8810,8 +8810,8 @@
+}
+
+#include "../selftest/blake2s.h"
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/chacha20poly1305.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/chacha20poly1305.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,852 @@
+/* SPDX-License-Identifier: OpenSSL OR (BSD-3-Clause OR GPL-2.0)
+ *
@@ -8853,11 +8853,11 @@
+asmlinkage void poly1305_blocks_avx512(void *ctx, const u8 *inp, size_t len, u32 padbit);
+#endif
+
+static bool chacha20poly1305_use_ssse3 __read_mostly;
+static bool chacha20poly1305_use_avx __read_mostly;
+static bool chacha20poly1305_use_avx2 __read_mostly;
+static bool chacha20poly1305_use_avx512 __read_mostly;
+static bool chacha20poly1305_use_avx512vl __read_mostly;
+static bool chacha20poly1305_use_ssse3 __ro_after_init;
+static bool chacha20poly1305_use_avx __ro_after_init;
+static bool chacha20poly1305_use_avx2 __ro_after_init;
+static bool chacha20poly1305_use_avx512 __ro_after_init;
+static bool chacha20poly1305_use_avx512vl __ro_after_init;
+
+void __init chacha20poly1305_fpu_init(void)
+{
@@ -8889,7 +8889,7 @@
+asmlinkage void poly1305_emit_neon(void *ctx, u8 mac[16], const u32 nonce[4]);
+asmlinkage void chacha20_neon(u8 *out, const u8 *in, size_t len, const u32 key[8], const u32 counter[4]);
+#endif
+static bool chacha20poly1305_use_neon __read_mostly;
+static bool chacha20poly1305_use_neon __ro_after_init;
+void __init chacha20poly1305_fpu_init(void)
+{
+#if defined(CONFIG_ARM64)
@@ -9665,8 +9665,8 @@
+
+#include "../selftest/chacha20poly1305.h"
+#include "../selftest/poly1305.h"
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/curve25519.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/curve25519.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -9749,8 +9749,8 @@
+}
+
+#include "../selftest/curve25519.h"
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/blake2s.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/blake2s.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,94 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -9846,8 +9846,8 @@
+#endif
+
+#endif /* _WG_BLAKE2S_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/chacha20poly1305.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/chacha20poly1305.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,93 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -9942,8 +9942,8 @@
+#endif
+
+#endif /* _WG_CHACHA20POLY1305_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/curve25519-arm.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/curve25519-arm.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -9954,13 +9954,13 @@
+#include <asm/neon.h>
+#include <asm/simd.h>
+asmlinkage void curve25519_neon(u8 mypublic[CURVE25519_POINT_SIZE], const u8 secret[CURVE25519_POINT_SIZE], const u8 basepoint[CURVE25519_POINT_SIZE]);
+static bool curve25519_use_neon __read_mostly;
+static bool curve25519_use_neon __ro_after_init;
+void __init curve25519_fpu_init(void)
+{
+ curve25519_use_neon = elf_hwcap & HWCAP_NEON;
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/curve25519-fiat32.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/curve25519-fiat32.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,838 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -10800,8 +10800,8 @@
+ memzero_explicit(&tmp1l, sizeof(tmp1l));
+ memzero_explicit(&e, sizeof(e));
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/curve25519.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/curve25519.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -10828,8 +10828,8 @@
+#endif
+
+#endif /* _WG_CURVE25519_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/curve25519-hacl64.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/curve25519-hacl64.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,751 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -11582,9 +11582,9 @@
+ }
+ memzero_explicit(buf0, sizeof(buf0));
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/curve25519-x86_64.h 2018-02-18 22:22:31.000000000 +0200
@@ -0,0 +1,175 @@
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/curve25519-x86_64.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,176 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
@@ -11596,7 +11596,8 @@
+#include <asm/processor.h>
+#include <asm/fpu/api.h>
+#include <asm/simd.h>
+static bool curve25519_use_avx __read_mostly;
+
+static bool curve25519_use_avx __ro_after_init;
+void __init curve25519_fpu_init(void)
+{
+#ifndef CONFIG_UML
@@ -11760,8 +11761,8 @@
+ memzero_explicit(x_51, sizeof(x_51));
+ memzero_explicit(z_51, sizeof(z_51));
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/blake2s-x86_64.S 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/blake2s-x86_64.S 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,685 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -12448,8 +12449,8 @@
+ retq
+ENDPROC(blake2s_compress_avx512)
+#endif /* CONFIG_AS_AVX512 */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/chacha20-arm64.S 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/chacha20-arm64.S 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,1940 @@
+/* SPDX-License-Identifier: OpenSSL OR (BSD-3-Clause OR GPL-2.0)
+ *
@@ -14391,8 +14392,8 @@
+.Labort_neon:
+ ret
+ENDPROC(chacha20_neon)
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/chacha20-arm.S 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/chacha20-arm.S 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,1471 @@
+/* SPDX-License-Identifier: OpenSSL OR (BSD-3-Clause OR GPL-2.0)
+ *
@@ -15865,8 +15866,8 @@
+.Lno_data_arm:
+ ldmia sp!,{r4-r11,pc}
+ENDPROC(chacha20_arm)
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/chacha20-x86_64.S 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/chacha20-x86_64.S 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,2630 @@
+/* SPDX-License-Identifier: OpenSSL OR (BSD-3-Clause OR GPL-2.0)
+ *
@@ -18498,8 +18499,8 @@
+ENDPROC(chacha20_avx512vl)
+
+#endif /* CONFIG_AS_AVX512 */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/curve25519-arm.S 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/curve25519-arm.S 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,2110 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -20611,8 +20612,8 @@
+ bx lr
+ENDPROC(curve25519_neon)
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/curve25519-x86_64.S 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/curve25519-x86_64.S 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,3261 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -23875,8 +23876,8 @@
+ ret
+ENDPROC(curve25519_sandy2x_ladder_base)
+#endif /* CONFIG_AS_AVX */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/poly1305-arm64.S 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/poly1305-arm64.S 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,820 @@
+/* SPDX-License-Identifier: OpenSSL OR (BSD-3-Clause OR GPL-2.0)
+ *
@@ -24698,8 +24699,8 @@
+.align 5
+.Lzeros:
+.long 0,0,0,0,0,0,0,0
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/poly1305-arm.S 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/poly1305-arm.S 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,1115 @@
+/* SPDX-License-Identifier: OpenSSL OR (BSD-3-Clause OR GPL-2.0)
+ *
@@ -25816,8 +25817,8 @@
+.Lzeros:
+.long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/poly1305-mips64.S 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/poly1305-mips64.S 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,357 @@
+/* SPDX-License-Identifier: OpenSSL OR (BSD-3-Clause OR GPL-2.0)
+ *
@@ -26176,8 +26177,8 @@
+
+ jr $31
+.end poly1305_emit_mips
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/crypto/poly1305-x86_64.S 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/crypto/poly1305-x86_64.S 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,2803 @@
+/* SPDX-License-Identifier: OpenSSL OR (BSD-3-Clause OR GPL-2.0)
+ *
@@ -28982,8 +28983,8 @@
+
+ENDPROC(poly1305_blocks_avx512)
+#endif /* CONFIG_AS_AVX512 */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/Makefile 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/Makefile 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0
+#
@@ -29004,13 +29005,14 @@
+include $(src)/compat/Makefile.include
+
+obj-$(if $(KBUILD_EXTMOD),m,$(CONFIG_WIREGUARD)) := wireguard.o
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/Kconfig 2018-02-18 22:22:31.000000000 +0200
@@ -0,0 +1,30 @@
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/Kconfig 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,31 @@
+config WIREGUARD
+ tristate "IP: WireGuard secure network tunnel"
+ depends on NET && INET
+ select NET_UDP_TUNNEL
+ select DST_CACHE
+ select CRYPTO_BLKCIPHER
+ select VFP
+ select VFPv3
@@ -29037,12 +29039,12 @@
+ only useful for debugging.
+
+ Say N here unless you know what you're doing.
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/simd/include/asm/simd.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/simd/include/asm/simd.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1 @@
+#include <asm/i387.h>
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/udp_tunnel/udp_tunnel_partial_compat.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/udp_tunnel/udp_tunnel_partial_compat.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,226 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -29270,8 +29272,8 @@
+#define udp_port_cfg udp_port_cfg_new
+#define udp_sock_create(a, b, c) udp_sock_create_new(a, b, c)
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/udp_tunnel/include/net/udp_tunnel.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/udp_tunnel/include/net/udp_tunnel.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,94 @@
+#ifndef _WG_NET_UDP_TUNNEL_H
+#define _WG_NET_UDP_TUNNEL_H
@@ -29367,8 +29369,8 @@
+void udp_tunnel_sock_release(struct socket *sock);
+
+#endif /* _WG_NET_UDP_TUNNEL_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/udp_tunnel/udp_tunnel.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/udp_tunnel/udp_tunnel.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,385 @@
+#include <linux/module.h>
+#include <linux/errno.h>
@@ -29755,12 +29757,12 @@
+ return 0;
+}
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/fpu/include/asm/fpu/api.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/fpu/include/asm/fpu/api.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1 @@
+#include <asm/i387.h>
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/checksum/checksum_partial_compat.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/checksum/checksum_partial_compat.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,208 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -29970,21 +29972,22 @@
+ }
+ return err;
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/Makefile.include 2018-02-18 22:22:31.000000000 +0200
@@ -0,0 +1,70 @@
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/Makefile.include 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+
+ifeq ($(wildcard $(src)/compat/compat.h),)
+ccflags-y += -include $(srctree)/$(src)/compat/compat.h
+asflags-y += -include $(srctree)/$(src)/compat/compat-asm.h
+cmd_include_path_prefix := $(srctree)/$(src)
+else
+ccflags-y += -include $(src)/compat/compat.h
+asflags-y += -include $(src)/compat/compat-asm.h
+cmd_include_path_prefix := $(src)
+endif
+
+ccflags-y += -include $(cmd_include_path_prefix)/compat/compat.h
+asflags-y += -include $(cmd_include_path_prefix)/compat/compat-asm.h
+
+ifeq ($(wildcard $(srctree)/include/linux/ptr_ring.h),)
+ccflags-y += -I$(src)/compat/ptr_ring/include
+endif
@@ -30017,7 +30020,7 @@
+endif
+
+ifeq ($(shell grep -F "int crypto_memneq" "$(srctree)/include/crypto/algapi.h"),)
+ccflags-y += -include $(src)/compat/memneq/include.h
+ccflags-y += -include $(cmd_include_path_prefix)/compat/memneq/include.h
+wireguard-y += compat/memneq/memneq.o
+endif
+
@@ -30043,8 +30046,8 @@
+ asflags-y += $(avx512_instr)
+ endif
+endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/siphash/siphash.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/siphash/siphash.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,539 @@
+/* Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+ *
@@ -30585,8 +30588,8 @@
+ HPOSTAMBLE
+}
+#endif
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/siphash/include/linux/siphash.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/siphash/include/linux/siphash.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,140 @@
+/* Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+ *
@@ -30728,8 +30731,8 @@
+}
+
+#endif /* _WG_LINUX_SIPHASH_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/intel-family/include/asm/intel-family.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/intel-family/include/asm/intel-family.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_INTEL_FAMILY_H
@@ -30804,8 +30807,8 @@
+#define INTEL_FAM6_XEON_PHI_KNM 0x85 /* Knights Mill */
+
+#endif /* _ASM_X86_INTEL_FAMILY_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/compat.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/compat.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,632 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -31291,7 +31294,7 @@
+#else
+#define ___COMPAT_NETLINK_DUMP_BLOCK return get_device_dump_real(skb, cb);
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 14) && LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) || LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 63)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)
+#define get_device_dump(a, b) get_device_dump_real(a, b); \
+static int get_device_dump(a, b) { \
+ struct wireguard_device *wg = (struct wireguard_device *)cb->args[0]; \
@@ -31439,8 +31442,8 @@
+#endif
+
+#endif /* _WG_COMPAT_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/ptr_ring/include/linux/ptr_ring.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/ptr_ring/include/linux/ptr_ring.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,640 @@
+/*
+ * Definitions for the 'struct ptr_ring' datastructure.
@@ -32082,16 +32085,16 @@
+}
+
+#endif /* _LINUX_PTR_RING_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/memneq/include.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/memneq/include.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,5 @@
+extern noinline unsigned long __crypto_memneq(const void *a, const void *b, size_t size);
+static inline int crypto_memneq(const void *a, const void *b, size_t size)
+{
+ return __crypto_memneq(a, b, size) != 0UL ? 1 : 0;
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/memneq/memneq.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/memneq/memneq.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,170 @@
+/*
+ * Constant-time equality testing of memory regions.
@@ -32157,7 +32160,7 @@
+#include <crypto/algapi.h>
+
+/* Make the optimizer believe the variable can be manipulated arbitrarily. */
+#define COMPILER_OPTIMIZER_HIDE_VAR(var) __asm__ ("" : "=r" (var) : "0" (var))
+#define COMPILER_OPTIMIZER_HIDE_VAR(var) asm("" : "=r" (var) : "0" (var))
+
+#ifndef __HAVE_ARCH_CRYPTO_MEMNEQ
+
@@ -32263,8 +32266,8 @@
+}
+
+#endif /* __HAVE_ARCH_CRYPTO_MEMNEQ */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/dst_cache/dst_cache.c 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/dst_cache/dst_cache.c 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,175 @@
+/*
+ * net/core/dst_cache.c - dst entry cache
@@ -32441,8 +32444,8 @@
+
+ free_percpu(dst_cache->cache);
+}
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/dst_cache/include/net/dst_cache.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/dst_cache/include/net/dst_cache.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,97 @@
+#ifndef _WG_NET_DST_CACHE_H
+#define _WG_NET_DST_CACHE_H
@@ -32541,8 +32544,8 @@
+void dst_cache_destroy(struct dst_cache *dst_cache);
+
+#endif /* _WG_NET_DST_CACHE_H */
--- /dev/null 2018-02-18 13:06:28.903837808 +0200
+++ b/net/wireguard/compat/compat-asm.h 2018-02-18 22:22:31.000000000 +0200
--- /dev/null 2018-03-04 21:55:12.891724619 +0200
+++ b/net/wireguard/compat/compat-asm.h 2018-03-04 19:51:33.000000000 +0200
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
@@ -0,0 +1,84 @@
From 57ebd808a97d7c5b1e1afb937c2db22beba3c1f8 Mon Sep 17 00:00:00 2001
From: Florian Westphal <fw@strlen.de>
Date: Wed, 7 Feb 2018 13:46:25 +0100
Subject: [PATCH] netfilter: add back stackpointer size checks
The rationale for removing the check is only correct for rulesets
generated by ip(6)tables.
In iptables, a jump can only occur to a user-defined chain, i.e.
because we size the stack based on number of user-defined chains we
cannot exceed stack size.
However, the underlying binary format has no such restriction,
and the validation step only ensures that the jump target is a
valid rule start point.
IOW, its possible to build a rule blob that has no user-defined
chains but does contain a jump.
If this happens, no jump stack gets allocated and crash occurs
because no jumpstack was allocated.
Fixes: 7814b6ec6d0d6 ("netfilter: xtables: don't save/restore jumpstack offset")
Reported-by: syzbot+e783f671527912cd9403@syzkaller.appspotmail.com
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/ipv4/netfilter/arp_tables.c | 4 ++++
net/ipv4/netfilter/ip_tables.c | 7 ++++++-
net/ipv6/netfilter/ip6_tables.c | 4 ++++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 4ffe302f9b82..e3e420f3ba7b 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -252,6 +252,10 @@ unsigned int arpt_do_table(struct sk_buff *skb,
}
if (table_base + v
!= arpt_next_entry(e)) {
+ if (unlikely(stackidx >= private->stacksize)) {
+ verdict = NF_DROP;
+ break;
+ }
jumpstack[stackidx++] = e;
}
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 9a71f3149507..e38395a8dcf2 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -330,8 +330,13 @@ ipt_do_table(struct sk_buff *skb,
continue;
}
if (table_base + v != ipt_next_entry(e) &&
- !(e->ip.flags & IPT_F_GOTO))
+ !(e->ip.flags & IPT_F_GOTO)) {
+ if (unlikely(stackidx >= private->stacksize)) {
+ verdict = NF_DROP;
+ break;
+ }
jumpstack[stackidx++] = e;
+ }
e = get_entry(table_base, v);
continue;
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index af4c917e0836..62358b93bbac 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -352,6 +352,10 @@ ip6t_do_table(struct sk_buff *skb,
}
if (table_base + v != ip6t_next_entry(e) &&
!(e->ipv6.flags & IP6T_F_GOTO)) {
+ if (unlikely(stackidx >= private->stacksize)) {
+ verdict = NF_DROP;
+ break;
+ }
jumpstack[stackidx++] = e;
}
--
2.16.2
File diff suppressed because it is too large Load Diff
@@ -1,7 +1,7 @@
From 3b7711fd3adb7d6b812a33da4a4639ddce6522b6 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Fri, 19 Jan 2018 13:46:20 +0100
Subject: [PATCH 01/31] x86/asm-offsets: Move TSS_sp0 and TSS_sp1 to
Subject: [PATCH 01/34] x86/asm-offsets: Move TSS_sp0 and TSS_sp1 to
asm-offsets.c
These offsets will be used in 32 bit assembly code as well,
@@ -40,5 +40,5 @@ index bf51e51d808d..d2eba73a5f8a 100644
#ifdef CONFIG_CC_STACKPROTECTOR
--
2.13.6
2.16.2
@@ -1,7 +1,7 @@
From 52806123bdb0b558a5b4fbfa132bae32e53b008a Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Mon, 15 Jan 2018 18:20:15 +0100
Subject: [PATCH 02/31] x86/entry/32: Rename TSS_sysenter_sp0 to
Subject: [PATCH 02/34] x86/entry/32: Rename TSS_sysenter_sp0 to
TSS_entry_stack
The stack address doesn't need to be stored in tss.sp0 if
@@ -44,5 +44,5 @@ index fa1261eefa16..f452bfdc485a 100644
#ifdef CONFIG_CC_STACKPROTECTOR
--
2.13.6
2.16.2
@@ -1,7 +1,7 @@
From b696a2c46d9b9937b816b11ff2ec72aa0b65f204 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Fri, 19 Jan 2018 13:33:37 +0100
Subject: [PATCH 03/31] x86/entry/32: Load task stack from x86_tss.sp1 in
Subject: [PATCH 03/34] x86/entry/32: Load task stack from x86_tss.sp1 in
SYSENTER handler
We want x86_tss.sp0 point to the entry stack later to use
@@ -45,5 +45,5 @@ index 5224c6099184..097d36a64889 100644
/*
* Restore %gs if needed (which is common)
--
2.13.6
2.16.2
@@ -1,7 +1,7 @@
From 7c97243c7694dc1c0e0ad73bc17bdc2c553225ac Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 31 Jan 2018 10:50:02 +0100
Subject: [PATCH 04/31] x86/entry/32: Put ESPFIX code into a macro
Subject: [PATCH 04/34] x86/entry/32: Put ESPFIX code into a macro
This makes it easier to split up the shared iret code path.
@@ -133,5 +133,5 @@ index e65977615616..0289bde37a08 100644
.macro FIXUP_ESPFIX_STACK
--
2.13.6
2.16.2
@@ -1,7 +1,7 @@
From c66ec22d03296d1311197aaef753c1c320eed225 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 31 Jan 2018 10:58:38 +0100
Subject: [PATCH 05/31] x86/entry/32: Unshare NMI return path
Subject: [PATCH 05/34] x86/entry/32: Unshare NMI return path
NMI will no longer use most of the shared return path,
because NMI needs special handling when the CR3 switches for
@@ -39,5 +39,5 @@ index 0289bde37a08..00ae759a7c44 100644
#ifdef CONFIG_X86_ESPFIX32
.Lnmi_espfix_stack:
--
2.13.6
2.16.2
@@ -1,7 +1,7 @@
From 916e5e906873de859d8a87c1ffb0323e167d1a44 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 31 Jan 2018 11:07:32 +0100
Subject: [PATCH 06/31] x86/entry/32: Split off return-to-kernel path
Subject: [PATCH 06/34] x86/entry/32: Split off return-to-kernel path
Use a separate return path when we know we are returning to
the kernel. This allows us to put the PTI cr3-switch and the
@@ -51,5 +51,5 @@ index 00ae759a7c44..9bd77183965f 100644
ENTRY(iret_exc )
pushl $0 # no error code
--
2.13.6
2.16.2
@@ -1,7 +1,7 @@
From c19ad15b16ec8908794459f28b44eca889a925f7 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 31 Jan 2018 11:29:59 +0100
Subject: [PATCH 07/31] x86/entry/32: Restore segments before int registers
Subject: [PATCH 07/34] x86/entry/32: Restore segments before int registers
Restoring the segments can cause exceptions that need to be
handled. With PTI enabled, we still need to be on kernel cr3
@@ -27,18 +27,18 @@ diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 9bd77183965f..b39c5e210b43 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -92,11 +92,6 @@
@@ -91,11 +91,6 @@
/* unfortunately push/pop can't be no-op */
.macro PUSH_GS
pushl $0
.endm
-.endm
-.macro POP_GS pop=0
- addl $(4 + \pop), %esp
-.endm
-.macro POP_GS_EX
-.endm
.endm
/* all the rest are no-op */
.macro PTGS_TO_GS
@@ -116,20 +111,6 @@
pushl %gs
.endm
@@ -107,5 +107,5 @@ index 9bd77183965f..b39c5e210b43 100644
.macro CHECK_AND_APPLY_ESPFIX
--
2.13.6
2.16.2
@@ -1,7 +1,7 @@
From d9dc2b83bdfc2a9265302cc90b32739ac579f8cc Mon Sep 17 00:00:00 2001
From 288a2a6b31018ab9172598a39477404582ae29fa Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 10:55:52 +0100
Subject: [PATCH 08/31] x86/entry/32: Enter the kernel via trampoline stack
Subject: [PATCH 08/34] x86/entry/32: Enter the kernel via trampoline stack
Use the entry-stack as a trampoline to enter the kernel. The
entry-stack is already in the cpu_entry_area and will be
@@ -9,16 +9,16 @@ mapped to userspace when PTI is enabled.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/entry/entry_32.S | 135 +++++++++++++++++++++++++++++++--------
arch/x86/entry/entry_32.S | 136 +++++++++++++++++++++++++++++++--------
arch/x86/include/asm/switch_to.h | 6 +-
arch/x86/kernel/asm-offsets.c | 1 +
arch/x86/kernel/cpu/common.c | 5 +-
arch/x86/kernel/process.c | 2 -
arch/x86/kernel/process_32.c | 10 +--
6 files changed, 120 insertions(+), 39 deletions(-)
6 files changed, 121 insertions(+), 39 deletions(-)
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index b39c5e210b43..e714b53b1eaa 100644
index b39c5e210b43..1737da2e4517 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -135,25 +135,36 @@
@@ -65,7 +65,7 @@ index b39c5e210b43..e714b53b1eaa 100644
.endm
/*
@@ -261,6 +272,71 @@
@@ -261,6 +272,72 @@
.Lend_\@:
#endif /* CONFIG_X86_ESPFIX32 */
.endm
@@ -128,8 +128,9 @@ index b39c5e210b43..e714b53b1eaa 100644
+ * We are now on the task-stack and can safely copy over the
+ * stack-frame
+ */
+ shrl $2, %ecx
+ cld
+ rep movsb
+ rep movsl
+
+.Lend_\@:
+.endm
@@ -137,7 +138,7 @@ index b39c5e210b43..e714b53b1eaa 100644
/*
* %eax: prev task
* %edx: next task
@@ -454,6 +530,7 @@ ENTRY(xen_sysenter_target)
@@ -454,6 +531,7 @@ ENTRY(xen_sysenter_target)
*/
ENTRY(entry_SYSENTER_32)
movl TSS_entry_stack(%esp), %esp
@@ -145,7 +146,7 @@ index b39c5e210b43..e714b53b1eaa 100644
.Lsysenter_past_esp:
pushl $__USER_DS /* pt_regs->ss */
pushl %ebp /* pt_regs->sp (stashed in bp) */
@@ -462,7 +539,7 @@ ENTRY(entry_SYSENTER_32)
@@ -462,7 +540,7 @@ ENTRY(entry_SYSENTER_32)
pushl $__USER_CS /* pt_regs->cs */
pushl $0 /* pt_regs->ip = 0 (placeholder) */
pushl %eax /* pt_regs->orig_ax */
@@ -154,7 +155,7 @@ index b39c5e210b43..e714b53b1eaa 100644
/*
* SYSENTER doesn't filter flags, so we need to clear NT, AC
@@ -573,7 +650,8 @@ ENDPROC(entry_SYSENTER_32)
@@ -573,7 +651,8 @@ ENDPROC(entry_SYSENTER_32)
ENTRY(entry_INT80_32)
ASM_CLAC
pushl %eax /* pt_regs->orig_ax */
@@ -164,7 +165,7 @@ index b39c5e210b43..e714b53b1eaa 100644
/*
* User mode is traced as though IRQs are on, and the interrupt gate
@@ -665,7 +743,8 @@ END(irq_entries_start)
@@ -665,7 +744,8 @@ END(irq_entries_start)
common_interrupt:
ASM_CLAC
addl $-0x80, (%esp) /* Adjust vector into the [-256, -1] range */
@@ -174,7 +175,7 @@ index b39c5e210b43..e714b53b1eaa 100644
ENCODE_FRAME_POINTER
TRACE_IRQS_OFF
movl %esp, %eax
@@ -673,16 +752,16 @@ common_interrupt:
@@ -673,16 +753,16 @@ common_interrupt:
jmp ret_from_intr
ENDPROC(common_interrupt)
@@ -201,7 +202,7 @@ index b39c5e210b43..e714b53b1eaa 100644
ENDPROC(name)
#define BUILD_INTERRUPT(name, nr) \
@@ -908,16 +987,20 @@ common_exception:
@@ -908,16 +988,20 @@ common_exception:
pushl %es
pushl %ds
pushl %eax
@@ -224,7 +225,7 @@ index b39c5e210b43..e714b53b1eaa 100644
UNWIND_ESPFIX_STACK
GS_TO_REG %ecx
movl PT_GS(%esp), %edi # get the function address
@@ -925,9 +1008,6 @@ common_exception:
@@ -925,9 +1009,6 @@ common_exception:
movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
REG_TO_PTGS %ecx
SET_KERNEL_GS %ecx
@@ -234,7 +235,7 @@ index b39c5e210b43..e714b53b1eaa 100644
TRACE_IRQS_OFF
movl %esp, %eax # pt_regs pointer
CALL_NOSPEC %edi
@@ -946,6 +1026,7 @@ ENTRY(debug)
@@ -946,6 +1027,7 @@ ENTRY(debug)
*/
ASM_CLAC
pushl $-1 # mark this as an int
@@ -242,7 +243,7 @@ index b39c5e210b43..e714b53b1eaa 100644
SAVE_ALL
ENCODE_FRAME_POINTER
xorl %edx, %edx # error code 0
@@ -981,6 +1062,7 @@ END(debug)
@@ -981,6 +1063,7 @@ END(debug)
*/
ENTRY(nmi)
ASM_CLAC
@@ -250,7 +251,7 @@ index b39c5e210b43..e714b53b1eaa 100644
#ifdef CONFIG_X86_ESPFIX32
pushl %eax
movl %ss, %eax
@@ -1048,7 +1130,8 @@ END(nmi)
@@ -1048,7 +1131,8 @@ END(nmi)
ENTRY(int3)
ASM_CLAC
pushl $-1 # mark this as an int
@@ -351,5 +352,5 @@ index 097d36a64889..3f3a8c620c63 100644
/*
--
2.13.6
2.16.2
@@ -1,29 +1,30 @@
From 4a06e416cfe4d173f8ed65799e112f77ecb12be8 Mon Sep 17 00:00:00 2001
From af8c0db250e710c6ecd19a83bd8b57da44662041 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 11:28:30 +0100
Subject: [PATCH 09/31] x86/entry/32: Leave the kernel via trampoline stack
Subject: [PATCH 09/34] x86/entry/32: Leave the kernel via trampoline stack
Switch back to the trampoline stack before returning to
userspace.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/entry/entry_32.S | 55 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
arch/x86/entry/entry_32.S | 79 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 77 insertions(+), 2 deletions(-)
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index e714b53b1eaa..ba3d8c2886ed 100644
index 1737da2e4517..1b5656d7040e 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -338,6 +338,59 @@
@@ -338,6 +338,60 @@
.Lend_\@:
.endm
/*
+/*
+ * Switch back from the kernel stack to the entry stack.
+ *
+ * The %esp register must point to pt_regs on the task stack. It will
+ * first calculate the size of the stack-frame to copy, depending on
+ * whether we return to VM86 mode or not. With that it uses 'rep movsb'
+ * whether we return to VM86 mode or not. With that it uses 'rep movsl'
+ * to copy the contents of the stack over to the entry stack.
+ *
+ * We must be very careful here, as we can't trust the contents of the
@@ -55,11 +56,12 @@ index e714b53b1eaa..ba3d8c2886ed 100644
+ movl %esp, %esi
+
+ /* Save future stack pointer in %ebx */
+ movl %edi, %ebx
+ movl %edi, %ebx
+
+ /* Copy over the stack-frame */
+ shrl $2, %ecx
+ cld
+ rep movsb
+ rep movsl
+
+ /*
+ * Switch to entry-stack - needs to happen after everything is
@@ -71,19 +73,58 @@ index e714b53b1eaa..ba3d8c2886ed 100644
+.Lend_\@:
+.endm
+
+/*
/*
* %eax: prev task
* %edx: next task
*/
@@ -578,6 +631,7 @@ ENTRY(entry_SYSENTER_32)
@@ -579,25 +633,45 @@ ENTRY(entry_SYSENTER_32)
/* Opportunistic SYSEXIT */
TRACE_IRQS_ON /* User mode traces as IRQs on. */
+ SWITCH_TO_ENTRY_STACK /* Switch to per-cpu entry stack */
+
+ /*
+ * Setup entry stack - we keep the pointer in %eax and do the
+ * switch after almost all user-state is restored.
+ */
+
+ /* Load entry stack pointer and allocate frame for eflags/eax */
+ movl PER_CPU_VAR(cpu_tss_rw + TSS_sp0), %eax
+ subl $(2*4), %eax
+
+ /* Copy eflags and eax to entry stack */
+ movl PT_EFLAGS(%esp), %edi
+ movl PT_EAX(%esp), %esi
+ movl %edi, (%eax)
+ movl %esi, 4(%eax)
+
+ /* Restore user registers and segments */
movl PT_EIP(%esp), %edx /* pt_regs->ip */
movl PT_OLDESP(%esp), %ecx /* pt_regs->sp */
1: mov PT_FS(%esp), %fs
@@ -665,6 +719,7 @@ ENTRY(entry_INT80_32)
PTGS_TO_GS
+
popl %ebx /* pt_regs->bx */
addl $2*4, %esp /* skip pt_regs->cx and pt_regs->dx */
popl %esi /* pt_regs->si */
popl %edi /* pt_regs->di */
popl %ebp /* pt_regs->bp */
- popl %eax /* pt_regs->ax */
+
+ /* Switch to entry stack */
+ movl %eax, %esp
/*
* Restore all flags except IF. (We restore IF separately because
* STI gives a one-instruction window in which we won't be interrupted,
* whereas POPF does not.)
*/
- addl $PT_EFLAGS-PT_DS, %esp /* point esp at pt_regs->flags */
btr $X86_EFLAGS_IF_BIT, (%esp)
popfl
+ popl %eax
/*
* Return back to the vDSO, which will pop ecx and edx.
@@ -666,6 +740,7 @@ ENTRY(entry_INT80_32)
restore_all:
TRACE_IRQS_IRET
@@ -92,5 +133,5 @@ index e714b53b1eaa..ba3d8c2886ed 100644
CHECK_AND_APPLY_ESPFIX
.Lrestore_nocheck:
--
2.13.6
2.16.2
@@ -1,7 +1,7 @@
From 26b38ec7dd2591f092eb359a5a59752d799ab60d Mon Sep 17 00:00:00 2001
From 49a15ace3cbe2fba45548538ede04c1599b33fb9 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 31 Jan 2018 16:35:42 +0100
Subject: [PATCH 10/31] x86/entry/32: Introduce SAVE_ALL_NMI and
Subject: [PATCH 10/34] x86/entry/32: Introduce SAVE_ALL_NMI and
RESTORE_ALL_NMI
These macros will be used in the NMI handler code and
@@ -14,7 +14,7 @@ Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index ba3d8c2886ed..be1d814bd056 100644
index 1b5656d7040e..bb0bd896c74b 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -167,6 +167,9 @@
@@ -46,7 +46,7 @@ index ba3d8c2886ed..be1d814bd056 100644
.macro CHECK_AND_APPLY_ESPFIX
#ifdef CONFIG_X86_ESPFIX32
#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
@@ -1127,7 +1142,7 @@ ENTRY(nmi)
@@ -1148,7 +1163,7 @@ ENTRY(nmi)
#endif
pushl %eax # pt_regs->orig_ax
@@ -55,7 +55,7 @@ index ba3d8c2886ed..be1d814bd056 100644
ENCODE_FRAME_POINTER
xorl %edx, %edx # zero error code
movl %esp, %eax # pt_regs pointer
@@ -1155,7 +1170,7 @@ ENTRY(nmi)
@@ -1176,7 +1191,7 @@ ENTRY(nmi)
.Lnmi_return:
CHECK_AND_APPLY_ESPFIX
@@ -64,7 +64,7 @@ index ba3d8c2886ed..be1d814bd056 100644
jmp .Lirq_return
#ifdef CONFIG_X86_ESPFIX32
@@ -1171,12 +1186,12 @@ ENTRY(nmi)
@@ -1192,12 +1207,12 @@ ENTRY(nmi)
pushl 16(%esp)
.endr
pushl %eax
@@ -80,5 +80,5 @@ index ba3d8c2886ed..be1d814bd056 100644
jmp .Lirq_return
#endif
--
2.13.6
2.16.2
@@ -0,0 +1,198 @@
From bbad1145165d4ed4452913df109ee3429a10dd90 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 31 Jan 2018 20:48:02 +0100
Subject: [PATCH 11/34] x86/entry/32: Handle Entry from Kernel-Mode on
Entry-Stack
It can happen that we enter the kernel from kernel-mode and
on the entry-stack. The most common way this happens is when
we get an exception while loading the user-space segment
registers on the kernel-to-userspace exit path.
The segment loading needs to be done after the entry-stack
switch, because the stack-switch needs kernel %fs for
per_cpu access.
When this happens, we need to make sure that we leave the
kernel with the entry-stack again, so that the interrupted
code-path runs on the right stack when switching to the
user-cr3.
We do this by detecting this condition on kernel-entry by
checking CS.RPL and %esp, and if it happens, we copy over
the complete content of the entry stack to the task-stack.
This needs to be done because once we enter the exception
handlers we might be scheduled out or even migrated to a
different CPU, so that we can't rely on the entry-stack
contents. We also leave a marker in the stack-frame to
detect this condition on the exit path.
On the exit path the copy is reversed, we copy all of the
remaining task-stack back to the entry-stack and switch
to it.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/entry/entry_32.S | 110 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 109 insertions(+), 1 deletion(-)
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index bb0bd896c74b..3a84945fa3b6 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -299,6 +299,9 @@
* copied there. So allocate the stack-frame on the task-stack and
* switch to it before we do any copying.
*/
+
+#define CS_FROM_ENTRY_STACK (1 << 31)
+
.macro SWITCH_TO_KERNEL_STACK
ALTERNATIVE "", "jmp .Lend_\@", X86_FEATURE_XENPV
@@ -320,6 +323,10 @@
/* Load top of task-stack into %edi */
movl TSS_entry_stack(%edi), %edi
+ /* Special case - entry from kernel mode via entry stack */
+ testl $SEGMENT_RPL_MASK, PT_CS(%esp)
+ jz .Lentry_from_kernel_\@
+
/* Bytes to copy */
movl $PTREGS_SIZE, %ecx
@@ -333,8 +340,8 @@
*/
addl $(4 * 4), %ecx
-.Lcopy_pt_regs_\@:
#endif
+.Lcopy_pt_regs_\@:
/* Allocate frame on task-stack */
subl %ecx, %edi
@@ -350,6 +357,56 @@
cld
rep movsl
+ jmp .Lend_\@
+
+.Lentry_from_kernel_\@:
+
+ /*
+ * This handles the case when we enter the kernel from
+ * kernel-mode and %esp points to the entry-stack. When this
+ * happens we need to switch to the task-stack to run C code,
+ * but switch back to the entry-stack again when we approach
+ * iret and return to the interrupted code-path. This usually
+ * happens when we hit an exception while restoring user-space
+ * segment registers on the way back to user-space.
+ *
+ * When we switch to the task-stack here, we can't trust the
+ * contents of the entry-stack anymore, as the exception handler
+ * might be scheduled out or moved to another CPU. Therefore we
+ * copy the complete entry-stack to the task-stack and set a
+ * marker in the iret-frame (bit 31 of the CS dword) to detect
+ * what we've done on the iret path.
+ *
+ * On the iret path we copy everything back and switch to the
+ * entry-stack, so that the interrupted kernel code-path
+ * continues on the same stack it was interrupted with.
+ *
+ * Be aware that an NMI can happen anytime in this code.
+ *
+ * %esi: Entry-Stack pointer (same as %esp)
+ * %edi: Top of the task stack
+ */
+
+ /* Calculate number of bytes on the entry stack in %ecx */
+ movl %esi, %ecx
+
+ /* %ecx to the top of entry-stack */
+ andl $(MASK_entry_stack), %ecx
+ addl $(SIZEOF_entry_stack), %ecx
+
+ /* Number of bytes on the entry stack to %ecx */
+ sub %esi, %ecx
+
+ /* Mark stackframe as coming from entry stack */
+ orl $CS_FROM_ENTRY_STACK, PT_CS(%esp)
+
+ /*
+ * %esi and %edi are unchanged, %ecx contains the number of
+ * bytes to copy. The code at .Lcopy_pt_regs_\@ will allocate
+ * the stack-frame on task-stack and copy everything over
+ */
+ jmp .Lcopy_pt_regs_\@
+
.Lend_\@:
.endm
@@ -407,6 +464,56 @@
.Lend_\@:
.endm
+/*
+ * This macro handles the case when we return to kernel-mode on the iret
+ * path and have to switch back to the entry stack.
+ *
+ * See the comments below the .Lentry_from_kernel_\@ label in the
+ * SWITCH_TO_KERNEL_STACK macro for more details.
+ */
+.macro PARANOID_EXIT_TO_KERNEL_MODE
+
+ /*
+ * Test if we entered the kernel with the entry-stack. Most
+ * likely we did not, because this code only runs on the
+ * return-to-kernel path.
+ */
+ testl $CS_FROM_ENTRY_STACK, PT_CS(%esp)
+ jz .Lend_\@
+
+ /* Unlikely slow-path */
+
+ /* Clear marker from stack-frame */
+ andl $(~CS_FROM_ENTRY_STACK), PT_CS(%esp)
+
+ /* Copy the remaining task-stack contents to entry-stack */
+ movl %esp, %esi
+ movl PER_CPU_VAR(cpu_tss_rw + TSS_sp0), %edi
+
+ /* Bytes on the task-stack to ecx */
+ movl PER_CPU_VAR(cpu_current_top_of_stack), %ecx
+ subl %esi, %ecx
+
+ /* Allocate stack-frame on entry-stack */
+ subl %ecx, %edi
+
+ /*
+ * Save future stack-pointer, we must not switch until the
+ * copy is done, otherwise the NMI handler could destroy the
+ * contents of the task-stack we are about to copy.
+ */
+ movl %edi, %ebx
+
+ /* Do the copy */
+ shrl $2, %ecx
+ cld
+ rep movsl
+
+ /* Safe to switch to entry-stack now */
+ movl %ebx, %esp
+
+.Lend_\@:
+.endm
/*
* %eax: prev task
* %edx: next task
@@ -765,6 +872,7 @@ restore_all:
restore_all_kernel:
TRACE_IRQS_IRET
+ PARANOID_EXIT_TO_KERNEL_MODE
RESTORE_REGS 4
jmp .Lirq_return
--
2.16.2
@@ -0,0 +1,69 @@
From 8743506d5153928d0a0fb4106470a6581d03796d Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Thu, 1 Mar 2018 14:48:16 +0100
Subject: [PATCH 12/34] x86/entry/32: Simplify debug entry point
The common exception entry code now handles the
entry-from-sysenter stack situation and makes sure to leave
with the same stack as it entered the kernel.
So there is no need anymore for the special handling in the
debug entry code.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/entry/entry_32.S | 35 +++--------------------------------
1 file changed, 3 insertions(+), 32 deletions(-)
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 3a84945fa3b6..b1a5f34eeb27 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -1215,41 +1215,12 @@ END(common_exception)
ENTRY(debug)
/*
- * #DB can happen at the first instruction of
- * entry_SYSENTER_32 or in Xen's SYSENTER prologue. If this
- * happens, then we will be running on a very small stack. We
- * need to detect this condition and switch to the thread
- * stack before calling any C code at all.
- *
- * If you edit this code, keep in mind that NMIs can happen in here.
+ * Entry from sysenter is now handled in common_exception
*/
ASM_CLAC
pushl $-1 # mark this as an int
-
- SAVE_ALL
- ENCODE_FRAME_POINTER
- xorl %edx, %edx # error code 0
- movl %esp, %eax # pt_regs pointer
-
- /* Are we currently on the SYSENTER stack? */
- movl PER_CPU_VAR(cpu_entry_area), %ecx
- addl $CPU_ENTRY_AREA_entry_stack + SIZEOF_entry_stack, %ecx
- subl %eax, %ecx /* ecx = (end of entry_stack) - esp */
- cmpl $SIZEOF_entry_stack, %ecx
- jb .Ldebug_from_sysenter_stack
-
- TRACE_IRQS_OFF
- call do_debug
- jmp ret_from_exception
-
-.Ldebug_from_sysenter_stack:
- /* We're on the SYSENTER stack. Switch off. */
- movl %esp, %ebx
- movl PER_CPU_VAR(cpu_current_top_of_stack), %esp
- TRACE_IRQS_OFF
- call do_debug
- movl %ebx, %esp
- jmp ret_from_exception
+ pushl $do_debug
+ jmp common_exception
END(debug)
/*
--
2.16.2
@@ -0,0 +1,127 @@
From 41bc2c77864b5464134c3ec722225a9ae4701968 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 31 Jan 2018 16:58:57 +0100
Subject: [PATCH 13/34] x86/entry/32: Add PTI cr3 switches to NMI handler code
The NMI handler is special, as it needs to leave with the
same cr3 as it was entered with. We need to do this because
we could enter the NMI handler from kernel code with
user-cr3 already loaded.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/entry/entry_32.S | 52 +++++++++++++++++++++++++++++++++++++++++------
1 file changed, 46 insertions(+), 6 deletions(-)
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index b1a5f34eeb27..35379e5f60c6 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -77,6 +77,8 @@
#endif
.endm
+#define PTI_SWITCH_MASK (1 << PAGE_SHIFT)
+
/*
* User gs save/restore
*
@@ -167,8 +169,30 @@
.endm
-.macro SAVE_ALL_NMI
+.macro SAVE_ALL_NMI cr3_reg:req
SAVE_ALL
+
+ /*
+ * Now switch the CR3 when PTI is enabled.
+ *
+ * We can enter with either user or kernel cr3, the code will
+ * store the old cr3 in \cr3_reg and switches to the kernel cr3
+ * if necessary.
+ */
+ ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_PTI
+
+ movl %cr3, \cr3_reg
+ testl $PTI_SWITCH_MASK, \cr3_reg
+ jz .Lend_\@ /* Already on kernel cr3 */
+
+ /* On user cr3 - write new kernel cr3 */
+ andl $(~PTI_SWITCH_MASK), \cr3_reg
+ movl \cr3_reg, %cr3
+
+ /* Restore user cr3 value */
+ orl $PTI_SWITCH_MASK, \cr3_reg
+
+.Lend_\@:
.endm
/*
* This is a sneaky trick to help the unwinder find pt_regs on the stack. The
@@ -227,13 +251,29 @@
RESTORE_SKIP_SEGMENTS \pop
.endm
-.macro RESTORE_ALL_NMI pop=0
+.macro RESTORE_ALL_NMI cr3_reg:req pop=0
/*
* Restore segments - might cause exceptions when loading
* user-space segments
*/
RESTORE_SEGMENTS
+ /*
+ * Now switch the CR3 when PTI is enabled.
+ *
+ * We enter with kernel cr3 and switch the cr3 to the value
+ * stored on \cr3_reg, which is either a user or a kernel cr3.
+ */
+ ALTERNATIVE "jmp .Lswitched_\@", "", X86_FEATURE_PTI
+
+ testl $PTI_SWITCH_MASK, \cr3_reg
+ jz .Lswitched_\@
+
+ /* User cr3 in \cr3_reg - write it to hardware cr3 */
+ movl \cr3_reg, %cr3
+
+.Lswitched_\@:
+
/* Restore integer registers and unwind stack to iret frame */
RESTORE_INT_REGS
RESTORE_SKIP_SEGMENTS \pop
@@ -1242,7 +1282,7 @@ ENTRY(nmi)
#endif
pushl %eax # pt_regs->orig_ax
- SAVE_ALL_NMI
+ SAVE_ALL_NMI cr3_reg=%edi
ENCODE_FRAME_POINTER
xorl %edx, %edx # zero error code
movl %esp, %eax # pt_regs pointer
@@ -1270,7 +1310,7 @@ ENTRY(nmi)
.Lnmi_return:
CHECK_AND_APPLY_ESPFIX
- RESTORE_ALL_NMI pop=4
+ RESTORE_ALL_NMI cr3_reg=%edi pop=4
jmp .Lirq_return
#ifdef CONFIG_X86_ESPFIX32
@@ -1286,12 +1326,12 @@ ENTRY(nmi)
pushl 16(%esp)
.endr
pushl %eax
- SAVE_ALL_NMI
+ SAVE_ALL_NMI cr3_reg=%edi
ENCODE_FRAME_POINTER
FIXUP_ESPFIX_STACK # %eax == %esp
xorl %edx, %edx # zero error code
call do_nmi
- RESTORE_ALL_NMI
+ RESTORE_ALL_NMI cr3_reg=%edi
lss 12+4(%esp), %esp # back to espfix stack
jmp .Lirq_return
#endif
--
2.16.2
@@ -0,0 +1,187 @@
From d40791fdb56c15767c7c65a1a2e0c8736f3db0af Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 31 Jan 2018 17:22:10 +0100
Subject: [PATCH 14/34] x86/entry/32: Add PTI cr3 switch to non-NMI entry/exit
points
Add unconditional cr3 switches between user and kernel cr3
to all non-NMI entry and exit points.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/entry/entry_32.S | 91 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 88 insertions(+), 3 deletions(-)
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index 35379e5f60c6..8f78abcf1f9c 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -328,6 +328,30 @@
#endif /* CONFIG_X86_ESPFIX32 */
.endm
+/* Unconditionally switch to user cr3 */
+.macro SWITCH_TO_USER_CR3 scratch_reg:req
+ ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_PTI
+
+ movl %cr3, \scratch_reg
+ orl $PTI_SWITCH_MASK, \scratch_reg
+ movl \scratch_reg, %cr3
+.Lend_\@:
+.endm
+
+/* Unconditionally switch to kernel cr3 */
+.macro SWITCH_TO_KERNEL_CR3 scratch_reg:req
+ ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_PTI
+ movl %cr3, \scratch_reg
+ /* Test if we are already on kernel CR3 */
+ testl $PTI_SWITCH_MASK, \scratch_reg
+ jz .Lend_\@
+ andl $(~PTI_SWITCH_MASK), \scratch_reg
+ movl \scratch_reg, %cr3
+ /* Return original CR3 in \scratch_reg */
+ orl $PTI_SWITCH_MASK, \scratch_reg
+.Lend_\@:
+.endm
+
/*
* Called with pt_regs fully populated and kernel segments loaded,
@@ -341,11 +365,19 @@
*/
#define CS_FROM_ENTRY_STACK (1 << 31)
+#define CS_FROM_USER_CR3 (1 << 30)
.macro SWITCH_TO_KERNEL_STACK
ALTERNATIVE "", "jmp .Lend_\@", X86_FEATURE_XENPV
+ SWITCH_TO_KERNEL_CR3 scratch_reg=%eax
+
+ /*
+ * %eax now contains the entry cr3 and we carry it forward in
+ * that register for the time this macro runs
+ */
+
/* Are we on the entry stack? Bail out if not! */
movl PER_CPU_VAR(cpu_entry_area), %edi
addl $CPU_ENTRY_AREA_entry_stack, %edi
@@ -408,7 +440,8 @@
* but switch back to the entry-stack again when we approach
* iret and return to the interrupted code-path. This usually
* happens when we hit an exception while restoring user-space
- * segment registers on the way back to user-space.
+ * segment registers on the way back to user-space or when the
+ * sysenter handler runs with eflags.tf set.
*
* When we switch to the task-stack here, we can't trust the
* contents of the entry-stack anymore, as the exception handler
@@ -425,6 +458,7 @@
*
* %esi: Entry-Stack pointer (same as %esp)
* %edi: Top of the task stack
+ * %eax: CR3 on kernel entry
*/
/* Calculate number of bytes on the entry stack in %ecx */
@@ -440,6 +474,14 @@
/* Mark stackframe as coming from entry stack */
orl $CS_FROM_ENTRY_STACK, PT_CS(%esp)
+ /*
+ * Test the cr3 used to enter the kernel and add a marker
+ * so that we can switch back to it before iret.
+ */
+ testl $PTI_SWITCH_MASK, %eax
+ jz .Lcopy_pt_regs_\@
+ orl $CS_FROM_USER_CR3, PT_CS(%esp)
+
/*
* %esi and %edi are unchanged, %ecx contains the number of
* bytes to copy. The code at .Lcopy_pt_regs_\@ will allocate
@@ -506,7 +548,7 @@
/*
* This macro handles the case when we return to kernel-mode on the iret
- * path and have to switch back to the entry stack.
+ * path and have to switch back to the entry stack and/or user-cr3
*
* See the comments below the .Lentry_from_kernel_\@ label in the
* SWITCH_TO_KERNEL_STACK macro for more details.
@@ -552,6 +594,18 @@
/* Safe to switch to entry-stack now */
movl %ebx, %esp
+ /*
+ * We came from entry-stack and need to check if we also need to
+ * switch back to user cr3.
+ */
+ testl $CS_FROM_USER_CR3, PT_CS(%esp)
+ jz .Lend_\@
+
+ /* Clear marker from stack-frame */
+ andl $(~CS_FROM_USER_CR3), PT_CS(%esp)
+
+ SWITCH_TO_USER_CR3 scratch_reg=%eax
+
.Lend_\@:
.endm
/*
@@ -746,6 +800,18 @@ ENTRY(xen_sysenter_target)
* 0(%ebp) arg6
*/
ENTRY(entry_SYSENTER_32)
+ /*
+ * On entry-stack with all userspace-regs live - save and
+ * restore eflags and %eax to use it as scratch-reg for the cr3
+ * switch.
+ */
+ pushfl
+ pushl %eax
+ SWITCH_TO_KERNEL_CR3 scratch_reg=%eax
+ popl %eax
+ popfl
+
+ /* Stack empty again, switch to task stack */
movl TSS_entry_stack(%esp), %esp
.Lsysenter_past_esp:
@@ -826,6 +892,9 @@ ENTRY(entry_SYSENTER_32)
/* Switch to entry stack */
movl %eax, %esp
+ /* Now ready to switch the cr3 */
+ SWITCH_TO_USER_CR3 scratch_reg=%eax
+
/*
* Restore all flags except IF. (We restore IF separately because
* STI gives a one-instruction window in which we won't be interrupted,
@@ -906,7 +975,23 @@ restore_all:
.Lrestore_all_notrace:
CHECK_AND_APPLY_ESPFIX
.Lrestore_nocheck:
- RESTORE_REGS 4 # skip orig_eax/error_code
+ /*
+ * First restore user segments. This can cause exceptions, so we
+ * run it with kernel cr3.
+ */
+ RESTORE_SEGMENTS
+
+ /*
+ * Segments are restored - no more exceptions from here on except on
+ * iret, but that handled safely.
+ */
+ SWITCH_TO_USER_CR3 scratch_reg=%eax
+
+ /* Restore rest */
+ RESTORE_INT_REGS
+
+ /* Unwind stack to the iret frame */
+ RESTORE_SKIP_SEGMENTS 4 # skip orig_eax/error_code
.Lirq_return:
INTERRUPT_RETURN
--
2.16.2
@@ -0,0 +1,81 @@
From 55797d951b45c9eb709a4e7483eef89d738c2427 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Thu, 1 Mar 2018 13:40:39 +0100
Subject: [PATCH 15/34] x86/pgtable: Rename pti_set_user_pgd to
pti_set_user_pgtbl
With the way page-table folding is implemented on 32 bit, we
are not only setting PGDs with this functions, but also PUDs
and even PMDs. Give the function a more generic name to
reflect that.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/pgtable_64.h | 12 ++++++------
arch/x86/mm/pti.c | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 81462e9a34f6..b68bda56db67 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -195,21 +195,21 @@ static inline bool pgdp_maps_userspace(void *__ptr)
}
#ifdef CONFIG_PAGE_TABLE_ISOLATION
-pgd_t __pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd);
+pgd_t __pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd);
/*
* Take a PGD location (pgdp) and a pgd value that needs to be set there.
* Populates the user and returns the resulting PGD that must be set in
* the kernel copy of the page tables.
*/
-static inline pgd_t pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd)
+static inline pgd_t pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd)
{
if (!static_cpu_has(X86_FEATURE_PTI))
return pgd;
- return __pti_set_user_pgd(pgdp, pgd);
+ return __pti_set_user_pgtbl(pgdp, pgd);
}
#else
-static inline pgd_t pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd)
+static inline pgd_t pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd)
{
return pgd;
}
@@ -218,7 +218,7 @@ static inline pgd_t pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd)
static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
{
#if defined(CONFIG_PAGE_TABLE_ISOLATION) && !defined(CONFIG_X86_5LEVEL)
- p4dp->pgd = pti_set_user_pgd(&p4dp->pgd, p4d.pgd);
+ p4dp->pgd = pti_set_user_pgtbl(&p4dp->pgd, p4d.pgd);
#else
*p4dp = p4d;
#endif
@@ -236,7 +236,7 @@ static inline void native_p4d_clear(p4d_t *p4d)
static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
{
#ifdef CONFIG_PAGE_TABLE_ISOLATION
- *pgdp = pti_set_user_pgd(pgdp, pgd);
+ *pgdp = pti_set_user_pgtbl(pgdp, pgd);
#else
*pgdp = pgd;
#endif
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index ce38f165489b..8f53d2101f64 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -102,7 +102,7 @@ void __init pti_check_boottime_disable(void)
setup_force_cpu_cap(X86_FEATURE_PTI);
}
-pgd_t __pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd)
+pgd_t __pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd)
{
/*
* Changes to the high (kernel) portion of the kernelmode page
--
2.16.2
@@ -0,0 +1,35 @@
From 5439accd9f31dacdfbf67a18440d5805e8a0bfad Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Fri, 2 Feb 2018 10:41:36 +0100
Subject: [PATCH 16/34] x86/pgtable/pae: Unshare kernel PMDs when PTI is
enabled
With PTI we need to map the per-process LDT into the kernel
address-space for each process, so we need separate kernel
PMDs per PGD.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/pgtable-3level_types.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/pgtable-3level_types.h b/arch/x86/include/asm/pgtable-3level_types.h
index 876b4c77d983..ed8a200ecdaf 100644
--- a/arch/x86/include/asm/pgtable-3level_types.h
+++ b/arch/x86/include/asm/pgtable-3level_types.h
@@ -21,9 +21,10 @@ typedef union {
#endif /* !__ASSEMBLY__ */
#ifdef CONFIG_PARAVIRT
-#define SHARED_KERNEL_PMD (pv_info.shared_kernel_pmd)
+#define SHARED_KERNEL_PMD ((!static_cpu_has(X86_FEATURE_PTI) && \
+ (pv_info.shared_kernel_pmd)))
#else
-#define SHARED_KERNEL_PMD 1
+#define SHARED_KERNEL_PMD (!static_cpu_has(X86_FEATURE_PTI))
#endif
/*
--
2.16.2
@@ -0,0 +1,98 @@
From 35cdf0541e9d5c7a47b59530fc8a42ac9ab767f8 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 13:10:57 +0100
Subject: [PATCH 17/34] x86/pgtable/32: Allocate 8k page-tables when PTI is
enabled
Allocate a kernel and a user page-table root when PTI is
enabled. Also allocate a full page per root for PAE because
otherwise the bit to flip in cr3 to switch between them
would be non-constant, which creates a lot of hassle.
Keep that for a later optimization.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/kernel/head_32.S | 20 +++++++++++++++-----
arch/x86/mm/pgtable.c | 5 +++--
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index c29020907886..1f35d600b69f 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -512,11 +512,18 @@ ENTRY(initial_code)
ENTRY(setup_once_ref)
.long setup_once
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+#define PGD_ALIGN (2 * PAGE_SIZE)
+#define PTI_USER_PGD_FILL 1024
+#else
+#define PGD_ALIGN (PAGE_SIZE)
+#define PTI_USER_PGD_FILL 0
+#endif
/*
* BSS section
*/
__PAGE_ALIGNED_BSS
- .align PAGE_SIZE
+ .align PGD_ALIGN
#ifdef CONFIG_X86_PAE
.globl initial_pg_pmd
initial_pg_pmd:
@@ -526,14 +533,17 @@ initial_pg_pmd:
initial_page_table:
.fill 1024,4,0
#endif
+ .align PGD_ALIGN
initial_pg_fixmap:
.fill 1024,4,0
-.globl empty_zero_page
-empty_zero_page:
- .fill 4096,1,0
.globl swapper_pg_dir
+ .align PGD_ALIGN
swapper_pg_dir:
.fill 1024,4,0
+ .fill PTI_USER_PGD_FILL,4,0
+.globl empty_zero_page
+empty_zero_page:
+ .fill 4096,1,0
EXPORT_SYMBOL(empty_zero_page)
/*
@@ -542,7 +552,7 @@ EXPORT_SYMBOL(empty_zero_page)
#ifdef CONFIG_X86_PAE
__PAGE_ALIGNED_DATA
/* Page-aligned for the benefit of paravirt? */
- .align PAGE_SIZE
+ .align PGD_ALIGN
ENTRY(initial_page_table)
.long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
# if KPMDS == 3
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 004abf9ebf12..a81d42e48922 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -338,7 +338,8 @@ static inline pgd_t *_pgd_alloc(void)
* We allocate one page for pgd.
*/
if (!SHARED_KERNEL_PMD)
- return (pgd_t *)__get_free_page(PGALLOC_GFP);
+ return (pgd_t *)__get_free_pages(PGALLOC_GFP,
+ PGD_ALLOCATION_ORDER);
/*
* Now PAE kernel is not running as a Xen domain. We can allocate
@@ -350,7 +351,7 @@ static inline pgd_t *_pgd_alloc(void)
static inline void _pgd_free(pgd_t *pgd)
{
if (!SHARED_KERNEL_PMD)
- free_page((unsigned long)pgd);
+ free_pages((unsigned long)pgd, PGD_ALLOCATION_ORDER);
else
kmem_cache_free(pgd_cache, pgd);
}
--
2.16.2
@@ -0,0 +1,137 @@
From 69dfcb6ee23f6841982e059f58cc9be921b669dc Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 11:53:38 +0100
Subject: [PATCH 18/34] x86/pgtable: Move pgdp kernel/user conversion functions
to pgtable.h
Make them available on 32 bit and clone_pgd_range() happy.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/pgtable.h | 49 +++++++++++++++++++++++++++++++++++++++
arch/x86/include/asm/pgtable_64.h | 49 ---------------------------------------
2 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index e42b8943cb1a..0a9f746cbdc1 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1109,6 +1109,55 @@ static inline int pud_write(pud_t pud)
return pud_flags(pud) & _PAGE_RW;
}
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+/*
+ * All top-level PAGE_TABLE_ISOLATION page tables are order-1 pages
+ * (8k-aligned and 8k in size). The kernel one is at the beginning 4k and
+ * the user one is in the last 4k. To switch between them, you
+ * just need to flip the 12th bit in their addresses.
+ */
+#define PTI_PGTABLE_SWITCH_BIT PAGE_SHIFT
+
+/*
+ * This generates better code than the inline assembly in
+ * __set_bit().
+ */
+static inline void *ptr_set_bit(void *ptr, int bit)
+{
+ unsigned long __ptr = (unsigned long)ptr;
+
+ __ptr |= BIT(bit);
+ return (void *)__ptr;
+}
+static inline void *ptr_clear_bit(void *ptr, int bit)
+{
+ unsigned long __ptr = (unsigned long)ptr;
+
+ __ptr &= ~BIT(bit);
+ return (void *)__ptr;
+}
+
+static inline pgd_t *kernel_to_user_pgdp(pgd_t *pgdp)
+{
+ return ptr_set_bit(pgdp, PTI_PGTABLE_SWITCH_BIT);
+}
+
+static inline pgd_t *user_to_kernel_pgdp(pgd_t *pgdp)
+{
+ return ptr_clear_bit(pgdp, PTI_PGTABLE_SWITCH_BIT);
+}
+
+static inline p4d_t *kernel_to_user_p4dp(p4d_t *p4dp)
+{
+ return ptr_set_bit(p4dp, PTI_PGTABLE_SWITCH_BIT);
+}
+
+static inline p4d_t *user_to_kernel_p4dp(p4d_t *p4dp)
+{
+ return ptr_clear_bit(p4dp, PTI_PGTABLE_SWITCH_BIT);
+}
+#endif /* CONFIG_PAGE_TABLE_ISOLATION */
+
/*
* clone_pgd_range(pgd_t *dst, pgd_t *src, int count);
*
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index b68bda56db67..5e680838761d 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -131,55 +131,6 @@ static inline pud_t native_pudp_get_and_clear(pud_t *xp)
#endif
}
-#ifdef CONFIG_PAGE_TABLE_ISOLATION
-/*
- * All top-level PAGE_TABLE_ISOLATION page tables are order-1 pages
- * (8k-aligned and 8k in size). The kernel one is at the beginning 4k and
- * the user one is in the last 4k. To switch between them, you
- * just need to flip the 12th bit in their addresses.
- */
-#define PTI_PGTABLE_SWITCH_BIT PAGE_SHIFT
-
-/*
- * This generates better code than the inline assembly in
- * __set_bit().
- */
-static inline void *ptr_set_bit(void *ptr, int bit)
-{
- unsigned long __ptr = (unsigned long)ptr;
-
- __ptr |= BIT(bit);
- return (void *)__ptr;
-}
-static inline void *ptr_clear_bit(void *ptr, int bit)
-{
- unsigned long __ptr = (unsigned long)ptr;
-
- __ptr &= ~BIT(bit);
- return (void *)__ptr;
-}
-
-static inline pgd_t *kernel_to_user_pgdp(pgd_t *pgdp)
-{
- return ptr_set_bit(pgdp, PTI_PGTABLE_SWITCH_BIT);
-}
-
-static inline pgd_t *user_to_kernel_pgdp(pgd_t *pgdp)
-{
- return ptr_clear_bit(pgdp, PTI_PGTABLE_SWITCH_BIT);
-}
-
-static inline p4d_t *kernel_to_user_p4dp(p4d_t *p4dp)
-{
- return ptr_set_bit(p4dp, PTI_PGTABLE_SWITCH_BIT);
-}
-
-static inline p4d_t *user_to_kernel_p4dp(p4d_t *p4dp)
-{
- return ptr_clear_bit(p4dp, PTI_PGTABLE_SWITCH_BIT);
-}
-#endif /* CONFIG_PAGE_TABLE_ISOLATION */
-
/*
* Page table pages are page-aligned. The lower half of the top
* level is used for userspace and the top half for the kernel.
--
2.16.2
@@ -0,0 +1,84 @@
From 88eb961770b7b265bf4725f0d687af8c9cf33467 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 15:50:39 +0100
Subject: [PATCH 19/34] x86/pgtable: Move pti_set_user_pgtbl() to pgtable.h
There it is also usable from 32 bit code.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/pgtable.h | 23 +++++++++++++++++++++++
arch/x86/include/asm/pgtable_64.h | 21 ---------------------
2 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 0a9f746cbdc1..1e900c1f8ab1 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -618,8 +618,31 @@ static inline int is_new_memtype_allowed(u64 paddr, unsigned long size,
pmd_t *populate_extra_pmd(unsigned long vaddr);
pte_t *populate_extra_pte(unsigned long vaddr);
+
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+pgd_t __pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd);
+
+/*
+ * Take a PGD location (pgdp) and a pgd value that needs to be set there.
+ * Populates the user and returns the resulting PGD that must be set in
+ * the kernel copy of the page tables.
+ */
+static inline pgd_t pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd)
+{
+ if (!static_cpu_has(X86_FEATURE_PTI))
+ return pgd;
+ return __pti_set_user_pgtbl(pgdp, pgd);
+}
+#else /* CONFIG_PAGE_TABLE_ISOLATION */
+static inline pgd_t pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd)
+{
+ return pgd;
+}
+#endif /* CONFIG_PAGE_TABLE_ISOLATION */
+
#endif /* __ASSEMBLY__ */
+
#ifdef CONFIG_X86_32
# include <asm/pgtable_32.h>
#else
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 5e680838761d..4cbf5173dd76 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -145,27 +145,6 @@ static inline bool pgdp_maps_userspace(void *__ptr)
return (ptr & ~PAGE_MASK) < (PAGE_SIZE / 2);
}
-#ifdef CONFIG_PAGE_TABLE_ISOLATION
-pgd_t __pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd);
-
-/*
- * Take a PGD location (pgdp) and a pgd value that needs to be set there.
- * Populates the user and returns the resulting PGD that must be set in
- * the kernel copy of the page tables.
- */
-static inline pgd_t pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd)
-{
- if (!static_cpu_has(X86_FEATURE_PTI))
- return pgd;
- return __pti_set_user_pgtbl(pgdp, pgd);
-}
-#else
-static inline pgd_t pti_set_user_pgtbl(pgd_t *pgdp, pgd_t pgd)
-{
- return pgd;
-}
-#endif
-
static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
{
#if defined(CONFIG_PAGE_TABLE_ISOLATION) && !defined(CONFIG_X86_5LEVEL)
--
2.16.2
@@ -0,0 +1,120 @@
From 2bcb4034a5d3e49213d4b7e72187b106a50d53f3 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 12:48:14 +0100
Subject: [PATCH 20/34] x86/pgtable: Move two more functions from pgtable_64.h
to pgtable.h
These two functions are required for PTI on 32 bit:
* pgdp_maps_userspace()
* pgd_large()
Also re-implement pgdp_maps_userspace() so that it will work
on 64 and 32 bit kernels.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/pgtable-2level_types.h | 3 +++
arch/x86/include/asm/pgtable-3level_types.h | 1 +
arch/x86/include/asm/pgtable.h | 16 ++++++++++++++++
arch/x86/include/asm/pgtable_64.h | 15 ---------------
arch/x86/include/asm/pgtable_64_types.h | 2 ++
5 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/arch/x86/include/asm/pgtable-2level_types.h b/arch/x86/include/asm/pgtable-2level_types.h
index f982ef808e7e..6deb6cd236e3 100644
--- a/arch/x86/include/asm/pgtable-2level_types.h
+++ b/arch/x86/include/asm/pgtable-2level_types.h
@@ -35,4 +35,7 @@ typedef union {
#define PTRS_PER_PTE 1024
+/* This covers all VMSPLIT_* and VMSPLIT_*_OPT variants */
+#define PGD_KERNEL_START (CONFIG_PAGE_OFFSET >> PGDIR_SHIFT)
+
#endif /* _ASM_X86_PGTABLE_2LEVEL_DEFS_H */
diff --git a/arch/x86/include/asm/pgtable-3level_types.h b/arch/x86/include/asm/pgtable-3level_types.h
index ed8a200ecdaf..925ac1bc45cb 100644
--- a/arch/x86/include/asm/pgtable-3level_types.h
+++ b/arch/x86/include/asm/pgtable-3level_types.h
@@ -45,5 +45,6 @@ typedef union {
*/
#define PTRS_PER_PTE 512
+#define PGD_KERNEL_START (CONFIG_PAGE_OFFSET >> PGDIR_SHIFT)
#endif /* _ASM_X86_PGTABLE_3LEVEL_DEFS_H */
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 1e900c1f8ab1..981e49a8cdb2 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1132,6 +1132,22 @@ static inline int pud_write(pud_t pud)
return pud_flags(pud) & _PAGE_RW;
}
+/*
+ * Page table pages are page-aligned. The lower half of the top
+ * level is used for userspace and the top half for the kernel.
+ *
+ * Returns true for parts of the PGD that map userspace and
+ * false for the parts that map the kernel.
+ */
+static inline bool pgdp_maps_userspace(void *__ptr)
+{
+ unsigned long ptr = (unsigned long)__ptr;
+
+ return (((ptr & ~PAGE_MASK) / sizeof(pgd_t)) < PGD_KERNEL_START);
+}
+
+static inline int pgd_large(pgd_t pgd) { return 0; }
+
#ifdef CONFIG_PAGE_TABLE_ISOLATION
/*
* All top-level PAGE_TABLE_ISOLATION page tables are order-1 pages
diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 4cbf5173dd76..e11b92585de4 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -131,20 +131,6 @@ static inline pud_t native_pudp_get_and_clear(pud_t *xp)
#endif
}
-/*
- * Page table pages are page-aligned. The lower half of the top
- * level is used for userspace and the top half for the kernel.
- *
- * Returns true for parts of the PGD that map userspace and
- * false for the parts that map the kernel.
- */
-static inline bool pgdp_maps_userspace(void *__ptr)
-{
- unsigned long ptr = (unsigned long)__ptr;
-
- return (ptr & ~PAGE_MASK) < (PAGE_SIZE / 2);
-}
-
static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
{
#if defined(CONFIG_PAGE_TABLE_ISOLATION) && !defined(CONFIG_X86_5LEVEL)
@@ -187,7 +173,6 @@ extern void sync_global_pgds(unsigned long start, unsigned long end);
/*
* Level 4 access.
*/
-static inline int pgd_large(pgd_t pgd) { return 0; }
#define mk_kernel_pgd(address) __pgd((address) | _KERNPG_TABLE)
/* PUD - Level3 access */
diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
index 6b8f73dcbc2c..e57003a3f58a 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -124,4 +124,6 @@ typedef struct { pteval_t pte; } pte_t;
#define EARLY_DYNAMIC_PAGE_TABLES 64
+#define PGD_KERNEL_START ((PAGE_SIZE / 2) / sizeof(pgd_t))
+
#endif /* _ASM_X86_PGTABLE_64_DEFS_H */
--
2.16.2
@@ -0,0 +1,73 @@
From 85228cdba0d4634d6a1a162be0d755bd8ed3bdfa Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 15:28:57 +0100
Subject: [PATCH 21/34] x86/mm/pae: Populate valid user PGD entries
Generic page-table code populates all non-leaf entries with
_KERNPG_TABLE bits set. This is fine for all paging modes
except PAE.
In PAE mode only a subset of the bits is allowed to be set.
Make sure we only set allowed bits by masking out the
reserved bits.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/pgtable_types.h | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index 3696398a9475..48fc70b2d044 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -50,6 +50,7 @@
#define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
#define _PAGE_SOFTW1 (_AT(pteval_t, 1) << _PAGE_BIT_SOFTW1)
#define _PAGE_SOFTW2 (_AT(pteval_t, 1) << _PAGE_BIT_SOFTW2)
+#define _PAGE_SOFTW3 (_AT(pteval_t, 1) << _PAGE_BIT_SOFTW3)
#define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
#define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
#define _PAGE_SPECIAL (_AT(pteval_t, 1) << _PAGE_BIT_SPECIAL)
@@ -267,14 +268,37 @@ typedef struct pgprot { pgprotval_t pgprot; } pgprot_t;
typedef struct { pgdval_t pgd; } pgd_t;
+#ifdef CONFIG_X86_PAE
+
+/*
+ * PHYSICAL_PAGE_MASK might be non-constant when SME is compiled in, so we can't
+ * use it here.
+ */
+
+#define PGD_PAE_PAGE_MASK ((signed long)PAGE_MASK)
+#define PGD_PAE_PHYS_MASK (((1ULL << __PHYSICAL_MASK_SHIFT)-1) & PGD_PAE_PAGE_MASK)
+
+/*
+ * PAE allows Base Address, P, PWT, PCD and AVL bits to be set in PGD entries.
+ * All other bits are Reserved MBZ
+ */
+#define PGD_ALLOWED_BITS (PGD_PAE_PHYS_MASK | _PAGE_PRESENT | \
+ _PAGE_PWT | _PAGE_PCD | \
+ _PAGE_SOFTW1 | _PAGE_SOFTW2 | _PAGE_SOFTW3 )
+
+#else
+/* No need to mask any bits for !PAE */
+#define PGD_ALLOWED_BITS (~0ULL)
+#endif
+
static inline pgd_t native_make_pgd(pgdval_t val)
{
- return (pgd_t) { val };
+ return (pgd_t) { val & PGD_ALLOWED_BITS };
}
static inline pgdval_t native_pgd_val(pgd_t pgd)
{
- return pgd.pgd;
+ return pgd.pgd & PGD_ALLOWED_BITS;
}
static inline pgdval_t pgd_flags(pgd_t pgd)
--
2.16.2
@@ -0,0 +1,42 @@
From f05eb123abd9d8696ef340e62a37348381ff95fa Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 15:55:17 +0100
Subject: [PATCH 22/34] x86/mm/pae: Populate the user page-table with user
pgd's
When we populate a PGD entry, make sure we populate it in
the user page-table too.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/pgtable-3level.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
index bc4af5453802..ab2aa4468293 100644
--- a/arch/x86/include/asm/pgtable-3level.h
+++ b/arch/x86/include/asm/pgtable-3level.h
@@ -98,6 +98,9 @@ static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
static inline void native_set_pud(pud_t *pudp, pud_t pud)
{
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+ pud.p4d.pgd = pti_set_user_pgtbl(&pudp->p4d.pgd, pud.p4d.pgd);
+#endif
set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
}
@@ -194,6 +197,10 @@ static inline pud_t native_pudp_get_and_clear(pud_t *pudp)
{
union split_pud res, *orig = (union split_pud *)pudp;
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+ pti_set_user_pgtbl(&pudp->p4d.pgd, __pgd(0));
+#endif
+
/* xchg acts as a barrier before setting of the high bits */
res.pud_low = xchg(&orig->pud_low, 0);
res.pud_high = orig->pud_high;
--
2.16.2
@@ -0,0 +1,50 @@
From 08a22d9c7b62e9c9e08eaf9508f3ef881768a636 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 16:29:13 +0100
Subject: [PATCH 23/34] x86/mm/legacy: Populate the user page-table with user
pgd's
Also populate the user-spage pgd's in the user page-table.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/pgtable-2level.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
index 685ffe8a0eaf..c399ea5eea41 100644
--- a/arch/x86/include/asm/pgtable-2level.h
+++ b/arch/x86/include/asm/pgtable-2level.h
@@ -19,6 +19,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
{
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+ pmd.pud.p4d.pgd = pti_set_user_pgtbl(&pmdp->pud.p4d.pgd, pmd.pud.p4d.pgd);
+#endif
*pmdp = pmd;
}
@@ -58,6 +61,9 @@ static inline pte_t native_ptep_get_and_clear(pte_t *xp)
#ifdef CONFIG_SMP
static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
{
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+ pti_set_user_pgtbl(&xp->pud.p4d.pgd, __pgd(0));
+#endif
return __pmd(xchg((pmdval_t *)xp, 0));
}
#else
@@ -67,6 +73,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
#ifdef CONFIG_SMP
static inline pud_t native_pudp_get_and_clear(pud_t *xp)
{
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+ pti_set_user_pgtbl(&xp->p4d.pgd, __pgd(0));
+#endif
return __pud(xchg((pudval_t *)xp, 0));
}
#else
--
2.16.2
@@ -0,0 +1,33 @@
From 9fb9b9305a94eb64cd9bfc007d0457aa16a3429c Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 16:23:52 +0100
Subject: [PATCH 24/34] x86/mm/pti: Add an overflow check to pti_clone_pmds()
The addr counter will overflow if we clone the last PMD of
the address space, resulting in an endless loop.
Check for that and bail out of the loop when it happens.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/mm/pti.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 8f53d2101f64..96a690e6c9b1 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -282,6 +282,10 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
p4d_t *p4d;
pud_t *pud;
+ /* Overflow check */
+ if (addr < start)
+ break;
+
pgd = pgd_offset_k(addr);
if (WARN_ON(pgd_none(*pgd)))
return;
--
2.16.2
@@ -0,0 +1,41 @@
From b4c87612168011f7e95681027bf1de290da8d668 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 11:35:19 +0100
Subject: [PATCH 25/34] x86/mm/pti: Define X86_CR3_PTI_PCID_USER_BIT on x86_32
Move it out of the X86_64 specific processor defines so
that its visible for 32bit too.
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/processor-flags.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/processor-flags.h b/arch/x86/include/asm/processor-flags.h
index 625a52a5594f..02c2cbda4a74 100644
--- a/arch/x86/include/asm/processor-flags.h
+++ b/arch/x86/include/asm/processor-flags.h
@@ -39,10 +39,6 @@
#define CR3_PCID_MASK 0xFFFull
#define CR3_NOFLUSH BIT_ULL(63)
-#ifdef CONFIG_PAGE_TABLE_ISOLATION
-# define X86_CR3_PTI_PCID_USER_BIT 11
-#endif
-
#else
/*
* CR3_ADDR_MASK needs at least bits 31:5 set on PAE systems, and we save
@@ -53,4 +49,8 @@
#define CR3_NOFLUSH 0
#endif
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+# define X86_CR3_PTI_PCID_USER_BIT 11
+#endif
+
#endif /* _ASM_X86_PROCESSOR_FLAGS_H */
--
2.16.2
@@ -0,0 +1,56 @@
From c3b8f5b6bbb097409895ea8e00042034408cac54 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 14:13:04 +0100
Subject: [PATCH 26/34] x86/mm/pti: Clone CPU_ENTRY_AREA on PMD level on x86_32
Cloning on the P4D level would clone the complete kernel
address space into the user-space page-tables for PAE
kernels. Cloning on PMD level is fine for PAE and legacy
paging.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/mm/pti.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 96a690e6c9b1..3ffd92309aca 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -312,6 +312,7 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
}
}
+#ifdef CONFIG_X86_64
/*
* Clone a single p4d (i.e. a top-level entry on 4-level systems and a
* next-level entry on 5-level systems.
@@ -335,6 +336,25 @@ static void __init pti_clone_user_shared(void)
pti_clone_p4d(CPU_ENTRY_AREA_BASE);
}
+#else /* CONFIG_X86_64 */
+
+/*
+ * On 32 bit PAE systems with 1GB of Kernel address space there is only
+ * one pgd/p4d for the whole kernel. Cloning that would map the whole
+ * address space into the user page-tables, making PTI useless. So clone
+ * the page-table on the PMD level to prevent that.
+ */
+static void __init pti_clone_user_shared(void)
+{
+ unsigned long start, end;
+
+ start = CPU_ENTRY_AREA_BASE;
+ end = start + (PAGE_SIZE * CPU_ENTRY_AREA_PAGES);
+
+ pti_clone_pmds(start, end, _PAGE_GLOBAL);
+}
+#endif /* CONFIG_X86_64 */
+
/*
* Clone the ESPFIX P4D into the user space visinble page table
*/
--
2.16.2
@@ -0,0 +1,61 @@
From 35f7b44b3ce2d5b4c4fe2fabb8905bfff44559d4 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Thu, 8 Feb 2018 09:11:57 +0100
Subject: [PATCH 27/34] x86/mm/dump_pagetables: Define INIT_PGD
Define INIT_PGD to point to the correct initial page-table
for 32 and 64 bit and use it where needed. This fixes the
build on 32 bit with CONFIG_PAGE_TABLE_ISOLATION enabled.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/mm/dump_pagetables.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 2a4849e92831..2151ebb6a282 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -105,6 +105,8 @@ static struct addr_marker address_markers[] = {
[END_OF_SPACE_NR] = { -1, NULL }
};
+#define INIT_PGD ((pgd_t *) &init_top_pgt)
+
#else /* CONFIG_X86_64 */
enum address_markers_idx {
@@ -133,6 +135,8 @@ static struct addr_marker address_markers[] = {
[END_OF_SPACE_NR] = { -1, NULL }
};
+#define INIT_PGD (swapper_pg_dir)
+
#endif /* !CONFIG_X86_64 */
/* Multipliers for offsets within the PTEs */
@@ -478,11 +482,7 @@ static inline bool is_hypervisor_range(int idx)
static void ptdump_walk_pgd_level_core(struct seq_file *m, pgd_t *pgd,
bool checkwx, bool dmesg)
{
-#ifdef CONFIG_X86_64
- pgd_t *start = (pgd_t *) &init_top_pgt;
-#else
- pgd_t *start = swapper_pg_dir;
-#endif
+ pgd_t *start = INIT_PGD;
pgprotval_t prot;
int i;
struct pg_state st = {};
@@ -543,7 +543,7 @@ EXPORT_SYMBOL_GPL(ptdump_walk_pgd_level_debugfs);
static void ptdump_walk_user_pgd_level_checkwx(void)
{
#ifdef CONFIG_PAGE_TABLE_ISOLATION
- pgd_t *pgd = (pgd_t *) &init_top_pgt;
+ pgd_t *pgd = INIT_PGD;
if (!static_cpu_has(X86_FEATURE_PTI))
return;
--
2.16.2
@@ -0,0 +1,213 @@
From c15cbcd9bc3d2e8aaecffc5053dbcf382fe6e56d Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 7 Feb 2018 15:37:52 +0100
Subject: [PATCH 28/34] x86/pgtable/pae: Use separate kernel PMDs for user
page-table
We need separate kernel PMDs in the user page-table when PTI
is enabled to map the per-process LDT for user-space.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/mm/pgtable.c | 100 ++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 81 insertions(+), 19 deletions(-)
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index a81d42e48922..d95bc7b1ffb4 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -177,6 +177,14 @@ static void pgd_dtor(pgd_t *pgd)
*/
#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
+/*
+ * We allocate separate PMDs for the kernel part of the user page-table
+ * when PTI is enabled. We need them to map the per-process LDT into the
+ * user-space page-table.
+ */
+#define PREALLOCATED_USER_PMDS (static_cpu_has(X86_FEATURE_PTI) ? \
+ KERNEL_PGD_PTRS : 0)
+
void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
{
paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
@@ -197,14 +205,14 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
/* No need to prepopulate any pagetable entries in non-PAE modes. */
#define PREALLOCATED_PMDS 0
-
+#define PREALLOCATED_USER_PMDS 0
#endif /* CONFIG_X86_PAE */
-static void free_pmds(struct mm_struct *mm, pmd_t *pmds[])
+static void free_pmds(struct mm_struct *mm, pmd_t *pmds[], int count)
{
int i;
- for(i = 0; i < PREALLOCATED_PMDS; i++)
+ for(i = 0; i < count; i++)
if (pmds[i]) {
pgtable_pmd_page_dtor(virt_to_page(pmds[i]));
free_page((unsigned long)pmds[i]);
@@ -212,7 +220,7 @@ static void free_pmds(struct mm_struct *mm, pmd_t *pmds[])
}
}
-static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
+static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[], int count)
{
int i;
bool failed = false;
@@ -221,7 +229,7 @@ static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
if (mm == &init_mm)
gfp &= ~__GFP_ACCOUNT;
- for(i = 0; i < PREALLOCATED_PMDS; i++) {
+ for(i = 0; i < count; i++) {
pmd_t *pmd = (pmd_t *)__get_free_page(gfp);
if (!pmd)
failed = true;
@@ -236,7 +244,7 @@ static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
}
if (failed) {
- free_pmds(mm, pmds);
+ free_pmds(mm, pmds, count);
return -ENOMEM;
}
@@ -249,23 +257,38 @@ static int preallocate_pmds(struct mm_struct *mm, pmd_t *pmds[])
* preallocate which never got a corresponding vma will need to be
* freed manually.
*/
+static void mop_up_one_pmd(struct mm_struct *mm, pgd_t *pgdp)
+{
+ pgd_t pgd = *pgdp;
+
+ if (pgd_val(pgd) != 0) {
+ pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
+
+ *pgdp = native_make_pgd(0);
+
+ paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
+ pmd_free(mm, pmd);
+ mm_dec_nr_pmds(mm);
+ }
+}
+
static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
{
int i;
- for(i = 0; i < PREALLOCATED_PMDS; i++) {
- pgd_t pgd = pgdp[i];
+ for(i = 0; i < PREALLOCATED_PMDS; i++)
+ mop_up_one_pmd(mm, &pgdp[i]);
- if (pgd_val(pgd) != 0) {
- pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
- pgdp[i] = native_make_pgd(0);
+ if (!static_cpu_has(X86_FEATURE_PTI))
+ return;
- paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
- pmd_free(mm, pmd);
- mm_dec_nr_pmds(mm);
- }
- }
+ pgdp = kernel_to_user_pgdp(pgdp);
+
+ for (i = 0; i < PREALLOCATED_USER_PMDS; i++)
+ mop_up_one_pmd(mm, &pgdp[i + KERNEL_PGD_BOUNDARY]);
+#endif
}
static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
@@ -291,6 +314,38 @@ static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
}
}
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+static void pgd_prepopulate_user_pmd(struct mm_struct *mm,
+ pgd_t *k_pgd, pmd_t *pmds[])
+{
+ pgd_t *s_pgd = kernel_to_user_pgdp(swapper_pg_dir);
+ pgd_t *u_pgd = kernel_to_user_pgdp(k_pgd);
+ p4d_t *u_p4d;
+ pud_t *u_pud;
+ int i;
+
+ u_p4d = p4d_offset(u_pgd, 0);
+ u_pud = pud_offset(u_p4d, 0);
+
+ s_pgd += KERNEL_PGD_BOUNDARY;
+ u_pud += KERNEL_PGD_BOUNDARY;
+
+ for (i = 0; i < PREALLOCATED_USER_PMDS; i++, u_pud++, s_pgd++) {
+ pmd_t *pmd = pmds[i];
+
+ memcpy(pmd, (pmd_t *)pgd_page_vaddr(*s_pgd),
+ sizeof(pmd_t) * PTRS_PER_PMD);
+
+ pud_populate(mm, u_pud, pmd);
+ }
+
+}
+#else
+static void pgd_prepopulate_user_pmd(struct mm_struct *mm,
+ pgd_t *k_pgd, pmd_t *pmds[])
+{
+}
+#endif
/*
* Xen paravirt assumes pgd table should be in one page. 64 bit kernel also
* assumes that pgd should be in one page.
@@ -371,6 +426,7 @@ static inline void _pgd_free(pgd_t *pgd)
pgd_t *pgd_alloc(struct mm_struct *mm)
{
pgd_t *pgd;
+ pmd_t *u_pmds[PREALLOCATED_USER_PMDS];
pmd_t *pmds[PREALLOCATED_PMDS];
pgd = _pgd_alloc();
@@ -380,12 +436,15 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
mm->pgd = pgd;
- if (preallocate_pmds(mm, pmds) != 0)
+ if (preallocate_pmds(mm, pmds, PREALLOCATED_PMDS) != 0)
goto out_free_pgd;
- if (paravirt_pgd_alloc(mm) != 0)
+ if (preallocate_pmds(mm, u_pmds, PREALLOCATED_USER_PMDS) != 0)
goto out_free_pmds;
+ if (paravirt_pgd_alloc(mm) != 0)
+ goto out_free_user_pmds;
+
/*
* Make sure that pre-populating the pmds is atomic with
* respect to anything walking the pgd_list, so that they
@@ -395,13 +454,16 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
pgd_ctor(mm, pgd);
pgd_prepopulate_pmd(mm, pgd, pmds);
+ pgd_prepopulate_user_pmd(mm, pgd, u_pmds);
spin_unlock(&pgd_lock);
return pgd;
+out_free_user_pmds:
+ free_pmds(mm, u_pmds, PREALLOCATED_USER_PMDS);
out_free_pmds:
- free_pmds(mm, pmds);
+ free_pmds(mm, pmds, PREALLOCATED_PMDS);
out_free_pgd:
_pgd_free(pgd);
out:
--
2.16.2
@@ -0,0 +1,75 @@
From dd247e8ec4d2eeefdcb6ad173f1eef8007f54101 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 12:40:07 +0100
Subject: [PATCH 29/34] x86/ldt: Reserve address-space range on 32 bit for the
LDT
Reserve 2MB/4MB of address-space for mapping the LDT to
user-space on 32 bit PTI kernels.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/pgtable_32_types.h | 7 +++++--
arch/x86/mm/dump_pagetables.c | 9 +++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
index 0777e18a1d23..eb2e97afb27d 100644
--- a/arch/x86/include/asm/pgtable_32_types.h
+++ b/arch/x86/include/asm/pgtable_32_types.h
@@ -48,13 +48,16 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
((FIXADDR_TOT_START - PAGE_SIZE * (CPU_ENTRY_AREA_PAGES + 1)) \
& PMD_MASK)
-#define PKMAP_BASE \
+#define LDT_BASE_ADDR \
((CPU_ENTRY_AREA_BASE - PAGE_SIZE) & PMD_MASK)
+#define PKMAP_BASE \
+ ((LDT_BASE_ADDR - PAGE_SIZE) & PMD_MASK)
+
#ifdef CONFIG_HIGHMEM
# define VMALLOC_END (PKMAP_BASE - 2 * PAGE_SIZE)
#else
-# define VMALLOC_END (CPU_ENTRY_AREA_BASE - 2 * PAGE_SIZE)
+# define VMALLOC_END (LDT_BASE_ADDR - 2 * PAGE_SIZE)
#endif
#define MODULES_VADDR VMALLOC_START
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 2151ebb6a282..fdefdf05739c 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -116,6 +116,9 @@ enum address_markers_idx {
VMALLOC_END_NR,
#ifdef CONFIG_HIGHMEM
PKMAP_BASE_NR,
+#endif
+#ifdef CONFIG_MODIFY_LDT_SYSCALL
+ LDT_NR,
#endif
CPU_ENTRY_AREA_NR,
FIXADDR_START_NR,
@@ -129,6 +132,9 @@ static struct addr_marker address_markers[] = {
[VMALLOC_END_NR] = { 0UL, "vmalloc() End" },
#ifdef CONFIG_HIGHMEM
[PKMAP_BASE_NR] = { 0UL, "Persistent kmap() Area" },
+#endif
+#ifdef CONFIG_MODIFY_LDT_SYSCALL
+ [LDT_NR] = { 0UL, "LDT remap" },
#endif
[CPU_ENTRY_AREA_NR] = { 0UL, "CPU entry area" },
[FIXADDR_START_NR] = { 0UL, "Fixmap area" },
@@ -579,6 +585,9 @@ static int __init pt_dump_init(void)
# endif
address_markers[FIXADDR_START_NR].start_address = FIXADDR_START;
address_markers[CPU_ENTRY_AREA_NR].start_address = CPU_ENTRY_AREA_BASE;
+# ifdef CONFIG_MODIFY_LDT_SYSCALL
+ address_markers[LDT_NR].start_address = LDT_BASE_ADDR;
+# endif
#endif
return 0;
}
--
2.16.2
@@ -0,0 +1,64 @@
From e00857066a9f75a64a00528d451be9899ec7328f Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 7 Feb 2018 17:44:44 +0100
Subject: [PATCH 30/34] x86/ldt: Define LDT_END_ADDR
It marks the end of the address-space range reserved for the
LDT. The LDT-code will use it when unmapping the LDT for
user-space.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/pgtable_32_types.h | 2 ++
arch/x86/include/asm/pgtable_64_types.h | 2 ++
arch/x86/kernel/ldt.c | 2 +-
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
index eb2e97afb27d..02bd445d1aee 100644
--- a/arch/x86/include/asm/pgtable_32_types.h
+++ b/arch/x86/include/asm/pgtable_32_types.h
@@ -51,6 +51,8 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
#define LDT_BASE_ADDR \
((CPU_ENTRY_AREA_BASE - PAGE_SIZE) & PMD_MASK)
+#define LDT_END_ADDR (LDT_BASE_ADDR + PMD_SIZE)
+
#define PKMAP_BASE \
((LDT_BASE_ADDR - PAGE_SIZE) & PMD_MASK)
diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
index e57003a3f58a..15188baa7762 100644
--- a/arch/x86/include/asm/pgtable_64_types.h
+++ b/arch/x86/include/asm/pgtable_64_types.h
@@ -90,12 +90,14 @@ typedef struct { pteval_t pte; } pte_t;
# define __VMEMMAP_BASE _AC(0xffd4000000000000, UL)
# define LDT_PGD_ENTRY _AC(-112, UL)
# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)
+#define LDT_END_ADDR (LDT_BASE_ADDR + PGDIR_SIZE)
#else
# define VMALLOC_SIZE_TB _AC(32, UL)
# define __VMALLOC_BASE _AC(0xffffc90000000000, UL)
# define __VMEMMAP_BASE _AC(0xffffea0000000000, UL)
# define LDT_PGD_ENTRY _AC(-3, UL)
# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT)
+#define LDT_END_ADDR (LDT_BASE_ADDR + PGDIR_SIZE)
#endif
#ifdef CONFIG_RANDOMIZE_MEMORY
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 26d713ecad34..f3c2fbf3c458 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -202,7 +202,7 @@ static void free_ldt_pgtables(struct mm_struct *mm)
#ifdef CONFIG_PAGE_TABLE_ISOLATION
struct mmu_gather tlb;
unsigned long start = LDT_BASE_ADDR;
- unsigned long end = start + (1UL << PGDIR_SHIFT);
+ unsigned long end = LDT_END_ADDR;
if (!static_cpu_has(X86_FEATURE_PTI))
return;
--
2.16.2
@@ -0,0 +1,146 @@
From 126ef631acff4fe06d76992f40e04237d7d57344 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 7 Feb 2018 18:02:18 +0100
Subject: [PATCH 31/34] x86/ldt: Split out sanity check in map_ldt_struct()
This splits out the mapping sanity check and the actual
mapping of the LDT to user-space from the map_ldt_struct()
function in a way so that it is re-usable for PAE paging.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/kernel/ldt.c | 82 ++++++++++++++++++++++++++++++++++++---------------
1 file changed, 58 insertions(+), 24 deletions(-)
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index f3c2fbf3c458..8ab7df99c868 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -100,6 +100,49 @@ static struct ldt_struct *alloc_ldt_struct(unsigned int num_entries)
return new_ldt;
}
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+
+static void do_sanity_check(struct mm_struct *mm,
+ bool had_kernel_mapping,
+ bool had_user_mapping)
+{
+ if (mm->context.ldt) {
+ /*
+ * We already had an LDT. The top-level entry should already
+ * have been allocated and synchronized with the usermode
+ * tables.
+ */
+ WARN_ON(!had_kernel_mapping);
+ if (static_cpu_has(X86_FEATURE_PTI))
+ WARN_ON(!had_user_mapping);
+ } else {
+ /*
+ * This is the first time we're mapping an LDT for this process.
+ * Sync the pgd to the usermode tables.
+ */
+ WARN_ON(had_kernel_mapping);
+ if (static_cpu_has(X86_FEATURE_PTI))
+ WARN_ON(had_user_mapping);
+ }
+}
+
+static void map_ldt_struct_to_user(struct mm_struct *mm)
+{
+ pgd_t *pgd = pgd_offset(mm, LDT_BASE_ADDR);
+
+ if (static_cpu_has(X86_FEATURE_PTI) && !mm->context.ldt)
+ set_pgd(kernel_to_user_pgdp(pgd), *pgd);
+}
+
+static void sanity_check_ldt_mapping(struct mm_struct *mm)
+{
+ pgd_t *pgd = pgd_offset(mm, LDT_BASE_ADDR);
+ bool had_kernel = (pgd->pgd != 0);
+ bool had_user = (kernel_to_user_pgdp(pgd)->pgd != 0);
+
+ do_sanity_check(mm, had_kernel, had_user);
+}
+
/*
* If PTI is enabled, this maps the LDT into the kernelmode and
* usermode tables for the given mm.
@@ -115,9 +158,8 @@ static struct ldt_struct *alloc_ldt_struct(unsigned int num_entries)
static int
map_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt, int slot)
{
-#ifdef CONFIG_PAGE_TABLE_ISOLATION
- bool is_vmalloc, had_top_level_entry;
unsigned long va;
+ bool is_vmalloc;
spinlock_t *ptl;
pgd_t *pgd;
int i;
@@ -131,13 +173,15 @@ map_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt, int slot)
*/
WARN_ON(ldt->slot != -1);
+ /* Check if the current mappings are sane */
+ sanity_check_ldt_mapping(mm);
+
/*
* Did we already have the top level entry allocated? We can't
* use pgd_none() for this because it doens't do anything on
* 4-level page table kernels.
*/
pgd = pgd_offset(mm, LDT_BASE_ADDR);
- had_top_level_entry = (pgd->pgd != 0);
is_vmalloc = is_vmalloc_addr(ldt->entries);
@@ -168,35 +212,25 @@ map_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt, int slot)
pte_unmap_unlock(ptep, ptl);
}
- if (mm->context.ldt) {
- /*
- * We already had an LDT. The top-level entry should already
- * have been allocated and synchronized with the usermode
- * tables.
- */
- WARN_ON(!had_top_level_entry);
- if (static_cpu_has(X86_FEATURE_PTI))
- WARN_ON(!kernel_to_user_pgdp(pgd)->pgd);
- } else {
- /*
- * This is the first time we're mapping an LDT for this process.
- * Sync the pgd to the usermode tables.
- */
- WARN_ON(had_top_level_entry);
- if (static_cpu_has(X86_FEATURE_PTI)) {
- WARN_ON(kernel_to_user_pgdp(pgd)->pgd);
- set_pgd(kernel_to_user_pgdp(pgd), *pgd);
- }
- }
+ /* Propagate LDT mapping to the user page-table */
+ map_ldt_struct_to_user(mm);
va = (unsigned long)ldt_slot_va(slot);
flush_tlb_mm_range(mm, va, va + LDT_SLOT_STRIDE, 0);
ldt->slot = slot;
-#endif
return 0;
}
+#else /* !CONFIG_PAGE_TABLE_ISOLATION */
+
+static int
+map_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt, int slot)
+{
+ return 0;
+}
+#endif /* CONFIG_PAGE_TABLE_ISOLATION */
+
static void free_ldt_pgtables(struct mm_struct *mm)
{
#ifdef CONFIG_PAGE_TABLE_ISOLATION
--
2.16.2
@@ -0,0 +1,107 @@
From 1d4ac3c5063abdada00ad78e0ccf74c7de4b365d Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Wed, 7 Feb 2018 18:11:54 +0100
Subject: [PATCH 32/34] x86/ldt: Enable LDT user-mapping for PAE
This adds the needed special case for PAE to get the LDT
mapped into the user page-table when PTI is enabled. The big
difference to the other paging modes is that we don't have a
full top-level PGD entry available for the LDT, but only PMD
entry.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/include/asm/mmu_context.h | 4 ---
arch/x86/kernel/ldt.c | 53 ++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
index c931b88982a0..af96cfb2ab13 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -70,11 +70,7 @@ struct ldt_struct {
static inline void *ldt_slot_va(int slot)
{
-#ifdef CONFIG_X86_64
return (void *)(LDT_BASE_ADDR + LDT_SLOT_STRIDE * slot);
-#else
- BUG();
-#endif
}
/*
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 8ab7df99c868..778745199d96 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -126,6 +126,57 @@ static void do_sanity_check(struct mm_struct *mm,
}
}
+#ifdef CONFIG_X86_PAE
+
+static pmd_t *pgd_to_pmd_walk(pgd_t *pgd, unsigned long va)
+{
+ p4d_t *p4d;
+ pud_t *pud;
+
+ if (pgd->pgd == 0)
+ return NULL;
+
+ p4d = p4d_offset(pgd, va);
+ if (p4d_none(*p4d))
+ return NULL;
+
+ pud = pud_offset(p4d, va);
+ if (pud_none(*pud))
+ return NULL;
+
+ return pmd_offset(pud, va);
+}
+
+static void map_ldt_struct_to_user(struct mm_struct *mm)
+{
+ pgd_t *k_pgd = pgd_offset(mm, LDT_BASE_ADDR);
+ pgd_t *u_pgd = kernel_to_user_pgdp(k_pgd);
+ pmd_t *k_pmd, *u_pmd;
+
+ k_pmd = pgd_to_pmd_walk(k_pgd, LDT_BASE_ADDR);
+ u_pmd = pgd_to_pmd_walk(u_pgd, LDT_BASE_ADDR);
+
+ if (static_cpu_has(X86_FEATURE_PTI) && !mm->context.ldt)
+ set_pmd(u_pmd, *k_pmd);
+}
+
+static void sanity_check_ldt_mapping(struct mm_struct *mm)
+{
+ pgd_t *k_pgd = pgd_offset(mm, LDT_BASE_ADDR);
+ pgd_t *u_pgd = kernel_to_user_pgdp(k_pgd);
+ bool had_kernel, had_user;
+ pmd_t *k_pmd, *u_pmd;
+
+ k_pmd = pgd_to_pmd_walk(k_pgd, LDT_BASE_ADDR);
+ u_pmd = pgd_to_pmd_walk(u_pgd, LDT_BASE_ADDR);
+ had_kernel = (k_pmd->pmd != 0);
+ had_user = (u_pmd->pmd != 0);
+
+ do_sanity_check(mm, had_kernel, had_user);
+}
+
+#else /* !CONFIG_X86_PAE */
+
static void map_ldt_struct_to_user(struct mm_struct *mm)
{
pgd_t *pgd = pgd_offset(mm, LDT_BASE_ADDR);
@@ -143,6 +194,8 @@ static void sanity_check_ldt_mapping(struct mm_struct *mm)
do_sanity_check(mm, had_kernel, had_user);
}
+#endif /* CONFIG_X86_PAE */
+
/*
* If PTI is enabled, this maps the LDT into the kernelmode and
* usermode tables for the given mm.
--
2.16.2
@@ -0,0 +1,25 @@
From c15b3c596de19962f32b8aecb5abe56a9455a342 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 16 Jan 2018 11:33:01 +0100
Subject: [PATCH 33/34] x86/pti: Allow CONFIG_PAGE_TABLE_ISOLATION for x86_32
Allow PTI to be compiled on x86_32.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
security/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/Kconfig b/security/Kconfig
index b0cb9a5f9448..93d85fda0f54 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -56,7 +56,7 @@ config SECURITY_NETWORK
config PAGE_TABLE_ISOLATION
bool "Remove the kernel mapping in user mode"
- depends on X86_64 && !UML
+ depends on X86 && !UML
default y
help
This feature reduces the number of hardware side channels by
@@ -0,0 +1,45 @@
From e7591bc0c06694418c773c099f84b79003257069 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <jroedel@suse.de>
Date: Mon, 12 Feb 2018 19:47:19 +0100
Subject: [PATCH 34/34] x86/mm/pti: Add Warning when booting on a PCID capable
CPU
Warn the user in case the performance can be significantly
improved by switching to a 64-bit kernel.
Suggested-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/mm/pti.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 3ffd92309aca..8f5aa0dda327 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -385,6 +385,22 @@ void __init pti_init(void)
pr_info("enabled\n");
+#ifdef CONFIG_X86_32
+ if (boot_cpu_has(X86_FEATURE_PCID)) {
+ /* Use printk to work around pr_fmt() */
+ printk(KERN_WARNING "\n");
+ printk(KERN_WARNING "************************************************************\n");
+ printk(KERN_WARNING "** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! **\n");
+ printk(KERN_WARNING "** **\n");
+ printk(KERN_WARNING "** You are using 32-bit PTI on a 64-bit PCID-capable CPU. **\n");
+ printk(KERN_WARNING "** Your performance will increase dramatically if you **\n");
+ printk(KERN_WARNING "** switch to a 64-bit kernel! **\n");
+ printk(KERN_WARNING "** **\n");
+ printk(KERN_WARNING "** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! **\n");
+ printk(KERN_WARNING "************************************************************\n");
+ }
+#endif
+
pti_clone_user_shared();
pti_clone_entry_text();
pti_setup_espfix64();
--
2.16.2
@@ -0,0 +1,32 @@
Dont scare people with something that should be an informal message.
Signed-off-by: Thomas Backlund <tmb@mageia.org>
--- linux/arch/x86/mm/pti.c.orig
+++ linux/arch/x86/mm/pti.c
@@ -388,16 +388,14 @@ void __init pti_init(void)
#ifdef CONFIG_X86_32
if (boot_cpu_has(X86_FEATURE_PCID)) {
/* Use printk to work around pr_fmt() */
- printk(KERN_WARNING "\n");
- printk(KERN_WARNING "************************************************************\n");
- printk(KERN_WARNING "** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! **\n");
- printk(KERN_WARNING "** **\n");
- printk(KERN_WARNING "** You are using 32-bit PTI on a 64-bit PCID-capable CPU. **\n");
- printk(KERN_WARNING "** Your performance will increase dramatically if you **\n");
- printk(KERN_WARNING "** switch to a 64-bit kernel! **\n");
- printk(KERN_WARNING "** **\n");
- printk(KERN_WARNING "** WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! **\n");
- printk(KERN_WARNING "************************************************************\n");
+ printk(KERN_INFO "\n");
+ printk(KERN_INFO "************************************************************\n");
+ printk(KERN_INFO "** **\n");
+ printk(KERN_INFO "** You are using 32-bit PTI on a 64-bit PCID-capable CPU. **\n");
+ printk(KERN_INFO "** Your performance will increase dramatically if you **\n");
+ printk(KERN_INFO "** switch to a 64-bit install. **\n");
+ printk(KERN_INFO "** **\n");
+ printk(KERN_INFO "************************************************************\n");
}
#endif
@@ -0,0 +1,126 @@
From 3be8828fc507cdafe7040a3dcf361a2bcd8e305b Mon Sep 17 00:00:00 2001
From: Bart Van Assche <bart.vanassche@wdc.com>
Date: Thu, 22 Feb 2018 11:30:20 -0800
Subject: scsi: core: Avoid that ATA error handling can trigger a kernel hang
or oops
Avoid that the recently introduced call_rcu() call in the SCSI core
triggers a double call_rcu() call.
Reported-by: Natanael Copa <ncopa@alpinelinux.org>
Reported-by: Damien Le Moal <damien.lemoal@wdc.com>
References: https://bugzilla.kernel.org/show_bug.cgi?id=198861
Fixes: 3bd6f43f5cb3 ("scsi: core: Ensure that the SCSI error handler gets woken up")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Tested-by: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Natanael Copa <ncopa@alpinelinux.org>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Alexandre Oliva <oliva@gnu.org>
Cc: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/scsi/hosts.c | 3 ---
drivers/scsi/scsi_error.c | 5 +++--
drivers/scsi/scsi_lib.c | 2 ++
include/scsi/scsi_cmnd.h | 3 +++
include/scsi/scsi_host.h | 2 --
5 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 57bf43e..dd94649 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -328,8 +328,6 @@ static void scsi_host_dev_release(struct device *dev)
if (shost->work_q)
destroy_workqueue(shost->work_q);
- destroy_rcu_head(&shost->rcu);
-
if (shost->shost_state == SHOST_CREATED) {
/*
* Free the shost_dev device name here if scsi_host_alloc()
@@ -404,7 +402,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
INIT_LIST_HEAD(&shost->starved_list);
init_waitqueue_head(&shost->host_wait);
mutex_init(&shost->scan_mutex);
- init_rcu_head(&shost->rcu);
index = ida_simple_get(&host_index_ida, 0, 0, GFP_KERNEL);
if (index < 0)
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index d042915..ca53a5f 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -223,7 +223,8 @@ static void scsi_eh_reset(struct scsi_cmnd *scmd)
static void scsi_eh_inc_host_failed(struct rcu_head *head)
{
- struct Scsi_Host *shost = container_of(head, typeof(*shost), rcu);
+ struct scsi_cmnd *scmd = container_of(head, typeof(*scmd), rcu);
+ struct Scsi_Host *shost = scmd->device->host;
unsigned long flags;
spin_lock_irqsave(shost->host_lock, flags);
@@ -259,7 +260,7 @@ void scsi_eh_scmd_add(struct scsi_cmnd *scmd)
* Ensure that all tasks observe the host state change before the
* host_failed change.
*/
- call_rcu(&shost->rcu, scsi_eh_inc_host_failed);
+ call_rcu(&scmd->rcu, scsi_eh_inc_host_failed);
}
/**
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 5cbc69b..4af1682 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -670,6 +670,7 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
if (!blk_rq_is_scsi(req)) {
WARN_ON_ONCE(!(cmd->flags & SCMD_INITIALIZED));
cmd->flags &= ~SCMD_INITIALIZED;
+ destroy_rcu_head(&cmd->rcu);
}
if (req->mq_ctx) {
@@ -1150,6 +1151,7 @@ static void scsi_initialize_rq(struct request *rq)
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
scsi_req_init(&cmd->req);
+ init_rcu_head(&cmd->rcu);
cmd->jiffies_at_alloc = jiffies;
cmd->retries = 0;
}
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 949a016..0382cea 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -69,6 +69,9 @@ struct scsi_cmnd {
struct list_head list; /* scsi_cmnd participates in queue lists */
struct list_head eh_entry; /* entry for the host eh_cmd_q */
struct delayed_work abort_work;
+
+ struct rcu_head rcu;
+
int eh_eflags; /* Used by error handlr */
/*
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 1a1df0d..a8b7bf8 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -571,8 +571,6 @@ struct Scsi_Host {
struct blk_mq_tag_set tag_set;
};
- struct rcu_head rcu;
-
atomic_t host_busy; /* commands actually active on low-level */
atomic_t host_blocked;
--
cgit v1.1
@@ -0,0 +1,34 @@
From e39a97353e5378eb46bf01679799c5704d397f32 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Mon, 26 Feb 2018 08:39:59 +0100
Subject: scsi: core: return BLK_STS_OK for DID_OK in
__scsi_error_from_host_byte()
When converting __scsi_error_from_host_byte() to BLK_STS error codes the
case DID_OK was forgotten, resulting in it always returning an error.
Fixes: 2a842acab109 ("block: introduce new block status code type")
Cc: Doug Gilbert <dgilbert@interlog.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/scsi/scsi_lib.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 4af1682..c984404 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -720,6 +720,8 @@ static blk_status_t __scsi_error_from_host_byte(struct scsi_cmnd *cmd,
int result)
{
switch (host_byte(result)) {
+ case DID_OK:
+ return BLK_STS_OK;
case DID_TRANSPORT_FAILFAST:
return BLK_STS_TRANSPORT;
case DID_TARGET_FAILURE:
--
cgit v1.1
@@ -0,0 +1,119 @@
From 1514839b366417934e2f1328edb50ed1e8a719f5 Mon Sep 17 00:00:00 2001
From: "himanshu.madhani@cavium.com" <himanshu.madhani@cavium.com>
Date: Mon, 12 Feb 2018 10:28:14 -0800
Subject: scsi: qla2xxx: Fix NULL pointer crash due to active timer for ABTS
This patch fixes NULL pointer crash due to active timer running for abort
IOCB.
From crash dump analysis it was discoverd that get_next_timer_interrupt()
encountered a corrupted entry on the timer list.
#9 [ffff95e1f6f0fd40] page_fault at ffffffff914fe8f8
[exception RIP: get_next_timer_interrupt+440]
RIP: ffffffff90ea3088 RSP: ffff95e1f6f0fdf0 RFLAGS: 00010013
RAX: ffff95e1f6451028 RBX: 000218e2389e5f40 RCX: 00000001232ad600
RDX: 0000000000000001 RSI: ffff95e1f6f0fdf0 RDI: 0000000001232ad6
RBP: ffff95e1f6f0fe40 R8: ffff95e1f6451188 R9: 0000000000000001
R10: 0000000000000016 R11: 0000000000000016 R12: 00000001232ad5f6
R13: ffff95e1f6450000 R14: ffff95e1f6f0fdf8 R15: ffff95e1f6f0fe10
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
Looking at the assembly of get_next_timer_interrupt(), address came
from %r8 (ffff95e1f6451188) which is pointing to list_head with single
entry at ffff95e5ff621178.
0xffffffff90ea307a <get_next_timer_interrupt+426>: mov (%r8),%rdx
0xffffffff90ea307d <get_next_timer_interrupt+429>: cmp %r8,%rdx
0xffffffff90ea3080 <get_next_timer_interrupt+432>: je 0xffffffff90ea30a7 <get_next_timer_interrupt+471>
0xffffffff90ea3082 <get_next_timer_interrupt+434>: nopw 0x0(%rax,%rax,1)
0xffffffff90ea3088 <get_next_timer_interrupt+440>: testb $0x1,0x18(%rdx)
crash> rd ffff95e1f6451188 10
ffff95e1f6451188: ffff95e5ff621178 ffff95e5ff621178 x.b.....x.b.....
ffff95e1f6451198: ffff95e1f6451198 ffff95e1f6451198 ..E.......E.....
ffff95e1f64511a8: ffff95e1f64511a8 ffff95e1f64511a8 ..E.......E.....
ffff95e1f64511b8: ffff95e77cf509a0 ffff95e77cf509a0 ...|.......|....
ffff95e1f64511c8: ffff95e1f64511c8 ffff95e1f64511c8 ..E.......E.....
crash> rd ffff95e5ff621178 10
ffff95e5ff621178: 0000000000000001 ffff95e15936aa00 ..........6Y....
ffff95e5ff621188: 0000000000000000 00000000ffffffff ................
ffff95e5ff621198: 00000000000000a0 0000000000000010 ................
ffff95e5ff6211a8: ffff95e5ff621198 000000000000000c ..b.............
ffff95e5ff6211b8: 00000f5800000000 ffff95e751f8d720 ....X... ..Q....
ffff95e5ff621178 belongs to freed mempool object at ffff95e5ff621080.
CACHE NAME OBJSIZE ALLOCATED TOTAL SLABS SSIZE
ffff95dc7fd74d00 mnt_cache 384 19785 24948 594 16k
SLAB MEMORY NODE TOTAL ALLOCATED FREE
ffffdc5dabfd8800 ffff95e5ff620000 1 42 29 13
FREE / [ALLOCATED]
ffff95e5ff621080 (cpu 6 cache)
Examining the contents of that memory reveals a pointer to a constant string
in the driver, "abort\0", which is set by qla24xx_async_abort_cmd().
crash> rd ffffffffc059277c 20
ffffffffc059277c: 6e490074726f6261 0074707572726574 abort.Interrupt.
ffffffffc059278c: 00676e696c6c6f50 6920726576697244 Polling.Driver i
ffffffffc059279c: 646f6d207325206e 6974736554000a65 n %s mode..Testi
ffffffffc05927ac: 636976656420676e 786c252074612065 ng device at %lx
ffffffffc05927bc: 6b63656843000a2e 646f727020676e69 ...Checking prod
ffffffffc05927cc: 6f20444920746375 0a2e706968632066 uct ID of chip..
ffffffffc05927dc: 5120646e756f4600 204130303232414c .Found QLA2200A
ffffffffc05927ec: 43000a2e70696843 20676e696b636568 Chip...Checking
ffffffffc05927fc: 65786f626c69616d 6c636e69000a2e73 mailboxes...incl
ffffffffc059280c: 756e696c2f656475 616d2d616d642f78 ude/linux/dma-ma
crash> struct -ox srb_iocb
struct srb_iocb {
union {
struct {...} logio;
struct {...} els_logo;
struct {...} tmf;
struct {...} fxiocb;
struct {...} abt;
struct ct_arg ctarg;
struct {...} mbx;
struct {...} nack;
[0x0 ] } u;
[0xb8] struct timer_list timer;
[0x108] void (*timeout)(void *);
}
SIZE: 0x110
crash> ! bc
ibase=16
obase=10
B8+40
F8
The object is a srb_t, and at offset 0xf8 within that structure
(i.e. ffff95e5ff621080 + f8 -> ffff95e5ff621178) is a struct timer_list.
Cc: <stable@vger.kernel.org> #4.4+
Fixes: 4440e46d5db7 ("[SCSI] qla2xxx: Add IOCB Abort command asynchronous handling.")
Signed-off-by: Himanshu Madhani <himanshu.madhani@cavium.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/scsi/qla2xxx/qla_init.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 2dea112..0487062 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1527,6 +1527,7 @@ qla24xx_abort_sp_done(void *ptr, int res)
srb_t *sp = ptr;
struct srb_iocb *abt = &sp->u.iocb_cmd;
+ del_timer(&sp->u.iocb_cmd.timer);
complete(&abt->u.abt.comp);
}
--
cgit v1.1
@@ -14,6 +14,7 @@
###
### Stable Queue
###
patch-4.14.25-rc1.patch
###
### Arch x86
@@ -45,35 +46,40 @@ pti32bit-0003-x86-entry-32-Load-task-stack-from-x86_tss.sp1-in-SYS.patch
pti32bit-0004-x86-entry-32-Put-ESPFIX-code-into-a-macro.patch
pti32bit-0005-x86-entry-32-Unshare-NMI-return-path.patch
pti32bit-0006-x86-entry-32-Split-off-return-to-kernel-path.patch
# could be disabled as not needed according to Linus @ LKML
pti32bit-0007-x86-entry-32-Restore-segments-before-int-registers.patch
pti32bit-0008-x86-entry-32-Enter-the-kernel-via-trampoline-stack.patch
pti32bit-0009-x86-entry-32-Leave-the-kernel-via-trampoline-stack.patch
pti32bit-0010-x86-entry-32-Introduce-SAVE_ALL_NMI-and-RESTORE_ALL_.patch
pti32bit-0011-x86-entry-32-Add-PTI-cr3-switches-to-NMI-handler-cod.patch
pti32bit-0012-x86-entry-32-Add-PTI-cr3-switch-to-non-NMI-entry-exi.patch
pti32bit-0013-x86-entry-32-Handle-Entry-from-Kernel-Mode-on-Entry-.patch
pti32bit-0014-x86-pgtable-pae-Unshare-kernel-PMDs-when-PTI-is-enab.patch
pti32bit-0015-x86-pgtable-32-Allocate-8k-page-tables-when-PTI-is-e.patch
pti32bit-0016-x86-pgtable-Move-pgdp-kernel-user-conversion-functio.patch
pti32bit-0017-x86-pgtable-Move-pti_set_user_pgd-to-pgtable.h.patch
pti32bit-0018-x86-pgtable-Move-two-more-functions-from-pgtable_64..patch
pti32bit-0019-x86-mm-pae-Populate-valid-user-PGD-entries.patch
pti32bit-0020-x86-mm-pae-Populate-the-user-page-table-with-user-pg.patch
pti32bit-0021-x86-mm-legacy-Populate-the-user-page-table-with-user.patch
pti32bit-0022-x86-mm-pti-Add-an-overflow-check-to-pti_clone_pmds.patch
pti32bit-0023-x86-mm-pti-Define-X86_CR3_PTI_PCID_USER_BIT-on-x86_3.patch
pti32bit-0024-x86-mm-pti-Clone-CPU_ENTRY_AREA-on-PMD-level-on-x86_.patch
pti32bit-0025-x86-mm-dump_pagetables-Define-INIT_PGD.patch
pti32bit-0026-x86-pgtable-pae-Use-separate-kernel-PMDs-for-user-pa.patch
pti32bit-0027-x86-ldt-Reserve-address-space-range-on-32-bit-for-th.patch
pti32bit-0028-x86-ldt-Define-LDT_END_ADDR.patch
pti32bit-0029-x86-ldt-Split-out-sanity-check-in-map_ldt_struct.patch
pti32bit-0030-x86-ldt-Enable-LDT-user-mapping-for-PAE.patch
pti32bit-0031-x86-pti-Allow-CONFIG_PAGE_TABLE_ISOLATION-for-x86_32.patch
pti32bit-0011-x86-entry-32-Handle-Entry-from-Kernel-Mode-on-Entry-.patch
pti32bit-0012-x86-entry-32-Simplify-debug-entry-point.patch
pti32bit-0013-x86-entry-32-Add-PTI-cr3-switches-to-NMI-handler-cod.patch
pti32bit-0014-x86-entry-32-Add-PTI-cr3-switch-to-non-NMI-entry-exi.patch
pti32bit-0015-x86-pgtable-Rename-pti_set_user_pgd-to-pti_set_user_.patch
pti32bit-0016-x86-pgtable-pae-Unshare-kernel-PMDs-when-PTI-is-enab.patch
pti32bit-0017-x86-pgtable-32-Allocate-8k-page-tables-when-PTI-is-e.patch
pti32bit-0018-x86-pgtable-Move-pgdp-kernel-user-conversion-functio.patch
pti32bit-0019-x86-pgtable-Move-pti_set_user_pgtbl-to-pgtable.h.patch
pti32bit-0020-x86-pgtable-Move-two-more-functions-from-pgtable_64..patch
pti32bit-0021-x86-mm-pae-Populate-valid-user-PGD-entries.patch
pti32bit-0022-x86-mm-pae-Populate-the-user-page-table-with-user-pg.patch
pti32bit-0023-x86-mm-legacy-Populate-the-user-page-table-with-user.patch
pti32bit-0024-x86-mm-pti-Add-an-overflow-check-to-pti_clone_pmds.patch
pti32bit-0025-x86-mm-pti-Define-X86_CR3_PTI_PCID_USER_BIT-on-x86_3.patch
pti32bit-0026-x86-mm-pti-Clone-CPU_ENTRY_AREA-on-PMD-level-on-x86_.patch
pti32bit-0027-x86-mm-dump_pagetables-Define-INIT_PGD.patch
pti32bit-0028-x86-pgtable-pae-Use-separate-kernel-PMDs-for-user-pa.patch
pti32bit-0029-x86-ldt-Reserve-address-space-range-on-32-bit-for-th.patch
pti32bit-0030-x86-ldt-Define-LDT_END_ADDR.patch
pti32bit-0031-x86-ldt-Split-out-sanity-check-in-map_ldt_struct.patch
pti32bit-0032-x86-ldt-Enable-LDT-user-mapping-for-PAE.patch
pti32bit-0033-x86-pti-Allow-CONFIG_PAGE_TABLE_ISOLATION-for-x86_32.patch
pti32bit-0034-x86-mm-pti-Add-Warning-when-booting-on-a-PCID-capabl.patch
# tone down warning about PCID on 32bit
pti32bit-0100-tone-down-PCID-on-32bit-message.patch
# selected fixes from x86/pti
x86-pti-0070-nospec-Kill-array_index_nospec_mask_check.patch
x86-pti-0071-nospec-Allow-index-argument-to-have-const-qualified-.patch
x86-pti-0072-nospec-Include-asm-barrier.h-dependency.patch
x86-pti-0073-x86-microcode-Propagate-return-value-from-updating-f.patch
x86-pti-0074-x86-CPU-Add-a-microcode-loader-callback.patch
@@ -186,6 +192,15 @@ block-bfq-limit-sectors-served-with-interactive-weig.patch
block-bfq-put-async-queues-for-root-bfq-groups-too.patch
block-bfq-add-requeue-request-hook.patch
# HPT RR 644L
ata-ahci-Add-PCI-id-for-the-Highpoint-Rocketraid-644L-card.patch
PCI-Add-function-1-DMA-alias-quirk-for-Highpoint-RocketRAID-644L.patch
# scsi
scsi-core-Avoid-that-ATA-error-handling-can-trigger-a-kernel-hang-or-oops.patch
scsi-core-return-BLK_STS_OK-for-DID_OK-in-__scsi_error_from_host_byte.patch
scsi-qla2xxx-Fix-NULL-pointer-crash-due-to-active-timer-for-ABTS.patch
###
### Char
###
@@ -251,6 +266,10 @@ hwmon-k10temp-Add-support-for-temperature-offsets.patch
input-i8042-quirks-for-Fujitsu-Lifebook-A544-and-Lif.patch
# mga #22703
input-goodix-disable-IRQs-while-suspended.patch
input-goodix-add-support-for-GDIX1002.patch
###
### idle
###
@@ -309,6 +328,9 @@ net-tls-Correct-length-of-scatterlist-in-tls_sw_sendpage.patch
# silence message that gets reported as a bug
net-netfilter-xt_addrtype-silence-BROADCAST-message.patch
# CVE-2018-1065
net-netfilter-add-back-stackpointer-size-checks.patch
###
### pinctrl
###
@@ -340,6 +362,12 @@ platform-x86-ideapad-laptop-Increase-timeout-to-wait-for-ec-answer.patch
### Sound
###
sound-ALSA-hda-Fix-a-wrong-FIXUP-for-alc289-on-Dell-machines.patch
# skl/kbl fixes
sound-ASoC-Intel-Skylake-Fix-jack-name-format-substitution.patch
sound-ASoC-Intel-kbl-fix-jack-name.patch
###
### Staging
###
@@ -448,6 +476,8 @@ video-mageia-logo.patch
### ARM
###
arch-ARM-omap2-hide-omap3_save_secure_ram-on-non-OMAP3-bu.patch
###
### IA64
###
@@ -0,0 +1,35 @@
From: Hui Wang <hui.wang@canonical.com>
Subject: [PATCH] ALSA: hda - Fix a wrong FIXUP for alc289 on Dell machines
Date: Fri, 2 Mar 2018 13:05:36 +0800
With the alc289, the Pin 0x1b is Headphone-Mic, so we should assign
ALC269_FIXUP_DELL4_MIC_NO_PRESENCE rather than
ALC225_FIXUP_DELL1_MIC_NO_PRESENCE to it. And this change is suggested
by Kailang of Realtek and is verified on the machine.
(This fixes the commit 3f2f7c55)
Cc: Kailang Yang <kailang@realtek.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
sound/pci/hda/patch_realtek.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index b9c93fa..7a9a867 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -6872,7 +6872,7 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
{0x12, 0x90a60120},
{0x14, 0x90170110},
{0x21, 0x0321101f}),
- SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
+ SND_HDA_PIN_QUIRK(0x10ec0289, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
{0x12, 0xb7a60130},
{0x14, 0x90170110},
{0x21, 0x04211020}),
--
2.7.4
@@ -0,0 +1,35 @@
From d1c4cb447a7efcb5608a33cdfed8ab4234378b0a Mon Sep 17 00:00:00 2001
From: Chintan Patel <chintan.m.patel@intel.com>
Date: Mon, 18 Sep 2017 08:43:18 -0700
Subject: [PATCH] ASoC: Intel: Skylake: Fix jack name format substitution
Jack name is not getting formatted correctly hence resulting
in invalid name for HDMI/DP input devices.
This was recently exposed due changes brought by MST:
commit 3a13347f05fd ("ASoC: Intel: kbl: Add jack port initialize
in kbl machine drivers")
Signed-off-by: Chintan Patel <chintan.m.patel@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
index 88ff54220007..9cd0769ccd34 100644
--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
@@ -604,6 +604,8 @@ static int kabylake_card_late_probe(struct snd_soc_card *card)
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
codec = pcm->codec_dai->codec;
+ snprintf(jack_name, sizeof(jack_name),
+ "HDMI/DP, pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name,
SND_JACK_AVOUT, &ctx->kabylake_hdmi[i],
NULL, 0);
--
2.16.2
@@ -0,0 +1,32 @@
From cedb6415f9ece6d3368aa0ac8a433caff799792a Mon Sep 17 00:00:00 2001
From: Vinod Koul <vinod.koul@intel.com>
Date: Tue, 31 Oct 2017 16:47:27 +0530
Subject: [PATCH] ASoC: Intel: kbl: fix jack name
Commit d1c4cb447a7e ("ASoC: Intel: Skylake: Fix jack name format
substitution") added Jack name but erroneously added a space as well,
so remove the space in Jack name.
Fixes: d1c4cb447a7e ("ASoC: Intel: Skylake: Fix jack name format substitution")
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
index 9cd0769ccd34..69ab55956492 100644
--- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
+++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c
@@ -605,7 +605,7 @@ static int kabylake_card_late_probe(struct snd_soc_card *card)
list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) {
codec = pcm->codec_dai->codec;
snprintf(jack_name, sizeof(jack_name),
- "HDMI/DP, pcm=%d Jack", pcm->device);
+ "HDMI/DP,pcm=%d Jack", pcm->device);
err = snd_soc_card_jack_new(card, jack_name,
SND_JACK_AVOUT, &ctx->kabylake_hdmi[i],
NULL, 0);
--
2.16.2
@@ -0,0 +1,18 @@
--- a/Makefile.orig 2019-11-25 03:32:01.000000000 +0300
+++ b/Makefile 2019-12-11 03:20:12.876664698 +0300
@@ -509,15 +509,6 @@
# ignore whole output directory
outputmakefile:
ifdef building_out_of_srctree
- $(Q)if [ -f $(srctree)/.config -o \
- -d $(srctree)/include/config -o \
- -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
- echo >&2 "***"; \
- echo >&2 "*** The source tree is not clean, please run 'make$(if $(findstring command line, $(origin ARCH)), ARCH=$(ARCH)) mrproper'"; \
- echo >&2 "*** in $(abs_srctree)";\
- echo >&2 "***"; \
- false; \
- fi
$(Q)ln -fsn $(srctree) source
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
$(Q)test -e .gitignore || \
@@ -0,0 +1,780 @@
--- a/Makefile.orig 2019-11-25 03:32:01.000000000 +0300
+++ b/Makefile 2019-12-11 16:59:26.708807035 +0300
@@ -3,7 +3,7 @@
PATCHLEVEL = 4
SUBLEVEL = 0
EXTRAVERSION =
-NAME = Kleptomaniac Octopus
+NAME = Bobtail Squid
# *DOCUMENTATION*
# To see a list of typical targets execute "make help"
@@ -206,16 +206,30 @@
KBUILD_CHECKSRC = 0
endif
-# Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
-# directory of external module to build. Setting M= takes precedence.
+# Use make M=dir to specify directory of external module to build
+# Old syntax make ... SUBDIRS=$PWD is still supported
+# Setting the environment variable KBUILD_EXTMOD take precedence
+ifdef SUBDIRS
+ $(warning ================= WARNING ================)
+ $(warning 'SUBDIRS' will be removed after Linux 5.3)
+ $(warning )
+ $(warning If you are building an individual subdirectory)
+ $(warning in the kernel tree, you can do like this:)
+ $(warning $$ make path/to/dir/you/want/to/build/)
+ $(warning (Do not forget the trailing slash))
+ $(warning )
+ $(warning If you are building an external module,)
+ $(warning Please use 'M=' or 'KBUILD_EXTMOD' instead)
+ $(warning ==========================================)
+ KBUILD_EXTMOD ?= $(SUBDIRS)
+endif
+
ifeq ("$(origin M)", "command line")
KBUILD_EXTMOD := $(M)
endif
export KBUILD_CHECKSRC KBUILD_EXTMOD
-extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
-
ifeq ($(abs_srctree),$(abs_objtree))
# building in the source tree
srctree := .
@@ -257,62 +271,52 @@
%asm-generic kernelversion %src-pkg
no-sync-config-targets := $(no-dot-config-targets) install %install \
kernelrelease
-single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
-config-build :=
-mixed-build :=
-need-config := 1
-may-sync-config := 1
-single-build :=
+config-targets := 0
+mixed-targets := 0
+dot-config := 1
+may-sync-config := 1
ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
- need-config :=
+ dot-config := 0
endif
endif
ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
- may-sync-config :=
+ may-sync-config := 0
endif
endif
ifneq ($(KBUILD_EXTMOD),)
- may-sync-config :=
+ may-sync-config := 0
endif
ifeq ($(KBUILD_EXTMOD),)
ifneq ($(filter config %config,$(MAKECMDGOALS)),)
- config-build := 1
+ config-targets := 1
ifneq ($(words $(MAKECMDGOALS)),1)
- mixed-build := 1
+ mixed-targets := 1
endif
endif
endif
-# We cannot build single targets and the others at the same time
-ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
- single-build := 1
- ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
- mixed-build := 1
- endif
-endif
-
# For "make -j clean all", "make -j mrproper defconfig all", etc.
ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
- mixed-build := 1
+ mixed-targets := 1
endif
endif
# install and modules_install need also be processed one by one
ifneq ($(filter install,$(MAKECMDGOALS)),)
ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
- mixed-build := 1
+ mixed-targets := 1
endif
endif
-ifdef mixed-build
+ifeq ($(mixed-targets),1)
# ===========================================================================
# We're called with mixed targets (*config and build targets).
# Handle them one by one.
@@ -328,7 +332,7 @@
$(MAKE) -f $(srctree)/Makefile $$i; \
done
-else # !mixed-build
+else
include scripts/Kbuild.include
@@ -388,7 +392,9 @@
export KCONFIG_CONFIG
# SHELL used by kbuild
-CONFIG_SHELL := sh
+CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
+ else if [ -x /bin/bash ]; then echo /bin/bash; \
+ else echo sh; fi ; fi)
HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
@@ -425,7 +431,6 @@
PYTHON2 = python2
PYTHON3 = python3
CHECK = sparse
-BASH = bash
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
-Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
@@ -465,13 +470,12 @@
KBUILD_CFLAGS_KERNEL :=
KBUILD_AFLAGS_MODULE := -DMODULE
KBUILD_CFLAGS_MODULE := -DMODULE
-KBUILD_LDFLAGS_MODULE :=
-export KBUILD_LDS_MODULE := $(srctree)/scripts/module-common.lds
+KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
KBUILD_LDFLAGS :=
GCC_PLUGINS_CFLAGS :=
CLANG_FLAGS :=
-export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
+export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK INSTALLKERNEL
export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
@@ -482,6 +486,7 @@
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
+export KBUILD_ARFLAGS
# Files to ignore in find ... statements
@@ -501,7 +506,6 @@
$(Q)rm -f .tmp_quiet_recordmcount
PHONY += outputmakefile
-# Before starting out-of-tree build, make sure the source tree is clean.
# outputmakefile generates a Makefile in the output directory, if using a
# separate output directory. This allows convenient use of make in the
# output directory.
@@ -509,15 +513,6 @@
# ignore whole output directory
outputmakefile:
ifdef building_out_of_srctree
- $(Q)if [ -f $(srctree)/.config -o \
- -d $(srctree)/include/config -o \
- -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
- echo >&2 "***"; \
- echo >&2 "*** The source tree is not clean, please run 'make$(if $(findstring command line, $(origin ARCH)), ARCH=$(ARCH)) mrproper'"; \
- echo >&2 "*** in $(abs_srctree)";\
- echo >&2 "***"; \
- false; \
- fi
$(Q)ln -fsn $(srctree) source
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
$(Q)test -e .gitignore || \
@@ -549,7 +544,7 @@
# and from include/config/auto.conf.cmd to detect the compiler upgrade.
CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1)
-ifdef config-build
+ifeq ($(config-targets),1)
# ===========================================================================
# *config targets only - make sure prerequisites are updated, and descend
# in scripts/kconfig to make the *config target
@@ -560,13 +555,13 @@
include arch/$(SRCARCH)/Makefile
export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
-config: outputmakefile scripts_basic FORCE
+config: scripts_basic outputmakefile FORCE
$(Q)$(MAKE) $(build)=scripts/kconfig $@
-%config: outputmakefile scripts_basic FORCE
+%config: scripts_basic outputmakefile FORCE
$(Q)$(MAKE) $(build)=scripts/kconfig $@
-else #!config-build
+else
# ===========================================================================
# Build targets only - this includes vmlinux, arch specific targets, clean
# targets and others. In general all targets except *config targets.
@@ -599,7 +594,7 @@
# in addition to whatever we do anyway.
# Just "make" or "make all" shall build modules as well
-ifneq ($(filter all _all modules nsdeps,$(MAKECMDGOALS)),)
+ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
KBUILD_MODULES := 1
endif
@@ -609,7 +604,7 @@
export KBUILD_MODULES KBUILD_BUILTIN
-ifdef need-config
+ifeq ($(dot-config),1)
include include/config/auto.conf
endif
@@ -650,10 +645,15 @@
export RETPOLINE_CFLAGS
export RETPOLINE_VDSO_CFLAGS
+# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
+# values of the respective KBUILD_* variables
+ARCH_CPPFLAGS :=
+ARCH_AFLAGS :=
+ARCH_CFLAGS :=
include arch/$(SRCARCH)/Makefile
-ifdef need-config
-ifdef may-sync-config
+ifeq ($(dot-config),1)
+ifeq ($(may-sync-config),1)
# Read in dependencies to all Kconfig* files, make sure to run syncconfig if
# changes are detected. This should be included after arch/$(SRCARCH)/Makefile
# because some architectures define CROSS_COMPILE there.
@@ -676,7 +676,7 @@
# The syncconfig should be executed only once to make all the targets.
%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
-else # !may-sync-config
+else
# External modules and some install targets need include/generated/autoconf.h
# and include/config/auto.conf but do not care if they are up-to-date.
# Use auto.conf to trigger the test
@@ -692,7 +692,7 @@
/bin/false)
endif # may-sync-config
-endif # need-config
+endif # $(dot-config)
KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
@@ -700,12 +700,10 @@
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
-ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
-KBUILD_CFLAGS += -O2
-else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
-KBUILD_CFLAGS += -O3
-else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS += -Os
+ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
+KBUILD_CFLAGS += -Os
+else
+KBUILD_CFLAGS += -O2
endif
ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED
@@ -753,11 +751,6 @@
# These warnings generated too much noise in a regular build.
# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
KBUILD_CFLAGS += -Wno-unused-but-set-variable
-
-# Warn about unmarked fall-throughs in switch statement.
-# Disabled for clang while comment to attribute conversion happens and
-# https://github.com/ClangBuiltLinux/linux/issues/636 is discussed.
-KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
endif
KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
@@ -852,6 +845,9 @@
# warn about C99 declaration after statement
KBUILD_CFLAGS += -Wdeclaration-after-statement
+# Warn about unmarked fall-throughs in switch statement.
+KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
+
# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
KBUILD_CFLAGS += -Wvla
@@ -897,14 +893,18 @@
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
endif
+# use the deterministic mode of AR if available
+KBUILD_ARFLAGS := $(call ar-option,D)
+
include scripts/Makefile.kasan
include scripts/Makefile.extrawarn
include scripts/Makefile.ubsan
-# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
-KBUILD_CPPFLAGS += $(KCPPFLAGS)
-KBUILD_AFLAGS += $(KAFLAGS)
-KBUILD_CFLAGS += $(KCFLAGS)
+# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the
+# last assignments
+KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS)
+KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS)
+KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS)
KBUILD_LDFLAGS_MODULE += --build-id
LDFLAGS_vmlinux += --build-id
@@ -913,13 +913,6 @@
LDFLAGS_vmlinux += $(call ld-option, -X,)
endif
-ifeq ($(CONFIG_RELR),y)
-LDFLAGS_vmlinux += --pack-dyn-relocs=relr
-endif
-
-# make the checker run with the right architecture
-CHECKFLAGS += --arch=$(ARCH)
-
# insure the checker run with the right endianness
CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
@@ -1010,7 +1003,7 @@
PHONY += prepare0
-export MODORDER := $(extmod-prefix)modules.order
+export MODORDER := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order
ifeq ($(KBUILD_EXTMOD),)
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
@@ -1023,9 +1016,6 @@
$(patsubst %/,%,$(filter %/, $(init-) $(core-) \
$(drivers-) $(net-) $(libs-) $(virt-))))
-build-dirs := $(vmlinux-dirs)
-clean-dirs := $(vmlinux-alldirs)
-
init-y := $(patsubst %/, %/built-in.a, $(init-y))
core-y := $(patsubst %/, %/built-in.a, $(core-y))
drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y))
@@ -1040,7 +1030,7 @@
export KBUILD_VMLINUX_LIBS := $(libs-y1)
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
export LDFLAGS_vmlinux
-# used by scripts/Makefile.package
+# used by scripts/package/Makefile
export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools)
vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
@@ -1048,7 +1038,7 @@
# Recurse until adjust_autoksyms.sh is satisfied
PHONY += autoksyms_recursive
ifdef CONFIG_TRIM_UNUSED_KSYMS
-autoksyms_recursive: descend modules.order
+autoksyms_recursive: $(vmlinux-deps) modules.order
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
"$(MAKE) -f $(srctree)/Makefile vmlinux"
endif
@@ -1080,7 +1070,17 @@
# The actual objects are generated when descending,
# make sure no implicit rule kicks in
-$(sort $(vmlinux-deps)): descend ;
+$(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
+
+# Handle descending into subdirectories listed in $(vmlinux-dirs)
+# Preset locale variables to speed up the build process. Limit locale
+# tweaks to this spot to avoid wrong language settings when running
+# make menuconfig etc.
+# Error messages still appears in the original language
+
+PHONY += $(vmlinux-dirs)
+$(vmlinux-dirs): prepare
+ $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1
filechk_kernel.release = \
echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
@@ -1102,9 +1102,24 @@
# archprepare is used in arch Makefiles and when processed asm symlink,
# version.h and scripts_basic is processed / created.
-PHONY += prepare archprepare
+PHONY += prepare archprepare prepare3
-archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
+# prepare3 is used to check if we are building in a separate output directory,
+# and if so do:
+# 1) Check that make has not been executed in the kernel src $(srctree)
+prepare3: include/config/kernel.release
+ifdef building_out_of_srctree
+ @$(kecho) ' Using $(srctree) as source for kernel'
+ $(Q)if [ -f $(srctree)/.config -o \
+ -d $(srctree)/include/config -o \
+ -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
+ echo >&2 " $(srctree) is not clean, please run 'make ARCH=$(ARCH) mrproper'"; \
+ echo >&2 " in the '$(srctree)' directory.";\
+ /bin/false; \
+ fi;
+endif
+
+archprepare: archheaders archscripts scripts prepare3 outputmakefile \
asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h
prepare0: archprepare
@@ -1220,15 +1235,16 @@
kselftest:
$(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
-kselftest-%: FORCE
- $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
+PHONY += kselftest-clean
+kselftest-clean:
+ $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests clean
PHONY += kselftest-merge
kselftest-merge:
$(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!))
$(Q)find $(srctree)/tools/testing/selftests -name config | \
xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
- $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
+ +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
# ---------------------------------------------------------------------------
# Devicetree files
@@ -1239,11 +1255,11 @@
ifneq ($(dtstree),)
-%.dtb: include/config/kernel.release scripts_dtc
+%.dtb: prepare3 scripts_dtc
$(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
PHONY += dtbs dtbs_install dt_binding_check
-dtbs dtbs_check: include/config/kernel.release scripts_dtc
+dtbs dtbs_check: prepare3 scripts_dtc
$(Q)$(MAKE) $(build)=$(dtstree)
dtbs_check: export CHECK_DTBS=1
@@ -1282,16 +1298,17 @@
PHONY += modules
modules: $(if $(KBUILD_BUILTIN),vmlinux) modules.order modules.builtin
+ @$(kecho) ' Building modules, stage 2.';
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh
-modules.order: descend
- $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
+modules.order: $(vmlinux-dirs)
+ $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@
-modbuiltin-dirs := $(addprefix _modbuiltin_, $(build-dirs))
+modbuiltin-dirs := $(addprefix _modbuiltin_, $(vmlinux-dirs))
modules.builtin: $(modbuiltin-dirs)
- $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(build-dirs)) > $@
+ $(Q)$(AWK) '!x[$$0]++' $(addsuffix /$@, $(vmlinux-dirs)) > $@
PHONY += $(modbuiltin-dirs)
# tristate.conf is not included from this Makefile. Add it as a prerequisite
@@ -1364,14 +1381,12 @@
# Directories & files removed with 'make mrproper'
MRPROPER_DIRS += include/config include/generated \
- arch/$(SRCARCH)/include/generated .tmp_objdiff \
- debian/ snap/ tar-install/
+ arch/$(SRCARCH)/include/generated .tmp_objdiff
MRPROPER_FILES += .config .config.old .version \
Module.symvers \
signing_key.pem signing_key.priv signing_key.x509 \
x509.genkey extra_certificates signing_key.x509.keyid \
- signing_key.x509.signer vmlinux-gdb.py \
- *.spec
+ signing_key.x509.signer vmlinux-gdb.py
# Directories & files removed with 'make distclean'
DISTCLEAN_DIRS +=
@@ -1381,8 +1396,11 @@
#
clean: rm-dirs := $(CLEAN_DIRS)
clean: rm-files := $(CLEAN_FILES)
+clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs))
-PHONY += archclean vmlinuxclean
+PHONY += $(clean-dirs) clean archclean vmlinuxclean
+$(clean-dirs):
+ $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
vmlinuxclean:
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
@@ -1423,11 +1441,13 @@
# Packaging of the kernel to various formats
# ---------------------------------------------------------------------------
+package-dir := scripts/package
%src-pkg: FORCE
- $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
+ $(Q)$(MAKE) $(build)=$(package-dir) $@
%pkg: include/config/kernel.release FORCE
- $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
+ $(Q)$(MAKE) $(build)=$(package-dir) $@
+
# Brief documentation of the typical targets used
# ---------------------------------------------------------------------------
@@ -1480,9 +1500,6 @@
@echo ' headerdep - Detect inclusion cycles in headers'
@echo ' coccicheck - Check with Coccinelle'
@echo ''
- @echo 'Tools:'
- @echo ' nsdeps - Generate missing symbol namespace dependencies'
- @echo ''
@echo 'Kernel selftest:'
@echo ' kselftest - Build and run kernel selftest (run as root)'
@echo ' Build, install, and boot kernel before'
@@ -1493,10 +1510,8 @@
@echo ''
@$(if $(dtstree), \
echo 'Devicetree:'; \
- echo '* dtbs - Build device tree blobs for enabled boards'; \
- echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
- echo ' dt_binding_check - Validate device tree binding documents'; \
- echo ' dtbs_check - Validate device tree source files';\
+ echo '* dtbs - Build device tree blobs for enabled boards'; \
+ echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
echo '')
@echo 'Userspace tools targets:'
@@ -1504,7 +1519,7 @@
@echo ' or "cd tools; make help"'
@echo ''
@echo 'Kernel packaging:'
- @$(MAKE) -f $(srctree)/scripts/Makefile.package help
+ @$(MAKE) $(build)=$(package-dir) help
@echo ''
@echo 'Documentation targets:'
@$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
@@ -1529,7 +1544,7 @@
@echo ' make C=1 [targets] Check re-compiled c source with $$CHECK (sparse by default)'
@echo ' make C=2 [targets] Force check of all c source with $$CHECK'
@echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
- @echo ' make W=n [targets] Enable extra build checks, n=1,2,3 where'
+ @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
@echo ' 1: warnings which may be relevant and do not occur too often'
@echo ' 2: warnings which occur quite often but may still be relevant'
@echo ' 3: more obscure warnings, can most likely be ignored'
@@ -1558,7 +1573,7 @@
DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
linkcheckdocs dochelp refcheckdocs
PHONY += $(DOC_TARGETS)
-$(DOC_TARGETS):
+$(DOC_TARGETS): scripts_basic FORCE
$(Q)$(MAKE) $(build)=Documentation $@
# Misc
@@ -1603,9 +1618,13 @@
echo " is missing; modules will have no dependencies and modversions."; \
echo )
-build-dirs := $(KBUILD_EXTMOD)
-PHONY += modules
-modules: descend $(objtree)/Module.symvers
+module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
+PHONY += $(module-dirs) modules
+$(module-dirs): prepare $(objtree)/Module.symvers
+ $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) need-modorder=1
+
+modules: $(module-dirs)
+ @$(kecho) ' Building modules, stage 2.';
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
PHONY += modules_install
@@ -1621,12 +1640,13 @@
_emodinst_post: _emodinst_
$(call cmd,depmod)
-clean-dirs := $(KBUILD_EXTMOD)
-clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
+clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
-PHONY += /
-/:
- @echo >&2 '"$(MAKE) /" is no longer supported. Please use "$(MAKE) ./" instead.'
+PHONY += $(clean-dirs) clean
+$(clean-dirs):
+ $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
+
+clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
PHONY += help
help:
@@ -1641,21 +1661,6 @@
PHONY += prepare
endif # KBUILD_EXTMOD
-# Handle descending into subdirectories listed in $(build-dirs)
-# Preset locale variables to speed up the build process. Limit locale
-# tweaks to this spot to avoid wrong language settings when running
-# make menuconfig etc.
-# Error messages still appears in the original language
-PHONY += descend $(build-dirs)
-descend: $(build-dirs)
-$(build-dirs): prepare
- $(Q)$(MAKE) $(build)=$@ single-build=$(single-build) need-builtin=1 need-modorder=1
-
-clean-dirs := $(addprefix _clean_, $(clean-dirs))
-PHONY += $(clean-dirs) clean
-$(clean-dirs):
- $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
-
clean: $(clean-dirs)
$(call cmd,rmdirs)
$(call cmd,rmfiles)
@@ -1664,7 +1669,7 @@
-o -name '*.ko.*' \
-o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
-o -name '*.dwo' -o -name '*.lst' \
- -o -name '*.su' -o -name '*.mod' -o -name '*.ns_deps' \
+ -o -name '*.su' -o -name '*.mod' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-o -name '*.lex.c' -o -name '*.tab.[ch]' \
-o -name '*.asn1.[ch]' \
@@ -1677,20 +1682,11 @@
# Generate tags for editors
# ---------------------------------------------------------------------------
quiet_cmd_tags = GEN $@
- cmd_tags = $(BASH) $(srctree)/scripts/tags.sh $@
+ cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@
tags TAGS cscope gtags: FORCE
$(call cmd,tags)
-# Script to generate missing namespace dependencies
-# ---------------------------------------------------------------------------
-
-PHONY += nsdeps
-
-nsdeps: modules
- $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost nsdeps
- $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@
-
# Scripts to check various things for consistency
# ---------------------------------------------------------------------------
@@ -1707,7 +1703,7 @@
| xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
coccicheck:
- $(Q)$(BASH) $(srctree)/scripts/$@
+ $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@
namespacecheck:
$(PERL) $(srctree)/scripts/namespace.pl
@@ -1755,47 +1751,45 @@
# Single targets
# ---------------------------------------------------------------------------
-# To build individual files in subdirectories, you can do like this:
-#
-# make foo/bar/baz.s
-#
-# The supported suffixes for single-target are listed in 'single-targets'
-#
-# To build only under specific subdirectories, you can do like this:
-#
-# make foo/bar/baz/
-
-ifdef single-build
-
-single-all := $(filter $(single-targets), $(MAKECMDGOALS))
-
-# .ko is special because modpost is needed
-single-ko := $(sort $(filter %.ko, $(single-all)))
-single-no-ko := $(sort $(patsubst %.ko,%.mod, $(single-all)))
-
-$(single-ko): single_modpost
- @:
-$(single-no-ko): descend
- @:
-
+# Single targets are compatible with:
+# - build with mixed source and output
+# - build with separate output dir 'make O=...'
+# - external modules
+#
+# target-dir => where to store outputfile
+# build-dir => directory in kernel source tree to use
+
+build-target = $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD)/)$@
+build-dir = $(patsubst %/,%,$(dir $(build-target)))
+
+%.i: prepare FORCE
+ $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
+%.ll: prepare FORCE
+ $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
+%.lst: prepare FORCE
+ $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
+%.o: prepare FORCE
+ $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
+%.s: prepare FORCE
+ $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
+%.symtypes: prepare FORCE
+ $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
ifeq ($(KBUILD_EXTMOD),)
-# For the single build of in-tree modules, use a temporary file to avoid
+# For the single build of an in-tree module, use a temporary file to avoid
# the situation of modules_install installing an invalid modules.order.
-MODORDER := .modules.tmp
+%.ko: MODORDER := .modules.tmp
endif
-
-PHONY += single_modpost
-single_modpost: $(single-no-ko)
- $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER)
+%.ko: prepare FORCE
+ $(Q)$(MAKE) $(build)=$(build-dir) $(build-target:.ko=.mod)
+ $(Q)echo $(build-target) > $(MODORDER)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
-KBUILD_MODULES := 1
-
-export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko))
+# Modules
+PHONY += /
+/: ./
-single-build = $(if $(filter-out $@/, $(single-no-ko)),1)
-
-endif
+%/: prepare FORCE
+ $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) need-modorder=1
# FIXME Should go into a make.lib or something
# ===========================================================================
@@ -1816,9 +1810,9 @@
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
-endif # config-targets
-endif # mixed-build
-endif # need-sub-make
+endif # ifeq ($(config-targets),1)
+endif # ifeq ($(mixed-targets),1)
+endif # need-sub-make
PHONY += FORCE
FORCE:
+19 -8
View File
@@ -12,19 +12,22 @@
<IsA>app:console</IsA>
<Summary>CPU power management tools</Summary>
<Description>cpupowertools contains utilities to manage power management and frequency scaling policies of modern CPUs.</Description>
<Archive sha1sum="eb09a8e0483a9ec40bdb767551d0eda27f7c221a" type="targz">https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.19.tar.gz</Archive>
<Archive sha1sum="8fd0449a462c77f3e5b35848f4bf3c41411702d6" type="targz">https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.4.tar.gz</Archive>
<BuildDependencies>
<Dependency>pciutils-devel</Dependency>
</BuildDependencies>
<Patches>
<!-- Linux patches -->
<Patch level="1" compressionType="xz">patches/linux/patch-4.19.56.xz</Patch>
<!-- Mageia Linux patches // compatible with http://svnweb.mageia.org/packages/cauldron/kernel/releases/4.14.44/2.mga7/PATCHES/patches/series-->
<!--stable patches-->
<!--CVE-2016-8405-->
<!--other patches-->
<Patch level="1">patches/mageia_4_19/fs-aufs-4.19.patch</Patch>
<Patch level="1">patches/mageia_4_19/fs-aufs-4.19-modular.patch</Patch>
<Patch level="1" compressionType="xz">patches/linux/patch-5.4.6.xz</Patch>
<!-- Mageia Linux patches-->
<Patch level="1">patches/mageia/fs-aufs-5.4.patch</Patch>
<Patch level="1">patches/mageia/fs-aufs-5.4-modular.patch</Patch>
<Patch level="1">patches/mageia/fs-vboxsf.patch</Patch>
<Patch level="1">patches/mageia/CVE-2019-12379.patch</Patch>
<!-- <Patch level="1">patches/mageia/disable-mrproper-in-devel-rpms.patch</Patch> -->
<!-- Build fix -->
<Patch level="1">patches/pisilinux/revert-Makefile.patch</Patch>
</Patches>
</Source>
@@ -41,6 +44,7 @@
<Path fileType="header">/usr/include</Path>
<Path fileType="man">/usr/share/man/man1/cpupower*</Path>
<Path fileType="locale">/usr/share/locale/*/*/cpupower.mo</Path>
<Path fileType="data">/usr/share/bash-completion/completions/cpupower</Path>
</Files>
<AdditionalFiles>
<AdditionalFile owner="root" permission="0644" target="/etc/conf.d/cpupower">cpupower.conf.d</AdditionalFile>
@@ -51,6 +55,13 @@
</Package>
<History>
<Update release="27">
<Date>2019-12-27</Date>
<Version>5.4.6</Version>
<Comment>Version bump</Comment>
<Name>Idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="26">
<Date>2019-06-26</Date>
<Version>4.19.56</Version>