Auto-enabling V unit and/or use of elf attributes (was Re: Adding V-ext regs to signal context w/o expanding kernel struct sigcontext to avoid glibc ABI break)
Vineet Gupta
vineetg at rivosinc.com
Tue Jan 10 10:07:43 PST 2023
Hi Kito,
On 1/10/23 05:21, Kito Cheng wrote:
> Hi Vineet:
>
>
>> But you are not suggesting that there is a scenario with executable
>> built somehow with V instructions (even .byte encoded) but not have that
>> info encoded in RV_ATTR_TAG_arch string. And I'd argue that it is user
>> error, they need to make sure that -march had 'v' passed to compiler
>> and/or assembler.
>
> The concept of Tag_RISCV_arch attribute is minimal execution
> environment requirement of the executable or shared libraries; use
> glibc as an example, we can compile glibc with rv64gc only and then it
> can contain vector optimized routines like memcpy and memcpy, and
> those function are resolved by ifunc, which means only use those
> routines when vector extension are available, so the Tag_RISCV_arch
> for the glibc is rv64gc, not rv64gcv since V is not minimal execution
> environment requirement.
I understand where you are coming from. This "minimal" info can be used
in a "compile-once-used-multiple" kind of a paradigm where a glibc with
V enabled ifunc can still run on non-V hardware.
> My expectation is most distro will still distribute with rv64gc for a
> while and then optimize function with vector extension for some
> libraries, and those vector code will guarded with some runtime check
> mechanism maybe IFUNC, so Tag_RISCV_arch for those libraries won't
> contain V.
Yes bulk of glibc might not have vector code, but those V ifunc routines
do and IMO this information needs to be recorded somewhere in the elf.
Case in point being the current issue with how to enable V unit.
Community wants a per-process enable, using an explicit prctl from
userspace (since RV doesn't have fault-on-first use hardware mechanism
unlike some of the other arches). But how does the glibc loader know to
invoke prctl. We can't just rely on user env GLIBC_TUNABLE etc since
that might not be accurate. It needs somethign concrete which IMO can
come from elf attributes. If not, do you have suggestions on how to
solve this issue ?
Granted the case of executable itself using V insns directly is less
likely than the linked/dlopen dso, so we can punt this being done in
kernel elf loader and do it in the glibc loader for the DT_NEEDED dsos.
> It's not clear in psABI spec, but intend to fix in future:
> https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/292
Please don't change the semantics of Tag_RISCV_arch itself. Keep the
minimum if you want, but also have something which reflects the absolute
-march used to build. If nothing it can be used to annotate binaries how
they were built.
Thx,
-Vineet
More information about the linux-riscv
mailing list