From patchwork Fri Dec 8 05:54:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484866 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3EDA2C4167B for ; Fri, 8 Dec 2023 05:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XVqZgcVoIjtSt5VYtBMX5R0lKM244qLhhXXAGOvuj9E=; b=LxGn0bEdr29Qm0 5UXPX/Hq2r4TRz/hJ/irXOkQOzjy09R1NKuIguMd7INa9UgRcpuW6qRjgEXMLEnX1x11tycicwRpL ym75cYELmC5K+ca7NdDLzALOHta4krVYuWWpu9ogMiq3uhtH0bDVvrl+F76MzLoci197VEK21WbUb 6DKCljw4gLwIuXxzordOwLQCsrImZHM2jv2WGJgutWxuqujGC7aAXKUc8bhbGtt58HAKUZunGy0J6 f89HJA095xNPBA+FtSKSlNeExh2Sead9fb4wxA4LNRZ7yAWc0qXaca/J7mjv/Ef30GevPQdQ1unDl NypX3ew9hn2xfq7PgTYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTqC-00EoJc-0h; Fri, 08 Dec 2023 05:56:00 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpl-00Ensl-2I for linux-arm-kernel@bombadil.infradead.org; Fri, 08 Dec 2023 05:55:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=pcpcBg9iqyFf2P75H/RgUfyoTRLcpINzc/uQQUbU4hE=; b=Mo5M77j28u/tg+qyQPuS2awBmN RBIe31XCZh8GRKrtRCMoZzAjB4Fq2Im6II8aDJTwZOQLyS50Lu+mGBc4epCtAGe7POhMuZOSLpLZA BqAj/SBmJFTscAsFPLSQjI1QwS0cAJ02RdNWYIqVT5GptutoiBG08IqTZCWS3qVqYg7VYSTdqAdRx H7MGh9WzKILoIez08JXgM+dtYRInSUdh5JLwKpzYFHhR4qtGbG+yDu8Nh6c3Ks6Xpb0jAZ1IlanUc e28mCTENzWijspXuRhd6/ayiqwCctTOfUPj31MB5m8IpLo6D4KHzJI8xEotJAT14PLNo2gKwqwX4C GoQGTJhg==; Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpb-006Uop-2g for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:29 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d2e6e14865so6660305ad.0 for ; Thu, 07 Dec 2023 21:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014918; x=1702619718; darn=lists.infradead.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=pcpcBg9iqyFf2P75H/RgUfyoTRLcpINzc/uQQUbU4hE=; b=SK3T8DFUqCKOqGSVqysl24NZjs8TlPymXuKb2JwaQ1MLXPM8MmvLpvQpEEjqUzekaW Wfq/G4VJS+DRRRwXWBHqP/sbz5G9RGghpIgX98KLIp8bP0B16twqbWOfQ73p5xqW4iIU seulVQAFuAw83SUBfQjmmu80A+gJJndC1WqMv656TheKG+l8dIPheEY8ptJg5jRePtI1 /HloT7V4RIdMuK9HVJM4I0tEgAgM3N5p1ULuatnkddY41mzmbfqzOD0+as/b/r7/9jaQ NQkczsFXVoNMRvSmFQaohBK0OCHB14pHNyLn2M9OwcucB3NhUsQJvtzrV/RwD5QBWPDJ Tlyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014918; x=1702619718; 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=pcpcBg9iqyFf2P75H/RgUfyoTRLcpINzc/uQQUbU4hE=; b=pS5gklnZ6BerJY3TtGTJXOPyB0AEMv2IKCpSM0qS1iqRs+KETJL1CuF3CzFyoPX5Gu IhaBUgD0709yN18yh9RmX1gDCNmLMuDlJMnhoYgS8Kf53h6OoxxgaJfbvTO19vg44gJa ZyP5oL0hQNLFcA5XLURrx1fpMK+pHx8oxSVSh9Uen7RSwFDuQ3WxTxCD+Ez31nm/JtnR lGWG/zooSxJOi9yUOrlmCaUUCSG5X+BBP3cy8wsh6cA3AtBC8X1nQIDwCio8lX5Eh83Y 5z3LGawotcKqgSkbYQcT3sLuqA5rFT+AQBfpHOw0fKtjHwCVDG6uUvbpai8/Dr2CMlia oxRw== X-Gm-Message-State: AOJu0Yy8JN/5WMYKPg3vf0bDiWdVqyKtgwUb75QcFa1HFUaH4hWZbOTX NbNl43i2hP47Cmi8OBB8D9f1YMA0Jka4h6bYcTRda45n3eT38vNbP7fQvsWwmZFFw2FQALBia0B WGDZxXJ3GbZAGkWioh+cXszcakDtTK6WEuDsDRKCS8YsRl3XlA1Rsjs2O5MEB4cpJy9C3WL0r+h m98a+OL6KGh/zRXT9C3LDh8egLWg== X-Google-Smtp-Source: AGHT+IEd1Q8NqQMc7dge0J/g+8VD/1S9VTAlw4GMwW5YWZLRIvv4qPwcnwD5N+VJxlW0x3wmr8JadA== X-Received: by 2002:a17:902:ab0f:b0:1d2:eee7:2a7e with SMTP id ik15-20020a170902ab0f00b001d2eee72a7emr114365plb.61.1702014917640; Thu, 07 Dec 2023 21:55:17 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id s22-20020a170902989600b001ce5b859a59sm786250plp.305.2023.12.07.21.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:17 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [RFC PATCH 12/12] selftests/fpu: Allow building on other architectures Date: Thu, 7 Dec 2023 21:54:42 -0800 Message-ID: <20231208055501.2916202-13-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231208055501.2916202-1-samuel.holland@sifive.com> References: <20231208055501.2916202-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231208_055524_368903_D5C66D72 X-CRM114-Status: GOOD ( 17.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- 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 cc7d53d9dc01..bbab0b054e09 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2933,7 +2933,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 e7cbd54944a2..b9f28558c9bd 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -109,31 +109,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) obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/ diff --git a/lib/test_fpu_glue.c b/lib/test_fpu_glue.c index 2761b51117b0..2e0b4027a5e3 100644 --- a/lib/test_fpu_glue.c +++ b/lib/test_fpu_glue.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include int test_fpu(void); @@ -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;