@@ -329,117 +329,23 @@ stack_ovf:
329
329
_ASM_NOKPROBE_SYMBOL(stack_ovf)
330
330
#endif
331
331
332
- #ifdef CONFIG_TRACE_IRQFLAGS
333
- trace_syscall_entry_irq_off:
334
- /*
335
- * Syscall shouldn't happen while interrupts are disabled,
336
- * so let's do a warning here.
337
- */
338
- 0: trap
339
- EMIT_BUG_ENTRY 0b,__FILE__ ,__LINE__ , BUGFLAG_WARNING
340
- bl trace_hardirqs_on
341
-
342
- /* Now enable for real */
343
- LOAD_REG_IMMEDIATE(r10, MSR_KERNEL | MSR_EE)
344
- mtmsr r10
345
-
346
- REST_GPR(0 , r1)
347
- REST_4GPRS(3 , r1)
348
- REST_2GPRS(7 , r1)
349
- b DoSyscall
350
- #endif /* CONFIG_TRACE_IRQFLAGS */
351
-
352
332
.globl transfer_to_syscall
353
333
transfer_to_syscall:
354
334
SAVE_NVGPRS(r1)
355
335
#ifdef CONFIG_PPC_BOOK3S_32
356
336
kuep_lock r11, r12
357
337
#endif
358
- #ifdef CONFIG_TRACE_IRQFLAGS
359
- andi. r12,r9,MSR_EE
360
- beq- trace_syscall_entry_irq_off
361
- #endif /* CONFIG_TRACE_IRQFLAGS */
362
338
363
- /*
364
- * Handle a system call.
365
- */
366
- .stabs "arch/powerpc/kernel/" ,N_SO,0 ,0 ,0f
367
- .stabs "entry_32.S" ,N_SO,0 ,0 ,0f
368
- 0:
369
-
370
- _GLOBAL(DoSyscall)
371
- stw r3,ORIG_GPR3(r1)
372
- li r12,0
373
- stw r12,RESULT(r1)
374
- #ifdef CONFIG_TRACE_IRQFLAGS
375
- /* Make sure interrupts are enabled */
376
- mfmsr r11
377
- andi. r12,r11,MSR_EE
378
- /* We came in with interrupts disabled, we WARN and mark them enabled
379
- * for lockdep now */
380
- 0: tweqi r12, 0
381
- EMIT_BUG_ENTRY 0b,__FILE__ ,__LINE__ , BUGFLAG_WARNING
382
- #endif /* CONFIG_TRACE_IRQFLAGS */
383
- lwz r11,TI_FLAGS(r2)
384
- andi. r11,r11,_TIF_SYSCALL_DOTRACE
385
- bne- syscall_dotrace
386
- syscall_dotrace_cont:
387
- cmplwi 0 ,r0,NR_syscalls
388
- lis r10,sys_call_table@h
389
- ori r10,r10,sys_call_table@l
390
- slwi r0,r0,2
391
- bge- 66f
392
-
393
- barrier_nospec_asm
394
- /*
395
- * Prevent the load of the handler below (based on the user-passed
396
- * system call number) being speculatively executed until the test
397
- * against NR_syscalls and branch to .66f above has
398
- * committed.
399
- */
339
+ /* Calling convention has r9 = orig r0, r10 = regs */
340
+ addi r10,r1,STACK_FRAME_OVERHEAD
341
+ mr r9,r0
342
+ stw r10,THREAD+PT_REGS(r2)
343
+ bl system_call_exception
400
344
401
- lwzx r10,r10,r0 /* Fetch system call handler [ptr] */
402
- mtlr r10
403
- addi r9,r1,STACK_FRAME_OVERHEAD
404
- PPC440EP_ERR42
405
- blrl /* Call handler */
406
- .globl ret_from_syscall
407
345
ret_from_syscall:
408
- #ifdef CONFIG_DEBUG_RSEQ
409
- /* Check whether the syscall is issued inside a restartable sequence */
410
- stw r3,GPR3(r1)
411
- addi r3,r1,STACK_FRAME_OVERHEAD
412
- bl rseq_syscall
413
- lwz r3,GPR3(r1)
414
- #endif
415
- mr r6,r3
416
- /* disable interrupts so current_thread_info()->flags can't change */
417
- LOAD_REG_IMMEDIATE(r10,MSR_KERNEL) /* doesn't include MSR_EE */
418
- /* Note: We don't bother telling lockdep about it */
419
- mtmsr r10
420
- lwz r9,TI_FLAGS(r2)
421
- li r8,-MAX_ERRNO
422
- andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
423
- bne- syscall_exit_work
424
- cmplw 0 ,r3,r8
425
- blt+ syscall_exit_cont
426
- lwz r11,_CCR(r1) /* Load CR */
427
- neg r3,r3
428
- oris r11,r11,0x1000 /* Set SO bit in CR */
429
- stw r11,_CCR(r1)
430
- syscall_exit_cont:
431
- lwz r8,_MSR(r1)
432
- #ifdef CONFIG_TRACE_IRQFLAGS
433
- /* If we are going to return from the syscall with interrupts
434
- * off, we trace that here. It shouldn't normally happen.
435
- */
436
- andi. r10,r8,MSR_EE
437
- bne+ 1f
438
- stw r3,GPR3(r1)
439
- bl trace_hardirqs_off
440
- lwz r3,GPR3(r1)
441
- 1:
442
- #endif /* CONFIG_TRACE_IRQFLAGS */
346
+ addi r4,r1,STACK_FRAME_OVERHEAD
347
+ li r5,0
348
+ bl syscall_exit_prepare
443
349
#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
444
350
/* If the process has its own DBCR0 value, load it up. The internal
445
351
debug mode bit tells us that dbcr0 should be loaded. */
@@ -453,44 +359,50 @@ syscall_exit_cont:
453
359
cmplwi cr0,r5,0
454
360
bne- 2f
455
361
#endif /* CONFIG_PPC_47x */
456
- 1:
457
- BEGIN_FTR_SECTION
458
- lwarx r7,0 ,r1
459
- END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
460
- stwcx. r0,0 ,r1 /* to clear the reservation */
461
- ACCOUNT_CPU_USER_EXIT(r2, r5, r7)
462
362
#ifdef CONFIG_PPC_BOOK3S_32
463
363
kuep_unlock r5, r7
464
364
#endif
465
365
kuap_check r2, r4
466
366
lwz r4,_LINK(r1)
467
367
lwz r5,_CCR(r1)
468
368
mtlr r4
469
- mtcr r5
470
369
lwz r7,_NIP(r1)
471
- lwz r2,GPR2(r1)
472
- lwz r1,GPR1(r1)
370
+ lwz r8,_MSR(r1)
371
+ cmpwi r3,0
372
+ lwz r3,GPR3(r1)
473
373
syscall_exit_finish:
474
- #if defined(CONFIG_PPC_8xx) && defined(CONFIG_PERF_EVENTS)
475
- mtspr SPRN_NRI, r0
476
- #endif
477
374
mtspr SPRN_SRR0,r7
478
375
mtspr SPRN_SRR1,r8
376
+
377
+ bne 3f
378
+ mtcr r5
379
+
380
+ 1: lwz r2,GPR2(r1)
381
+ lwz r1,GPR1(r1)
479
382
rfi
480
383
#ifdef CONFIG_40x
481
384
b . /* Prevent prefetch past rfi */
482
385
#endif
483
- _ASM_NOKPROBE_SYMBOL(syscall_exit_finish)
386
+
387
+ 3: mtcr r5
388
+ lwz r4,_CTR(r1)
389
+ lwz r5,_XER(r1)
390
+ REST_NVGPRS(r1)
391
+ mtctr r4
392
+ mtxer r5
393
+ lwz r0,GPR0(r1)
394
+ lwz r3,GPR3(r1)
395
+ REST_8GPRS(4 ,r1)
396
+ lwz r12,GPR12(r1)
397
+ b 1b
398
+
484
399
#ifdef CONFIG_44x
485
400
2: li r7,0
486
401
iccci r0,r0
487
402
stw r7,icache_44x_need_flush@l(r4)
488
403
b 1b
489
404
#endif /* CONFIG_44x */
490
405
491
- 66: li r3,-ENOSYS
492
- b ret_from_syscall
493
-
494
406
.globl ret_from_fork
495
407
ret_from_fork:
496
408
REST_NVGPRS(r1)
@@ -509,82 +421,6 @@ ret_from_kernel_thread:
509
421
li r3,0
510
422
b ret_from_syscall
511
423
512
- /* Traced system call support */
513
- syscall_dotrace:
514
- SAVE_NVGPRS(r1)
515
- li r0,0xc00
516
- stw r0,_TRAP(r1)
517
- addi r3,r1,STACK_FRAME_OVERHEAD
518
- bl do_syscall_trace_enter
519
- /*
520
- * Restore argument registers possibly just changed.
521
- * We use the return value of do_syscall_trace_enter
522
- * for call number to look up in the table (r0).
523
- */
524
- mr r0,r3
525
- lwz r3,GPR3(r1)
526
- lwz r4,GPR4(r1)
527
- lwz r5,GPR5(r1)
528
- lwz r6,GPR6(r1)
529
- lwz r7,GPR7(r1)
530
- lwz r8,GPR8(r1)
531
- REST_NVGPRS(r1)
532
-
533
- cmplwi r0,NR_syscalls
534
- /* Return code is already in r3 thanks to do_syscall_trace_enter() */
535
- bge- ret_from_syscall
536
- b syscall_dotrace_cont
537
-
538
- syscall_exit_work:
539
- andi. r0,r9,_TIF_RESTOREALL
540
- beq+ 0f
541
- REST_NVGPRS(r1)
542
- b 2f
543
- 0: cmplw 0 ,r3,r8
544
- blt+ 1f
545
- andi. r0,r9,_TIF_NOERROR
546
- bne- 1f
547
- lwz r11,_CCR(r1) /* Load CR */
548
- neg r3,r3
549
- oris r11,r11,0x1000 /* Set SO bit in CR */
550
- stw r11,_CCR(r1)
551
-
552
- 1: stw r6,RESULT(r1) /* Save result */
553
- stw r3,GPR3(r1) /* Update return value */
554
- 2: andi. r0,r9,(_TIF_PERSYSCALL_MASK)
555
- beq 4f
556
-
557
- /* Clear per-syscall TIF flags if any are set. */
558
-
559
- li r11,_TIF_PERSYSCALL_MASK
560
- addi r12,r2,TI_FLAGS
561
- 3: lwarx r8,0 ,r12
562
- andc r8,r8,r11
563
- stwcx. r8,0 ,r12
564
- bne- 3b
565
-
566
- 4: /* Anything which requires enabling interrupts? */
567
- andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP)
568
- beq ret_from_except
569
-
570
- /* Re-enable interrupts. There is no need to trace that with
571
- * lockdep as we are supposed to have IRQs on at this point
572
- */
573
- ori r10,r10,MSR_EE
574
- mtmsr r10
575
-
576
- /* Save NVGPRS if they're not saved already */
577
- lwz r4,_TRAP(r1)
578
- andi. r4,r4,1
579
- beq 5f
580
- SAVE_NVGPRS(r1)
581
- li r4,0xc00
582
- stw r4,_TRAP(r1)
583
- 5:
584
- addi r3,r1,STACK_FRAME_OVERHEAD
585
- bl do_syscall_trace_leave
586
- b ret_from_except_full
587
-
588
424
/*
589
425
* System call was called from kernel. We get here with SRR1 in r9.
590
426
* Mark the exception as recoverable once we have retrieved SRR0,
0 commit comments