Commit d93c870bad38e8daaaf9f7e900a13431f24becbb

Authored by Jeremy Fitzhardinge
Committed by Ingo Molnar
1 parent 687c805409

x86: only enable interrupts when kernel state has been set up

The sysenter path tries to enable interrupts immediately.  Unfortunately
this doesn't work in a paravirt environment, because not enough kernel
state has been set up at that point (namely, pointing %fs to the kernel
percpu data segment).  To fix this, defer ENABLE_INTERRUPTS until after
the kernel state has been set up.

Unfortunately this means that we're running with interrupts disabled
for a while without calling the IRQ tracing code, but that can't be
called without setting up %fs either.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 1 changed file with 10 additions and 9 deletions Side-by-side Diff

arch/x86/kernel/entry_32.S
... ... @@ -291,10 +291,10 @@
291 291 movl TSS_sysenter_sp0(%esp),%esp
292 292 sysenter_past_esp:
293 293 /*
294   - * No need to follow this irqs on/off section: the syscall
295   - * disabled irqs and here we enable it straight after entry:
  294 + * Interrupts are disabled here, but we can't trace it until
  295 + * enough kernel state to call TRACE_IRQS_OFF can be called - but
  296 + * we immediately enable interrupts at that point anyway.
296 297 */
297   - ENABLE_INTERRUPTS(CLBR_NONE)
298 298 pushl $(__USER_DS)
299 299 CFI_ADJUST_CFA_OFFSET 4
300 300 /*CFI_REL_OFFSET ss, 0*/
... ... @@ -302,6 +302,7 @@
302 302 CFI_ADJUST_CFA_OFFSET 4
303 303 CFI_REL_OFFSET esp, 0
304 304 pushfl
  305 + orl $X86_EFLAGS_IF, (%esp)
305 306 CFI_ADJUST_CFA_OFFSET 4
306 307 pushl $(__USER_CS)
307 308 CFI_ADJUST_CFA_OFFSET 4
... ... @@ -315,6 +316,11 @@
315 316 CFI_ADJUST_CFA_OFFSET 4
316 317 CFI_REL_OFFSET eip, 0
317 318  
  319 + pushl %eax
  320 + CFI_ADJUST_CFA_OFFSET 4
  321 + SAVE_ALL
  322 + ENABLE_INTERRUPTS(CLBR_NONE)
  323 +
318 324 /*
319 325 * Load the potential sixth argument from user stack.
320 326 * Careful about security.
321 327  
... ... @@ -322,14 +328,12 @@
322 328 cmpl $__PAGE_OFFSET-3,%ebp
323 329 jae syscall_fault
324 330 1: movl (%ebp),%ebp
  331 + movl %ebp,PT_EBP(%esp)
325 332 .section __ex_table,"a"
326 333 .align 4
327 334 .long 1b,syscall_fault
328 335 .previous
329 336  
330   - pushl %eax
331   - CFI_ADJUST_CFA_OFFSET 4
332   - SAVE_ALL
333 337 GET_THREAD_INFO(%ebp)
334 338  
335 339 /* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
... ... @@ -543,9 +547,6 @@
543 547  
544 548 RING0_INT_FRAME # can't unwind into user space anyway
545 549 syscall_fault:
546   - pushl %eax # save orig_eax
547   - CFI_ADJUST_CFA_OFFSET 4
548   - SAVE_ALL
549 550 GET_THREAD_INFO(%ebp)
550 551 movl $-EFAULT,PT_EAX(%esp)
551 552 jmp resume_userspace