Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4959298rdb; Fri, 29 Dec 2023 23:04:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+In3wXUyQ3Wv8S02iZ4FlnHrVloVZiWJyzCYSMe7onNrWglLWnumYze4bQHx9vHBLrbKB X-Received: by 2002:ac8:5986:0:b0:425:8359:712b with SMTP id e6-20020ac85986000000b004258359712bmr18263614qte.129.1703919891176; Fri, 29 Dec 2023 23:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703919891; cv=none; d=google.com; s=arc-20160816; b=p7bLJYdJXRdn7M9Zq+0Uw38sUmclrawA56H4DmilJ14D+7vdGxvrc4phbZz5PTQeA2 dctlTMMuCU+7m6i3zT+YD1cDga08qgNqm8ksZkZxyRpzENecSdCggt8OtTLXetesHWEX 1wjYxS4w3w1tz0azJkzUr5cHKHntiCGLYfarujtAfQ8MqqSnDC/E7dzsiTEWMWrMoxwq rHAbFGLVeyw55b74OJ5Xp+sYcxJ3ujth1fk6ZtgI8RxLyfb2HoTk/rjkAFActPYI0ZxW +R4Z93mlwQ2XpHVxiGOiwep6Mns+5AtDsELjdwhn4W/3ug6P3p5hI59PsOifLxLTkl7Z ILAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:cc:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=NFt8D3nUaxTzVGgyi1Xhpwj06qKThoc1XQB2Ad4PkOs=; fh=avpu5u/TpSwNlPGspmWv8vq8WYaEN7GD7Dlo4d5X3Hg=; b=hYEt8Ea/LMIHG1chSVPF8icu7LFoNZ7elhJGPGcY0CA6LJG8kqi9tsNnP9U2dANqg9 AVxKVNtPGWxFns3sJI68KXdoPoEQFCOsgUFqmC71EMPFMuHmS8PHFzLzZMyv18YmnRUA 4vGodVsvyuaJ8rpgHtr8U0f8XI6HbyL7+WOYvqP4LL32sz3PWf+4MC8XM0/mqa7+zBur le0sn1iQiA5IDeX3ufH7FBxKI17SoOInmfrLM+WgqHsbWm1N6aJsH5Lo1VMu8jCOM2hE MwZPi45Lcxn4hZsSclYzdZDOIwBpqmivi3zr9hJEwyVf8wAdnJbMYeimGl+ZgeJjpJT4 Q/Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=X32tBU+R; spf=pass (google.com: domain of linux-kernel+bounces-13346-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13346-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v40-20020a05622a18a800b004260c6e3af5si19866976qtc.161.2023.12.29.23.04.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 23:04:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13346-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=X32tBU+R; spf=pass (google.com: domain of linux-kernel+bounces-13346-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13346-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 40F631C20AFE for ; Sat, 30 Dec 2023 07:04:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E815A1FC5; Sat, 30 Dec 2023 07:04:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="X32tBU+R" X-Original-To: linux-kernel@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C90F23AF; Sat, 30 Dec 2023 07:04:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1703919877; bh=regxFrkzSDh5tQmV2aWZG9LxLgfUKQzyJQP28ZnTBLw=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=X32tBU+RYg2E4kUPD0bN1ogiP6NkmeL0heVSakadSIsCmfRMIYw4/bd4ZR6wqecpf 1W3vbvYqubVLnec52Uvh5/gsx7cQn9AO5n3GqlSnpBTAx4gTEf/qkezbV/NrAI4R+V 7KDOlSNSHrt/J2HZhYNQdn2SrrPBtieYXoKJSR0t4PCyaqHEdqep0tZiXYxC449kam tImMzQNNY7vg5UJ/OpOndri1jenbnLUd4IcTz9h51wuyberh6NecFzjWECaT5ZUUUK K/xFOSX66KOwmo0YdVWnzy7Or0Xs6NGm2JNZYNBkAO5Rjk2NsLcIqPtlRqJU6gMP4R c5k3QvMpsaLiA== Received: from [100.96.234.34] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 82410378045F; Sat, 30 Dec 2023 07:04:35 +0000 (UTC) Message-ID: Date: Sat, 30 Dec 2023 12:04:35 +0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: Muhammad Usama Anjum , linux-kselftest@vger.kernel.org, loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] selftests/vDSO: Fix runtime errors on LoongArch Content-Language: en-US To: Tiezhu Yang , Shuah Khan , Shuah Khan References: <20231213012300.5640-1-yangtiezhu@loongson.cn> <20231213012300.5640-3-yangtiezhu@loongson.cn> From: Muhammad Usama Anjum In-Reply-To: <20231213012300.5640-3-yangtiezhu@loongson.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/13/23 6:23 AM, Tiezhu Yang wrote: > It could not find __vdso_getcpu and __vdso_gettimeofday when test > getcpu and gettimeofday on LoongArch. > > # make headers && cd tools/testing/selftests/vDSO && make > # ./vdso_test_getcpu > Could not find __vdso_getcpu > # ./vdso_test_gettimeofday > Could not find __vdso_gettimeofday > > One simple way is to add LoongArch case to define version and name, > just like commit d942f231afc0 ("selftests/vDSO: Add riscv getcpu & > gettimeofday test"), but it is not the best way. > > Since each architecture has already defined names and versions in > vdso_config.h, it is proper to include vdso_config.h to get version > and name for all archs. > > Signed-off-by: Tiezhu Yang Reviewed-by: Muhammad Usama Anjum Tested on x86, works fine. Tested-by: Muhammad Usama Anjum > --- > .../testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++------- > .../selftests/vDSO/vdso_test_gettimeofday.c | 26 +++++-------------- > 2 files changed, 13 insertions(+), 29 deletions(-) > > diff --git a/tools/testing/selftests/vDSO/vdso_test_getcpu.c b/tools/testing/selftests/vDSO/vdso_test_getcpu.c > index 1df5d057d79f..b758f68c6c9c 100644 > --- a/tools/testing/selftests/vDSO/vdso_test_getcpu.c > +++ b/tools/testing/selftests/vDSO/vdso_test_getcpu.c > @@ -13,13 +13,7 @@ > > #include "../kselftest.h" > #include "parse_vdso.h" > - > -#if defined(__riscv) > -const char *version = "LINUX_4.15"; > -#else > -const char *version = "LINUX_2.6"; > -#endif > -const char *name = "__vdso_getcpu"; > +#include "vdso_config.h" > > struct getcpu_cache; > typedef long (*getcpu_t)(unsigned int *, unsigned int *, > @@ -27,6 +21,8 @@ typedef long (*getcpu_t)(unsigned int *, unsigned int *, > > int main(int argc, char **argv) > { > + const char *version = versions[VDSO_VERSION]; > + const char **name = (const char **)&names[VDSO_NAMES]; > unsigned long sysinfo_ehdr; > unsigned int cpu, node; > getcpu_t get_cpu; > @@ -40,9 +36,9 @@ int main(int argc, char **argv) > > vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR)); > > - get_cpu = (getcpu_t)vdso_sym(version, name); > + get_cpu = (getcpu_t)vdso_sym(version, name[4]); > if (!get_cpu) { > - printf("Could not find %s\n", name); > + printf("Could not find %s\n", name[4]); > return KSFT_SKIP; > } > > @@ -50,7 +46,7 @@ int main(int argc, char **argv) > if (ret == 0) { > printf("Running on CPU %u node %u\n", cpu, node); > } else { > - printf("%s failed\n", name); > + printf("%s failed\n", name[4]); > return KSFT_FAIL; > } > > diff --git a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c > index e411f287a426..ee4f1ca56a71 100644 > --- a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c > +++ b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c > @@ -18,25 +18,13 @@ > > #include "../kselftest.h" > #include "parse_vdso.h" > - > -/* > - * ARM64's vDSO exports its gettimeofday() implementation with a different > - * name and version from other architectures, so we need to handle it as > - * a special case. > - */ > -#if defined(__aarch64__) > -const char *version = "LINUX_2.6.39"; > -const char *name = "__kernel_gettimeofday"; > -#elif defined(__riscv) > -const char *version = "LINUX_4.15"; > -const char *name = "__vdso_gettimeofday"; > -#else > -const char *version = "LINUX_2.6"; > -const char *name = "__vdso_gettimeofday"; > -#endif > +#include "vdso_config.h" > > int main(int argc, char **argv) > { > + const char *version = versions[VDSO_VERSION]; > + const char **name = (const char **)&names[VDSO_NAMES]; > + > unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR); > if (!sysinfo_ehdr) { > printf("AT_SYSINFO_EHDR is not present!\n"); > @@ -47,10 +35,10 @@ int main(int argc, char **argv) > > /* Find gettimeofday. */ > typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz); > - gtod_t gtod = (gtod_t)vdso_sym(version, name); > + gtod_t gtod = (gtod_t)vdso_sym(version, name[0]); > > if (!gtod) { > - printf("Could not find %s\n", name); > + printf("Could not find %s\n", name[0]); > return KSFT_SKIP; > } > > @@ -61,7 +49,7 @@ int main(int argc, char **argv) > printf("The time is %lld.%06lld\n", > (long long)tv.tv_sec, (long long)tv.tv_usec); > } else { > - printf("%s failed\n", name); > + printf("%s failed\n", name[0]); > return KSFT_FAIL; > } > -- BR, Muhammad Usama Anjum