Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp828873rba; Wed, 27 Mar 2024 13:05:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFcl/NA/mS9eoWFoqSAj2aNnu/8fbUyFPBvVcCm3wrWw0M0ZGJU2RVvLkj9YDWnx2lLR5iIpwG+hZ/jf3XnZQ/LiYnp/3/tPq+0U/myw== X-Google-Smtp-Source: AGHT+IGZxoYIbd7OmDqnfIbigYd/7cLjStv5UMK5eCPKYkdlYjNjYLoKt+if7TBn/BnohuL9XJ/d X-Received: by 2002:a05:6214:2ccb:b0:696:2b3e:7813 with SMTP id lf11-20020a0562142ccb00b006962b3e7813mr646576qvb.17.1711569906713; Wed, 27 Mar 2024 13:05:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711569906; cv=pass; d=google.com; s=arc-20160816; b=X6CHRbuxBDCxwcNR2wkPTG5hDjfNP72YNQD/xBO0pjwFPrRE+eMvl1u7yHyZWCKwMY 1pSGXLDuD7Ksy/rAUBJuzY40z8GTf63qlndHnK110zy7fQgOrO7IgQ4mKg0bNaPxHfNk F5JovRLXTQ9cA6XDjSUumSEf0SkGadQx7JBdPri86MmC3qBLYJhMK2gUfo9lJxjQcmp9 7RlU0AhsCJSRFRyHmN7Quj5mdb/p8VUfrBsCtuegU2/ss1ThM6L8g6cZ8MUJ7DIpTtQZ m0DX1YHbLopptExd9d+cozhgqL4Z+TkDpH+LAdFBqDo+3LC8p2w8XcIuSqhfp0mF+/KE a/mg== 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=1KPYCb9S3Soscoa7gVsLkBiv/vc0d18dY2Lykf0pkTk=; fh=bO5wkMWVyAmlcK/jrB+5GsJP0U535A85Nq3xBEBHFwY=; b=Ozib2cyG3tAJtIfW5Q7mIL6fg3MyT4Mni1WKEYY/m9rc37HuaQSN06H1xT1QE5q5bU gIcOJ1WzfL/AaicU5TcxMPd1GyKcl3sdyMBHP2O6+c/fwGXQqR7/y/+4r0bAUjFuEQXA xhtFeltRecm6jfu1mFrN8wu6P3neQkE/DeId1wj4iMLnqCsNqPxF0z7O5jDsewb/7G+f jS3tHo7jGFD1kieTNJfiKP51GX1uaj5lRSV0/CEy81oWB/gLpEXhM775qJ/DZc/fq5mj wNbjK4EDDhZWtNZqYiYT+mT10BfCOX38K3Tx0yH7LMiZkj4T+7YaMaLo54PeMzI6qpBt mtcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=noziLqwF; 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-121947-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121947-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gu15-20020a056214260f00b00692d62023bcsi12968110qvb.591.2024.03.27.13.05.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:05:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121947-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=@sifive.com header.s=google header.b=noziLqwF; 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-121947-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121947-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 495C71C3353F for ; Wed, 27 Mar 2024 20:05:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E20CF155305; Wed, 27 Mar 2024 20:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="noziLqwF" Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 65640154BF7 for ; Wed, 27 Mar 2024 20:02:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569740; cv=none; b=NJrxe6bIrDNtqnz3VRUXv6eiu0DPfCgATWF74hQ/T75MTlH/cP1GbCddsW7/7cW3yrl0x71CEUgOSlaE7u8fuZLGaI1ghY4hP1kuJGNKw5JIJXLYi1wFnli5KUB9zt9cmaG0lLwCePd5rVD+t94p0EslGdn60iPgUG88cJVSlh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569740; c=relaxed/simple; bh=E7MLSmCZtdYqT/97iSjjy5MvTX1XvFIxMI0c3iuGdCI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=krRGqBzx+j98DcNeT8oszmLyAvKl3sa4K+NOlX+OiD8B8+59v3JeSKD9utvivwZuvgU1mKlN2F+tj7LGtHNC7B/SgmKRELELFkgdYPUfiWUFWhMnCRueLiQ8hXxq4FzIsDPy2SOaD4hejc7alF9AmOqfaskzAlgddvlmBGAbWfk= 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=noziLqwF; arc=none smtp.client-ip=209.85.214.172 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-pl1-f172.google.com with SMTP id d9443c01a7336-1def59b537cso1592295ad.2 for ; Wed, 27 Mar 2024 13:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569738; x=1712174538; 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=1KPYCb9S3Soscoa7gVsLkBiv/vc0d18dY2Lykf0pkTk=; b=noziLqwFZQWZjHYxnaQ7Ba1PpL6FqL/WWlAx8A69tosxUn7uAeWY2fUa8cTYFNY6o5 E7ahw2Hh2itkW8PLwG53FIRFWIKFriGNHXis1RGuCH3o68E1DYnzq3XSUHs8PB0AJXx5 FmGeEc7wMrN5bhJSwoonwaFyVDQ+aGsIcT9AQ5fFolpPWUdk+4SYeYnl95dF86XOBJbK ZcKfoZpQzni84VSM08/4GJF86upNXlb1nSk+x/hSAtfrMvc6zPIaBLCpn+VuG1b6emkN MjZAUr4QOUTZIdE9a64iRpyoNyZLEZWTohxGSe4OE6ZwzYmZTqg4pn8TwxMBAZAPxbMz 88CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569738; x=1712174538; 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=1KPYCb9S3Soscoa7gVsLkBiv/vc0d18dY2Lykf0pkTk=; b=pvPC+hwsceGt13SrKR2fxwmZ2M4IcHBITpL/jUA/XXbq8pOEo/+Xdhf7K3/gsUJPEA I/5WVFBbmWErrPDOv/q7nIaiI/UHBUIGCgpm1fctEOb484BGjcNd6BrmBzquazeBKyVK PnBueCLvt5MziL21LgLt1FtCIoS9WC1i0c1dmRyIdMJVQHRdVq/kTMqaLdeFstmdzLos mHkCYRM0o1r5B7SyvRXFwGNTvn1DF3l/glZpF23QND9xVpAbhfXAykH/YCXW7uICQPjZ 505y1tNpXyJLFDbJLA3dFr1MzcTH+2Iki9iHMRyZPIngoqHaepqGw2DHhNvxfkshA9ui KF3g== X-Gm-Message-State: AOJu0Ywclzsc0PRp+iTtxvFa41cinWpZiMXnOKNMUH2mt3dUG0vfCZED H5UCprjmBFewLh6xGoto/J3W+ipFHu52b7z0NCQBgKGpuGXYfAqS8NShKbkDvvJ/o7V1myHoOKh 5 X-Received: by 2002:a17:902:ec8b:b0:1e0:1f1d:bd38 with SMTP id x11-20020a170902ec8b00b001e01f1dbd38mr622795plg.7.1711569737898; Wed, 27 Mar 2024 13:02:17 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id u4-20020a170902e5c400b001dd0d0d26a4sm9446459plf.147.2024.03.27.13.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:17 -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 v3 14/14] selftests/fpu: Allow building on other architectures Date: Wed, 27 Mar 2024 13:00:45 -0700 Message-ID: <20240327200157.1097089-15-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240327200157.1097089-1-samuel.holland@sifive.com> References: <20240327200157.1097089-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.43.1