Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp73041lqc; Thu, 7 Mar 2024 10:37:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV8AuC6kQrXk6m2xOLjCU+JpOUutSIDhrv8SuR+Ol9ZCK9h2rS/3vMpK/loZ7XIGZaeQA8ntQf9vBkVUstqK0HTC+6JfVkmX0fNP/4qOA== X-Google-Smtp-Source: AGHT+IE1anb2bAMfw8CoFPjAA10dfzcowvVr0/T2tLYg1V1GrNcxayd05uol9VnPBJp816R7vqZP X-Received: by 2002:a05:6214:5489:b0:690:affb:1de with SMTP id lg9-20020a056214548900b00690affb01demr684962qvb.11.1709836642677; Thu, 07 Mar 2024 10:37:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709836642; cv=pass; d=google.com; s=arc-20160816; b=xv2WGAz0FPBjb/5p/BrXRKZ4+/sgS9xvGQKAegTYmmGK/ez2mYBFPmSTdk2jfHZoou I1c774D6wLIXExhmCDPn3z0zuY/07qBywmzmdzTnv7J8WyANTqPHhUIcnPWitzwgWjh3 ViL4b8/x1BqBJ5teX5ZhXeMOOK+ZczFLhczaIa3RwQI9YMIGkNTCz8KA9ZXzR2IMkMh6 QiJ1dRkzyCan/hBpNgZHVUFwk0eK2t8sVi4bTCHDsTTlImF7O9McWp7ZBcRzOHskOBlM jIPLbGxRbUqQBYLMLNDsI0r3UG/a+gMX27GCBV9eWIEj56FIGBQwQGdARSkhkmqVzpLR uYOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=TVDYM9MswaRghuvAAZCE3UcWi04FpzGgvyiuf5axS2I=; fh=RsWG4aeTMF/Wrd9bGtpxnJlKOqIYbYrE6E1UyIKZUQs=; b=rAWhUowN1pk9gNGU0/iFDjq32usMK7DdeXbn604LkADrVMYdpTaJsgCfGRAp8877n3 kP8BqTX6AT46eye35kGezWrC9RlYPvv+riEmTlcLgbJ9CqvsvPC+GlI6SZh5LO7qyxc+ OnG7TTvqGjmw6BaWzFJMOBre7siuwU142KxCHz3KBIpeL2tcLv8d3ZEI2w25bCmVgqm8 GrxiBVt2EN6VhGqdkZffxwpt1oDhFmAIXsesX4x7XLS1HziShm9IiAwgWddRhsbDdW+q U1VNTToFQhajQdPLAspmZCDW57H0A8lwyW2NjolIBJnnFLa8kekG4Np78BK32h9uMSWI aHPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=hR3WT9rn; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-96022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96022-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 jz6-20020a0562140e6600b00690aff4db04si344240qvb.138.2024.03.07.10.37.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 10:37:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96022-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=hR3WT9rn; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-96022-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96022-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 64EF11C212B7 for ; Thu, 7 Mar 2024 18:37:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9005D13341A; Thu, 7 Mar 2024 18:37:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="hR3WT9rn" 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 1E66512F5A5; Thu, 7 Mar 2024 18:37:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709836636; cv=none; b=lZcNGYKAPMApZX4b8yDp7f10FuRwcQirydIQ9ommbKTanPvWoke+EJRONeasoBueQBQkvjKCdXz+eMEVpUzBzWM6IJDMycZ9KUxgkYZDbic45ZxnpwVIopBNYyTQhrrCqcBEKoZHMfv3GHW5rvcgDztEAPl0fayjTzlQSamPCk4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709836636; c=relaxed/simple; bh=0hw/BO/EMvzsmF1IVaaww3RoUUfz1Eu0MajBXr+3PIk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=saCFzeCohehiMZJtNoBsPNUFvMUdodlkZE0SjkGEmOBJuEgRWJVGqS1Z1SZb+OpDGen5Kz/HrDcLWN27TJcx2wCeLHrqT25oiL1esABkFZPCX2IsF/pjS1mdSziB3R2dPY8qLjKsT/S/OpyVuFLSPofG/gcfyw+HOwN/uq9IPdA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=hR3WT9rn; arc=none smtp.client-ip=46.235.227.194 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=1709836633; bh=0hw/BO/EMvzsmF1IVaaww3RoUUfz1Eu0MajBXr+3PIk=; h=From:To:Cc:Subject:Date:From; b=hR3WT9rnguVUkb7FRTJqU5F8NmFxtRh/IDEWIN2BTOzaxtZeniDYVumU9o0X93+IF OsNZge3SRSkxrPYGVRkOqp47nlseWYYrlHOVy0igcpftzmtQUPRKDPEqW3PVwPwxrf VGEIm7qmlL8dGgu+GYq3qGJvTeQds7UsTlVmzYrIltNmfWjNeSMSYhT6el3mTkcIaH 0ai14W/ZSazloDh5owQ5QS7VS+nTyyfyBrxttai3La0h9Y9BAn+kqcmhhouwpVFKt2 ayHgqVh3nJETl+j3s4vTKspYaTQ9MBh3R2D1I0hF9ycbnvENnLfXrdcdC3RzHanyge RjVjPayqzBv6Q== Received: from localhost.localdomain (broslavsky.collaboradmins.com [68.183.210.73]) (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) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id BDB8A378134F; Thu, 7 Mar 2024 18:37:09 +0000 (UTC) From: Muhammad Usama Anjum To: Shuah Khan , Muhammad Usama Anjum , "Chang S. Bae" , Dave Hansen , "Kirill A. Shutemov" , "Peter Zijlstra (Intel)" , Weihong Zhang , Binbin Wu , angquan yu Cc: kernel@collabora.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests: x86: skip the tests if prerequisites aren't fulfilled Date: Thu, 7 Mar 2024 23:37:22 +0500 Message-Id: <20240307183730.2858264-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Skip instead of failing when prerequisite conditions aren't fulfilled, such as invalid xstate values etc. This patch would make the tests show as skip when run by: make -C tools/testing/selftest/ TARGETS=x86 run_tests ... # timeout set to 45 # selftests: x86: amx_64 # # xstate cpuid: invalid tile data size/offset: 0/0 ok 42 selftests: x86: amx_64 # SKIP # timeout set to 45 # selftests: x86: lam_64 # # Unsupported LAM feature! ok 43 selftests: x86: lam_64 # SKIP ... Signed-off-by: Muhammad Usama Anjum --- I'm not sure if xstate values should be correct on all the x86 processors. If the xstate is invalid on a CPU, the test should be skipped instead of failing. --- tools/testing/selftests/x86/amx.c | 33 ++++++++++++++++++++----------- tools/testing/selftests/x86/lam.c | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/x86/amx.c b/tools/testing/selftests/x86/amx.c index d884fd69dd510..5d1ca0bbaaae7 100644 --- a/tools/testing/selftests/x86/amx.c +++ b/tools/testing/selftests/x86/amx.c @@ -103,9 +103,10 @@ static void clearhandler(int sig) #define CPUID_LEAF1_ECX_XSAVE_MASK (1 << 26) #define CPUID_LEAF1_ECX_OSXSAVE_MASK (1 << 27) -static inline void check_cpuid_xsave(void) +static inline int check_cpuid_xsave(void) { uint32_t eax, ebx, ecx, edx; + int ret = 0; /* * CPUID.1:ECX.XSAVE[bit 26] enumerates general @@ -113,10 +114,16 @@ static inline void check_cpuid_xsave(void) * XGETBV. */ __cpuid_count(1, 0, eax, ebx, ecx, edx); - if (!(ecx & CPUID_LEAF1_ECX_XSAVE_MASK)) - fatal_error("cpuid: no CPU xsave support"); - if (!(ecx & CPUID_LEAF1_ECX_OSXSAVE_MASK)) - fatal_error("cpuid: no OS xsave support"); + if (!(ecx & CPUID_LEAF1_ECX_XSAVE_MASK)) { + ksft_print_msg("cpuid: no CPU xsave support\n"); + ret = -1; + } + if (!(ecx & CPUID_LEAF1_ECX_OSXSAVE_MASK)) { + ksft_print_msg("cpuid: no OS xsave support\n"); + ret = -1; + } + + return ret; } static uint32_t xbuf_size; @@ -131,7 +138,7 @@ static struct { #define TILE_CPUID 0x1d #define TILE_PALETTE_ID 0x1 -static void check_cpuid_xtiledata(void) +static int check_cpuid_xtiledata(void) { uint32_t eax, ebx, ecx, edx; @@ -153,12 +160,16 @@ static void check_cpuid_xtiledata(void) * eax: XTILEDATA state component size * ebx: XTILEDATA state component offset in user buffer */ - if (!eax || !ebx) - fatal_error("xstate cpuid: invalid tile data size/offset: %d/%d", - eax, ebx); + if (!eax || !ebx) { + ksft_print_msg("xstate cpuid: invalid tile data size/offset: %d/%d\n", + eax, ebx); + return -1; + } xtiledata.size = eax; xtiledata.xbuf_offset = ebx; + + return 0; } /* The helpers for managing XSAVE buffer and tile states: */ @@ -929,8 +940,8 @@ static void test_ptrace(void) int main(void) { /* Check hardware availability at first */ - check_cpuid_xsave(); - check_cpuid_xtiledata(); + if (check_cpuid_xsave() || check_cpuid_xtiledata()) + return KSFT_SKIP; init_stashed_xsave(); sethandler(SIGILL, handle_noperm, 0); diff --git a/tools/testing/selftests/x86/lam.c b/tools/testing/selftests/x86/lam.c index 215b8150b7cca..c0f016f45ee17 100644 --- a/tools/testing/selftests/x86/lam.c +++ b/tools/testing/selftests/x86/lam.c @@ -1183,7 +1183,7 @@ int main(int argc, char **argv) if (!cpu_has_lam()) { ksft_print_msg("Unsupported LAM feature!\n"); - return -1; + return KSFT_SKIP; } while ((c = getopt(argc, argv, "ht:")) != -1) { -- 2.39.2