[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.2505012126250.31828@angie.orcam.me.uk>
Date: Thu, 1 May 2025 21:41:31 +0100 (BST)
From: "Maciej W. Rozycki" <macro@...am.me.uk>
To: Clément Léger <cleger@...osinc.com>
cc: Peter Zijlstra <peterz@...radead.org>, Alexandre Ghiti <alex@...ti.fr>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>,
"open list:RISC-V ARCHITECTURE" <linux-riscv@...ts.infradead.org>,
"open list:KERNEL SELFTEST FRAMEWORK" <linux-kselftest@...r.kernel.org>,
Jonathan Corbet <corbet@....net>, Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
Shuah Khan <shuah@...nel.org>, Andrew Jones <ajones@...tanamicro.com>,
Samuel Holland <samuel.holland@...ive.com>
Subject: Re: [PATCH 1/5] riscv: misaligned: factorize trap handling
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.fsf@email.froward.int.ebiederm.org/>
HTH,
Maciej
Powered by blists - more mailing lists