Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp915377lqh; Fri, 29 Mar 2024 00:28:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWofJwMug9jC6M/LBGgqIPhjewfkHQUeVbmlngUKZopOm3W1DZPGFy0jsSaMOQbVn3/Jd4VE+BQF8Js9/gjtF/79Ga5JhKucmp/rO6mqw== X-Google-Smtp-Source: AGHT+IFBaSHSRdPGjAl/3ntxApyS8t5DTyWSpuVPBbPLlNlj1MH9h3F5CXx/qvw9L5yekkFgR2TD X-Received: by 2002:a05:6a21:151a:b0:1a5:6acb:399e with SMTP id nq26-20020a056a21151a00b001a56acb399emr6665404pzb.12.1711697295699; Fri, 29 Mar 2024 00:28:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711697295; cv=pass; d=google.com; s=arc-20160816; b=O2Yn+0+AV0l6Ygw4iMLLTL39sGu0de7xxsue7GEnu+tx6hazBsxuddYoMjsBBdFjyJ lSG6BpGW6tL8Jqi7iPp4Yrb/h+FJkqmi5ZA306E7x85gowZj7CymdTbu0HxQpb3YOXWf WsvtIFSCSXKgl+4wVOfrOM7ClDVS4VQAyUIgLtf1EWUvgVtBMP4LpzfNyNasZyz/6fgb ymzBcDIBRM7FM2+ruhFltqjAz6ie0O6ZyWMbrrup8M8VdWTr4ePy4NnwLGfGL9TmyE6V hWTR0x/iEw1shPsb+/fkIfpWvccmLPOYfpwUfxlF7lSYk8njM+RIyatt2e0caqGcZWam HoXw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wd7UwvCa9oMHOiIEhQpk6/wRs60SiO2oLPgpnvXy/o4=; fh=bO5wkMWVyAmlcK/jrB+5GsJP0U535A85Nq3xBEBHFwY=; b=E+88I44A6eKCkLQ8gahN7k7+9Et3receK9blKKWZs0RHDQRei6LVf7l4ADg6CsXYUP 0vwPF/4qGdyZglq3gkEoXk6iz4nzmS7YL8F3bjlivOwsj//gVffJPJ8oNKDrI34MX+QP TcFwPW0wbcuAxvL5H0urFb1Gwqb0uFs7CJVG8mNlJW83BxA4LObQayL6mnESpNUY3wxL 505ih6KbKxYpkFNhOGRzDROndNc+1GY0+qwcPT8Xt83eFRO6OUkZ7avrQhMCe9tyxVNA a/68eA306I0v/1p+FnFPhEMEgFIuAyKQ+OtN0lyVngiJQuVbPCRvicHp1lVbELilQQ3E wgxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Cu5VI3LT; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-124242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q33-20020a635c21000000b005cdf9923679si3070000pgb.727.2024.03.29.00.28.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:28:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=Cu5VI3LT; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-124242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 516622865EA for ; Fri, 29 Mar 2024 07:28:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B221869DEA; Fri, 29 Mar 2024 07:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="Cu5VI3LT" Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D0A669D2F for ; Fri, 29 Mar 2024 07:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711697109; cv=none; b=kNcr8yvADCWVoulIcErPsSDoEuoTvF20TOECzVFqGYUNURjx165fMnRFB8sN6DHp0lX1MmZKM5haqg/yM3cFk4/XIkWcm0stkgmUVmy0TL2PzObvk3W09nlUgvJesY28LFqRoHWbADQD8R7nmL7siO/AanMPrHBawkpHHZ6rG3M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711697109; c=relaxed/simple; bh=/RMV6EvjfbMDeh8AAAKCcDfR7SkW64DSoezNtrIFGmg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hHoxuzBmNr0LYW3OqKvFLz9quR1Jd8hYWxIRBim7RkzzPgNfJOx2mohDA5GTvavWjG4i4/do9iGDXwb7cUgAwTdpd+hdAT0AslJI4mNiXtSaLAPHd4fbGbRiX0xP7Hu15+llldHwx3hMXUwZW7/UAD0Z3/nHiL8Lnla6e7dXWF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=Cu5VI3LT; arc=none smtp.client-ip=209.85.216.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-29dee60302fso2013248a91.1 for ; Fri, 29 Mar 2024 00:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697108; x=1712301908; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wd7UwvCa9oMHOiIEhQpk6/wRs60SiO2oLPgpnvXy/o4=; b=Cu5VI3LTXLsWnzJZr16aULBeoGYvllWpLE7OISDoerEZotowO2K8zzVzVCSz1X4Wpq T+F8nl3Xjy93hK4yLiFZUXiozBkIWuQpaT/DebCnc9lXB32QgB6kyeO2+3vV6rt0oFu1 qnHmz/Nc/8rzkkzZSwW1UXWFSUFZ5Jpmd9LmuB0i4iFi6ZJ5vZy54dvqHC9NyASHetnH bu6aZ+RPcR8o6xao06C6eBqnDUJKC3apQBeKP/stGLhAnUUG97Jo7V9wME194m2HUlP/ iSSByguZa8P5D1EhFqxPTY6oeEqtiEXZzcsAqYbopcto3ow3olxr33hkDznm/8ratXFp KHTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697108; x=1712301908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wd7UwvCa9oMHOiIEhQpk6/wRs60SiO2oLPgpnvXy/o4=; b=JiMLgbylCBEfn3eA3JLema15k5s/ceq63ETIXLrIk3AkAk51uJMCrzP7Sl4wEVk5Wk CB+EOW2ra5zvGAJ/TAWxMCWiy5ljAi/FBrD478Gp5LbOOOphGQ57W7LSqwePvkPp8Siz eRFFHs1Bb4OAYsoQWayk9mk/ndleOx+y260+zcF9VT1VH7pMp8Xtod3A9gyh2Hus6OWd CDwWCuIsQ5ytJVvAeUHWFWsBnn5xaszD4aDiFbhBCrH02BmH7/HlA+QTTEQvx3USFC1y KD36V3/PVvcLaa7b1P63kyRoU0BvCK6KigkiavLuOEjqTvyY1xTPaojksgW7C6GAYZOZ BAAQ== X-Gm-Message-State: AOJu0Yz286quTL+ezqAz+myQDDwec9gp9nsVtCNef3Nze3GFx+yk0TZ9 HMjPHDyWNuFAClcoP8WWgUTIAl3bg8wO/85Rr6LEv3a5xYA28QCcdp1MrusDgsw= X-Received: by 2002:a17:90b:1c06:b0:29d:f52c:5d40 with SMTP id oc6-20020a17090b1c0600b0029df52c5d40mr2496570pjb.15.1711697107768; Fri, 29 Mar 2024 00:25:07 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25:07 -0700 (PDT) From: Samuel Holland To: Andrew Morton , linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Christoph Hellwig , loongarch@lists.linux.dev, amd-gfx@lists.freedesktop.org, Samuel Holland Subject: [PATCH v4 15/15] selftests/fpu: Allow building on other architectures Date: Fri, 29 Mar 2024 00:18:30 -0700 Message-ID: <20240329072441.591471-16-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now that ARCH_HAS_KERNEL_FPU_SUPPORT provides a common way to compile and run floating-point code, this test is no longer x86-specific. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v1) lib/Kconfig.debug | 2 +- lib/Makefile | 25 ++----------------------- lib/test_fpu_glue.c | 5 ++++- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index c63a5fbf1f1c..f93e778e0405 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2890,7 +2890,7 @@ config TEST_FREE_PAGES config TEST_FPU tristate "Test floating point operations in kernel space" - depends on X86 && !KCOV_INSTRUMENT_ALL + depends on ARCH_HAS_KERNEL_FPU_SUPPORT && !KCOV_INSTRUMENT_ALL help Enable this option to add /sys/kernel/debug/selftest_helpers/test_fpu which will trigger a sequence of floating point operations. This is used diff --git a/lib/Makefile b/lib/Makefile index fcb35bf50979..e44ad11f77b5 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -110,31 +110,10 @@ CFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE) obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o obj-$(CONFIG_TEST_OBJPOOL) += test_objpool.o -# -# CFLAGS for compiling floating point code inside the kernel. x86/Makefile turns -# off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS -# get appended last to CFLAGS and thus override those previous compiler options. -# -FPU_CFLAGS := -msse -msse2 -ifdef CONFIG_CC_IS_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 -# (8B stack alignment). -# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 -# -# The "-msse" in the first argument is there so that the -# -mpreferred-stack-boundary=3 build error: -# -# -mpreferred-stack-boundary=3 is not between 4 and 12 -# -# can be triggered. Otherwise gcc doesn't complain. -FPU_CFLAGS += -mhard-float -FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4) -endif - obj-$(CONFIG_TEST_FPU) += test_fpu.o test_fpu-y := test_fpu_glue.o test_fpu_impl.o -CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS) +CFLAGS_test_fpu_impl.o += $(CC_FLAGS_FPU) +CFLAGS_REMOVE_test_fpu_impl.o += $(CC_FLAGS_NO_FPU) # Some KUnit files (hooks.o) need to be built-in even when KUnit is a module, # so we can't just use obj-$(CONFIG_KUNIT). diff --git a/lib/test_fpu_glue.c b/lib/test_fpu_glue.c index 85963d7be826..eef282a2715f 100644 --- a/lib/test_fpu_glue.c +++ b/lib/test_fpu_glue.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include "test_fpu.h" @@ -38,6 +38,9 @@ static struct dentry *selftest_dir; static int __init test_fpu_init(void) { + if (!kernel_fpu_available()) + return -EINVAL; + selftest_dir = debugfs_create_dir("selftest_helpers", NULL); if (!selftest_dir) return -ENOMEM; -- 2.44.0