On Tue, 22 Apr 2025, Clément Léger wrote:

> > x86 mostly does the first, any trap that can happen with IRQs disabled
> > is treated unconditionally as NMI like. The obvious exception is
> > page-fault, but that already has a from-non-preemptible-context branch
> > that is 'careful'.
> > 
> > As to unaligned traps from kernel space, I would imagine they mostly BUG
> > the kernel, except when there's an exception entry for that location, in
> > which case it might do a fixup?
> 
> The misaligned access exception handling currently handles misaligned
> access for the kernel as well (except if explicitly disabled).

 It's currently not clear that a kernel mode unaligned access is indeed a 
bug, as some network protocol stacks may still rely on unaligned accesses 
for performance reasons for the regular case where network headers do come 
out aligned[1][2].

 Hopefully not in the hardirq context though, and the usual approach is to 
keep interrupts disabled in the emulation path if arriving from the kernel 
mode as we don't expect kernel code to be ever paged out (the same applies 
to all kinds of machine instruction emulation).

References:

[1] "TCP SYNs broken in 2.3.41", 
    <https://marc.info/?l=linux-kernel&m=94927689929463>

[2] "Alpha: Emulate unaligned LDx_L/STx_C for data consistency", 
    
<https://lore.kernel.org/lkml/87v7rd8h99....@email.froward.int.ebiederm.org/>

 HTH,

  Maciej

Reply via email to