arm64: entry: unmask IRQ in el0_sp()
Mark Rutland
reviewerPATCH 1/1 arm64: entry: unmask IRQ in el0_sp()
Currently, the EL0 SP alignment handler masks IRQs unnecessarily. It does so due to historic code sharing of the EL0 SP and PC alignment handlers, and branch predictor hardening applicable to the EL0 SP handler.
We began masking IRQs in the EL0 SP alignment handler in commit:
5dfc6ed27710c42c ("arm64: entry: Apply BP hardening for high-priority synchronous exception")
... as this shared code with the EL0 PC alignment handler, and branch predictor hardening made it necessary to disable IRQs for early parts of the EL0 PC alignment handler. It was not necessary to mask IRQs during EL0 SP alignment exceptions, but it was not considered harmful to do so.
This masking was carried forward into C code in commit:
582f95835a8fc812 ("arm64: entry: convert el0_sync to C")
... where the SP/PC cases were split into separate handlers, and the masking duplicated.
Subsequently the EL0 PC alignment handler was refactored to perform branch predictor hardening before unmasking IRQs, in commit:
bfe298745afc9548 ("arm64: entry-common: don't touch daif before bp-hardening")
... but the redundant masking of IRQs was not removed from the EL0 SP alignment handler.
Let's do so now, and make it interruptible as with most other synchronous exception handlers.
--- arch/arm64/kernel/entry-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/entry-common.c +1 -1
@@ -175,7 +175,7 @@ NOKPROBE_SYMBOL(el0_pc); static void notrace el0_sp(struct pt_regs *regs, unsigned long esr) {user_exit_irqoff (); -local_daif_restore (DAIF_PROCCTX_NOIRQ ); +local_daif_restore (DAIF_PROCCTX );do_sp_pc_abort (regs->sp, esr, regs); }NOKPROBE_SYMBOL (el0_sp);
Signature · 7 lines
2.11.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Mark,
Quoted 21 lines · Mark Rutland
Currently, the EL0 SP alignment handler masks IRQs unnecessarily. It does so due to historic code sharing of the EL0 SP and PC alignment handlers, and branch predictor hardening applicable to the EL0 SP handler.
We began masking IRQs in the EL0 SP alignment handler in commit:
5dfc6ed27710c42c("arm64: entry: Apply BP hardening for high-priority synchronous exception")... as this shared code with the EL0 PC alignment handler, and branch predictor hardening made it necessary to disable IRQs for early parts of the EL0 PC alignment handler. It was not necessary to mask IRQs during EL0 SP alignment exceptions, but it was not considered harmful to do so.
This masking was carried forward into C code in commit:
582f95835a8fc812("arm64: entry: convertel0_syncto C")... where the SP/PC cases were split into separate handlers, and the masking duplicated.
Quoted 7 lines
Subsequently the EL0 PC alignment handler was refactored to perform branch predictor hardening before unmasking IRQs, in commit:
bfe298745afc9548("arm64: entry-common: don't touch daif before bp-hardening")... but the redundant masking of IRQs was not removed from the EL0 SP alignment handler.
Bother.
Quoted 2 lines
Let's do so now, and make it interruptible as with most other synchronous exception handlers.
I think you want:
on this as, bfe298745afc9548 changed the behaviour: local_daif_restore(DAIF_PROCCTX) was called before arm64_notify_die(), now its not.
With that,
Thanks!
James
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mark Rutland
reviewerQuoted 38 lines · James Morse
Hi Mark,
Quoted 21 lines · Mark Rutland
Currently, the EL0 SP alignment handler masks IRQs unnecessarily. It does so due to historic code sharing of the EL0 SP and PC alignment handlers, and branch predictor hardening applicable to the EL0 SP handler.
We began masking IRQs in the EL0 SP alignment handler in commit:
5dfc6ed27710c42c("arm64: entry: Apply BP hardening for high-priority synchronous exception")... as this shared code with the EL0 PC alignment handler, and branch predictor hardening made it necessary to disable IRQs for early parts of the EL0 PC alignment handler. It was not necessary to mask IRQs during EL0 SP alignment exceptions, but it was not considered harmful to do so.
This masking was carried forward into C code in commit:
582f95835a8fc812("arm64: entry: convertel0_syncto C")... where the SP/PC cases were split into separate handlers, and the masking duplicated.
Quoted 7 lines
Subsequently the EL0 PC alignment handler was refactored to perform branch predictor hardening before unmasking IRQs, in commit:
bfe298745afc9548("arm64: entry-common: don't touch daif before bp-hardening")... but the redundant masking of IRQs was not removed from the EL0 SP alignment handler.
Bother.
Quoted 2 lines
Let's do so now, and make it interruptible as with most other synchronous exception handlers.
Quoted 8 lines
I think you want:
Fixes bfe298745afc9548 ("arm64: entry-common: don't touch daif before bp-hardening")on this as,
bfe298745afc9548changed the behaviour:local_daif_restore(DAIF_PROCCTX)was called beforearm64_notify_die(), now its not.With that,
Reviewed-by James Morse <[email protected]>
Ah; I missed that subtlety.
I assume that Catalin can fold those in when applying. Otherwise I'll add them for a v2.
Thanks,
Mark.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Will Deacon
maintainerQuoted 11 lines · Mark Rutland
Quoted 10 lines · James Morse
Quoted 2 lines · Mark Rutland
Let's do so now, and make it interruptible as with most other synchronous exception handlers.
I think you want:
Fixes bfe298745afc9548 ("arm64: entry-common: don't touch daif before bp-hardening")on this as,
bfe298745afc9548changed the behaviour:local_daif_restore(DAIF_PROCCTX)was called beforearm64_notify_die(), now its not.
Quoted 7 lines
Quoted 2 lines
With that,
Reviewed-by James Morse <[email protected]>Ah; I missed that subtlety.
I assume that Catalin can fold those in when applying. Otherwise I'll add them for a v2.
If you want v2 to go in as a fix, please can you explain why this is a problem (beyond disabling interrupts for longer than necessary) in the commit message?
Cheers,
Will
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Mark, Will,
Quoted 15 lines · Will Deacon
Quoted 14 lines · Mark Rutland
Quoted 12 lines · James Morse
Quoted 2 lines · Mark Rutland
Let's do so now, and make it interruptible as with most other synchronous exception handlers.
I think you want:
Fixes bfe298745afc9548 ("arm64: entry-common: don't touch daif before bp-hardening")on this as,
bfe298745afc9548changed the behaviour:local_daif_restore(DAIF_PROCCTX)was called beforearm64_notify_die(), now its not.With that,
Reviewed-by James Morse <[email protected]>
Quoted 8 lines
Quoted 4 lines
Ah; I missed that subtlety.
I assume that Catalin can fold those in when applying. Otherwise I'll add them for a v2.
If you want v2 to go in as a fix, please can you explain why this is a problem (beyond disabling interrupts for longer than necessary) in the commit message?
Good news, its not broken. I wrongly-assumed calling arm64_notify_die() and then force_sig_fault() with both IRQ-unmasked and IRQ-masked would lead to problems, but the guts of force_sig_fault() is all wrapped in spin_lock_irqsave().
Thanks,
James
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Mark Rutland
reviewerQuoted 23 lines · James Morse
Hi Mark, Will,
Quoted 20 lines · Will Deacon
Quoted 18 lines · Mark Rutland
Quoted 4 lines · James Morse
Quoted 2 lines · Mark Rutland
Let's do so now, and make it interruptible as with most other synchronous exception handlers.
Quoted 8 lines
I think you want:
Fixes bfe298745afc9548 ("arm64: entry-common: don't touch daif before bp-hardening")on this as,
bfe298745afc9548changed the behaviour:local_daif_restore(DAIF_PROCCTX)was called beforearm64_notify_die(), now its not.With that,
Reviewed-by James Morse <[email protected]>Ah; I missed that subtlety.
I assume that Catalin can fold those in when applying. Otherwise I'll add them for a v2.
Quoted 7 lines
Quoted 3 lines
If you want v2 to go in as a fix, please can you explain why this is a problem (beyond disabling interrupts for longer than necessary) in the commit message?
Good news, its not broken. I wrongly-assumed calling
arm64_notify_die()and thenforce_sig_fault()with both IRQ-unmasked and IRQ-masked would lead to problems, but the guts offorce_sig_fault()is all wrapped inspin_lock_irqsave().
Thanks for delving into that.
Catalin, are you happy to queue the patch for v5.7 with James' R-b (but not the Fixes tag), and/or would you like me to send a v2 with that?
Thanks,
Mark.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Catalin Marinas
maintainerQuoted 28 lines · Mark Rutland
Quoted 27 lines · James Morse
Hi Mark, Will,
Quoted 23 lines · Will Deacon
Quoted 11 lines · Mark Rutland
Quoted 10 lines · James Morse
Quoted 2 lines · Mark Rutland
Let's do so now, and make it interruptible as with most other synchronous exception handlers.
I think you want:
Fixes bfe298745afc9548 ("arm64: entry-common: don't touch daif before bp-hardening")on this as,
bfe298745afc9548changed the behaviour:local_daif_restore(DAIF_PROCCTX)was called beforearm64_notify_die(), now its not.Quoted 7 lines
Quoted 2 lines
With that,
Reviewed-by James Morse <[email protected]>Ah; I missed that subtlety.
I assume that Catalin can fold those in when applying. Otherwise I'll add them for a v2.
If you want v2 to go in as a fix, please can you explain why this is a problem (beyond disabling interrupts for longer than necessary) in the commit message?
Quoted 8 lines
Quoted 3 lines
Good news, its not broken. I wrongly-assumed calling
arm64_notify_die()and thenforce_sig_fault()with both IRQ-unmasked and IRQ-masked would lead to problems, but the guts offorce_sig_fault()is all wrapped inspin_lock_irqsave().Thanks for delving into that.
Catalin, are you happy to queue the patch for v5.7 with James' R-b (but not the Fixes tag), and/or would you like me to send a v2 with that?
No need to send a v2. Queued for 5.7. Thanks.
Signature · 6 lines
Catalin _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel