On 18/10/22 11:58, Michael Tokarev wrote:
10.10.2022 11:53, Helge Deller wrote:
On 10/9/22 08:08, WANG Xuerui wrote:
User space has been preferring this syscall for a while, due to its
closer match with C semantics, and newer platforms such as LoongArch
apparently have libc implementations that don't fallback to faccessat
so normal access checks are failing without the emulation in place.

https://lore.kernel.org/qemu-devel/YzLdcnL6x646T61W@p100/

I think this one is the more complete and simplest solution.
Only change:

+#if defined(TARGET_NR_faccessat2) && defined(__NR_faccessat2)

with

+#if defined(TARGET_NR_faccessat2)

(not necessary to have host __NR_faccessat2)

and replace "faccessat2(...)" with "faccessat(...)", so it uses glibc implementation, that uses __NR_faccessat2 if host has this syscall, otherwise it falls back to faccessat with the addition of fstatat if flags!=0 (obviously, the definition of syscall4(... faccessat2 ...) should be removed).

For loongarch64 users this has become essential, because this is a
new enough arch so that userspace does not bother using older syscalls,
in this case it uses faccessat2() for everything, and simplest programs
fail under qemu due to no fallback whatsoever.

I agree that it has become essential. Development with qemu-user is much faster than using qemu-system, with all the benefits to use chroot on a shared file system.

I tested (and currently testing) the above patch with Slackware-current build scripts on x86_64 host: all works fine!

Thanks!
  Luca

Reply via email to