Re: kernel/trace/rv/monitors/sleep/sleep.c:130:7: error: use of undeclared identifier '__NR_clock_nanosleep'

From: Gabriele Monaco
Date: Mon Aug 18 2025 - 03:42:39 EST


On Sat, 2025-08-16 at 02:37 +0800, kernel test robot wrote:
> tree:  
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ma
> ster
> head:   ee94b00c1a648530333d9734200be7a45e6e00cd
> commit: f74f8bb246cf22f27752977da62079cb615f55b2 rv: Add rtapp_sleep
> monitor
> date:   5 weeks ago
> config: riscv-randconfig-001-20250816
> (https://download.01.org/0day-ci/archive/20250816/202508160204.SsFyNf
> o6-lkp@xxxxxxxxx/config)
> compiler: clang version 22.0.0git
> (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef3152
> 4fa1d9f3f)
> reproduce (this is a W=1 build):
> (https://download.01.org/0day-ci/archive/20250816/202508160204.SsFyNf
> o6-lkp@xxxxxxxxx/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new
> version of
> the same patch/commit), kindly add following tags
> > Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > Closes:
> > https://lore.kernel.org/oe-kbuild-all/202508160204.SsFyNfo6-lkp@xxxxxxxxx/
>

Palmer, this issue is what you fix in
https://lore.kernel.org/lkml/20250804194518.97620-2-palmer@xxxxxxxxxxx/
, right?

> All errors (new ones prefixed by >>):
>
>    In file included from arch/riscv/include/asm/io.h:136:
>    include/asm-generic/io.h:804:2: warning: performing pointer
> arithmetic on a null pointer has undefined behavior [-Wnull-pointer-
> arithmetic]
>      804 |         insb(addr, buffer, count);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~
>    arch/riscv/include/asm/io.h:104:53: note: expanded from macro
> 'insb'
>      104 | #define insb(addr, buffer, count) __insb(PCI_IOBASE +
> (addr), buffer, count)
>          |                                          ~~~~~~~~~~ ^
>    In file included from kernel/trace/rv/monitors/sleep/sleep.c:2:
>    In file included from include/linux/ftrace.h:10:
>    In file included from include/linux/trace_recursion.h:5:
>    In file included from include/linux/interrupt.h:11:
>    In file included from include/linux/hardirq.h:11:
>    In file included from
> ./arch/riscv/include/generated/asm/hardirq.h:1:
>    In file included from include/asm-generic/hardirq.h:17:
>    In file included from include/linux/irq.h:20:
>    In file included from include/linux/io.h:12:
>    In file included from arch/riscv/include/asm/io.h:136:
>    include/asm-generic/io.h:812:2: warning: performing pointer
> arithmetic on a null pointer has undefined behavior [-Wnull-pointer-
> arithmetic]
>      812 |         insw(addr, buffer, count);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~
>    arch/riscv/include/asm/io.h:105:53: note: expanded from macro
> 'insw'
>      105 | #define insw(addr, buffer, count) __insw(PCI_IOBASE +
> (addr), buffer, count)
>          |                                          ~~~~~~~~~~ ^
>    In file included from kernel/trace/rv/monitors/sleep/sleep.c:2:
>    In file included from include/linux/ftrace.h:10:
>    In file included from include/linux/trace_recursion.h:5:
>    In file included from include/linux/interrupt.h:11:
>    In file included from include/linux/hardirq.h:11:
>    In file included from
> ./arch/riscv/include/generated/asm/hardirq.h:1:
>    In file included from include/asm-generic/hardirq.h:17:
>    In file included from include/linux/irq.h:20:
>    In file included from include/linux/io.h:12:
>    In file included from arch/riscv/include/asm/io.h:136:
>    include/asm-generic/io.h:820:2: warning: performing pointer
> arithmetic on a null pointer has undefined behavior [-Wnull-pointer-
> arithmetic]
>      820 |         insl(addr, buffer, count);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~
>    arch/riscv/include/asm/io.h:106:53: note: expanded from macro
> 'insl'
>      106 | #define insl(addr, buffer, count) __insl(PCI_IOBASE +
> (addr), buffer, count)
>          |                                          ~~~~~~~~~~ ^
>    In file included from kernel/trace/rv/monitors/sleep/sleep.c:2:
>    In file included from include/linux/ftrace.h:10:
>    In file included from include/linux/trace_recursion.h:5:
>    In file included from include/linux/interrupt.h:11:
>    In file included from include/linux/hardirq.h:11:
>    In file included from
> ./arch/riscv/include/generated/asm/hardirq.h:1:
>    In file included from include/asm-generic/hardirq.h:17:
>    In file included from include/linux/irq.h:20:
>    In file included from include/linux/io.h:12:
>    In file included from arch/riscv/include/asm/io.h:136:
>    include/asm-generic/io.h:829:2: warning: performing pointer
> arithmetic on a null pointer has undefined behavior [-Wnull-pointer-
> arithmetic]
>      829 |         outsb(addr, buffer, count);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
>    arch/riscv/include/asm/io.h:118:55: note: expanded from macro
> 'outsb'
>      118 | #define outsb(addr, buffer, count) __outsb(PCI_IOBASE +
> (addr), buffer, count)
>          |                                            ~~~~~~~~~~ ^
>    In file included from kernel/trace/rv/monitors/sleep/sleep.c:2:
>    In file included from include/linux/ftrace.h:10:
>    In file included from include/linux/trace_recursion.h:5:
>    In file included from include/linux/interrupt.h:11:
>    In file included from include/linux/hardirq.h:11:
>    In file included from
> ./arch/riscv/include/generated/asm/hardirq.h:1:
>    In file included from include/asm-generic/hardirq.h:17:
>    In file included from include/linux/irq.h:20:
>    In file included from include/linux/io.h:12:
>    In file included from arch/riscv/include/asm/io.h:136:
>    include/asm-generic/io.h:838:2: warning: performing pointer
> arithmetic on a null pointer has undefined behavior [-Wnull-pointer-
> arithmetic]
>      838 |         outsw(addr, buffer, count);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
>    arch/riscv/include/asm/io.h:119:55: note: expanded from macro
> 'outsw'
>      119 | #define outsw(addr, buffer, count) __outsw(PCI_IOBASE +
> (addr), buffer, count)
>          |                                            ~~~~~~~~~~ ^
>    In file included from kernel/trace/rv/monitors/sleep/sleep.c:2:
>    In file included from include/linux/ftrace.h:10:
>    In file included from include/linux/trace_recursion.h:5:
>    In file included from include/linux/interrupt.h:11:
>    In file included from include/linux/hardirq.h:11:
>    In file included from
> ./arch/riscv/include/generated/asm/hardirq.h:1:
>    In file included from include/asm-generic/hardirq.h:17:
>    In file included from include/linux/irq.h:20:
>    In file included from include/linux/io.h:12:
>    In file included from arch/riscv/include/asm/io.h:136:
>    include/asm-generic/io.h:847:2: warning: performing pointer
> arithmetic on a null pointer has undefined behavior [-Wnull-pointer-
> arithmetic]
>      847 |         outsl(addr, buffer, count);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
>    arch/riscv/include/asm/io.h:120:55: note: expanded from macro
> 'outsl'
>      120 | #define outsl(addr, buffer, count) __outsl(PCI_IOBASE +
> (addr), buffer, count)
>          |                                            ~~~~~~~~~~ ^
>    In file included from kernel/trace/rv/monitors/sleep/sleep.c:2:
>    In file included from include/linux/ftrace.h:10:
>    In file included from include/linux/trace_recursion.h:5:
>    In file included from include/linux/interrupt.h:11:
>    In file included from include/linux/hardirq.h:11:
>    In file included from
> ./arch/riscv/include/generated/asm/hardirq.h:1:
>    In file included from include/asm-generic/hardirq.h:17:
>    In file included from include/linux/irq.h:20:
>    In file included from include/linux/io.h:12:
>    In file included from arch/riscv/include/asm/io.h:136:
>    include/asm-generic/io.h:1175:55: warning: performing pointer
> arithmetic on a null pointer has undefined behavior [-Wnull-pointer-
> arithmetic]
>     1175 |         return (port > MMIO_UPPER_LIMIT) ? NULL :
> PCI_IOBASE + port;
>          |                                                  
> ~~~~~~~~~~ ^
> > > kernel/trace/rv/monitors/sleep/sleep.c:130:7: error: use of
> > > undeclared identifier '__NR_clock_nanosleep'
>      130 |         case __NR_clock_nanosleep:
>          |              ^~~~~~~~~~~~~~~~~~~~
> > > kernel/trace/rv/monitors/sleep/sleep.c:141:7: error: use of
> > > undeclared identifier '__NR_futex'
>      141 |         case __NR_futex:
>          |              ^~~~~~~~~~
>    7 warnings and 2 errors generated.
>
>
> vim +/__NR_clock_nanosleep +130
> kernel/trace/rv/monitors/sleep/sleep.c
>
>    120
>    121 static void handle_sys_enter(void *data, struct pt_regs
> *regs, long id)
>    122 {
>    123 struct ltl_monitor *mon;
>    124 unsigned long args[6];
>    125 int op, cmd;
>    126
>    127 mon = ltl_get_monitor(current);
>    128
>    129 switch (id) {
>  > 130 case __NR_clock_nanosleep:
>    131 #ifdef __NR_clock_nanosleep_time64
>    132 case __NR_clock_nanosleep_time64:
>    133 #endif
>    134 syscall_get_arguments(current, regs, args);
>    135 ltl_atom_set(mon,
> LTL_NANOSLEEP_CLOCK_MONOTONIC, args[0] == CLOCK_MONOTONIC);
>    136 ltl_atom_set(mon, LTL_NANOSLEEP_CLOCK_TAI,
> args[0] == CLOCK_TAI);
>    137 ltl_atom_set(mon,
> LTL_NANOSLEEP_TIMER_ABSTIME, args[1] == TIMER_ABSTIME);
>    138 ltl_atom_update(current,
> LTL_CLOCK_NANOSLEEP, true);
>    139 break;
>    140
>  > 141 case __NR_futex:
>    142 #ifdef __NR_futex_time64
>    143 case __NR_futex_time64:
>    144 #endif
>    145 syscall_get_arguments(current, regs, args);
>    146 op = args[1];
>    147 cmd = op & FUTEX_CMD_MASK;
>    148
>    149 switch (cmd) {
>    150 case FUTEX_LOCK_PI:
>    151 case FUTEX_LOCK_PI2:
>    152 ltl_atom_update(current,
> LTL_FUTEX_LOCK_PI, true);
>    153 break;
>    154 case FUTEX_WAIT:
>    155 case FUTEX_WAIT_BITSET:
>    156 case FUTEX_WAIT_REQUEUE_PI:
>    157 ltl_atom_update(current,
> LTL_FUTEX_WAIT, true);
>    158 break;
>    159 }
>    160 break;
>    161 }
>    162 }
>    163