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: 13607396 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 68F5CC47DD9 for ; Wed, 27 Mar 2024 20:02:54 +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=sWfCNe5e6qYR5WVey8G1LzODv5TVNsJh49QRk4mm76E=; b=iJs6IULJ/ffeUD 4G0aIL2dfX1bprqstLaVjhiGz2iqNs20XpgmrDaM0SY9z3+4T5BoS8J3HzOdt2x4a36j+dtawlYKc UPdFB4sTML9gd6y3VTd/F2KKb7nxHREYRJ7lrAgAp6GXonADZuiGp8k01BscFAMocSl2WT5M/XORw yv+WccCoROh8JKDbvc9Hqe4GGO4cDSEhG5WN2WZ0Slfb+734+FvBOFzFBAAZRyZ4julj56uzPs6xl U51aeopfg5T/2rkJXe7C+ajllgy6YNJ0kcvskqY+TVUols3yi62E8QT/qsSVE1IAStDNAGcHiW1gt pdkZ5/cW1MXU+oRT9fcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZU3-0000000AuUR-16nz; Wed, 27 Mar 2024 20:02:51 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTM-0000000Atxi-1yw2 for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:14 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e0189323b4so1643755ad.1 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=BXMqg/FYeJ4xWJlEHSRuh2mvtUoIP3uHpYQxAy3XRoGlJQbBKz+ndH6HdtNQ9DYlgR 4n8hLcoIOAGjYgEt71sUqBV5GtM5tGV8SsbrPFv/xyfDUAkzK3jzzIrQFLMQ6Pd8DrSi taS1y3sCjcB48h2xOGaY6vYvcqDwoTyGT6GlKKKfJ6jidN2uhfXSkEIjdvnDLBPO/PuR kDwA4RxEP5PRQsZVwaVQTbZ/eZqTTmFIfNx4n1J5BoflzCiD0zVYGifx6XGB7v47xrwI IMkuJ5ZTGC7Tot5dNZsEPg/b8/MOASEKxWsNp7MiZuMu8KUSGyoo44xHQTVQev5rh6Oy jIew== X-Forwarded-Encrypted: i=1; AJvYcCXTQxYygYtoCRMB6x8o5rWEDAmDpiRFwdDl72R+nodG2QhXcz68+g+e0C5OiOhHYN8w5ENVIuk61vucsh4mb7qbD0U9ephn9+Tuq7LexsM+ X-Gm-Message-State: AOJu0YymXU7qIVP5qhnW3OX/B/b6hCi12YYkuEOMkxMtoCVwT42dLxbL P3yavdewk5rDenWfqgvffHQLE5vE+qBqRb3vnN2Wi5EqXuILW5QilztG/Cx4Us8= 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_731469_709B2470 X-CRM114-Status: GOOD ( 29.61 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607460 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 A4712C54E67 for ; Wed, 27 Mar 2024 21:03: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=NAkfNB7JjOaSidRi/sFs2ISSoJot6FUBcJYMnvDiWu8=; b=Yg01U77BFJOcK+ O7cSuOYZ5CcRMhtjk6xppGyZJE8XrX4H4onxuEhzx2ByFN/FG1DyppD0LtOYTMYZbfymw000tcdxZ 1R8KRd2fXCJ9kqzdZRd1bgTB92lpCsmGZT9XrTtcPB4RSDQDFbJ2FIDl8mDXmR2g1tAQQiE7jxrsL EIw59li6c+7dO24AMkdxZ+jpZd2RpKfBsb6yajFa6Ky/w44aC5i/MCz0PWsRip6zUVaiYLL6ZWerR ryULN6Jm2j6pUB76lPNN2sOGmrQPUqqGgRpAj2yVOlaDQHQ8micWSNKqjbuoLkH69qJ7TKAg18VsV V+PMHY8mssS1SH/MFBzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpaQl-0000000B8Ln-3rwe; Wed, 27 Mar 2024 21:03:31 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTG-0000000Atxv-38GC for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:04 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1dee5ef2a7bso1953905ad.1 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=eoo6a/schabhb9vnWpZpU4+Hf4KD2fGXqRP7s3YFFPlsRe27E5c0vKz4xZj5P5gmO9 F/vRvLWkH17wuZenvl+8CCM9/KLBErOEalnG/2uN3BuWOhIQWyMBgrDRGiHwlWT4UKhB L4hW9Fc64uagElGmCLRgS7T2Q5QZ//sE/ZmWdCooEvytld97vp/FXjT0EQf12+BgJlsc rOf4x9wzt/K7FucK+ir8+vZBsA6N6XvhPJGHs/tYxXDT1Dc3SNwN2xS57ZhEysMvbg7T iFDPnc0t+nKizInxfQhF/VejXg6BOW4Z9uhME2yFLf66UIcAKTC8SI0dBv/S67Ko/RzA VuFQ== X-Forwarded-Encrypted: i=1; AJvYcCU8XY/Cr5RgzLE3gdT67XEfxFh38/O3j9Lir5JZnp34L0K3VCv1+cvhMPVGaJAYjQmV7w9MDvXLkd8xi2Rm4E6cpg5v0k+NlB9TxJsGDPPR X-Gm-Message-State: AOJu0YynxJSlLoQqjs+CuxRmumjWhc4pn7vfzUzpr6nMvhysIU5scx3i coT1b8UzsIKG8mp1FDtYKAB36ffbYCu+Bg6NKqnGP2O7e2uqTP8egHPL6Pk1mkQ= 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_130202_930496_7811206F X-CRM114-Status: GOOD ( 15.41 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607400 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 E289AC54E67 for ; Wed, 27 Mar 2024 20:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5jRxR2KmIvyrFKrqoCDzVOBryKGTXZRG1aNNXB89ouI=; b=WWsHINZdRcRtvS RejNXVsna2odOFaK5tH35axlVs7w46O7wBlSzzwGWK72jT3qm7TY1ria2JwytkAjX/TyMOJ67JVOR UZp7O5xf4JeVTI4zxgJbmaGUKOnU/1B6wQiQ6YVPRpGo0GWWSqm9AeT/lUd9sfOeBnrfAUulbcjP9 xj3v4AlhtzAOvE6uqCWhdEJ13TRxLeeA6ZGY+juSSWpkZk4QVdipPaXlwTtnfDMbsIB/sB8uHVfo4 kqp17QlqOF+QBLQPBeZc3UMTUDwABVnZP0gBbwv/VDhbNEwR6BYpRW3ZfAk4JROayK4AAM8ccg4gy JwiRcOTZPgNYOKlxoP9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZVX-0000000AvRV-2Big; Wed, 27 Mar 2024 20:04:23 +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 1rpZTT-0000000Au6M-3gDN for linux-riscv@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=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-x62e.google.com ([2607:f8b0:4864:20::62e]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTK-00000000WpK-3ENM for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:12 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1e0bec01232so2082605ad.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=Eak7KvbXRpOChtaleHv7wykaU/tl7RW0gx3iSFwAD+DnwSz0DN2MlK9GEAdqShnggo QJcH79mJ15CTJ+CnE7zP0q8qUF58+6EsNMQou/I3+Va1MQ+jFrzUppou1RCwtWyNuUsE 2pP+PWZpdHcMCRY1HOX1m1Gwn9S6wNFJgi5VrtlDTEkCxh1oUvb/mL4T3mO/L4gs6BYr xAyBns8pd5CFPD/5NAi0KgQcEtu+6kcxsIHy8eEvuN8GOwruWOR4iLDsxLCcBs1ghC3q 6ZJOlvQpyvNPfCrLLWdmHVbqjr3Xw1oMdgOtNFOSEZzHj5jrBjPYUPmpXo+AuNDs1Woo PsHw== X-Forwarded-Encrypted: i=1; AJvYcCUH26OBJ0NyQvb0ShSSeg0AJc6QCH/zOTucqEpIzxUcCOz23QDh8oSFqH+3bcjNRmXw6TBEb1uiF1AKUlHnppMPP8P8eoR/ssQh5x1gRiwB X-Gm-Message-State: AOJu0YwWAyNmmuk1fXnoRzKgdor2QjF6RTsRpH0MdRUixw1XtUO8CfNh qjbBf9cgxkpEX+LKv1JIoCmXupLvh2ivm3yIqRSZP556V31MljgtOoCNMNg8qP8= 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_217794_43983667 X-CRM114-Status: GOOD ( 11.07 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607393 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 64519C54E67 for ; Wed, 27 Mar 2024 20:02: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=m9tkO/ZWESrBKzxbquh/8UjqGWTdQ5PX6x/8dVq2ymM=; b=okZ6Xlwxj7pf35 vR719+lBW0UH/hprtWJ0U2fOfFGs1x/BvDWW22akdGEjIZIUcKcl9I9e2B98AsBT7Mv/eIZozhPVR VNTM14FjTIrHZVzyU5jlEpDATynVS7H1D79kY2jFqNEp6T0iN/cO/ijE3GHSEuf3Nf5LmMI5phTXL EjLkNLKNlAU3l9gF37lSyoMGuDdLwsLENOXQtsnd6ZDXng45Qcx+3wm08WWRDnYsfK1pq+5FO5eoM c+dtHdZDeydR/9tjEie/5BVO/+zrzPw+HW1YqnG9XSbjqKfd7YBObzx7JQXdU7pt7bDuHVyiSqjJ/ qt4ex3XcHuJKZLaTJEJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTf-0000000AuFX-0JZ4; Wed, 27 Mar 2024 20:02:27 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTM-0000000Atyj-21I3 for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:10 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1dff837d674so1880595ad.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=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=TrEU67ge1ryshgG2xdN3l5sbHDlIGL1X+G+2cN5/6Kp11tqvGy+cx1viZQmH8CQxb+ qEtwouS7+o20h2BsHXu/f50llYw0cfn8xReZZOvJk+YWnnIKQEAb2yPO0j2FL2iJIp+0 9K8Uz4RUDQfGqxiJHm73TY7IA9kygr31vJcVXP1nLLE6pqPFZ4azc3W30DTrXeQSLyqH fFFZ177NDPnPtQOTO4F1aQxsS0Ao7BZt7O0YAnM5XIistX8h4vAqtdwQ8UAPU6+KE0tT JoxQAQbQWGwl7IxgMWkB4r0zgTsKmOas6jB0nngzn+vDQd6UZTriCsVVUTvACgkpD82/ 5I3g== X-Forwarded-Encrypted: i=1; AJvYcCUUYSeEJTVKe2U3fCpHftM6MazES/5RSGiy8mNPJTKiwSs7ficxzSza5Pivsq3flV4o8QUHXULvLG8kfCW7W9yYXbmj27ZCJRfkkVUmsmfx X-Gm-Message-State: AOJu0YyqrHDPHm8QOeDVTMZrQBLqo25XMNFbWHZoZEpWkLRW4Ew2DiPD EabHv6ik/wP702E5Xp/f+0TIhRHHPjJHtqj8k6Yd4Fn+JcIa7vMSHr2InfcuTTmhshGIq0t6rZN m 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_734124_814C68B8 X-CRM114-Status: GOOD ( 14.69 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607398 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 5E195C47DD9 for ; Wed, 27 Mar 2024 20:03:43 +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=6jveSZWwD7rC4F+k53uJ0JpqGn/f2gTXmeaEJLfC6sA=; b=zJBplogQMt6UOS PoEE4LB5bFEKB2qGJcNTwF5ad26xCckGqrApO0BO94yGEwL58d2cXYPP06fyQj7go3HSPYuF0KUJq 29CkIBpfI0FcL/ZW1Aao6CAw79VMhXd+CaHUVgP6wsFjUz4w2kSUWRDkIY6v5WVUUSbci92fKz78z GAYAZzc/XGX6CtP+ADABMyeFwW9tkK6JG9Dc3+DnyaLARCljQL4I8MP8CaOdU8T2ksyESfl90i1kh LCCheMv+XozibCHrCrDLqb5lRkaiFPu3/hTTYKFX0KQJ8ucpe7XQVUv6bqIDQfSpqp03VV142RNnM IM/OWprUz73fMXX7pbig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZUp-0000000Av07-0Aby; Wed, 27 Mar 2024 20:03:39 +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-0000000Au8A-3KhL for linux-riscv@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-x633.google.com ([2607:f8b0:4864:20::633]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTL-00000000WpP-2wwi for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:16 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1e0bec01232so2083145ad.3 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=vh9S0fnZP35k2vig4rjGjpyxVI4qnAhEtYx6gcALlUU4ROTk63zWfTuAsd9ez5vwDl n4sHaVgr2MwFZNwCxfA1db1XcH9sprpzAQh472SyBp1QJlIyFpaO+dp+2gXKr6A2Bmhy BC7KIrwX7xyKKVBcb6+ng/l+nTtL6h1SlNzJ8wJCVXCqGpPyT5JJY5+c5ajBG2iwRRz2 qKrJP4oz9LR2HbOJOPyQ5l81W62PhTWkAVe2h3JmrYj7qfu4QbZp0cUsHJzfDN7ZDDOd KExaYKUG4wIr+A9W9gXHafgZQvqkNF02X9nC9BSyMsiKR7AQExf9BXjw4A6zTQVcWtao WndA== X-Forwarded-Encrypted: i=1; AJvYcCUXSF2es27Gx6hn3NwpL99bemQYZ8fmky8+Hv+rMSSiaXLhLE2v3TWa4am9tifA3Ay1ENI4LUzDYg5gC2gXViR5Ha3hUGV6FbzUVACSfpg3 X-Gm-Message-State: AOJu0YxcmfJgstROlkmyJY12/D+9G+2aVZ6AEkdppmIjrkE2QID6DPq9 KsxwmVufx7bfsQoAZ90/gTVkrJdeYj2jcH3k8+nZusRCkdPUaoIVPoL7L9vBFzI= 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_931039_C7F9A9E0 X-CRM114-Status: GOOD ( 10.48 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607401 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 55604C47DD9 for ; Wed, 27 Mar 2024 20:04:49 +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=xa9yaC3vbzXtTWd1AUyzldjdggdIafzRqKM5i0fLqhM=; b=twwTU/bmXgn1sS XYcDZgXB2ByZ+46HWIODQknGMyeAK3wP6er3u3VC2HKZUweaCOHPOMBfiDLpPGn0Ygn8LK7lyYyP1 mSZgfDegyRJr+pvIg9v/HdzCnbHN+zAAG+o1kJvBTKiyDjTDp1xeBZ0AttwnbIPx2nFUkGZ6nsgJV WvUOhIK8iQC+jDc/ejjJYlG4o9fJjzzinODYyLD2KRMsT3zh5EwHxpthLwbwJSoc6jjQ2IrAWT/ZX mQCuxPA5oSh2DJlKl9vICg8QbxV3Z6qXT4VCXSmauukEXaDAQdtEaBaxvOmTS77ml0LpwHvnBsgHa K1b7j8U3YY8o0m8FyOxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZVs-0000000Aveg-3RPt; Wed, 27 Mar 2024 20:04:44 +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-0000000Au8F-3XjK for linux-riscv@bombadil.infradead.org; Wed, 27 Mar 2024 20:02:18 +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-x632.google.com ([2607:f8b0:4864:20::632]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTN-00000000Wpz-0Noj for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:16 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dfff641d10so1915865ad.2 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=KsSvHGQjiOfb/zobU0S/UbpBu0SPT9RpQT8VCQKSprPp+AD0p7Zx7eY7jAis0qWnFL I/ekYXanEZgcPNUdX8AN//A+oTHfXlF4RhezBvfvwa3hlRFYopW1f3N588fV84DRtFxo 3tadKRfnEhq/+Y+fMnoRUy6vnMAbStDuenX0xXzmPxB887XYLjuFL6t5LqM/UgIp7ea9 24SIdAumIc2+Z40K5NlUEzF/Hei+FWizxqMLuFz9UVSmYtxvpjW84G0Fr0Ruq9dqe7sG zSjhWmOur2ov2vRWPd/+2KInu40Eht14xzP3t2jIz+pqnIjNuaZi2HJwIti0c39lWeoh NlDg== X-Forwarded-Encrypted: i=1; AJvYcCV1hG9H4mjnqF9UymEgTVEBbk4dbsdnLg98Sj3Mqd/zGl8ckOnl1M7aXk7Wx5ms1pZ6/gjCwbVWb81cHKy+ni4td8GDo24sMdHP+KFHFGWh X-Gm-Message-State: AOJu0Ywkty2lkKoyrn45+EthxYhGu/DAJs71FFrtGXkFMbDlsejotjHZ BxavB2+8xgR/MfE5GXl0TO/myzI5sq6X0eRXGf9NOl0/uhJz7sf3OyRU7M9SO6s= 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_200213_269952_9D9E3F98 X-CRM114-Status: GOOD ( 10.29 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607397 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 7E1A6C54E67 for ; Wed, 27 Mar 2024 20:03: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=w946HGvqLOz7OZqKYkb87+wOLHqw/Ws5iFPgoUJyKZc=; b=Xv5CzQUrRr8oPX NWhH4t5+yGV1rlTugbz9JzHSZpFsOrBWbF45M7rCGXT4S+AXqMjzLXRtoima3QcwO06dcRxM8RdPF e6mvZr86B/mO7oY2wCD5DVAE5FrZra8bysqbktcc98deS2PjLbCf46DFYYbXhHNWkFy/rHurE2Umy 89+wJXfVCyPHqE2Y+aKgLJSBkfOPqdsVrWNA1W2RwOZFNuUN9n+BuOuA+UAGs2zheIKUgy+QJ631R 7bKhSldoPwm3hWNuCc21s0tCwG6Oh2OZNCrKhBwxYwOFpJ+CdnjB26T/r7bDyLcWgvaH8DI6qYieA TcmTsVBO8uaHt4orUAXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZUf-0000000Autw-0njm; Wed, 27 Mar 2024 20:03: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-0000000Au8D-3K97 for linux-riscv@bombadil.infradead.org; Wed, 27 Mar 2024 20:02:18 +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=CZE0ell9od5iMx/niXSnkXHAkP7o0Zji40W4vIuo5Ic=; b=YE2vBlKtmFYLpE9mj3cgkq25YH OIcMQutXaaG+Lj9CDaUybxH8KiXyLfz15R8bJQhClkatZodqjsT/C2uP/Vj5qs0QQZRpui8ua8Xx5 uMy2sGnc1Rhozc8+v20h3MjTKPBssra+VaxiwmMgc9Ds2KOIBGC1cOf55sezHU2E03pSbiTCgNZ3+ dv1TB3TjFaL/4s0EXtLKv0LRyXkp78v8z61msmEdcBcgM5Uz7KGPDodIiO0VMw4M62rtMCdZwJYE0 MSs1LcpNk5+zybpe1SB4f5PRPP3bVIGRp6aikatDXZrWv6beq8OCuPA9QT9fpvzQ8xmR44K4/x7do /8c77x/Q==; 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 1rpZTO-00000000WqJ-2LmT for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:16 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1e0d82d441bso2011095ad.3 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=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=St1PsOyKBW0j/vcoieWMwhAwuNi+dVdoYcda7frl1hBvQdCXvhba7u9Q7a1Mrb1Wbx GYbPucSlMcevVEwiAfctznVjZFTxFHNleKEZL4WEGQt4t2k8hqIITk60n05hkazi8Z1O jMR8V9sc3LoDpH2ggGoNtdOEUOAlUSp2wqNazdf57fdKXdQ3kiqFMHugp04UxhzlEupN Ce1l7Nq0XygN+3wBmmXNMyCSt+Kr8G7tyLHT5TJehnd2XEmlwXcG+NWuJkEjoV8+Gdw4 2nUF6iI+6+mLHHXJgCEMvR0sCxienhdAEZp5R4WqI37FAicwF4rk3xEBSEGdvzzSUkGk 3DLA== X-Forwarded-Encrypted: i=1; AJvYcCUq4sC/1CqafIAOsl8TDr/ORX3g9bsuhBllpzI4fyP1waD3DSUJkr1MtJR112oBMaUwUqjDYUo7KQpYSTL/P31/VZanYCmUpKugIDtTjusC X-Gm-Message-State: AOJu0Yx7Q2v6O3gHhyyl7ePtTUHb/jjHcEyjpBJbcSS6OWBJkMAB2KNu eAL5Uo48VMckUL2Bj++Tlac6705uF/rC0tSDRhuxD9OmVRiPKI80bVDaeKNw+XU= 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_200213_007814_FE143A92 X-CRM114-Status: GOOD ( 12.28 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607395 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 2D2FDC54E67 for ; Wed, 27 Mar 2024 20:02:54 +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=rFYPceOYWxI9YLje9KWVwqNZYkF/MiZLYpSNuxkroyQ=; b=IA0PL4yvcCHn85 PTPeu7Nao9EqqBVy/TKt1yFxIlf4RwHqnEQ7i/XTaHzvkF1CgOEVqZuCReeciBYo/z8lNZiy6RHKV E1fQl3SbsxpGKW8LGi3ZWzZBHT8MwaFriV9aeSo7qwZnqQJ8QYuPzNd3ZED1J2hUPt9FqD70zsrN9 bjrNem1/pMd+lSaQmiLlhHEu4NuxOMaFchLyOlnzYUWrucRKUayqHTxckHKaXIbAO1hOLVF09MOQT X4JIFQAJHcjwrKA8YJxmombd+wP5LrcEHZaCGnU8Rlnzy3TWoqnA2b3a9hir1Ztqfg6lCJda9rY7N MkmMQWT6qfpnAejOx9+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZU1-0000000AuSv-0sRK; Wed, 27 Mar 2024 20:02:49 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTO-0000000Au2w-0acN for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:14 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e0511a4383so2188895ad.2 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=QxPShAiA/xDBon0Jmi7orsJPrbWRBrUiZ/2UKsOkq3cSJgy8wsDLnBBnw/i49YWTM+ IRlNno7ANTynKnS877GsU0ueNCjStTZoxxS3EgXBZEd1ixCUtugov1Zx3u56f2h/ry/K 27i59iw81tQ9ZT5K06HQ4LJiVdkyTtWHFuVeelsF6mfN6sXeOsPz+VwcltlXDlgy17ns UBGqbrRzVqP1R/yIl7nESC0T8p8SsKkyKgatzcwN2LGz7PzColQ0TTLv6kV1LFPWbLqi 2Acadx+Hq2c8IzMSui5MzbDo4IChNnun2LKAzFtNlzsFBxs/sOYw+9JvGdd207CMDIdW Hegw== X-Forwarded-Encrypted: i=1; AJvYcCVuYgYErqst/fuTkI5NkPSMsLq8FRKi7FxAL+zkqu2CpBu6Pu2/VAJNXMpnLk1BZJM609G6UGHH6YvO9JnWPb7REn6ZGFXaWFfaUYcEFP+c X-Gm-Message-State: AOJu0YyOPsq1Q6sp2U6DyYeK9Kh7ZL7vf+znQUVIN3WedDEHZ2V1kC5q VwNstaRgLxrW5JRb8/ZcV+m5r3IEGxC2bXdfo+BJH0u1hSJHMjQuerHTUcpk1cU= 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_335317_28522B27 X-CRM114-Status: GOOD ( 14.18 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607399 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 7AFA4C54E67 for ; Wed, 27 Mar 2024 20:04: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=L3u62KmDQMeTBR29q5kMpkBufFZ1Y3+LZh71bOQYCuU=; b=NGXFphlWnxGUnQ fhXGB1D+cipYlsNGFdyPgUmDCrNS4dZQVsssqmaYQ78HE5G8fvwoMNIVksf5gc4QFth7qkxUcP1PX ZUvng+Vh8qDSbSH4xV36ZPWqkb4hdLoFsNK/pQUkteNS0HEQuX7BnloNlbhymjzne5iFLlxRd+KgJ cnwNrmNbBTZq2GPRawMijjasADMXFL90aEpjlsyyTF/XzaZtsKiMkZ/Q8Nj+BOp/d4xSpvCXGdHtZ WK8ab5QcajbgMkmKAs2z7FOaV0pXgDFlPNO3dYpVx422jpxypJuUkb7L5PaylyDnUIrUn36H2DZ7P w9AoOvNnib+4/cRymjLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZVB-0000000AvEK-3OUS; Wed, 27 Mar 2024 20:04:01 +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 1rpZTV-0000000Au88-3DCL for linux-riscv@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-x631.google.com ([2607:f8b0:4864:20::631]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTS-00000004dpJ-2XDa for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:16 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1e0ae065d24so2142855ad.1 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=WIGwW/kRBGq/myZlZLOgYuRjtQgisT9LAdJnKEHfrV7XQEzjt3goIstOq89AY2oPq5 Abi/0n2qtIqXh/p/qFXkzVGcno1RsTuXI6n459HN94msAQ89wMZ9+0a46cG40lcb07g6 93d4Y1hDmagLCmHwZzzq50eD8d7XZL1pPnmuwjAiPd1UAIOdeIFNVE+1NpnZpoAF/tiE 8eYyrYELn9C4Pel7hYfrHKfgZOx5eSzD7ccLDt3/oI0zhVNPwk5jicDoBUz4zGHXaRVG c2ShmEVVsJTC8sh2JknFMFD2XeQDAMkVdVc3BXBSIPcRUmYdu5rAVu8QqWkKvmMKoAW/ Ym9w== X-Forwarded-Encrypted: i=1; AJvYcCWRgqiuu5GexCvQo9NK9lAgB9ZF82pWN+C2svJH/v0z8zo16n1iE8LNi3naWZKjI9dTEyoQKo6H0Lsv6mTwtbmbJ/ydqDFAhJ1PnnUPaI8l X-Gm-Message-State: AOJu0Yy0b1PskcptS0ymlpoHsLeLvcBHH/Zkb4XlLQGMsp7/ib6yWTk5 OfNoSQh0X8/9Y6CI0LLmUDmypwWEPiFIAu6LJtX37yCcb8SrRP6S6PJwALgZtPk= 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_200214_660060_D06BF21D X-CRM114-Status: GOOD ( 14.06 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607461 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 C5EEBC47DD9 for ; Wed, 27 Mar 2024 21:03: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=fkZ78+dHvI4yJkgcTgOul0SSRMJF+xAcnFDxpP9AJ0o=; b=07t3Yd9G93Rq32 zzanIcErB55Fb2vxskqVgLOopoCX4Jw+znUC1mxBmyOlJwZ7Y0VIQ25zCDTMihLmfBeQF6zIA0KrT 4YmP/d6UQR9LOdQLmGEUgLtDO5qYp2w3dU2DduBj0/PBfGHOjqmCg5lVQrfoOiRKGTlIc9pq+rlnl QVlR5N5buNDVtMuZcpw3g2E7grWpReK7UxQzk6ZYJjU/m70W2iyzmLKiaFdXaQAgUM/oKplOIIZRE 5Ey0iQnnMeSzRZZpgzKqaIpPxISL0dED9eFLNHycfwV1Ry5wQwYDFIHv36pm7ji9ZtogNxwsgS+Im BqTT+zMSlbUWTaDVKUIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpaQo-0000000B8Mx-03jX; Wed, 27 Mar 2024 21:03:34 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTR-0000000Au4v-3gld for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:16 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1e0d8403257so2162425ad.1 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=ltXnclKHFIGpf/zbaGE28GmDdS8MVG1ykDjT0mJ7LC93jsdMGH6Uu8227bORF+Hz83 ZS+KOtH/D8O/odfQi0w+vLsbW65g0ZUKb6LbXN8+Z4xjGpxBLWyDF8y19cTk8kf/n8AY 4MY791iluMOpxLb30PjRDyeKh+KLqdINUP9TREBWZbWUQ5hPf7k8gfbSlqtf4G/6ReYY 2kwwG0BDiTruLg02mqoLN0Qu3Og1XGBpO3IVPJIjnFngMDTJPCrm1zz06R2tWz3x6s94 m9rOzoLCCpX6bUWmULL3WtCVumAkZS8VvLFBMBHjwAtnd6T2Mi7DXOAWpRpmHSQOs3NH sg6Q== X-Forwarded-Encrypted: i=1; AJvYcCW2ufRi3IHLnUPJE5v90Zelv579CzgSXSsOTdtSRUgtVp8CKLZmg+CsjUpdXjB8izA/z+zqbmPDVInsN89As8j8t2DXImCm77cjkKHmTSPp X-Gm-Message-State: AOJu0YxRrTjypCf/UEwRmiqLExCnnaLm3/xfvfuPuPs0NcGD6CDvKPMU YA1+UEsFUwJsGrQ9W1Fzcjz7mdBPVZ941pNNmKnigPyR0/qvoARHHNO+UD2iCgz/O+/dM4zPmIt 9 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_130214_200370_2B6F1B0C X-CRM114-Status: GOOD ( 16.84 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607471 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 4A9A1C47DD9 for ; Wed, 27 Mar 2024 21:18: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=1fdB20WVpbROXPBRoKpY1pzt2bae7PSJyQHKEC9ZU+0=; b=OPBMG412Hxol/9 kwm+yEnf4oZ68gf3rgf5YRBbnJCfR+SMWg8rHeApC+Xj04LXsQBi7yJ+rBFiJL6rzf8WynEV5M41D cCsqLqdKCQ/QH+MyfJVrRvPHFBKoj6JA7nukxqFK4ifCjCepiE/r7IIL+y93pOKhYmqDtHVuKqQPb ehZRdK6V6/uZVwvscIu4SODYsd7NNC+JA8YJqacZtdHuRxNwmReamrVfYrYFvx8O+D63xiDvSfPIo c6lQzJjqhG3Y8GoNSRxbpXvjJt1Vbzx8hirWadRCeg2zEBzhq4PB3DEKcxcTa74XHaPHsFkmcQAM7 Pqqt2OB0KOwBL6I3sDww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafI-0000000BBFe-0m3R; Wed, 27 Mar 2024 21:18:32 +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 1rpZTZ-0000000AuBq-36YD for linux-riscv@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=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=Kt5T6f5KKlAqEBrctbVWHiZ4yWz8xGfDOuoPShtqdto=; b=qK0kGQUzTEaDSQ7cYJBuzcMJc9 EfbBgST/KyenV9APqId9bNqbJ9/rxLfvHmG2YMvJjMetlM8rOpcIdleupQBT8nO3ghlWrOdfskiYy tbkbXh9gNarG8nsAK9bI8iE0RjS8GqhfIZLxRXTd1bJNOr7AtkgL4q9HM7STH80IgfXQ6mFoVqQWi JNlNHIShovIwQ+fLqD40kB+DuywqgsBd44OIn/qiyBy2xngstdQwe56JthkztWTyxT1kRyTNrfoZ7 MpP+3jW1hgqFFcNS480+cepqrfX9aRRY6flpDSO8QjGxSZwdViGJPIO2L95q7RHfMLHNiYZ6VvYBD /MVC+3Aw==; Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTU-00000004dq6-2sqP for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:20 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1e0b889901bso2371785ad.1 for ; Wed, 27 Mar 2024 13:02:16 -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=tVf/sK2Sh/Mgm+p7fXQMy8CJy5lCJMfWIFLvpNwkAouhWnp50RowAA3CpgbY5yE9Jg 0ay6xao8xGMqsNLv9YxWmN9ZyJ5oEk4pTKt951cQzG/V1NLwqdfg5s6ks6OwQEpu6/AX Ccx9tJVBmG0e0aaNc2PMk3m3X9Heu0QufFb76rHoTq0geKzW9Y2mZOoND3PJ0Gz2IWal X+h3voF0j6TifxtnbYRqI1uCS1TDvW7vRAiX0ybf6+kT921TE1nquGIHCIhPyviTS63z U/DbJnA9Vb7NTC9ssckqTVrdcmvKjKrL51pL9bIZJqdk6rR6RU6RhUrqMbXKoGfQby75 oBVw== X-Forwarded-Encrypted: i=1; AJvYcCXYdqg4Kk+us8vE0iqAEoesfWbFyKXKSxQgnj1XLWHRCF0RHpb6BDkn5/4Cl/Nq/hL9RJEeBLX4TyQyqvPw0Ji0nJnCZgQO1Ga3qX+PnqLw X-Gm-Message-State: AOJu0YzY6eLNeaTYCKc/suboLYWHn10KiPRq8Q6Fl9EZU+Yy06TMutdF LOoxwdVG8iumeSLOoNyQFiHeAakFt7yZVc6m37S9nlHMpAooDwXMMLKESSqtN6c= 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_200216_783052_41585BD8 X-CRM114-Status: GOOD ( 12.08 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607474 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 006CECD1283 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=7N0uAWP6S1hZXt5KmcennQk/CpaGR5JE83XnxVSJvkY=; b=2UsVRmLN7UIkpq wR1AewLYr/8N2J6G5+haCwEg38wxSfcr0HASnr4gJbD6FBw9N0cRpElZXRXvH+gBaVaGEI3fWfSjd Vzy68GJnLzfYsFXUyrxwwU9uRs329Ll+7FhrZsN90680MEqh+80vZt1qDVoGLinzq9Wa9vi89Mz/A 5ZsqnCayJCCaDQhzUI1n2f+qS4YMAejA0GaLIFzzbRl7nbP9IfrolwdLPp6NCQG1uHohglo4+SfKt 1l6rLgs1AlN6SRHu6VQc3CLSvlHxI6AYzsGXiSf+YP3xsuBFuu/A0uwUyhtahMfPdSec3DTUOrfGA RddPFG1FDT46Th7M7mzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafL-0000000BBIU-3oge; Wed, 27 Mar 2024 21:18: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 1rpZTc-0000000AuDP-3XWK for linux-riscv@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-x634.google.com ([2607:f8b0:4864:20::634]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTV-00000004drY-3cqK for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:23 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1e0f0398553so2230365ad.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=nOKfIDuNicNPOgh4QXtbZqc++F/YJh7orsmVYY/ltI5O82p4l5OlT2Wl2BSq319KPV Y6v5TkfhhSbaYEAtISKi5/k6ikjc/1GenZODm74YXk238wfEJCDa2atQL+ltROvw7pfx 82vUVTRRbWztvKbhsrv1c9FPMCm9sapgY3p59bWRRVYWh8vZVEkd9DWtr60S1mL0zA9b hsZAIfpG1UsZUERH+w+d0yzeAN/DUqHH+j13YwBNSkFv0TLbKjkxuNgr9rZk8Drhu4lF /2FmwGzgI8sFnJlBWx0vWMKQaZzQRHaqhZWMVjSva8J3yEYgG6zJLHRWilgLzzau4cDo 5LUw== X-Forwarded-Encrypted: i=1; AJvYcCUFmgsNmV2r3hoQRHbN8DKgVX5WCygtClwan9RFYJk/pTsKxh+KtOv4G3AVHHTQsUwkJUYCZk5QEdz7FetsCBLeSGFpk2IFuL1vQmulzuG7 X-Gm-Message-State: AOJu0Yy0JLmF5vPZNSwzQpqkynIpXW/t+50VhXYjEupNHzAlODCaq+sD JQ2Qksx2o501BddMBQtacw7/KZJXDoeg0ZPHGWNS8DlzUih6T2aVEGmj7u1Tf64= 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_970668_3869F30A X-CRM114-Status: GOOD ( 14.29 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13607472 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 7B771CD1283 for ; Wed, 27 Mar 2024 21:18: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=OSnSA+eqdXOS4K08MAwYxIaXb8wMdGgCYBAy/j73/yQ=; b=xshf/Bje3hu2vj qO1S0hzCAOt7iAOnnOpwVgE5WPfBhCd1RxZIAifIfOnzCQaoEa7IEccNO0LcOgMq7PLmUrHXgVaV7 AvHkK7L04qFSNFQNlilr2XidapiI8zLJUng7pB1Y1aRo2sCDf4rSs10PzjQZyLe6QVK5WWVhQXehH UYzFXDjwmIpcXQwiDhM2RDQ93A/a/uHUB5qmBSJm5YmZyvrl5PMN6SOMASFE72QvyZDlHy9awqFBi eJ/W9/Mcg/THcJbFOG6FEo1RtRlTkmeuZapq/gvO0Lyu9UyBtSKzTu/5KcbLfuSyo2C+ps/FTEMHb B6sYF1ytOivFby/hAAvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafH-0000000BBF0-1tQD; 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-0000000AuBp-3HZ7 for linux-riscv@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-x633.google.com ([2607:f8b0:4864:20::633]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTV-00000000WtA-489q for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:20 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1e0000cdf99so2222915ad.0 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=S1PqlK35c028e8YYQCflx2tNI6PCVRqAtzC76W758nW9UatJskIBfPRQSk5ELyRucO hN9G8E7LVGonf1DsjWJ0NVHJiqtY58oQiABPEfDizg2BUHGzfnuU8pBu4WISmCUfRfUN Uk63tXNorUoTC9kRYz7T482SPF3E4rRxMy3cdS1GUt+c+fuHs//xGdbMuOm3PUurkQvQ gl+b8TZIfnfxHghDDrdd+i2qtddoDC2aksizL/Rak+oY23U653P0HA3+H9c15p0H4+sg /AMXN1S9jfzkEm55ZtBmuHc5mIw1S5OWAFjKqdMFxGiICYpX8dfC/UnNSn8k0sv75epi d2gQ== X-Forwarded-Encrypted: i=1; AJvYcCWDy7he9PJQ1BggNb3Bvj4Exrn+I7b8ROb/W9gb/fPAHkltccQxWEyyhgrNKTvPhkYu6JlGIeVRJtLox0rjXVpFFrHy02or2xADaBO7YBfM X-Gm-Message-State: AOJu0YxQecVNZ3jbNWRyhstGi12UO6ySq/2YcwSA1pGkTN3Ht0BzsAn8 UZRz3KhiU2CsBWahlapRCJa8VLTmkaj7x4aSeyWNbKeW3kT6+iYweoSHZH+oyN0= 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_298745_315E2BAF X-CRM114-Status: GOOD ( 19.04 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This ensures no compiler-generated floating-point code can appear outside kernel_fpu_{begin,end}() sections, and some architectures enforce this separation. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Declare test_fpu() in a header lib/Makefile | 3 ++- lib/test_fpu.h | 8 +++++++ lib/{test_fpu.c => test_fpu_glue.c} | 32 +------------------------ lib/test_fpu_impl.c | 37 +++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 lib/test_fpu.h rename lib/{test_fpu.c => test_fpu_glue.c} (71%) create mode 100644 lib/test_fpu_impl.c diff --git a/lib/Makefile b/lib/Makefile index ffc6b2341b45..fcb35bf50979 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -133,7 +133,8 @@ FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-st endif obj-$(CONFIG_TEST_FPU) += test_fpu.o -CFLAGS_test_fpu.o += $(FPU_CFLAGS) +test_fpu-y := test_fpu_glue.o test_fpu_impl.o +CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS) # Some KUnit files (hooks.o) need to be built-in even when KUnit is a module, # so we can't just use obj-$(CONFIG_KUNIT). diff --git a/lib/test_fpu.h b/lib/test_fpu.h new file mode 100644 index 000000000000..4459807084bc --- /dev/null +++ b/lib/test_fpu.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _LIB_TEST_FPU_H +#define _LIB_TEST_FPU_H + +int test_fpu(void); + +#endif diff --git a/lib/test_fpu.c b/lib/test_fpu_glue.c similarity index 71% rename from lib/test_fpu.c rename to lib/test_fpu_glue.c index e82db19fed84..85963d7be826 100644 --- a/lib/test_fpu.c +++ b/lib/test_fpu_glue.c @@ -19,37 +19,7 @@ #include #include -static int test_fpu(void) -{ - /* - * This sequence of operations tests that rounding mode is - * to nearest and that denormal numbers are supported. - * Volatile variables are used to avoid compiler optimizing - * the calculations away. - */ - volatile double a, b, c, d, e, f, g; - - a = 4.0; - b = 1e-15; - c = 1e-310; - - /* Sets precision flag */ - d = a + b; - - /* Result depends on rounding mode */ - e = a + b / 2; - - /* Denormal and very large values */ - f = b / c; - - /* Depends on denormal support */ - g = a + c * f; - - if (d > a && e > a && g > a) - return 0; - else - return -EINVAL; -} +#include "test_fpu.h" static int test_fpu_get(void *data, u64 *val) { diff --git a/lib/test_fpu_impl.c b/lib/test_fpu_impl.c new file mode 100644 index 000000000000..777894dbbe86 --- /dev/null +++ b/lib/test_fpu_impl.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "test_fpu.h" + +int test_fpu(void) +{ + /* + * This sequence of operations tests that rounding mode is + * to nearest and that denormal numbers are supported. + * Volatile variables are used to avoid compiler optimizing + * the calculations away. + */ + volatile double a, b, c, d, e, f, g; + + a = 4.0; + b = 1e-15; + c = 1e-310; + + /* Sets precision flag */ + d = a + b; + + /* Result depends on rounding mode */ + e = a + b / 2; + + /* Denormal and very large values */ + f = b / c; + + /* Depends on denormal support */ + g = a + c * f; + + if (d > a && e > a && g > a) + return 0; + else + return -EINVAL; +} 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: 13607473 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 767C5C47DD9 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=fFWb9t1sbr25t3tpRDaSXGYnc66GSNcqDZVCIlwiQSA=; b=Qhc+i9cOZmajjy jXJBCGCNlO9itF9EC+VEZvEKjWByfPKh9Dmzk0/ElSz/I2MixNJjHOMVdd7SgtiqFw4Vlvw6nVKOs vlh9/bZCOCAQcHvi6qV21Mh0rSnT/vR7I+ugTgNU1Ae/6PAF8az0sWBgIUt93skgbdSzHSHVGWBIW +1jvfJHQzCD2pAG6Is0kncwFbHHu5yzr8NSGdD4NUm0lqxTt7r696QT3s6ehD237I3kaK0HNF+su6 0l5ebBrMTsDfofUSCCM/ZQzVYMBuWm/9kSCfWl8BNNr3L1d2Bf5NmVC2M/IX+D6XxMbe6BT8StE/A OSXlSQGzyXF2pgeXSSmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpafK-0000000BBHU-2UlJ; Wed, 27 Mar 2024 21:18:34 +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 1rpZTc-0000000AuDK-2ZMD for linux-riscv@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=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=1KPYCb9S3Soscoa7gVsLkBiv/vc0d18dY2Lykf0pkTk=; b=Bn6ZTRfdseQ7Td/6DtgL8Pe7JO 89jH5YC/RJe7mtijzXubAE82Z3e4gGuOKC/TRKEmo3uLp0JgurmFaG5HJPN4kPKGa7LcVth0MSt2P XjqPImZSOykVus/1qwoSKd6PPpRjV6Uw1vvU3O6cZYSoGe4a7TzSgGy8gcISUTt8Pmte9bsu430Np lKQ54YOyC3sb5u08tuXT+TavibJXWg5oFaFM4deVZouZrllTLbHO6mvwrxmoBdzXT6jtBLLc8JTHB OviCdDeVIV0Cx5ToaUtkMh0heoGBo4MxbEhBP+35Vj0aVbLJxwUWQdIvscgk8JzzigBntsNnFQ98I 9AFo1t8A==; Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpZTY-00000000WuO-0hyL for linux-riscv@lists.infradead.org; Wed, 27 Mar 2024 20:02:22 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1e0b889901bso2372345ad.1 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=iJUWtJFK/2VFUUm9ikWLFw9OXTg9Yc2WXRnr3+whqhZkoSAfTLFdVP0TGsrbPdSFxN mLP5fKHGOBRgNUdzm9o9qR4vSa0fzivPQ8tfxvTZxZ+teahavRTKZcyaw1wkQE6iDZnF Odz84pKyi2fhGNGNJMPjrn7f+zKjRXETwwDOkJbkcfRD0JrRzfEjYrPNaJ8GGRx+KJss gOtHi88DmWSsBLDAoVMrhItee4xwCgW8yaMnnkJCe0kz1Q9qiXwgetXaZWlUKq8r1vNO 2qonXD5DhY4U6w4V2Heb3S6dyCIYE6b/xwlENaQ8qKNgQzX19XAOsuziH+v+yXV2EsSa WG+g== X-Forwarded-Encrypted: i=1; AJvYcCVksk/b0divdKEqYQZjM+OKj3453UEtDdUHz6RwwwsN1L9MNRdwD4KhLBs6ofAQ2qhiLGQ9xa3wG9dYixYITtE/2SIOJ3VERjLX0JbAFPY0 X-Gm-Message-State: AOJu0YxzJDHxJZ79oCOGHFuV0tIlNSzzPoS8/XYGh+BMlQQab5ZbEe7U T3YU44KTVGxwAjhTsYNL9tWH0uV1AylIecN0QVp1bqgHuR8CI36Dy/4MQCg80Zc= 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_200220_650046_0BFA513D X-CRM114-Status: GOOD ( 17.30 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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;