RE: [linus:master] [x86/vdso] 877cff5296: kernel-selftests.x86.test_vsyscall_32.fail

From: Li, Xin3
Date: Sat Mar 11 2023 - 03:51:36 EST


> FYI, we noticed kernel-selftests.x86.test_vsyscall_32.fail due to commit (built with
> gcc-11):
>
> commit: 877cff5296faa6ef312f8002216bbf73bea006c7 ("x86/vdso: Fake 32bit
> VDSO build on 64bit compile for vgetcpu")
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master
>
> [test failed on linux-next/master 1716a175592aff9549a0c07aac8f9cadd03003f5]
>
> in testcase: kernel-selftests
> version: kernel-selftests-x86_64-d4cf28ee-1_20230110
> with following parameters:
>
> group: x86
>
> test-description: The kernel contains a set of "self tests" under the
> tools/testing/selftests/ directory. These are intended to be small unit tests to
> exercise individual code paths in the kernel.
> test-url: https://www.kernel.org/doc/Documentation/kselftest.txt
>
> on test machine: 8 threads 1 sockets Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
> (Kaby Lake) with 32G memory
>
> caused below changes (please refer to attached dmesg/kmsg for entire
> log/backtrace):
>
>
> # selftests: x86: test_vsyscall_32
> # [RUN] test gettimeofday()
> # vDSO time offsets: 0.000017 0.000001
> # [OK] vDSO gettimeofday()'s timeval was okay
> # [RUN] test time()
> # [OK] vDSO time() is okay
> # [RUN] getcpu() on CPU 0
> # [FAIL] vDSO reported CPU 227 but should be 0
> # [OK] vDSO reported correct node
> # [RUN] getcpu() on CPU 1
> # [FAIL] vDSO reported CPU 227 but should be 1
> # [OK] vDSO reported correct node
> not ok 9 selftests: x86: test_vsyscall_32 # exit=1
>
>
> If you fix the issue, kindly add following tag
> | Reported-by: kernel test robot <yujie.liu@xxxxxxxxx>
> | Link:
> | https://lore.kernel.org/oe-lkp/202303020903.b01fd1de-yujie.liu@xxxxxxxxx

Shan Kang found the same issue when she was testing the v5 FRED patch set.
The root cause is the 32-bit getcpu() on 64-bit Linux kernel is compiled
with 32-bit Linux kernel GDT_ENTRY_CPUNODE, i.e., 28, beyond the 64-bit
Linux kernel GDT limit.

I will send a fix soon.

Thanks!
Xin