arm64 fixes:

- Explicitly encode the XZR register if the value passed to
    write_sysreg_s() is 0. The GIC CDEOI instruction is encoded as a
    system register write with XZR as the source register. However, clang
    does not honour the "Z" register constraint, leading to incorrect
    code generation
 
  - Ensure the interrupts (DAIF.IF) are unmasked when completing
    single-step of a suspended breakpoint before calling
    exit_to_user_mode(). With pseudo-NMIs, interrupts are (additionally)
    masked at the PMR_EL1 register, handled by local_irq_*()
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE5RElWfyWxS+3PLO2a9axLQDIXvEFAmjyuF8ACgkQa9axLQDI
 XvEHcg//dlc6sQTq0aEKWDJu9XaCjun3zxQ0O1gNhEc6Y+QQQsV64rdRVPaG2np5
 ZfLWe4NsywmTwJUzinfr9z5U3v57yxo0h4AfM7GIgx2M/7eGNNNC6OEQFxeI+ty4
 Mf+NfnSRhFTrh/4DGZUZniKCVrVO1DWj27PTA09IWvD8pATPx4vtqWUQIym1kXdr
 LHuB3TwRWyGKf0r4QziLedYvjKgBL1kWgdbMZGuN3Wy0lV31w9qGTK8Om6l4jycs
 FNjnWdKnKjfDqoMmAbWHheWWAFB0OGcbikHDTh14vmV2tktK9Ohq/KQUoYoVx2lv
 RV7vvKSGTi7mY51EmE6xBley9WZ9Y+Na1EfUUJia9q8kVBiutvpDJGiHk6sCub7g
 FyHXpgv8Z04uljDKKE19WPnv5vWl7qrI7CAXnVES+8M4bwW4/1hH6lf37U+7Fsh6
 ED/LHZsgyHadHn6rfkgh/5yRKeGmT99w+QYhpv3YmKBNpHyr+KA49x5TBuOMsJc+
 gLGZIOLJOAq7gsFsO4e1is2/rPcYVX/ZAV0HDZHI9fyf65kV2W9hHcYwbCxU5KeB
 rMg9DNQbarKdT9gBNWT4lYpfNlTZQbqJKzPK0yAQLcMxZXaOdMuyknjp7i88Y0gv
 NMbxAOf2yekBT4RCCR7BqudS0KCg/YcoqmS/rOEgv+Zj/hPvuHw=
 =Dn7A
 -----END PGP SIGNATURE-----

Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull arm64 fixes from Catalin Marinas:

 - Explicitly encode the XZR register if the value passed to
   write_sysreg_s() is 0.

   The GIC CDEOI instruction is encoded as a system register write with
   XZR as the source register. However, clang does not honour the "Z"
   register constraint, leading to incorrect code generation

 - Ensure the interrupts (DAIF.IF) are unmasked when completing
   single-step of a suspended breakpoint before calling
   exit_to_user_mode().

   With pseudo-NMIs, interrupts are (additionally) masked at the PMR_EL1
   register, handled by local_irq_*()

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
  arm64: debug: always unmask interrupts in el0_softstp()
  arm64/sysreg: Fix GIC CDEOI instruction encoding
This commit is contained in:
Linus Torvalds 2025-10-17 13:04:21 -10:00
commit f406055cb1
2 changed files with 15 additions and 4 deletions

View File

@ -1220,10 +1220,19 @@
__val; \ __val; \
}) })
/*
* The "Z" constraint combined with the "%x0" template should be enough
* to force XZR generation if (v) is a constant 0 value but LLVM does not
* yet understand that modifier/constraint combo so a conditional is required
* to nudge the compiler into using XZR as a source for a 0 constant value.
*/
#define write_sysreg_s(v, r) do { \ #define write_sysreg_s(v, r) do { \
u64 __val = (u64)(v); \ u64 __val = (u64)(v); \
u32 __maybe_unused __check_r = (u32)(r); \ u32 __maybe_unused __check_r = (u32)(r); \
asm volatile(__msr_s(r, "%x0") : : "rZ" (__val)); \ if (__builtin_constant_p(__val) && __val == 0) \
asm volatile(__msr_s(r, "xzr")); \
else \
asm volatile(__msr_s(r, "%x0") : : "r" (__val)); \
} while (0) } while (0)
/* /*

View File

@ -697,6 +697,8 @@ static void noinstr el0_breakpt(struct pt_regs *regs, unsigned long esr)
static void noinstr el0_softstp(struct pt_regs *regs, unsigned long esr) static void noinstr el0_softstp(struct pt_regs *regs, unsigned long esr)
{ {
bool step_done;
if (!is_ttbr0_addr(regs->pc)) if (!is_ttbr0_addr(regs->pc))
arm64_apply_bp_hardening(); arm64_apply_bp_hardening();
@ -707,10 +709,10 @@ static void noinstr el0_softstp(struct pt_regs *regs, unsigned long esr)
* If we are stepping a suspended breakpoint there's nothing more to do: * If we are stepping a suspended breakpoint there's nothing more to do:
* the single-step is complete. * the single-step is complete.
*/ */
if (!try_step_suspended_breakpoints(regs)) { step_done = try_step_suspended_breakpoints(regs);
local_daif_restore(DAIF_PROCCTX); local_daif_restore(DAIF_PROCCTX);
if (!step_done)
do_el0_softstep(esr, regs); do_el0_softstep(esr, regs);
}
arm64_exit_to_user_mode(regs); arm64_exit_to_user_mode(regs);
} }