Skip to content

Commit 657c1ee

Browse files
amlutoIngo Molnar
authored andcommitted
x86/entry/32: Fix entry_INT80_32() to expect interrupts to be on
When I rewrote entry_INT80_32, I thought that int80 was an interrupt gate. It's a trap gate. *facepalm* Thanks to Brian Gerst for pointing out that it's better to change the entry code than to change the gate type. Suggested-by: Brian Gerst <brgerst@gmail.com> Reported-and-tested-by: Borislav Petkov <bp@suse.de> Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Fixes: 150ac78 ("x86/entry/32: Switch INT80 to the new C syscall path") Link: http://lkml.kernel.org/r/dc09d9b574a5c1dcca996847875c73f8341ce0ad.1445035014.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 612bece commit 657c1ee

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

arch/x86/entry/common.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,14 @@ __visible inline void syscall_return_slowpath(struct pt_regs *regs)
351351
* in workloads that use it, and it's usually called from
352352
* do_fast_syscall_32, so forcibly inline it to improve performance.
353353
*/
354-
static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs)
354+
#ifdef CONFIG_X86_32
355+
/* 32-bit kernels use a trap gate for INT80, and the asm code calls here. */
356+
__visible
357+
#else
358+
/* 64-bit kernels use do_syscall_32_irqs_off() instead. */
359+
static
360+
#endif
361+
__always_inline void do_syscall_32_irqs_on(struct pt_regs *regs)
355362
{
356363
struct thread_info *ti = pt_regs_to_thread_info(regs);
357364
unsigned int nr = (unsigned int)regs->orig_ax;
@@ -386,12 +393,14 @@ static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs)
386393
syscall_return_slowpath(regs);
387394
}
388395

389-
/* Handles int $0x80 */
390-
__visible void do_int80_syscall_32(struct pt_regs *regs)
396+
#ifdef CONFIG_X86_64
397+
/* Handles INT80 on 64-bit kernels */
398+
__visible void do_syscall_32_irqs_off(struct pt_regs *regs)
391399
{
392400
local_irq_enable();
393401
do_syscall_32_irqs_on(regs);
394402
}
403+
#endif
395404

396405
/* Returns 0 to return using IRET or 1 to return using SYSEXIT/SYSRETL. */
397406
__visible long do_fast_syscall_32(struct pt_regs *regs)

arch/x86/entry/entry_32.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,13 @@ ENTRY(entry_INT80_32)
345345
SAVE_ALL pt_regs_ax=$-ENOSYS /* save rest */
346346

347347
/*
348-
* User mode is traced as though IRQs are on, and the interrupt gate
349-
* turned them off.
348+
* User mode is traced as though IRQs are on. Unlike the 64-bit
349+
* case, INT80 is a trap gate on 32-bit kernels, so interrupts
350+
* are already on (unless user code is messing around with iopl).
350351
*/
351-
TRACE_IRQS_OFF
352352

353353
movl %esp, %eax
354-
call do_int80_syscall_32
354+
call do_syscall_32_irqs_on
355355
.Lsyscall_32_done:
356356

357357
restore_all:

arch/x86/entry/entry_64_compat.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ ENTRY(entry_INT80_compat)
303303
TRACE_IRQS_OFF
304304

305305
movq %rsp, %rdi
306-
call do_int80_syscall_32
306+
call do_syscall_32_irqs_off
307307
.Lsyscall_32_done:
308308

309309
/* Go back to user mode. */

0 commit comments

Comments
 (0)