s390x: glibc widestring algorithms broken

Host environment

  • Operating system: ArchLinux
  • OS/kernel version: Linux ... 6.0.0-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 04 Oct 2022 19:16:52 +0000 x86_64 GNU/Linux
  • Architecture: x86_64
  • QEMU flavor: qemu-s390x
  • QEMU version: qemu-s390x version 7.1.0
  • QEMU command line: qemu-s390x ./test -> output 0
/* test.c */
#include <wchar.h>
#include <stdio.h>

int main(void)
{
	printf("%ld\n", wcsspn(L"FOO", L"F"));
}

Emulated/Virtualized environment

  • Operating system: user emulation
  • OS/kernel version: user emulation
  • Architecture: s390x
  • Test program linked against glibc 2.35-0ubuntu3.1

Description of problem

Several wide-string functions from glibc are broken und qemu user emulation. Affected are at least: wcsbrk(), wcsspn() and wcscspn(). All of these are implemented in optimized assembler in glibc.

Unfortunately I don't have access to the real hardware to check the behavior there. But it would probably been detected by now. Also I don't know which instructions exactly don't work, as I don't have any knowledge about s390x assembler.

Steps to reproduce

  1. Compile the test program above
  2. Run the program
  3. Output is 0, should be 1.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information