Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/mpx: remove bounds exception code

From: Dave Hansen <dave.hansen@linux.intel.com>

MPX is being removed from the kernel due to a lack of support
in the toolchain going forward (gcc).

Remove the other user-visible ABI: signal handling. This code
should basically have been inactive after the prctl()s were
removed, but there may be some small ABI remnants from this code.
Remove it.

Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: x86@kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>

authored by

Dave Hansen and committed by
Dave Hansen
aa9ccb7b 4ba68d00

-74
-74
arch/x86/kernel/traps.c
··· 57 57 #include <asm/mach_traps.h> 58 58 #include <asm/alternative.h> 59 59 #include <asm/fpu/xstate.h> 60 - #include <asm/trace/mpx.h> 61 - #include <asm/mpx.h> 62 60 #include <asm/vm86.h> 63 61 #include <asm/umip.h> 64 62 ··· 428 430 429 431 dotraplinkage void do_bounds(struct pt_regs *regs, long error_code) 430 432 { 431 - const struct mpx_bndcsr *bndcsr; 432 - 433 433 RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU"); 434 434 if (notify_die(DIE_TRAP, "bounds", regs, error_code, 435 435 X86_TRAP_BR, SIGSEGV) == NOTIFY_STOP) ··· 437 441 if (!user_mode(regs)) 438 442 die("bounds", regs, error_code); 439 443 440 - if (!cpu_feature_enabled(X86_FEATURE_MPX)) { 441 - /* The exception is not from Intel MPX */ 442 - goto exit_trap; 443 - } 444 - 445 - /* 446 - * We need to look at BNDSTATUS to resolve this exception. 447 - * A NULL here might mean that it is in its 'init state', 448 - * which is all zeros which indicates MPX was not 449 - * responsible for the exception. 450 - */ 451 - bndcsr = get_xsave_field_ptr(XFEATURE_BNDCSR); 452 - if (!bndcsr) 453 - goto exit_trap; 454 - 455 - trace_bounds_exception_mpx(bndcsr); 456 - /* 457 - * The error code field of the BNDSTATUS register communicates status 458 - * information of a bound range exception #BR or operation involving 459 - * bound directory. 460 - */ 461 - switch (bndcsr->bndstatus & MPX_BNDSTA_ERROR_CODE) { 462 - case 2: /* Bound directory has invalid entry. */ 463 - if (mpx_handle_bd_fault()) 464 - goto exit_trap; 465 - break; /* Success, it was handled */ 466 - case 1: /* Bound violation. */ 467 - { 468 - struct task_struct *tsk = current; 469 - struct mpx_fault_info mpx; 470 - 471 - if (mpx_fault_info(&mpx, regs)) { 472 - /* 473 - * We failed to decode the MPX instruction. Act as if 474 - * the exception was not caused by MPX. 475 - */ 476 - goto exit_trap; 477 - } 478 - /* 479 - * Success, we decoded the instruction and retrieved 480 - * an 'mpx' containing the address being accessed 481 - * which caused the exception. This information 482 - * allows and application to possibly handle the 483 - * #BR exception itself. 484 - */ 485 - if (!do_trap_no_signal(tsk, X86_TRAP_BR, "bounds", regs, 486 - error_code)) 487 - break; 488 - 489 - show_signal(tsk, SIGSEGV, "trap ", "bounds", regs, error_code); 490 - 491 - force_sig_bnderr(mpx.addr, mpx.lower, mpx.upper); 492 - break; 493 - } 494 - case 0: /* No exception caused by Intel MPX operations. */ 495 - goto exit_trap; 496 - default: 497 - die("bounds", regs, error_code); 498 - } 499 - 500 - return; 501 - 502 - exit_trap: 503 - /* 504 - * This path out is for all the cases where we could not 505 - * handle the exception in some way (like allocating a 506 - * table or telling userspace about it. We will also end 507 - * up here if the kernel has MPX turned off at compile 508 - * time.. 509 - */ 510 444 do_trap(X86_TRAP_BR, SIGSEGV, "bounds", regs, error_code, 0, NULL); 511 445 } 512 446