Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: selftests: Fix build of rseq test

The KVM rseq test is failing to build in -next due to a commit merged
from the tip tree which adds a wrapper for sys_getcpu() to the rseq
kselftests, conflicting with the wrapper already included in the KVM
selftest:

rseq_test.c:48:13: error: conflicting types for 'sys_getcpu'
48 | static void sys_getcpu(unsigned *cpu)
| ^~~~~~~~~~
In file included from rseq_test.c:23:
../rseq/rseq.c:82:12: note: previous definition of 'sys_getcpu' was here
82 | static int sys_getcpu(unsigned *cpu, unsigned *node)
| ^~~~~~~~~~

Fix this by removing the local wrapper and moving the result check up to
the caller.

Fixes: 99babd04b250 ("selftests/rseq: Implement rseq numa node id field selftest")
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://lore.kernel.org/r/20230106-fix-kvm-rseq-build-v1-1-b704d9831d02@kernel.org

authored by

Mark Brown and committed by
Peter Zijlstra
68efe8f7 001c28e5

+3 -13
+3 -13
tools/testing/selftests/kvm/rseq_test.c
··· 41 41 GUEST_SYNC(0); 42 42 } 43 43 44 - /* 45 - * We have to perform direct system call for getcpu() because it's 46 - * not available until glic 2.29. 47 - */ 48 - static void sys_getcpu(unsigned *cpu) 49 - { 50 - int r; 51 - 52 - r = syscall(__NR_getcpu, cpu, NULL, NULL); 53 - TEST_ASSERT(!r, "getcpu failed, errno = %d (%s)", errno, strerror(errno)); 54 - } 55 - 56 44 static int next_cpu(int cpu) 57 45 { 58 46 /* ··· 237 249 * across the seq_cnt reads. 238 250 */ 239 251 smp_rmb(); 240 - sys_getcpu(&cpu); 252 + r = sys_getcpu(&cpu, NULL); 253 + TEST_ASSERT(!r, "getcpu failed, errno = %d (%s)", 254 + errno, strerror(errno)); 241 255 rseq_cpu = rseq_current_cpu_raw(); 242 256 smp_rmb(); 243 257 } while (snapshot != atomic_read(&seq_cnt));