From patchwork Mon Nov 8 02:14:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 1552102 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RS3ZOfIJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HnZSs0vSwz9s0r for ; Mon, 8 Nov 2021 13:15:07 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D1D2A3C75C8 for ; Mon, 8 Nov 2021 03:15:00 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 247033C006A for ; Mon, 8 Nov 2021 03:14:58 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 65D4F600A15 for ; Mon, 8 Nov 2021 03:14:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636337695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZEpTBS1b0kJfgIl5yAjstdln+OcEfMeq5Z3bwmP/VUM=; b=RS3ZOfIJeaMR5AaY5PtMEps3zOybESZg1boEAEeZjLuy5N4JPatS80Wciy5j2kFo2L84Xq o+IkG1e3IH8HDiZ3rXoPKtdCU8sYTlSbAdR5x0oB/x79NmmpE03d/f6apBkCCUiEqhbvAf HFo42KzUra4r4fVc2jkJo4Nx3wJFRr4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-52-ZgPb23zVNDC8VDCiTi4aiA-1; Sun, 07 Nov 2021 21:14:54 -0500 X-MC-Unique: ZgPb23zVNDC8VDCiTi4aiA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 481C8102CB2B for ; Mon, 8 Nov 2021 02:14:53 +0000 (UTC) Received: from liwang-workstation.nay.redhat.com (unknown [10.66.81.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 782C15C1A1 for ; Mon, 8 Nov 2021 02:14:52 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Mon, 8 Nov 2021 10:14:48 +0800 Message-Id: <20211108021450.1460819-1-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=liwang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v3 1/3] lib: adding .supported_archs field in tst_test structure X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Testcases for specific arch should be limited on that only being supported platform to run, we now involve a .supported_archs to achieve this feature in LTP library. All you need to run a test on the expected arch is to set the '.supported_archs' array in the 'struct tst_test' to choose the required arch list. e.g. .supported_archs = (const char *const []){"x86_64", "ppc64", NULL} This helps move the TCONF info from code to tst_test metadata as well. And, we also export a struct tst_arch to save the system architecture for using in the whole test cases. extern struct arch { char name[16]; enum tst_arch_type type; } tst_arch; Signed-off-by: Li Wang --- doc/c-test-api.txt | 36 +++++++++++++++ include/tst_arch.h | 39 ++++++++++++++++ include/tst_test.h | 10 +++++ lib/tst_arch.c | 108 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 193 insertions(+) create mode 100644 include/tst_arch.h create mode 100644 lib/tst_arch.c diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt index 3127018a4..5e32b7075 100644 --- a/doc/c-test-api.txt +++ b/doc/c-test-api.txt @@ -2261,6 +2261,42 @@ struct tst_test test = { }; ------------------------------------------------------------------------------- +1.39 Testing on the specific architecture +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Testcases for specific arch should be limited on that only being supported +platform to run, we now involve a .supported_archs to achieve this feature +in LTP library. All you need to run a test on the expected arch is to set +the '.supported_archs' array in the 'struct tst_test' to choose the required +arch list. e.g. + + .supported_archs = (const char *const []){"x86_64", "ppc64", NULL} + +This helps move the TCONF info from code to tst_test metadata as well. + +And, we also export a struct tst_arch to save the system architecture for +using in the whole test cases. + + extern struct arch { + char name[16]; + enum tst_arch_type type; + } tst_arch; + +[source,c] +------------------------------------------------------------------------------- +#include "tst_test.h" + +static struct tst_test test = { + ... + .setup = setup, + .supported_archs = (const char *const []) { + "x86_64", + "ppc64", + "s390x", + NULL + }, +}; +------------------------------------------------------------------------------- + 2. Common problems ------------------ diff --git a/include/tst_arch.h b/include/tst_arch.h new file mode 100644 index 000000000..784c3093b --- /dev/null +++ b/include/tst_arch.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (c) 2021 Li Wang + */ + +#ifndef TST_ARCH_H__ +#define TST_ARCH_H__ + +enum tst_arch_type { + TST_I386, + TST_X86, + TST_X86_64, + TST_IA64, + TST_PPC, + TST_PPC64, + TST_S390, + TST_S390X, + TST_ARM, + TST_AARCH64, + TST_SPARC, +}; + +/* + * This tst_arch is to save the system architecture for + * using in the whole testcase. + */ +extern struct arch { + char name[16]; + enum tst_arch_type type; +} tst_arch; + +/* + * Check if test platform is in the given arch list. If yes return 1, + * otherwise return 0. + * + * @archlist A NULL terminated array of architectures to support. + */ +int tst_is_on_arch(const char *const *archlist); + +#endif /* TST_ARCH_H__ */ diff --git a/include/tst_test.h b/include/tst_test.h index 3dcb45de0..7611520ee 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -43,6 +43,7 @@ #include "tst_fips.h" #include "tst_taint.h" #include "tst_memutils.h" +#include "tst_arch.h" /* * Reports testcase result. @@ -139,6 +140,12 @@ struct tst_test { const char *min_kver; + /* + * The supported_archs is a NULL terminated list of archs the test + * does support. + */ + const char *const *supported_archs; + /* If set the test is compiled out */ const char *tconf_msg; @@ -316,6 +323,9 @@ static struct tst_test test; int main(int argc, char *argv[]) { + if (!tst_is_on_arch(test.supported_archs)) + tst_brk(TCONF, "This arch '%s' is not supported for test!", tst_arch.name); + tst_run_tcases(argc, argv, &test); } diff --git a/lib/tst_arch.c b/lib/tst_arch.c new file mode 100644 index 000000000..ae5817075 --- /dev/null +++ b/lib/tst_arch.c @@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (c) 2021 Li Wang + */ + +#include +#include + +#define TST_NO_DEFAULT_MAIN +#include "tst_arch.h" +#include "tst_test.h" + +struct arch tst_arch; + +static const char *const arch_type_list[] = { + "i386", + "x86", + "x86_64", + "ia64", + "ppc", + "ppc64", + "s390", + "s390x", + "arm", + "aarch64", + "sparc", + NULL +}; + +static int is_matched_arch(const char *arch, const char *name) +{ + if (strcmp(arch, name) == 0) + return 1; + + return 0; +} + +static int is_valid_arch_name(const char *name) +{ + unsigned int i; + + for (i = 0; arch_type_list[i]; i++) { + if (is_matched_arch(arch_type_list[i], name)) + return 1; + } + + return 0; +} + +static void get_system_arch(void) +{ +#if defined(__i386__) + strcpy(tst_arch.name, "i386"); + tst_arch.type = TST_I386; +#elif defined(__x86__) + strcpy(tst_arch.name, "x86"); + tst_arch.type = TST_X86; +#elif defined(__x86_64__) + strcpy(tst_arch.name, "x86_64"); + tst_arch.type = TST_X86_64; +#elif defined(__ia64__) + strcpy(tst_arch.name, "ia64"); + tst_arch.type = TST_IA64; +#elif defined(__powerpc__) + strcpy(tst_arch.name, "ppc"); + tst_arch.type = TST_PPC; +#elif defined(__powerpc64__) + strcpy(tst_arch.name, "ppc64"); + tst_arch.type = TST_PPC64; +#elif defined(__s390x__) + strcpy(tst_arch.name, "s390x"); + tst_arch.type = TST_S390X; +#elif defined(__s390__) + strcpy(tst_arch.name, "s390"); + tst_arch.type = TST_S390; +#elif defined(__arm__) + strcpy(tst_arch.name, "s390x"); + tst_arch.type = TST_ARM; +#elif defined(__aarch64__) + strcpy(tst_arch.name, "aarch64"); + tst_arch.type = TST_AARCH64; +#elif defined(__sparc__) + strcpy(tst_arch.name, "sparc"); + tst_arch.type = TST_SPARC; +#endif +} + +int tst_is_on_arch(const char *const *archlist) +{ + unsigned int i; + + get_system_arch(); + + if (archlist == NULL) + return 1; + + for (i = 0; archlist[i]; i++) { + if (!is_valid_arch_name(archlist[i])) + tst_brk(TBROK, "%s is invalid arch, please reset!", + archlist[i]); + } + + for (i = 0; archlist[i]; i++) { + if (is_matched_arch(tst_arch.name, archlist[i])) + return 1; + } + + return 0; +} From patchwork Mon Nov 8 02:14:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 1552104 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cbmIxhUx; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HnZTg2ZCmz9s0r for ; Mon, 8 Nov 2021 13:15:50 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id CC45C3C75A0 for ; Mon, 8 Nov 2021 03:15:44 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 0D0153C7133 for ; Mon, 8 Nov 2021 03:15:43 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 9C6606006D9 for ; Mon, 8 Nov 2021 03:15:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636337734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=feTJwgKOexsl78gEUvwxbEAPeFkB571ai0f6MlgrNkw=; b=cbmIxhUxHT/pDAlKGXJnfkrLpPa8v75kCkG/LzL3QEhBJLYFdJqJCPnjmFVxESOUkPujZe u84j8OEYWPADZCW7zrBqpfZTsVXMJ8iM+9n3D1y9nLq9fC+PVhtPkPWDZu+4kgEHbadc4t GRlY9mEfV6mv7nIrJW5/VuKpLMzzBag= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-Jw4hC_oFP7K6z85d9I2QmA-1; Sun, 07 Nov 2021 21:14:55 -0500 X-MC-Unique: Jw4hC_oFP7K6z85d9I2QmA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 967D487123E for ; Mon, 8 Nov 2021 02:14:54 +0000 (UTC) Received: from liwang-workstation.nay.redhat.com (unknown [10.66.81.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id C582E5C1A1 for ; Mon, 8 Nov 2021 02:14:53 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Mon, 8 Nov 2021 10:14:49 +0800 Message-Id: <20211108021450.1460819-2-liwang@redhat.com> In-Reply-To: <20211108021450.1460819-1-liwang@redhat.com> References: <20211108021450.1460819-1-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=liwang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v3 2/3] testcase: make use of .supported_archs X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" In some places, we have to keep ifdefs to make the compiler work with unportable code. Signed-off-by: Li Wang --- configure.ac | 1 + testcases/cve/meltdown.c | 16 ++++++----- testcases/kernel/syscalls/ptrace/ptrace07.c | 11 ++++---- testcases/kernel/syscalls/ptrace/ptrace08.c | 22 ++++++++------- testcases/kernel/syscalls/ptrace/ptrace09.c | 11 +++++--- testcases/kernel/syscalls/ptrace/ptrace10.c | 12 +++++---- .../syscalls/set_mempolicy/set_mempolicy05.c | 27 +++++++++---------- 7 files changed, 54 insertions(+), 46 deletions(-) diff --git a/configure.ac b/configure.ac index 5bf3c52ec..7efd9df87 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,7 @@ AC_CHECK_DECLS([SEM_STAT_ANY],,,[#include ]) AC_CHECK_HEADERS_ONCE([ \ asm/ldt.h \ + emmintrin.h \ ifaddrs.h \ keyutils.h \ linux/can.h \ diff --git a/testcases/cve/meltdown.c b/testcases/cve/meltdown.c index 5a984aba3..2577c1a80 100644 --- a/testcases/cve/meltdown.c +++ b/testcases/cve/meltdown.c @@ -6,8 +6,6 @@ #include "config.h" #include "tst_test.h" -#if defined(__x86_64__) || defined(__i386__) - #include #include #include @@ -17,6 +15,7 @@ #include #include +#ifdef HAVE_EMMINTRIN_H #include #include "tst_tsc.h" @@ -378,14 +377,17 @@ static struct tst_test test = { .test_all = run, .cleanup = cleanup, .min_kver = "2.6.32", + .supported_archs = (const char *const []) { + "i386", + "x86_64", + NULL + }, .tags = (const struct tst_tag[]) { {"CVE", "2017-5754"}, {} } }; -#else /* #if defined(__x86_64__) || defined(__i386__) */ - -TST_TEST_TCONF("not x86_64 or i386"); - -#endif /* #else #if defined(__x86_64__) || defined(__i386__) */ +#else /* HAVE_EMMINTRIN_H */ + TST_TEST_TCONF(" is not supported"); +#endif diff --git a/testcases/kernel/syscalls/ptrace/ptrace07.c b/testcases/kernel/syscalls/ptrace/ptrace07.c index 9e3f7511d..da62cadb0 100644 --- a/testcases/kernel/syscalls/ptrace/ptrace07.c +++ b/testcases/kernel/syscalls/ptrace/ptrace07.c @@ -48,13 +48,13 @@ # define NT_X86_XSTATE 0x202 #endif -#ifdef __x86_64__ static void check_regs_loop(uint32_t initval) { const unsigned long num_iters = 1000000000; uint32_t xmm0[4] = { initval, initval, initval, initval }; int status = 1; +#ifdef __x86_64__ asm volatile(" movdqu %0, %%xmm0\n" " mov %0, %%rbx\n" "1: dec %2\n" @@ -68,6 +68,7 @@ static void check_regs_loop(uint32_t initval) "3:\n" : "+m" (xmm0), "+r" (status) : "r" (num_iters) : "rax", "rbx", "xmm0"); +#endif if (status) { tst_res(TFAIL, @@ -178,6 +179,10 @@ static struct tst_test test = { .test_all = do_test, .forks_child = 1, .needs_checkpoints = 1, + .supported_archs = (const char *const []) { + "x86_64", + NULL + }, .tags = (const struct tst_tag[]) { {"linux-git", "814fb7bb7db5"}, {"CVE", "2017-15537"}, @@ -185,7 +190,3 @@ static struct tst_test test = { } }; - -#else /* !__x86_64__ */ - TST_TEST_TCONF("this test is only supported on x86_64"); -#endif /* __x86_64__ */ diff --git a/testcases/kernel/syscalls/ptrace/ptrace08.c b/testcases/kernel/syscalls/ptrace/ptrace08.c index f86f69a9c..77c4c10c3 100644 --- a/testcases/kernel/syscalls/ptrace/ptrace08.c +++ b/testcases/kernel/syscalls/ptrace/ptrace08.c @@ -43,18 +43,16 @@ #include "tst_test.h" #include "tst_safe_stdio.h" -#if defined(__i386__) || defined(__x86_64__) - static pid_t child_pid; -#if defined(__x86_64__) -# define KERN_ADDR_MIN 0xffff800000000000 -# define KERN_ADDR_MAX 0xffffffffffffffff -# define KERN_ADDR_BITS 64 -#elif defined(__i386__) +#if defined(__i386__) # define KERN_ADDR_MIN 0xc0000000 # define KERN_ADDR_MAX 0xffffffff # define KERN_ADDR_BITS 32 +#else +# define KERN_ADDR_MIN 0xffff800000000000 +# define KERN_ADDR_MAX 0xffffffffffffffff +# define KERN_ADDR_BITS 64 #endif static int deffered_check; @@ -106,6 +104,7 @@ static void ptrace_try_kern_addr(unsigned long kern_addr) if (SAFE_WAITPID(child_pid, &status, WUNTRACED) != child_pid) tst_brk(TBROK, "Received event from unexpected PID"); +#if defined(__i386__) || defined(__x86_64__) SAFE_PTRACE(PTRACE_ATTACH, child_pid, NULL, NULL); SAFE_PTRACE(PTRACE_POKEUSER, child_pid, (void *)offsetof(struct user, u_debugreg[0]), (void *)1); @@ -135,6 +134,7 @@ static void ptrace_try_kern_addr(unsigned long kern_addr) addr = ptrace(PTRACE_PEEKUSER, child_pid, (void*)offsetof(struct user, u_debugreg[0]), NULL); +#endif if (!deffered_check && addr == kern_addr) tst_res(TFAIL, "Was able to set breakpoint on kernel addr"); @@ -164,6 +164,11 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .forks_child = 1, + .supported_archs = (const char *const []) { + "i386", + "x86_64", + NULL + }, .tags = (const struct tst_tag[]) { {"linux-git", "f67b15037a7a"}, {"CVE", "2018-1000199"}, @@ -171,6 +176,3 @@ static struct tst_test test = { {} } }; -#else -TST_TEST_TCONF("This test is only supported on x86 systems"); -#endif diff --git a/testcases/kernel/syscalls/ptrace/ptrace09.c b/testcases/kernel/syscalls/ptrace/ptrace09.c index 85875ce65..8ccdfcc4b 100644 --- a/testcases/kernel/syscalls/ptrace/ptrace09.c +++ b/testcases/kernel/syscalls/ptrace/ptrace09.c @@ -22,7 +22,6 @@ #include #include "tst_test.h" -#if defined(__i386__) || defined(__x86_64__) static short watchpoint; static pid_t child_pid; @@ -46,6 +45,7 @@ static void run(void) { int status; +#if defined(__i386__) || defined(__x86_64__) child_pid = SAFE_FORK(); if (!child_pid) { @@ -60,6 +60,7 @@ static void run(void) SAFE_PTRACE(PTRACE_POKEUSER, child_pid, (void *)offsetof(struct user, u_debugreg[7]), (void *)0x30001); SAFE_PTRACE(PTRACE_CONT, child_pid, NULL, NULL); +#endif while (1) { if (SAFE_WAITPID(child_pid, &status, 0) != child_pid) @@ -92,12 +93,14 @@ static struct tst_test test = { .test_all = run, .cleanup = cleanup, .forks_child = 1, + .supported_archs = (const char *const []) { + "i386", + "x86_64", + NULL + }, .tags = (const struct tst_tag[]) { {"linux-git", "d8ba61ba58c8"}, {"CVE", "2018-8897"}, {} } }; -#else -TST_TEST_TCONF("This test is only supported on x86 systems"); -#endif diff --git a/testcases/kernel/syscalls/ptrace/ptrace10.c b/testcases/kernel/syscalls/ptrace/ptrace10.c index b5d6b9f8f..3bd8ca1a9 100644 --- a/testcases/kernel/syscalls/ptrace/ptrace10.c +++ b/testcases/kernel/syscalls/ptrace/ptrace10.c @@ -22,8 +22,6 @@ #include #include "tst_test.h" -#if defined(__i386__) || defined(__x86_64__) - static pid_t child_pid; static void child_main(void) @@ -45,6 +43,7 @@ static void run(void) if (SAFE_WAITPID(child_pid, &status, WUNTRACED) != child_pid) tst_brk(TBROK, "Received event from unexpected PID"); +#if defined(__i386__) || defined(__x86_64__) SAFE_PTRACE(PTRACE_ATTACH, child_pid, NULL, NULL); SAFE_PTRACE(PTRACE_POKEUSER, child_pid, (void *)offsetof(struct user, u_debugreg[0]), (void *)1); @@ -53,6 +52,7 @@ static void run(void) addr = ptrace(PTRACE_PEEKUSER, child_pid, (void*)offsetof(struct user, u_debugreg[0]), NULL); +#endif if (addr == 2) tst_res(TPASS, "The rd0 was set on second PTRACE_POKEUSR"); @@ -76,11 +76,13 @@ static struct tst_test test = { .test_all = run, .cleanup = cleanup, .forks_child = 1, + .supported_archs = (const char *const []) { + "i386", + "x86_64", + NULL + }, .tags = (const struct tst_tag[]) { {"linux-git", "bd14406b78e6"}, {} } }; -#else -TST_TEST_TCONF("This test is only supported on x86 systems"); -#endif diff --git a/testcases/kernel/syscalls/set_mempolicy/set_mempolicy05.c b/testcases/kernel/syscalls/set_mempolicy/set_mempolicy05.c index 86f6a95dc..f56b7b26f 100644 --- a/testcases/kernel/syscalls/set_mempolicy/set_mempolicy05.c +++ b/testcases/kernel/syscalls/set_mempolicy/set_mempolicy05.c @@ -37,18 +37,10 @@ #include "config.h" #include "tst_test.h" -#if defined(__i386__) || defined(__powerpc__) - #include static unsigned int i; static int sys_ret; -#ifdef __i386__ -static const int sys_num = 276; -static const int mode; -static const int node_mask_ptr = UINT_MAX; -static const int node_mask_sz = UINT_MAX; -#endif static volatile char *stack_ptr; static void run(void) @@ -58,6 +50,11 @@ static void run(void) register long mode __asm__("r3"); register long node_mask_ptr __asm__("r4"); register long node_mask_sz __asm__("r5"); +#else + static const int sys_num = 276; + static const int mode; + static const int node_mask_ptr = UINT_MAX; + static const int node_mask_sz = UINT_MAX; #endif char stack_pattern[0x400]; @@ -78,7 +75,8 @@ static void run(void) : "memory", "cr0", "r6", "r7", "r8", "r9", "r10", "r11", "r12"); sys_ret = mode; -#else /* __i386__ */ +#endif +#ifdef __i386__ asm volatile ( "add $0x400, %%esp\n\t" "int $0x80\n\t" @@ -114,15 +112,14 @@ static void run(void) static struct tst_test test = { .test_all = run, + .supported_archs = (const char *const []) { + "i386", + "ppc", + NULL + }, .tags = (const struct tst_tag[]) { {"linux-git", "cf01fb9985e8"}, {"CVE", "CVE-2017-7616"}, {} } }; - -#else /* #if defined(__x86_64__) || defined(__powerpc__) */ - -TST_TEST_TCONF("not i386 or powerpc"); - -#endif /* #else #if defined(__x86_64__) || defined(__powerpc__) */ From patchwork Mon Nov 8 02:14:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 1552103 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CFsOU9x2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HnZSx0x3Bz9s0r for ; Mon, 8 Nov 2021 13:15:13 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 00B913C7636 for ; Mon, 8 Nov 2021 03:15:11 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id B0DDB3C7596 for ; Mon, 8 Nov 2021 03:15:00 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id F16C06006E2 for ; Mon, 8 Nov 2021 03:14:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636337698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hKsAXmV5gW9g+49mGhyB9lZcJ+eePNGMtA7qaeoSxdc=; b=CFsOU9x2qWR8yTlBSlU/dG1sBCcGhwmEtRrHm582ApgdP/b74lzxsNG4gj56VCesXYxeDs pFTniqBNDvoHtcrSDdyxETr0uF0fCMUDdu237x5vPVxCiZiULEkCKCVacvDbkzTITkrIr4 /iNqXi8eWMGRr7K8oGXcZawtBHK4Hgw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495--Df1mvtZMNCqc0MNzULroA-1; Sun, 07 Nov 2021 21:14:56 -0500 X-MC-Unique: -Df1mvtZMNCqc0MNzULroA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1E0C1006AA1 for ; Mon, 8 Nov 2021 02:14:55 +0000 (UTC) Received: from liwang-workstation.nay.redhat.com (unknown [10.66.81.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E5D26788F for ; Mon, 8 Nov 2021 02:14:54 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Mon, 8 Nov 2021 10:14:50 +0800 Message-Id: <20211108021450.1460819-3-liwang@redhat.com> In-Reply-To: <20211108021450.1460819-1-liwang@redhat.com> References: <20211108021450.1460819-1-liwang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=liwang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v3 3/3] max_map_count: replace ifdefs by tst_arch X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Li Wang --- testcases/kernel/mem/tunable/max_map_count.c | 41 +++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/testcases/kernel/mem/tunable/max_map_count.c b/testcases/kernel/mem/tunable/max_map_count.c index 4f0ad0037..9da67520c 100644 --- a/testcases/kernel/mem/tunable/max_map_count.c +++ b/testcases/kernel/mem/tunable/max_map_count.c @@ -91,24 +91,29 @@ static bool filter_map(const char *line) if (ret != 1) return false; -#if defined(__x86_64__) || defined(__x86__) - /* On x86, there's an old compat vsyscall page */ - if (!strcmp(buf, "[vsyscall]")) - return true; -#elif defined(__ia64__) - /* On ia64, the vdso is not a proper mapping */ - if (!strcmp(buf, "[vdso]")) - return true; -#elif defined(__arm__) - /* Skip it when run it in aarch64 */ - if ((!strcmp(un.machine, "aarch64")) - || (!strcmp(un.machine, "aarch64_be"))) - return false; - - /* Older arm kernels didn't label their vdso maps */ - if (!strncmp(line, "ffff0000-ffff1000", 17)) - return true; -#endif + switch (tst_arch.type) { + case TST_X86: + case TST_X86_64: + /* On x86, there's an old compat vsyscall page */ + if (!strcmp(buf, "[vsyscall]")) + return true; + break; + case TST_IA64: + /* On ia64, the vdso is not a proper mapping */ + if (!strcmp(buf, "[vdso]")) + return true; + break; + case TST_ARM: + /* Skip it when run it in aarch64 */ + if ((!strcmp(un.machine, "aarch64")) + || (!strcmp(un.machine, "aarch64_be"))) + return false; + + /* Older arm kernels didn't label their vdso maps */ + if (!strncmp(line, "ffff0000-ffff1000", 17)) + return true; + break; + }; return false; }