* [LTP] [PATCH] syscalls: arch_prctl01.c fix compilation on old distros
@ 2024-05-09 12:09 Cyril Hrubis
2024-05-09 12:32 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2024-05-09 12:09 UTC (permalink / raw)
To: ltp
From: Cyril Hrubis <chrubis@suse.cz>
There are distros that have asm/prctl.h without the ARCH_{GET,SET}_CPUID
definitions, fix the compilation on such distributions by adding
lapi/arch_prctl.h.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
include/lapi/arch_prctl.h | 22 ++++++++++++++++++++++
.../kernel/syscalls/arch_prctl/arch_prctl01.c | 7 +------
2 files changed, 23 insertions(+), 6 deletions(-)
create mode 100644 include/lapi/arch_prctl.h
diff --git a/include/lapi/arch_prctl.h b/include/lapi/arch_prctl.h
new file mode 100644
index 000000000..6d0ef51f4
--- /dev/null
+++ b/include/lapi/arch_prctl.h
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2024 Cyril Hrubis <chrubis@suse.cz>
+ */
+#ifndef LAPI_ARCH_PRCTL_H__
+#define LAPI_ARCH_PRCTL_H__
+
+#include "config.h"
+
+#ifdef HAVE_ASM_PRCTL_H
+# include <asm/prctl.h>
+#endif
+
+#ifndef ARCH_GET_CPUID
+# define ARCH_GET_CPUID 1011
+#endif
+
+#ifndef ARCH_SET_CPUID
+# define ARCH_SET_CPUID 1012
+#endif
+
+#endif /* LAPI_ARCH_PRCTL_H__ */
diff --git a/testcases/kernel/syscalls/arch_prctl/arch_prctl01.c b/testcases/kernel/syscalls/arch_prctl/arch_prctl01.c
index e30b5667a..b98ef99d2 100644
--- a/testcases/kernel/syscalls/arch_prctl/arch_prctl01.c
+++ b/testcases/kernel/syscalls/arch_prctl/arch_prctl01.c
@@ -13,10 +13,9 @@
#include "tst_test.h"
#include "tst_safe_stdio.h"
#include "lapi/syscalls.h"
+#include "lapi/arch_prctl.h"
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_ASM_PRCTL_H
-#include <asm/prctl.h>
static int arch_prctl_get(int code)
{
@@ -76,7 +75,3 @@ static struct tst_test test = {
.min_kver = "4.12",
.supported_archs = (const char *const []){"x86_64", "x86", NULL}
};
-
-#else /* HAVE_ASM_PRCTL_H */
-TST_TEST_TCONF("missing <asm/prctl.h>");
-#endif
--
2.12.3
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] syscalls: arch_prctl01.c fix compilation on old distros
2024-05-09 12:09 [LTP] [PATCH] syscalls: arch_prctl01.c fix compilation on old distros Cyril Hrubis
@ 2024-05-09 12:32 ` Petr Vorel
2024-05-09 12:46 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2024-05-09 12:32 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
> From: Cyril Hrubis <chrubis@suse.cz>
> There are distros that have asm/prctl.h without the ARCH_{GET,SET}_CPUID
> definitions, fix the compilation on such distributions by adding
> lapi/arch_prctl.h.
I would note that this was for Leap 42.2. We can remove the fallback in the
future once we remove the support for these oldest distros (it's hard to find
the original reason when doing a cleanup few years later).
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
> include/lapi/arch_prctl.h | 22 ++++++++++++++++++++++
> .../kernel/syscalls/arch_prctl/arch_prctl01.c | 7 +------
> 2 files changed, 23 insertions(+), 6 deletions(-)
> create mode 100644 include/lapi/arch_prctl.h
> diff --git a/include/lapi/arch_prctl.h b/include/lapi/arch_prctl.h
> new file mode 100644
> index 000000000..6d0ef51f4
> --- /dev/null
> +++ b/include/lapi/arch_prctl.h
> @@ -0,0 +1,22 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2024 Cyril Hrubis <chrubis@suse.cz>
> + */
> +#ifndef LAPI_ARCH_PRCTL_H__
> +#define LAPI_ARCH_PRCTL_H__
> +
> +#include "config.h"
> +
> +#ifdef HAVE_ASM_PRCTL_H
> +# include <asm/prctl.h>
> +#endif
> +
> +#ifndef ARCH_GET_CPUID
> +# define ARCH_GET_CPUID 1011
This is wrong, in the header is a hex number (missing 0x)
# define ARCH_GET_CPUID 0x1011
> +#endif
> +
> +#ifndef ARCH_SET_CPUID
> +# define ARCH_SET_CPUID 1012
And here as well:
# define ARCH_SET_CPUID 0x1012
It obviously break the result when fallback is used:
arch_prctl01.c:56: TFAIL: arch_prctl_set(ARCH_SET_CPUID, index) failed: EINVAL (22)
arch_prctl01.c:68: TFAIL: get wrong cpuid status
arch_prctl01.c:56: TFAIL: arch_prctl_set(ARCH_SET_CPUID, index) failed: EINVAL (22)
arch_prctl01.c:68: TFAIL: get wrong cpuid status
With that fixed:
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] syscalls: arch_prctl01.c fix compilation on old distros
2024-05-09 12:32 ` Petr Vorel
@ 2024-05-09 12:46 ` Cyril Hrubis
0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2024-05-09 12:46 UTC (permalink / raw)
To: Petr Vorel; +Cc: Cyril Hrubis, ltp
Hi!
> > +#ifndef ARCH_GET_CPUID
> > +# define ARCH_GET_CPUID 1011
> This is wrong, in the header is a hex number (missing 0x)
Good catch, fixed and pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-09 12:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 12:09 [LTP] [PATCH] syscalls: arch_prctl01.c fix compilation on old distros Cyril Hrubis
2024-05-09 12:32 ` Petr Vorel
2024-05-09 12:46 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox