mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: George Guo <dongtai.guo@linux.dev>
To: yangtiezhu@loongson.cn
Cc: chenhuacai@kernel.org, guodongtai@kylinos.cn,
	loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] LoongArch: Call fixup_exception() for unaligned accesses
Date: Wed,  2 Dec 2026 05:21:58 -0800	[thread overview]
Message-ID: <20261202132158.39948-1-dongtai.guo@linux.dev> (raw)
In-Reply-To: <20261202081108.20060-1-yangtiezhu@loongson.cn>

On 2026/12/2 16:11, Tiezhu Yang wrote:
> On LoongArch, atomic memory instructions (AM*) require natural
> alignment and always raise EXCCODE_ALE when given an unaligned
> address, whereas unaligned regular loads and stores are either
> handled in hardware or emulated in software.
>
> Consult fixup_exception() on the failure paths of do_ale() and
> emulate_load_store_insn() so that registered exception handlers
> can catch and recover from unaligned access faults.

I tested this on Loongson-3C6000, with the LoongArch BPF arena atomics
series applied, using a new arena_atomics/unaligned subtest that does
32-bit fetch add and fetch or, 64-bit xchg and cmpxchg one byte off an
aligned arena address.

Without this patch, the kernel panics at the first atomic:

  Kernel ale access[#1]:
  ...
    ERA: ffff8000020136f4 bpf_prog_53d40cccca5faaf3_unaligned+0x10c/0x284
  ESTAT: 00090000 [ALE] (IS= ECode=9 EsubCode=0)
   BADV: ffff80008d600001
  ...
  Kernel panic - not syncing: Fatal exception

With this patch, the test passed with both CONFIG_ARCH_STRICT_ALIGN=y
and CONFIG_ARCH_STRICT_ALIGN=n:

  $ sudo ./test_progs -a arena_atomics/unaligned
  #3/10    arena_atomics/unaligned:OK
  #3       arena_atomics:OK
  Summary: 1/1 PASSED, 0 SKIPPED, 0/0 FAILED

Reviewed-by: George Guo <guodongtai@kylinos.cn>
Tested-by: George Guo <guodongtai@kylinos.cn>

I will send the test as a follow-up to this patch.

Thanks,
George

  reply	other threads:[~2026-12-02 13:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  8:11 Tiezhu Yang
2026-12-02 13:21 ` George Guo [this message]
2026-12-02 13:40 ` George Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202132158.39948-1-dongtai.guo@linux.dev \
    --to=dongtai.guo@linux.dev \
    --cc=chenhuacai@kernel.org \
    --cc=guodongtai@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®