Skip to content

Commit 6ab6463

Browse files
Larry Basselctmarinas
authored andcommitted
arm64: adjust el0_sync so that a function can be called
To implement the context tracker properly on arm64, a function call needs to be made after debugging and interrupts are turned on, but before the lr is changed to point to ret_to_user(). If the function call is made after the lr is changed the function will not return to the correct place. For similar reasons, defer the setting of x0 so that it doesn't need to be saved around the function call (save far_el1 in x26 temporarily instead). Acked-by: Will Deacon <will.deacon@arm.com> Reviewed-by: Kevin Hilman <khilman@linaro.org> Tested-by: Kevin Hilman <khilman@linaro.org> Signed-off-by: Larry Bassel <larry.bassel@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent c0c264a commit 6ab6463

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎arch/arm64/kernel/entry.S‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ el0_sync:
353353
lsr x24, x25, #ESR_EL1_EC_SHIFT // exception class
354354
cmp x24, #ESR_EL1_EC_SVC64 // SVC in 64-bit state
355355
b.eq el0_svc
356-
adr lr, ret_to_user
357356
cmp x24, #ESR_EL1_EC_DABT_EL0 // data abort in EL0
358357
b.eq el0_da
359358
cmp x24, #ESR_EL1_EC_IABT_EL0 // instruction abort in EL0
@@ -382,7 +381,6 @@ el0_sync_compat:
382381
lsr x24, x25, #ESR_EL1_EC_SHIFT // exception class
383382
cmp x24, #ESR_EL1_EC_SVC32 // SVC in 32-bit state
384383
b.eq el0_svc_compat
385-
adr lr, ret_to_user
386384
cmp x24, #ESR_EL1_EC_DABT_EL0 // data abort in EL0
387385
b.eq el0_da
388386
cmp x24, #ESR_EL1_EC_IABT_EL0 // instruction abort in EL0
@@ -425,22 +423,25 @@ el0_da:
425423
/*
426424
* Data abort handling
427425
*/
428-
mrs x0, far_el1
429-
bic x0, x0, #(0xff << 56)
426+
mrs x26, far_el1
430427
// enable interrupts before calling the main handler
431428
enable_dbg_and_irq
429+
bic x0, x26, #(0xff << 56)
432430
mov x1, x25
433431
mov x2, sp
432+
adr lr, ret_to_user
434433
b do_mem_abort
435434
el0_ia:
436435
/*
437436
* Instruction abort handling
438437
*/
439-
mrs x0, far_el1
438+
mrs x26, far_el1
440439
// enable interrupts before calling the main handler
441440
enable_dbg_and_irq
441+
mov x0, x26
442442
orr x1, x25, #1 << 24 // use reserved ISS bit for instruction aborts
443443
mov x2, sp
444+
adr lr, ret_to_user
444445
b do_mem_abort
445446
el0_fpsimd_acc:
446447
/*
@@ -449,6 +450,7 @@ el0_fpsimd_acc:
449450
enable_dbg
450451
mov x0, x25
451452
mov x1, sp
453+
adr lr, ret_to_user
452454
b do_fpsimd_acc
453455
el0_fpsimd_exc:
454456
/*
@@ -457,16 +459,19 @@ el0_fpsimd_exc:
457459
enable_dbg
458460
mov x0, x25
459461
mov x1, sp
462+
adr lr, ret_to_user
460463
b do_fpsimd_exc
461464
el0_sp_pc:
462465
/*
463466
* Stack or PC alignment exception handling
464467
*/
465-
mrs x0, far_el1
468+
mrs x26, far_el1
466469
// enable interrupts before calling the main handler
467470
enable_dbg_and_irq
471+
mov x0, x26
468472
mov x1, x25
469473
mov x2, sp
474+
adr lr, ret_to_user
470475
b do_sp_pc_abort
471476
el0_undef:
472477
/*
@@ -475,6 +480,7 @@ el0_undef:
475480
// enable interrupts before calling the main handler
476481
enable_dbg_and_irq
477482
mov x0, sp
483+
adr lr, ret_to_user
478484
b do_undefinstr
479485
el0_dbg:
480486
/*
@@ -492,6 +498,7 @@ el0_inv:
492498
mov x0, sp
493499
mov x1, #BAD_SYNC
494500
mrs x2, esr_el1
501+
adr lr, ret_to_user
495502
b bad_mode
496503
ENDPROC(el0_sync)
497504

0 commit comments

Comments
 (0)