From patchwork Fri Jun 14 23:31:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 13699168 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2078.outbound.protection.outlook.com [40.107.244.78]) (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 ECB0518757B; Fri, 14 Jun 2024 23:31:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718407878; cv=fail; b=omAACZnC/sUb3kwfVmTa/xf0I+9IIGua1bPRFlkl9yi7ousrge47eoBTnlN930VOmmrsvZUupOVsd5j10wZAY6oQyhbArmYH5aOmJqJsoBCdaipi8JE2m7l8qGk4DXG0vleulUG4QpTp0KqcIqm/XeKEC+Dps+mYUrYgOPNwuTo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718407878; c=relaxed/simple; bh=fS0h2uo0gjsvRvhFJVYjz4AkAkxlJjbzDCaNBlB9SjM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=tuhHLmIQGSldsTuD9vBAQfaprF+z0et2afvlVzFM/HZNxCJtx7O5RDcMVrBWDx+OSGqosc1rByyXzG66jX5Etxdfo6oCNOOM3UL8/3MoaSME7QOcPrc2qYhidaTMhXzFFPvaL7jKKBDfup7wNC+p3ABSy4DfxG2NNyxALrQycb4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=ew/2LI59; arc=fail smtp.client-ip=40.107.244.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="ew/2LI59" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P3vDPfQ6eC+SDiFXNnPXS++O7++wjMiYD4B6xias1u92vjQ5wm7Ar6+vewZfek5T8dIDajFkbtyzCte7IKT+Zfj7uNhfU6tl0EkHYhrIc/U4zSydKY+s5lvr3uhksZVbucCvYZTsLO1cmiFMqJZrI4gk9PDTr+Gw/7FufDzsm2UDG4iyKD70YzJkARk1FrZnNHzHDWH1FnkUEtkjFl2/7zCOVjck8NzrnwSn8TgDC5izYz7tJA2vbIhQOLV+M8+vJ6BdL1qWUIEIMdC4b8LD9ojnAXTsqJQP7YhY4+mjZUzy8ak38sEWy5g7Z72wouWUsKd+JtxyhjrW4hqk6lErDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qcsnsD1pNMQuFrOynC4BFElE2hN2iFDFASMwNJ9NSK4=; b=kT4LmnLLWHU6jjNjkLQ+RC9Io2TeAk9WxM3l9aLc4sCOtQeSIk/W271P/p98txOxVr00OfeHQIW/L5tNmbSTFJmcJg+urznklO3WyEkaeOV80WcXptaOrWmCRk8g6hB2hX0P2LrlNpyGeyw3FcuNQeHCz2Wz4zmp+T7nUFh/wGV1LeVbhGqhNKLR5Kghv31+pVsvPS19zqRlAn15XffQmyW1IL8q8/wwiounWIcu4LmTdq2rzHE5ECbYlDRAwt4ZXADtEfAVxzq1+0//PHvAVeolp2nRw/UIOEyzvB1FMgWg+89cKFOT+9NC8nwNeV/4ZMsNrXpt//GRVXXD8XJUvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qcsnsD1pNMQuFrOynC4BFElE2hN2iFDFASMwNJ9NSK4=; b=ew/2LI59jL6QMX8cnwkk2wTwInISBmS/t2aVRPbNpWSkV25MtfrVjgSlOJCzeRt/f7DVpiq0vhiOQ0LAyOLDAs8VzbnLMIaAZGLqq7MD7/67Krrds1a++R0Z8FPkYBkbL/LrbLiZ3e1ROozqhMFJ9+r/pUXToA//p4FYx+csRQbLFX3KOMPNUKmlrOw09+OvoUfjfuE1kHxNA8xh4tdqae+PGu9SMrbf01EAbhY+XGBh/BdGQjOGFsOw9bi8fwNO5k8M58LT4VmvlJ7M9iXkrOt640cfzNvm8SsSrx5erodzokVKjC4Y4ImkIkyEaYddyiXbdfdAsnHzxV797ch92A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) by PH7PR12MB6953.namprd12.prod.outlook.com (2603:10b6:510:1ac::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.25; Fri, 14 Jun 2024 23:31:07 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::2cf4:5198:354a:cd07]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::2cf4:5198:354a:cd07%4]) with mapi id 15.20.7677.024; Fri, 14 Jun 2024 23:31:07 +0000 From: John Hubbard To: Shuah Khan Cc: "Jason A . Donenfeld" , Andy Lutomirski , Mark Brown , Vincenzo Frascino , Colin Ian King , Valentin Obst , linux-kselftest@vger.kernel.org, LKML , llvm@lists.linux.dev, John Hubbard , Carlos Llamas , Edward Liaw , Muhammad Usama Anjum Subject: [PATCH v3 1/3] selftests/vDSO: fix clang build errors and warnings Date: Fri, 14 Jun 2024 16:31:03 -0700 Message-ID: <20240614233105.265009-2-jhubbard@nvidia.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240614233105.265009-1-jhubbard@nvidia.com> References: <20240614233105.265009-1-jhubbard@nvidia.com> X-NVConfidentiality: public X-ClientProxiedBy: BY5PR20CA0027.namprd20.prod.outlook.com (2603:10b6:a03:1f4::40) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR12MB4130:EE_|PH7PR12MB6953:EE_ X-MS-Office365-Filtering-Correlation-Id: 398c940d-ef75-4b33-cd45-08dc8cca10ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|366013|7416011|376011; X-Microsoft-Antispam-Message-Info: LsggZN2oP82g04UXiC7EjT2jf49wjUfDEc8Jl5uI73BseraAZEC0qF4kcJPoFkmTl8yz1/I6QGGalefJVUPOut5/fMsiulGiaqdzp2HFXXGWWSzSK29KPqBlOmPGFxpCn3u+0gnLt1SBDr/bSc5cWgpQcFqIdXtgFbH53WZCgkL9L8+tJwGPt5/F74t+qDIFCWBKbn7eBBF0NVx8MPnnXe/qZlARTMl7iChFRD+vD2mQVdftUwJKA4JKLGb5AGSop9e65LwSp/59nG6mg15z5QXYXmrKsw2K+tCvoNVAIFkw9MzeYeYu67xhX9fv1qIOFKjAGT212gtU5fWsdKTTvhS+5odV1N0gAMa80amMQGKIiYxUy/XWBwij7tkc2kp3ZhlhmkZW4U6mhFIBOy98aYmeiZv1N4L4xRWvta1Fu6N3KyRT0FrAHOlf5Z4myAX1g2+X/unuKrP5NXBvE/M0Z2suqcXfJ8092puu7BiPZUquJdBsD+Jlchf/AdmifQ1sOqt6AbIdWNvX73xG0imCfEvqY5xzDL3Kss2PzItzjGdAGcjrC7rHasAkMxD6IGxtwz22sGslv5tvLAquelLSUZgCiyag2h92caJuFt6CYX2XAFtdX6x20giTMPCEIrdkWnEm4ryANuviaqkeeX7Q33lEs2nGWjF7jVqiAYPkKGqmZmJywDEPUXuyBdk9cNpMBPeWMJR6g4Da3twnB5ElkREZewatptdLV/AFGN1rWAUM8GVOArOKmvWm0EG7ug3Ll2x7evqst6X98y1OTd9nD1XUY3TyrQIUUyVz14xdKOsgouSuGaiBusgXj7Hll+NdqHm/438LoVBtxENGXA5qdO0XjEGl+Y671ZAS+w58UWDMSyFbUdL/ifFuf/90zOHakrjNkRQSjct1HLMv5OK6fuKLl+a7eEJg/viCmbg1AeyJrVvwy5v1eZVQA6/lSfCEL4QQT4gbWyHnIc7xjgykrKLrFhqtqNnbnntjBPnd8hLes+Iu4k/nONj3lUdO6XSnUzYMn1AbrEvL3KDuyIcZ1H/qZ2OIPSwAgnInh9rT0aov1a/ucGbAdFZO95Yv7v531N1RPdQB3bGhJqpX+ccTBmk+xNrtn4aiMsHiBfvMLZEWM8uU+cPBFA8r5d1srITL1LKG1SrRwcKOV+fbM3vFFxhopX1KNt0yXWJye9KrPmyZ+/U5E9uY9TGi63FbnwhOEukii9eG5Rqjz4AFAsde/BWVZ6VHiGhiqaLc3acx7DuVEcX+ttH275FC16GMbyaxEZlG41fxuvV/LvFAwb/jHRSbRrdahDiWJC9CY2pqJUkplOkmHCwrreCnvgWUQ0Qv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB4130.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021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/aRlfZlAtgvrj4haygw9wjdn3XykAehs09W6YsPHSfVsxcBTfXs7s4/kUfyWdfhnzPmicpJ06MGIEJ9iRn3XfRwXVLvHH3swJnWaKQ/uDOCxTgmDh+qrRj0QDjJye9nnQMoWLZAV9zS3t00tagI5Q/fS5Vvpwsgypar81Ssc/b438yY50DASrlHvKArAmR/pa1PLlbsdW8u3avWb0up75vm7/x5HbQhVHcwTYzmQaTf4YANqcF8QBS+rx9YVYkulYSYmrZO0kEerY0kNiE0q2G4kwuv2DcZ0ljIm13tGaXADIMsfqMZlwhHrZLa0D9gO8wesRF5lwBV0Va8Zi0KUExwDx3k31s/yln35N8hSJeWceJkpvMHf2lAC/BjpCF7YRwZM8cPBMGPXhxa81rVD5cfVqArsD3LJTSmrezFdwJ/Ngi32tMjJ6PiudxTIskvoe6V/mfIoYrlOMzV64Y3gjVgB2aPan7UrPy7CYO01Sy756K3ZnuS0wBcYk/FUL9DvGiCohEfVFqBNohT+/72Kk7nPaaKPbt2RceBwTbzzpaGV/4cokqjQ4b7gZE4F62cCDcX5mm7iwD6uwRpT4FjLu7kb86inb1zI52K1F4BvjAyMi5LhEOcm X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 398c940d-ef75-4b33-cd45-08dc8cca10ab X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2024 23:31:07.1430 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JWggBYASYUaaqwmMF6nlJeEEh+Cc5EwFNhbOy/aQgfDsSmEWFtziRCGQKNeYKoUHOFCWdDainNEZpF7Vo3rHNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6953 When building with clang, via: make LLVM=1 -C tools/testing/selftests ...there are several warnings, and an error. This fixes all of those and allows these tests to run and pass. 1. Fix linker error (undefined reference to memcpy) by providing a local version of memcpy. 2. clang complains about using this form: if (g = h & 0xf0000000) ...so factor out the assignment into a separate step. 3. The code is passing a signed const char* to elf_hash(), which expects a const unsigned char *. There are several callers, so fix this at the source by allowing the function to accept a signed argument, and then converting to unsigned operations, once inside the function. 4. clang doesn't have __attribute__((externally_visible)) and generates a warning to that effect. Fortunately, gcc 12 and gcc 13 do not seem to require that attribute in order to build, run and pass tests here, so remove it. Reviewed-by: Carlos Llamas Reviewed-by: Edward Liaw Reviewed-by: Muhammad Usama Anjum Tested-by: Muhammad Usama Anjum Signed-off-by: John Hubbard --- tools/testing/selftests/vDSO/parse_vdso.c | 16 +++++++++++----- .../selftests/vDSO/vdso_standalone_test_x86.c | 18 ++++++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c index 413f75620a35..4ae417372e9e 100644 --- a/tools/testing/selftests/vDSO/parse_vdso.c +++ b/tools/testing/selftests/vDSO/parse_vdso.c @@ -55,14 +55,20 @@ static struct vdso_info ELF(Verdef) *verdef; } vdso_info; -/* Straight from the ELF specification. */ -static unsigned long elf_hash(const unsigned char *name) +/* + * Straight from the ELF specification...and then tweaked slightly, in order to + * avoid a few clang warnings. + */ +static unsigned long elf_hash(const char *name) { unsigned long h = 0, g; - while (*name) + const unsigned char *uch_name = (const unsigned char *)name; + + while (*uch_name) { - h = (h << 4) + *name++; - if (g = h & 0xf0000000) + h = (h << 4) + *uch_name++; + g = h & 0xf0000000; + if (g) h ^= g >> 24; h &= ~g; } diff --git a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c index 8a44ff973ee1..27f6fdf11969 100644 --- a/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c +++ b/tools/testing/selftests/vDSO/vdso_standalone_test_x86.c @@ -18,7 +18,7 @@ #include "parse_vdso.h" -/* We need a libc functions... */ +/* We need some libc functions... */ int strcmp(const char *a, const char *b) { /* This implementation is buggy: it never returns -1. */ @@ -34,6 +34,20 @@ int strcmp(const char *a, const char *b) return 0; } +/* + * The clang build needs this, although gcc does not. + * Stolen from lib/string.c. + */ +void *memcpy(void *dest, const void *src, size_t count) +{ + char *tmp = dest; + const char *s = src; + + while (count--) + *tmp++ = *s++; + return dest; +} + /* ...and two syscalls. This is x86-specific. */ static inline long x86_syscall3(long nr, long a0, long a1, long a2) { @@ -70,7 +84,7 @@ void to_base10(char *lastdig, time_t n) } } -__attribute__((externally_visible)) void c_main(void **stack) +void c_main(void **stack) { /* Parse the stack */ long argc = (long)*stack;