From patchwork Fri May 22 16:21:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 208479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1E67C433DF for ; Fri, 22 May 2020 16:21:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8255E2070A for ; Fri, 22 May 2020 16:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590164507; bh=4iCCz19po9xgnLGsbZnbbWXeps6ukThnpnJYA9jeKPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Ab8mNGca4BdAtBldrsZQ5Q3sME3XenM4aXUz/4QR2a2Rhf6vR09BeuH20PhhdSXvG mULlzkdQRaa3dnyPUA5R3iXyqRvBXqtt7+H7xsCj+2I/ixn2MtrXvJU/Jh2aTh9MU2 Uc3d0Ky+/oiNFL/sL2imuQH7ZVMbWTJRICEWQG0E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730426AbgEVQVq (ORCPT ); Fri, 22 May 2020 12:21:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:47872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729040AbgEVQVq (ORCPT ); Fri, 22 May 2020 12:21:46 -0400 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9B8302070A; Fri, 22 May 2020 16:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590164506; bh=4iCCz19po9xgnLGsbZnbbWXeps6ukThnpnJYA9jeKPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MgqfJvbxMkvyX0udkCBml+bGT9q6xY2DoauxPVho2VC0OKJwpaaWPOq76363JSQ9h aDIAlKsqkV6P/2nJGP397JELBG+UKH6JWQjlTqjfnVFRbMUC0k8LgqkvdCJ4ZNL9LX fh86HsbXT7l2eUT4YekrnyFh+UiC88XKOgWm8/7I= From: Mark Brown To: Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v3 1/3] selftests: vdso: Rename vdso_test to vdso_test_gettimeofday Date: Fri, 22 May 2020 17:21:37 +0100 Message-Id: <20200522162139.44380-2-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522162139.44380-1-broonie@kernel.org> References: <20200522162139.44380-1-broonie@kernel.org> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently the vDSO kselftests have a test called vdso_test which tests the vDSO implementation of gettimeofday(). In preparation for adding tests for other vDSO functionality rename this test to reflect what's going on. Signed-off-by: Mark Brown --- tools/testing/selftests/vDSO/.gitignore | 1 + tools/testing/selftests/vDSO/Makefile | 4 ++-- .../selftests/vDSO/{vdso_test.c => vdso_test_gettimeofday.c} | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) rename tools/testing/selftests/vDSO/{vdso_test.c => vdso_test_gettimeofday.c} (89%) diff --git a/tools/testing/selftests/vDSO/.gitignore b/tools/testing/selftests/vDSO/.gitignore index 382cfb39a1a3..74f49bd5f6dd 100644 --- a/tools/testing/selftests/vDSO/.gitignore +++ b/tools/testing/selftests/vDSO/.gitignore @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only vdso_test +vdso_test_gettimeofday vdso_standalone_test_x86 diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile index 9e03d61f52fd..ae15d700b62e 100644 --- a/tools/testing/selftests/vDSO/Makefile +++ b/tools/testing/selftests/vDSO/Makefile @@ -4,7 +4,7 @@ include ../lib.mk uname_M := $(shell uname -m 2>/dev/null || echo not) ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) -TEST_GEN_PROGS := $(OUTPUT)/vdso_test +TEST_GEN_PROGS := $(OUTPUT)/vdso_test_gettimeofday ifeq ($(ARCH),x86) TEST_GEN_PROGS += $(OUTPUT)/vdso_standalone_test_x86 endif @@ -17,7 +17,7 @@ LDLIBS += -lgcc_s endif all: $(TEST_GEN_PROGS) -$(OUTPUT)/vdso_test: parse_vdso.c vdso_test.c +$(OUTPUT)/vdso_test_gettimeofday: parse_vdso.c vdso_test_gettimeofday.c $(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c $(CC) $(CFLAGS) $(CFLAGS_vdso_standalone_test_x86) \ vdso_standalone_test_x86.c parse_vdso.c \ diff --git a/tools/testing/selftests/vDSO/vdso_test.c b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c similarity index 89% rename from tools/testing/selftests/vDSO/vdso_test.c rename to tools/testing/selftests/vDSO/vdso_test_gettimeofday.c index 719d5a6bd664..511c0dc5e47e 100644 --- a/tools/testing/selftests/vDSO/vdso_test.c +++ b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c @@ -1,10 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * vdso_test.c: Sample code to test parse_vdso.c + * vdso_test_gettimeofday.c: Sample code to test parse_vdso.c and + * vDSO gettimeofday() * Copyright (c) 2014 Andy Lutomirski * * Compile with: - * gcc -std=gnu99 vdso_test.c parse_vdso.c + * gcc -std=gnu99 vdso_test_gettimeofday.c parse_vdso_gettimeofday.c * * Tested on x86, 32-bit and 64-bit. It may work on other architectures, too. */ From patchwork Fri May 22 16:21:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 208478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 891FBC433DF for ; Fri, 22 May 2020 16:21:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6937520727 for ; Fri, 22 May 2020 16:21:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590164514; bh=Stxmy5bjtizNU8Nx6Mslgp2T+FmzRshtXGRDcZodBIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hYWHsH+GLgGCkrYRKroK3+YtulxyVcV878KkjtmPNV0A+o17iUR0DQblVeLqtn8HQ SwQmbDZTB7x6+L2pwV2CMp8YnFItGeJqpZ0NA6LsBhsZLngS0Lr2OEVr7zdbphEsaD Fk9YW2s/VFIOCRUxUykxSJtiCEkTLGR6Yts+4xMw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729040AbgEVQVx (ORCPT ); Fri, 22 May 2020 12:21:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:48032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730537AbgEVQVw (ORCPT ); Fri, 22 May 2020 12:21:52 -0400 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 641E820756; Fri, 22 May 2020 16:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590164512; bh=Stxmy5bjtizNU8Nx6Mslgp2T+FmzRshtXGRDcZodBIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nC4Fjt+V7HSlwjlv0oD9X6Q57rCFAoKe3tDUwZ/ilw9ZqYEeo4MQvTQUKfqltWNZU ZvlSMpOgOBOdSkyaGvbU2DCc/mOPKbpIA38cIkaphdqCnNy8ek0wD/1Z2edlJoZpQI yopvNB09RWTBE/0xHkUwmO81x8Su1mx4f4KM5nFQ= From: Mark Brown To: Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v3 3/3] selftests: vdso: Add a selftest for vDSO getcpu() Date: Fri, 22 May 2020 17:21:39 +0100 Message-Id: <20200522162139.44380-4-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200522162139.44380-1-broonie@kernel.org> References: <20200522162139.44380-1-broonie@kernel.org> MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Provide a very basic selftest for getcpu() which similarly to our existing test for gettimeofday() looks up the function in the vDSO and prints the results it gets if the function exists and succeeds. Signed-off-by: Mark Brown --- tools/testing/selftests/vDSO/.gitignore | 1 + tools/testing/selftests/vDSO/Makefile | 3 +- .../testing/selftests/vDSO/vdso_test_getcpu.c | 54 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/vDSO/vdso_test_getcpu.c diff --git a/tools/testing/selftests/vDSO/.gitignore b/tools/testing/selftests/vDSO/.gitignore index 74f49bd5f6dd..5eb64d41e541 100644 --- a/tools/testing/selftests/vDSO/.gitignore +++ b/tools/testing/selftests/vDSO/.gitignore @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only vdso_test vdso_test_gettimeofday +vdso_test_getcpu vdso_standalone_test_x86 diff --git a/tools/testing/selftests/vDSO/Makefile b/tools/testing/selftests/vDSO/Makefile index ae15d700b62e..0069f2f83f86 100644 --- a/tools/testing/selftests/vDSO/Makefile +++ b/tools/testing/selftests/vDSO/Makefile @@ -4,7 +4,7 @@ include ../lib.mk uname_M := $(shell uname -m 2>/dev/null || echo not) ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) -TEST_GEN_PROGS := $(OUTPUT)/vdso_test_gettimeofday +TEST_GEN_PROGS := $(OUTPUT)/vdso_test_gettimeofday $(OUTPUT)/vdso_test_getcpu ifeq ($(ARCH),x86) TEST_GEN_PROGS += $(OUTPUT)/vdso_standalone_test_x86 endif @@ -18,6 +18,7 @@ endif all: $(TEST_GEN_PROGS) $(OUTPUT)/vdso_test_gettimeofday: parse_vdso.c vdso_test_gettimeofday.c +$(OUTPUT)/vdso_test_getcpu: parse_vdso.c vdso_test_getcpu.c $(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c $(CC) $(CFLAGS) $(CFLAGS_vdso_standalone_test_x86) \ vdso_standalone_test_x86.c parse_vdso.c \ diff --git a/tools/testing/selftests/vDSO/vdso_test_getcpu.c b/tools/testing/selftests/vDSO/vdso_test_getcpu.c new file mode 100644 index 000000000000..fc25ede131b8 --- /dev/null +++ b/tools/testing/selftests/vDSO/vdso_test_getcpu.c @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * vdso_test_getcpu.c: Sample code to test parse_vdso.c and vDSO getcpu() + * + * Copyright (c) 2020 Arm Ltd + */ + +#include +#include +#include +#include +#include + +#include "../kselftest.h" +#include "parse_vdso.h" + +const char *version = "LINUX_2.6"; +const char *name = "__vdso_getcpu"; + +struct getcpu_cache; +typedef long (*getcpu_t)(unsigned int *, unsigned int *, + struct getcpu_cache *); + +int main(int argc, char **argv) +{ + unsigned long sysinfo_ehdr; + unsigned int cpu, node; + getcpu_t get_cpu; + long ret; + + sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); + if (!sysinfo_ehdr) { + printf("AT_SYSINFO_EHDR is not present!\n"); + return KSFT_SKIP; + } + + vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR)); + + get_cpu = (getcpu_t)vdso_sym(version, name); + if (!get_cpu) { + printf("Could not find %s\n", name); + return KSFT_SKIP; + } + + ret = get_cpu(&cpu, &node, 0); + if (ret == 0) { + printf("Running on CPU %u node %u\n", cpu, node); + } else { + printf("%s failed\n", name); + return KSFT_FAIL; + } + + return 0; +}