Commit f129b616 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'urgent-nolibc.2023.01.09a' of...

Merge tag 'urgent-nolibc.2023.01.09a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu

Pull nolibc fixes from Paul McKenney:

 - The fd_set structure was incorrectly defined as arrays of u32 instead
   of long, which breaks BE64. Fix courtesy of Sven Schnelle.

 - S_ISxxx macros were incorrectly testing the bits after applying them
   instead of bitwise ANDing S_FMT with the value. Fix from Warner Losh.

 - The mips code was randomly broken due to an unprotected "noreorder"
   directive in the _start code that could prevent the assembler from
   filling delayed slots. This in turn resulted in random other
   instructions being placed into those slots. Fix courtesy of Willy
   Tarreau.

 - The current nolibc header layout refrains from including files that
   are not explicitly included by the code using nolibc. Unfortunately,
   this causes build failures when such files contain definitions that
   are used (for example) by libgcc. Example definitions include raise()
   and memset(), which are called by some architectures, but only at
   certain optimization levels. Fix courtesy of Willy Tarreau.

 - gcc 11.3 in ARM thumb2 mode at -O2 recognized a memset() construction
   inside the memset() definition. The compiler replaced this
   construction with a call to... memset(). Userland cannot be forced to
   build with -ffreestanding, so an empty asm() statement was introduced
   into the loop the loop in order to prevent the compiler from making
   this unproductive transformation. Fix courtesy of Willy Tarreau.

 - Most of the O_* macros were wrong on RISCV because their octal values
   were coded as hexadecimal. This resulted in the getdents64() selftest
   failing. Fix courtesy of Willy Tarreau.

This was tested on x86_64, i386, armv5, armv7, thumb1, thumb2, mips and
riscv, all at -O0, -Os and -O3.

* tag 'urgent-nolibc.2023.01.09a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu:
  tools/nolibc: fix the O_* fcntl/open macro definitions for riscv
  tools/nolibc: prevent gcc from making memset() loop over itself
  tools/nolibc: fix missing includes causing build issues at -O0
  tools/nolibc: restore mips branch ordering in the _start block
  tools/nolibc: Fix S_ISxxx macros
  nolibc: fix fd_set type
parents c757fc92 00b18da4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -192,6 +192,7 @@ struct sys_stat_struct {
__asm__ (".section .text\n"
    ".weak __start\n"
    ".set nomips16\n"
    ".set push\n"
    ".set    noreorder\n"
    ".option pic0\n"
    ".ent __start\n"
@@ -210,6 +211,7 @@ __asm__ (".section .text\n"
    "li $v0, 4001\n"              // NR_exit == 4001
    "syscall\n"
    ".end __start\n"
    ".set pop\n"
    "");

#endif // _NOLIBC_ARCH_MIPS_H
+7 −7
Original line number Diff line number Diff line
@@ -11,13 +11,13 @@
#define O_RDONLY            0
#define O_WRONLY            1
#define O_RDWR              2
#define O_CREAT         0x100
#define O_EXCL          0x200
#define O_NOCTTY        0x400
#define O_TRUNC        0x1000
#define O_APPEND       0x2000
#define O_NONBLOCK     0x4000
#define O_DIRECTORY  0x200000
#define O_CREAT          0x40
#define O_EXCL           0x80
#define O_NOCTTY        0x100
#define O_TRUNC         0x200
#define O_APPEND        0x400
#define O_NONBLOCK      0x800
#define O_DIRECTORY   0x10000

struct sys_stat_struct {
	unsigned long	st_dev;		/* Device.  */
+3 −0
Original line number Diff line number Diff line
@@ -96,4 +96,7 @@ int ispunct(int c)
	return isgraph(c) && !isalnum(c);
}

/* make sure to include all global symbols */
#include "nolibc.h"

#endif /* _NOLIBC_CTYPE_H */
+3 −0
Original line number Diff line number Diff line
@@ -24,4 +24,7 @@ static int errno;
 */
#define MAX_ERRNO 4095

/* make sure to include all global symbols */
#include "nolibc.h"

#endif /* _NOLIBC_ERRNO_H */
+3 −0
Original line number Diff line number Diff line
@@ -19,4 +19,7 @@ int raise(int signal)
	return sys_kill(sys_getpid(), signal);
}

/* make sure to include all global symbols */
#include "nolibc.h"

#endif /* _NOLIBC_SIGNAL_H */
Loading