Merge pull request #1011 from IdrisKalp/master

core
This commit is contained in:
Idris Kalp
2019-12-27 19:17:38 +03:00
committed by GitHub
340 changed files with 129824 additions and 8725 deletions
+7
View File
@@ -72,6 +72,13 @@
</Package>
<History>
<Update release="8">
<Date>2019-12-27</Date>
<Version>2.10.1</Version>
<Comment>Rebuild</Comment>
<Name>Idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="7">
<Date>2019-08-01</Date>
<Version>2.10.1</Version>
+8 -1
View File
@@ -21,7 +21,7 @@
</Patches>
<BuildDependencies>
<Dependency>klibc</Dependency>
<Dependency>colorgcc</Dependency>
<!-- <Dependency>colorgcc</Dependency> -->
</BuildDependencies>
</Source>
@@ -35,6 +35,13 @@
</Package>
<History>
<Update release="5">
<Date>2019-12-27</Date>
<Version>9</Version>
<Comment>Rebuild</Comment>
<Name>idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="4">
<Date>2018-07-23</Date>
<Version>9</Version>
+5 -1
View File
@@ -60,10 +60,14 @@ def builddiet():
def setup():
# Breaks linking when sandbox is disabled
shelltools.export("CLDFLAGS", get.LDFLAGS())
shelltools.export("CLDFLAGS", "%s -lpthread" %get.LDFLAGS())
shelltools.export("LIB_PTHREAD", "-lpthread")
pisitools.dosed("conf/example.conf.in", "use_lvmetad = 0", "use_lvmetad = 1")
#shelltools.system(""" sed -i -e "1iAR = $(tc-getAR)" -e "s:CC ?= @CC@:CC = $(tc-getCC):" make.tmpl.in || die """)
shelltools.system(""" sed -i -e '/FLAG/s:-O2::' configure || die """)
shelltools.system(""" sed -i -e '/FLAG/s:-O2::' configure.ac || die """)
autotools.autoreconf("-fi")
autotools.configure("--with-thin-check= \
@@ -0,0 +1,12 @@
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -505,7 +505,9 @@
dev->flags |= DEV_NOT_O_NOATIME;
if ((dev->fd = open(name, flags, 0777)) >= 0) {
log_debug_devs("%s: Not using O_NOATIME", name);
+#ifdef O_DIRECT_SUPPORT
goto opened;
+#endif
}
}
#endif
@@ -0,0 +1,13 @@
diff --git a/make.tmpl.in b/make.tmpl.in
index a40eaaa15..7eea943aa 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -53,7 +53,7 @@ PYCOMPILE = $(top_srcdir)/autoconf/py-compile
LIBS = @LIBS@
# Extra libraries always linked with static binaries
-STATIC_LIBS = $(SELINUX_STATIC_LIBS) $(UDEV_STATIC_LIBS) $(BLKID_STATIC_LIBS)
+STATIC_LIBS = $(SELINUX_STATIC_LIBS) $(UDEV_STATIC_LIBS) $(BLKID_STATIC_LIBS) $(M_LIBS)
DEFS += @DEFS@
# FIXME set this only where it's needed, not globally?
CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
@@ -0,0 +1,102 @@
--- LVM2.2.02.178/configure.ac
+++ LVM2.2.02.178/configure.ac
@@ -1238,6 +1238,7 @@
PKG_CHECK_MODULES(BLKID, blkid >= 2.24,
[ BLKID_WIPING=yes
BLKID_PC="blkid"
+ BLKID_STATIC_LIBS=`$PKG_CONFIG --static --libs $BLKID_PC`
DEFAULT_USE_BLKID_WIPING=1
AC_DEFINE([BLKID_WIPING_SUPPORT], 1, [Define to 1 to use libblkid detection of signatures when wiping.])
], [if test "$BLKID_WIPING" = maybe; then
@@ -1286,6 +1287,7 @@
if test "$UDEV_SYNC" = yes; then
pkg_config_init
PKG_CHECK_MODULES(UDEV, libudev >= 143, [UDEV_PC="libudev"])
+ UDEV_STATIC_LIBS=`$PKG_CONFIG --static --libs libudev`
AC_DEFINE([UDEV_SYNC_SUPPORT], 1, [Define to 1 to enable synchronisation with udev processing.])
AC_CHECK_LIB(udev, udev_device_get_is_initialized, AC_DEFINE([HAVE_LIBUDEV_UDEV_DEVICE_GET_IS_INITIALIZED], 1,
@@ -1564,19 +1566,32 @@
if test "$SELINUX" = yes; then
AC_CHECK_LIB([sepol], [sepol_check_context], [
AC_DEFINE([HAVE_SEPOL], 1, [Define to 1 if sepol_check_context is available.])
- SELINUX_LIBS="-lsepol"])
+ SEPOL_LIBS="-lsepol"])
+
+ dnl -- init pkgconfig if required
+ if test x$PKGCONFIG_INIT != x1; then
+ pkg_config_init
+ fi
+ PKG_CHECK_MODULES(SELINUX, libselinux, [
+ SELINUX_PC="libselinux"
+ SELINUX_STATIC_LIBS=`$PKG_CONFIG --static --libs libselinux`
+ SELINUX_LIBS="$SELINUX_LIBS $SEPOL_LIBS"
+ AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.])
+ ],[
+ dnl -- old non-pkgconfig method, is buggy with static builds
AC_CHECK_LIB([selinux], [is_selinux_enabled], [
AC_CHECK_HEADERS([selinux/selinux.h],, hard_bailout)
AC_CHECK_HEADERS([selinux/label.h])
AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.])
- SELINUX_LIBS="-lselinux $SELINUX_LIBS"
+ SELINUX_LIBS="-lselinux $SEPOL_LIBS"
SELINUX_PC="libselinux"
HAVE_SELINUX=yes ], [
AC_MSG_WARN(Disabling selinux)
SELINUX_LIBS=
SELINUX_PC=
HAVE_SELINUX=no ])
+ ])
fi
################################################################################
@@ -1927,6 +1942,7 @@
################################################################################
AC_SUBST(APPLIB)
AC_SUBST(AWK)
+AC_SUBST(BLKID_STATIC_LIBS)
AC_SUBST(BLKID_PC)
AC_SUBST(BUILD_CMIRRORD)
AC_SUBST(BUILD_DMEVENTD)
@@ -2037,6 +2053,7 @@
AC_SUBST(SALCK_LIBS)
AC_SUBST(SBINDIR)
AC_SUBST(SELINUX_LIBS)
+AC_SUBST(SELINUX_STATIC_LIBS)
AC_SUBST(SELINUX_PC)
AC_SUBST(SYSCONFDIR)
AC_SUBST(SYSTEMD_LIBS)
@@ -2053,6 +2070,7 @@
AC_SUBST(CACHE_DUMP_CMD)
AC_SUBST(CACHE_REPAIR_CMD)
AC_SUBST(CACHE_RESTORE_CMD)
+AC_SUBST(UDEV_STATIC_LIBS)
AC_SUBST(UDEV_PC)
AC_SUBST(UDEV_RULES)
AC_SUBST(UDEV_SYNC)
--- LVM2.2.02.178/make.tmpl.in
+++ LVM2.2.02.178/make.tmpl.in
@@ -59,7 +59,7 @@
LIBS = @LIBS@
# Extra libraries always linked with static binaries
-STATIC_LIBS = $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS)
+STATIC_LIBS = $(SELINUX_STATIC_LIBS) $(UDEV_STATIC_LIBS) $(BLKID_STATIC_LIBS)
DEFS += @DEFS@
# FIXME set this only where it's needed, not globally?
CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
@@ -75,10 +75,13 @@
PTHREAD_LIBS = @PTHREAD_LIBS@
READLINE_LIBS = @READLINE_LIBS@
SELINUX_LIBS = @SELINUX_LIBS@
+SELINUX_STATIC_LIBS = @SELINUX_STATIC_LIBS@
UDEV_CFLAGS = @UDEV_CFLAGS@
UDEV_LIBS = @UDEV_LIBS@
+UDEV_STATIC_LIBS = @UDEV_STATIC_LIBS@
BLKID_CFLAGS = @BLKID_CFLAGS@
BLKID_LIBS = @BLKID_LIBS@
+BLKID_STATIC_LIBS = @BLKID_STATIC_LIBS@
SYSTEMD_LIBS = @SYSTEMD_LIBS@
VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
@@ -0,0 +1,72 @@
From a397b69ce33d811aba7d64d54b5c8e0efb86fd15 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Fri, 10 May 2019 14:40:11 +0200
Subject: [PATCH] metadata: allow reading metadata with invalid creation_time
lvm2 till version 2.02.169 (commit 78d004efa8a1809cea68283e6204edfa9d7c1091)
was printing invalid creation_time argument into metadata on 32bit arch.
However with commit ba9820b14223b731125c83dbc9709aa44fdcdbf1 we started
to properly validate all input numbers and thus we refused to accept
invalid metadata with 'garbage' string - but this results in the
situation where metadata produced on older lvm2 on 32 bit architecture
will become unreadable after upgrade.
To fix this case - extend libdm parser in a way, that whenever we
find error integer value, we also check if the parsed value is not for
creation_time node and in this case we let the metadata pass through
with made-up date 2018-05-24 (release date of 2.02.169).
---
libdm/libdm-config.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index 3f0d2510e..382f86bbf 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -51,6 +51,8 @@ struct parser {
struct dm_pool *mem;
int no_dup_node_check; /* whether to disable dup node checking */
+ const char *key; /* last obtained key */
+ unsigned ignored_creation_time;
};
struct config_output {
@@ -176,7 +178,7 @@ static int _do_dm_config_parse(struct dm_config_tree *cft, const char *start, co
/* TODO? if (start == end) return 1; */
struct parser *p;
- if (!(p = dm_pool_alloc(cft->mem, sizeof(*p))))
+ if (!(p = dm_pool_zalloc(cft->mem, sizeof(*p))))
return_0;
p->mem = cft->mem;
@@ -615,6 +617,7 @@ static struct dm_config_node *_section(struct parser *p, struct dm_config_node *
match(TOK_SECTION_E);
} else {
match(TOK_EQ);
+ p->key = root->key;
if (!(value = _value(p)))
return_NULL;
if (root->v)
@@ -682,8 +685,17 @@ static struct dm_config_value *_type(struct parser *p)
errno = 0;
v->v.i = strtoll(p->tb, NULL, 0); /* FIXME: check error */
if (errno) {
- log_error("Failed to read int token.");
- return NULL;
+ if (errno == ERANGE && p->key &&
+ strcmp("creation_time", p->key) == 0) {
+ /* Due to a bug in some older 32bit builds (<2.02.169),
+ * lvm was able to produce invalid creation_time string */
+ v->v.i = 1527120000; /* Pick 2018-05-24 day instead */
+ if (!p->ignored_creation_time++)
+ log_warn("WARNING: Invalid creation_time found in metadata (repaired with next metadata update).");
+ } else {
+ log_error("Failed to read int token.");
+ return NULL;
+ }
}
match(TOK_INT);
break;
@@ -0,0 +1,13 @@
https://bugs.gentoo.org/686652
--- LVM2.2.02.184/tools/Makefile.in
+++ LVM2.2.02.184/tools/Makefile.in
@@ -220,6 +220,6 @@
echo "/* Do not edit. This file is generated by the Makefile. */" && \
echo -en "const char _command_input[] =\n\n\"" && \
$(EGREP) -v '^#|\-\-\-|^$$' $(srcdir)/command-lines.in | $(AWK) 'BEGIN {ORS = "\\n\"\n\""} //' && \
- echo "\\n\";" \
+ printf "%s\n" "\\n\";" \
) > $@
$(SOURCES:%.c=%.d) $(SOURCES2:%.c=%.d): command-lines-input.h command-count.h cmds.h
@@ -0,0 +1,34 @@
From f98f79a047dd1c4980008e0ed6c9ad4e18596cdc Mon Sep 17 00:00:00 2001
From: Peter Rajnoha <prajnoha@redhat.com>
Date: Tue, 13 Aug 2019 15:18:30 +0200
Subject: [PATCH] udev: remove unsupported OPTIONS+="event_timeout" rule
The OPTIONS+="event_timeout" is Unsupported since systemd/udev version 216,
that is ~5 years ago.
Since systemd/udev version 243, there's a new message printed if unsupported
OPTIONS value is used:
Invalid value for OPTIONS key, ignoring: 'event_timeout=180'
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1740666
---
udev/11-dm-lvm.rules.in | 2 --
1 file changed, 2 deletions(-)
diff --git a/udev/11-dm-lvm.rules.in b/udev/11-dm-lvm.rules.in
index 91cb991df9..7c589943b7 100644
--- a/udev/11-dm-lvm.rules.in
+++ b/udev/11-dm-lvm.rules.in
@@ -37,8 +37,6 @@ ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_DISABLE_OTHE
ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end"
-OPTIONS+="event_timeout=180"
-
# Do not create symlinks for inappropriate subdevices.
ENV{DM_LV_NAME}=="pvmove?*|?*_vorigin", GOTO="lvm_disable"
ENV{DM_LV_LAYER}=="?*", GOTO="lvm_disable"
--
2.24.0
@@ -0,0 +1,72 @@
--- LVM2.2.02.56/scripts/lvm2create_initrd/lvm2create_initrd.orig 2006-11-21 22:41:56.000000000 +0000
+++ LVM2.2.02.56/scripts/lvm2create_initrd/lvm2create_initrd 2009-12-26 01:47:08.025224602 +0000
@@ -54,7 +54,9 @@
DEVRAM=/tmp/initrd.$$
# set defaults
-BINFILES=${BINFILES:-"`which lvm` `which bash` `which busybox` `which pivot_root`"}
+LVM=`which lvm.static`
+LVM=${LVM:-"`which lvm`"}
+BINFILES=${BINFILES:-"${LVM} `which bash` `which busybox` `which pivot_root`"}
BASICDEVICES=${BASICDEVICES:-"std consoleonly fd"}
BLOCKDEVICES=${BLOCKDEVICES:-"md hda hdb hdc hdd sda sdb sdc sdd"}
MAKEDEV=${MAKEDEV:-"debian"}
@@ -119,6 +121,10 @@
echo "$PRE Mounting /proc"
mount -t proc none /proc
+# We need /sys for lvm
+echo "$PRE Mounting /sys"
+mount -t sysfs sysfs /sys
+
# plug in modules listed in /etc/modules
if [ -f /etc/modules ]; then
echo -n "$PRE plugging in kernel modules:"
@@ -179,26 +185,29 @@
# run a shell if we're passed lvm2rescue on commandline
grep lvm2rescue /proc/cmdline 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
- lvm vgchange --ignorelockingfailure -P -a y
+ $LVM vgchange --ignorelockingfailure -P -a y
do_shell
else
- lvm vgchange --ignorelockingfailure -a y
+ $LVM vgchange --ignorelockingfailure -a y
fi
echo "$PRE Mounting root filesystem $rootvol ro"
mkdir /rootvol
if ! mount -t auto -o ro $rootvol /rootvol; then
- echo "\t*FAILED*";
+ echo "\t*FAILED TRYING TO MOUNT ROOTVOL*";
do_shell
fi
echo "$PRE Umounting /proc"
umount /proc
+echo "$PRE Umounting /sys"
+umount /sys
+
echo "$PRE Changing roots"
cd /rootvol
if ! pivot_root . initrd ; then
- echo "\t*FAILED*"
+ echo "\t*FAILED PIVOT TO NEW ROOT*"
do_shell
fi
@@ -356,7 +365,7 @@
fi
verbose "creating basic set of directories in $TMPMNT"
-(cd $TMPMNT; mkdir bin dev etc lib proc sbin var)
+(cd $TMPMNT; mkdir bin dev etc lib proc sbin sys var)
if [ $? -ne 0 ]; then
echo "$cmd -- ERROR creating directories in $TMPMNT"
cleanup 1
@@ -499,4 +508,3 @@
FINALTXT
cleanup 0
-
@@ -0,0 +1,18 @@
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=301331
X-Gentoo-Bug: 301331
diff -Nuar LVM2.2.02.67.orig/scripts/lvm2create_initrd/lvm2create_initrd LVM2.2.02.67/scripts/lvm2create_initrd/lvm2create_initrd
--- LVM2.2.02.67.orig/scripts/lvm2create_initrd/lvm2create_initrd 2010-06-07 18:44:34.182980475 +0000
+++ LVM2.2.02.67/scripts/lvm2create_initrd/lvm2create_initrd 2010-06-07 18:51:27.636312899 +0000
@@ -469,9 +469,9 @@
rmdir $TMPMNT/lost+found
echo "$cmd -- ummounting ram disk"
-umount $DEVRAM
+umount $TMPMNT
if [ $? -ne 0 ]; then
- echo "$cmd -- ERROR umounting $DEVRAM"
+ echo "$cmd -- ERROR umounting $TMPMNT"
cleanup 1
fi
@@ -0,0 +1,11 @@
--- LVM2/make.tmpl.in
+++ LVM2/make.tmpl.in
@@ -395,7 +395,7 @@
( cat $(srcdir)/.exported_symbols; \
if test x$(EXPORTED_HEADER) != x; then \
$(CC) -E -P $(INCLUDES) $(DEFS) $(EXPORTED_HEADER) | \
- $(SED) -ne "/^typedef|}/!s/.*[ *]\($(EXPORTED_FN_PREFIX)_[a-z0-9_]*\)(.*/\1/p"; \
+ LC_ALL=C $(SED) -ne "/^typedef|}/!s/.*[ *]\($(EXPORTED_FN_PREFIX)_[a-z0-9_]*\)(.*/\1/p"; \
fi \
) > $@
@@ -0,0 +1,81 @@
From ab3ae0a22dfbe20e2d17e7dc60e0f76184ec098c Mon Sep 17 00:00:00 2001
From: "Robin H. Johnson" <robbat2@gentoo.org>
Date: Wed, 24 Jul 2019 11:22:32 +0200
Subject: [PATCH] dmeventd configurable idle exit time
dmeventd nominally exits after 1 hour of idle time. There are use cases for
this, esp. with socket activation, but also cases where users don't expect
dmeventd to exit.
Provide a tuning knob via environment variable, DMEVENTD_IDLE_EXIT_TIMEOUT,
that can be -1 to not exit, or a configurable time for different idle exit.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Fixes: https://bugs.gentoo.org/682556
Forward-ported from 2.02.184 to 2.03.05
Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
---
daemons/dmeventd/dmeventd.c | 16 ++++++++++++++--
man/dmeventd.8_main | 4 ++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 33859ef414..ac0b9743fc 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -2158,6 +2158,18 @@ int main(int argc, char *argv[])
.server_path = DM_EVENT_FIFO_SERVER
};
time_t now, idle_exit_timeout = DMEVENTD_IDLE_EXIT_TIMEOUT;
+
+ /* Provide a basic way to config the idle timeout */
+ char* idle_exit_timeout_env = getenv("DMEVENTD_IDLE_EXIT_TIMEOUT") ? : NULL;
+ if(NULL != idle_exit_timeout_env) {
+ char* endptr;
+ idle_exit_timeout = strtol(idle_exit_timeout_env, &endptr, 10);
+ if (errno == ERANGE || *endptr != '\0') {
+ fprintf(stderr, "DMEVENTD_IDLE_EXIT_TIMEOUT: bad time input\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+
opterr = 0;
optind = 0;
@@ -2253,7 +2265,7 @@ int main(int argc, char *argv[])
_process_initial_registrations();
for (;;) {
- if (_idle_since) {
+ if (_idle_since || _exit_now) {
if (_exit_now) {
if (_exit_now == DM_SCHEDULED_EXIT)
break; /* Only prints shutdown message */
@@ -2262,7 +2274,7 @@ int main(int argc, char *argv[])
(long) (time(NULL) - _idle_since));
break;
}
- if (idle_exit_timeout) {
+ if (idle_exit_timeout && idle_exit_timeout > 0) {
now = time(NULL);
if (now < _idle_since)
_idle_since = now; /* clock change? */
diff --git a/man/dmeventd.8_main b/man/dmeventd.8_main
index dc4abf627e..4b0e522041 100644
--- a/man/dmeventd.8_main
+++ b/man/dmeventd.8_main
@@ -178,6 +178,10 @@ is processed.
Variable is set by thin and vdo plugin to prohibit recursive interation
with dmeventd by any executed lvm2 command from
a thin_command, vdo_command environment.
+.TP
+.B DMEVENTD_IDLE_EXIT_TIMEOUT
+Configure the dmeventd idle exit timeout behavior, value in seconds. Default
+is 3600 (1 hour). -1 means do not exit.
.
.SH SEE ALSO
.
--
2.22.0
@@ -0,0 +1,75 @@
From 93101699f5e1190184c00c99ab7b6e9717e5019a Mon Sep 17 00:00:00 2001
From: "Robin H. Johnson" <robbat2@gentoo.org>
Date: Wed, 24 Jul 2019 11:11:35 +0200
Subject: [PATCH] Add dynamic static ldflags
Forward-ported from 2.02.178 to 2.03.05
Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
---
configure.ac | 2 ++
daemons/dmeventd/Makefile.in | 2 +-
make.tmpl.in | 1 +
tools/Makefile.in | 2 +-
4 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 1e45c0edcb..cc2625294a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,7 @@ case "$host_os" in
CLDFLAGS="${CLDFLAGS:"$LDFLAGS"} -Wl,--version-script,.export.sym"
# equivalent to -rdynamic
ELDFLAGS="-Wl,--export-dynamic"
+ STATIC_LDFLAGS="-Wl,--no-export-dynamic"
# FIXME Generate list and use --dynamic-list=.dlopen.sym
CLDWHOLEARCHIVE="-Wl,-whole-archive"
CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
@@ -1758,6 +1759,7 @@ AC_SUBST(SYSCONFDIR)
AC_SUBST(SYSTEMD_LIBS)
AC_SUBST(SNAPSHOTS)
AC_SUBST(STATICDIR)
+AC_SUBST(STATIC_LDFLAGS)
AC_SUBST(STATIC_LINK)
AC_SUBST(TESTSUITE_DATA)
AC_SUBST(THIN)
diff --git a/daemons/dmeventd/Makefile.in b/daemons/dmeventd/Makefile.in
index 6bd36d0325..a3c30ec1a0 100644
--- a/daemons/dmeventd/Makefile.in
+++ b/daemons/dmeventd/Makefile.in
@@ -66,7 +66,7 @@ dmeventd: $(LIB_SHARED) dmeventd.o
dmeventd.static: $(LIB_STATIC) dmeventd.o
@echo " [CC] $@"
- $(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L. -L$(interfacebuilddir) dmeventd.o \
+ $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L. -L$(interfacebuilddir) dmeventd.o \
-o $@ $(DL_LIBS) $(DMEVENT_LIBS) $(LIBS) $(STATIC_LIBS)
ifeq ("@PKGCONFIG@", "yes")
diff --git a/make.tmpl.in b/make.tmpl.in
index f3332e91c1..1489c2afad 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -68,6 +68,7 @@ DEFS += @DEFS@
# FIXME set this only where it's needed, not globally?
CFLAGS ?= @COPTIMISE_FLAG@ @CFLAGS@
LDFLAGS ?= @LDFLAGS@
+STATIC_LDFLAGS += @STATIC_LDFLAGS@
CLDFLAGS += @CLDFLAGS@
ELDFLAGS += @ELDFLAGS@
LDDEPS += @LDDEPS@
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 2620daa17c..e5fc9c4ae4 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -136,7 +136,7 @@ man-generator: man-generator.o
lvm.static: $(OBJECTS) lvm-static.o $(LVMINTERNAL_LIBS)
@echo " [CC] $@"
- $(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ $+ \
+ $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static -L$(interfacebuilddir) -o $@ $+ \
$(DMEVENT_LIBS) $(STATIC_LIBS) $(LVMLIBS)
liblvm2cmd.a: $(top_builddir)/lib/liblvm-internal.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
--
2.22.0
@@ -0,0 +1,48 @@
From dbb68df8d02eff87f10df331e17bd0940e158f56 Mon Sep 17 00:00:00 2001
From: "Robin H. Johnson" <robbat2@gentoo.org>
Date: Wed, 24 Jul 2019 11:15:59 +0200
Subject: [PATCH] Add pthread to libdevmapper pkgconfig file
Forward-ported from 2.02.176 to 2.03.05
Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
---
libdm/libdevmapper.pc.in | 2 +-
tools/Makefile.in | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/libdm/libdevmapper.pc.in b/libdm/libdevmapper.pc.in
index a325aeb9e0..aa0980378f 100644
--- a/libdm/libdevmapper.pc.in
+++ b/libdm/libdevmapper.pc.in
@@ -9,4 +9,4 @@ Version: @DM_LIB_PATCHLEVEL@
Cflags: -I${includedir}
Libs: -L${libdir} -ldevmapper
Requires.private: @SELINUX_PC@ @UDEV_PC@
-Libs.private: -lm @RT_LIBS@
+Libs.private: -lm @RT_LIBS@ @PTHREAD_LIBS@
diff --git a/tools/Makefile.in b/tools/Makefile.in
index e5fc9c4ae4..12e4de2c63 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -87,6 +87,7 @@ ifeq ("@STATIC_LINK@", "yes")
TARGETS += lvm.static
INSTALL_LVM_TARGETS += install_tools_static
INSTALL_CMDLIB_TARGETS += install_cmdlib_static
+ STATIC_LIBS += @PTHREAD_LIBS@
endif
LVMLIBS = $(SYSTEMD_LIBS) -L$(top_builddir)/libdm -ldevmapper $(LIBS) -laio
@@ -113,6 +114,10 @@ CFLOW_TARGET = lvm
include $(top_builddir)/make.tmpl
+ifeq ("@STATIC_LINK@", "yes")
+ STATIC_LIBS += @PTHREAD_LIBS@
+endif
+
device-mapper:
all: device-mapper
--
2.22.0
+24 -2
View File
@@ -12,17 +12,29 @@
<IsA>app:console</IsA>
<Summary>Userland logical volume management tools</Summary>
<Description>LVM2 includes all of the support for handling read/write operations physical and logical volumes.</Description>
<Archive sha1sum="35b7358ebefefbf1fceb50bf282c328203248bdb" type="targz">ftp://sources.redhat.com/pub/lvm2/LVM2.2.02.167.tgz</Archive>
<Archive sha1sum="7a3834ca1ddaa7c4edc3863f18ec604f45722c65" type="targz">http://mirrors.kernel.org/sourceware/lvm2/LVM2.2.02.186.tgz</Archive>
<BuildDependencies>
<Dependency>libutil-linux-devel</Dependency>
<Dependency>eudev-devel</Dependency>
<Dependency>autoconf-archive</Dependency>
<Dependency>libaio-devel</Dependency>
<!-- <Dependency>thin-provisioning-tools</Dependency> -->
</BuildDependencies>
<Patches>
<!--<Patch level="1">lvm2-2.02.63-always-make-static-libdm.patch</Patch>
<Patch level="1">lvm2-2.02.92-dynamic-static-ldflags.patch</Patch>
<Patch level="1">lvm2-2.02.105-pthread-pkgconfig.patch</Patch>
<Patch>lvm2-2.02.106-static-pkgconfig-libs.patch</Patch>-->
<!-- <Patch level="1">lvm2-2.03.05-pthread-pkgconfig.patch</Patch> -->
<!-- <Patch level="1">lvm2-2.03.05-dynamic-static-ldflags.patch</Patch> -->
<!-- <Patch level="1">lvm2-2.03.05-dmeventd-no-idle-exit.patch</Patch> -->
<Patch level="1">lvm2-2.02.178-static-pkgconfig-libs.patch</Patch>
<Patch level="1">lvm2-2.02.56-lvm2create_initrd.patch</Patch>
<Patch level="1">lvm2-2.02.67-createinitrd.patch</Patch>
<Patch level="1">lvm2-2.02.99-locale-muck.patch</Patch>
<Patch level="1">lvm2-2.02.171-static-libm.patch</Patch>
<Patch level="1">lvm2-2.02.166-HPPA-no-O_DIRECT.patch</Patch>
<Patch level="1">lvm2-2.02.184-mksh_build.patch</Patch>
</Patches>
</Source>
@@ -54,7 +66,7 @@
<Description>Device-mapper-devel contains files needed to develop applications that use the device-mapper libraries.</Description>
<RuntimeDependencies>
<Dependency release="current" >device-mapper</Dependency>
<Dependency>eudev-devel</Dependency>
<Dependency>eudev-devel</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="header">/usr/include/libdevmapper.h</Path>
@@ -73,6 +85,9 @@
<Path fileType="executable">/usr/sbin/dmeventd</Path>
<Path fileType="library">/usr/lib/libdevmapper-event.a</Path>
<Path fileType="library">/usr/lib/libdevmapper-event.so*</Path>
<Path fileType="library">/usr/lib/libdevmapper-event-lvm2vdo.so</Path>
<Path fileType="library">/usr/lib/device-mapper/libdevmapper-event-lvm2vdo.so</Path>
<Path fileType="library">/usr/lib/libdevmapper-event-lvm2thin.so</Path>
<Path fileType="library">/usr/lib/device-mapper/libdevmapper-event-lvm2thin.so</Path>
<Path fileType="man">/usr/share/man/man8/dmeventd.8</Path>
@@ -189,6 +204,13 @@
</Package>
<History>
<Update release="5">
<Date>2019-12-26</Date>
<Version>2.02.186</Version>
<Comment>Version bump</Comment>
<Name>Kamil Atlı</Name>
<Email>suvarice@pisilinux.org</Email>
</Update>
<Update release="4">
<Date>2018-07-23</Date>
<Version>2.02.167</Version>
+7
View File
@@ -57,6 +57,13 @@
</Package>
<History>
<Update release="6">
<Date>2019-12-27</Date>
<Version>3.4</Version>
<Comment>Rebuild</Comment>
<Name>idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="5">
<Date>2018-10-02</Date>
<Version>3.4</Version>
+7
View File
@@ -27,6 +27,13 @@
</Package>
<History>
<Update release="5">
<Date>2019-12-27</Date>
<Version>4.0.18</Version>
<Comment>Rebuild</Comment>
<Name>idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="4">
<Date>2018-07-15</Date>
<Version>4.0.18</Version>
+6 -5
View File
@@ -10,6 +10,7 @@ from pisi.actionsapi import pisitools
from pisi.actionsapi import get
WorkDir = "linux-firmware"
NoStrip = ["/lib"]
def setup():
# Remove source files
@@ -29,15 +30,15 @@ def install():
pisitools.insinto("/lib/firmware", "mix/*")
# Remove installed and LIC* files from /lib/firmware
pisitools.remove("/lib/firmware/GPL-3")
#pisitools.remove("/lib/firmware/GPL-3")
pisitools.remove("/lib/firmware/LICENCE*")
pisitools.remove("/lib/firmware/LICENSE*")
pisitools.remove("/lib/firmware/configure")
pisitools.remove("/lib/firmware/Makefile")
pisitools.removeDir("/lib/firmware/mix")
#pisitools.remove("/lib/firmware/configure")
#pisitools.remove("/lib/firmware/Makefile")
#pisitools.removeDir("/lib/firmware/mix")
#conflict on alsa-firmware
#pisitools.remove("/lib/firmware/ctefx.bin")
pisitools.remove("/lib/firmware/ctspeq.bin")
# Install LICENSE files
pisitools.dodoc("WHENCE", "LICENCE.*", "LICENSE.*", "GPL-3")
pisitools.dodoc("WHENCE", "LICENCE.*", "LICENSE.*")
+9 -2
View File
@@ -17,8 +17,8 @@
<IsA>data</IsA>
<Summary>Firmware files used by the Linux kernel</Summary>
<Description>linux-firmware contains different firmware files required for some devices to operate correctly.</Description>
<!-- linux-firmware commit: 711d3297bac870af42088a467459a0634c1970ca 2019-05-14 -->
<Archive sha1sum="4711d2c3125580edf46161694439a2eef4fc0cec" type="tarxz">https://sourceforge.net/projects/pisilinux/files/source/linux-firmware-20190514.tar.xz</Archive>
<Archive sha1sum="9313317db68525a3928f64c082eb1a22305b89fb" type="tarxz">https://sourceforge.net/projects/pisilinux/files/source/linux-firmware-20191220.tar.xz</Archive>
<Archive sha1sum="dd685266f7bc0acb0d455462637d23e3e895bc96" type="tarxz" target="linux-firmware/mix">http://source.pisilinux.org/common-fw/common-fw.tar.xz</Archive>
<Archive sha1sum="b2bb7fce3ea67d131f543a48134f7a65f2a8d834" type="tarxz" target="linux-firmware/mix">http://source.pisilinux.org/firmware-ipw/firmware-ipw.tar.xz</Archive>
<Archive sha1sum="a5a616a9f765cf9cbb224deb7ccefdc82a7fe4d9" type="tarbz2" target="linux-firmware/mix">http://source.pisilinux.org/firmware-nonfreebox/firmware-nonfreebox-2-tar.bz2</Archive>
@@ -49,6 +49,13 @@
</Package>
<History>
<Update release="6">
<Date>2019-12-27</Date>
<Version>20191220</Version>
<Comment>Update</Comment>
<Name>Idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="8">
<Date>2019-06-05</Date>
<Version>20190514</Version>
+8 -1
View File
@@ -13,7 +13,7 @@
<IsA>app:console</IsA>
<Summary>This package contains the wireless regulatory database used by all cfg80211 based Linux wireless drivers</Summary>
<Description>This package contains the wireless regulatory database used by all cfg80211 based Linux wireless drivers</Description>
<Archive sha1sum="a4a541f4ef81985e919b15477253f16df997e8d9" type="tarxz">https://mirrors.edge.kernel.org/pub/software/network/wireless-regdb/wireless-regdb-2018.10.24.tar.xz</Archive>
<Archive sha1sum="22520576da73b6282d6cd28fe469913258aecd3f" type="tarxz">https://mirrors.edge.kernel.org/pub/software/network/wireless-regdb/wireless-regdb-2019.06.03.tar.xz</Archive>
</Source>
<Package>
@@ -28,6 +28,13 @@
</Package>
<History>
<Update release="2">
<Date>2019-12-27</Date>
<Version>2019.06.03</Version>
<Comment>Version bump</Comment>
<Name>Idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="1">
<Date>2019-01-15</Date>
<Version>2018.10.24</Version>
+9 -2
View File
@@ -13,7 +13,7 @@
<Summary>Kernel module allowing to switch dedicated graphics card on Optimus laptops</Summary>
<Description>kernel module allowing to switch dedicated graphics card on Optimus laptops</Description>
<BuildDependencies>
<Dependency version="4.19.56">kernel-module-headers</Dependency>
<Dependency version="5.4.6">kernel-module-headers</Dependency>
</BuildDependencies>
<Archive sha1sum="e282ee682d794e3962baa4dead01917c42571e78" type="targz">https://github.com/Bumblebee-Project/bbswitch/archive/v0.8.tar.gz</Archive>
<Patches>
@@ -22,7 +22,7 @@
<Package>
<Name>module-bbswitch</Name>
<RuntimeDependencies>
<Dependency version="4.19.56">kernel</Dependency>
<Dependency version="5.4.6">kernel</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="library" permanent="true">/lib/modules</Path>
@@ -36,6 +36,13 @@
</Package>
<History>
<Update release="27">
<Date>2019-12-27</Date>
<Version>0.8</Version>
<Comment>Rebuild.</Comment>
<Name>Idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="26">
<Date>2019-06-26</Date>
<Version>0.8</Version>
+15
View File
@@ -0,0 +1,15 @@
diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index cdf8c01..63b5650 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -52,6 +52,10 @@ u32 wl_dbg_level = WL_DBG_ERR | WL_DBG_INFO;
u32 wl_dbg_level = WL_DBG_ERR;
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
+#define get_ds() ((mm_segment_t) { (-1UL) })
+#endif
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
static s32 wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
enum nl80211_iftype type, struct vif_params *params);
+10 -2
View File
@@ -15,7 +15,7 @@
<Archive sha1sum="8acbdbb4ab4ab4123d1773b616904798fbef9277" type="targz" target="i686">https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/hybrid-v35-nodebug-pcoem-6_30_223_271.tar.gz</Archive>
<Archive sha1sum="1f568bb989d175813c5631c6629d9479eae6f3be" type="targz" target="x86_64">https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/hybrid-v35_64-nodebug-pcoem-6_30_223_271.tar.gz</Archive>
<BuildDependencies>
<Dependency version="4.19.56">kernel-module-headers</Dependency>
<Dependency version="5.4.6">kernel-module-headers</Dependency>
</BuildDependencies>
<Patches>
<Patch level="1">patch/license.patch</Patch>
@@ -25,13 +25,14 @@
<Patch level="1">linux-4.11.patch</Patch>
<Patch level="1">linux-4.12.patch</Patch>
<Patch level="1">linux-4.15.patch</Patch>
<Patch level="1">linux-5.1.patch</Patch>
</Patches>
</Source>
<Package>
<Name>module-broadcom-wl</Name>
<RuntimeDependencies>
<Dependency version="4.19.56">kernel</Dependency>
<Dependency version="5.4.6">kernel</Dependency>
<Dependency release="current">module-broadcom-wl-userspace</Dependency>
</RuntimeDependencies>
<Files>
@@ -60,6 +61,13 @@
</Package>
<History>
<Update release="26">
<Date>2019-12-27</Date>
<Version>6.30.223.271</Version>
<Comment>Rebuild.</Comment>
<Name>Idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="25">
<Date>2019-06-26</Date>
<Version>6.30.223.271</Version>
@@ -12,9 +12,9 @@
<IsA>driver</IsA>
<Summary>Kernel modules for VirtualBox guest machines</Summary>
<Description>This package provides the kernel modules needed for mouse integration and shared folder support between VirtualBox host and guest systems.</Description>
<Archive sha1sum="95e44a83478c78ab393b4f35f21d8d910f30ee15" type="tarxz">https://sourceforge.net/projects/pisilinux/files/source/module-virtualbox-guest-6.0.14.tar.xz</Archive>
<Archive sha1sum="0318e609411c514de693e1ec80634682cdf9703e" type="tarxz">https://sourceforge.net/projects/pisilinux/files/source/module-virtualbox-guest-6.1.0.tar.xz</Archive>
<BuildDependencies>
<Dependency version="4.19.56">kernel-module-headers</Dependency>
<Dependency version="5.4.6">kernel-module-headers</Dependency>
</BuildDependencies>
<Patches>
<!-- <Patch>vboxsf-make.patch</Patch> -->
@@ -24,7 +24,7 @@
<Package>
<Name>module-virtualbox-guest</Name>
<RuntimeDependencies>
<Dependency version="4.19.56">kernel</Dependency>
<Dependency version="5.4.6">kernel</Dependency>
<Dependency>baselayout</Dependency>
<Dependency version="current">module-virtualbox-guest-userspace</Dependency>
</RuntimeDependencies>
@@ -55,6 +55,13 @@
</Package>
<History>
<Update release="47">
<Date>2019-12-27</Date>
<Version>6.1.0</Version>
<Comment>Version bump.</Comment>
<Name>Idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="46">
<Date>2019-10-29</Date>
<Version>6.0.14</Version>
+10 -3
View File
@@ -12,9 +12,9 @@
<IsA>driver</IsA>
<Summary>Kernel modules for VirtualBox</Summary>
<Description>This package provides the kernel support for VirtualBox.</Description>
<Archive sha1sum="40bc8280cba8430bd7ceb7896dffd1da44d917f1" type="tarxz">https://sourceforge.net/projects/pisilinux/files/source/module-virtualbox-6.0.14.tar.xz</Archive>
<Archive sha1sum="70b6edc22bcc71c3c33893db795219237e03d9ca" type="tarxz">https://sourceforge.net/projects/pisilinux/files/source/module-virtualbox-6.1.0.tar.xz</Archive>
<BuildDependencies>
<Dependency version="4.19.56">kernel-module-headers</Dependency>
<Dependency version="5.4.6">kernel-module-headers</Dependency>
</BuildDependencies>
<!--Patches>
<Patch>vbox_linux-4.3.diff</Patch>
@@ -24,7 +24,7 @@
<Package>
<Name>module-virtualbox</Name>
<RuntimeDependencies>
<Dependency version="4.19.56">kernel</Dependency>
<Dependency version="5.4.6">kernel</Dependency>
<Dependency version="current">module-virtualbox-userspace</Dependency>
</RuntimeDependencies>
<Files>
@@ -50,6 +50,13 @@
</Package>
<History>
<Update release="47">
<Date>2019-12-27</Date>
<Version>6.1.0</Version>
<Comment>Version bump.</Comment>
<Name>Idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="46">
<Date>2019-10-29</Date>
<Version>6.0.14</Version>
@@ -0,0 +1,69 @@
diff --git a/ndiswrapper/driver/ntoskernel.c b/ndiswrapper/driver/ntoskernel.c
index 4fe0dc1..4dd7a89 100644
--- a/ndiswrapper/driver/ntoskernel.c
+++ b/ndiswrapper/driver/ntoskernel.c
@@ -2524,7 +2524,11 @@ int ntoskernel_init(void)
info->task = NULL;
info->count = 0;
#ifdef CONFIG_SMP
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0)
cpumask_setall(&info->cpus_allowed);
+#else
+ cpumask_setall(&info->cpus_mask);
+#endif
#endif
}
} while (0);
diff --git a/ndiswrapper/driver/ntoskernel.h b/ndiswrapper/driver/ntoskernel.h
index 3c4c6ff..8a71ae3 100644
--- a/ndiswrapper/driver/ntoskernel.h
+++ b/ndiswrapper/driver/ntoskernel.h
@@ -107,7 +107,11 @@ static cpumask_t cpumasks[NR_CPUS];
#endif /* CONFIG_SMP */
#ifndef tsk_cpus_allowed
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0)
#define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
+#else
+#define tsk_cpus_allowed(tsk) (&(tsk)->cpus_mask)
+#endif
#endif
#ifndef __packed
@@ -631,7 +635,12 @@ struct irql_info {
int count;
struct mutex lock;
#ifdef CONFIG_SMP
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0)
cpumask_t cpus_allowed;
+#else
+ const cpumask_t *cpus_ptr;
+ cpumask_t cpus_mask;
+#endif
#endif
struct task_struct *task;
};
@@ -658,7 +667,11 @@ static inline KIRQL raise_irql(KIRQL newirql)
/* TODO: is this enough to pin down to current cpu? */
#ifdef CONFIG_SMP
assert(task_cpu(current) == smp_processor_id());
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0)
cpumask_copy(&info->cpus_allowed, tsk_cpus_allowed(current));
+#else
+ cpumask_copy(&info->cpus_mask, tsk_cpus_allowed(current));
+#endif
set_cpus_allowed_ptr(current, cpumask_of(smp_processor_id()));
#endif
put_cpu_var(irql_info);
@@ -682,7 +695,11 @@ static inline void lower_irql(KIRQL oldirql)
if (--info->count == 0) {
info->task = NULL;
#ifdef CONFIG_SMP
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,3,0)
set_cpus_allowed_ptr(current, &info->cpus_allowed);
+#else
+ set_cpus_allowed_ptr(current, &info->cpus_mask);
+#endif
#endif
mutex_unlock(&info->lock);
}
@@ -0,0 +1,22 @@
diff -u -r ndiswrapper-1.62/driver/wrapndis.c ndiswrapper-1.62-5.4/driver/wrapndis.c
--- ndiswrapper-1.62/driver/wrapndis.c 2019-02-11 04:11:14.000000000 +0000
+++ ndiswrapper-1.62-5.4/driver/wrapndis.c 2019-11-26 00:02:39.035464963 +0000
@@ -457,10 +457,18 @@
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
sg_element++;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
sg_element->length = frag->size;
+#else
+ sg_element->length = skb_frag_size(frag);
+#endif
sg_element->address =
pci_map_page(wnd->wd->pci.pdev, skb_frag_page(frag),
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,4,0)
frag->page_offset, frag->size,
+#else
+ skb_frag_off(frag), skb_frag_size(frag),
+#endif
PCI_DMA_TODEVICE);
TRACE3("%llx, %u", sg_element->address, sg_element->length);
}
+13 -7
View File
@@ -15,19 +15,18 @@
<Description>module-ndiswrapper allows you to use Windows XP drivers for WLAN cards without proper Linux drivers.</Description>
<Archive sha1sum="d98b97ff7e88d39b7966b4a3e7b7deeb7dc6e192" type="targz">http://download.sourceforge.net/ndiswrapper/ndiswrapper-1.62.tar.gz</Archive>
<BuildDependencies>
<Dependency version="4.19.56">kernel-module-headers</Dependency>
<Dependency version="5.4.6">kernel-module-headers</Dependency>
</BuildDependencies>
<!--Patches>
<Patch>linux-4.11.patch</Patch>
<Patch>linux-4.13.patch</Patch>
<Patch>linux-4.15.patch</Patch>
</Patches-->
<Patches>
<Patch>kernel-5.3.patch</Patch>
<Patch>kernel-5.4.patch</Patch>
</Patches>
</Source>
<Package>
<Name>ndiswrapper</Name>
<RuntimeDependencies>
<Dependency version="4.19.56">kernel</Dependency>
<Dependency version="5.4.6">kernel</Dependency>
</RuntimeDependencies>
<Files>
<Path fileType="library" permanent="true">/lib/modules</Path>
@@ -43,6 +42,13 @@
</Package>
<History>
<Update release="27">
<Date>2019-12-27</Date>
<Version>1.62</Version>
<Comment>Rebuild</Comment>
<Name>Idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="26">
<Date>2019-06-26</Date>
<Version>1.62</Version>
View File
+9968 -7325
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -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,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)
@@ -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/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:
View File
+23 -8
View File
@@ -12,7 +12,7 @@
<IsA>kernel</IsA>
<Summary>The Linux kernel (the core of the Linux operating system) for Pisi Linux</Summary>
<Description>kernel contains the Linux kernel, the core of any Linux operating system. The kernel handles the basic functions of the operating system: memory allocation, process allocation, device input and output, etc.</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>
<AdditionalFiles>
<AdditionalFile target="configs/kernel-i686-config">configs/kernel-i686-config</AdditionalFile>
<AdditionalFile target="configs/kernel-x86_64-config">configs/kernel-x86_64-config</AdditionalFile>
@@ -29,16 +29,20 @@
<Dependency>zlib-devel</Dependency>
<Dependency>xz-devel</Dependency>
<Dependency>openssl-devel</Dependency>
<Dependency>rsync</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>
@@ -94,6 +98,17 @@
</Package>
<History>
<Update release="28">
<Date>2019-12-27</Date>
<Version>5.4.6</Version>
<Comment>Version Bump.</Comment>
<Type package="kernel">security</Type>
<Requires>
<Action package="kernel">systemRestart</Action>
</Requires>
<Name>Idris Kalp</Name>
<Email>idriskalp@gmail.com</Email>
</Update>
<Update release="27">
<Date>2019-06-25</Date>
<Version>4.19.56</Version>
@@ -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

Some files were not shown because too many files have changed in this diff Show More