Re: Detecting the Zbb extension on riscv64

From: <tuexen_at_freebsd.org>
Date: Sun, 02 Jun 2024 13:05:09 UTC
> On 2. Jun 2024, at 13:38, Robert Clausecker <fuz@freebsd.org> wrote:
> 
> Greetings!
> 
> I'm currently working on two projects that require the Zbb
> instruction set extension on riscv64:
> 
> - strajabot@ is a gsoc student who is currently porting the
>  SIMD-enhanced libc string functions from amd64 to riscv64.
>  For these, Zbb is immensely useful as it provides the
>  CTZ and ORC.B instructions needed for fast string comparison
> 
> - I'm trying to write a fast sha1 implementation for libmd,
>  which (you might have guessed it) requires Zbb for rotate
>  instructions.  Not having these is possible here, but there
>  is a significant performance penalty.
> 
> Zbb is supported by the SiFive unmatched board for example.
Hi Robert,

just double checking:
According to
https://sifive.cdn.prismic.io/sifive/d0556df9-55c6-47a8-b0f2-4b1521546543_hifive-unmatched-datasheet.pdf
the processor supports RV64GC (RV64IMAFDC). I don't see a B there.
So does it actually support Zbb? What about Zbr?

Best regards
Michael
> 
> I originally wanted to just write an ifunc dispatcher that
> checks for the presence off Zbb and then picks an appropriate
> implementation, but then noticed that AT_HWCAP currently only
> supports the detection of capital letter extensions.
> 
> Furthermore, we do not give user space any access to the isa
> string (a sysctl like hw.isa would be nice), so it's not even
> possible to determine the availability manually.
> 
> Please check if you can add a sysctl to get the ISA string and
> possibly add an elf_aux_info extension to allow the user to find
> out which Z extensions are present.
> 
> We are working with 15-CURRENT, so if it's there it'll suffice
> for our needs.
> 
> Yours,
> Robert Clausecker
> 
> -- 
> ()  ascii ribbon campaign - for an encoding-agnostic world
> /\  - against html email  - against proprietary attachments
>