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: 175598 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5263471vqy; Thu, 7 Dec 2023 21:56:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvS95SmjqLn+Q2oC+0avySw1gC25A770zVjSLTyumXiSGqtoQhP97SBdFve7LpyzxAx/w5 X-Received: by 2002:a05:6a20:8e16:b0:190:2746:8bd2 with SMTP id y22-20020a056a208e1600b0019027468bd2mr1037640pzj.20.1702015006818; Thu, 07 Dec 2023 21:56:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702015006; cv=none; d=google.com; s=arc-20160816; b=dJuE+oC4xD9E2dAetZYBO3xGX3uadt899CIK3JiFK9akvM+ph046O7ebHj/fCMbXeF HluiaJeeheZnlUc2y/ybt6ykJOnWTU0WfHSIrZAwOTWM5J64Bwidma3JI42IIXvJK6wZ g8DViqQA4leMuKZRTcB92zeL36q7WO4GkER2VMqbLSBwZ0vDrE6mqsyhGo4VPyE0LFnb Z0sxQ+NoSYIJ/5Xt9Kv597/OrpiDVKHMdZV3Z9WIBqANgtN8qDZcHHSBt1bP90i7dmXU yhdwa7IVIjEbH+gXR//zLqw6qGJYa15s0hPX66SWYnifUTO3nXN4BwS3IGAkBidIa0/U 3KFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pcpcBg9iqyFf2P75H/RgUfyoTRLcpINzc/uQQUbU4hE=; fh=GWiN7/yH5ZaeB7dNf34H6takS9oI70VVB29etA3Fg9Y=; b=o0Rr64h5walU5OwfQamfDRjh/zWSYWgDkUtv2VZZDCJ5bYWCSKVPzHaASgaupbgva2 U7FhOhUwBU/fRmx+ytAMZmSzd4IHuIN8BLE9+uach6N6XJcikL95ij99FZLgizp5hWA2 UBDiffcjF3tVcPv6plIYt1CQms8L6IY43KMy2kwDsrD4ShJvc5a/+6bOJ5Z14P1rCup3 FoVNYfmI96rELY5D5XB04xKr8WuTm0zELDjHS/r0+IQB7ClfzvoJVCnUFWCziNAaFEug rxfpK5DLKAVrhwLmg2KM7fyPprhg3aK/1LcstA22j6QvyyqOeMM1oNpze5jCmfuGd7Ue shSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=lZnJZmFp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id y3-20020a17090a1f4300b00286f3b1d40csi1092907pjy.132.2023.12.07.21.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:56:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=lZnJZmFp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 088C88292A50; Thu, 7 Dec 2023 21:56:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573261AbjLHFzz (ORCPT + 99 others); Fri, 8 Dec 2023 00:55:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235659AbjLHFz2 (ORCPT ); Fri, 8 Dec 2023 00:55:28 -0500 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C87E172D for ; Thu, 7 Dec 2023 21:55:18 -0800 (PST) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d2eb06ab11so3725275ad.1 for ; Thu, 07 Dec 2023 21:55:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014917; x=1702619717; 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=pcpcBg9iqyFf2P75H/RgUfyoTRLcpINzc/uQQUbU4hE=; b=lZnJZmFpO73Gds/A3Nw/akhAFVxsBby192xlde+DD9+nmu1fLqTHMSDc97iflP25Ov 297O84DoCDaYJKNSAc/TMg52Mr9m3RpMVru3dW0mLnJFc/H7z1EKiwuAF6q7yVr9uwwO wrj40NjPuPQ2TlUIDm74y1AfBfGx7fHLcfGUJsscuYWeRrHfop9u2Y55/Pja5n9P9siR CBzNrAG0Rnwrw5y9wcoTlvEX0Il7K+OzPRrYs1m6p5ThGmcgA3coZilHeExs5emP9SZq E6QUvT6ieOhhwTHTwyWeeeh/dWlliDHZvrn0uDTUxC0gvX+Ct5cYaS5jJCfkMlfKH2UC Sekw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014917; x=1702619717; 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=qH4ZYKeui2/DVskfXqviJBV2g484nyoz34S2yR3cXz0PMzpeOBAW6QYUy/NzVXDLjN oSNM6OXM8NKHlRLp0g9EGMEPLIyiOKnArdQqrduj0HwKapQjczoPXRMQf2tJSZS+J9yw bTnxcXRCwo2Hvn5m0RuZPVSm9VxPKJs3HvqBpPYGYdZFCd23ZFSha5UgHO3FjlzCvpIM N8XUTtJfg0Uxp6Q8+irQgpmumyFaiYrsXdL7NGlfHWVmEWtXH/4s8XgBgJd5zFNAL0/5 +yz/Vyc+WbQBBvbM3RkKcNzYZ7mNbx4Ovtv8/JfA58Sr5WZtU85/Y/dlDjbfmJpg7cmZ C8pA== X-Gm-Message-State: AOJu0YzyDW4aV6lMXVrd2FnxaD1mUoJkuwGPVBEZAp2ZtNL7EgctYODG 7j43ybT5HNOm4MR0gFfiuKhovw== 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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 07 Dec 2023 21:56:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784692088221745457 X-GMAIL-MSGID: 1784692088221745457 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;