[PATCH 0/4] Fix a segmentation fault also add raid6test for RISC-V support

Chunyan Zhang posted 4 patches 4 months ago
lib/raid6/recov_rvv.c   |  9 +-----
lib/raid6/rvv.c         | 62 +++++++++++++++++++++--------------------
lib/raid6/rvv.h         | 15 ++++++++++
lib/raid6/test/Makefile |  8 ++++++
4 files changed, 56 insertions(+), 38 deletions(-)
[PATCH 0/4] Fix a segmentation fault also add raid6test for RISC-V support
Posted by Chunyan Zhang 4 months ago
The first two patches are fixes. 
The last two are for userspace raid6test support on RISC-V.

The issue fixed in patch 2/4 was probably the same which was spotted by
Charlie [1], I couldn't reproduce it at that time.

When running raid6test in userspace on RISC-V, I saw a segmentation fault,
I used gdb command to print pointer p, it was an unaccessible address.

With patch 2/4, the issue didn't appear anymore.

[1] https://lore.kernel.org/lkml/Z5gJ35pXI2W41QDk@ghost/

Chunyan Zhang (4):
  raid6: riscv: clean up unused header file inclusion
  raid6: riscv: Fix NULL pointer dereference issue
  raid6: riscv: Allow code to be compiled in userspace
  raid6: test: add support for RISC-V

 lib/raid6/recov_rvv.c   |  9 +-----
 lib/raid6/rvv.c         | 62 +++++++++++++++++++++--------------------
 lib/raid6/rvv.h         | 15 ++++++++++
 lib/raid6/test/Makefile |  8 ++++++
 4 files changed, 56 insertions(+), 38 deletions(-)

-- 
2.34.1
Re: [PATCH 0/4] Fix a segmentation fault also add raid6test for RISC-V support
Posted by Alexandre Ghiti 3 months ago
Hi Chunyan,

Patch 2 was merged via fixes, do you plan on resending a new version for 
6.17 that takes into account Palmer's remarks?

Thanks,

Alex

On 6/10/25 12:12, Chunyan Zhang wrote:
> The first two patches are fixes.
> The last two are for userspace raid6test support on RISC-V.
>
> The issue fixed in patch 2/4 was probably the same which was spotted by
> Charlie [1], I couldn't reproduce it at that time.
>
> When running raid6test in userspace on RISC-V, I saw a segmentation fault,
> I used gdb command to print pointer p, it was an unaccessible address.
>
> With patch 2/4, the issue didn't appear anymore.
>
> [1] https://lore.kernel.org/lkml/Z5gJ35pXI2W41QDk@ghost/
>
> Chunyan Zhang (4):
>    raid6: riscv: clean up unused header file inclusion
>    raid6: riscv: Fix NULL pointer dereference issue
>    raid6: riscv: Allow code to be compiled in userspace
>    raid6: test: add support for RISC-V
>
>   lib/raid6/recov_rvv.c   |  9 +-----
>   lib/raid6/rvv.c         | 62 +++++++++++++++++++++--------------------
>   lib/raid6/rvv.h         | 15 ++++++++++
>   lib/raid6/test/Makefile |  8 ++++++
>   4 files changed, 56 insertions(+), 38 deletions(-)
>
Re: [PATCH 0/4] Fix a segmentation fault also add raid6test for RISC-V support
Posted by Chunyan Zhang 3 months ago
Hi Alex,

On Wed, 9 Jul 2025 at 23:18, Alexandre Ghiti <alex@ghiti.fr> wrote:
>
> Hi Chunyan,
>
> Patch 2 was merged via fixes, do you plan on resending a new version for
> 6.17 that takes into account Palmer's remarks?

Yes, I'm preparing the patches these days, just haven't figured out
how to set NSIZE properly for user space.

I probably should split the patchset, send out one today.

Thanks,
Chunyan

>
> Thanks,
>
> Alex
>
> On 6/10/25 12:12, Chunyan Zhang wrote:
> > The first two patches are fixes.
> > The last two are for userspace raid6test support on RISC-V.
> >
> > The issue fixed in patch 2/4 was probably the same which was spotted by
> > Charlie [1], I couldn't reproduce it at that time.
> >
> > When running raid6test in userspace on RISC-V, I saw a segmentation fault,
> > I used gdb command to print pointer p, it was an unaccessible address.
> >
> > With patch 2/4, the issue didn't appear anymore.
> >
> > [1] https://lore.kernel.org/lkml/Z5gJ35pXI2W41QDk@ghost/
> >
> > Chunyan Zhang (4):
> >    raid6: riscv: clean up unused header file inclusion
> >    raid6: riscv: Fix NULL pointer dereference issue
> >    raid6: riscv: Allow code to be compiled in userspace
> >    raid6: test: add support for RISC-V
> >
> >   lib/raid6/recov_rvv.c   |  9 +-----
> >   lib/raid6/rvv.c         | 62 +++++++++++++++++++++--------------------
> >   lib/raid6/rvv.h         | 15 ++++++++++
> >   lib/raid6/test/Makefile |  8 ++++++
> >   4 files changed, 56 insertions(+), 38 deletions(-)
> >
Re: [PATCH 0/4] Fix a segmentation fault also add raid6test for RISC-V support
Posted by Alexandre Ghiti 3 months ago
On 7/10/25 03:44, Chunyan Zhang wrote:
> Hi Alex,
>
> On Wed, 9 Jul 2025 at 23:18, Alexandre Ghiti <alex@ghiti.fr> wrote:
>> Hi Chunyan,
>>
>> Patch 2 was merged via fixes, do you plan on resending a new version for
>> 6.17 that takes into account Palmer's remarks?
> Yes, I'm preparing the patches these days, just haven't figured out
> how to set NSIZE properly for user space.


Just use hwprobe() to make sure V is supported and then csr_read(VLENB) 
to retrieve this value, no?


>
> I probably should split the patchset, send out one today.
>
> Thanks,
> Chunyan
>
>> Thanks,
>>
>> Alex
>>
>> On 6/10/25 12:12, Chunyan Zhang wrote:
>>> The first two patches are fixes.
>>> The last two are for userspace raid6test support on RISC-V.
>>>
>>> The issue fixed in patch 2/4 was probably the same which was spotted by
>>> Charlie [1], I couldn't reproduce it at that time.
>>>
>>> When running raid6test in userspace on RISC-V, I saw a segmentation fault,
>>> I used gdb command to print pointer p, it was an unaccessible address.
>>>
>>> With patch 2/4, the issue didn't appear anymore.
>>>
>>> [1] https://lore.kernel.org/lkml/Z5gJ35pXI2W41QDk@ghost/
>>>
>>> Chunyan Zhang (4):
>>>     raid6: riscv: clean up unused header file inclusion
>>>     raid6: riscv: Fix NULL pointer dereference issue
>>>     raid6: riscv: Allow code to be compiled in userspace
>>>     raid6: test: add support for RISC-V
>>>
>>>    lib/raid6/recov_rvv.c   |  9 +-----
>>>    lib/raid6/rvv.c         | 62 +++++++++++++++++++++--------------------
>>>    lib/raid6/rvv.h         | 15 ++++++++++
>>>    lib/raid6/test/Makefile |  8 ++++++
>>>    4 files changed, 56 insertions(+), 38 deletions(-)
>>>
Re: [PATCH 0/4] Fix a segmentation fault also add raid6test for RISC-V support
Posted by Alexandre Ghiti 4 months ago
Hi Chunyan,

On 6/10/25 12:12, Chunyan Zhang wrote:
> The first two patches are fixes.
> The last two are for userspace raid6test support on RISC-V.
>
> The issue fixed in patch 2/4 was probably the same which was spotted by
> Charlie [1], I couldn't reproduce it at that time.
>
> When running raid6test in userspace on RISC-V, I saw a segmentation fault,
> I used gdb command to print pointer p, it was an unaccessible address.


Can you give me your config, kernel and toolchain versions? I can't 
reproduce the segfault on my machine.

Thanks for the fixes and the test, I'll take a look this week.

Alex


>
> With patch 2/4, the issue didn't appear anymore.
>
> [1] https://lore.kernel.org/lkml/Z5gJ35pXI2W41QDk@ghost/
>
> Chunyan Zhang (4):
>    raid6: riscv: clean up unused header file inclusion
>    raid6: riscv: Fix NULL pointer dereference issue
>    raid6: riscv: Allow code to be compiled in userspace
>    raid6: test: add support for RISC-V
>
>   lib/raid6/recov_rvv.c   |  9 +-----
>   lib/raid6/rvv.c         | 62 +++++++++++++++++++++--------------------
>   lib/raid6/rvv.h         | 15 ++++++++++
>   lib/raid6/test/Makefile |  8 ++++++
>   4 files changed, 56 insertions(+), 38 deletions(-)
>
Re: [PATCH 0/4] Fix a segmentation fault also add raid6test for RISC-V support
Posted by Chunyan Zhang 4 months ago
Hi Alex,

On Wed, 11 Jun 2025 at 03:23, Alexandre Ghiti <alex@ghiti.fr> wrote:
>
> Hi Chunyan,
>
> On 6/10/25 12:12, Chunyan Zhang wrote:
> > The first two patches are fixes.
> > The last two are for userspace raid6test support on RISC-V.
> >
> > The issue fixed in patch 2/4 was probably the same which was spotted by
> > Charlie [1], I couldn't reproduce it at that time.
> >
> > When running raid6test in userspace on RISC-V, I saw a segmentation fault,
> > I used gdb command to print pointer p, it was an unaccessible address.
>
>
> Can you give me your config, kernel and toolchain versions? I can't
> reproduce the segfault on my machine.

I can use the below combination to reproduce:

- riscv/configs/defconfig
- Kernel v6.16-rc1
- Cross-compile toolchain [1] for building kernel which brings up QEMU
(running Ubuntu 22.04)
- Two choices for compiling raid6test program after applying patches 3-4:
1) Use toolchain [1] to cross-compile it as statically linked.
2) Compile it locally on QEMU (running Ubuntu 22.04) with local riscv gcc:

root@riscv-ubuntu2204:~# gcc --version
gcc (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0

Thanks,
Chunyan

[1] https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2025.05.30/riscv64-glibc-ubuntu-22.04-gcc-nightly-2025.05.30-nightly.tar.xz



>
> Thanks for the fixes and the test, I'll take a look this week.
>
> Alex
>
>
> >
> > With patch 2/4, the issue didn't appear anymore.
> >
> > [1] https://lore.kernel.org/lkml/Z5gJ35pXI2W41QDk@ghost/
> >
> > Chunyan Zhang (4):
> >    raid6: riscv: clean up unused header file inclusion
> >    raid6: riscv: Fix NULL pointer dereference issue
> >    raid6: riscv: Allow code to be compiled in userspace
> >    raid6: test: add support for RISC-V
> >
> >   lib/raid6/recov_rvv.c   |  9 +-----
> >   lib/raid6/rvv.c         | 62 +++++++++++++++++++++--------------------
> >   lib/raid6/rvv.h         | 15 ++++++++++
> >   lib/raid6/test/Makefile |  8 ++++++
> >   4 files changed, 56 insertions(+), 38 deletions(-)
> >
Re: [PATCH 0/4] Fix a segmentation fault also add raid6test for RISC-V support
Posted by Palmer Dabbelt 4 months ago
On Tue, 10 Jun 2025 12:23:18 PDT (-0700), Alexandre Ghiti wrote:
> Hi Chunyan,
>
> On 6/10/25 12:12, Chunyan Zhang wrote:
>> The first two patches are fixes.
>> The last two are for userspace raid6test support on RISC-V.
>>
>> The issue fixed in patch 2/4 was probably the same which was spotted by
>> Charlie [1], I couldn't reproduce it at that time.
>>
>> When running raid6test in userspace on RISC-V, I saw a segmentation fault,
>> I used gdb command to print pointer p, it was an unaccessible address.
>
>
> Can you give me your config, kernel and toolchain versions? I can't
> reproduce the segfault on my machine.

It's probably going to be super fragile to reproduce.  The code is just 
scrubbing over t0 without a clobber, so it's just going to break stuff 
somewhat arbitrarily.

>
> Thanks for the fixes and the test, I'll take a look this week.
>
> Alex
>
>
>>
>> With patch 2/4, the issue didn't appear anymore.
>>
>> [1] https://lore.kernel.org/lkml/Z5gJ35pXI2W41QDk@ghost/
>>
>> Chunyan Zhang (4):
>>    raid6: riscv: clean up unused header file inclusion
>>    raid6: riscv: Fix NULL pointer dereference issue
>>    raid6: riscv: Allow code to be compiled in userspace
>>    raid6: test: add support for RISC-V
>>
>>   lib/raid6/recov_rvv.c   |  9 +-----
>>   lib/raid6/rvv.c         | 62 +++++++++++++++++++++--------------------
>>   lib/raid6/rvv.h         | 15 ++++++++++
>>   lib/raid6/test/Makefile |  8 ++++++
>>   4 files changed, 56 insertions(+), 38 deletions(-)
>>