x86: start the MPX removal process
Dave Hansen
maintainercover x86: start the MPX removal process
MPX requires recompiling applications, which requires compiler support. Unfortunately, GCC 9.1 is expected to be be released without support for MPX. This means that there was only a relatively small window where folks could have ever used MPX. It failed to gain wide adoption in the industry, and Linux was the only mainstream OS to ever support it widely.
Support for the feature may also disappear on future processors.
The benefits of keeping the feature in the tree is not worth the ongoing maintenance cost.
It was a fun run, but it's time for it to go. Adios, MPX!
This set starts the process, beginning with the removal of code that is unlikely to cause any collateral damage. The selftests have been causing some trouble, so they along with the APIs are first to go.
This series is also available here, and will get some additional 0day testing to ensure no funkiness:
git://git.kernel.org/pub/scm/linux/kernel/git/daveh/x86-mpx.git mpx-remove-201907
While there's no rocket science in here, this is probably not ready to be pulled until 0day has the weekend to churn on it.
Dave Hansen
maintainerPATCH 1/3 x86/mpx: remove selftests Makefile entry
From: Dave Hansen <[email protected]>
MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).
This is the smallest possible patch to fix some issues that have been reported around running the MPX selftests. It is would also have been part of any removal series, so it is offered first.
---
b/tools/testing/selftests/x86/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/x86/Makefile renamed from tools/testing/selftests/x86/Makefile~mpx-remove-x86-selftests-makefile +1 -1
@@ -11,7 +11,7 @@ CAN_BUILD_X86_64 := $(shell ./check_cc.s CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh $(CC) trivial_program.c -no-pie) TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt test_mremap_vdso \ - check_initial_reg_state sigreturn iopl mpx-mini-test ioperm \ + check_initial_reg_state sigreturn iopl ioperm \ protection_keys test_vdso test_vsyscall mov_ss_trap TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault test_syscall_vdso unwind_vdso \ test_FCMOV test_FCOMI test_FISTTP \
_
tip-bot for Dave Hansen
merge bot[tip:x86/cleanups] x86/mpx: Remove selftests Makefile entry
x86/mpx: Remove selftests Makefile entry
Commit-ID: 48febc03e6c239d96f46d8b38d91863769fc18c8 Gitweb: https://git.kernel.org/tip/48febc03e6c239d96f46d8b38d91863769fc18c8 Author: Dave Hansen <[email protected]> AuthorDate: Fri, 5 Jul 2019 10:53:18 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Mon, 22 Jul 2019 11:54:56 +0200
x86/mpx: Remove selftests Makefile entry
MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).
This is the smallest possible patch to fix some issues that have been reported around running the MPX selftests. It it would also have been part of any removal series, it is offered first.
--- tools/testing/selftests/x86/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/x86/Makefile +1 -1
@@ -11,7 +11,7 @@ CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c) CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh $(CC) trivial_program.c -no-pie) TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt test_mremap_vdso \ - check_initial_reg_state sigreturn iopl mpx-mini-test ioperm \ + check_initial_reg_state sigreturn iopl ioperm \ protection_keys test_vdso test_vsyscall mov_ss_trap \ syscall_arg_fault TARGETS_C_32BIT_ONLY := entry_from_vm86 test_syscall_vdso unwind_vdso \
Dave Hansen
maintainerPATCH 2/3 x86/mpx: remove selftests themselves
In reply to Dave HansenFrom: Dave Hansen <[email protected]>
MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).
Remove the x86 selftests since they have been causing some issues because of their propensity to do some debug-aiding tracepoint mucking.
---
a/tools/testing/selftests/x86/mpx-debug.h | 15 a/tools/testing/selftests/x86/mpx-dig.c | 497 -------- a/tools/testing/selftests/x86/mpx-hw.h | 124 - a/tools/testing/selftests/x86/mpx-mini-test.c | 1613 -------------------------- a/tools/testing/selftests/x86/mpx-mm.h | 10 5 files changed, 2259 deletions(-)
tools/testing/selftests/x86/mpx-debug.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _MPX_DEBUG_H -#define _MPX_DEBUG_H - -#ifndef DEBUG_LEVEL -#define DEBUG_LEVEL 0 -#endif -#define dprintf_level(level, args...) do { if(level <= DEBUG_LEVEL) printf(args); } while(0) -#define dprintf1(args...) dprintf_level(1, args) -#define dprintf2(args...) dprintf_level(2, args) -#define dprintf3(args...) dprintf_level(3, args) -#define dprintf4(args...) dprintf_level(4, args) -#define dprintf5(args...) dprintf_level(5, args) - -#endif /* _MPX_DEBUG_H */
tools/testing/selftests/x86/mpx-dig.c deleted +0 -497
497 lines not on this page · raw message
tools/testing/selftests/x86/mpx-hw.h deleted +0 -124
124 lines not on this page · raw message
tools/testing/selftests/x86/mpx-mini-test.c deleted +0 -1613
1,613 lines not on this page · raw message
tools/testing/selftests/x86/mpx-mm.h deleted +0 -10
@@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _MPX_MM_H -#define _MPX_MM_H - -#define PAGE_SIZE 4096 -#define MB (1UL<<20) - -extern long nr_incore (void *ptr,unsigned long size_bytes); - -#endif /* _MPX_MM_H */
_
tip-bot for Dave Hansen
merge bot[tip:x86/cleanups] x86/mpx: Remove selftests themselves
x86/mpx: Remove selftests themselves
Commit-ID: e28df79ae2dfebf18e08dc66c0948b7950e4368a Gitweb: https://git.kernel.org/tip/e28df79ae2dfebf18e08dc66c0948b7950e4368a Author: Dave Hansen <[email protected]> AuthorDate: Fri, 5 Jul 2019 10:53:20 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Mon, 22 Jul 2019 11:54:56 +0200
x86/mpx: Remove selftests themselves
MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).
Remove the x86 selftests since they have been causing some issues because of their propensity to do some debug-aiding tracepoint mucking.
--- tools/testing/selftests/x86/mpx-debug.h | 15 - tools/testing/selftests/x86/mpx-dig.c | 497 --------- tools/testing/selftests/x86/mpx-hw.h | 124 -- tools/testing/selftests/x86/mpx-mini-test.c | 1613 --------------------------- tools/testing/selftests/x86/mpx-mm.h | 10 - 5 files changed, 2259 deletions(-)
tools/testing/selftests/x86/mpx-debug.h deleted +0 -15
@@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _MPX_DEBUG_H -#define _MPX_DEBUG_H - -#ifndef DEBUG_LEVEL -#define DEBUG_LEVEL 0 -#endif -#define dprintf_level(level, args...) do { if(level <= DEBUG_LEVEL) printf(args); } while(0) -#define dprintf1(args...) dprintf_level(1, args) -#define dprintf2(args...) dprintf_level(2, args) -#define dprintf3(args...) dprintf_level(3, args) -#define dprintf4(args...) dprintf_level(4, args) -#define dprintf5(args...) dprintf_level(5, args) - -#endif /* _MPX_DEBUG_H */
tools/testing/selftests/x86/mpx-dig.c deleted +0 -497
497 lines not on this page · raw message
tools/testing/selftests/x86/mpx-hw.h deleted +0 -124
124 lines not on this page · raw message
tools/testing/selftests/x86/mpx-mini-test.c deleted +0 -1613
1,613 lines not on this page · raw message
tools/testing/selftests/x86/mpx-mm.h deleted +0 -10
@@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _MPX_MM_H -#define _MPX_MM_H - -#define PAGE_SIZE 4096 -#define MB (1UL<<20) - -extern long nr_incore (void *ptr,unsigned long size_bytes); - -#endif /* _MPX_MM_H */
Dave Hansen
maintainerPATCH 3/3 x86/mpx: remove MPX APIs
In reply to Dave HansenFrom: Dave Hansen <[email protected]>
MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).
The first thing we need to do is remove the userspace-visible ABIs so that applications will stop using it. The most visible one are the enable/disable prctl()s. Remove them first.
This is the most minimal and least invasive patch needed to ensure that apps stop using MPX with new kernels.
---
b/include/uapi/linux/prctl.h | 2 +- b/kernel/sys.c | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-)
include/uapi/linux/prctl.h renamed from include/uapi/linux/prctl.h~mpx-remove-apis +1 -1
@@ -181,7 +181,7 @@ struct prctl_mm_map {#define PR_GET_THP_DISABLE 42/* -* Tell the kernel to start/stop helping userspace manage bounds tables. +* No longer implemented, but left here to ensure the numbers stay reserved: */ #define PR_MPX_ENABLE_MANAGEMENT 43#define PR_MPX_DISABLE_MANAGEMENT 44
kernel/sys.c renamed from kernel/sys.c~mpx-remove-apis +2 -14
@@ -103,12 +103,6 @@#ifndef SET_TSC_CTL # define SET_TSC_CTL (a) (-EINVAL)#endif -#ifndef MPX_ENABLE_MANAGEMENT -# define MPX_ENABLE_MANAGEMENT () (-EINVAL) -#endif -#ifndef MPX_DISABLE_MANAGEMENT -# define MPX_DISABLE_MANAGEMENT () (-EINVAL) -#endif #ifndef GET_FP_MODE # define GET_FP_MODE (a) (-EINVAL)#endif
@@ -2456,15 +2450,9 @@ SYSCALL_DEFINE5(prctl, int, option, unsiup_write (&me->mm->mmap_sem);break ;case PR_MPX_ENABLE_MANAGEMENT : -if (arg2 || arg3 || arg4 || arg5) -return -EINVAL ; - error =MPX_ENABLE_MANAGEMENT (); -break ;case PR_MPX_DISABLE_MANAGEMENT : -if (arg2 || arg3 || arg4 || arg5) -return -EINVAL ; - error =MPX_DISABLE_MANAGEMENT (); -break ; +/* No longer implemented: */ +return -EINVAL ;case PR_SET_FP_MODE : error =SET_FP_MODE (me, arg2);break ;
_
tip-bot for Dave Hansen
merge bot[tip:x86/cleanups] x86/mpx: Remove MPX APIs
x86/mpx: Remove MPX APIs
Commit-ID: f240652b6032b48ad7fa35c5e701cc4c8d697c0b Gitweb: https://git.kernel.org/tip/f240652b6032b48ad7fa35c5e701cc4c8d697c0b Author: Dave Hansen <[email protected]> AuthorDate: Fri, 5 Jul 2019 10:53:21 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Mon, 22 Jul 2019 11:54:57 +0200
x86/mpx: Remove MPX APIs
MPX is being removed from the kernel due to a lack of support in the toolchain going forward (gcc).
The first step is to remove the userspace-visible ABIs so that applications will stop using it. The most visible one are the enable/disable prctl()s. Remove them first.
This is the most minimal and least invasive change needed to ensure that apps stop using MPX with new kernels.
--- include/uapi/linux/prctl.h | 2 +- kernel/sys.c | 16 ++-------------- 2 files changed, 3 insertions(+), 15 deletions(-)
include/uapi/linux/prctl.h +1 -1
@@ -181,7 +181,7 @@ struct prctl_mm_map {#define PR_GET_THP_DISABLE 42/* -* Tell the kernel to start/stop helping userspace manage bounds tables. +* No longer implemented, but left here to ensure the numbers stay reserved: */ #define PR_MPX_ENABLE_MANAGEMENT 43#define PR_MPX_DISABLE_MANAGEMENT 44
kernel/sys.c +2 -14
@@ -103,12 +103,6 @@#ifndef SET_TSC_CTL # define SET_TSC_CTL (a) (-EINVAL)#endif -#ifndef MPX_ENABLE_MANAGEMENT -# define MPX_ENABLE_MANAGEMENT () (-EINVAL) -#endif -#ifndef MPX_DISABLE_MANAGEMENT -# define MPX_DISABLE_MANAGEMENT () (-EINVAL) -#endif #ifndef GET_FP_MODE # define GET_FP_MODE (a) (-EINVAL)#endif
@@ -2456,15 +2450,9 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,up_write (&me->mm->mmap_sem);break ;case PR_MPX_ENABLE_MANAGEMENT : -if (arg2 || arg3 || arg4 || arg5) -return -EINVAL ; - error =MPX_ENABLE_MANAGEMENT (); -break ;case PR_MPX_DISABLE_MANAGEMENT : -if (arg2 || arg3 || arg4 || arg5) -return -EINVAL ; - error =MPX_DISABLE_MANAGEMENT (); -break ; +/* No longer implemented: */ +return -EINVAL ;case PR_SET_FP_MODE : error =SET_FP_MODE (me, arg2);break ;
Borislav Petkov
maintainerQuoted 7 lines · Dave Hansen
This series is also available here, and will get some additional 0day testing to ensure no funkiness:
git://git.kernel.org/pub/scm/linux/kernel/git/daveh/x86-mpx.git mpx-remove-201907While there's no rocket science in here, this is probably not ready to be pulled until 0day has the weekend to churn on it.
And whoops, half a year passed. :-)
Should we try removing it again? This time I won't stop until it's gone. :-)
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 10 lines · Borislav Petkov
Quoted 7 lines · Dave Hansen
This series is also available here, and will get some additional 0day testing to ensure no funkiness:
git://git.kernel.org/pub/scm/linux/kernel/git/daveh/x86-mpx.git mpx-remove-201907While there's no rocket science in here, this is probably not ready to be pulled until 0day has the weekend to churn on it.
And whoops, half a year passed. :-)
Quoted 1 line
Should we try removing it again? This time I won't stop until it's gone.
Here's an updated tree:
https://git.kernel.org/pub/scm/linux/kernel/git/daveh/x86-mpx.git/log/?h=mpx-remove-202001
Very lightly tested.
Borislav Petkov
maintainerQuoted 5 lines · Dave Hansen
Here's an updated tree:
https://git.kernel.org/pub/scm/linux/kernel/git/daveh/x86-mpx.git/log/?h=mpx-remove-202001
Very lightly tested.
Thx.
So I merged tip/master into it and did some build smoke testing. The only issue I found is below which happens with an allnoconfig build and the fix is simple:
arch/x86/kernel/alternative.c +1 -0
@@ -21,6 +21,7 @@#include <asm/pgtable.h> #include <asm/mce.h> #include <asm/nmi.h> +#include <asm/insn.h> #include <asm/cacheflush.h> #include <asm/tlbflush.h> #include <asm/io.h>
as apparently the include hell needs to be satisfied again. :)
You could fold it into one of your 4 patches so that you don't break bisection and then either send the pull request directly to Linus next week or I can do that - I'm fine with either.
Provided, of course, there are no other complaints.
Thx.
---
arch/x86/kernel/alternative.c: In function ‘text_poke_loc_init’:
arch/x86/kernel/alternative.c:1172:14: error: storage size of ‘insn’ isn’t known
1172 | struct insn insn;
| ^~~~
arch/x86/kernel/alternative.c:1178:2: error: implicit declaration of function ‘kernel_insn_init’; did you mean ‘kernfs_init’? [-Werror=implicit-function-declaration]
1178 | kernel_insn_init(&insn, emulate, MAX_INSN_SIZE);
| ^~~~~~~~~~~~~~~~
| kernfs_init
arch/x86/kernel/alternative.c:1178:35: error: ‘MAX_INSN_SIZE’ undeclared (first use in this function); did you mean ‘CALL_INSN_SIZE’?
1178 | kernel_insn_init(&insn, emulate, MAX_INSN_SIZE);
| ^~~~~~~~~~~~~
| CALL_INSN_SIZE
arch/x86/kernel/alternative.c:1178:35: note: each undeclared identifier is reported only once for each function it appears in
arch/x86/kernel/alternative.c:1179:2: error: implicit declaration of function ‘insn_get_length’ [-Werror=implicit-function-declaration]
1179 | insn_get_length(&insn);
| ^~~~~~~~~~~~~~~
In file included from ./include/linux/export.h:43,
from ./include/linux/linkage.h:7,
from ./include/linux/kernel.h:8,
from ./include/linux/list.h:9,
from ./include/linux/module.h:12,
from arch/x86/kernel/alternative.c:4:
arch/x86/kernel/alternative.c:1181:10: error: implicit declaration of function ‘insn_complete’; did you mean ‘complete’? [-Werror=implicit-function-declaration]
1181 | BUG_ON(!insn_complete(&insn));
| ^~~~~~~~~~~~~
./include/linux/compiler.h:78:42: note: in definition of macro ‘unlikely’
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
arch/x86/kernel/alternative.c:1181:2: note: in expansion of macro ‘BUG_ON’
1181 | BUG_ON(!insn_complete(&insn));
| ^~~~~~
arch/x86/kernel/alternative.c:1172:14: warning: unused variable ‘insn’ [-Wunused-variable]
1172 | struct insn insn;
| ^~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:266: arch/x86/kernel/alternative.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [scripts/Makefile.build:503: arch/x86/kernel] Error 2
make: *** [Makefile:1694: arch/x86] Error 2
make: *** Waiting for unfinished jobs....Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette