From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) (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 107335D8FD for ; Fri, 29 Mar 2024 07:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711697108; cv=none; b=epi1PdHL5mby+NATWRSyui1s15EVQubRIKijB7i99tWkFIOaJPQwvh7lv8icptm8NVfOQ3xMROsYNwjGPk67RjFQDETMOFZPDd1oIVGZpE8cxbzlKEnf1SqymPGR27KQ294EaRAz31DHF+04U+pt+1hv3ZY1Fn7imjHohJPwI+s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711697108; c=relaxed/simple; bh=sDSM8SzyTSBzvwgCVM/QtpZk9UVDm9MyzCcLceVlwvo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WBUpYlvYEuJ/r0zNXdOu2elQghAyqw2Juno+I2XpvDs7VPJoeJa7QQdxX4jojS3P8oluOqEWbw+hZX8hZfzo4N+USs85iiTGVIj84hRl1myuT3W+wLNDKpFlTpzCkSO7Ge2YiDB+YdOczdkYO4oIUyVIbdJIFAtiKzOJtPuwWA4= 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=UWIwmaot; arc=none smtp.client-ip=209.85.216.46 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="UWIwmaot" Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-29fb12a22afso1334851a91.3 for ; Fri, 29 Mar 2024 00:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697106; x=1712301906; 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=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=UWIwmaot0nXODV6lmi/3x88Uajdml4SyA9rrPah4N4ilELSLttuLO7mbY4ueV2UfOM 2LlJrMCAtRE/ZDCH7Ae58GYDpez9Z2ZcuOHtupvDIUKJwvy/HNFiDI4HV3Lq39Adw4fK H+FkMOdVAnuctEgzQ8mTvAIrkyzVFAnZ9nX+e6pHswOK1DGS41B/7zYEgiucoXafsWsV EgA00nVMlqROx1eWCPQidkeGqlxbwB0u0iOjeMuJpYoVXm0bUIGOGvNcWUaIXEs3yaOn pwcmUC6Nkt5CsgVf+We/CMYTAb4UjNdITvnpLnYMPFFZ5mexQPiJsSIUPP8gYzILvfkR Z8pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697106; x=1712301906; 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=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=Xh29XcVpHiTe0iqNLh4I6PGcMj1QVsqyL8VNlOcO4HA5NPxu19CGvntInD5sl6sTH/ XiYdyEgh8Dle1vm/8boIAMYQfp/ZSGx7u1bc0wqwLkBdCu0HqdlGM8rMGGsX1kGmxtPM THuPbTbw5pc67etnOfC6V0CrFhgsYkYQHQ6yTlmexHr+CvsBmAUovqDJHJjxXjT0CYv5 yC6lDNNESNszjKT6D2mY36YHIBGjrYOq6fW4KDw3IbxP2wyijBLIaNA2e2FCDU4RZTqL j1JSMZln+GNbusTCGqLqbsg2kwpYM43sSw+W/d9wm2/Qpv4wccdoO+/A8e/XtU0tFnF4 SadQ== X-Gm-Message-State: AOJu0YzySe5M6+qYOcNpdLkfwyAjKCUi0sF1GjH0iAvECaRRSget/JJg Bxew7wwJq4SalalLw+QM9eWg5nx5Xpi1UTqFRNeQgTR0gi0/9Xmh+KGWjeeP2Qw= X-Google-Smtp-Source: AGHT+IEgFbP2oHNJWaGrzpoC9/WKXB2wk7z5kOFJSRoINaDHcY2EGHO1B7+JnkXlN7mfRYkSUpJEAg== X-Received: by 2002:a17:90a:3ee6:b0:2a0:3a16:7489 with SMTP id k93-20020a17090a3ee600b002a03a167489mr1460482pjc.44.1711697106489; Fri, 29 Mar 2024 00:25:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25:06 -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 14/15] selftests/fpu: Move FP code to a separate translation unit Date: Fri, 29 Mar 2024 00:18:29 -0700 Message-ID: <20240329072441.591471-15-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 This ensures no compiler-generated floating-point code can appear outside kernel_fpu_{begin,end}() sections, and some architectures enforce this separation. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Declare test_fpu() in a header lib/Makefile | 3 ++- lib/test_fpu.h | 8 +++++++ lib/{test_fpu.c => test_fpu_glue.c} | 32 +------------------------ lib/test_fpu_impl.c | 37 +++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 lib/test_fpu.h rename lib/{test_fpu.c => test_fpu_glue.c} (71%) create mode 100644 lib/test_fpu_impl.c diff --git a/lib/Makefile b/lib/Makefile index ffc6b2341b45..fcb35bf50979 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -133,7 +133,8 @@ FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-st endif obj-$(CONFIG_TEST_FPU) += test_fpu.o -CFLAGS_test_fpu.o += $(FPU_CFLAGS) +test_fpu-y := test_fpu_glue.o test_fpu_impl.o +CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS) # 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.h b/lib/test_fpu.h new file mode 100644 index 000000000000..4459807084bc --- /dev/null +++ b/lib/test_fpu.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _LIB_TEST_FPU_H +#define _LIB_TEST_FPU_H + +int test_fpu(void); + +#endif diff --git a/lib/test_fpu.c b/lib/test_fpu_glue.c similarity index 71% rename from lib/test_fpu.c rename to lib/test_fpu_glue.c index e82db19fed84..85963d7be826 100644 --- a/lib/test_fpu.c +++ b/lib/test_fpu_glue.c @@ -19,37 +19,7 @@ #include #include -static int test_fpu(void) -{ - /* - * This sequence of operations tests that rounding mode is - * to nearest and that denormal numbers are supported. - * Volatile variables are used to avoid compiler optimizing - * the calculations away. - */ - volatile double a, b, c, d, e, f, g; - - a = 4.0; - b = 1e-15; - c = 1e-310; - - /* Sets precision flag */ - d = a + b; - - /* Result depends on rounding mode */ - e = a + b / 2; - - /* Denormal and very large values */ - f = b / c; - - /* Depends on denormal support */ - g = a + c * f; - - if (d > a && e > a && g > a) - return 0; - else - return -EINVAL; -} +#include "test_fpu.h" static int test_fpu_get(void *data, u64 *val) { diff --git a/lib/test_fpu_impl.c b/lib/test_fpu_impl.c new file mode 100644 index 000000000000..777894dbbe86 --- /dev/null +++ b/lib/test_fpu_impl.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "test_fpu.h" + +int test_fpu(void) +{ + /* + * This sequence of operations tests that rounding mode is + * to nearest and that denormal numbers are supported. + * Volatile variables are used to avoid compiler optimizing + * the calculations away. + */ + volatile double a, b, c, d, e, f, g; + + a = 4.0; + b = 1e-15; + c = 1e-310; + + /* Sets precision flag */ + d = a + b; + + /* Result depends on rounding mode */ + e = a + b / 2; + + /* Denormal and very large values */ + f = b / c; + + /* Depends on denormal support */ + g = a + c * f; + + if (d > a && e > a && g > a) + return 0; + else + return -EINVAL; +} -- 2.44.0 From mboxrd@z Thu Jan 1 00:00:00 1970 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 92C71CD1288 for ; Fri, 29 Mar 2024 07:27:06 +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=lswGEibikxrNB3zxR4L//JxUhypvxzEUiyaF1doQjuA=; b=exHqf2jGQW0Awc TB00KQ4yN/mF4cMofx8fovDHC8AfAtTcHIYqCI+D3DDPIltalJ4BIcXY+JEt15caTGQMlDM7a+ZPs VV+eCjg0etoyB5/d1pcSnPJPrPZhyW61RWtg86j0WCOy1yDZvPr0WJ4LNTB+WEgDkH5r6vYJb2Esx h1m+z9NHh9jiA4r++mz+dhG38QPbpzsfE+zE0WW20Ixl7JOHpMmjFHmCTq+HAYshqc09V7CU7Pmtn YIkReVWkAgHEb6PduTRMxAdCqBvOSFGc+eV4dNlp7pfGx2+QW0D7hJCMj2TRD93+xC36AmbvfO8rs vMXW4YevkJYrcKUhhMNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6di-0000000HA1b-1nTJ; Fri, 29 Mar 2024 07:27:02 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bs-0000000H8kD-231g for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:25:10 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5d8b70b39efso1400274a12.0 for ; Fri, 29 Mar 2024 00:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697106; x=1712301906; 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=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=NVMQ6Sri7O55r+h4zmsIlvECjSh9BcLjrKKnd4MDecZZRZJ8i0Zl5SCVzQFlB61dld OpZDFyQ1wCocePmiPaibwG7WmPn1tmrDzTtRP63eeqkF8A+fytPWHYXDv2qH6i8rWTn0 F87KB2aOIDU4jKitqrhYnzeks7i2pY4vX+ZbI6wfeG30v0TDvsivLA9AbQ5dH5iB6mgK MgDI4N7gwWhZg1jvZ/t46PqPjijyEKTApe5PlFqJgsqh3GJ/J64k16sHdHE44eRtgqf4 K2ziwSCCOWx/E0b3FjgvBn7r/pu3RR87X2V+ijT7mZ6d8LGTQSVZQUpIm7VrXb9ksQm7 hmBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697106; x=1712301906; 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=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=TkAvAC8A2UPSJASbRe+bimhXWc489GDqMMjwUBusCjHpbQH1LelqWviGdYVzakO9Wo fdcNeORreiiA7zuI11ufa8fJ6W0K5ojxS4Y8vCZVmkqsXuD9U0ojGYTC8LjW0kbUBsoV BYOPRaR+W9S/5WlpOl+c3UroUsW1LidDaBFBKE1OoJqa6aKBjTQLPZwrmn0ETFw/49qf 7kfbl2YX2vVVJiocycxyuRlMZIP/Y0kpRHg97nbR046WN+HppthuDmtKLBlxzMinnJeF QLLBleFQiNFsrvieVwP00YENqjl0HQs1SdkBdQb5MMB1NZJ4vLtHxqgCxEgiYxD0vgei yViA== X-Forwarded-Encrypted: i=1; AJvYcCVEQLEhDBjmVrKjSms/q16ln+o6SDM+9BL1RrKOdndpILAenRs5cebLSkTTJK2/TF8ypQG1k5CGpnzW2hEC62bEFnkHgvzKbLv9WrXKnVlO X-Gm-Message-State: AOJu0YzKuO5zthTSJQ/ojigOi4fFC2k918afAUt1wPzz62QQ1rkpH2/4 sqdIsm+rqXdGJkY9LHtMawOcWEyRXGGHe0Okt/C5BqCF8OpIWRAkb538R39o1Do= X-Google-Smtp-Source: AGHT+IEgFbP2oHNJWaGrzpoC9/WKXB2wk7z5kOFJSRoINaDHcY2EGHO1B7+JnkXlN7mfRYkSUpJEAg== X-Received: by 2002:a17:90a:3ee6:b0:2a0:3a16:7489 with SMTP id k93-20020a17090a3ee600b002a03a167489mr1460482pjc.44.1711697106489; Fri, 29 Mar 2024 00:25:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25:06 -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 14/15] selftests/fpu: Move FP code to a separate translation unit Date: Fri, 29 Mar 2024 00:18:29 -0700 Message-ID: <20240329072441.591471-15-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002508_589725_27612BAF X-CRM114-Status: GOOD ( 18.97 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This ensures no compiler-generated floating-point code can appear outside kernel_fpu_{begin,end}() sections, and some architectures enforce this separation. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Declare test_fpu() in a header lib/Makefile | 3 ++- lib/test_fpu.h | 8 +++++++ lib/{test_fpu.c => test_fpu_glue.c} | 32 +------------------------ lib/test_fpu_impl.c | 37 +++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 lib/test_fpu.h rename lib/{test_fpu.c => test_fpu_glue.c} (71%) create mode 100644 lib/test_fpu_impl.c diff --git a/lib/Makefile b/lib/Makefile index ffc6b2341b45..fcb35bf50979 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -133,7 +133,8 @@ FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-st endif obj-$(CONFIG_TEST_FPU) += test_fpu.o -CFLAGS_test_fpu.o += $(FPU_CFLAGS) +test_fpu-y := test_fpu_glue.o test_fpu_impl.o +CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS) # 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.h b/lib/test_fpu.h new file mode 100644 index 000000000000..4459807084bc --- /dev/null +++ b/lib/test_fpu.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _LIB_TEST_FPU_H +#define _LIB_TEST_FPU_H + +int test_fpu(void); + +#endif diff --git a/lib/test_fpu.c b/lib/test_fpu_glue.c similarity index 71% rename from lib/test_fpu.c rename to lib/test_fpu_glue.c index e82db19fed84..85963d7be826 100644 --- a/lib/test_fpu.c +++ b/lib/test_fpu_glue.c @@ -19,37 +19,7 @@ #include #include -static int test_fpu(void) -{ - /* - * This sequence of operations tests that rounding mode is - * to nearest and that denormal numbers are supported. - * Volatile variables are used to avoid compiler optimizing - * the calculations away. - */ - volatile double a, b, c, d, e, f, g; - - a = 4.0; - b = 1e-15; - c = 1e-310; - - /* Sets precision flag */ - d = a + b; - - /* Result depends on rounding mode */ - e = a + b / 2; - - /* Denormal and very large values */ - f = b / c; - - /* Depends on denormal support */ - g = a + c * f; - - if (d > a && e > a && g > a) - return 0; - else - return -EINVAL; -} +#include "test_fpu.h" static int test_fpu_get(void *data, u64 *val) { diff --git a/lib/test_fpu_impl.c b/lib/test_fpu_impl.c new file mode 100644 index 000000000000..777894dbbe86 --- /dev/null +++ b/lib/test_fpu_impl.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "test_fpu.h" + +int test_fpu(void) +{ + /* + * This sequence of operations tests that rounding mode is + * to nearest and that denormal numbers are supported. + * Volatile variables are used to avoid compiler optimizing + * the calculations away. + */ + volatile double a, b, c, d, e, f, g; + + a = 4.0; + b = 1e-15; + c = 1e-310; + + /* Sets precision flag */ + d = a + b; + + /* Result depends on rounding mode */ + e = a + b / 2; + + /* Denormal and very large values */ + f = b / c; + + /* Depends on denormal support */ + g = a + c * f; + + if (d > a && e > a && g > a) + return 0; + else + return -EINVAL; +} -- 2.44.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 01F92CD1288 for ; Fri, 29 Mar 2024 07:35:31 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=HbCALm3Q; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4V5XJ24h6Vz3wG6 for ; Fri, 29 Mar 2024 18:35:30 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=HbCALm3Q; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sifive.com (client-ip=2607:f8b0:4864:20::1029; helo=mail-pj1-x1029.google.com; envelope-from=samuel.holland@sifive.com; receiver=lists.ozlabs.org) Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4V5X450CSKz3vd9 for ; Fri, 29 Mar 2024 18:25:08 +1100 (AEDT) Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-2a207208187so994657a91.2 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=1711697106; x=1712301906; darn=lists.ozlabs.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=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=HbCALm3QkbAgIp1qatacdn7aMmlsuJak7+jDpEmcnjkVpDHjRr5nGf7XbJNqwrGAQN FTfmxWk9Hz2zWSkmmZkGreeyVdaicmDpVoZiRzdO4Lmtiwqj+0aL0hVMrPbmmKdGG6xM xRtD6E08O7OjUjcBEV+G7xF9TN9Qv0X26CXHcZIbowb1imeG9FD5vME2piTqLxkMFxnS wHqcSy3/M37bo7ZT1u7MYHJilxlfPYEJMOEedmgd+2FGK1dfa+eaUclMgIuoyCTUiYhc qXUsfxveIk4phnaVIsuExnMpmJ6U6ZOMdk3BAqZPuXWTewOHQOuVcMS4YFb/vzt0hRLV v5uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697106; x=1712301906; 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=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=RqkL4obXArz8VuTCKu9QcpanuC/sES427hrzd2/xrsTTsMwYwkY64LmwBwp8M3avZw mUgDfJZsdfleQzfPOieIWn9oSohCYpRSEhDi77s/PRE39+lvUi1Ki9M9kSel4FuK5vrf MXRQgi8UBuGkyMVUM8eKR8nB05zC68RmXui6Y1uG+ETs+BrajgTdThEwBB4CR3rK7yeo /zKUwEWHpxchqDEL6Dj468wswx27Z7xuNdcLYKQBZBLrAMTLpFoQ1sPJ1zqkhnoCqqdz qDVPfC+xyS8jXaJIti5ma1Z+jbai5CHCmpxf44WZthvkNm3AQ5/EMhdkL4vJzK2Ppm0M Kb5g== X-Forwarded-Encrypted: i=1; AJvYcCUJ5Z/Wi4rviyxiHK/vT+K8TWx27u152va/Ld0xkdWKv73aVfzWXrAuhlNvPQwzVknmn4yquaAJVHGcRyw4K8pgl5iObFdnaAA7bi85zg== X-Gm-Message-State: AOJu0YwkYBJPuZy/tUfJMXvh9WeX9fj+zICgyuri91WInRMRonKUQqwc 8/Jp12dozxcqphbNQybewUH0a6V0v90KMkBQm9apFtRp62HPtIYq1YKF3YknVQM= X-Google-Smtp-Source: AGHT+IEgFbP2oHNJWaGrzpoC9/WKXB2wk7z5kOFJSRoINaDHcY2EGHO1B7+JnkXlN7mfRYkSUpJEAg== X-Received: by 2002:a17:90a:3ee6:b0:2a0:3a16:7489 with SMTP id k93-20020a17090a3ee600b002a03a167489mr1460482pjc.44.1711697106489; Fri, 29 Mar 2024 00:25:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25:06 -0700 (PDT) From: Samuel Holland To: Andrew Morton , linux-arm-kernel@lists.infradead.org, x86@kernel.org Subject: [PATCH v4 14/15] selftests/fpu: Move FP code to a separate translation unit Date: Fri, 29 Mar 2024 00:18:29 -0700 Message-ID: <20240329072441.591471-15-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> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Samuel Holland , loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Christoph Hellwig Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" This ensures no compiler-generated floating-point code can appear outside kernel_fpu_{begin,end}() sections, and some architectures enforce this separation. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Declare test_fpu() in a header lib/Makefile | 3 ++- lib/test_fpu.h | 8 +++++++ lib/{test_fpu.c => test_fpu_glue.c} | 32 +------------------------ lib/test_fpu_impl.c | 37 +++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 lib/test_fpu.h rename lib/{test_fpu.c => test_fpu_glue.c} (71%) create mode 100644 lib/test_fpu_impl.c diff --git a/lib/Makefile b/lib/Makefile index ffc6b2341b45..fcb35bf50979 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -133,7 +133,8 @@ FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-st endif obj-$(CONFIG_TEST_FPU) += test_fpu.o -CFLAGS_test_fpu.o += $(FPU_CFLAGS) +test_fpu-y := test_fpu_glue.o test_fpu_impl.o +CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS) # 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.h b/lib/test_fpu.h new file mode 100644 index 000000000000..4459807084bc --- /dev/null +++ b/lib/test_fpu.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _LIB_TEST_FPU_H +#define _LIB_TEST_FPU_H + +int test_fpu(void); + +#endif diff --git a/lib/test_fpu.c b/lib/test_fpu_glue.c similarity index 71% rename from lib/test_fpu.c rename to lib/test_fpu_glue.c index e82db19fed84..85963d7be826 100644 --- a/lib/test_fpu.c +++ b/lib/test_fpu_glue.c @@ -19,37 +19,7 @@ #include #include -static int test_fpu(void) -{ - /* - * This sequence of operations tests that rounding mode is - * to nearest and that denormal numbers are supported. - * Volatile variables are used to avoid compiler optimizing - * the calculations away. - */ - volatile double a, b, c, d, e, f, g; - - a = 4.0; - b = 1e-15; - c = 1e-310; - - /* Sets precision flag */ - d = a + b; - - /* Result depends on rounding mode */ - e = a + b / 2; - - /* Denormal and very large values */ - f = b / c; - - /* Depends on denormal support */ - g = a + c * f; - - if (d > a && e > a && g > a) - return 0; - else - return -EINVAL; -} +#include "test_fpu.h" static int test_fpu_get(void *data, u64 *val) { diff --git a/lib/test_fpu_impl.c b/lib/test_fpu_impl.c new file mode 100644 index 000000000000..777894dbbe86 --- /dev/null +++ b/lib/test_fpu_impl.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "test_fpu.h" + +int test_fpu(void) +{ + /* + * This sequence of operations tests that rounding mode is + * to nearest and that denormal numbers are supported. + * Volatile variables are used to avoid compiler optimizing + * the calculations away. + */ + volatile double a, b, c, d, e, f, g; + + a = 4.0; + b = 1e-15; + c = 1e-310; + + /* Sets precision flag */ + d = a + b; + + /* Result depends on rounding mode */ + e = a + b / 2; + + /* Denormal and very large values */ + f = b / c; + + /* Depends on denormal support */ + g = a + c * f; + + if (d > a && e > a && g > a) + return 0; + else + return -EINVAL; +} -- 2.44.0 From mboxrd@z Thu Jan 1 00:00:00 1970 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 9457ECD1288 for ; Fri, 29 Mar 2024 08:34:26 +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=pmixhhyoDCiuEPMEzlXvP4hKdfz9L3PyVg0h9QiWV0o=; b=f5x3YycTFp4HQk nQBO92GO5fOIKp7cwC9emvxxywRlbavUNRVFPn2fUduqlX8p6jaZYk1sjYv3DSSuofBH2sUxTO4s3 V3kAtHJIQhvPSwfaSdumGJgyNrTVtjHEWP7TQIv5nP2DwuTrsi3tor26jgqFaHNu67iUx2Qqtr95y LzmH/QrO2nQAuqdPCQhAxyximTog9wWY3lZUH3BvZkvzoqD27elv0aU82BPKPShwTt5vqWrn/T+bz ARfLeco4kvnNxB76Xf319hkL0ExICSuU4eH7VwD7DYo/otCtrDurhlRjMctHQMuglNHYo96o1jQm1 21P5HK2VbUhGFDHQK+vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gi-0000000HKew-3lWr; Fri, 29 Mar 2024 08:34:12 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6br-0000000H8kF-0BP9 for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:25:08 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5c6bd3100fcso1194154a12.3 for ; Fri, 29 Mar 2024 00:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697106; x=1712301906; 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=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=NVMQ6Sri7O55r+h4zmsIlvECjSh9BcLjrKKnd4MDecZZRZJ8i0Zl5SCVzQFlB61dld OpZDFyQ1wCocePmiPaibwG7WmPn1tmrDzTtRP63eeqkF8A+fytPWHYXDv2qH6i8rWTn0 F87KB2aOIDU4jKitqrhYnzeks7i2pY4vX+ZbI6wfeG30v0TDvsivLA9AbQ5dH5iB6mgK MgDI4N7gwWhZg1jvZ/t46PqPjijyEKTApe5PlFqJgsqh3GJ/J64k16sHdHE44eRtgqf4 K2ziwSCCOWx/E0b3FjgvBn7r/pu3RR87X2V+ijT7mZ6d8LGTQSVZQUpIm7VrXb9ksQm7 hmBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697106; x=1712301906; 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=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=NgkhIi/MEQm2RrSid4qzNtRo3k812q9LeeVWrGSu16XPQAU4+fpqQOvKQqjjB9aJrr Yg5nKPLt7x+9UJavmOLmGOd71ndE53SOZmsJnW6FZ28EiFVNCeQ3YoMyw8T72E9SL9zS 9IQzsnEqOqLRiowM3ySNWvhA4QKXhGcyd9kISEFYYpeNeAQj+pSV9moRNf9ZDZMIg2wc 7qgIt8reLYh4JFvQN+lknvlwfdzWmzXCh02qaqYrs9JvKG8tjotDVJ2AfoI8nnmal5eT aQWRNu5+Tvq7OTkkRX2NuJHRgeXX3jvj3pTOk554FgdYWX3Z+wcgB3C9UwYRD9NMU/N3 crVg== X-Forwarded-Encrypted: i=1; AJvYcCX4b5PgOSZQqXNiZyQ96K6dAEZ9oLeOuWPIZmfmmJn58cJU9MN1TAH1f9Ydlb+Ok6CinUbRxijMEchhGERpAizV71zm8Lv6OJRPFQ3e9R2x7jWsbjw= X-Gm-Message-State: AOJu0Yy8cj19OosshV9QRcGSaWaSl9F5gY+KQrWXboMT7PeT3Z6gpt4I ozQUgugrZ+48MGfDaMuDxW7jnNZ+Z/ay5pykLuOteKJqzv1m9LGfYy4XCP+hqyg= X-Google-Smtp-Source: AGHT+IEgFbP2oHNJWaGrzpoC9/WKXB2wk7z5kOFJSRoINaDHcY2EGHO1B7+JnkXlN7mfRYkSUpJEAg== X-Received: by 2002:a17:90a:3ee6:b0:2a0:3a16:7489 with SMTP id k93-20020a17090a3ee600b002a03a167489mr1460482pjc.44.1711697106489; Fri, 29 Mar 2024 00:25:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25:06 -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 14/15] selftests/fpu: Move FP code to a separate translation unit Date: Fri, 29 Mar 2024 00:18:29 -0700 Message-ID: <20240329072441.591471-15-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002507_222417_3494516E X-CRM114-Status: GOOD ( 20.37 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This ensures no compiler-generated floating-point code can appear outside kernel_fpu_{begin,end}() sections, and some architectures enforce this separation. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Declare test_fpu() in a header lib/Makefile | 3 ++- lib/test_fpu.h | 8 +++++++ lib/{test_fpu.c => test_fpu_glue.c} | 32 +------------------------ lib/test_fpu_impl.c | 37 +++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 lib/test_fpu.h rename lib/{test_fpu.c => test_fpu_glue.c} (71%) create mode 100644 lib/test_fpu_impl.c diff --git a/lib/Makefile b/lib/Makefile index ffc6b2341b45..fcb35bf50979 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -133,7 +133,8 @@ FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-st endif obj-$(CONFIG_TEST_FPU) += test_fpu.o -CFLAGS_test_fpu.o += $(FPU_CFLAGS) +test_fpu-y := test_fpu_glue.o test_fpu_impl.o +CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS) # 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.h b/lib/test_fpu.h new file mode 100644 index 000000000000..4459807084bc --- /dev/null +++ b/lib/test_fpu.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _LIB_TEST_FPU_H +#define _LIB_TEST_FPU_H + +int test_fpu(void); + +#endif diff --git a/lib/test_fpu.c b/lib/test_fpu_glue.c similarity index 71% rename from lib/test_fpu.c rename to lib/test_fpu_glue.c index e82db19fed84..85963d7be826 100644 --- a/lib/test_fpu.c +++ b/lib/test_fpu_glue.c @@ -19,37 +19,7 @@ #include #include -static int test_fpu(void) -{ - /* - * This sequence of operations tests that rounding mode is - * to nearest and that denormal numbers are supported. - * Volatile variables are used to avoid compiler optimizing - * the calculations away. - */ - volatile double a, b, c, d, e, f, g; - - a = 4.0; - b = 1e-15; - c = 1e-310; - - /* Sets precision flag */ - d = a + b; - - /* Result depends on rounding mode */ - e = a + b / 2; - - /* Denormal and very large values */ - f = b / c; - - /* Depends on denormal support */ - g = a + c * f; - - if (d > a && e > a && g > a) - return 0; - else - return -EINVAL; -} +#include "test_fpu.h" static int test_fpu_get(void *data, u64 *val) { diff --git a/lib/test_fpu_impl.c b/lib/test_fpu_impl.c new file mode 100644 index 000000000000..777894dbbe86 --- /dev/null +++ b/lib/test_fpu_impl.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "test_fpu.h" + +int test_fpu(void) +{ + /* + * This sequence of operations tests that rounding mode is + * to nearest and that denormal numbers are supported. + * Volatile variables are used to avoid compiler optimizing + * the calculations away. + */ + volatile double a, b, c, d, e, f, g; + + a = 4.0; + b = 1e-15; + c = 1e-310; + + /* Sets precision flag */ + d = a + b; + + /* Result depends on rounding mode */ + e = a + b / 2; + + /* Denormal and very large values */ + f = b / c; + + /* Depends on denormal support */ + g = a + c * f; + + if (d > a && e > a && g > a) + return 0; + else + return -EINVAL; +} -- 2.44.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel