]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commit
linux-yocto/6.6: fix AB-INT: QEMU kernel panic: No irq handler for vector
authorBruce Ashfield <bruce.ashfield@gmail.com>
Tue, 2 Jan 2024 04:31:05 +0000 (23:31 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 4 Jan 2024 23:47:04 +0000 (23:47 +0000)
commit6e1d5d1301ae5dbc7fa1a09da831e8e9bf03671c
tree30a641f1896c9fa461dc7191f5096ebcf90c1119
parentd341b4b176f72d4214714ffc7a7a5fc337eb321c
linux-yocto/6.6: fix AB-INT: QEMU kernel panic: No irq handler for vector

Integrating the following commit(s) to linux-yocto/6.6:

1/2 [
    Author: Thomas Gleixner
    Email: tglx@linutronix.de
    Subject: x86/alternatives: Sync core before enabling interrupts
    Date: Thu, 7 Dec 2023 20:49:24 +0100

    text_poke_early() does:

       local_irq_save(flags);
       memcpy(addr, opcode, len);
       local_irq_restore(flags);
       sync_core();

    That's not really correct because the synchronization should happen before
    interrupts are reenabled to ensure that a pending interrupt observes the
    complete update of the opcodes.

    It's not entirely clear whether the interrupt entry provides enough
    serialization already, but moving the sync_core() invocation into interrupt
    disabled region does no harm and is obviously correct.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
]

2/2 [
    Author: Thomas Gleixner
    Email: tglx@linutronix.de
    Subject: x86/alternatives: Disable interrupts and sync when optimizing NOPs in place
    Date: Thu, 7 Dec 2023 20:49:26 +0100

    apply_alternatives() treats alternatives with the ALT_FLAG_NOT flag set
    special as it optimizes the existing NOPs in place.

    Unfortunately this happens with interrupts enabled and does not provide any
    form of core synchronization.

    So an interrupt hitting in the middle of the update and using the affected
    code path will observe a half updated NOP and crash and burn. The following
    3 NOP sequence was observed to expose this crash halfways reliably under
    QEMU 32bit:

       0x90 0x90 0x90

    which is replaced by the optimized 3 byte NOP:

       0x8d 0x76 0x00

    So an interrupt can observe:

       1) 0x90 0x90 0x90 nop nop nop
       2) 0x8d 0x90 0x90 undefined
       3) 0x8d 0x76 0x90 lea    -0x70(%esi),%esi
       4) 0x8d 0x76 0x00 lea     0x0(%esi),%esi

    Where only #1 and #4 are true NOPs. The same problem exists for 64bit obviously.

    Disable interrupts around this NOP optimization and invoke sync_core()
    before reenabling them.

Fixes: 270a69c4485d ("x86/alternative: Support relocations in alternatives")
Reported-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
]

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-kernel/linux/linux-yocto-rt_6.6.bb
meta/recipes-kernel/linux/linux-yocto-tiny_6.6.bb
meta/recipes-kernel/linux/linux-yocto_6.6.bb