linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Vivian Wang <wangruikang@iscas.ac.cn>
Cc: Karl Mehltretter <kmehltretter@gmail.com>,
	Andy Chiu <tchiu@tenstorrent.com>,
	spacemit@lists.linux.dev, linux-riscv@lists.infradead.org
Subject: Re: Random corruption on SpacemiT K1 (and K3) with RVV
Date: Wed, 4 Nov 2026 22:35:29 +0100	[thread overview]
Message-ID: <auulITfR8BrabdVF@aurel32.net> (raw)
In-Reply-To: <ato_lUcnuZV30Mtj@aurel32.net>

Hi,

I have finally been able to capture the last few exceptions happening 
for one event where the vectored user copy code is corrupting data. That 
was on the SpacemiT K1.

I added a hook to handle_exception(), activated only when 
__asm_vector_usercopy_sum_enabled is running, and recording CPU state at 
the beginning of the exception, in per-CPU 16-entry tables.
On the OpenSBI side, I also instrumented sbi_trap_handler() to log the 
CAUSE_MISALIGNED_LOAD and CAUSE_LOAD_ACCESS cases. This only fires
during the kernel boot when it tries to measure speed of unaligned 
accesses.

The case I captured was a 4096-byte long copy, from 0x2a883310 
(userland) to 0xffffffd701e54000 (kernel), presumably from a write 
syscall. The copy is considered successful, i.e it exits with a0=0. That 
said after the copy, the source and the destination start to differ 
after the first 16 bytes, at address 0xffffffd701e54010.

The copy started on CPU 5 and ended on CPU 5, and there was only a 
single exception between the start and the end, so it wasn't 
rescheduled.

The exception happened with epc=0xffffffff80e09204, which corresponds to 
the location of the "vle8.v v0,(a1)" instruction. I recorded:
- cause=0xd
- badaddr=0x2a883410
- a0=0xffffffd701e54100
- a1=0x2a883410
- a2=0xf00
- vl=0x100
- vstart=0x0
- vtype=0xc3

As you can see, the exception happened during the second iteration of 
the loop. It is not clear to me why the first iteration didn't trigger a 
page fault, as both 0x2a883310 and 0x2a883410 are on the same 4k page. I 
have also logged the content of v0 at the time of the exception, and I 
can clearly see that only the first 16 bytes (out of 32 bytes) got 
loaded during the previous iteration. Its content matches the error 
reported by GNU as on the userland side.

Then the remaining of the loop continued without exception to copy 4096 
bytes in total.

At this stage, I do not have any other explanation than a CPU bug. That 
said, I have noticed that the problem started when userland started to 
use the vector extension, and with the above, I do not have any 
explanation for the link between the two. I'll try to capture another
corruption event (it takes ages) to see if it can help refine the 
explanation.

Regards
Aurelien

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                     http://aurel32.net

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

      reply	other threads:[~2026-11-04 21:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30 20:52 Random corruption on SpacemiT K1 with RVV and THP Aurelien Jarno
2026-09-08  4:42 ` Random corruption on SpacemiT K1 with RVV Aurelien Jarno
2026-09-09 16:45   ` Random corruption on SpacemiT K1 (and K3) " Aurelien Jarno
2026-09-15 21:14     ` Aurelien Jarno
2026-09-17 19:18       ` Palmer Dabbelt
2026-09-18  4:34         ` Aurelien Jarno
2026-09-22 21:33     ` Andy Chiu
2026-09-24  4:52       ` Aurelien Jarno
2026-09-24  6:15         ` Karl Mehltretter
2026-09-25  4:40           ` Aurelien Jarno
2026-09-28  4:32             ` Aurelien Jarno
2026-09-29  4:07               ` Vivian Wang
2026-10-22 16:53                 ` Aurelien Jarno
2026-11-04 21:35                   ` Aurelien Jarno [this message]

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=auulITfR8BrabdVF@aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=kmehltretter@gmail.com \
    --cc=linux-riscv@lists.infradead.org \
    --cc=spacemit@lists.linux.dev \
    --cc=tchiu@tenstorrent.com \
    --cc=wangruikang@iscas.ac.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;
as well as URLs for NNTP newsgroup(s).