From patchwork Fri Mar 29 07:18:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610246 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 B1B1AC6FD1F for ; Fri, 29 Mar 2024 07:25:11 +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=roIOzpI1yZEgsmjBu1jfh9l1iTci2iezLO4rw5Jqv5A=; b=DqukMDFCDm/J1a dIJ/spaYO/PLRx0m0ZausMDOYhSuUaQ7MmX4c4We1f8ndymBYQIrVFcWmz+sBvnUYbwdCpJHI1K1+ /iA7nWN3weS2MIegp61y48zuVIC1kN5VnEnFkkbBKupuWHcB0Mr0KFOzxAEAJiTrJx6iQGNqymqpf KF0rCmhRcBr0Rlzxv0GKNZLi+NqYzX+nBAHrO+HvqtSnYU5sok69CQKG94SiT2xZrcD27IFEfCyts 1HmxcIQN5fEnQaPJJOeEiDvFT7RzhxOCm9VhkXnZtJZ1xi4pwoyFBuUqkjDeBWIgFcL6yeBTQkO+0 MF7VTFF3vo6haaWuwPBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bn-0000000H8he-2qFg; Fri, 29 Mar 2024 07:25:03 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bW-0000000H8WP-1K0h for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:24:50 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-29f9af2e0b7so1255768a91.1 for ; Fri, 29 Mar 2024 00:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697085; x=1712301885; 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=gJgb6TiBTsQDE1YCv6FX1Cn5RHV4TaKIlUyS6ICHf2c=; b=Ph+OaZC9B/epPwwZr4L9xkFW4V0Q6pLnEdaQVcKpxv3niyxrlzpQrHVIf3qSD6thtF NbZaKnak7KOeIIAtwn6B3oTPFZUNS0obCzRUI90MI0jSixIFuYiXT42+Q2t/Ce34o99i Vt61P8+IDfZMOl/9uowicJHG5Lr5ajMQ6W7ZlQhzv4wuTMYvpf6X3r33Tws73VRxMWri kRciWNif1Sm7ysj9YvFraHTijX17nWZ0HUbbPr2JXMAh01oI7ReXvruBN29Mutaj2lLA ABASaVGfGJy8DEzwm/0M8W4kkuTpzUjlUwbysbz+lSaUkq95HR6U4kKrHsMRYEhQJkd/ /X5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697085; x=1712301885; 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=gJgb6TiBTsQDE1YCv6FX1Cn5RHV4TaKIlUyS6ICHf2c=; b=UsMK6hNE+jCEHcoBQXs9Tq/q0loTT6EJthAhMtwS8GfObXmZvXosGHqW1MR8mVKeo4 8T3KyZyOItUaRKyN3fcOeGm+6C0dePkWGfcxr+2RGFf8wAqK8po+3oB34frW1LGI6XZA EvTUPBZT7WHsJzwUR96hjdz3CXk19VYyN3U3bYYJRbfPhhHtgIegrP37ntCcyoxOVVSo ZywHKcxgCMta04vmVtpclP2nraaRkwmM4zNiA/+j56dJO3RDvcOBBqLsk9dGgg5ZGe3Z s8+K2yhqQR4sVRnOTNqXj7kIAtkJz9Z2B97B3TkvQB5wDhtmEKXFcwt9nKlvq5dkuF5E 2zjQ== X-Forwarded-Encrypted: i=1; AJvYcCUjmfy95Z9mTXu7wzSAqsigzmBwY2PRigxvFOpDhCXAPzCqsZOlAjvCztFGPI2tseZ9kd4j0dMFVVplD5xQNCxLrv8SjOE58MafFCHUo77h X-Gm-Message-State: AOJu0Yy9623Ra79OawvGK+UKRycx7urIzmJaNsBotTF30FgcKIfr+g1x MmyryzqsX8s4AsFYxG2+lBj4Qj15Amc59+WLKFGzMkNH0nNNT6X2yUUqSECqFUU= X-Google-Smtp-Source: AGHT+IHa/zXusbJGA4K8cLPLAWn+CnPIA4cHPz+eGb6xCnwX+ovRVMEI/wA60Ad/6sOmnhgR0Mc6ng== X-Received: by 2002:a17:90b:3c50:b0:2a2:19f:dbc7 with SMTP id pm16-20020a17090b3c5000b002a2019fdbc7mr1989065pjb.0.1711697084840; Fri, 29 Mar 2024 00:24:44 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:44 -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 v4 01/15] arch: Add ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:16 -0700 Message-ID: <20240329072441.591471-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002446_467786_077AEDB6 X-CRM114-Status: GOOD ( 29.35 ) 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 Fri Mar 29 07:18:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610247 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 7BDDECD1288 for ; Fri, 29 Mar 2024 07:25:12 +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=yj7l/2nctGZu2TntYEnm38BGBqLAHO9NW+ZOMuynNbk=; b=TxmnRIH47Itk5A hcde3+udsuQAGmdHBh2PtsffaDjU+EoFYxZ4UGwMHIW55X5f7nA9m16xSLvPbncUdKntPDjRe+nTt m0tiQscO5+gwdYhykkdYUJK5JVFFIPCHCJR+YuLOhdym5wP9FQW3lSdiJxzJ2opLLVssT+Fj/+QvQ GTi7NVza8YV5XbGJaph9mZZ0z/LT/JNcuTsR3uic1TpDfuyNLX5gxzISlhE5K8W8A5dd4hZDPXvZA Ny7xQBlc+0Kvj1/wpPHBA73vOWr4CiSYJx5ZvFI3HgFslH5aT6tdZsmtAJWlPkhpiHWkuz7OPEuQO 3aoYFauSttw2gJfEYg6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bp-0000000H8iy-2ZIi; Fri, 29 Mar 2024 07:25:05 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bX-0000000H8Wu-0Yub for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:24:49 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-29f749b6667so1266479a91.0 for ; Fri, 29 Mar 2024 00:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697086; x=1712301886; 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=RfeToGq8Q96lZ3sXR0xrZDFoq0gdI38cqcIbuzYANg0=; b=Xa+jlzT/YtA4oNEL2Xom1uuIQjTtiPNlnOVmw9C2zDbV4uoxCHKdrPlsjrnTS5RA8g c4yGH/rQb92Iir4eHU9uCA1He/INGgkWVSm8Q0cWqZVeLhjHws9f925gi8BkaYFWHHtq 5Nu0YSj6kEfrfsH1zdztHnIHj2rtzFy9TgreH5rovZXxM3Bc6E5IFxrCKjl2+A/NVvpb SO85BEBorKVec7/k6DHI7yYecwzDnVbLgG9a8LBWuUdLQ1qTQ0De0EOygk9LdtfgFyU4 G6NvUe9nlOEepLH3TTYZ5gQgy6caGK+7YmehyGKxXw3cjFgW+tLvwCn2DrWvHXjd64GM xspQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697086; x=1712301886; 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=RfeToGq8Q96lZ3sXR0xrZDFoq0gdI38cqcIbuzYANg0=; b=ZHa1VnqZAkPIIWXLSzrghq+RJbVFK4KM+/kYWGUWVcb1wPEOD8IAetfSg7GrTajz/i ZYcycSPYRIplxNkdnWHkfEtLdZ+RDJvTYOcYglQiYWH1SdPJqysI6M5RfZfOvXg8DlvX WBIv1YfUi77HZxWKIl0ifYcmdPdM+647XuVxTVvbL94w0AYQNTTObhDQM040FJGmdRdn WC3JMETtq1w9iD3RVmerOQebUMlS7BZNAYTW1dS8HbX8xYDVpX5tr3qydQFpNse0bcSr M+g42gn4eF1Jb++9phdEwPiEMIUhqvyUXVzSNKGoGYH5bQWIT3DicEslPscoIiGdItje oF4w== X-Forwarded-Encrypted: i=1; AJvYcCW4KpirqarApYjif3pTh5YP4Fa++9mZv8qNGQTYjTN5ucaMPYqmsJa91wSrbU7B+0tkxx4KyVWHVVlhcJlgoTEPxiXXVp7tA+0bjs2CxMcf X-Gm-Message-State: AOJu0Yzz5LYQvqYfS/vq/5rO0FDppJOcqHR3nxdQfeRlMeEBlNvcYQo9 VTuDP5Q/lLtJ2s3gEhXt+vEhAZfSSvOBqrbb/beiU2Ng8sgCPz84OkG6Ot00A6M= X-Google-Smtp-Source: AGHT+IGQfC9gwOMWVs1GDk/ouQ8mrl3lJb1JowaZL6ev/gV/g9creRjfkW6AQIWqS7U8Lf5+l0COxw== X-Received: by 2002:a17:90a:4594:b0:2a2:88d:cdcb with SMTP id v20-20020a17090a459400b002a2088dcdcbmr1743529pjg.26.1711697086007; Fri, 29 Mar 2024 00:24:46 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:45 -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 v4 02/15] ARM: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:17 -0700 Message-ID: <20240329072441.591471-3-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002447_209102_AF6DAABB X-CRM114-Status: GOOD ( 15.40 ) 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 Fri Mar 29 07:18:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610250 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 6D9ACC6FD1F for ; Fri, 29 Mar 2024 07:25:42 +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=l4jsbGcGtyMMwSdFaAGM7nZXWcPU3fyY/htnFT0K8So=; b=JMVF3kRuH9DwhY wL5Gj7ISqm1+9LC1oAPLQT3+EdDmCbXqmlXOguuwiaSICx5gweQngNJfwozjMzChauTqWzc7Nga1A tnXLJuTP64QHfdL3Z5dOX+PnJ0F3CibGEEGtFZxNXkquTqifY7Ju+ui7mPpD/sv0jB8XS93GwaZJp jYdnYpWIL5Ma+X1BVKifhUdso+DM0JHwH0uD5GMF9OhGKolq2RAi7eUyikHulgEbtHTtzz21KnP0p TShZVyJ8wrg0me3QqxRgu5tuThYVfxTXOvAMMJkHIb4qxAudaPxT0qLdgCZiw2Nm7ywl5Hh1NtQXk t2csNtq1bgmRLJuJCKSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6cL-0000000H98Z-19B2; Fri, 29 Mar 2024 07:25:37 +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 1rq6bd-0000000H8bB-269s for linux-riscv@bombadil.infradead.org; Fri, 29 Mar 2024 07:24:53 +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=cDl3drvCV8mQminB8cd0FWY5ZeQD5iRDfGVHISUC3N8=; b=NZlEbrPUfceCIViBDNcpRLB/w2 xCDe7rzMCxlzqP/YMoRYfjsTyeSDdguskbvRtYy95Q3sw+2QpjPfEj1mI5DG4wn226pNT6UFfIoaf 4RELrGmv4PJBR8h4/emEr2smGKaEUjdRLIVsvMTrAjCvLum/MauAbzv8tK4aK5eicoB/xy7WcDIfq n09oSUZt1R42GVnqN+SMPrY4d4k7eJvWvsdCcNxo8BcHCl9Lk3ty+T2cAQeZOW4Y/l/0Z0UpncwyO dJIW7OZgQ/dAASwEkD/P352CVGGYjExp32SHeY8mbnybuTBisNmM3/OTmYEGcfyD7/t2v4voPiHyY /OZpl3IQ==; Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bZ-00000001Qpr-3kCj for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:24:52 +0000 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-5d42e7ab8a9so1029637a12.3 for ; Fri, 29 Mar 2024 00:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697087; x=1712301887; 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=cDl3drvCV8mQminB8cd0FWY5ZeQD5iRDfGVHISUC3N8=; b=NFrY2hqkzB7B6q5MkqGtWxxwoZJ5c9iAj2Q+ZOv6LpeFHH7YDFU6I//jq5Rxyv17p2 4+vGx0D/X7wx8nFUGi+8Z3LyFdy/CodR/tS/zCeNVaf7BVh5noDldsbSl8byxuA0gJTv do67gt/8gFLqnpRvSAos67FAJj3ggsb15r0BktBBjNGAwNVR0CfLSKA6TfNrsOQVHShy OKaOBGYfZT1jxZOZXwH9PdcJSnGnTtZ0I46H/KS/nq2ZYAaMqPtH+86phcywUE5NgDOz tfPhi+OySoGycWF6NuqRC3wIXpoEp1e40VvajPr8x5myj0jeBEMbD0P48gN2rP075q83 VJ0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697087; x=1712301887; 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=cDl3drvCV8mQminB8cd0FWY5ZeQD5iRDfGVHISUC3N8=; b=ojfxhxOCKTJzCgKJEnM0MeMzPBRa3uiM+3QY7GcQrH0AvVILSNyEvSC5B45gATprve 1Tsb9OUmL6DrDVWHLILR1tuq8qWBQOQe4DzMrIcJbj/W+pODTin8kaw6UUxhVmwLayzV i+C0hvlCfG3BglSYkeQVXIKXY+qKY5oYKx9vXGfxKUc28OAfoYAu3BckZQTzw8B1veiS vKfzJqDaRavOQuVt6T6Rt9FqwiTJMNrz59ACX9DH41RfOaQuXYZjRiLPoupiREcrAtzm TzzMRxvnNU5/JpAcy84Y80azjux5erdzHpuVEvW1RyBABTnCP/45GTFLKU/yXI6VtGIj V1Yw== X-Forwarded-Encrypted: i=1; AJvYcCWGkXFH4LKdFckM2Rbgqcsmr3dCjqOl3K1/vTJPp0FWajwr1NGnWwqPblGZdDW31znpADM+TppKp/oSQOSDVMOzfRAiAV2K7g57b5ZnwD+f X-Gm-Message-State: AOJu0Ywb06oNbE3Q3Jer0jsRGo2kvDtWqDYEqpY9YmQ40ItHvblV0ADN 1kfB1dhx3oapO4UYTo3cDZSRwYfzPg8Kz64kfco4zcYEXNOk9NKDdhaDcL5rd00= X-Google-Smtp-Source: AGHT+IF+FV+uMuQXtJuoJZDILLDfziMVBq/KUES3aiEW6OY8o73iJ5kWmw5SdybGS1gXP7gvN622NQ== X-Received: by 2002:a05:6a20:394d:b0:1a3:647b:b895 with SMTP id r13-20020a056a20394d00b001a3647bb895mr1477372pzg.47.1711697087156; Fri, 29 Mar 2024 00:24:47 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:46 -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 v4 03/15] ARM: crypto: Use CC_FLAGS_FPU for NEON CFLAGS Date: Fri, 29 Mar 2024 00:18:18 -0700 Message-ID: <20240329072441.591471-4-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_072450_221996_F15851B3 X-CRM114-Status: GOOD ( 11.03 ) 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 Fri Mar 29 07:18:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610248 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 5DB58CD1288 for ; Fri, 29 Mar 2024 07:25: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=CM93jGH0h5XmfTJj2bolxbvWOwYlPbKq/aVtHE7X8VU=; b=MtaBXAyPV8lQgm vitXyrLLOxtUZ6Op3sCK0WBN4oTcTjDST2EDEtTN/Y2KZUB8WDAIVuxNJjWWE5bvn2A5yyP6a+Qyz rnq8U6AfUvoq38LNtqlRc6sAeJ8Wmfb7na1dHkO3RTJ6xoVokBcfLQ0IybBYKPiyFN9VtiC0nyH/p cfIG3ggjQ/vQZvUWc2srQ8PRziEnaSYAguvpsqgiRlGDvbssqDmgMvimY877wvmbLdrwSCBKuwaim bgJbIBHEPbUm8Yv8x3Ma7zn7tFwTbZtTcsnAm8cxht2qZs2nau9XoNFmAJl+gmjKb6nEXCfgl2DUl yPo/bKmYKqNN0jVSMW9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6c9-0000000H8y5-1w5b; Fri, 29 Mar 2024 07:25:25 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bZ-0000000H8YQ-3Hdb for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:24:52 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6eac64f2205so1527615b3a.2 for ; Fri, 29 Mar 2024 00:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697088; x=1712301888; 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=BaG/5r11zMVVbJK9XMgdhlmzZC0nXZGHxxAlEP5YrDw=; b=ZugzDHWi72bp8dMq8uf7hcbekD7WVZIoSRbr70Hw/XPdrL2rBm0TRvz2oleMasTWli H9xVOe1azIHr59bZQhfSyM6fat7SbFMZCyzNFFMk1WIpKp7y6sbJ5myUWsh6NszUauFE q83X2SIAUVwicHLO54XORC2vqoNWwReO03lLxMgvK/FIk3oFl28BJU7kab7Y6SLmLOQW u75bTI0gyL0+eG+YI78+k1sEysRtwqZVEmOy9cKR02fButWs7tiPqUyI80YYHmCQupOX Xiq0kxZ3ac3j0uMmPcG6rJMeB+t+qDKZ+W65WMDuekBi84mcNUBbUjk1CIsDbH9f9CSY OGkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697088; x=1712301888; 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=BaG/5r11zMVVbJK9XMgdhlmzZC0nXZGHxxAlEP5YrDw=; b=oAlIEmyl89pz7amzEDI9eE5FooSpV1PER3itq4kbvnwc4Wi1hXErpHOl6sjDpkRrL3 87nXjVVELtOO1nnRjsGaBbMTqTZ0aHzwR/ISBzONqgF1/09f9fpZx5tslknLOjqu26lc bo+zART7uB73acabzmbe1KfCKAcUuCR+Tc1t6il+TNdPhkkPwW6wSXW01c8yvqXPD8uV G1z7UzAKNKlC8+BU52ifJ4/aBcrE6tYwJjALXT50KjIvtYh/tR7n/bAyJYZrW2nZmIOE Kj1XlaitSH3H6UaFRZWp7ACykRcaAbCY/fd7nCxzCryg00hshrvhPaYkaW9rMpe32wXG n7/g== X-Forwarded-Encrypted: i=1; AJvYcCXuHi5HSoFtBJXMOl6Z4f8wTctN2eGeNKqwmKnNvAXdFIsQFsegJ/hycIG8BgXTklhed+Ulgl4mZXlj0jeiMvrGSEdLkjxUzkoytI0DZAcs X-Gm-Message-State: AOJu0YzkOLgS4JGqslCOSRuidJkQHs1CskKaU3q8SAOvWAnXDqhBnJ+N N0sEidnoYZXDsavotCJH155yjmS/XQF8Jnvp5CiM2AZqZRki97oTmbaiUyxbM20= X-Google-Smtp-Source: AGHT+IHyYuok2TNfdiOcE/l5igRa3fLGWQKdU9IqGK1Jb+NsKkae7YWqfCeB+c37aWtPbJ/1sA02qQ== X-Received: by 2002:a05:6a21:6d9f:b0:1a3:55d2:1489 with SMTP id wl31-20020a056a216d9f00b001a355d21489mr1432790pzb.7.1711697088383; Fri, 29 Mar 2024 00:24:48 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:48 -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 v4 04/15] arm64: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:19 -0700 Message-ID: <20240329072441.591471-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002450_154891_6A90A9BF X-CRM114-Status: GOOD ( 14.60 ) 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 Fri Mar 29 07:18:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610249 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 6E70FC6FD1F for ; Fri, 29 Mar 2024 07:25:33 +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=B7e/sCRqO1o7nHlWZbTPMKJNSuuWMaCrgdv4s5Vxldk=; b=ICYqYjPUbE8lkI pBFqE45yUn3EenEh45nSRug94y1SMHF4+tf48oPcKCr3oa4lhrdERZpXRSvHpJlwRG2e9HuvoBILa ivQo1sL28a2iNInYY4SWHPJSsY8/mP4c3t6N4kjoZGIb2aw0ZdjUdz9X2fFLVsLdbs6riQCS17uvD d21AGIFHIH1E1XP/8FaU2t1Ypl7569gFp41Ev3hpZ4NVX/wdKXKExOs/HzAd/lMbqunjHTuKeHu8G dWpDbZ7PdhIFkf8+opMdPoiBqGgdwbs0K4Eq2Z1ZN+kuaSrS3lhL9Y50s9sCa0yYftqcx05JABWSX 5LSdxtsU33cZ9sNlp8kQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6cB-0000000H8zZ-0Tvc; Fri, 29 Mar 2024 07:25:27 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6ba-0000000H8ZD-46Rl for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:24:52 +0000 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-5dca1efad59so1224908a12.2 for ; Fri, 29 Mar 2024 00:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697090; x=1712301890; 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=RPRyZsExaX9jqH4yhl7xuz7hAOg3yG/uDoq2R6sqbZQ=; b=JRriq9lyYNURzcZp8Cz2N/1opAsIAQv8Fa/po6rVNtPiOyDnGtMwt4/ZXshtDDcUC4 FWRE8iu9GaTnLiqZB9BFc1XFaSgo4vec2niyEhk3Ysxfe0BPGrCJZ9/9zfZYbZKAS74p uBy45MzMC2qziD69hke2bmTCjSjtWGA0zbmcRb4VfrwGv8sUEx62o1JpO4U6ZKj+YQid VSVrvzmsDIMGo4ajP9xtnIe99fGuhI4ly7EaKzkDsBdQsQZedTnSpFFa4Yj1kus8x9a8 7ziOoFZevjyOfzW0IvFrZJO17To/WA9jBdtJsdsrVJFkJWmXmX9CAEhMtvyCNxkLeeNb zBuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697090; x=1712301890; 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=RPRyZsExaX9jqH4yhl7xuz7hAOg3yG/uDoq2R6sqbZQ=; b=mI9QuzfplqsPThglB5ftnu2G6lFRrityGZp8sEnZn9u9p/YLGGaw1S/Qkh0gR7hWJR AwBGWMJ+jdrUhd6N2MiH7e4svB49ZzxAchLRJqe7LmNHn+X93ywPXPofYXIlNcaAL6i6 jlRFQZt/UxziZnrD9VBDlX4SEjV6Ss6rK60oO/aNwd3LoJAyJcZu4QaeDczjQNewch3Z JYAGD/sKRe7ToAldbUAmULSqaLtSmcn0ItjrndkAZ7kNQ8v6CVV+AYxZFbmQsgpuihhE +DXdybu+vtWdnhNLeH/wnq+AT9yPygIZ1DNx1bCPXIow9X28uhSDiEEuiaMBnaJhRT7J EdGQ== X-Forwarded-Encrypted: i=1; AJvYcCXEezQoi24SA1b0tNVF4yVscxp5RBHMlTg02a9GUXUPT/vaYrqZB+bCd43wVeJrEY8hEegSQvo+lTqeRu/X1VkguhMHvtqCU2394WxY/UZs X-Gm-Message-State: AOJu0Yz6imEAX+ijutF69CWd7L+As52Vub1lezvl5aBkZNSshEHHc7RY 7FnbbWfPnyulF2mBYyGGz/l0e1WE80ceqmrzx940JiJrkvrAHl5BFioncU6ZHA4= X-Google-Smtp-Source: AGHT+IGTP4+TuVjePLHUufBWyrdagoR69ieuL91+Fm218jTRMOa2nDQVrtkL7zzrGfUrh4aL4xmRCg== X-Received: by 2002:a05:6a20:2db:b0:1a3:71f7:df3d with SMTP id 27-20020a056a2002db00b001a371f7df3dmr1114388pzb.30.1711697089806; Fri, 29 Mar 2024 00:24:49 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:49 -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 v4 05/15] arm64: crypto: Use CC_FLAGS_FPU for NEON CFLAGS Date: Fri, 29 Mar 2024 00:18:20 -0700 Message-ID: <20240329072441.591471-6-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002451_217896_739D61F7 X-CRM114-Status: GOOD ( 10.40 ) 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 Fri Mar 29 07:18:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610358 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 9F78BC6FD1F for ; Fri, 29 Mar 2024 08:34:12 +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=X62HD2IsDqEhtaayq2vN663+Jjm/qIO7E9oa/l9zRgs=; b=xjhjujcIFBvMLC 4YeOEVTEYbh11Axsc0XvrJpc11sri5OeVa5vwJXn9jxiI0fvNVBJcOFYAnK0Wpx3yysFOPgMw7Wb0 o8N6g9v3r9gW5qleGAfeOJui3ZpVMx8u8tXUoeAj1zUQs1aHp2DEz8hg+tvqOrEUVsuYkwKuDXi1g he5Yjw3vF7Pi3Q2FJoMLTeDe1XMAX58F3pmldq/zuVfKQZZJmW3k8jXWm6ZHSGG7qdDpYfasFtIo3 wCF7jRZXtWCRjwYnZGnkPQ3K+njShQO+jraW4o7ZTGMFFzTGMDmhwYqVsG4DRO/YBkJ6LwvSAKngo ncUOqBQ9ZNcjJ3qnmykA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7ge-0000000HKbb-01li; Fri, 29 Mar 2024 08:34:08 +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 1rq6bh-0000000H8dc-1ge3 for linux-riscv@bombadil.infradead.org; Fri, 29 Mar 2024 07:24:57 +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=XqbtCYy6rKAgoCWJo/IDkaQi4Zmy7pvo/Tw1FadjoIk=; b=DHteTzr/cpo4FraJvto4HkwTni dmA12eZYwSimBivP9W/Ddk01pGJEAjoapwES0chNUg8b6D9+VVplvi7RKyQWXCr+Ksd1lLFZB1N2O CZ52ExDeFjP3DqA8jbYiT/U+7f5ezmk5U718m6E4bzLnOgta8/LgPUhq6agf1YRv35ERUJZ3vViit Xkwo4GxquvNv4lMMvyfMvsw4mvotzXUh7Qx2NJXKbpflEX9RhFyTyojY8Lpc4ov+j2EXTLqa9sZtk i9jxY9UNgishN6++aPDiluO0f/S9yu+Xa718jtZqOzDsRFqX5DBcQD7fVsHcUqFda8+Xx4PVJh4Zg s4qtGSHA==; Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bd-00000001QqK-3Jrx for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:24:55 +0000 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5cf2d73a183so1983425a12.1 for ; Fri, 29 Mar 2024 00:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697091; x=1712301891; 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=XqbtCYy6rKAgoCWJo/IDkaQi4Zmy7pvo/Tw1FadjoIk=; b=Y2cRgk3iJTomtqVF1uFgqfsQ0epoTyaftYxyUOb5GKjp0rHXxTyd5jy2Hh7nAjH4ti ENpWLUtJ92sINnNRvoMVhBNK5+VJG1XfsHkOhLb2gW29+AnBsaClllhXYYM2zA6zuCuh upXgP9d362eNPNnyUUHZKRCjTIIg6dAOICq0fQO77l4kOq6E55WcytXRUGVVYRIJ1hwi 2wMse3/QaL2CQq4eiefqOh4+sfzfKefUWevgFmk66TcEMOGjxGUMUvTK9DzyoxAggO/P iAjoZqxrJjd2MZnWWgDz9xCz47mHCfLOc4xe6AQ6MsaibMUALeRWmc8JlykwF0NbRX3J JwoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697091; x=1712301891; 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=XqbtCYy6rKAgoCWJo/IDkaQi4Zmy7pvo/Tw1FadjoIk=; b=J5a2ivh1dcgNMRfEcBCFdlBDxgLNRDr1eUVJSEXOyFpr4pH4bxf8vncwUCR/OMegbZ XNuniQ3e54+NkNRsd1P9NbIYDdNX1CK0Ljw6MQZP/1aGJUz9UY1fr7EEs+3zq9Fm/MY2 1tqn9Xi6wJ6mfwp8DtrYHHonOTA5B6r+F7C94jX777z5B1Maf82QFvJORdKot6V+OZdq oBZlaNICh7ys2OM7rnfbPOUvQaEYsk6f8g7nH33DtxMFLmTkXbO+MMMJ/fHUkUvwA+pf upqkZ+YEC+lXxwKivHaECnBswDv02AiggPzjcoxRLeVP8WzHU4zLa4jc19u1LUCGZppB +Vrg== X-Forwarded-Encrypted: i=1; AJvYcCV/rPbvflXPWMtKMpT8ErN4ZrmCHh7xO3qNC2eRVQWJrk3c5pHMkGFDOVCYo1ziNzbL/5lAnUAyuufgb0HGop3T5HACF7E+I3PIAQwku+09 X-Gm-Message-State: AOJu0YzLQ3SsE25zScrObR3471e9IiCJj2694tKS8JgszymPHsOxBkVp GhSRF+7clD1sa4gjYGmDfvvxrnKxnRu7WwCNjmEODLCioEbXwPZotGlPQWaa6Xs= X-Google-Smtp-Source: AGHT+IFpgVY+di4cvDttsjDdGENlsS7ZbuG0wU7DGKwYbCO2yCZHbkcZgR0Ijs83aSucHtPBLyzxXQ== X-Received: by 2002:a17:90a:d588:b0:2a0:3b1d:7c5 with SMTP id v8-20020a17090ad58800b002a03b1d07c5mr6633406pju.3.1711697091135; Fri, 29 Mar 2024 00:24:51 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:50 -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 v4 06/15] lib/raid6: Use CC_FLAGS_FPU for NEON CFLAGS Date: Fri, 29 Mar 2024 00:18:21 -0700 Message-ID: <20240329072441.591471-7-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_072454_057656_5F584E45 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 --- Changes in v4: - Add missed CFLAGS changes for recov_neon_inner.c (fixes arm build failures) lib/raid6/Makefile | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile index 385a94aa0b99..0e88bfe6445b 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,16 @@ 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_recov_neon_inner.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) +CFLAGS_REMOVE_recov_neon_inner.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 Fri Mar 29 07:18:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610359 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 9BDE1CD1288 for ; Fri, 29 Mar 2024 08:34:13 +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=P5EXxQKH955yOAGl5ITHokCUpXVE1vhHbLYw04DL2X0=; b=O2PjRx7yQocwww K3/t2ZXGBhKfl7QOrVAEuaxGZQ/tGq58B065GkeYYVvLEFbT7Dka51TTRrF7cedvH2Dkgky+MqwHU QNosPH7ZXobPKydXuVFY2fC7tYICAc+14AhrVVtQ8bZ+n3bqE1p7TvN/eo73IbI+Zn7Yh9sQfLqRI 6eToI3LrAuX9ahpywUiEd+HC0SJNftAG4EU3++byy8SFx+8PBduL+HbVDB5nQQMTnCgF00yyh5waw wIrOMhMgD9mx4wNg1u2QESlOx7FlYTVqxRqESUpicCtStJxrN7+Ksh3mTM3kw18hJ/L2CLU0xNMdq E426wUwZnMGnPPcbw4SQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gf-0000000HKcf-2NjQ; Fri, 29 Mar 2024 08:34:09 +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 1rq6bj-0000000H8e9-0oKY for linux-riscv@bombadil.infradead.org; Fri, 29 Mar 2024 07:24:59 +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=F18yE3QV4MW8RCzD1e25jw8k09/j20Bb+PnplrzhdA4=; b=WJe+UgjFUuiIToPVsZKBothm+7 MyqSy1d8Dcmsr4vA2fkZA4fNs/qKk6yyB+FsD9Cz+unZrmtKXwuMN0U/vsnADA7goAXVW5BHGzP0B cE8E47zW6hlBmG3XTsjLwbmhE5ugg/O8QsIXxKT7dBbWPs+pY5k+CMCh5aUJJeE56vIABDp/JHtKv SeI86YYJ6epX6bnrl/S4SSBnhqooNcL2WCZ8KcB85CpJOspIwIAzGT9o0ZJqjQ3AMwLJP2buFYZ4Z X7E2/tW9b4R8WjKy+z3KgzdMxWLDA7snKHSY8fnaVIKJ8Thwf/rpmKBVgD030Um5zSyUyH7IkdQBU Y4+19ZZQ==; Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6be-00000001QqN-19ms for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:24:57 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5d3912c9a83so1029772a12.3 for ; Fri, 29 Mar 2024 00:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697092; x=1712301892; 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=F18yE3QV4MW8RCzD1e25jw8k09/j20Bb+PnplrzhdA4=; b=Cj0KXSlw+sd4e2g0lmtQtL12wgmcoGQFIpUtognY/FeJDsuevRfGodaiqSo7H5n3VG g9vh23pixD75i+mOybqGWu0TGAYxR81w5vHkb5ZE4rtu72Rf8zoXOKQmc1EMMfcpO7WJ zu3ijwSA+gLmlvqmc/R3lbolrxm+HvDT8zdcLeAZjrxz+xFiBUA7DMdX+x50psrp+L00 mKbvns+SGQErZ4IJj/ixp3KC1w8z9VDok1PYvyKzPCEiUZlmqicMmCz8T06zTVARyPig hPoItwLHivHFSFzqgX6CBFLILoWHVFg29NOmQDuHJKjlXRwdpP08J4BV/HzNICmDc7hM LADg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697092; x=1712301892; 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=F18yE3QV4MW8RCzD1e25jw8k09/j20Bb+PnplrzhdA4=; b=V2vUoQtP3bAXrM4TxxM4pvHzAJEqUTk94SNtQUD/Yz97d4DnMkKXp/vA8SmPB6BMKs 6mQamtRSMYCoqIxRwn6/kSNOSgfneY8BhGLBOqC0wCOI54UUMoI+bS7Jh6YAkchra97l DgEzZ2lSnILoGXMLiHKYAb/9pLE+vfplD8wdhbcCDhcpbkm8hPYomLFv6SP+XuY0Fuhb 0SuvfTZezlyRrvutyvek1RKLWmoYJOXQLKE6WXGfPmYSQaFdHNAMq7TaeylyyfeJZ8ut 2dpd1vYaHUMMq7BytL+xUSHSYke0PqVP8+cNm/cqvQ0EE4koc9x2zxWvh8bXhmnBDe3q 5SsQ== X-Forwarded-Encrypted: i=1; AJvYcCXmhiiWoN6PAruWHS/felHXPYcvF3HhycDmkszA7z2+8Y4CezVgskakwzsmE8pAMs2fdUBL505duJt8c9XWR4hYQfEK73QMwZtWWz0a5eig X-Gm-Message-State: AOJu0YwJxsylggNYpnD67e8Ap/Um/eoljmAAN4wEQMntVh1TWMsphYWy Lh8KgJv3SfxmY6pCPtnz9LpJuvtwqw3aezDRJ2+m3mQRi80Tumnz16od7TnheEM= X-Google-Smtp-Source: AGHT+IFY/yzEzRZYFdEySbj/sKHZJd/DWAHR82okZCfCkYYQ9Rz+9YBmaRZXyDE1LpyvvN0Ey140hg== X-Received: by 2002:a17:90a:fe85:b0:29f:ea48:25dd with SMTP id co5-20020a17090afe8500b0029fea4825ddmr1492025pjb.33.1711697092415; Fri, 29 Mar 2024 00:24:52 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:52 -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 v4 07/15] LoongArch: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:22 -0700 Message-ID: <20240329072441.591471-8-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_072454_502337_E9061357 X-CRM114-Status: GOOD ( 12.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 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 --- (no changes since v3) 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 Fri Mar 29 07:18:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610361 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 6426CC6FD1F for ; Fri, 29 Mar 2024 08:34:16 +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=BINAtuknauSGav5dFR1jvUepxbfvD6CnNvfDYZTwDfk=; b=rV2eBGoGBjh2uB KCISPwyFqc8eMUj4hxeqv2+yIvRQGjpfQhjXhkHYPUMaPYLYUrlvGcHEdwowYHf1iZgKoX27hJPzt WtCtC0Bx+3t2roPHaexRdonEY6qVtnzS+HUs2BWYPojKIqrP7GQJBhmD/ELMfvIUAcyiqDO0mXROw 6fBhCZa6CimeO6uyvb0jWcIJ44QDjOrK7S2TkJpnEXklsIDg7WT94ez23ooIJ9blKoImB57qsmc2Z 2JN1vbTh5eh7dYM/h0rEls5f5zFejZlkb76+5ZRswDbIEzrDUT3Hh6IiI6mj7IPA+vOAs8xUQxUFH xnrikRH9tRt6JIywO0Tg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gg-0000000HKdI-34Y2; Fri, 29 Mar 2024 08:34:10 +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 1rq6bo-0000000H8hp-3bAm for linux-riscv@bombadil.infradead.org; Fri, 29 Mar 2024 07:25:05 +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=miBOSRWGIbztCOf3acmBaICqQz/+WnlSIiHBb+4Rl8M=; b=JEm/7Ho5jwi1OcMMs+Wlg9jHaI Fo1qUkC/RG3Hh303Ng0Q81qkOyG+HAOyRbjGsxdY68kMndm64R7sWgEs8NdSRGnFyvelAPXu9FsU0 s7I2i9GshRf86s/H+G0HBhXmVgh10241vLRMEvyaZyIYhhGzkvAlgJpa1zH96PNi8WB611J9+gWkH 4XZ7htv4yksiEn9dr2Ygsmv4lhPC1eLFxG11Ktjbi7rmnkXFHH7cDgBtWz0o8v1RD8mIZzwfcqUF/ q9sdhSdiKvyggg2+56bLhLJjGP3MeVIWNdY0Ait13TFL9x0IOB7ghetviOn1rFY3LkCSLTzKSW+J6 M7sPMX7Q==; Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bl-00000001QtU-2GOO for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:25:03 +0000 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6e7425a6714so1502237b3a.0 for ; Fri, 29 Mar 2024 00:25:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697099; x=1712301899; 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=miBOSRWGIbztCOf3acmBaICqQz/+WnlSIiHBb+4Rl8M=; b=IrWdzBqppExxW0jsN5DO1Lye8ORzfalZpVvRu4CDwDwDhl951IAkiCgUWDQpgCTadx Je1N1Jn24WMdxr4WOQOFWDvYKN8EWNK3Pj5DYG6ofJMuRWtsNcDrGhs+wUARMFLDtj5S y+t6HidMaOK/WQmCk8FXCIArZzmlYIwmhpc0Pd6wnxRQm7H/BdzpUi9JavjubNK4ui2N nLOIm4rUhL8/3Bbaq9bjNSc67izK1J19h+b48Tj8AY98/Mu4Csbcu6skK0oiz4jpQSh1 CjWUuIy3EXpOmqFkNSYjUop9tzjc9duw8Xu2AjhvUq2GG3kbNwMdDfAIycYxRnoycdkF Jnmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697099; x=1712301899; 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=miBOSRWGIbztCOf3acmBaICqQz/+WnlSIiHBb+4Rl8M=; b=fCL1wk8gbNVLMds3vOSI9VuvVxJW8HhC58VdSzNak4N9vrnmC/9UzYCDIXQlZwSvVW EjEBNF8M9n7sJFcLVIjwdbwWU/3eLrfCYxctDaTrmjNeoEC6M88BjaYzbNejJTjdaYW6 iucXyCnJ7vNFD24AeXaKE5qi9b9G3YA/XlCJKnhH3KGhbfXF9hrvPEIwzO4bmAhQvT1x dUqZ06BoyQu+Yfka33MmmIui0PrwzWQLcx6U8Yd7+dwaX2ohL/RYdVrfEGcfFliL51E9 vcQw4exAhHMCSTg14wa5o9Qq3RG8gT7GD8eSyaN3H87u/Qvl44G5GxnhqeH1cQPEtQ/5 ho0A== X-Forwarded-Encrypted: i=1; AJvYcCXoLWs3ct9qLulG0vByUH0VU41Ko8ccHuPnU70MTstXW2UehDuqZRsl8F1Q4+ygkoqVEXC8h581cMWrzI2j1/6P3N2T9JWAIx1dbaAqiNI8 X-Gm-Message-State: AOJu0YxC5qVYoQw9oCvLYuiIMokqNOxxz2Ddi/bySePCZmX1R41FwQkz gmUDuIbqsdoUKKgjrXDLdjdZ6CT9beF88E55O5DXt5yAFPXqR+JfFhI+gZkBv8I= X-Google-Smtp-Source: AGHT+IHGvAdAnX/0WDZVeXS0a7ZQ/motGWeac64eqKBau0xYaG382zqiN+0tE34St5zugVtRmJL1tg== X-Received: by 2002:a05:6a20:549c:b0:1a3:baad:d566 with SMTP id i28-20020a056a20549c00b001a3baadd566mr1487303pzk.40.1711697098883; Fri, 29 Mar 2024 00:24:58 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:53 -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 v4 08/15] powerpc: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:23 -0700 Message-ID: <20240329072441.591471-9-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_072501_731840_5DD39B26 X-CRM114-Status: GOOD ( 14.01 ) 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 Fri Mar 29 07:18:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610362 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 E578BCD1290 for ; Fri, 29 Mar 2024 08:34:16 +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=MGrLbYeyTsDVHUf6w9NV8qjnmiaATleIewSNQponOso=; b=1gDTMa89LlAhWc IvDurQUTJlk6F9wuBLBjCjsD2Ey9oqR7j6wCiqunngH1T9/Bjml6VddLp566B3Fc1so2UCMnmF+sg bPBbpojTmoyMOdncFxRzndz5srX8RCEJa+OFIpA/L5xoC04/2DycBu2kPe9TPBwKcn5a8nGMYmdoI a3RazGyd9x0wIVjQQ6ytDiuT0v5Y89UoEhOzXsSRs+bOSq0A33/SOKjxgqnrtiGhI/BSMFICyhM8+ UvaUUYf8i7qHZ8DFmG4Er8hNTrqgVUX4K1GizU4LzoVgBMmop7h7yH9XwVROKjmI1f1HBc9JrIimS EJsrygy1l4yJ6vshISoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gh-0000000HKe7-3qK6; Fri, 29 Mar 2024 08:34:11 +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 1rq6bq-0000000H8jX-3c1V for linux-riscv@bombadil.infradead.org; Fri, 29 Mar 2024 07:25:06 +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=dzRar7ztYXEnRyKAelp48saozJM51jVm9Dh1Zr4pH8s=; b=R/eR0jtQBoY3zYVgj5DGyHDaMX ZxPV8m1ajar3nUN5/tDvw3/sOH0wwJEWCPvZ6pkSyLfVKXt2ga99Wp050UBhi44C+gRPcXoR5StaY HWusR47UaLAYCcfK3d4iqTeXICO6vkLof6m3TaXcrqKR3E9EAB2UfsNCEdzpC0mU8HV7VTWDtOs6v RVXG+BoNuzq/F4rfvhujPwIJtEvCW+3DVN13R0POAQYzC4KqQMexc3YSoKF2YH+EcQLfHOLgMijBt vDKta9TV+UyLQfoapMQrzywHr5c2gqonE2FVuiBAeglaz1WCFv01n58I8m7vUh1Wb7sNbFvdhVIxW QtIAIyoQ==; Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bm-00000001Qtc-1ctN for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:25:05 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5d8b70b39efso1400236a12.0 for ; Fri, 29 Mar 2024 00:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697100; x=1712301900; 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=dzRar7ztYXEnRyKAelp48saozJM51jVm9Dh1Zr4pH8s=; b=bFbCCw+WQAsOyWdheB8qUqnvmFLupY5g8i50F2cYMInmi0jHOx5mqLugbYPKBNWonV tyolszfRGASjEsSHlXVRB96p+8T5CxsJ8G9N2XlT0LeUNWZLfjpYLT16oufxQ/vg/Xag +lAv0MCW4CQnWuNo8CyjDKbbNZ/xxl1u/TqqqosSRGEtj2bEw9n5/vRaL21XWHxzi4ae 4NhrIM0/6j307QvY84/c4+VgVaRjGys/sfSj0Kzyn4LIPrJol/FxXP3xd89+g2pMQlik 6xNPS/SKSwE+iFKM5mHK1JvaOxkkp/AcQcXef9k5xBEGwsY26E+ceyHwOE8IvmcClLB6 kzfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697100; x=1712301900; 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=dzRar7ztYXEnRyKAelp48saozJM51jVm9Dh1Zr4pH8s=; b=PEli7dIXMGWuTSn903Ol4CHJj5Tbre1xkavcmtVYjupbJNG3kSKW1KvGNRzG77BFxU Pqb2FCHXqUqcNu8MlANCKeCBeLZ2B45pZqRFVQux2/GJ1AzHRu/oiVH3d+LiBZdT1ndP A2WifZwDEgcF32nLI3Y1Otl4jeeSHb1Ge3JPNQP0aRvRx2iJ2vQg2R02Q5pwhH6x9Eqp g6Ljt2WLHEf8EfbKGNDNHwPbAc25Ytx4x28nGWUJruEdTUMQ7fO8498Qu/+mxugaFH+r 8bkfEQLgOS2UzO5NKfqfmi0i9gQQZQHuIsDNBlcZwBlw3fyxJ9yHrxqfyynvWlPhy2zn st/A== X-Forwarded-Encrypted: i=1; AJvYcCVTAOSW9c9GEqufSB3yiVQC9JgQFTFAb3/p41UJlC9fX0XhwH44NNLRfgKSB+zYpb7nGRmXJhPRJtjYpnjS8OVDV425Q/bqdprBrcuOsavP X-Gm-Message-State: AOJu0YwMVWuhvZmVOpsj+Ao2z+Hk5PG2bELOHPFOtkH58GmpqP2RSbsS uWwKzDhns7EPEd4INaIpjmi0eV2EsUEO1vqEirFJqW/bN2tr3mkKTl4Mf/aUMqE= X-Google-Smtp-Source: AGHT+IEs8kBZu3dBChnRywCF22OnC9/Ej+znSx9gblpEFd+wsOZOeprciOlW3fwk28PpRrFgoWrM2Q== X-Received: by 2002:a17:90a:d3c3:b0:29e:975:3500 with SMTP id d3-20020a17090ad3c300b0029e09753500mr1446912pjw.28.1711697100232; Fri, 29 Mar 2024 00:25:00 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:59 -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 v4 09/15] x86/fpu: Fix asm/fpu/types.h include guard Date: Fri, 29 Mar 2024 00:18:24 -0700 Message-ID: <20240329072441.591471-10-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_072502_556019_A6A74A35 X-CRM114-Status: GOOD ( 11.53 ) 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 The include guard should match the filename, or it will conflict with the newly-added asm/fpu.h. Signed-off-by: Samuel Holland Acked-by: Dave Hansen --- Changes in v4: - New patch for v4 arch/x86/include/asm/fpu/types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h index ace9aa3b78a3..eb17f31b06d2 100644 --- a/arch/x86/include/asm/fpu/types.h +++ b/arch/x86/include/asm/fpu/types.h @@ -2,8 +2,8 @@ /* * FPU data structures: */ -#ifndef _ASM_X86_FPU_H -#define _ASM_X86_FPU_H +#ifndef _ASM_X86_FPU_TYPES_H +#define _ASM_X86_FPU_TYPES_H #include @@ -596,4 +596,4 @@ struct fpu_state_config { /* FPU state configuration information */ extern struct fpu_state_config fpu_kernel_cfg, fpu_user_cfg; -#endif /* _ASM_X86_FPU_H */ +#endif /* _ASM_X86_FPU_TYPES_H */ From patchwork Fri Mar 29 07:18:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610252 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 84DFBC6FD1F for ; Fri, 29 Mar 2024 07:27: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=/CkELF7Q5aQN2Q2GCWNWw0vv/LbvTGNWVqrB0qnFdSU=; b=aEcYod0uBDgFO2 P1ggR5Mom6hw6GJpT5nuLNDMuE5A0j4cC5R2LVxvNzG5O+Ok5p2r+lzHYWEpRgVMIvp8kJcORSldD yHvTJ9d4fm453Cf5bqWEDNLWbkpt8Y1BbIc05smSi8x81foMpdKwvM1I5HvvvqeD73eCotnUbq9HA FuxbkB1AItwpA4gZ/T4Sqn9ArNg0FYgZoyXwVZthcNkWAbsaAsOjMWRAKTFo2zgzIQ96XzaxIDpwZ uwXyqSc+El8iHivE2jR/whPpzPJICHMR9ZXAln2gEIbNhsPV8sIecsOg9sN8D92uUZUc0t6462NgA luDE5SulG0CWr7Z8waPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6dl-0000000HA3b-1mbH; Fri, 29 Mar 2024 07:27:05 +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 1rq6bu-0000000H8mi-00kW for linux-riscv@bombadil.infradead.org; Fri, 29 Mar 2024 07:25:10 +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=1ZUya0v8Oh5iLzX7Kw5hO2ocqVWj9tNi/iu8yR8eYow=; b=FLdY2Ck/0DadFmItQP0yXtBbJd LWwObX5ez9PBlY/odgrOKUwdenDksFdBDJ33GggOc16EvRFrIwBSppmSXZstTsVcoSbOqe7D+2xh4 x9AjU8ggYSzqnfWtH4Tvo+lKz+L5mlvd4ezp6gEpZPD732vzzE7dBKCatCNQFtHLOUIswB8suZjSk SbQVahrmdhOFfd6+LNEgFUOlcMdOl00egHZAZ6KkerAHgCyrBwsObYpxSC7pwyP1nQVlGHN+IchiT 1FMT8w/or4ikyb2owpD8zuHW45PFS9xLWCbWR7Di7WSPq7mdwo3de0XR/lxiH0aNTAJo/s/uMKgSU dZwLDA/Q==; Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bn-00000001Qur-3j3K for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:25:06 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2a209b8af12so915240a91.3 for ; Fri, 29 Mar 2024 00:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697101; x=1712301901; 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=1ZUya0v8Oh5iLzX7Kw5hO2ocqVWj9tNi/iu8yR8eYow=; b=UdHh3OsTB8lgvqDTPwH1434wlD/BI9ambuJZoE8cuq7fb2/dLX1cBf1gsgx+Y7Qu6E OnZKnlgCWJ9NhhQh4tEXKAWjEm+47pdRTzQzbKOtgzj2tCrrSHSpHUfEPe1vCtDkhcOR cZe1CWgAeNDVH7I609v6XUfK0xYeB7ackZEemDQECPKnR/O9uQtAL2nvl/VAguzha3SD BDatEosxnchtMvUHgS63s6bOEZUU2xNUb9JO+PCSjGUICV4KTl8fsOi+FwJAkINqvkiO +dAEnCXfpMXh2GirV5bcQDHD+jbK5h6P4CH2oyIXpzvkoTYh0n6n9inBQq5fqKh8cCnu mZgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697101; x=1712301901; 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=1ZUya0v8Oh5iLzX7Kw5hO2ocqVWj9tNi/iu8yR8eYow=; b=jhZw+cWPgNZ1L8Th7mjHO5hdy9AV3JdE6Fz2uCOnQI1eBAJj+PaNh2LQfmKwrb0xdP Pw8cOWfIt9ytVyAbiNPuVcipijT4IO0W2vwSMoOfTdbvyoESkazZXEepBM11ra3LcCtx aGU2oDo4GgaNzJUfIjVsDZHkCj0I/1M9//HA6MRVudZP5ZAFcmrqvfnU6rR7MsIbJUYP Ihdg5Q+tdVUxw/k6MynGRbvxg8f/KYdzKtNPttXoCzKkvscuma0BpD9Ct5W09qtu0f7m vP67/eFrNf1FKrme0u+GDoynZhQrSaXTMA0O3Xxk3258oGaQUzewAGuf0wqYEeaqk8V9 JjVw== X-Forwarded-Encrypted: i=1; AJvYcCUC+Vl6qm+g3XKbHWI13otFyIGRzMcREdV1bVG12DdJkIrVVUsMYR+QHbv9IZlsX1wfcIiU/w0uVEMvuzbE6oxzZnED3qxjMikGkPu1/k6c X-Gm-Message-State: AOJu0YyV+WnBFf4QZKbjpF1F2jM/fdIBp867znhmmJ6abpw4Ng2Y2+sX uxQhwnSP+fa32huaJzwXE7UqaC9peAAmKkg3pR+/RVNPzDbTZv1qVPHBSJ0L+/+C3qpvODOB3NO L X-Google-Smtp-Source: AGHT+IERKMtTUUrMNrNdpmOZyYX6MKtFB7fSH53v9LodH/8MB2comF4l1LxXs3fRZJNBleQgeI68Nw== X-Received: by 2002:a17:90a:b008:b0:2a0:5339:7751 with SMTP id x8-20020a17090ab00800b002a053397751mr1529473pjq.37.1711697101571; Fri, 29 Mar 2024 00:25:01 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.25.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25: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 , Borislav Petkov , Dave Hansen , Ingo Molnar , Thomas Gleixner Subject: [PATCH v4 10/15] x86: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:25 -0700 Message-ID: <20240329072441.591471-11-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_072504_137826_C9FEDE9F X-CRM114-Status: GOOD ( 15.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 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 Fri Mar 29 07:18:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610253 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 4199CCD128D for ; Fri, 29 Mar 2024 07:27:11 +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=yQV3WvmoLQG9ojSOU7c/BiR28mavtKxjBrW/wb97ne0=; b=jKqjxxWVHGUTCa ijbyzwTRLtk88BPAow+DxtmQ7gVL0IC0o4ovKeJkgqLY3jhkCWt6ZyxIowq/JT/Y5SITBmaMW3unH t1BVyi35CMRmbDUuW7SL1bnWa6dQS1vkyHhZ20vr48JdIuCSfQCh7qqTGMYPQRsp2/yFE7sMsq/qg v6k2z4frXWwf9m5GfTi5ZXHjftM6HVRVFi9QZfnd2+xkujUFjMlPY2djEWSYVuuKccst+4vdXPLVH Lgt5oRG7xqvWqRwNeN8Shjb7TgN9xCtEhSA/Mk/uxHt7hyfmI5J/756osyjuUo+2pE0daLUmoUTip 4HJRrJAsonq7cBTHip0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6dn-0000000HA4e-2IbT; Fri, 29 Mar 2024 07:27:07 +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 1rq6bu-0000000H8mk-0TEL for linux-riscv@bombadil.infradead.org; Fri, 29 Mar 2024 07:25:10 +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=Z4EVp4FPE+/jeIRBNmVRsUyItk8Ntjq2i9UEb5o+3e0=; b=JunElJ/UZGZNzy+zxkUNEY+fMn VtUdXf7Z2PJUSbr/wl9pBly6UKabpJ9RL3THhmJ/knYBQhy9dlzokAOMg64j15jGZJNnkCMSvkWrS MbR08Bzv6eWKM+Sp+VCOQiuDnCwQRCnxpe6pOSUgP8FuBx4CxKzoaSoSVpH9f9a3WwwgfLY9rNzCH nlFhMCCuvMlhZFaWAnViOjOMnDuAEBBoNHxTb9c2ch/lVQR5JsZLqb2jEx6MM+dFF+vuAt2OJCV5U R1GGbPSvGt5OR6mEArFLjbhNR2bbHs76tSFS4HbAqyqe3v/niO5HHsTmFtrQxb+wGYl0DeRrBvEmv JxKJAIeQ==; Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bo-00000001Quu-34zZ for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:25:07 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-29c75e348afso1379356a91.2 for ; Fri, 29 Mar 2024 00:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697103; x=1712301903; 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=Z4EVp4FPE+/jeIRBNmVRsUyItk8Ntjq2i9UEb5o+3e0=; b=RK/qrRTgX+LiiZm89uNqUuFP+s9tqeoCWpShL1fCDsWDz45ZGspke2ZtC6D/GiG5FS NcyYW/e5Bvfec8RWdD6LECEn43BCleuB3JhUg/8ZajV28IwGljZvQgCTGVNBYER1wf7l G5RDjvm9oSWPnfr0vHjVz8bbrygZpI3oH6EbIviJxg1iCOpb+Pyhb2Yh8KLkFx/AgsNx 57tUf5FP7kuwtkes3WWRVErJQrfWV5313eMdsQqkX5P5go2vRPydVVg1LbRNbnG6OEam AWMr4+G9OHpoEIiTElzqBHrcmnRmsLaA267MRFT0vZpAqLoXb+dJzXSvEcoX1WiEyT8/ mMcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697103; x=1712301903; 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=Z4EVp4FPE+/jeIRBNmVRsUyItk8Ntjq2i9UEb5o+3e0=; b=gozgcqOigTXVWhGkGJRMnGDVgLIV2SlyT56s0ZoUSXpAGSmOwrX9LkbGC9JWD2DkxS EiLMdAuKBwe1ETldzc1SiL9/tOGTnbDWFOj5Q6s/3XCCEGmB/pWA78DLCxNLRukh4MBW FbVNg/ziSJehri/qlR+kmxplqtgUapuej+o6sKJbs5FDhSwK/nKW23oZZ0XmHj8hGOJE ztNOYpG/kUMs+XepKjGZAyCVmkHbaR6jQwsmEe2JxGtdmqUvSV7Ui7uOomyWZI/5OqaV HdWQ9s5Ky3EFWzp2leDFsDFSnJphmyIwya1uxemmpJbjbvYvHmTtLcBLlMxo5PAzf57k 1HFw== X-Forwarded-Encrypted: i=1; AJvYcCW+lhAsgw63lpgk8fUGqD78wkR2Upa3y2w4sGpkPSP9SDG5PcX9GKYofZzi2UcGFCP053oO7Cf43mwT8EFf6e7DpWhRE+0fMWhX6xPIeeLC X-Gm-Message-State: AOJu0YyPYKS+tjPH7vof9Kq6e2wKe0PPzuvP597MVGAo/ReT3wmVbu86 h+neSDl1LxDXnLdqTwndrNHVOXzGAM6+UNnynlmbabNCnBWGZBTxB0yRNDGmx7k= X-Google-Smtp-Source: AGHT+IHObpmsfqDnVzwffSCR0G9zA2Nzm55W89HV7TW/i69TFVB/o13/9rds5tWd/Fn8feEYN1IDow== X-Received: by 2002:a17:90a:f2ce:b0:29f:cbd8:ea11 with SMTP id gt14-20020a17090af2ce00b0029fcbd8ea11mr1691675pjb.15.1711697102774; Fri, 29 Mar 2024 00:25:02 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25: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 , Palmer Dabbelt Subject: [PATCH v4 11/15] riscv: Add support for kernel-mode FPU Date: Fri, 29 Mar 2024 00:18:26 -0700 Message-ID: <20240329072441.591471-12-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_072505_358674_74CE8120 X-CRM114-Status: GOOD ( 16.16 ) 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 --- (no changes since v3) Changes in v3: - Limit riscv 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 Fri Mar 29 07:18:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610364 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 5840CC6FD1F for ; Fri, 29 Mar 2024 08:34:25 +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=imJVALcJDJFleIqG1DXLQShwa/nL19G5d2h9oi6I7eg=; b=u2G5nVMK7uzjlO VcIAjybEKdSAeXFZqGUSzBYPhzyfbuQGkLUMIkY298tnZmIfa7dqzIcDYDPTiGZ6B0BlxC0BmbsNV Cr9OM7cE4n6Ika4PApG4fmL+VQtIMVR24cJw1m4f+4jjYSK8uvso6CJkrhXCIioidnPqUpBqveVKS CTd4eWDqxRy8kt/SbOGM/KhZf203mhqzxJm//Zv534O1nSXSieKv9ENQrwIUHUNl9Y/mPio5UVBS/ nxt/Xkb6TYcXosAIDggdGk9YhWeMLZ/QljpLhpYpUKgqtb0xj+Gs0qT4zXT8idXjEScRzSmEkPZSM uXtqjuyTBf74BLCrzDiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7go-0000000HKjj-3qbi; Fri, 29 Mar 2024 08:34:18 +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 1rq6bv-0000000H8ne-3GNz for linux-riscv@bombadil.infradead.org; Fri, 29 Mar 2024 07:25:11 +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=bxmfK/dV9iwtkx63gHffuqsF2FQECTKGikC6K6RCS1A=; b=IZRHky5EJafHJEWTI5O4kE9d88 gMfAJDRn6TLHvrUcwTEgG3Wdy6IKSGIEQVIexv1/FoZQim9hJalfJ2k8F5Ldz1D1zDuUG8J+iPNjS KYrPeAKgI7l7Cnb56EIUbiT+tGhX8GVW6XaKt+N+WPoTO0D4ka9qaMezMaxRYu7CerWS+RoqZMbHh 3DywSkZASdRctixlGV6n5Z+Bq1GdahCxDd7HCxDe9uiYh6Nf5KblcepIf07Mw77q3B4ozniYFvM++ XpJETxhpIxQ+c8iAQhm3fqLSJey8+B2b+Oj7xf0GVoYRvqtf0nXJsVeJiEuhIUxnDmdtmUMPnMESQ uxbU4Tyg==; Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bq-00000001Qvk-0dBU for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:25:10 +0000 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2a215582617so160327a91.0 for ; Fri, 29 Mar 2024 00:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697104; x=1712301904; 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=bxmfK/dV9iwtkx63gHffuqsF2FQECTKGikC6K6RCS1A=; b=RUqs+OavvAIN2aHxItEDedHFDbF/9Qc/i0JJ9ZzaCsisjYXvo8RVsCq++Be9MCMAec ILTS21bNYXRsSoncewPm8jj4WfmY0Gtq58ut5Fvy9cXs9fdsmsdqlWCjmlmi6Wi/Nn2R E4fzGAEfZJdyWqR3yMgrnOe5/n3NyPEi3wx2cRlThdCe5hhZ7RihVcYNg5d/ncyKCu+m av99DC0GAfJfSsXHQ8QgRxwHZCraT2xoFseJ8L54ksTeKdPFoRlhZyHjzThYjR7tdpiz dwRqbbiQRE6cXK6ewmuNSWeD3qafn6fVI840oJaTrTpa8dsEtbA20WDWoYnNhGBrhiBG /Asg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697104; x=1712301904; 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=bxmfK/dV9iwtkx63gHffuqsF2FQECTKGikC6K6RCS1A=; b=V1XdlUqO2FmVuuG+4CHgZD9ueZZeVvAsDYRQ1JGRRxloxnjzMLaJske00GAaV05k1x fHqSrPn2ANP1Sv9HI2ropNI2GK1SymCYNsVnVyilpaquGJIKNVkazwivSXnZ4BSfUdP9 J/42I/FjCaTWY2Gi/6i0w+Ctslv8l+EXsVcXeQMJyDJU5O2s8yzfc7Mri9ya/Evi/Cir NS8FoZqgDgt8o16d2okKWzJDg5KWMQaoqXXJhBcKmg3sS29ep7BDFXQXHynul34DGEXt kI8awEA0y4lXkl+a1DGZi26L+vx92HvvOfZs/t0XOFcAZLmq4wSuKbTHIP6cQ04opBCV 6bdQ== X-Forwarded-Encrypted: i=1; AJvYcCVDoFeQMW9+nfdzJZ4n9SPpogECnDxZlqWRZLSJOsvfMGeOmq42ze9XDtwQwG+wXkmsFeGof77IliQ6T4BL/kAhfYDfMr5L2SE94eUmqT7D X-Gm-Message-State: AOJu0YwSE8Ak37Gbb37S/ogaO86jK23ALj76kGI72H05+d8hhb6uBSvM F4YFBl+V2naQf1jf2kaZHQk95PU+/fD+B0WL2HHbe9a2jwATipchCOb1elKTpX8= X-Google-Smtp-Source: AGHT+IHpeVerdLnkB6vVIrwuNmVNMPefUfPXpMCtetpMqAC6/YKtxmEHNVWfJReDkAcL5lZnKsQNnw== X-Received: by 2002:a17:90a:ff15:b0:2a0:4a22:3740 with SMTP id ce21-20020a17090aff1500b002a04a223740mr1338180pjb.49.1711697104041; Fri, 29 Mar 2024 00:25:04 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.25.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25: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, Michael Ellerman , Alex Deucher , Samuel Holland Subject: [PATCH v4 12/15] drm/amd/display: Only use hard-float, not altivec on powerpc Date: Fri, 29 Mar 2024 00:18:27 -0700 Message-ID: <20240329072441.591471-13-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_072508_779026_E1B57570 X-CRM114-Status: GOOD ( 12.55 ) 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 Acked-by: Harry Wentland --- (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 Fri Mar 29 07:18:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610363 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 3647FC6FD1F for ; Fri, 29 Mar 2024 08:34:20 +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=0IVnpHQBQhy72h0vPCDPKgEL0w+TvLoSl8AXtPjKPpE=; b=ZNqgmTIuVU3vUK CxB0N+XjSzkHfLB7dTjbIm4LUvUs+UpuIoIGydfFU/A2Sr2GNG0XMXY3mACnEPR2p8BbFX452D6Pk ZcuFoG5lTx8trSn9t7Gkcz+EAgoHDKPISfPCwivEPSynDU4KgAoQZ9zrBQl/hg6hwzwlI0zufCI2l bAMWKlc2yIJ0Zblrq/QFEigUoTCd3QYp2ECrGgMG7K34mwD+2nMiXUJnm05O6NiwLk8zmY1URY910 /ZTTi3K6EX69G82jNV4TuQSeiOkw+pB0XOEUDkt7hEOynkmM9RKv/+dX8eVPVGr3202bnuYZ2TwRR nLGdbnNw4p+WWcLEL10Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gk-0000000HKgK-2xVq; Fri, 29 Mar 2024 08:34:14 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bs-0000000H8j7-2g1E for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:25:10 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2a21330d093so347560a91.2 for ; Fri, 29 Mar 2024 00:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697105; x=1712301905; 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=mTLgc+w86CIzWS7wXUfx6m7PM9/cP8vcHn3CMtfjbTw=; b=BJxRND2OZ/EzspShNtPye2avtBc3EoRg8QYY2WkYW1N4AYf8RsYajCGGIVr4uE79a6 /Axd8SRFU+OePj3+HEIyr1LyyXlA6HH2K/FkJzwEFjaCgwZnRYLN1XvGhHOfY9/uYi/A 6+MT/v4z5lUrByDAcbcCC16x2ZRGOXSR61MCAuSaSSdjyWUS/4VXHgpsw+2UFb+ITU+p azRir1Ox/ppSDXyvs5LHYnt1VGOhPpE5y8P0/yDog29ExNJL1duAkhUuA+LDB47A8PiA 4JpJ/bpPHulDjFxPuMm4y+ra1XMUUOrfmAROmL6QAkfnOKvovdl+kciSKtE0tpzfWzKK fjmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697105; x=1712301905; 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=mTLgc+w86CIzWS7wXUfx6m7PM9/cP8vcHn3CMtfjbTw=; b=A2vylQVPDDs3+7TuEdD6NKAlk2HdNlk/WGUuEbWBGI7p4oqYQVuYkch6dZPtrWPLU7 /TWs0nrXw8z7Dv8fwtMNl3ocCcA+MWkl2m8DO8w+mthwa/MmAt/IDWTsZvx4smRNIKAO rukM0JEHgL+fKIk41PeauGG4qccGbQHg6crVfGb7PdM2TDH4BEpxe17PNk5f4kYB90bl BPfqcQBUB2parFFQol2ufZUidDZJymgvbU0RCq3hyROO3wCBxIWJ/HYyqFuSL/Ocm8Su 1cfVKBvbpbPwalmQbe+fr0x8jptVdIyO1m3Vbnub7hhrP5aoi0Vr8K+S6xXgOOkokpaN Fy3Q== X-Forwarded-Encrypted: i=1; AJvYcCXsm3ZEm7hHq1G5vAdLMgNgmYxrlLJ2Bzoz7n5LqoIz4MQk7JHjXczkmGk6k0QBzBsaY0LnfCemPA2/yZPCKIH/GnZC4BGI94YtyLMsw74H X-Gm-Message-State: AOJu0Yw6NX/8VOrDG21An+gnprFbQi7gUlTzacoakp4LFFGTWyZPnOPJ u52CZss5MaRz7oCm3bhmUSU+AVeOjDgCAe2HXADBOk4hifcUAJhVN7W6HBu4VFA= X-Google-Smtp-Source: AGHT+IFao8s2x1qXqbSOjOiMcaW8BXkO3qbDPzR4wBp4ZGBo4Mov4EtcdN3TNOFfEQHizvd+vN9IZw== X-Received: by 2002:a17:90a:be04:b0:2a2:1415:723d with SMTP id a4-20020a17090abe0400b002a21415723dmr1167790pjs.42.1711697105239; Fri, 29 Mar 2024 00:25:05 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25:04 -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 v4 13/15] drm/amd/display: Use ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:28 -0700 Message-ID: <20240329072441.591471-14-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002508_752249_3626FC84 X-CRM114-Status: GOOD ( 14.24 ) 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 Acked-by: Harry Wentland --- (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 Fri Mar 29 07:18:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 92C71CD1288 for ; Fri, 29 Mar 2024 07:27:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lswGEibikxrNB3zxR4L//JxUhypvxzEUiyaF1doQjuA=; b=exHqf2jGQW0Awc TB00KQ4yN/mF4cMofx8fovDHC8AfAtTcHIYqCI+D3DDPIltalJ4BIcXY+JEt15caTGQMlDM7a+ZPs VV+eCjg0etoyB5/d1pcSnPJPrPZhyW61RWtg86j0WCOy1yDZvPr0WJ4LNTB+WEgDkH5r6vYJb2Esx h1m+z9NHh9jiA4r++mz+dhG38QPbpzsfE+zE0WW20Ixl7JOHpMmjFHmCTq+HAYshqc09V7CU7Pmtn YIkReVWkAgHEb6PduTRMxAdCqBvOSFGc+eV4dNlp7pfGx2+QW0D7hJCMj2TRD93+xC36AmbvfO8rs vMXW4YevkJYrcKUhhMNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6di-0000000HA1b-1nTJ; Fri, 29 Mar 2024 07:27:02 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bs-0000000H8kD-231g for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:25:10 +0000 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5d8b70b39efso1400274a12.0 for ; Fri, 29 Mar 2024 00:25:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697106; x=1712301906; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=NVMQ6Sri7O55r+h4zmsIlvECjSh9BcLjrKKnd4MDecZZRZJ8i0Zl5SCVzQFlB61dld OpZDFyQ1wCocePmiPaibwG7WmPn1tmrDzTtRP63eeqkF8A+fytPWHYXDv2qH6i8rWTn0 F87KB2aOIDU4jKitqrhYnzeks7i2pY4vX+ZbI6wfeG30v0TDvsivLA9AbQ5dH5iB6mgK MgDI4N7gwWhZg1jvZ/t46PqPjijyEKTApe5PlFqJgsqh3GJ/J64k16sHdHE44eRtgqf4 K2ziwSCCOWx/E0b3FjgvBn7r/pu3RR87X2V+ijT7mZ6d8LGTQSVZQUpIm7VrXb9ksQm7 hmBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697106; x=1712301906; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=TkAvAC8A2UPSJASbRe+bimhXWc489GDqMMjwUBusCjHpbQH1LelqWviGdYVzakO9Wo fdcNeORreiiA7zuI11ufa8fJ6W0K5ojxS4Y8vCZVmkqsXuD9U0ojGYTC8LjW0kbUBsoV BYOPRaR+W9S/5WlpOl+c3UroUsW1LidDaBFBKE1OoJqa6aKBjTQLPZwrmn0ETFw/49qf 7kfbl2YX2vVVJiocycxyuRlMZIP/Y0kpRHg97nbR046WN+HppthuDmtKLBlxzMinnJeF QLLBleFQiNFsrvieVwP00YENqjl0HQs1SdkBdQb5MMB1NZJ4vLtHxqgCxEgiYxD0vgei yViA== X-Forwarded-Encrypted: i=1; AJvYcCVEQLEhDBjmVrKjSms/q16ln+o6SDM+9BL1RrKOdndpILAenRs5cebLSkTTJK2/TF8ypQG1k5CGpnzW2hEC62bEFnkHgvzKbLv9WrXKnVlO X-Gm-Message-State: AOJu0YzKuO5zthTSJQ/ojigOi4fFC2k918afAUt1wPzz62QQ1rkpH2/4 sqdIsm+rqXdGJkY9LHtMawOcWEyRXGGHe0Okt/C5BqCF8OpIWRAkb538R39o1Do= X-Google-Smtp-Source: AGHT+IEgFbP2oHNJWaGrzpoC9/WKXB2wk7z5kOFJSRoINaDHcY2EGHO1B7+JnkXlN7mfRYkSUpJEAg== X-Received: by 2002:a17:90a:3ee6:b0:2a0:3a16:7489 with SMTP id k93-20020a17090a3ee600b002a03a167489mr1460482pjc.44.1711697106489; Fri, 29 Mar 2024 00:25:06 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25:06 -0700 (PDT) From: Samuel Holland To: Andrew Morton , linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Christoph Hellwig , loongarch@lists.linux.dev, amd-gfx@lists.freedesktop.org, Samuel Holland Subject: [PATCH v4 14/15] selftests/fpu: Move FP code to a separate translation unit Date: Fri, 29 Mar 2024 00:18:29 -0700 Message-ID: <20240329072441.591471-15-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002508_589725_27612BAF X-CRM114-Status: GOOD ( 18.97 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Fri Mar 29 07:18:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13610365 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 513CCCD1288 for ; Fri, 29 Mar 2024 08:34:30 +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=pNl/KlbSdJZsbBq590BoCDQ0VwRqeTXyh5FtmD+ZwBk=; b=J/90eFJ4ZtPe95 uChQ/mShzG5GFvKGPC93QaLnvSOal+/q4hWwRbti3wg3zdbPGRRtF9Q2D8V3+pMLvd6ZNBw9moj4t rOJWcyFduRcM3oW2nNuItohi+CJucpa8xMFb0eRtjSdlZua+EnKNa0YswxU8Tii32kqwmOVEnIYID BKLgVsd2TA4qeMEw5NRCBdWAHpZV6lFoGadXUPVmEtnE5WEdDJfVBYDbaOaNwbrL5gMWq0vJfDadK h4mKKMTenRQGKxLzgLJQW90Y2CPoxy6YLWZqRbe0O+SV+RhXLCgQ/jj3uGyjpzWnSGwjpGs35RMrq kU39ixPcllsNt5j8IOkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gt-0000000HKmt-2Elx; Fri, 29 Mar 2024 08:34:23 +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 1rq6c1-0000000H8rZ-3SRQ for linux-riscv@bombadil.infradead.org; Fri, 29 Mar 2024 07:25: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=wd7UwvCa9oMHOiIEhQpk6/wRs60SiO2oLPgpnvXy/o4=; b=ZUH26nmEJTy5+EBj3hfulXlsht Z9t/QFYovH1LtmxVHm/z07YMnTmsbSWcuAYp+ogGhzt4RbfQ2eBgEA7J3wmaMZPCpO8mbSU6IIXB4 +tw3JyQXsPJ6QMJ2YxrjRwcxpH1rh70RiAzMX6tPm6Hy8dShiXQ9p829UfTTuAZxqzTBKeE5pRVO6 N9y/drcevrl2EBqivwKRmsN/YjCwbl9hu0THSvO28/A/aCJTnqDJtfUuu5UY1B/+18VH+KnALKthF 5BSm2kCg4loFBqWa75dENp7g/r4dtmU2Ff7DGQeah15E6R/0G2e8U7MUR0wBkhcmq4A6s10xAUcwv t5ijV/1Q==; Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bx-00000008HGW-2pYn for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:25:16 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2a0782f0da5so2028219a91.0 for ; Fri, 29 Mar 2024 00:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697108; x=1712301908; 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=wd7UwvCa9oMHOiIEhQpk6/wRs60SiO2oLPgpnvXy/o4=; b=HSEoPipNiMwVjGHb7t/2whWCkVmKFf7S32P71S7NTvEUqD7HL/IQs4vWzH939IS52R v3mQJYToSzTXfQRAGx7pTKD31s3TsFoVmspvF7yzY+cHz1fiViBacwWKKMEwpkHPXiei qO28B/8cajgyNedKEd+e+43GvJ3TZjIrLP76ubJkPcvCVOnAZ1qX+bBPxlYXJfdUsHrk KDfFNCYnXc3zzyguYZf3reSRQmYZ1RRlJhklR5h96DF4y9sceVNXk1cLA7hHHq5OBHAy aCmSmBYQPUR65VGPHFMALtg8ycucpLD6HuuOOFCZuuJtmPLX7fdhLCrT3WSxUmAkaCeV /5+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697108; x=1712301908; 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=wd7UwvCa9oMHOiIEhQpk6/wRs60SiO2oLPgpnvXy/o4=; b=PjTr2fwA7selLnaBXd6uHKZEufHmSqJa9Tes0FnuQgGZuFUG0yRSkO59A+QRGzOAyM Vk5ZSeerkNP+RQ/9zHt2Zem83Pr4/nJzkkmQv5AA0K4Q0wl40AAQhko5G3zbrrri5eJT ymxV+IVvN8DvJD99AgooMdemUhKvHit4ID0H5283S1tUeon0ybk0tP/Hqn2JK2lkr6fL MLgajdyuU8GfEodlRWmwSrf3rSiiA7RU+Su+F6v/g43p22L0remc0xf8UvRVz44k3HYu W6/1dsCjaPGgeJs0IQDR+PySNc+R+w1cve4is+AU7SLsJrf69z3RWaHZ4gftwUQYYQ0t 4cDg== X-Forwarded-Encrypted: i=1; AJvYcCXqB/T01hzyZxG6geLLdvNuLWBZ3WVfY57zKYQPS63YMQHU4w/WNYr8z05BrRUN6srV3BNO4hqIdoyD8AkYTCTmt3l6obx4MPOUJGzfzjeR X-Gm-Message-State: AOJu0Yxqrtjiq3sSIPO6QXiCFd1xJzVivNWvH47NlHsvFfmQjheELwr8 B0H4a6Oi+kXe7+NE3PVOk3Lx8tEEBMPXppcVnPLsKIt4qj9j2nuAeLm8NfjYeUM= X-Google-Smtp-Source: AGHT+IHxypVhChIzRiQ/e47hMPrNYQnLhNujXyM1QCssN6f6ZMhSHIBGzyaKpY86BExy9FwELnwgHw== X-Received: by 2002:a17:90b:1c06:b0:29d:f52c:5d40 with SMTP id oc6-20020a17090b1c0600b0029df52c5d40mr2496570pjb.15.1711697107768; Fri, 29 Mar 2024 00:25:07 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.25.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25: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 Subject: [PATCH v4 15/15] selftests/fpu: Allow building on other architectures Date: Fri, 29 Mar 2024 00:18:30 -0700 Message-ID: <20240329072441.591471-16-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_072513_882474_D9FEA298 X-CRM114-Status: GOOD ( 15.77 ) 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;