[LTP] (no subject)
Jan Stancek
jstancek@redhat.com
Fri Apr 26 14:47:47 CEST 2024
On Fri, Apr 26, 2024 at 2:27 PM 路斐 <lufei@uniontech.com> wrote:
>
> Hi, Cyril.
> Here is my case:
>
>
> ```
> [root@rocky arch_prctl]# gcc --version
> gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2)
> Copyright (C) 2021 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> [root@rocky arch_prctl]# uname -a
> Linux rocky 5.14.0-362.18.1.el9_3.0.1.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Feb 11 13:49:23 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
>
> [root@rocky arch_prctl]# cat arch_prctl01.c
> // SPDX-License-Identifier: GPL-2.0-or-later
> /*
> * Copyright (c) UnionTech Software Technology Co.,Ltd., 2024
> * Author: Lu Fei <lufei@uniontech.com>
> */
>
>
> /*\
> * [Description]
> *
> * Simple test on arch_prctl to set and get cpuid instruction of test thread.
> */
>
>
> #include "tst_test.h"
> #include "lapi/syscalls.h"
> #include <stdlib.h>
> #ifdef HAVE_ASM_PRCTL_H
> #include <asm/prctl.h>
>
>
> static int arch_prctl_get(int code, unsigned long *addr)
> {
> return tst_syscall(__NR_arch_prctl, code, *addr);
^^
you are de-refencing here, while kernel expects a pointer
> }
>
>
> static int arch_prctl_set(int code, unsigned long addr)
> {
> return tst_syscall(__NR_arch_prctl, code, addr);
> }
>
>
> static void run(unsigned int index)
> {
> unsigned long *addr = malloc(sizeof(long));
>
>
> // index == 0 for disable cpuid, 1 for enable cpuid.
> TST_EXP_PASS(arch_prctl_set(ARCH_SET_CPUID, index));
>
>
> TEST(arch_prctl_get(ARCH_GET_CPUID, addr));
>
>
> if (TST_RET == index)
> tst_res(TPASS, "get cpuid succeed.");
> else
> tst_res(TFAIL, "get cpuid failed.");
> }
>
>
> static struct tst_test test = {
> .test = run,
> .tcnt = 2,
> .min_kver = "4.12",
> .supported_archs = {"x86_64", "x86", NULL},
> };
>
>
> #else /* HAVE_ASM_PRCTL_H */
> TST_TEST_TCONF("missing <asm/prctl.h>");
> #endif
> [root@rocky arch_prctl]# make clean
> rm -f -f -r arch_prctl01 *.o *.pyc .cache.mk *.dwo .*.dwo
> [root@rocky arch_prctl]# make check
> CHECK testcases/kernel/syscalls/arch_prctl/arch_prctl01.c
> arch_prctl01.c:48:10: warning: bogus scalar initializer
> [root@rocky arch_prctl]# make
> make -C "/root/Develop/ltp/lib" -f "/root/Develop/ltp/lib/Makefile" all
> make[1]: Entering directory '/root/Develop/ltp/lib'
> GEN ltp-version.h
> make[2]: Nothing to be done for 'all'.
> make[2]: Nothing to be done for 'all'.
> make[1]: Leaving directory '/root/Develop/ltp/lib'
> arch_prctl01.c:48:9: warning: braces around scalar initializer
> 48 | .supported_archs = {"x86_64", "x86", NULL},
> | ^
> arch_prctl01.c:48:9: note: (near initialization for ‘test.supported_archs’)
> arch_prctl01.c:48:29: warning: initialization of ‘const char * const*’ from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
> 48 | .supported_archs = {"x86_64", "x86", NULL},
> | ^~~~~~~~
> arch_prctl01.c:48:29: note: (near initialization for ‘test.supported_archs’)
> arch_prctl01.c:48:39: warning: excess elements in scalar initializer
> 48 | .supported_archs = {"x86_64", "x86", NULL},
> | ^~~~~
> arch_prctl01.c:48:39: note: (near initialization for ‘test.supported_archs’)
> arch_prctl01.c:48:46: warning: excess elements in scalar initializer
> 48 | .supported_archs = {"x86_64", "x86", NULL},
> | ^~~~
> arch_prctl01.c:48:46: note: (near initialization for ‘test.supported_archs’)
> CC testcases/kernel/syscalls/arch_prctl/arch_prctl01
> ```
>
>
>
>
>
>
>
> 路斐 Fei.Lu
> Uniontech Technology
> site: www.uniontech.com
> tel: 18501012352
> addr: Xi'an China
>
>
>
>
>
>
>
>
> ------------------ Original ------------------
> From: "Cyril Hrubis"<chrubis@suse.cz>;
> Date: Fri, Apr 26, 2024 06:30 PM
> To: "路斐"<lufei@uniontech.com>;
> Cc: "ltp"<ltp@lists.linux.it>;
> Subject: Re: Re:
>
>
>
> Hi!
> > I tried using NULL, but met `TBROK: Test killed by SIGSEGV!`.
>
> That means that the manual page is wrong and the address is not ignored.
>
> > And the last time you mentioned in response to using
> > `supported_archs`, this seems not work properly by now, the ltp
> > document(section of writing_tests) says "not applicable".
>
> The supported_archs is supposed to work. How did you set it (the value)
> and what happened?
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
More information about the ltp
mailing list