x86/traps: Make interrupt enable/disable symmetric in C code
Traps enable interrupts conditionally but rely on the ASM return code to disable them again. That results in redundant interrupt disable and trace calls. Make the trap handlers disable interrupts before returning to avoid that, which allows simplification of the ASM entry code in follow up changes. Originally-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Acked-by: Andy Lutomirski <luto@kernel.org> Link: https://lkml.kernel.org/r/20200505134903.622702796@linutronix.de
This commit is contained in:
@@ -786,6 +786,8 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
|
||||
|
||||
force_sig_fault(SIGSEGV, si_code, (void __user *)address);
|
||||
|
||||
local_irq_disable();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1384,9 +1386,18 @@ do_page_fault(struct pt_regs *regs, unsigned long hw_error_code,
|
||||
return;
|
||||
|
||||
/* Was the fault on kernel-controlled part of the address space? */
|
||||
if (unlikely(fault_in_kernel_space(address)))
|
||||
if (unlikely(fault_in_kernel_space(address))) {
|
||||
do_kern_addr_fault(regs, hw_error_code, address);
|
||||
else
|
||||
} else {
|
||||
do_user_addr_fault(regs, hw_error_code, address);
|
||||
/*
|
||||
* User address page fault handling might have reenabled
|
||||
* interrupts. Fixing up all potential exit points of
|
||||
* do_user_addr_fault() and its leaf functions is just not
|
||||
* doable w/o creating an unholy mess or turning the code
|
||||
* upside down.
|
||||
*/
|
||||
local_irq_disable();
|
||||
}
|
||||
}
|
||||
NOKPROBE_SYMBOL(do_page_fault);
|
||||
|
Reference in New Issue
Block a user