From patchwork Wed Mar 27 20:00:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607388 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 D33A2C54E67 for ; Wed, 27 Mar 2024 20:04:36 +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=RNDwzdfOkzvQ6LoIGxv1sW+9xfnzlxEZGCsFecGhyxY=; b=14nYWxKeUhtV1V D5Keie7WOpDfcULWq+7zZqiJrMOTG6moxo6nu5UxzyaJ7qy/szVkPbJqxAUXnKtKEKeYZaIXyTb4E h7BIy7vEU9mSTIk9AIVqnte1x3Y0BIgW14W8ubRlaO5wvHjr+zxIQJ691FJe4wjhtSJTV8KaLEHWn mresB4F0CFEtXmK2z9CZPpNNW4P3SLNWkUZvzqe2p8lfy0E0AT/mgfPgp1bjGQm+walFqZtYbAgKF FXP1CKJ0vUyLFCzI1m5hsijYfEdgCE56jksANHSJ9kig24hveVXPs8lqHaS+UWPuoFq46edQ4brlB Ac4JKpJaMesKOiUhimDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZVW-0000000AvQk-2UXt; Wed, 27 Mar 2024 20:04:22 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTM-0000000Atxj-1zTr for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:12 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1df01161b39so1900045ad.3 for ; Wed, 27 Mar 2024 13:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569720; x=1712174520; 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=ypWDQztlaUl0OBgzt8wXnA3vBiMMRAqmq7IofZwnoZI=; b=Qaouox/YuyYg39S+hprBvQ6fAPW3kcbSXckHsNT/GFflqMtYAxLR029Fugn5XN9b0y x4F8Y7bjJLGmkouGfUO7Dc27hr1G62d4pdo4+bGGzGX38QV0HhlA63TinWJStuntwgUt Qey5iyZO6UcXICU6dMlt+NVbH2+Udt7/C7q1cy1hD3VrLSHLBEHh0qh7gPV/WWeBeIGx j2+X+YfdE1AVbWgO1YTqwTeOQs52NFADQ4fPlAPxYpfFf/3/m14I+9O07IJlW7U1KCEv MSnRYl/x3aHb8tU1Q9z6ZhTYDlh+a8wlux2px7hBX3wNPwQubbqAeRuJNfLwb8ZnJM+8 o5WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569720; x=1712174520; 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=ypWDQztlaUl0OBgzt8wXnA3vBiMMRAqmq7IofZwnoZI=; b=M6lq257DRc93/u5vqG0xA3pvPdIcIpufp81M+tR6w55eny1aSmlnEFRYiRbfsaFo2A 6LEbQ1qsxJ08pXQqqb6qmiklljNJznpnq0nfkkLmU4Oj7cE6ikAkjryHtCErY30r1y4e esIbCdITEp3athfcedBtOosNcMEUy4u3B/IIrcSmBoMJRn15GG9lA/HVyCyNDU0Kudsj PzadXmgW+MsNi6rGlay6EMnHipFTnCOwqU/8o0RcSlE9XNls47pekamPnl8ilJQw7w9R 06Lgh11z7xBuxC3ov4gXCyx0hgvZM9U4xreA2cvoRDRLl8DJpBbW5Vr8kp20mgfysxU5 wuVA== X-Forwarded-Encrypted: i=1; AJvYcCUdDbIrMqr6nCRhx4sd5GI5XPh8mg3tbjwACbJF437ACxsgd8pqB9zWrT7wfYW7iEECWncJd79ujFaEScA4airQSAQwwRyQgF40+b5rsLNelb8TwE0= X-Gm-Message-State: AOJu0YwwOFIt5UiU3SaVx+hZ5bcVdxlSnGouXaoBnPULJG2iit29S/ZI zQGyThZZILT5LuWsPAXOaFWzAPZ6QY4A6rvHUndwDMu59hRvPtQeBLxlCRflliwlWH8tJKCqV7b X X-Google-Smtp-Source: AGHT+IG/guZZUh1z8VBs2UBKbikNm/ct62HN1I/AjguyoIM/V4kgoDEmkJWsd5kFsvUg8c6UkAoepg== X-Received: by 2002:a17:903:1251:b0:1e0:f366:13e5 with SMTP id u17-20020a170903125100b001e0f36613e5mr876644plh.61.1711569720448; Wed, 27 Mar 2024 13:02:00 -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.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:00 -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 , Borislav Petkov , Catalin Marinas , Dave Hansen , Huacai Chen , Ingo Molnar , Jonathan Corbet , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Russell King , Thomas Gleixner , Will Deacon , linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [PATCH v3 01/14] arch: Add ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Mar 2024 13:00:32 -0700 Message-ID: <20240327200157.1097089-2-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_130208_707650_5D2BE6D1 X-CRM114-Status: GOOD ( 31.11 ) 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 Several architectures provide an API to enable the FPU and run floating-point SIMD code in kernel space. However, the function names, header locations, and semantics are inconsistent across architectures, and FPU support may be gated behind other Kconfig options. Provide a standard way for architectures to declare that kernel space FPU support is available. Architectures selecting this option must implement what is currently the most common API (kernel_fpu_begin() and kernel_fpu_end(), plus a new function kernel_fpu_available()) and provide the appropriate CFLAGS for compiling floating-point C code. Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Add documentation explaining the built-time and runtime APIs - Add a linux/fpu.h header for generic isolation enforcement Documentation/core-api/floating-point.rst | 78 +++++++++++++++++++++++ Documentation/core-api/index.rst | 1 + Makefile | 5 ++ arch/Kconfig | 6 ++ include/linux/fpu.h | 12 ++++ 5 files changed, 102 insertions(+) create mode 100644 Documentation/core-api/floating-point.rst create mode 100644 include/linux/fpu.h diff --git a/Documentation/core-api/floating-point.rst b/Documentation/core-api/floating-point.rst new file mode 100644 index 000000000000..a8d0d4b05052 --- /dev/null +++ b/Documentation/core-api/floating-point.rst @@ -0,0 +1,78 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Floating-point API +================== + +Kernel code is normally prohibited from using floating-point (FP) registers or +instructions, including the C float and double data types. This rule reduces +system call overhead, because the kernel does not need to save and restore the +userspace floating-point register state. + +However, occasionally drivers or library functions may need to include FP code. +This is supported by isolating the functions containing FP code to a separate +translation unit (a separate source file), and saving/restoring the FP register +state around calls to those functions. This creates "critical sections" of +floating-point usage. + +The reason for this isolation is to prevent the compiler from generating code +touching the FP registers outside these critical sections. Compilers sometimes +use FP registers to optimize inlined ``memcpy`` or variable assignment, as +floating-point registers may be wider than general-purpose registers. + +Usability of floating-point code within the kernel is architecture-specific. +Additionally, because a single kernel may be configured to support platforms +both with and without a floating-point unit, FPU availability must be checked +both at build time and at run time. + +Several architectures implement the generic kernel floating-point API from +``linux/fpu.h``, as described below. Some other architectures implement their +own unique APIs, which are documented separately. + +Build-time API +-------------- + +Floating-point code may be built if the option ``ARCH_HAS_KERNEL_FPU_SUPPORT`` +is enabled. For C code, such code must be placed in a separate file, and that +file must have its compilation flags adjusted using the following pattern:: + + CFLAGS_foo.o += $(CC_FLAGS_FPU) + CFLAGS_REMOVE_foo.o += $(CC_FLAGS_NO_FPU) + +Architectures are expected to define one or both of these variables in their +top-level Makefile as needed. For example:: + + CC_FLAGS_FPU := -mhard-float + +or:: + + CC_FLAGS_NO_FPU := -msoft-float + +Normal kernel code is assumed to use the equivalent of ``CC_FLAGS_NO_FPU``. + +Runtime API +----------- + +The runtime API is provided in ``linux/fpu.h``. This header cannot be included +from files implementing FP code (those with their compilation flags adjusted as +above). Instead, it must be included when defining the FP critical sections. + +.. c:function:: bool kernel_fpu_available( void ) + + This function reports if floating-point code can be used on this CPU or + platform. The value returned by this function is not expected to change + at runtime, so it only needs to be called once, not before every + critical section. + +.. c:function:: void kernel_fpu_begin( void ) + void kernel_fpu_end( void ) + + These functions create a floating-point critical section. It is only + valid to call ``kernel_fpu_begin()`` after a previous call to + ``kernel_fpu_available()`` returned ``true``. These functions are only + guaranteed to be callable from (preemptible or non-preemptible) process + context. + + Preemption may be disabled inside critical sections, so their size + should be minimized. They are *not* required to be reentrant. If the + caller expects to nest critical sections, it must implement its own + reference counting. diff --git a/Documentation/core-api/index.rst b/Documentation/core-api/index.rst index 7a3a08d81f11..974beccd671f 100644 --- a/Documentation/core-api/index.rst +++ b/Documentation/core-api/index.rst @@ -48,6 +48,7 @@ Library functionality that is used throughout the kernel. errseq wrappers/atomic_t wrappers/atomic_bitops + floating-point Low level entry and exit ======================== diff --git a/Makefile b/Makefile index 763b6792d3d5..710f65e4249d 100644 --- a/Makefile +++ b/Makefile @@ -964,6 +964,11 @@ KBUILD_CFLAGS += $(CC_FLAGS_CFI) export CC_FLAGS_CFI endif +# Architectures can define flags to add/remove for floating-point support +CC_FLAGS_FPU += -D_LINUX_FPU_COMPILATION_UNIT +export CC_FLAGS_FPU +export CC_FLAGS_NO_FPU + ifneq ($(CONFIG_FUNCTION_ALIGNMENT),0) # Set the minimal function alignment. Use the newer GCC option # -fmin-function-alignment if it is available, or fall back to -falign-funtions. diff --git a/arch/Kconfig b/arch/Kconfig index 9f066785bb71..8e34b3acf73d 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1569,6 +1569,12 @@ config ARCH_HAS_NONLEAF_PMD_YOUNG address translations. Page table walkers that clear the accessed bit may use this capability to reduce their search space. +config ARCH_HAS_KERNEL_FPU_SUPPORT + bool + help + Architectures that select this option can run floating-point code in + the kernel, as described in Documentation/core-api/floating-point.rst. + source "kernel/gcov/Kconfig" source "scripts/gcc-plugins/Kconfig" diff --git a/include/linux/fpu.h b/include/linux/fpu.h new file mode 100644 index 000000000000..2fb63e22913b --- /dev/null +++ b/include/linux/fpu.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_FPU_H +#define _LINUX_FPU_H + +#ifdef _LINUX_FPU_COMPILATION_UNIT +#error FP code must be compiled separately. See Documentation/core-api/floating-point.rst. +#endif + +#include + +#endif From patchwork Wed Mar 27 20:00:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607386 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 98AF6C54E67 for ; Wed, 27 Mar 2024 20:02:37 +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=WO9vTUKWIGBNkNq+kLM17rDJY9tFkk/QzGJMjBQFmMQ=; b=t7hJU8Q13tddAU D2mhh7nTmNOKfKNXXCHQ6vrcppTswxLQjkqedciTYS7BytJhDG4iqvATpJv/cDjiz4VWzW5tl2Vao Meu6gz4KX5C8KRa3Or400bZv/giA5dHhqd/6w/Cs4h4YJvWOKixQIWObExPc9MPIUf86TSNfQSPoO P/0txTWfnZOpub4z7hE7hWmNYCxcbT2ShaQJPwCO72C7Z452l8BndaVB1BeHwYg0rKv3cLzYzQepa WoCt52stz2Ok0nmWEGcXOjNnTVGIc9Cb/5gsqinXM5eKYTf4nVAxpUY+XZY+rQnTPctP0hgFMHngS Q0+E7JRvmCkPi0lG3QnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTd-0000000AuEA-0sQA; Wed, 27 Mar 2024 20:02:25 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTM-0000000Atxu-1xRm for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:10 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1e0000cdf99so2219885ad.0 for ; Wed, 27 Mar 2024 13:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569721; x=1712174521; 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=im7zmQeDt7pZodE0p+VySjAa7DBv0KaW+gKoLu+LS/g=; b=TRSVMQ36uWjZzRmAW0UAIect3xkTU1TU3MYTPXKyc0tfmv9HjmubR7jAKNxsde6hsv Gagf4cMKfDlryewUvk0g3044pXzbZevZqDbZztx1jDWmyPS80hL6ZoyiLjMobDB1bZDQ uJq4kQzC1Pvoo8IXwTGDe+S8klOKws7oTEZFcle+9gVtPEDW7SJ+DA5lc3YGuq88hRbJ vo6VBCEwdiYNU0EH731QyVDJf10UZRBsddzJyPysnFfEwef+hOmudL/cEJSHkbvqMUUI 9cHWQ3g9qnqx/KNZF3Sbb03GOu6aqUqTUsIBILBM/iq4P7kmupghU0CmhdKrpo+U9mRT pftA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569721; x=1712174521; 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=im7zmQeDt7pZodE0p+VySjAa7DBv0KaW+gKoLu+LS/g=; b=bUszS8oKMingWrG/UFDCQ7tagpeHxizeKNP4SnSwiVPcchF7tkMNu5dj9FXWgfqeY/ FdpYpAEpLRx3xtrYC6j/LG513l3s6mi8c79YMQbXzmw+GdUdozCwE995+/Drybqp7swF EFA0EZDbgAgRxVeQC4dctlCOGURqdRs9ljaW/bxL/mYTlv3Pk9zIFzVYF6Pu90uJNnqQ /OvGuC71fnTGiCqtNOoQ2mQPgu2KtAALEHvtBMwfO8bHfxcYSUveDCtefKe447jVl648 r7WW/I05yOQHSvjSw0BcBodjfG/AC/4PYhpTTwEOxG2i+gHsLYZY0BV8YIZScSu2g7Mo D0TQ== X-Forwarded-Encrypted: i=1; AJvYcCUZFPCxMLv5WH0PHd5RESFKu1SntjbBEAYCOsivlwlxSxQmZSc7xO32a9NW4BwYEzB1twj1b5Rx9XH6fSdfsltrjdn/p2WYWeOwmswnxp1swU5ASQM= X-Gm-Message-State: AOJu0Yw8sp9oBp9XghgDIvihWnvBWI6d8j5OX/xLikKWLvEpVQ7z4KWr JEtcFmNN/uRFbNR7G8NPs2WYN4V91lcM+dvI9Q1BncmbwObhieigIwEZSt7N1+A= X-Google-Smtp-Source: AGHT+IF+ykWlXq/2p9fLdxe5qiT+fQJVLXU8yD1cTqgZWIiJ9yzpflW/8jhLl1LVX7Yz7XdGYJsgng== X-Received: by 2002:a17:903:28e:b0:1e0:d6ce:7e16 with SMTP id j14-20020a170903028e00b001e0d6ce7e16mr805365plr.15.1711569721663; Wed, 27 Mar 2024 13:02:01 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:01 -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 , Russell King Subject: [PATCH v3 02/14] ARM: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Mar 2024 13:00:33 -0700 Message-ID: <20240327200157.1097089-3-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_130208_700573_1B74F9A5 X-CRM114-Status: GOOD ( 16.83 ) 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 ARM provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Remove file name from header comment arch/arm/Kconfig | 1 + arch/arm/Makefile | 7 +++++++ arch/arm/include/asm/fpu.h | 15 +++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 arch/arm/include/asm/fpu.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index b14aed3a17ab..b1751c2cab87 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -15,6 +15,7 @@ config ARM select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_KEEPINITRD select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PTE_SPECIAL if ARM_LPAE diff --git a/arch/arm/Makefile b/arch/arm/Makefile index d82908b1b1bb..71afdd98ddf2 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -130,6 +130,13 @@ endif # Accept old syntax despite ".syntax unified" AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W) +# The GCC option -ffreestanding is required in order to compile code containing +# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) +CC_FLAGS_FPU := -ffreestanding +# Enable +CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) +CC_FLAGS_FPU += -march=armv7-a -mfloat-abi=softfp -mfpu=neon + ifeq ($(CONFIG_THUMB2_KERNEL),y) CFLAGS_ISA :=-Wa,-mimplicit-it=always $(AFLAGS_NOWARN) AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb diff --git a/arch/arm/include/asm/fpu.h b/arch/arm/include/asm/fpu.h new file mode 100644 index 000000000000..2ae50bdce59b --- /dev/null +++ b/arch/arm/include/asm/fpu.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef __ASM_FPU_H +#define __ASM_FPU_H + +#include + +#define kernel_fpu_available() cpu_has_neon() +#define kernel_fpu_begin() kernel_neon_begin() +#define kernel_fpu_end() kernel_neon_end() + +#endif /* ! __ASM_FPU_H */ From patchwork Wed Mar 27 20:00:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607466 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 49C80C54E67 for ; Wed, 27 Mar 2024 21:18:40 +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=HgIjyVTs73OblPQxTbyPmxBu3yasi6i7FFdiX+Ij+PY=; b=Ah2o7CXAQzVLuy wbQxIjPx6J92GsDsELCIP3EfRQP7UmUMewujg+MEddE9qUTsfu76j/6ZA+zT+/6hgfH2vzZvGRguc nBs3DNAFUPVEoeSOTmEYzWJVofPPPMX08i0rpTdzVmeIpisPkLJWamZzAFVbMevhk/ns8nOwUmpim cjbehVSGGdtMH7rkFjBpLY0prWWfEstnP3ry6ZruVqW/rfYKBhGOVFBka0cXWMYaHlk7Wx0fUJ5t/ GbHc6WLDGg6ghitYM1J6Rc1wcMNEqsQ6tPUkVhCKvFQrODFgVlgOXyMLwlZ2frUnrKAtdmxb9y3NB 2Vh/PvaRc54TNZovTS6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafE-0000000BBDH-3TIZ; Wed, 27 Mar 2024 21:18:28 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTU-0000000Au71-1gMG for linux-arm-kernel@bombadil.infradead.org; Wed, 27 Mar 2024 20:02:16 +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=z3VQJildZHY1Bgj6r2iljFMqpw+vWq4Si7He8vtNBY4=; b=Ts36Ao9EROrrl6pPwKzSBul7lL uAbI+fnMajzfbFdmEiQEEZ6X7QEcC8a5n+rUUTLj6s6UWUOcft/uo8uytYqGlyMdQa7LM6EnfVa8C hKQXvb3bhaQYPLmuwM3j6N6QwKUfxZyG/6D+q+Jnew2eQtqiCUbDd1ZUuR23izRz235xsn3Rzh4v7 uXQVaRjZKCaEAooT9x5Fl0172FIChAaNWdqVQxxY/AG8Tik1BXZlyg/ofwpm4b86B5wmQ78RTUyDv x+NhDOfYkRHf9q8E1ShFs1CNmE7J952TEcMV5XLnMEC3ur8np56guRahjz8jHSOXQehe7qJFsHXOg 40V4T24w==; Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTK-00000000WpJ-3ETV for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:12 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e0bec01232so2082595ad.3 for ; Wed, 27 Mar 2024 13:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569723; x=1712174523; 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=z3VQJildZHY1Bgj6r2iljFMqpw+vWq4Si7He8vtNBY4=; b=WtqlXhY+aANfKdDFFyPAM2QEpD7XPx0u57Kn9T0frI9j5UM2Ym6VL1u1tH12r96ISj Hi4xyJRWvbCmd6A5McU9u6WILVzhPegh9m2J9MfAuLkuxguAn74U03VRor5P5bgbTOPX rZkAAQTWYB/bTedmPmmEmD+PoCvDSUX4ZFkvwampo0P+AQ0WzPHjzrRxTYvKBDs17aq5 doMFQs3M7IZivGxSIAITB8hQoPAt3hTAWqKT3u4OQZNKUNV4HSSnWxlowBjAL5mjww5m eBaSP22Qh9xryZ/e8Ex/HsXTlJa298aLS/4tBtXqZvVisuAL+8QNGJJajgb/8tSEhTKk NY0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569723; x=1712174523; 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=z3VQJildZHY1Bgj6r2iljFMqpw+vWq4Si7He8vtNBY4=; b=cTeRAq6Uo99BGPmP8wfXBEL9BhfMmzEwlIe2jWcS5X3I+sfqf9RIecEcUs8gfjTgHj Zkzp5oDfcr2OsURv0/B+btdgFUb53AGAcecu6G5wB6jhogKsXS13bgvEAaXpWGBjdPDO KAPYuWDIcUXx5K+xWCvHsTd0AHOgFI8hr1pdtoD/n//iqC94IqkS8n9d2w8VCJSFm5Eh uv5KFXzVZe+9PDFnCCdoPgZ3ua+ERA4yn1HvemCjZndMmYclSki8XNzJHYlzcCaQHTIx FfeOsBRdyg7lJ8+gJSyR9sU2s3QYKe221kGoLGfMreXRAu73iY2g53VK8kx1BbtZzL59 NKtA== X-Forwarded-Encrypted: i=1; AJvYcCU9MT+Q/btl3FFBtQKeldLXpbXWGto3yhbkpWZZpYwQfcNf2izp9oOA5SoBRKZxHIxBT2y1IwSOknimMP9COtpzfKBi+ja+hHE0QA750XHa/W0KZqI= X-Gm-Message-State: AOJu0Yzp8EP7c6Bh0Jx+d7eVvkJeC806l30ayDcqJ2M22LGlOfnMBERh VIjmpb9MJOSDp3QPFHDN2jxDxcULgIyR69k82cDz6QPKqHSLRZ/AuuiZTfj8Hys= X-Google-Smtp-Source: AGHT+IHYrCNFuZi7JM5PzLehk0tocOhYuLDObxCk9XIqMJvg9sySawc5MBuX1NvDT7qWP/3i+9Szlw== X-Received: by 2002:a17:902:cece:b0:1dd:c7ea:81f3 with SMTP id d14-20020a170902cece00b001ddc7ea81f3mr964085plg.1.1711569722972; Wed, 27 Mar 2024 13:02:02 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:02 -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 , Russell King Subject: [PATCH v3 03/14] ARM: crypto: Use CC_FLAGS_FPU for NEON CFLAGS Date: Wed, 27 Mar 2024 13:00:34 -0700 Message-ID: <20240327200157.1097089-4-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_200207_196180_5EF60A13 X-CRM114-Status: GOOD ( 12.58 ) 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 CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v1) arch/arm/lib/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 650404be6768..0ca5aae1bcc3 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -40,8 +40,7 @@ $(obj)/csumpartialcopy.o: $(obj)/csumpartialcopygeneric.S $(obj)/csumpartialcopyuser.o: $(obj)/csumpartialcopygeneric.S ifeq ($(CONFIG_KERNEL_MODE_NEON),y) - NEON_FLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon - CFLAGS_xor-neon.o += $(NEON_FLAGS) + CFLAGS_xor-neon.o += $(CC_FLAGS_FPU) obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o endif From patchwork Wed Mar 27 20:00:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607458 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 5F84AC54E67 for ; Wed, 27 Mar 2024 21:03:44 +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=HHXUPJH/M1W/NtSeiS+Rzb1CF43rIjnrdGgoPgJ46cM=; b=ZMBJ1zx5VmA4zi tjXY5XLjtOgiBhphTdN5Z20PmHLyf/oJMvTpGmVm+9Ae2O9GlYjnAFYVl9UhURLkCfwKI8R9PiQhr 1LrkXAhy2g8KDPWNZjIeDxkhDxWjEp9Jw77ej0ujIWDWS66yictpMEo28/v+8EIwmM2U6mMAkg250 OJeTrdkWAkL45GZpKanSSaq2L+NehvMyo1aqWa1m92/WJwk/eDdQD1OJ05uxVyx4Kw1dP7LH8+AtT eg4JojhHIFlMxyFEoicHY/ODbzNo4z4ACyZ2iQgQI4AVfWx+W5uUNGGrfwxXJIAXx1XD9/UuBjT2W atnhFQm5xdgddQ1S5M2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpaQm-0000000B8M9-3jRl; Wed, 27 Mar 2024 21:03:32 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTM-0000000Atyi-1xfe for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:10 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1e0d8403257so2161105ad.1 for ; Wed, 27 Mar 2024 13:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569724; x=1712174524; 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=7YKNt/WF/wnD0YRJEikw0HuScFyU0745kXYQrNfvXV8=; b=GprbohSabvgchMd+FOe/dvV7fBhjiH3ql7xUrPhXY4/anvLqNFu7UxJDxH3Ke8GkHs A54JkV8o1U4xNC3spw1nH+q5q0FHPfMqdZOW+Wi9qhoF+akcl/5LppD0oLvalB/lVhsZ FgABW5AraZcRH44dYc01JvydNLkSZX1+OkhTEoqoT+syL+jMVD8Elnn+OVpHJ4r6ib3C KeMTWU+ws0Q65jT5iIKivwQfq7gBA6cTBksa9Km+f9L7+rRMsqlB9Ohg06/POMJ8zzNd TqJp0B0vv0sE0SrobM9XwwQTNscOCxeH8oyyHmMQmDQcVkdGxYrwuvlrADQ5zuggcRDq YIHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569724; x=1712174524; 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=7YKNt/WF/wnD0YRJEikw0HuScFyU0745kXYQrNfvXV8=; b=qTj+CNPGXKv+8VwdG70cj5ewj+kzOrc+/skFyeBxt0LwOUIiV4XFCnLsEUb9cWjSfv qVHPFDjl5PpQUYR9+OmiWpH71M061qzRhTk2ZEmmZcEXWB1jt7ECICbXNXja30PExasu zfUFnoeXIJ2ouJuija3CRCVDesSzPrRaIRwIgpqDf3Lq2LL9kyZY83DeRwXssqwT/M7b L7k/2lFbFbh+v324bzQX5i0kwUzjQvvjFopoWJ0q/shjmQyXePrv/dk348JljLCn/INm SZeRzcQWNQO/Pzo98xbUzlvJm8fEerDAOQZtgdGC5WHpvCTmhE9BC+ljWDvO7kFq/G4G nQ/w== X-Forwarded-Encrypted: i=1; AJvYcCWErKwTytFIlnzxYkIm+Xfg1sMC1j+q640AmFSaeVuCEXq18V/+cr2cQjfjee/EVFaQI+FJHXp03tydhhxTSnUqHUim89UC09IyVJixMeSC60FhgX8= X-Gm-Message-State: AOJu0YxU29ZLLglckaItj8UDPNJIjZUFzjpb14vKI7ioxflQ5IPEHbve YHQnYHHeY/zL9d3m608BqalLZ5l1DVt8pSZalWYMVe8YPLYVTP5oJt8jRyV/aJE= X-Google-Smtp-Source: AGHT+IFfqF0zaQyhJG4fHFNgO9YCVd9dAMtKWVHSa8WQRo1J9B12INfMAAQOQNi7OQwx6x82eCY8tA== X-Received: by 2002:a17:903:8c3:b0:1e0:b874:1e5f with SMTP id lk3-20020a17090308c300b001e0b8741e5fmr850196plb.65.1711569724329; Wed, 27 Mar 2024 13:02:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:03 -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 , Catalin Marinas , Will Deacon Subject: [PATCH v3 04/14] arm64: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Mar 2024 13:00:35 -0700 Message-ID: <20240327200157.1097089-5-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_130208_700573_E67FFA77 X-CRM114-Status: GOOD ( 16.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 arm64 provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Remove file name from header comment arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 9 ++++++++- arch/arm64/include/asm/fpu.h | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/fpu.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7b11c98b3e84..67f0d3b5b7df 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -30,6 +30,7 @@ config ARM64 select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON select ARCH_HAS_KEEPINITRD select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 0e075d3c546b..3e863e5b0169 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -36,7 +36,14 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y) $(warning Detected assembler with broken .inst; disassembly will be unreliable) endif -KBUILD_CFLAGS += -mgeneral-regs-only \ +# The GCC option -ffreestanding is required in order to compile code containing +# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) +CC_FLAGS_FPU := -ffreestanding +# Enable +CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) +CC_FLAGS_NO_FPU := -mgeneral-regs-only + +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \ $(compat_vdso) $(cc_has_k_constraint) KBUILD_CFLAGS += $(call cc-disable-warning, psabi) KBUILD_AFLAGS += $(compat_vdso) diff --git a/arch/arm64/include/asm/fpu.h b/arch/arm64/include/asm/fpu.h new file mode 100644 index 000000000000..2ae50bdce59b --- /dev/null +++ b/arch/arm64/include/asm/fpu.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef __ASM_FPU_H +#define __ASM_FPU_H + +#include + +#define kernel_fpu_available() cpu_has_neon() +#define kernel_fpu_begin() kernel_neon_begin() +#define kernel_fpu_end() kernel_neon_end() + +#endif /* ! __ASM_FPU_H */ From patchwork Wed Mar 27 20:00:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607467 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 9F28CCD1287 for ; Wed, 27 Mar 2024 21:18:40 +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=Ldi8L8i9UovCU1OLLis0jcW77Hu6j0xAYwDk+au3g9I=; b=rllZQiLt4c5HAc 4x8d+d4mbTCRasPn7DA2BNO9ojAr0dtXtI2uRNMIaeQdyOeA4ji8+X+5oBnRBmo7YaQfnrP62sNnU T3Hqdu2U1zAyazyCp11/9/pVgkL5zCeK2mfiJdm7UYr/5u2rIPW1TOIMLGGsCsIcSCKrSsWRhAcU3 4NFkgbNqwmT21pFDdkgYjvcUXR4qcfz2HWnQiYEYYE6pttlhWHS0HpMGC0ZmopsdGh5xZM2PDcaru n5gLstx/vIOxRT1rFse5AoMQHBmlBcw5JK5oakhsNr0nH801EDk+pUAvrF3lYWnh9qsuVVDy75s6M 5rvZas9ZM8XVx34vHY1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafF-0000000BBDt-224U; Wed, 27 Mar 2024 21:18:29 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTV-0000000Au8B-3WAl for linux-arm-kernel@bombadil.infradead.org; Wed, 27 Mar 2024 20:02:17 +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=s9egB7QSoDAHRW6tgRYqVd+NUTiSQfL/JcKX7OjtD5w=; b=KnCIwVmJNh4MzLjXUKDjLgp/FV ixJQkTbUH386bYXx2n8j4UUkIA9krt3mpEo4/9iAJWtw250nlTco8DQBJ/RkG4vstknP4PlnYMEHO kRzFVsKBxL1BFLKypmrd0wT77K8oNfVwnvqAdBUXuoOe+/umL7i2/JhQGbJQ9jB+xIdhcd8mio88p CykhWwgaZr8F0FOhIfTQQ2SFzayJEYWKjGfbUkbSbtclaSERBrLk24eEOasPbuJJOBbCQ0MytxWxw sEuPxTzPGtl+O/V4yPErKAVrlW1h/1ujXG4Or6t8/2ZcBsZzpwJrjVSlfwn0auPBK4I6SNzLbJx2B dAIEGXhQ==; Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTL-00000000WpO-2wb9 for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:16 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1e00d1e13a2so1945735ad.0 for ; Wed, 27 Mar 2024 13:02:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569726; x=1712174526; 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=s9egB7QSoDAHRW6tgRYqVd+NUTiSQfL/JcKX7OjtD5w=; b=LfzU3ozRbFRP4ITlpFuPz2PDvUynGm+eXPd+Ue7DJiQGrLnyyR7i7Gyv1wrO37+/hI 3xyxbD88NNz+IJFeyrTtwyGXew+R9em3rvVM4TP7s+4c4yitns1P5VjPd1QmTNrPAC40 HjkYarEOnxh95qyjBQig7FdpIIgNKBg9C4q5xZ7pJ5inGNM+mUsu4Jx9EwttkEc+ekca VVySnIGYrKnyX969p3OfsKUE+hWo1CzMbaUElOMDKLyHEa1HVx+fXvVJSmygS7ErrfQS OaQKpsZH3GLzjz99HdQswXMTx2Pb0mEJ8+qFg0+0usebcF7B4uU/rzbA59mJzn16cyHX sk8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569726; x=1712174526; 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=s9egB7QSoDAHRW6tgRYqVd+NUTiSQfL/JcKX7OjtD5w=; b=MJoLvfF1saYyVkWyGklvRp0sdg/Ky4H+sIhnIHP+VsYSMpNgoz9NC2tJQp2eqEOPYP c1lysuOgO6G/xJuENH0kty1iXUU4ycYN5z+w9yRb+39R4bdZDiTrlbEcGcCGsNhdFZLw xH7DwP9cF7C39tVLpGgSD7KoKk7xQhZjg4ueqmHJCGGNBbJ2+xaTqS8wEtxkNt4F8sgv NKxCmLhRf2dff2uHwTAqIgqOQNvv9KUYXuzMDbSFDKMXmB+2kLa6SfBCiqr8zWNkU0Xa Wrdz9No0tTZu2f+Op9V3B4daT/0Fs5dI4RLN6FaTW1Yuy7Zkx9p8nRkNu1uM3kyRsiRH x5PQ== X-Forwarded-Encrypted: i=1; AJvYcCUitWRZJ3v9Adm259bf25lu40eostllGSxPCmdwp3O6gCyOrnRBTcIBBAG45uemKlHBjO66nt9JWvs8RUHAN/ZochyyqJM6usunvyYVeocbiHzECcI= X-Gm-Message-State: AOJu0YyIT0+f0ZbyEvlc/AZAlPS/Smd0/n2agae57TIFhc2ujHwTaMB1 8S4qOX7sSajTZ3WSYWvku9OhzfFNwMu/A4vlak2S/MC/TPMEAyoT0aJ4acxGNYY= X-Google-Smtp-Source: AGHT+IFGHdi74bAZSMUCS5nBpcP7LI5Cfqz6VZFaIDx36rlYRojmLVaB4TIyZga5IdN5tuwaxR1nKA== X-Received: by 2002:a17:903:2b05:b0:1dc:a605:5435 with SMTP id mc5-20020a1709032b0500b001dca6055435mr854470plb.31.1711569725718; Wed, 27 Mar 2024 13:02:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:05 -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 , Catalin Marinas , Will Deacon Subject: [PATCH v3 05/14] arm64: crypto: Use CC_FLAGS_FPU for NEON CFLAGS Date: Wed, 27 Mar 2024 13:00:36 -0700 Message-ID: <20240327200157.1097089-6-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_200207_950508_6BC8DDA7 X-CRM114-Status: GOOD ( 12.00 ) 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 CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - New patch for v2 arch/arm64/lib/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/arm64/lib/Makefile b/arch/arm64/lib/Makefile index 29490be2546b..13e6a2829116 100644 --- a/arch/arm64/lib/Makefile +++ b/arch/arm64/lib/Makefile @@ -7,10 +7,8 @@ lib-y := clear_user.o delay.o copy_from_user.o \ ifeq ($(CONFIG_KERNEL_MODE_NEON), y) obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o -CFLAGS_REMOVE_xor-neon.o += -mgeneral-regs-only -CFLAGS_xor-neon.o += -ffreestanding -# Enable -CFLAGS_xor-neon.o += -isystem $(shell $(CC) -print-file-name=include) +CFLAGS_xor-neon.o += $(CC_FLAGS_FPU) +CFLAGS_REMOVE_xor-neon.o += $(CC_FLAGS_NO_FPU) endif lib-$(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) += uaccess_flushcache.o From patchwork Wed Mar 27 20:00:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607389 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 4A7E0C47DD9 for ; Wed, 27 Mar 2024 20:04:56 +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=a+r52+9K+XzPXcfdscV+5EEU7WLu9Q0fuoJLgUCMkJc=; b=JLEVWzgDU1Fxva tRvBBAqmGVBIZcLQWohwKGDeUsy0m/VsANcl7p+kKWYftS5dzmjf3h1g/VMv4qpDG5pYv6tvPdM6z DuKbBA+A9CqY4mZd7PdFsN3vddV93mCJhCOI0985uGRKdl7Lqd2fgwlxswunJVWR7zccAzm1Lf+yE MJqFy6VhT73jiiua4+oFqUChDOWNZIJQrPRmWixJ9MKyzZtCyXMsfi0NzxX3lSCKgZHqRpF1M1ycF iJ2aesrsECw3olkOWVCt1SsWE3aIOMdDquO6JVDsyuLL+17cT6xF69m0b9cgmPg0XwgS3MsAtpe+6 XIDbW3/Izlmglw34Fn6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZVq-0000000Avd5-2RQV; Wed, 27 Mar 2024 20:04:43 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTV-0000000Au87-3HeD for linux-arm-kernel@bombadil.infradead.org; Wed, 27 Mar 2024 20:02:17 +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=JhRrF1Pu1wTofDEF5NDtSjXNjQrJmyXSgj6gSsLdD3o=; b=kTtCt0c1Sw9hp6hziuZQniN2wa uGTurNDruvXDZAt3WrfVIUUcCCoIAyUKHcyUbxzk+8z/462EFBi5GMmE5Wmeg65/d1yDSThUgE12O flK0mQBazd44Bo1pzRURZbufROIVmlSCmJBx9e6qh47AK5zcGyb9TRRLY1j+cOeeJhOfIV7MlxgqK /Dtwey9B8Skw93CLtJ6gBRDMq3CW8DKdTw63Sw/kSUD4XDocNMAmBHjyR0sTeHIR6em4+C3p5Ok84 0Jpu8ms4Ybm3D1IgY6/1QamsYv+UIPqDi2bfiLoBnxKvk38GDu5jerLvv4jjkANLa7xW++B+4hUOo sxvYatJg==; Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTM-00000000Wpy-3vGW for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:16 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e0f2798cd8so2273125ad.3 for ; Wed, 27 Mar 2024 13:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569727; x=1712174527; 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=JhRrF1Pu1wTofDEF5NDtSjXNjQrJmyXSgj6gSsLdD3o=; b=bvBmJfk8irpuOzlh5TmE+RsuKxPdKZ8qdVCQi+68AcdyjzUrQygVrCaGM87IXV28NI 40fqYhowDQ/zkrGuqyVbFryg2h8EaDknwDNIyAP5y8CsMJqZA06IqfwxqtB/Gml0UUrd QDDLH+9ix2udXOmUhWXTsOd1fvtjPaC1sjirDOpm4JKGVM4FxkpEQy16TAC8osDfNvOZ MACaUdIOlqPN1/J6e/62iyTX1cuuPQJPf8cltLGeSE7hMxEx/1XtW5qp7z0XdgcOWhxG 1i97zGCsPIsdvKatOP3Zq5hyHMUXVyRpRTrhhD1snTSjG9RglFKkwwnqdnizw+werVBu gQuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569727; x=1712174527; 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=JhRrF1Pu1wTofDEF5NDtSjXNjQrJmyXSgj6gSsLdD3o=; b=o2zyxKAk7LF8xi5r0w/oZTJIoxuJ+wp8bYVIBtUUrN1ccNf3j0EHKjh28diDlS3eDc 9BQk/2C8VTtQkzd23hSCMlUfD+LX608GiWBGkxJeYx+M7xQ0mKQtxbc88liUEqa3Lzf8 u6m4cvVkz1zLXd4W+c25p1MfvDZVOB3Twjk9sK53mB2xQCqs5Uncd81Awv63kZVgWKwK CBCIpjLfissO8o32VuOdiHkttv/j1YI584chVgbKbt3JZ7HiB0jo24TbnYtJy5qdabKl dcox8uM7i5L8YY1VxQoLTso4vzql3kxY2R25/mU50CrrJRhg00jlnIRoWMi/Sfu+Qn6s 9Mcg== X-Forwarded-Encrypted: i=1; AJvYcCWGN2VSCYUADuPZpwU9JSWLwIfX94ORB5tRGiC25y8X3wAKaVW9OsbHDPKzl7iVYhhoUaqw0DMzhAdFh13ewmHOsgZXHINTXnceAx8ug2C39NoXhog= X-Gm-Message-State: AOJu0YzlN+0dLmY0eSo5vC4sN+Q2IwrqaKFP3/C/7rc1Qo5LqrgOFURl xZrVlLeaOB15gs0pmDthVKdIJOgVJGbW+RdR9vKlkJ8o5VRZeP61IP6rGCIv2fY= X-Google-Smtp-Source: AGHT+IFTdj+7xjr/hkuUZrog62OKlzxWVPjf6p/E+DdPaik3Rv7nG00gWJ8Kh9j7qP1eqTQJrGE0sw== X-Received: by 2002:a17:902:650e:b0:1de:eca6:483d with SMTP id b14-20020a170902650e00b001deeca6483dmr724908plk.27.1711569726983; Wed, 27 Mar 2024 13:02:06 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02: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 , Catalin Marinas , Russell King , Will Deacon Subject: [PATCH v3 06/14] lib/raid6: Use CC_FLAGS_FPU for NEON CFLAGS Date: Wed, 27 Mar 2024 13:00:37 -0700 Message-ID: <20240327200157.1097089-7-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_200210_557240_7720B6B6 X-CRM114-Status: GOOD ( 11.80 ) 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 CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v1) lib/raid6/Makefile | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile index 385a94aa0b99..c71984e04c4d 100644 --- a/lib/raid6/Makefile +++ b/lib/raid6/Makefile @@ -33,25 +33,6 @@ CFLAGS_REMOVE_vpermxor8.o += -msoft-float endif endif -# The GCC option -ffreestanding is required in order to compile code containing -# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) -ifeq ($(CONFIG_KERNEL_MODE_NEON),y) -NEON_FLAGS := -ffreestanding -# Enable -NEON_FLAGS += -isystem $(shell $(CC) -print-file-name=include) -ifeq ($(ARCH),arm) -NEON_FLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=neon -endif -CFLAGS_recov_neon_inner.o += $(NEON_FLAGS) -ifeq ($(ARCH),arm64) -CFLAGS_REMOVE_recov_neon_inner.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon1.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon2.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon4.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon8.o += -mgeneral-regs-only -endif -endif - quiet_cmd_unroll = UNROLL $@ cmd_unroll = $(AWK) -v N=$* -f $(srctree)/$(src)/unroll.awk < $< > $@ @@ -75,10 +56,14 @@ targets += vpermxor1.c vpermxor2.c vpermxor4.c vpermxor8.c $(obj)/vpermxor%.c: $(src)/vpermxor.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -CFLAGS_neon1.o += $(NEON_FLAGS) -CFLAGS_neon2.o += $(NEON_FLAGS) -CFLAGS_neon4.o += $(NEON_FLAGS) -CFLAGS_neon8.o += $(NEON_FLAGS) +CFLAGS_neon1.o += $(CC_FLAGS_FPU) +CFLAGS_neon2.o += $(CC_FLAGS_FPU) +CFLAGS_neon4.o += $(CC_FLAGS_FPU) +CFLAGS_neon8.o += $(CC_FLAGS_FPU) +CFLAGS_REMOVE_neon1.o += $(CC_FLAGS_NO_FPU) +CFLAGS_REMOVE_neon2.o += $(CC_FLAGS_NO_FPU) +CFLAGS_REMOVE_neon4.o += $(CC_FLAGS_NO_FPU) +CFLAGS_REMOVE_neon8.o += $(CC_FLAGS_NO_FPU) targets += neon1.c neon2.c neon4.c neon8.c $(obj)/neon%.c: $(src)/neon.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) From patchwork Wed Mar 27 20:00:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607387 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 128CCC54E67 for ; Wed, 27 Mar 2024 20:03: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=EfKkIPOYyWRhVgXvovof5WrIVmB/RVnppKXxu5Yoniw=; b=v1tmcLq+9NcOwX lVUCRpTPefQLUSeSdbOid0DneQ9L5xIcRCravLnZm742WCgH2m68oG2i3b7XOwWju7nXydXcSWTsM ynsrzGXG+bALlftLAxW+XamM0701slLWidpybbPQb6XeaFjmJgvYKNXCY8NtURdaWhfbNNwzdyCqV o4Ecz+crIWFS10PzXkQOPwyR2UDYSg9V1sWEY6aYYfen/MuHcs+rkjd8RPCDQ5bGj8EelFAJwnEKC sdOCQiBEZjjsCWWfBCfKI9K13NC27Vx4Gj385x+WciUpSTdlu3wU3ok9suV8NUI87ejY23Jvj6VG7 cJoxz/eUoW4LLS+QJMig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZU4-0000000AuVF-2wLq; Wed, 27 Mar 2024 20:02:52 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTT-0000000Au62-2O4v for linux-arm-kernel@bombadil.infradead.org; Wed, 27 Mar 2024 20:02:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=CZE0ell9od5iMx/niXSnkXHAkP7o0Zji40W4vIuo5Ic=; b=Y0mTayhdUdwzp7TlvIjBfJ+WzZ yZCvdBd4iLy+hOH/a4K305W7wD2INRc2ZE3ZXMY2LFkp6EGCT9wEAJZdcri7hz5zaKLZ9CpJTet8o P8YDEdSxYeQBL/uGrrSKCs8UEYT3gKuJu/ittzWke4mOKjOI7ZXWJI4rml9ouR6s5WYbI0rjLsnom Q2/yyWWEQNXAfoqGD4/ZbvvVdTznXfJeEm+Gs6hS1nW2xywmaubXuvn7In49HIrenqQpfGhERAjK8 SYnTAIbdGHEhqP6+og/f5py25qwDUpGOM0NnSUA3GcWbS7L0O/21SUWpvP88j3h4gzPt9k/MJsbDn pZW0aGBA==; Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTQ-00000004dp0-1oPE for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:14 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e0000cdf99so2221215ad.0 for ; Wed, 27 Mar 2024 13:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569728; x=1712174528; 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=CZE0ell9od5iMx/niXSnkXHAkP7o0Zji40W4vIuo5Ic=; b=mkJJ0zMFHXHExZvekjH1i42sskThHkJ3vL+VGkbw6mdhRrKjgy74AvPCM338enDNRk MTCDzOnlxQtWVQWktqkx4GtlAF1/dh4j8hqCOQTqB8zall8YYO7eLByxDP3TRLxwbIM3 Jhy67pQsU40Y6ZC7mSLqvqaW4InyipEwQmBJwBsIaorcrbMeVbMeGFYH9InmfbSPY5wA zEiArvcXpGakHwPACrOp8wNj6Omx+8ZxMX9bGHGuPjUMngHDwzgdTncUxUSSwMZCuqqc a0LZLmHvFJkuatUyEm2umzCWCp6cUMXfGEnoH1DOZRgHrJ6rGl/TF63gB134kOOZBDWL KdZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569728; x=1712174528; 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=CZE0ell9od5iMx/niXSnkXHAkP7o0Zji40W4vIuo5Ic=; b=Ro594JU5Xqde0eyY9Lqfi8TfsxCkGD1nLImTfEhErL6gQtVZZaLl/7BtGzGMKz4HHW r8R0dNBcWfMeWjYmXMr5107G4yYIo4HLbb80F5WKhMhhkTahudILqRQQ7RM6YA+5LVp9 bZ8MCyiEAjGqVl38JL3cW/HuRkdW+FucItfYqYs4dxsuWoAZG9k5k9H+PGgSaxcQDkBE tZwyVUsynytsxA49zySOFbHa750K/ayloaCQUiLIHUk2guCVpkUfOlqtyx5KTjcWG3WP my57b7h8UFgHG682ffjpRUYGIx6WMeLMv2R5LjALIYvondpT6cZB2iwcms2+w40ltwgX zevg== X-Forwarded-Encrypted: i=1; AJvYcCV9swqoWPKOG2vBOMo6P2jMGkXm47uiick77h1PJ1sZiANIW/qCrJ+wsNVF/JGN9VnooqYLdxjvhXTVrgsFT06gTa22f1sXp1NzPEMBvFku70zu36s= X-Gm-Message-State: AOJu0YyxxGYHJkVLIVIGzG4Y+RCLVve2eSVmwkkQ4JeU1BY2gEmi6Dwu wyEc9q+tKSz+baDjSXaXyvaKs3nT85pcLQq6gYESHVAmB8VQ533ZMx4rZmVtkhrGhn6sFXlrVQB 7 X-Google-Smtp-Source: AGHT+IGM9v2q1Bg0jHlsJFItc73WPBzqi9soPcoc57OB2ZggdclEbNRISa4ohk9keY4487ms+Vhuaw== X-Received: by 2002:a17:902:d4d0:b0:1de:fbc2:99f0 with SMTP id o16-20020a170902d4d000b001defbc299f0mr957547plg.2.1711569728307; Wed, 27 Mar 2024 13:02:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02: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 , WANG Xuerui , Huacai Chen Subject: [PATCH v3 07/14] LoongArch: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Mar 2024 13:00:38 -0700 Message-ID: <20240327200157.1097089-8-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_200212_557924_2A487759 X-CRM114-Status: GOOD ( 12.09 ) 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 LoongArch already provides kernel_fpu_begin() and kernel_fpu_end() in asm/fpu.h, so it only needs to add kernel_fpu_available() and export the CFLAGS adjustments. Acked-by: WANG Xuerui Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- Changes in v3: - Rebase on v6.9-rc1 arch/loongarch/Kconfig | 1 + arch/loongarch/Makefile | 5 ++++- arch/loongarch/include/asm/fpu.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index a5f300ec6f28..2266c6c41c38 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -18,6 +18,7 @@ config LOONGARCH select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PTE_SPECIAL diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index df6caf79537a..efb5440a43ec 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -26,6 +26,9 @@ endif 32bit-emul = elf32loongarch 64bit-emul = elf64loongarch +CC_FLAGS_FPU := -mfpu=64 +CC_FLAGS_NO_FPU := -msoft-float + ifdef CONFIG_UNWINDER_ORC orc_hash_h := arch/$(SRCARCH)/include/generated/asm/orc_hash.h orc_hash_sh := $(srctree)/scripts/orc_hash.sh @@ -59,7 +62,7 @@ ld-emul = $(64bit-emul) cflags-y += -mabi=lp64s endif -cflags-y += -pipe -msoft-float +cflags-y += -pipe $(CC_FLAGS_NO_FPU) LDFLAGS_vmlinux += -static -n -nostdlib # When the assembler supports explicit relocation hint, we must use it. diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h index c2d8962fda00..3177674228f8 100644 --- a/arch/loongarch/include/asm/fpu.h +++ b/arch/loongarch/include/asm/fpu.h @@ -21,6 +21,7 @@ struct sigcontext; +#define kernel_fpu_available() cpu_has_fpu extern void kernel_fpu_begin(void); extern void kernel_fpu_end(void); From patchwork Wed Mar 27 20:00:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607465 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 AD60FCD1284 for ; Wed, 27 Mar 2024 21:18:39 +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=uU5Wshi6Sqm+4lSeqfuj/xPqZedlEHKwkllFuXQddFQ=; b=oel7TbDD66z+4+ HwTWEYqtOtn/TaYiDBasNJu3kJuJB/pzpZdovQ5GV/DDJ4E8yYXH0/EVNuEBXeQTG73pncrB686E+ z4rR54MgJ/LNkc/GQvT3oSDOiSOXrCA1JAhDkxniBqDS+xMKmTGsk97VxJIDb4v4A0DbOg3Duikdy YkG2p+F00SfWH4n9OUXYA1pOLwjuqFiv1glKYAJ0QAkr2uLLkSlA3V7lH8OEWYcRnA+3rtqZufYBX NR+pJaZksy0rMMaJ4BZEUD7HjEgLx+T6JNAJc0Vrxj/RsvYy+9V3lWLn8SJLiN7HbqILkGAC46a8m ZVyIFVTYjKaEmB5OOR0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafE-0000000BBDD-0dB7; Wed, 27 Mar 2024 21:18:28 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTO-0000000Au2v-0nlx for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:13 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e0b213efa3so2409035ad.0 for ; Wed, 27 Mar 2024 13:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569729; x=1712174529; 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=m88RK+Z/il7UccpWfFZJ13Lz8O1oGIqhXeprohKD33g=; b=FekRvyettbsSu2/ywpxT75sDgBSfTPaVHuovDO6Or+coKxJwJWm9E3S8mROINkQxdV M+Q7+4uA2IopB5g1P4s3PO9gmvQChdo2VrZmZMyRD3OxFBW2PO0sp5Y7h8O366bgPWNd ympZi2xAUSF/Ns15AMCDRKXP3Cn4tj4vXElxbcJglTr0jfpqIgbGcbaa98/VWjLBinvb QhbvdtwXK4aqq3A1EU4TG7UD3s2t9WfCz5t5XFFt4dUzRF5hCYDGZZIrTfs+6TZwN0/S NL7BiccjDk5j1uQn0K79dcOrW37zIkHpqc7JSMnbavZkI9yD3Rekm+NPHWZrQcVhSr25 i4iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569729; x=1712174529; 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=m88RK+Z/il7UccpWfFZJ13Lz8O1oGIqhXeprohKD33g=; b=ukBNAkE5Wz7sJCD2zdAueKvNtyOG3C4UbSxiARHAjpydUdCWhIV7s7ytBQwWlve6YO 6ABkz1GtJcweV9jealTWXamyT/Ul8E6KI915BPnLMn+lKcQp70GGREjDyNi+culwZZZH Sa1tAKHaA2GzJL/hykXIYgNBqoDtFfyuu22yGWd41YGhLrI8dcV3zyphfLdbQMx0x4ec +l9XBi2+XWaAPKyWELmaW2Nsp7ACyQIexeWVrq6y0JN1uZG6rMJ8rixDxD+P+IsZAq9J U4aVAA5Oocfsrx9GOJ0O80Y2L1BDhOFkNruvf2BOGW4M9l8v3UeW5JKqfXeLZExPHRr+ QpZg== X-Forwarded-Encrypted: i=1; AJvYcCWgv9qml8a6hiw8jTN9JjwjS6E/txzuQwGFMKJbBMvHDFOzbCzsLh5zIBj38wuH5XIiljZeq6L04n/qw/LNbywxDZ2tdmVngs1synluwdPF5fRPrDU= X-Gm-Message-State: AOJu0YwGkCKxgrzEJKB9vALyCausfh69rWibx9fUg4/98CzUitVGSmGC GLn7H/IQp1DUU6rvPGOaqq/Ys6VUbmWt2G95+0mYVqEqmahm6SCw56lXpnRYBJ4= X-Google-Smtp-Source: AGHT+IH0VAZKrv/13SGM5UcmUSkWC7Cq+3cYLh6cyOWJKLLcWVjV8z3mPcOJjmVufYLvLYoh5WS5fQ== X-Received: by 2002:a17:903:245:b0:1e0:e70:4264 with SMTP id j5-20020a170903024500b001e00e704264mr785470plh.33.1711569729552; Wed, 27 Mar 2024 13:02:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:09 -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 , Michael Ellerman Subject: [PATCH v3 08/14] powerpc: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Mar 2024 13:00:39 -0700 Message-ID: <20240327200157.1097089-9-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_130210_357138_0B595455 X-CRM114-Status: GOOD ( 15.59 ) 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 PowerPC provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. The PowerPC API also requires a non-preemptible context. Add a wrapper header, and export the CFLAGS adjustments. Acked-by: Michael Ellerman (powerpc) Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v1) arch/powerpc/Kconfig | 1 + arch/powerpc/Makefile | 5 ++++- arch/powerpc/include/asm/fpu.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/include/asm/fpu.h diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 1c4be3373686..c42a57b6839d 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -137,6 +137,7 @@ config PPC select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_HUGEPD if HUGETLB_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if PPC_FPU select ARCH_HAS_MEMBARRIER_CALLBACKS select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_MEMREMAP_COMPAT_ALIGN if PPC_64S_HASH_MMU diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 65261cbe5bfd..93d89f055b70 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -153,6 +153,9 @@ CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD)) CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata) +CC_FLAGS_FPU := $(call cc-option,-mhard-float) +CC_FLAGS_NO_FPU := $(call cc-option,-msoft-float) + ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY @@ -174,7 +177,7 @@ asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) KBUILD_CPPFLAGS += -I $(srctree)/arch/powerpc $(asinstr) KBUILD_AFLAGS += $(AFLAGS-y) -KBUILD_CFLAGS += $(call cc-option,-msoft-float) +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) KBUILD_CFLAGS += $(CFLAGS-y) CPP = $(CC) -E $(KBUILD_CFLAGS) diff --git a/arch/powerpc/include/asm/fpu.h b/arch/powerpc/include/asm/fpu.h new file mode 100644 index 000000000000..ca584e4bc40f --- /dev/null +++ b/arch/powerpc/include/asm/fpu.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef _ASM_POWERPC_FPU_H +#define _ASM_POWERPC_FPU_H + +#include + +#include +#include + +#define kernel_fpu_available() (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) + +static inline void kernel_fpu_begin(void) +{ + preempt_disable(); + enable_kernel_fp(); +} + +static inline void kernel_fpu_end(void) +{ + disable_kernel_fp(); + preempt_enable(); +} + +#endif /* ! _ASM_POWERPC_FPU_H */ From patchwork Wed Mar 27 20:00:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607459 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 B8078C47DD9 for ; Wed, 27 Mar 2024 21:03:46 +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=GxCDJZN8gdMbm4MkA6nZPvcAYAz4QBOeBRt9+VqzSPA=; b=mBsjjznWRAUEFT tTkIrJK8/+gXzuViapOVHEM2cxHu3aaPQKJRl4LMWlKHD4GbR91dWy6j8Rkv1Bv7KdiSKXLwL1DF1 ie/2cAzd0Htwct1S5UJNla7ALQ8KLxVIvVEN3mVKlkgjlWTMMOQlBV/YfLZQlrZVh0VYftePMNVJ3 gtw+31uRMQZ3uvrvBRemq+noxI82INXNCeI9HBabpcFUjHH4T0hB1Pu5oJjmH+rxzM5VGue7RDvmm iAegj94blbWDrDMipcId/NRzwifFaaYlA21IiN6bSD6gjyyEf3UxUwMaP2T5H4SKd/faXadthMN/2 OxlrrRVCELbj+iUsbaDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpaQp-0000000B8O2-0U7b; Wed, 27 Mar 2024 21:03:35 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTU-0000000Au7c-43aC for linux-arm-kernel@bombadil.infradead.org; Wed, 27 Mar 2024 20:02:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=nnfcb5HAvzgd9XZtKey8r+Hj1U7B+/pwxPGR+srUxos=; b=ozrgTldVFuLV6I1oAzGCa2Rn/9 dG6w5TYFh7QejPaJDwpL2iwkffWS6q0aSQnVKARhLOBtyCLVN1MBKGEwdcqep7ado6DWWVfU8F2Sc Kch8rdClckEzxf5RVAQjAoZDl068I8ae2ubUTI5zi4G2Ewa9U6ZrTxm+alXC6HgpDtjQgOMWrRWeg ZqP773BULHKiiQfkYjkXyHB0AeE/iliv7JQyJeHVv5hy8GE8+vh7vXd2UMvkJFpAE2CywbuJ/9cIU Ml0camCGUZevkyXbXSDQ7+xM3+CDwPUovMvmlw2D+NswjdhwwUS8hsCX4T4Xkkhxbo7LPyerIl3l1 +CrkQSRw==; Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTR-00000004dp8-2vwM for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:15 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1e0d6356ce9so1809825ad.3 for ; Wed, 27 Mar 2024 13:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569731; x=1712174531; 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=nnfcb5HAvzgd9XZtKey8r+Hj1U7B+/pwxPGR+srUxos=; b=RBw/1oeiAlSavLClFtdRhFh664hsj9wpy1zB9FxJchnrtdi5RLDB7lfvMKub4ru2+e krt8E3f0/Ny92SrQIhjMg+q1cpIvzcqLQH7TZEfaJvH99Xy5ZtTBZJGV1eQ4BXNW7b56 O4JJK2iwODnxQSbOSbdY3TtJfV93r+f8dfxEoCoCL6aq/Ut4WrxiavxfoiqpwGbh1IL0 G4SYWa8o/zIsgr/+P8xP0sbfE0nHctO+ndESXG41n13ZpH4EexxXe9XHeEjP0fx+Afn6 +LhxXF4a7PWSeO6TEF2e6jAmGnIF7VmujVi2QvoA8oqP3TgJ1ozeCSYjJlNc4NOlc9GL VX4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569731; x=1712174531; 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=nnfcb5HAvzgd9XZtKey8r+Hj1U7B+/pwxPGR+srUxos=; b=b49ejSozdPBIffqYpFU55599YCrmjOF/WIb7CvffQhQd042efYGUWlF5WWZixFOdAL cggsMm7AkdW2t+cyW1QxlCb0LLbDSENL38maWXAqX0f9fFfK87rg9KrIAUX1LAGEzcWP WDwWBQx46krIHqwmdVIAyFZDFIPsAyUOXildPKL7nCSrZWN4cxiyfdlY7+O8JiM+seLi m1X3mwWRme+NW+xzwgbcH748FBqJIsDpQBb0erHb9SUMo3NUz1mflSjfmdtb6ctQ4Ir+ 5nasj0Wgac6Exny4CIaGJhi/XUrlRyq30DPYQgqlrKvTiR2dchWFno5lRr4ZzIX7xWbl 4V5A== X-Forwarded-Encrypted: i=1; AJvYcCWCxPwJa4pWst1rVHT2xKUAAVkGClrjSsP2Gbnhj59h1/9c5coKbXQdWqa3IObrGyNMD/SgV25lHSe03Oy1oRopGzeFE8SEn4tHCPrALasnD02VslY= X-Gm-Message-State: AOJu0YwK+J1rPbqmnmrX+Cc/NXsH9d5NBC0KO4X8IlG4GvdWtfx2PFZE khqtmb60VZpEYgGrDU7dizWbPLdzBV6XnQYMUny9ZTAgiJ+X/QXOuXLfIOyosrk= X-Google-Smtp-Source: AGHT+IGwHWClv4VHwAUMeRko9/IrGC0nK3n3EBnq+VQl6LUZXOQ24ITW9JUdRJyNTiGgpBBFPtyemA== X-Received: by 2002:a17:902:f545:b0:1dd:73ba:cd7f with SMTP id h5-20020a170902f54500b001dd73bacd7fmr731731plf.47.1711569731200; Wed, 27 Mar 2024 13:02:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:10 -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 , Borislav Petkov , Dave Hansen , Ingo Molnar , Thomas Gleixner Subject: [PATCH v3 09/14] x86: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Mar 2024 13:00:40 -0700 Message-ID: <20240327200157.1097089-10-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_200213_778873_F3F76FA6 X-CRM114-Status: GOOD ( 15.46 ) 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 x86 already provides kernel_fpu_begin() and kernel_fpu_end(), but in a different header. Add a wrapper header, and export the CFLAGS adjustments as found in lib/Makefile. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v1) arch/x86/Kconfig | 1 + arch/x86/Makefile | 20 ++++++++++++++++++++ arch/x86/include/asm/fpu.h | 13 +++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 arch/x86/include/asm/fpu.h diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 39886bab943a..7c9d032ee675 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -83,6 +83,7 @@ config X86 select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_KCOV if X86_64 + select ARCH_HAS_KERNEL_FPU_SUPPORT select ARCH_HAS_MEM_ENCRYPT select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 662d9d4033e6..5a5f5999c505 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -74,6 +74,26 @@ KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 +# +# CFLAGS for compiling floating point code inside the kernel. +# +CC_FLAGS_FPU := -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. +CC_FLAGS_FPU += -mhard-float +CC_FLAGS_FPU += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4) +endif + ifeq ($(CONFIG_X86_KERNEL_IBT),y) # # Kernel IBT has S_CET.NOTRACK_EN=0, as such the compilers must not generate diff --git a/arch/x86/include/asm/fpu.h b/arch/x86/include/asm/fpu.h new file mode 100644 index 000000000000..b2743fe19339 --- /dev/null +++ b/arch/x86/include/asm/fpu.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef _ASM_X86_FPU_H +#define _ASM_X86_FPU_H + +#include + +#define kernel_fpu_available() true + +#endif /* ! _ASM_X86_FPU_H */ From patchwork Wed Mar 27 20:00:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607390 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 A4E24C47DD9 for ; Wed, 27 Mar 2024 20:05:09 +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=jOx8CNFjIG5WaZ90mDXwaLf9bpeezI28GvADlqDbXF0=; b=uoSq/QigZOZkHH QYYQgg+VczbRqU1GR66yCEhL9ebD+yJ7YguqD+YQZ5wteBz0+tHxpTW8Yl0JK1jkW2swqqm9uxKcQ 50cmqj49vMqfY91eLx36TaBIeV0DCLEPqlAWI6z4J4JBQ5YASg4ZgTlvdVfOKDo++Ddl4i7UzSeU/ 7/BH9UEuMhKuXUQ0ebWrGnxtcwgncK7DRccJsV4FoK2asxreyByVHCD0MtYJU10okQy32C2mfItV+ fRQLrS4/ugxDLoxDY4AIywzyAwfIppOzIx1J3rglto92+c4mttIf1OgKEWW0z/7uQfIv98ENa4Kr5 rrMzWA7kckKjr+FaXePQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZW4-0000000AvnB-4BGe; Wed, 27 Mar 2024 20:04:57 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTX-0000000Au4u-0A3m for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:21 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1e00d1e13acso1825795ad.0 for ; Wed, 27 Mar 2024 13:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569732; x=1712174532; 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=tGWc9ebaY2QC87evSRTtIDPTTKODWYBNdAFlf6sP+x8=; b=m3X9YGsaUuj9tc4w8GJ4t07x29cO5RHX+NlvG7j1Zs9uXrI/soO69XCK7pyUNOv2lJ YkJk8HE5qW21x4Sr0sF4cU9HklZXmEnF8IxejWlezma1aZ24dLl8D9PrJlIe9OdICr68 Dm5HA3/h7TcJ38EocSE1LuXn8y0FQBm58NOUTpdP/0/spnH4W72KewSc0H1Xk7T9HMEg joU98o5olUHKgvbk2xyBvNOH0+IowzNDwDWqRLa2hO6W7tz9yBqQh69U9UD1ypdgz7UI e0RMrTSUZPnJu9rlHJbDRIZJ9nvU/nhtjvSBQIf0lQOJRJdyLBk4OqncktSjesmJM2Ed 7QWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569732; x=1712174532; 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=tGWc9ebaY2QC87evSRTtIDPTTKODWYBNdAFlf6sP+x8=; b=aHZPLxlHC6eNhBXc4YB6wYSGMeTeM5M9YFb6ydj/8CeX5vD+VEf1F8WzxJtad96Qdq 97QR7YTx2NYgwVAuqLgFQKLyrMo+VBzOKai48auqZckyHmvImIsAIQANIx3Si6Tl1TIN T7YzKieUzgceRzbtXw+YjryPrJtBPrqZcXMsdkEzKrwoNU7/KvlklCDOzmKfaqBaodiB sR/KNCU8lB0AV2VprxesVcLK5IWA8BEQcLL/YufrFlnaepiNfITTyvKDlWEztE2aENOH xM/TEmsASXf9dgX4dhpngIyi1VcrdK12RJt/lshJT05XJiyaCFt85IcMM4qwibtH5UVx Ct8w== X-Forwarded-Encrypted: i=1; AJvYcCV4bWnezgsXezMvO1h2WMgFenprmRreMAAyYf86hi5HMyT/b6CDiRLuQu71z/1IOnNxgsP5zaOQrmMGUGPgHG+HcVbw0l/oSZ8PaaUgvIxg91nLkGM= X-Gm-Message-State: AOJu0YwYMLNt6Rl8f8xwundQtd3NE5THsSh7gscUyLeYqUNDED2xOiHh 9bEYQ8sXhHWxGaNUrAkZTuORHRc3XRSIcs0YTPESLJHR0SviQcJyosbmsutntaE= X-Google-Smtp-Source: AGHT+IF/XXLIIHj+pdeHOeaQpfwKr83x+9g91i//d+1nB1dHcUYu9bI9urgKfRLt2peRxnrkYrSQjA== X-Received: by 2002:a17:902:ec92:b0:1e0:73d:9175 with SMTP id x18-20020a170902ec9200b001e0073d9175mr916865plg.45.1711569732549; Wed, 27 Mar 2024 13:02:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:12 -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 , Palmer Dabbelt Subject: [PATCH v3 10/14] riscv: Add support for kernel-mode FPU Date: Wed, 27 Mar 2024 13:00:41 -0700 Message-ID: <20240327200157.1097089-11-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_130219_386799_1096D8DA X-CRM114-Status: GOOD ( 18.20 ) 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 This is motivated by the amdgpu DRM driver, which needs floating-point code to support recent hardware. That code is not performance-critical, so only provide a minimal non-preemptible implementation for now. Support is limited to riscv64 because riscv32 requires runtime (libgcc) assistance to convert between doubles and 64-bit integers. Acked-by: Palmer Dabbelt Reviewed-by: Palmer Dabbelt Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- Changes in v3: - Rebase on v6.9-rc1 - Limit ARCH_HAS_KERNEL_FPU_SUPPORT to 64BIT Changes in v2: - Remove RISC-V architecture-specific preprocessor check arch/riscv/Kconfig | 1 + arch/riscv/Makefile | 3 +++ arch/riscv/include/asm/fpu.h | 16 ++++++++++++++++ arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/kernel_mode_fpu.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 arch/riscv/include/asm/fpu.h create mode 100644 arch/riscv/kernel/kernel_mode_fpu.c diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index be09c8836d56..3bcd0d250810 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -27,6 +27,7 @@ config RISCV select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if 64BIT && FPU select ARCH_HAS_MEMBARRIER_CALLBACKS select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_MMIOWB diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 252d63942f34..76ff4033c854 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -84,6 +84,9 @@ KBUILD_CFLAGS += -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64i KBUILD_AFLAGS += -march=$(riscv-march-y) +# For C code built with floating-point support, exclude V but keep F and D. +CC_FLAGS_FPU := -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)([^v_]*)v?/\1\2/') + KBUILD_CFLAGS += -mno-save-restore KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET) diff --git a/arch/riscv/include/asm/fpu.h b/arch/riscv/include/asm/fpu.h new file mode 100644 index 000000000000..91c04c244e12 --- /dev/null +++ b/arch/riscv/include/asm/fpu.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef _ASM_RISCV_FPU_H +#define _ASM_RISCV_FPU_H + +#include + +#define kernel_fpu_available() has_fpu() + +void kernel_fpu_begin(void); +void kernel_fpu_end(void); + +#endif /* ! _ASM_RISCV_FPU_H */ diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 81d94a8ee10f..5b243d46f4b1 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -67,6 +67,7 @@ obj-$(CONFIG_RISCV_MISALIGNED) += unaligned_access_speed.o obj-$(CONFIG_RISCV_PROBE_UNALIGNED_ACCESS) += copy-unaligned.o obj-$(CONFIG_FPU) += fpu.o +obj-$(CONFIG_FPU) += kernel_mode_fpu.o obj-$(CONFIG_RISCV_ISA_V) += vector.o obj-$(CONFIG_RISCV_ISA_V) += kernel_mode_vector.o obj-$(CONFIG_SMP) += smpboot.o diff --git a/arch/riscv/kernel/kernel_mode_fpu.c b/arch/riscv/kernel/kernel_mode_fpu.c new file mode 100644 index 000000000000..0ac8348876c4 --- /dev/null +++ b/arch/riscv/kernel/kernel_mode_fpu.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 SiFive + */ + +#include +#include + +#include +#include +#include +#include + +void kernel_fpu_begin(void) +{ + preempt_disable(); + fstate_save(current, task_pt_regs(current)); + csr_set(CSR_SSTATUS, SR_FS); +} +EXPORT_SYMBOL_GPL(kernel_fpu_begin); + +void kernel_fpu_end(void) +{ + csr_clear(CSR_SSTATUS, SR_FS); + fstate_restore(current, task_pt_regs(current)); + preempt_enable(); +} +EXPORT_SYMBOL_GPL(kernel_fpu_end); From patchwork Wed Mar 27 20:00:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607468 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 3C421CD1289 for ; Wed, 27 Mar 2024 21:18:41 +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=HsHC01t4QZoB1DFmP97Y/rEPYOaMdP/51VN+xrW1CCk=; b=pLpV86ripx7etu V//xrSBYjtYc5fxusPEuzHHM97H2fkHAYdXz5IwJv89qWiqUGYbFQ/CPKKiQ2U+sV+xNLanT1PHG9 AI3pOngPuucr2r71zQMQp6hvOR6GqVo70MAcnwt8NHitlG9zyLmRhOEZD8qbW0YTIysc4MAb5MoOi yPrF7PGnuGtysGSLwp3/tKNwwS/ZZ4Awtu4fkZ71iVO/r29eaR5tSl/2sWDKAt7ik56Axa5MQ70sO BVuDEZlpq9LTh0lUk19x1fl/5R2dPXDio2luJ1DWAx6rO2BbFBvooet1zPm6BMeGB59h5DwUD/4ma 2YF1LaYdvkGWMrVgesrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafG-0000000BBEV-1MCa; Wed, 27 Mar 2024 21:18:30 +0000 Received: from mail-pl1-f172.google.com ([209.85.214.172]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTV-0000000Au5u-0rGY for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:20 +0000 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1e00d1e13a2so1946995ad.0 for ; Wed, 27 Mar 2024 13:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569734; x=1712174534; 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=Kt5T6f5KKlAqEBrctbVWHiZ4yWz8xGfDOuoPShtqdto=; b=HCWKeHS+ePwcHUURIA8zbF8vlAXJR9pxjAgyT2XQYNhAjLF0AF/xvsHJHEkcskIGOA GR9SrXPLBhs/S+DD8u+VyUtYNCr46I82JzIqxbLUDIAenwv9yQwqpoXgELgAnRCwmxBV SfjbAsSHOnMZUKJw+LpTLxcqXNlOUJYsXbly6mS9J6x4rYVH2jI8kidx4RtNpGHBC1Th +F+KVFKdlVaxWjMos9cg6Ju1RkebGW3Udi1jfiGbAeKIBW0P2FlHF92KjHvb33wFeb7B 1oh5PzAAhxXeQphHuRfxBieJEbSYW78ILzhjid8bPVXIS74DYju0Gah0S/1lXISqvswd Luxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569734; x=1712174534; 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=Kt5T6f5KKlAqEBrctbVWHiZ4yWz8xGfDOuoPShtqdto=; b=MT8JDsorV9+8tYQDfe/rkpWQcMGue72svZ/SWkUaktodyDHZzTWjExcXih1ZBO7diz b1b765e4N0X5YLobwIoC5rf/+hbtqAaRRlfdVnKDDR7SDaF382WB9v5a2r3cewBfUh+D yPHVdD2Kg26lepPUSTX2Hm7Hwx7NhmZFGgvRV4+PJxZe1fvCg6ck8rof3DhXreVCSv6r mZ8k6MT/DpzsOVTS9Y/6pZW3mxgOtCXRJZWqzamh8U6YjPDEUkNINinbNKTfzy0XIs0Y BABovPWWMxZHABhj9TELbITW08iV3UJAjJD3an4IlDn8pa8EKv4gOJVENbFgnY9c71Zl Ojfw== X-Forwarded-Encrypted: i=1; AJvYcCW5Uoomzm9LR63ouwYfYmibaHHqOfIGFED8rfaIe+o9iqYUkJVpwhJksG9GPXDJ9XGJJnCm4/flic7xgB/ibN1YyGik2uRJI6AbnhP73+K+eoNmtV0= X-Gm-Message-State: AOJu0Yymz7QKF35wuoUVdKh9l7So5fqWkC8aAck5IbwCCTwhW5QT7f4Z Q/kfxvPl6k/ecNkpS4ifMXF9wqXsRfC3m7YGJdzx2yZKtzCTEk1VYS9sADCmkiY= X-Google-Smtp-Source: AGHT+IGvbXfMD3NpHBvc61C4JrxkXrP2UbmyeCXEZSqIACFIDKyEi0FLcpBAl7w+qDDaJ12IbzUk9g== X-Received: by 2002:a17:903:1211:b0:1e0:afa0:cc9c with SMTP id l17-20020a170903121100b001e0afa0cc9cmr851093plh.2.1711569733842; Wed, 27 Mar 2024 13:02:13 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:13 -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, Michael Ellerman , Alex Deucher , Samuel Holland Subject: [PATCH v3 11/14] drm/amd/display: Only use hard-float, not altivec on powerpc Date: Wed, 27 Mar 2024 13:00:42 -0700 Message-ID: <20240327200157.1097089-12-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_130217_597308_DD3BC8E1 X-CRM114-Status: GOOD ( 14.33 ) 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 From: Michael Ellerman The compiler flags enable altivec, but that is not required; hard-float is sufficient for the code to build and function. Drop altivec from the compiler flags and adjust the enable/disable code to only enable FPU use. Signed-off-by: Michael Ellerman Acked-by: Alex Deucher Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - New patch for v2 drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 12 ++---------- drivers/gpu/drm/amd/display/dc/dml/Makefile | 2 +- drivers/gpu/drm/amd/display/dc/dml2/Makefile | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c index 4ae4720535a5..0de16796466b 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c @@ -92,11 +92,7 @@ void dc_fpu_begin(const char *function_name, const int line) #if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) kernel_fpu_begin(); #elif defined(CONFIG_PPC64) - if (cpu_has_feature(CPU_FTR_VSX_COMP)) - enable_kernel_vsx(); - else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) - enable_kernel_altivec(); - else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) + if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) enable_kernel_fp(); #elif defined(CONFIG_ARM64) kernel_neon_begin(); @@ -125,11 +121,7 @@ void dc_fpu_end(const char *function_name, const int line) #if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) kernel_fpu_end(); #elif defined(CONFIG_PPC64) - if (cpu_has_feature(CPU_FTR_VSX_COMP)) - disable_kernel_vsx(); - else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) - disable_kernel_altivec(); - else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) + if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) disable_kernel_fp(); #elif defined(CONFIG_ARM64) kernel_neon_end(); diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile index c4a5efd2dda5..59d3972341d2 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -31,7 +31,7 @@ dml_ccflags := $(dml_ccflags-y) -msse endif ifdef CONFIG_PPC64 -dml_ccflags := -mhard-float -maltivec +dml_ccflags := -mhard-float endif ifdef CONFIG_ARM64 diff --git a/drivers/gpu/drm/amd/display/dc/dml2/Makefile b/drivers/gpu/drm/amd/display/dc/dml2/Makefile index acff3449b8d7..7b51364084b5 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml2/Makefile @@ -30,7 +30,7 @@ dml2_ccflags := $(dml2_ccflags-y) -msse endif ifdef CONFIG_PPC64 -dml2_ccflags := -mhard-float -maltivec +dml2_ccflags := -mhard-float endif ifdef CONFIG_ARM64 From patchwork Wed Mar 27 20:00:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607470 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 BCB3FCD1284 for ; Wed, 27 Mar 2024 21:18:44 +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=hkA/Jw9D+x2wGTOYdpErQJKYkHn/w4M5Y8JkcsLrjIE=; b=l4g3PszJpN4Xwt pmgqBm7pnjzMWePAVpNScx9Rz5BnDgvWF2ZhJji9muut+sq/b9Db4cTztq+LA/qCUL7lWE1uqrcFz BVfCdeTorXTZFp2WqP0KnHyIhXynJfOkmkROcru3gCwuxSILIGK+0qw/MWcTPBVS3Cl/LbSg1qC5P FiybZd5O7KuXX29pyqjWxMdkVBQpdTfleg88FBIhLRLop2NAqjpkoqth8te0G3D5ySCWrfRKMvCWw aANYDGzSDsuj3uml/TWWPEcJUUNafWgVeJs4JBMjRJTzPO4+v5JNsafZWOSU4mQ9dUifxAdJG2Q4y QnI6vJaiaxuMvuuhorHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafJ-0000000BBGt-3ZaT; Wed, 27 Mar 2024 21:18:33 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTc-0000000AuDE-1Z8t for linux-arm-kernel@bombadil.infradead.org; Wed, 27 Mar 2024 20:02:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=bM3Hi+5Alr7tzqsz3KXbQamZzAJvK/Ux1AY7aws8WNM=; b=LLAGcoIs4FdL57UaK0OvBj5v6H dzJrvMnY2W2xMBOorGLertr4o9LSoIbPH1Qrtag8i2yho+P+r2RzYU7LRtai1L9FZkJHuPX0K59Kd WyDPYF9ealodYaK8aY5x7FcInCE+MMCt2aVwhd/YMpB9QAwWf78yK9TBFqEYHmDDAmNLkQZgKAyHt lmZ/aKr4CjpX1qDO9Vi9Sg1eG4P1wbKMMAGb+t+GaBZYUhRMMn34UyelILteiVWZXZk/+RQwutNI6 RxpLzUIO7c1CiraSJY3ZPmyQnuO83mhetEmt9u/Xw+M1I8w6tnmkZ4X8Tqe1Zf25g4RsP32zWcNu5 3YNm9+tw==; Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTV-00000004drF-3dON for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:23 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1e0f0398553so2230355ad.3 for ; Wed, 27 Mar 2024 13:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569735; x=1712174535; 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=bM3Hi+5Alr7tzqsz3KXbQamZzAJvK/Ux1AY7aws8WNM=; b=c0Tr1jz6pD+05G33eYCqoDyEeFR5V6ijP8roRvF3jZRZKm9Ere1OYjdJVjzFP2UEkT ZZVdY43ys172TqCktKquCZrRnD0/xvyGIVmwYaQsFVDgAvFCWOZ40ETL7uI8UqJHiQZc 2BuwXsnaVy9VGc1mYRBxo36u/ljpdYKhJDL0FfTd1DOQPRXyQuhSt7J/WTsGI0wC148i 9UJe7OpqCyFB6MSwDt+7llJUAT41+7C9ILt16IODWtHYpqKGnjRPVAonpNI8AJwiBdvk IYonwECkIpl9ZRHv+IFBmrPEg8D5owGwnZywL3lxDp0JbVmA216Vok0NjpXhD1z39c24 LKHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569735; x=1712174535; 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=bM3Hi+5Alr7tzqsz3KXbQamZzAJvK/Ux1AY7aws8WNM=; b=SHH1vIbl0b7qf5zktVJkbOKotw1d3wMuFEY7JSifZ+B9Bzgb9PlkIw1Cl2AsnSGxm/ QM7oYxmLQR/JCq4hxcig3GM5QWA8mBPL2n0mj9UgmCCDfVu5h1IT5eF8r410uDr1iisX t5z+476Lxb0fEtwxEgVpVifJf++IQXrZZWga/O6K7St0w9eE94+himD74RtJgNygQ8VG BN6GN5qB1ccYHSEFz3hGdV0A/u6xER4xn6CNZNC1HazuE7c2qH8/JmZ8N8YWeA2luKig sO9/fO0aSQVx/zNQhgjDvQeMgtoWnCGHtCORaRhCxvyXaMJJbZCCVHdntwWaji1zbVti +l9w== X-Forwarded-Encrypted: i=1; AJvYcCXtbLQDgdkIiqnuILLOgN1V2EGIHf2sYvNVpsQV2WEvA9Oj0RD/X+OD/CBly9nuamzPKoLLKmCQCHcO3PclXNmEc4R1+LGVJVFFheGOJ1lD9RRgUtI= X-Gm-Message-State: AOJu0YwsCq4hcQ3RZuN9nm/VOiD3LQP/tf5kIOC/hwDc76fvX4xkRyYm qrd7kJcV/jeuOqN6I6pcyVb0Qul2bHmhftKdux1KALAvg24SoKBpMXABxk8HjmU= X-Google-Smtp-Source: AGHT+IFj0bwxlMv24MtX2R4pKVUBPTEZabeDrpj2jWHiUrD8cnm8OWyltVVZB2eEjF0aA2RcWrF1Pw== X-Received: by 2002:a17:902:e5c1:b0:1e0:c91d:4487 with SMTP id u1-20020a170902e5c100b001e0c91d4487mr958029plf.43.1711569735358; Wed, 27 Mar 2024 13:02:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:14 -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 , Alex Deucher Subject: [PATCH v3 12/14] drm/amd/display: Use ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Mar 2024 13:00:43 -0700 Message-ID: <20240327200157.1097089-13-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_200217_965263_B61F57F1 X-CRM114-Status: GOOD ( 15.69 ) 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 all previously-supported architectures select ARCH_HAS_KERNEL_FPU_SUPPORT, this code can depend on that symbol instead of the existing list of architectures. It can also take advantage of the common kernel-mode FPU API and method of adjusting CFLAGS. Acked-by: Alex Deucher Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Split altivec removal to a separate patch - Use linux/fpu.h instead of asm/fpu.h in consumers drivers/gpu/drm/amd/display/Kconfig | 2 +- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 27 ++------------ drivers/gpu/drm/amd/display/dc/dml/Makefile | 36 ++----------------- drivers/gpu/drm/amd/display/dc/dml2/Makefile | 36 ++----------------- 4 files changed, 7 insertions(+), 94 deletions(-) diff --git a/drivers/gpu/drm/amd/display/Kconfig b/drivers/gpu/drm/amd/display/Kconfig index 901d1961b739..5fcd4f778dc3 100644 --- a/drivers/gpu/drm/amd/display/Kconfig +++ b/drivers/gpu/drm/amd/display/Kconfig @@ -8,7 +8,7 @@ config DRM_AMD_DC depends on BROKEN || !CC_IS_CLANG || ARM64 || RISCV || SPARC64 || X86_64 select SND_HDA_COMPONENT if SND_HDA_CORE # !CC_IS_CLANG: https://github.com/ClangBuiltLinux/linux/issues/1752 - select DRM_AMD_DC_FP if (X86 || LOONGARCH || (PPC64 && ALTIVEC) || (ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG)) + select DRM_AMD_DC_FP if ARCH_HAS_KERNEL_FPU_SUPPORT && (!ARM64 || !CC_IS_CLANG) help Choose this option if you want to use the new display engine support for AMDGPU. This adds required support for Vega and diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c index 0de16796466b..e46f8ce41d87 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c @@ -26,16 +26,7 @@ #include "dc_trace.h" -#if defined(CONFIG_X86) -#include -#elif defined(CONFIG_PPC64) -#include -#include -#elif defined(CONFIG_ARM64) -#include -#elif defined(CONFIG_LOONGARCH) -#include -#endif +#include /** * DOC: DC FPU manipulation overview @@ -87,16 +78,9 @@ void dc_fpu_begin(const char *function_name, const int line) WARN_ON_ONCE(!in_task()); preempt_disable(); depth = __this_cpu_inc_return(fpu_recursion_depth); - if (depth == 1) { -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) + BUG_ON(!kernel_fpu_available()); kernel_fpu_begin(); -#elif defined(CONFIG_PPC64) - if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) - enable_kernel_fp(); -#elif defined(CONFIG_ARM64) - kernel_neon_begin(); -#endif } TRACE_DCN_FPU(true, function_name, line, depth); @@ -118,14 +102,7 @@ void dc_fpu_end(const char *function_name, const int line) depth = __this_cpu_dec_return(fpu_recursion_depth); if (depth == 0) { -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) kernel_fpu_end(); -#elif defined(CONFIG_PPC64) - if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) - disable_kernel_fp(); -#elif defined(CONFIG_ARM64) - kernel_neon_end(); -#endif } else { WARN_ON_ONCE(depth < 0); } diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile index 59d3972341d2..a94b6d546cd1 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -25,40 +25,8 @@ # It provides the general basic services required by other DAL # subcomponents. -ifdef CONFIG_X86 -dml_ccflags-$(CONFIG_CC_IS_GCC) := -mhard-float -dml_ccflags := $(dml_ccflags-y) -msse -endif - -ifdef CONFIG_PPC64 -dml_ccflags := -mhard-float -endif - -ifdef CONFIG_ARM64 -dml_rcflags := -mgeneral-regs-only -endif - -ifdef CONFIG_LOONGARCH -dml_ccflags := -mfpu=64 -dml_rcflags := -msoft-float -endif - -ifdef CONFIG_CC_IS_GCC -ifneq ($(call gcc-min-version, 70100),y) -IS_OLD_GCC = 1 -endif -endif - -ifdef CONFIG_X86 -ifdef IS_OLD_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 -# (8B stack alignment). -dml_ccflags += -mpreferred-stack-boundary=4 -else -dml_ccflags += -msse2 -endif -endif +dml_ccflags := $(CC_FLAGS_FPU) +dml_rcflags := $(CC_FLAGS_NO_FPU) ifneq ($(CONFIG_FRAME_WARN),0) ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y) diff --git a/drivers/gpu/drm/amd/display/dc/dml2/Makefile b/drivers/gpu/drm/amd/display/dc/dml2/Makefile index 7b51364084b5..4f6c804a26ad 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml2/Makefile @@ -24,40 +24,8 @@ # # Makefile for dml2. -ifdef CONFIG_X86 -dml2_ccflags-$(CONFIG_CC_IS_GCC) := -mhard-float -dml2_ccflags := $(dml2_ccflags-y) -msse -endif - -ifdef CONFIG_PPC64 -dml2_ccflags := -mhard-float -endif - -ifdef CONFIG_ARM64 -dml2_rcflags := -mgeneral-regs-only -endif - -ifdef CONFIG_LOONGARCH -dml2_ccflags := -mfpu=64 -dml2_rcflags := -msoft-float -endif - -ifdef CONFIG_CC_IS_GCC -ifeq ($(call cc-ifversion, -lt, 0701, y), y) -IS_OLD_GCC = 1 -endif -endif - -ifdef CONFIG_X86 -ifdef IS_OLD_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 -# (8B stack alignment). -dml2_ccflags += -mpreferred-stack-boundary=4 -else -dml2_ccflags += -msse2 -endif -endif +dml2_ccflags := $(CC_FLAGS_FPU) +dml2_rcflags := $(CC_FLAGS_NO_FPU) ifneq ($(CONFIG_FRAME_WARN),0) ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y) From patchwork Wed Mar 27 20:00:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607464 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 ED7EDC47DD9 for ; Wed, 27 Mar 2024 21:18:31 +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=X4QJFV0ozAM/DD3C2RE4MOJ85LaspLJiWsERnNdyEu0=; b=0khWd0CQwIGd06 42WjSXFFpCg2CMJr4fN6XU0QVPS5AY7p1sr1x/eM24CUFHLO1VbQMRmCTE/nbsQpMDAX+rie6/qFu I6sbuhY8AtopixN3HgE9N+RIFgyJbzJFHKuF2nfF0G5swDBq/4TRmquwNondmxf+Tg84vpCnQV5TW rzx/pcVwcnG4NHHsbqo1H2XFkHyqiOnjwA4+Llu7oZBMrK8hB96GDvMdmtwrGA36nhaoWhoOgervK 3sTlcEazO2eDY5e/pEubv88vJpUHV+Wu9TQ3FC8xmdllf2BqzdtELbBVuQjE8za69E3/Zejj450RV 3nxfTQEGdj2LrXmMV1Yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafH-0000000BBEu-0gok; Wed, 27 Mar 2024 21:18:31 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTZ-0000000AuBl-2Z1r for linux-arm-kernel@bombadil.infradead.org; Wed, 27 Mar 2024 20:02:21 +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=WUVdv0rxxPa8lHoyIaYtKDRoPzXAvzEPK1q3j7PbRrc=; b=fBc6aU5/SbgERnzpSK11zxPZnS 3rmYTBgq0NrXeooDO/LjsOIo0xeTcfPm6rXFMC+NRg/NLlf3U7HpiXVOZ7ZuXI+VcXDcDUEU+SRq9 mFN4zMzIG7c8a2lOhfCLBTXwuotHACwKkhgBLxhyFYCBXMk/MWD5X1mUoqAu8yh5WjbQYPVkMchJF lHeVywbbJ6ltE7zbTFxEgKfdO8yJ1bCe/qSkmd6qTnOsKL69unBlXP+WBfMlLYcFUvgow7cemW8D3 af2F2i5gZJxmSdaKARWch4VMad6B1QACWhIuc8Tf8iFBR02NR//bPJiPRkkdtN1F4EV3GLJ05VGn6 2dwaWMJQ==; Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTV-00000000Wt0-3wyn for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:20 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1e0f3052145so2330765ad.2 for ; Wed, 27 Mar 2024 13:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569736; x=1712174536; 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=WUVdv0rxxPa8lHoyIaYtKDRoPzXAvzEPK1q3j7PbRrc=; b=NmuFCOjS7HV6MI5lwJDAeIFXCbldxwTAH9UI9d22wz22em8lOkT6H2gBv8DCFvvRYA p3Ug/MiMV9K0QiotO4XkdqEdeiJJhvKIBjM2UxcFzISmrPk0OsvKzNq2/J7OsSCpmNey iprL5u0hgJo/T/Kz7JBh9m6hWVqnM0v/tFMi0IVli/DkRzUecGooLnGekK12CXPtjEyd RUvyotExY6Hip20+cjPrjTNEGafcRhSUcQPxPjTAzFrOusiNMcDZDngqertRIpYf68JK ZZcUT7213NZadtj8sZKip7tKvcVWrZ7/OhuyCLynv2HNtq+ywwEWS+3VSan61GhWI1Y3 td4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569736; x=1712174536; 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=WUVdv0rxxPa8lHoyIaYtKDRoPzXAvzEPK1q3j7PbRrc=; b=rSi+MRCgrCgt6ubxOWorDH26QcXNWOHha7QYdRJWVWiOOdX42QRg6kAuoy2u6QIIVf tff2OmGqAYeaCKkV9C6j1wfEd+LyOtnzVxzr0nwDVSHaz/PJRpsiL+nt949v8/Lkfu73 NqOjRTJvn9s9VfjkZzZPv4cLYlmZ0J/3WMZBrNIOfgylqwwwRNQODsMMLnN/YfF5nv5O 7SvcD8K2mDrC11tvgLhfQqIrriiZ7ZwAb0Tcn9NYRu4MWUwiVbMbaRJT+kywYLeFShic ystSeQzB5hMZJUUVF95HL25aOpYMykkQpQZt5qrQipcAmAJMkCBnxzXDltldztVrkAzd Ctrw== X-Forwarded-Encrypted: i=1; AJvYcCV0RucJ5unve2/3FkfcMB73trSymNG1gWM9YgRpjxhculyjp1cYJmCSriKRrCvEzl4mkOz+/q279Av1xjxhBhBYNVNCGc8T3zUKVc7fvRZddprxDSk= X-Gm-Message-State: AOJu0YxXIp4w1DJyz0gUo3YQcnMYBAPYbUgB8G83yE3oErkTZtP7Y5I6 HDLJii3k/uPLW5TMb5sK+gd/4ItEfnfrZbzu3OTXsJkwiDfrnt/YrD98bTCxOpQ= X-Google-Smtp-Source: AGHT+IElWB3obfH3WLoSJnhNdDLs9puYhG8ITpGoTToOUpNvi6XoJmk6eGirKGJFaRPnDc33GdSn9w== X-Received: by 2002:a17:902:b28c:b0:1e0:e85b:2d30 with SMTP id u12-20020a170902b28c00b001e0e85b2d30mr669199plr.42.1711569736542; Wed, 27 Mar 2024 13:02:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:16 -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 13/14] selftests/fpu: Move FP code to a separate translation unit Date: Wed, 27 Mar 2024 13:00:44 -0700 Message-ID: <20240327200157.1097089-14-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_200218_206535_4E2A23BF X-CRM114-Status: GOOD ( 20.55 ) 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 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; +} From patchwork Wed Mar 27 20:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13607469 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 3F687C47DD9 for ; Wed, 27 Mar 2024 21:18:44 +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=AXa+yf1mQbb4LDqrzjcufH5njfCVt4f5JOX20Wtx2Uc=; b=ipTk/pWxvHLUCa a+okTYKxX+ro3DG4Mb+wD8LMZWPdqus6Hsu3MNXdqJo/yFlFT1xYGiklN+VL0aEhiiHZAi5ddYZri YwPHlUYT/upRBX7rCdbP2Ng1LGdmM1JIQyVu+n9Xetzh/cCj369p8OILTcm281pMT5MDOR0HegSEH eL9KJPk6TdP6YNtEUXN0TcD2x9KApCB1VYfuU/hfGDPf90H4YtKSsq0b5WdKzLGbF9eWPokiAMTnL j8hAl/dxYnJ0K2fzyloD+SCU/8X4KNfTKe4P9Hu5MTQ9T6TulbYumU24Q+AYIkfxO5E33RspG/D0O zq1Z8G+4I5nDB/erd6Dw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafJ-0000000BBGP-0IoG; Wed, 27 Mar 2024 21:18:33 +0000 Received: from mail-pl1-f180.google.com ([209.85.214.180]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTX-0000000Au9d-3SXY for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2024 20:02:22 +0000 Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1e0bec01232so2085325ad.3 for ; Wed, 27 Mar 2024 13:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569738; x=1712174538; 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=1KPYCb9S3Soscoa7gVsLkBiv/vc0d18dY2Lykf0pkTk=; b=Wend+BTNhAl3h/Y0T94rZgzWTH0wMSQCtZ2HraTwh7VSARwbCS8n58t+wfn2VXqZBB lJfvxLCmDME3VcUIzGOcGDjCVaEOcYOQe82uOKbwXFylxDgG8xZ1/k1fV/DdUaVsGsou +LwoCHWopObqD/vaiRjSrMDIPDKl0b9OHJgnxEBuSir5GFWDQ4ZRkNDvKW8tqK9LSdHK M/7Gn9jpbN54cgqC5cMPCCy4zD/BJfvrD7n1cByIE2JLqVIHQFlGPWa/Ty5zxIMNlp2E BNNE1hyvr660V0JQYnPLN60q+m8SzISrBfvWZFgr78+MkSFx+6Sy7G5+cFHEe0X5b6Tv fbwA== 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=IVoOx1WmqLB1Jb9f4TMa3dCDOeZPoce1n189OfzpURNRWbkBqF63NaLhLmrNqwG2Wf ruir9Zg1Wq2uFTfw4T00YOUpgP5bim92FclPUHccgDH8dxjyNrGcTJQRR756ENrYUBxl q6hwVfVQJf9fwplU0VB6jRdi5Ta/jw23cJXKoNkY6t8gGz11nyWKjdxdrBoyq64e+mY7 CuRleh+fAlzV2tubGrW7q+nlDG5GxfFggIi8515FY4YU7wQMu2V9yrR/EXpvX2FhkcSb PB9uhzfJw/nsOaQ0RVwk6VLAqe0UIpEWiM/C9UZOo9XAQ2YEmhIsMwpd0Fqp0W5LlrPn on1Q== X-Forwarded-Encrypted: i=1; AJvYcCUVjLBuUL+dfE1qm2y78CmctDIPJbhQFhhzVpS9ht7bNs9LXU9NmglZN9UHku0K8b9blltnxD7S3mAAWbQRZBu+JEV7shNHqQE0m/0rons8vzPuTg4= X-Gm-Message-State: AOJu0YwK5MBJfOZAyTgVS+yZDp77V5FYuP50D57nQtolirGclQxC2bGs xAKxLofwaAx7i1BRIFl27M6+p6jW0wsymrRq+mQYLrFGm0DfQSp3hkdnLpCNhDc= X-Google-Smtp-Source: AGHT+IHiVrJt14UyveizhwLAq9XPpEU6ZyZvDdQzDZe0rjNysh7dZh6CYDZhY9eiiH2RA2j+uTxBcQ== 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240327_130219_949734_EFB71453 X-CRM114-Status: GOOD ( 18.86 ) 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. 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;