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: 13610236 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 8D95ACD1288 for ; Fri, 29 Mar 2024 07:25: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=PtYrbAUwJ0Yx5hSL9nhztOlrrMa97yHSAuuJzxEMjws=; b=UFNU3vQZK96wRB 469uoZs+sJWwiIC7X1A1sXgXgroPM5cAHHpgU1JBMtcfYGnIvan2FsXl5rFBrZHcC1uRRAqRICHef 8qyAfxLny2CNvAdVEebSimnX0CCWrAe3p1zuGGaXLzyHb+57L7YmQ5++wkIIDsyNIKbCmQBDwm+4p CpWVrsF6BQYqev6TqYSGYYb/GojqADTAHUsfa3eqJbRJeTeVnx7GFPgx/z0wbG1Lyw6aHR7TPBlN7 FVT5xtqZ3sBV5qiFlS4igCJclpj4gphEE6Hzo+528G3MvWY0Q7ZPf+rNlnGnRJWq9k/3HlqH1FvKe NAYAaLCbu2mdG51kqRqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bm-0000000H8gN-0O4r; Fri, 29 Mar 2024 07:25:02 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bW-0000000H8WQ-1Mc2 for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:24:49 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2a21330d093so347424a91.2 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=qp5xZiMdokAk7NwyvaoInAgek9Xt6v1Ia9gWGRX3fmQBc46891nfffKBoONGYdIz3U pByRuemtWO8m6ZD6DLhZJMUX9p12M0ISqoBlaZPLdA1XHxWh8A+YcULZk1VywADBvNa3 Rc1KQm8DwgxHpqO/TAfftq7THseCdMJsBGZZINULblnNvEbZzjYeKPk+NY44ERRZGrs+ zsHAm7vN6oRcD+4qGMBZbttN9VoHzkBMvoOIgIL5sZHmk8JRAWL/5Vg3pGj8fgiDH8aL Mr3uOFJCLzwy+Gr4fjINqng5iRd8j1ZnZIUpmVqcMaHWmSEPuFJvAwcgzFk6hzEkeAHX H6sQ== X-Forwarded-Encrypted: i=1; AJvYcCVIdVVkqLl4K1wcLFm3jDpvt2henoz5u5FdE2TW/HWjmWG3CbM7xCUYlnoa1ORnrwIW97rPXJwnJD95fpDN2ZvWfsmgGTReESZCsr6wsQGfbxm3EZk= X-Gm-Message-State: AOJu0Ywpg6l0FxWuhLM3M7VhEm6+v6RRwQVpnXg6FhIqVBoDxPGGOV5q lH1Sr+FEx6LaLCUI2D0tSbvwnxqVl8p1MAAc8M2Hx0ToPFBgPug1EuJv5ckwBCg= 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_462578_E3ECAE86 X-CRM114-Status: GOOD ( 30.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Several architectures provide an API to enable the FPU and run floating-point SIMD code in kernel space. However, the function names, header locations, and semantics are inconsistent across architectures, and FPU support may be gated behind other Kconfig options. Provide a standard way for architectures to declare that kernel space FPU support is available. Architectures selecting this option must implement what is currently the most common API (kernel_fpu_begin() and kernel_fpu_end(), plus a new function kernel_fpu_available()) and provide the appropriate CFLAGS for compiling floating-point C code. Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Add documentation explaining the built-time and runtime APIs - Add a linux/fpu.h header for generic isolation enforcement Documentation/core-api/floating-point.rst | 78 +++++++++++++++++++++++ Documentation/core-api/index.rst | 1 + Makefile | 5 ++ arch/Kconfig | 6 ++ include/linux/fpu.h | 12 ++++ 5 files changed, 102 insertions(+) create mode 100644 Documentation/core-api/floating-point.rst create mode 100644 include/linux/fpu.h diff --git a/Documentation/core-api/floating-point.rst b/Documentation/core-api/floating-point.rst new file mode 100644 index 000000000000..a8d0d4b05052 --- /dev/null +++ b/Documentation/core-api/floating-point.rst @@ -0,0 +1,78 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Floating-point API +================== + +Kernel code is normally prohibited from using floating-point (FP) registers or +instructions, including the C float and double data types. This rule reduces +system call overhead, because the kernel does not need to save and restore the +userspace floating-point register state. + +However, occasionally drivers or library functions may need to include FP code. +This is supported by isolating the functions containing FP code to a separate +translation unit (a separate source file), and saving/restoring the FP register +state around calls to those functions. This creates "critical sections" of +floating-point usage. + +The reason for this isolation is to prevent the compiler from generating code +touching the FP registers outside these critical sections. Compilers sometimes +use FP registers to optimize inlined ``memcpy`` or variable assignment, as +floating-point registers may be wider than general-purpose registers. + +Usability of floating-point code within the kernel is architecture-specific. +Additionally, because a single kernel may be configured to support platforms +both with and without a floating-point unit, FPU availability must be checked +both at build time and at run time. + +Several architectures implement the generic kernel floating-point API from +``linux/fpu.h``, as described below. Some other architectures implement their +own unique APIs, which are documented separately. + +Build-time API +-------------- + +Floating-point code may be built if the option ``ARCH_HAS_KERNEL_FPU_SUPPORT`` +is enabled. For C code, such code must be placed in a separate file, and that +file must have its compilation flags adjusted using the following pattern:: + + CFLAGS_foo.o += $(CC_FLAGS_FPU) + CFLAGS_REMOVE_foo.o += $(CC_FLAGS_NO_FPU) + +Architectures are expected to define one or both of these variables in their +top-level Makefile as needed. For example:: + + CC_FLAGS_FPU := -mhard-float + +or:: + + CC_FLAGS_NO_FPU := -msoft-float + +Normal kernel code is assumed to use the equivalent of ``CC_FLAGS_NO_FPU``. + +Runtime API +----------- + +The runtime API is provided in ``linux/fpu.h``. This header cannot be included +from files implementing FP code (those with their compilation flags adjusted as +above). Instead, it must be included when defining the FP critical sections. + +.. c:function:: bool kernel_fpu_available( void ) + + This function reports if floating-point code can be used on this CPU or + platform. The value returned by this function is not expected to change + at runtime, so it only needs to be called once, not before every + critical section. + +.. c:function:: void kernel_fpu_begin( void ) + void kernel_fpu_end( void ) + + These functions create a floating-point critical section. It is only + valid to call ``kernel_fpu_begin()`` after a previous call to + ``kernel_fpu_available()`` returned ``true``. These functions are only + guaranteed to be callable from (preemptible or non-preemptible) process + context. + + Preemption may be disabled inside critical sections, so their size + should be minimized. They are *not* required to be reentrant. If the + caller expects to nest critical sections, it must implement its own + reference counting. diff --git a/Documentation/core-api/index.rst b/Documentation/core-api/index.rst index 7a3a08d81f11..974beccd671f 100644 --- a/Documentation/core-api/index.rst +++ b/Documentation/core-api/index.rst @@ -48,6 +48,7 @@ Library functionality that is used throughout the kernel. errseq wrappers/atomic_t wrappers/atomic_bitops + floating-point Low level entry and exit ======================== diff --git a/Makefile b/Makefile index 763b6792d3d5..710f65e4249d 100644 --- a/Makefile +++ b/Makefile @@ -964,6 +964,11 @@ KBUILD_CFLAGS += $(CC_FLAGS_CFI) export CC_FLAGS_CFI endif +# Architectures can define flags to add/remove for floating-point support +CC_FLAGS_FPU += -D_LINUX_FPU_COMPILATION_UNIT +export CC_FLAGS_FPU +export CC_FLAGS_NO_FPU + ifneq ($(CONFIG_FUNCTION_ALIGNMENT),0) # Set the minimal function alignment. Use the newer GCC option # -fmin-function-alignment if it is available, or fall back to -falign-funtions. diff --git a/arch/Kconfig b/arch/Kconfig index 9f066785bb71..8e34b3acf73d 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1569,6 +1569,12 @@ config ARCH_HAS_NONLEAF_PMD_YOUNG address translations. Page table walkers that clear the accessed bit may use this capability to reduce their search space. +config ARCH_HAS_KERNEL_FPU_SUPPORT + bool + help + Architectures that select this option can run floating-point code in + the kernel, as described in Documentation/core-api/floating-point.rst. + source "kernel/gcov/Kconfig" source "scripts/gcc-plugins/Kconfig" diff --git a/include/linux/fpu.h b/include/linux/fpu.h new file mode 100644 index 000000000000..2fb63e22913b --- /dev/null +++ b/include/linux/fpu.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_FPU_H +#define _LINUX_FPU_H + +#ifdef _LINUX_FPU_COMPILATION_UNIT +#error FP code must be compiled separately. See Documentation/core-api/floating-point.rst. +#endif + +#include + +#endif From patchwork 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: 13610352 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 59063CD128E 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=ADDAum6EK6OGlR180pGC0MY4I1cfVMaid7xNtXMHCBs=; b=FwjOi98UDYiksL ma58ZqtRFnvy38Tfk0ORhaXEiqvuaa8TVu9iUCJ/bkZEWgirk5Tdx/8JpqFO8fapGYkSNIy5jmlWF UZt1h1TEfoAPM01iJFq+680NPs/seTbmBqvTCQaV3AyMl3rkRtP9pZOKHK8pupdfDWpBsxtiinrO/ 0PIap4ncQAAU/w2S55SSKXb92i6hSj626bPjmv8XgdXXoIzIQU4xOFdxicfa58MNrf4y7wEiNpgam zVV+v3HWRa1Mez+9CjGi0lqLrSTEjuRxHLfpxlskhms4nqO8K4ZYqIij8qBLz/IDPbKo5yOTqg4Hp WFDoOo+kgQBb5I9lvp4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gb-0000000HKZh-3lQ8; Fri, 29 Mar 2024 08:34:05 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bX-0000000H8Wv-0YlB for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:24:50 +0000 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2a21330d093so347434a91.2 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=wDg8EJVt6/ZENU5UT51jfznO+1Hg3zG6i2jv5zTeO34czL1ptEPXwSyV074xF+YPHE MaL0CALQnI+iP9k0WtA9Q7EomGplysN8NfyoNFybwP+tAftpVvOdRBOZdiVlWaEZ/hXm Wv6YXkl9cuz0Jls2zRLHUCAw/kwY76xNbqsjgD8vvr0p+nNqjVqUMNg5vNlqr7/wQj+l LMONR/brlpEanndEvecuHnqTAXBpaoShMLNlLnQXJfGJVXascwMaU2f89qDOlKvy5dbc G0lTiKIV8nNhgBFXeBsiekg0ogqwfrgCViTHfn9DVaTOilERE/0H+sr3dRNGJ3RIJo8Z mteg== X-Forwarded-Encrypted: i=1; AJvYcCX96oS+RrG5L/EBD+LrrDGAc20Rysn0KKkILdMPUwAWNC7Olg3v+JMe0W2kmH9FnwA4Wb1K89S5KsrMSJCbw9nI43T0ZI/6w+0htOK/UrlbzuGQIBo= X-Gm-Message-State: AOJu0YyN2O89eAH1Q2CJC343YQUBjnyL1/c0yMzA2tnqwwxYcAgIWgg6 90w9NvrlHvaqmdYAz6CF9uOBct4wiVkLO/3cxnDUO73WucC0FMvcnrdSO30WlSo= 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_223057_9BBDDC1E X-CRM114-Status: GOOD ( 16.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ARM provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Remove file name from header comment arch/arm/Kconfig | 1 + arch/arm/Makefile | 7 +++++++ arch/arm/include/asm/fpu.h | 15 +++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 arch/arm/include/asm/fpu.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index b14aed3a17ab..b1751c2cab87 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -15,6 +15,7 @@ config ARM select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_KEEPINITRD select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PTE_SPECIAL if ARM_LPAE diff --git a/arch/arm/Makefile b/arch/arm/Makefile index d82908b1b1bb..71afdd98ddf2 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -130,6 +130,13 @@ endif # Accept old syntax despite ".syntax unified" AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W) +# The GCC option -ffreestanding is required in order to compile code containing +# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) +CC_FLAGS_FPU := -ffreestanding +# Enable +CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) +CC_FLAGS_FPU += -march=armv7-a -mfloat-abi=softfp -mfpu=neon + ifeq ($(CONFIG_THUMB2_KERNEL),y) CFLAGS_ISA :=-Wa,-mimplicit-it=always $(AFLAGS_NOWARN) AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb diff --git a/arch/arm/include/asm/fpu.h b/arch/arm/include/asm/fpu.h new file mode 100644 index 000000000000..2ae50bdce59b --- /dev/null +++ b/arch/arm/include/asm/fpu.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef __ASM_FPU_H +#define __ASM_FPU_H + +#include + +#define kernel_fpu_available() cpu_has_neon() +#define kernel_fpu_begin() kernel_neon_begin() +#define kernel_fpu_end() kernel_neon_end() + +#endif /* ! __ASM_FPU_H */ From patchwork 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: 13610237 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 8A246CD1288 for ; Fri, 29 Mar 2024 07:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7daa7xH7Vl/PTowNsPTgpnGn1Kdri1pgs2UXfAURvy8=; b=oTELMZeCnioOyk MYsu7nTiDk8pduPDQTB53Gey4QL2X+C152ieg4m5t/vf2reG2tovGN3H+at7/fLm8oeDnHRGLbpFp y2eTHpHIooJkxUqyJ+3Ay7sX1rdx6Jkf0k9F1pfQGfhmybNfnTqKgZKvzbPWNnqShO+qBsuxHr2/L 3MI4B3dalR1ZxC/OAIfnoOpMstibirf9dVID6KPgBsGMMzEEDcM/SG64Zfr9zOxifFMZdEFDhsbo/ CWhHQEA8KZeOhIXiLhNvN8LyzPyc2nFe6y0qD30XW5NfWXBT5txTUjywUXY6QFiOFLqtVgDonbLpZ c0cC75SVisvGT8zbZYJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6c0-0000000H8qk-1g4t; Fri, 29 Mar 2024 07:25:16 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bY-0000000H8Xq-0sRj for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:24:50 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5ce07cf1e5dso1212186a12.2 for ; Fri, 29 Mar 2024 00:24:47 -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=sjtP8Tvk3pRcOj6JcAaFv3snLsRB2D14gsUIqLXg85KJ2itdxej0TurDfN7Suf82G/ ww50N7b87xNU/fTAVOSPKLa1dnqLw1MSQ4TyJSt4W/gUjSHAI0kW1G+X0zghC0YDQf1F Ayqdgbjj9i/EWm5old5SnGBV1BcekP6inT0yVUh/NaMuse8rWWawG6GpvyywV75AdgJb VgGHQOBjyHr1kGPEQMUoClRio3VrPBhHmWV+K4Bhaef/sWl/dUiJo5tFQwHVFy+aeIyj QP2vaRQWP/zWpluTgDbyap0Nf8B5AQfceAxQ4n42nlKNLtGg2NJluBGFtPO3ySltcYdA ysnw== X-Forwarded-Encrypted: i=1; AJvYcCX5iCwj4tkO3sSruuAAUGKYSTwzZHEMeqFTPPSn+wEOaJ0bBU4xJRdhkNvmnbPc71CjN4nEQbGIeOsHSyWyqKuoGRaGVgzDnnRzWFGHGZJDjsAnyDg= X-Gm-Message-State: AOJu0YxRCAoZ4D+K+FQS+1AlHqsD5JHxpWmy3lCpYCMyPtF+5pBwL83H CHO8Sh0YG+krEa8VLlukhq9FPAZCVgo8/mhNa2Gp9NNLBx54Aggsyv0T80JGzvw7A54dqTCBnO+ X 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_002448_375322_A3DCE681 X-CRM114-Status: GOOD ( 12.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13610238 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 F21DEC6FD1F for ; Fri, 29 Mar 2024 07:25:29 +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=sdkabc5F7aP0ti/8QJtIDbmpbgzqaZaM4YeyyvBiCRc=; b=nuwaedOjVbvRFI uS1ced6XVMHElP80V0jNLRhK6ZznYGJdaHWfiE+zeNdsD9DJuVDqf3c2IpQas54aA29gOyreJDCG+ M+6VwS7F31dwWnimsL923K2WcOTJQY+gqEUKVBoeoBrhzgnn/pBLw+xdHyILOQwg7HepE3Q5bEKZP HXVGgW2+IlEP8OA0GJOUjfLWnjz4Ai4GJJrhMFlmiK33jtGlOsv3SOprv7+ml0Ix3HSAL5GVMbknn ciInVtGen/53+QDaVIMb+4lbpOzM763mepq4T4yWMjMNxJtWwweF/2aTpbkKmV10g8k0gOyA5BqlG 1mM/H1KJXFC1bNuh3vPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6c1-0000000H8rg-1fsN; Fri, 29 Mar 2024 07:25:17 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bZ-0000000H8YP-3FJ5 for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:24:52 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6e6c0098328so1476623b3a.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=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=EpXVY7AWatXk2O5wwLDdvC+YC4Trqa/oLFccBMdQh9+VXzk9ii9Tc/NSKN5rGQeHOl aAnIwo3iZbGlb1zIvgfbStIvHSJ/2qZugMrQLyhDVNx3xZO12FmWRoKE/G6PGXMjhClQ wNCyGQwULFYKGKJZp5GcDckI878Yq/OMP4u94/243HvVTMXPc+DlsrYiJqaDfXWTsapa XMcmdqIpaeOaUDKw3vQEAd4sLG9F/TlKy0c90HvWixAj63k8pOCfaT/c375eBLr7pUrK Q9DPGu+ty1glztXfRxLSt5GsgWhO4yx5vj7gDi+5FRF7E2fSsJXNVR5fDSrLGlDGBkW1 HuJA== X-Forwarded-Encrypted: i=1; AJvYcCWpM31+VfElVWRT8vMkO34pSVmSxY+ZrEr7kl4S2VYBBeT4w8i3ZPIBDIZGGYJlpdj3Nwb8TRIviO+JNLyV7sQyfN794dWuDWlgNhmhoIxcM3/kakk= X-Gm-Message-State: AOJu0YzbGq+37lTWDod2yoU+fEkOlZB0bc8DZD3iitMHMFPBwXnTR6lv /e0h8RRIo+85LelV3zBbuSzjuuktHrtiLJC3vOzrfC2AgxRRvWvo56iikJ+CXM8= 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_026947_33D0104D X-CRM114-Status: GOOD ( 15.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org arm64 provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Remove file name from header comment arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 9 ++++++++- arch/arm64/include/asm/fpu.h | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/fpu.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7b11c98b3e84..67f0d3b5b7df 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -30,6 +30,7 @@ config ARM64 select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON select ARCH_HAS_KEEPINITRD select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 0e075d3c546b..3e863e5b0169 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -36,7 +36,14 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y) $(warning Detected assembler with broken .inst; disassembly will be unreliable) endif -KBUILD_CFLAGS += -mgeneral-regs-only \ +# The GCC option -ffreestanding is required in order to compile code containing +# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) +CC_FLAGS_FPU := -ffreestanding +# Enable +CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) +CC_FLAGS_NO_FPU := -mgeneral-regs-only + +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \ $(compat_vdso) $(cc_has_k_constraint) KBUILD_CFLAGS += $(call cc-disable-warning, psabi) KBUILD_AFLAGS += $(compat_vdso) diff --git a/arch/arm64/include/asm/fpu.h b/arch/arm64/include/asm/fpu.h new file mode 100644 index 000000000000..2ae50bdce59b --- /dev/null +++ b/arch/arm64/include/asm/fpu.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef __ASM_FPU_H +#define __ASM_FPU_H + +#include + +#define kernel_fpu_available() cpu_has_neon() +#define kernel_fpu_begin() kernel_neon_begin() +#define kernel_fpu_end() kernel_neon_end() + +#endif /* ! __ASM_FPU_H */ From patchwork 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: 13610353 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 3DBECCD1288 for ; Fri, 29 Mar 2024 08:34:17 +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=0rHdm5Y88mwuBC55G4gLpIHvfmEIozFD6f7flXFQ44U=; b=jnvxbULNYZd+F/ GnayelCvbgUwcA5G4XfUtpYABGUqakBWSO+CY1Gm4GcbgUgQPzL/uDxkZJssHXCsm9y9yGTxno+Kz ZL5PO935JQrB7YG8Vt0de2KuPe8jlKC7EwnbSY04zxy94IO/7A+3Cak6pOeie3+gjqifcJnLYxOEy dDEeU6REKPq0Dl/Tw+71cH3LLe8KZFM7EQa1EQUgFQeeq0oRmDV4yl4GJTPacskENYobRE5r65x38 LHgU3Qi9iotpLDhwfAsJBboGtDRVbJzeN06+zUOiv8I+Z1cQs2lIlVSOet4XZ/st7WGbQpXKIMKfH bUaRv9XfnSSK/BM8S3Nw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gc-0000000HKaY-2dYq; Fri, 29 Mar 2024 08:34:06 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6ba-0000000H8ZC-414D for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:24:53 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5d8b519e438so1258868a12.1 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=hkl83EHMqpni/fjZrMch7ImUEafDvmoe8RQuknIV0yiVdIeqS3ZsJxFlwLqUAsMsZZ RvnhMBAeY8E4rarGTS1NRhi/g+6Mvm++PGrJ+GjiprYIA8rYE8/HNJ2pbz1xI4bjJDnW jKHGuf/TRvcUCgVlo0t/gh63NWHB6Vx8c0Iu493okqiDKV/Xhv7ASPqBDqqPYUewzXSj xZwnEsIAx0oItxbV55qOKfjNL0Qo2iZ0SfNJVUkK9EzfXsvfUEAhfHURhekgoCf4KkN0 S2MyUv6KRbJokIjDl+67D2lui9UNItKd5xRpxz9a9NO+tHt3PMpBe8z5OEs9406/PEEV 60Uw== X-Forwarded-Encrypted: i=1; AJvYcCVx1mpn/X48Wl5HKSk+baf51BvSZ1T5OMmb3Bh8GQ4+pO/V09pYR7a6Renyor/VIRgvXaO6XwwSAKXGSX6NW97qyILqrk5ELuQF8vXfWCAAuFsj4Cg= X-Gm-Message-State: AOJu0Yy1dfve/w3f7yS728st8CMvBsleqsRAODBky3X/kUquDTDKcOiU DuSGeH6480GfVjxjl5eRrDShvJSDL9B6YIP8jai1KMn9gvTptez4b7CHmSSzesM= 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_309997_E557D20D X-CRM114-Status: GOOD ( 11.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - New patch for v2 arch/arm64/lib/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/arm64/lib/Makefile b/arch/arm64/lib/Makefile index 29490be2546b..13e6a2829116 100644 --- a/arch/arm64/lib/Makefile +++ b/arch/arm64/lib/Makefile @@ -7,10 +7,8 @@ lib-y := clear_user.o delay.o copy_from_user.o \ ifeq ($(CONFIG_KERNEL_MODE_NEON), y) obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o -CFLAGS_REMOVE_xor-neon.o += -mgeneral-regs-only -CFLAGS_xor-neon.o += -ffreestanding -# Enable -CFLAGS_xor-neon.o += -isystem $(shell $(CC) -print-file-name=include) +CFLAGS_xor-neon.o += $(CC_FLAGS_FPU) +CFLAGS_REMOVE_xor-neon.o += $(CC_FLAGS_NO_FPU) endif lib-$(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) += uaccess_flushcache.o From patchwork 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: 13610354 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 DB8FBCD1292 for ; Fri, 29 Mar 2024 08:34:17 +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=yqKWC8NXeEL4paRz0zhGMQawoCJRaw8aZ15sEDdppOw=; b=Q2eS9YO7NSwUED JfCcqTdFWsIstG75NFruN8V05BDgTaGdoMzhffswT956t6Egk0O9Ba1AJ96JEuOL3V7Z1FMID8+C6 m5ffGHXZ2x+HBeyfbc2uhlBoZKyRkNWq+SDodEUTptulXPkRe409pGlPx5TG8yesRviAJMDlen6t7 zEDMXtQlbNjQhg840fgsKbLppkJW/F6t0Ot3EKomCMnyxyu3FcouqC1H+6OIJTp93dCp3UOoxhIOa 89C4MuA6l24/lLKfO+5q7+PmARqnZLxBCkB93B1gYRsqWVsxXshWBiSPpJ2niWUxdfBz+9ft9oqBJ jDJUfp22Cn8nMZ2oM6Sw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gd-0000000HKb0-1Hwe; Fri, 29 Mar 2024 08:34: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 1rq6bh-0000000H8dG-0FOg for linux-arm-kernel@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-x532.google.com ([2607:f8b0:4864:20::532]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bd-00000001QqJ-3KU7 for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:24:55 +0000 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5cf2d73a183so1983427a12.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=iMoNgPth6aAH8rXLDqWe/6nOqRNELnZMilrguTr1w7v0slQ4aqC34B+/9K7yUM2xQn 6Z6oAmwng2jTZoUA0O8tjAajcKyhSwC63j60MVEMxq90ajm6kcfjKNoY9GyaJ8gMRcwm R3XzqfaOfrEcynECemARxcqrJa4hXiQfkN8Dc/AGLAnNaMxIEqU79BQHrONnbp1yAU+r WqRuHaBtFYxmO3nEdlOtxviL4sguG64L0mhKBEYH53yqj08gH1qparHNFTZSPWw4zcBS j1SF1Nh9xYwnMmISpk/Qr3GKt4HqUibzk2eLvkyX3Rd0nJ+LSUcbQHoL5g4M6YnuxBkI Qe/w== X-Forwarded-Encrypted: i=1; AJvYcCWDy6rEOfe4BhuwM1LsrTY8alw1p1Is9XShb+ptSDawv68DPX6j4Ff4NUNlQXyzWYSa29deZe9VmicTr6giFL4AOSbwue5/Ry3F02L3gHZDcZGhO/k= X-Gm-Message-State: AOJu0YweBdtnE7bL2+EJpw1MDq4asRPhGcH7pWIyw3ZpTnpVZsj62Zic cz0mouEHvfCthMd2Uw/2uPAaEeqbiQYwsF3JU65ItBpcpEzpN5ogfvRtX0Uyrcc= 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_045974_04818DB6 X-CRM114-Status: GOOD ( 11.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- 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: 13610356 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 2FA05CD128D 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=2S6xCqhfO73zONc00PqVQ7Be/LubLP5EmAszLDNcG8M=; b=twn+fQmuACYBOu e4paCen9N7hxG31T8Nsih8hUruYEtTV+q34fFoMcNVC0G+gfPKfBvH3M675BiPiNSi8gWUKrQDuLk fZoUXnyd3wx1tez3VlaXYj3rygFtJwb8kAsLiEmqIsQM/ZxNb00OJXD3Vy90qtwiciajie598xRAx 7Bl4TbecROCgEph/3YrNeOuwoVlqSRwjRJH1UBsfMeecKzjHZpzqPAzxkggVJS3shpBOhq8Cv7JZJ dp+/79HXeCT2tp/HoI0uVmqUI+ye8Ec4LGZkHdRqOr3Cb4/x9ivAaSaxmq9FisF/r4rG+Rng4wmUD IM6INM3LpSlvVvagR0qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7ge-0000000HKc7-3OTQ; 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 1rq6bj-0000000H8e8-0m0W for linux-arm-kernel@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-x529.google.com ([2607:f8b0:4864:20::529]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6be-00000001QqO-195K for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:24:57 +0000 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-5d8b519e438so1258887a12.1 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=vs6umnZ7eEQ9j4RNPmlvpVHsTUsSD0zv/FUn6vWevFrE59Pwshk4pRvSJqGJEcrVv2 2wk7+ooTj63GsEsgGVx1OFKNaQb1CT/oXpJ+FtHHWtx40U4xgqFwRJHoytStKypfKf1m IPKJkci4FaK3AEgvhEDc6MBNjAkO02Aitaxi8rk3hG3jHVCD1AfARVsRqcZ0uwMdziYS hYr4/akiQZsM44I4FIXZP+aDg6y6lQKeTzL8szEsp4D/WPUXNEY5V9REwnfka9KzwyKo NlfMw258FYJdPcRhTd/GvjebD/F+It+opD5INe/zZDifspp/rp84pqUFysOj0Nhfm3js e/fA== X-Forwarded-Encrypted: i=1; AJvYcCWBgXiCtBDBVJh7lE+uyPad5ioDtmwIlsOVykSXfnfoB/5uwQqOVe59xLHbQ8aeHEjj8iermq/nWsW6kf9from/qa9k+YpZEQpZ2dqoiC5wmMk9nAk= X-Gm-Message-State: AOJu0YzCBLufhz6w4s5zxMkqKTkz2h6FHq+dFz8vGaCl/ZA1yWi3UOZS BU/FjM7DteuIxsGi66chqpv3Xl7Wp8pA1Vr6ALB53Y3NMeO4+FNZvtpILrF/970= 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_504891_485DD739 X-CRM114-Status: GOOD ( 13.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org LoongArch already provides kernel_fpu_begin() and kernel_fpu_end() in asm/fpu.h, so it only needs to add kernel_fpu_available() and export the CFLAGS adjustments. Acked-by: WANG Xuerui Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (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: 13610239 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 C8DD6CD1288 for ; Fri, 29 Mar 2024 07:26:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/oRjgy0IRe4EZlSogiWNYlYM8gv/+s8CQsRvY6gnsgg=; b=03yDtl8rvccbJ/ dsal4nSGsObbTNneovt+4SUtID2aP7Cw7THQ1JNOZZRVb4s/meBPOLpRsCeYpjfRa0bJ7U+822gxi LL713bzwlNH83hB/H/2vPd+VBJnpGp4d9ZYmsLl9qNjcucEeRg9+BS8ZYepinUGvJcaVsEXe9a03C 74EJ+12uvyzGZ9XDXkiW7YdtQvpQKrrmu4btzOqG7tDAHYfzKWQ8CKFg8LCPtpsCQMYEVSR47dWm9 7lY3hv7oczfSUigA0JBYFUPtI+t9rS0la3hSrS6p9F46rnMguvyjL1mpT6C16KmcEDr5DwYOyQpFA EfP8guh7fcKIUV0BxdqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6dG-0000000H9g8-0CWE; Fri, 29 Mar 2024 07:26:34 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bp-0000000H8hw-23Dw for linux-arm-kernel@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-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bm-00000001QtW-1clh for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:25:04 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5ce07cf1e5dso1212250a12.2 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=Z4KVqUhc7ArnI9MBtAthIzhFPz+6ymIBL7qvqtI+gumwkCr/T7U7DQ1qN5iJtZnN0R ilmUs6QZHXhaQ5Q7/OXDjWyI3gzWy7bocacpW/j43/CMHJQuGP1yeRF0Y7r9JftgPcov igF4x+jWf+Qf1NN5eTG7ymAj/k+Whd6e/xDrrWPgrd5lBqM8Uc9VYiQYcxZJpXPl4k6G bCCvZXhU4Nn2wzMdl7p3LaCdM+efZssIZuPOxVyOlEbi2Psio16WtswHt19eDtVp/Jvp tkjVSzl6JUpkG2L3939Yrso3KUmzKYDGJQhMmrZZDV5SiEm1OFx1wLsYczXIr66+dguf 2ccw== X-Forwarded-Encrypted: i=1; AJvYcCVgrur0E/MIjPfgqSW1CHvcI5+oWAFOyDKby5c1Zytz9N2iBz3EG/RVS5iqxrf8BeB7KmDE85QZKL0SN3FBo8IfoXFZ9EDhxSvTW2R4m+s7ODAUe0o= X-Gm-Message-State: AOJu0YzYLJSeHqueATDEgDQz0wBWF2RFQEbbKWkXAeSIXpKQVI5W7ykE sk135k5ARzupt98X/l0AuHJLWy9mLFXOg75/5xvROgTrzLC15244VBaHKg02+e0= 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_072502_558500_9CB0397F X-CRM114-Status: GOOD ( 15.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org PowerPC provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. The PowerPC API also requires a non-preemptible context. Add a wrapper header, and export the CFLAGS adjustments. Acked-by: Michael Ellerman (powerpc) Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v1) arch/powerpc/Kconfig | 1 + arch/powerpc/Makefile | 5 ++++- arch/powerpc/include/asm/fpu.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/include/asm/fpu.h diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 1c4be3373686..c42a57b6839d 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -137,6 +137,7 @@ config PPC select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_HUGEPD if HUGETLB_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if PPC_FPU select ARCH_HAS_MEMBARRIER_CALLBACKS select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_MEMREMAP_COMPAT_ALIGN if PPC_64S_HASH_MMU diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 65261cbe5bfd..93d89f055b70 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -153,6 +153,9 @@ CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD)) CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata) +CC_FLAGS_FPU := $(call cc-option,-mhard-float) +CC_FLAGS_NO_FPU := $(call cc-option,-msoft-float) + ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY @@ -174,7 +177,7 @@ asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) KBUILD_CPPFLAGS += -I $(srctree)/arch/powerpc $(asinstr) KBUILD_AFLAGS += $(AFLAGS-y) -KBUILD_CFLAGS += $(call cc-option,-msoft-float) +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) KBUILD_CFLAGS += $(CFLAGS-y) CPP = $(CC) -E $(KBUILD_CFLAGS) diff --git a/arch/powerpc/include/asm/fpu.h b/arch/powerpc/include/asm/fpu.h new file mode 100644 index 000000000000..ca584e4bc40f --- /dev/null +++ b/arch/powerpc/include/asm/fpu.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef _ASM_POWERPC_FPU_H +#define _ASM_POWERPC_FPU_H + +#include + +#include +#include + +#define kernel_fpu_available() (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) + +static inline void kernel_fpu_begin(void) +{ + preempt_disable(); + enable_kernel_fp(); +} + +static inline void kernel_fpu_end(void) +{ + disable_kernel_fp(); + preempt_enable(); +} + +#endif /* ! _ASM_POWERPC_FPU_H */ From patchwork 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: 13610242 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 D67B4CD1288 for ; Fri, 29 Mar 2024 07:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w/TjYyNlzCpiZn4JFwjBSERtgR+LX9K5VBSPBmqimA0=; b=fIOAs4mBZHo8dI ydAkUYAL3kvTVVMNgx2E1JB7hvfjXEpAp4Jw2VFMAqVvOsRq/aqDyTl+OZ5/eTyr1gFBBX1Cs23bo EW8sjihgsjPnUgrCXrw8IU/yMxbJ/1iN7cYZG14JgC/+iJ9VA5/Pv5upL5t+nMOFoXnDI6u2nMYQq qdMobpqRavcN+Uv9DOuseBkpyvF3u+5dC8tzEhG8kNmbZeMphzRJ2kYZUD0xbo5v7IICFII+h8icK 7H3oGsh2zzZZWuPGvZOZgHi2PGRHCuR+RUe7j0VBpN6QGMH7PtQajmbdNfI5k5kFVsKdjSXP0S4ir ImgZq1wBw4c3mkFmQbWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6dP-0000000H9nr-3b32; Fri, 29 Mar 2024 07:26:43 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6br-0000000H8k9-1PNP for linux-arm-kernel@bombadil.infradead.org; Fri, 29 Mar 2024 07:25:07 +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-x52c.google.com ([2607:f8b0:4864:20::52c]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bm-00000001Qte-1cnw for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:25:05 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5d8b70b39efso1400234a12.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=TXeR5Tds1ZBelpmVJEAUGuY+/RW/Wcb8/gdDHu/+GewYw6oVAf52Uy+WPEmbNftE9M zCiPRwITRSdJ/EIXaU9w4uYHYH2si79Xwhl/5PqL4Y2mn+Rg0DTwP9WAwRzhF8nkg3fs Ff//lKEqPfupkqzNipCjsMz9yXmqeWmOOQ5aoSKeX4BoUfLQIdbajJpH1Boz2VLy+ptw pFISOrP/hM7+ZUQAwBXb4Ny2wNeWpzByl0kZefDvBP7EBDs/59HDg9FYl+vIyay4l/q0 QLxV64uaGoMTPEUs36Dccz2yQd9dY4fc+5rTuZnSXJm0HIGboOaWTVxGAvFZZb+2CnTQ Yd0w== X-Forwarded-Encrypted: i=1; AJvYcCXLploum/KUWSiQk9TEAuOJgSbcKId2B+EJy8jq1S6+VJ54Sp64K9GGpc6Qz39lS8GIx917jXCPcRkM6kGUbA9xbp4dnhXupNBPtUbtx2esW9s3edM= X-Gm-Message-State: AOJu0Yw1xWBuXHAQVXl8wmtvLzLcAOufjBObYwQxcEzCRCb6c7vPaIeF xZEUqmpqtkhG1OgTfZZtais2TMyfWKOkID8b4Az8EuiHirwiZGzsJ67SurP1z2U= 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_577950_83B0392D X-CRM114-Status: GOOD ( 12.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13610240 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 A4A16C6FD1F for ; Fri, 29 Mar 2024 07:26:45 +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=vVAt2p90bYuNBzck2qNVMP1l/ijJHqU7JwmxjXvPnww=; b=fuhnR6J/WCtyWJ X6dy0IPo+rsgRnnoZ7wEGu3WP/+OOYc7M7rypxTlmyeIvuBdiO1STuYVm51DpMNh3f96hZ3FkwAo3 dowCF1gvq4uz6EFCc1Ov806ONX+9S1NlOMfXZ7zfMtTddJcjD+3dKTVFujPPo9svYeyYCz6wi4g76 nSTPQ7i9ZhSZ0QQ7ezKnfglalSUa3H7xMim+StUee+45jDork6U4kM2QMZTXaIoGkCVgFwVXBgUbN CJ7ZDb0W/RKmcnW4WhBlyfzgg3M0fw+Gz92hFcGesKw86yAbsBF+bdqvnndBefeTpkgQvUSXKA6ft /Eq2BXsQ67c6Tz7EuqbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6dD-0000000H9ei-3xSt; Fri, 29 Mar 2024 07:26:31 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bn-0000000H8gQ-1aeD for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:25:05 +0000 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2a07b092c4fso1396500a91.0 for ; Fri, 29 Mar 2024 00:25:02 -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=YZSuCdp13D/f6j0MLea9jgs6wvQBO9Sojbk1dUN1ehPADYpFyVltWPgkTzH2Qc+rFy 0q8j1JqsgpSnqVW6DVJpL4oSPW2Hjh2Ft48m7pgwjftN/C11VYhihv8QEOJynJdva+JE y1Iek2Fu8gJMTK/D+B8MsKuC3mR2UmeYVBYaXuujOpsgply2roCMVlZ734S9oAcS0T7/ M+Nq7jDvjX8nYcpAqkkEVY9I3JiN4JqBYU6n0fsaoXxZeZVMbP6sLDJe1BguRbpmQqCq mncl9SQ8RVB+45Hhvjwb/E48VoORgw+uVrMdInDELT41IIHiRPgZfwgDvUD/TI5orBa4 nDnQ== X-Forwarded-Encrypted: i=1; AJvYcCXrTlyzI1hTUA5aj+4+HwTxsLW3YQB7cdieiBB6lIoSTytNLzk8dmkxG2il/4vseSmqOlQSuF7r5Ig1vg2uS6pZT5xyYnRuQoonQprRFDtOqj+JUzU= X-Gm-Message-State: AOJu0Yx4xyds5kOnNXDOqF8gnz65XkeMfJa4Ii1I1aRBuJDqHfmTS3pB 9rGpp3eeF2I3WTUPWNsxeg0WayipUFn2/ECuVcUhwWv7cQ3zWvGyjISZJSIRWjA= 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_002503_512963_EFE28C05 X-CRM114-Status: GOOD ( 16.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org x86 already provides kernel_fpu_begin() and kernel_fpu_end(), but in a different header. Add a wrapper header, and export the CFLAGS adjustments as found in lib/Makefile. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v1) arch/x86/Kconfig | 1 + arch/x86/Makefile | 20 ++++++++++++++++++++ arch/x86/include/asm/fpu.h | 13 +++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 arch/x86/include/asm/fpu.h diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 39886bab943a..7c9d032ee675 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -83,6 +83,7 @@ config X86 select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_KCOV if X86_64 + select ARCH_HAS_KERNEL_FPU_SUPPORT select ARCH_HAS_MEM_ENCRYPT select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 662d9d4033e6..5a5f5999c505 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -74,6 +74,26 @@ KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 +# +# CFLAGS for compiling floating point code inside the kernel. +# +CC_FLAGS_FPU := -msse -msse2 +ifdef CONFIG_CC_IS_GCC +# Stack alignment mismatch, proceed with caution. +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 +# (8B stack alignment). +# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 +# +# The "-msse" in the first argument is there so that the +# -mpreferred-stack-boundary=3 build error: +# +# -mpreferred-stack-boundary=3 is not between 4 and 12 +# +# can be triggered. Otherwise gcc doesn't complain. +CC_FLAGS_FPU += -mhard-float +CC_FLAGS_FPU += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4) +endif + ifeq ($(CONFIG_X86_KERNEL_IBT),y) # # Kernel IBT has S_CET.NOTRACK_EN=0, as such the compilers must not generate diff --git a/arch/x86/include/asm/fpu.h b/arch/x86/include/asm/fpu.h new file mode 100644 index 000000000000..b2743fe19339 --- /dev/null +++ b/arch/x86/include/asm/fpu.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef _ASM_X86_FPU_H +#define _ASM_X86_FPU_H + +#include + +#define kernel_fpu_available() true + +#endif /* ! _ASM_X86_FPU_H */ From patchwork 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: 13610241 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 8B78FC6FD1F for ; Fri, 29 Mar 2024 07:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NAv5z7DFCaN3mlzj23P2KeN/UY5+Y32Dz9ClavMdVs8=; b=vjD0owsiBpwc9e MdRy7zLaitKa8+1eDdv65hvRG82bZs5OoQiansiJJwuyh6pglLdJHMAUM86uz44Lre8PoJGDUSr+R jNnjM0bDHTf7MCT/XmRubwmHJUjxCVaKKkS/VGo9hrm6Ss/ffGzeJQpiQVTgN3AlXLu78flIKIaqR M0xIwLEo0aEe+TjAVeG6mvLff19rp4vJxRvRJeG2MOirQJhYaLR98cmrpm5+3tJfAxB3wbpJXT3U6 pSrAXkrshWpocxMj8t84l1/NFpvKZfkNhkvj/1Npb5mZnhR9Bp1PWTEuJXdYAsIk1xPKNizdPdLBP UBVszRQlISinf8JDAinw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6dI-0000000H9hu-0wLn; Fri, 29 Mar 2024 07:26:36 +0000 Received: from mail-pj1-f50.google.com ([209.85.216.50]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bo-0000000H8hP-2whI for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:25:06 +0000 Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-29de4c33441so1386555a91.1 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=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=plxkpvhzYHidYoVUCfvfwsEtUAQL5suT8ZvHWLfgM6+8p2v1QXWAqvr21pSxms1IkB Osbw1JmPqrTMeEZYbDNyAS4MfSM2EPGZP4XTu/Jx6xQLS0T8h1DOHI811ZCdAQEvOm1m G+2NZj33C6HBXe9RGX7NiwpeLFoOnESz3jpQvxQKi6Nrcy3DXIAYFHFqslibG9dgPI3s 6d5Zs+TDG3EiKU0E/j1kutUfrdJJF6IhNx+T47JXN0X5kAg6JM/56q8RuAoj5NwnF8G5 9gLZBqWMBoKpI9rTDK0dzNMhjna+Q1u0Vclhseyoc0d1JanfFT+X6WvYd97ADF49MpqX 1fHw== X-Forwarded-Encrypted: i=1; AJvYcCWGd0qVHkhFodPiE9aQQe/nCHioBAyF01sMyuHAv9/As6jk9lSE4pj1Z9MG5SnCejxMzj3rRAGYy+FZD4U0aNwFQYd3a3X4Cr2U2oQ0N9XBGgvPYhg= X-Gm-Message-State: AOJu0YyQAyxnk+Mp61P49ivCVo1JmRFOdz0+lTJvsjUKvKwG8i+r2jZC OpWaY08nHeJx8hf8OIulyISALsZ4I7Cb6G0Sc+AO1RZh7lfQhT1eC55KRvyJDj4= 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_002504_825491_C527610B X-CRM114-Status: GOOD ( 17.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is motivated by the amdgpu DRM driver, which needs floating-point code to support recent hardware. That code is not performance-critical, so only provide a minimal non-preemptible implementation for now. Support is limited to riscv64 because riscv32 requires runtime (libgcc) assistance to convert between doubles and 64-bit integers. Acked-by: Palmer Dabbelt Reviewed-by: Palmer Dabbelt Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (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: 13610255 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 EC7C3CD1288 for ; Fri, 29 Mar 2024 07:29:35 +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=JKTFitcB+C2yveg5+3hEa5yFIbZ9MuG5qayLQPYjMfg=; b=0iKUaMjazS2FL3 al/XZnSjy7u7XAQ3YRiB3pAmM0jzdjsDYQu9k1VoSj3XwHV/4dlkB7CV8oTPjkB1IY7PmuK4JiI1L QjfUDId+SjSZiY7gATpFJYI0G8NbsSfJVkG540vV0e7LHmInwiiNedsJnWWVlP6XB9/vGN7MrKjt6 7RKV0M5RLq+h5EV0WIxImcYzVudqXWltdJvQGA36sta5iw6ugJ+EfNy+cMbjighNFh9Hy3AIudbWm 3Bi1wczWJJ9QDWH12SM/s4UTFeLXYQMxXRjPGr8mg/5Emob4FMeTWliGGiAMpL5nsF0E2f91pvS4R gIpt3HLiXfwn8TI4IXJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6g1-0000000HB7m-3qm8; Fri, 29 Mar 2024 07:29:25 +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 1rq6bx-0000000H8p7-2fJL for linux-arm-kernel@bombadil.infradead.org; Fri, 29 Mar 2024 07:25:13 +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-x102c.google.com ([2607:f8b0:4864:20::102c]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bq-00000001Qvl-0dBN for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:25:12 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-29fa10274e5so1326580a91.3 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=cDs5IhjX3BKWC3wZVnDe3AD6EDnDhlNEROkzyEQDeIH2u/zmhzD+bqQ3Mrh9CcbpwD 32f77oBSgl2Cy9sGf+czEgxXdhVsZ2MOc0YxJ7+0eeWLpGa+nEOh/Yj2wTGZMfEpJP9N MRCgRbHcah21nNFJmmGIlKwcjz6SqVVNrbplssFJZnyi6Cu2S/IFP/Uq9RSeoqqvremm 26EnlCXTZOdKtpAx+hYOaKRPMV4jrzgLRJjUnb0lZ3NAO0ZOZWeySY5wtVbefvR2OHo9 YQNMOtyGVNEi6TPg2cxtW16oVgaDqIbNLedbcAzJC3g4J42HuBVqPNMz6MXG7VN04JiN wkjA== X-Forwarded-Encrypted: i=1; AJvYcCVtgsRKjhPRnZsnjPaOCzeZqi4A6mGjHD/9OeabUX7oXVaqF3/OJhzEcqR5iNAwhVBMEbao8d3+DGpYBaL1DIKy2AR972h1VGurnxzSAzmIGLh58QM= X-Gm-Message-State: AOJu0YzuvIjFDqJ8NrYC0nBr2u/q2JxCPVc8fiEu6vUwb9s0Zq/H0KPH zwdNBPathprLHOfaqgLGky4CEjbMlahyRzLBLpaajo9r8VNDkaMMDFmyDQxOuUc= 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_819672_79E45557 X-CRM114-Status: GOOD ( 13.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Michael Ellerman The compiler flags enable altivec, but that is not required; hard-float is sufficient for the code to build and function. Drop altivec from the compiler flags and adjust the enable/disable code to only enable FPU use. Signed-off-by: Michael Ellerman Acked-by: Alex Deucher Signed-off-by: Samuel Holland 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: 13610243 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 22C68CD128D for ; Fri, 29 Mar 2024 07:27:01 +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=4AKvh6pNJxwD5PsHzOicoHSFtgQDpNeDOR+vG/oDizA=; b=ilYkwMkQrzQNGE 9iJnDMlx0zm68/o1mVOuLdW3xxemIH5W79ytTzkIN1IH+guAbv9zdf0I2uzuBRC6u/jWgmPvumVfa fw6sMPJ1JsWDCx3fufluJN1WWXZ19bZB4oy8KpqriAFUhizM5YLgaaGpt041jw3phfkYrj8lBjp7A kugnbOgrpOADhAZ/+nMOALT1v/ZBbaBiQUWHJZJT5ZOrXGTtqXYlE5fJxhefXye8cS45m3CLaTaHV 4AvoTdEpHPeZxuu1i/PIla8BCvCkMfN0xx1AVI+OpZrjxzOM4GieflO+QuR4m8wpdH0TepllyY2cK Z8/JD9pW3KXe8YpdiaTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6dS-0000000H9qO-3fve; Fri, 29 Mar 2024 07:26:46 +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 1rq6bp-0000000H8j6-3J41 for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:25:07 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2a20e595351so643946a91.3 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=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=Ig+zC9KRMg5iDHI+R1JY6GCYKncjAuEMPkmybxxx1MVNTmz/W4qH5Ji3KtT4CEvm09 vQ3/E7rMLqmRevgMieHI6UgHJ2in2pKvZuvxO8MtJe8x7YnLAo5SJT2vnHwop/U+csiX tpC1/FWDoSdDZz5fH3MDEfedjpXV/A86wxhxNlB3lT94Rfy23MXRDJQj396MS1LG4Mf/ XETc3XoR54TPwhSBokG+68x1BL6oUli+ZoWqCNYfO4XC5m0iZQ5D78/4SBjw0KYbuT2M Hd4NO9mh2lJY0bQVdM/vFL9CDQ56y8ntcoCKeT67ISw0yPQkvYOq47X4bPppNKN9nY1D MTiA== X-Forwarded-Encrypted: i=1; AJvYcCXz+JhSRu1+ad6bx3xmEyS2iok/Q7LahoIaVXUv+3suBX+sBfmTNj9QBSM/WOTJUQcqNGZfd2mm9GJa55GalGROAJhezjsFYLoZA/6rVAAUrWX6Gfw= X-Gm-Message-State: AOJu0YySWYqSd28QYtHZBft9WRbHS9q6xPHScotrzaIWeE2ysxozmDXX hHFYcUNag7kbFwnB3HUvd+9+NxhBLOnOddEYzGAPu/H5+RCPOC4VZg4e/fWs1pU= 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_002506_060982_1F25DFBA X-CRM114-Status: GOOD ( 15.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that all previously-supported architectures select ARCH_HAS_KERNEL_FPU_SUPPORT, this code can depend on that symbol instead of the existing list of architectures. It can also take advantage of the common kernel-mode FPU API and method of adjusting CFLAGS. Acked-by: Alex Deucher Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland 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: 13610357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9457ECD1288 for ; Fri, 29 Mar 2024 08:34:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pmixhhyoDCiuEPMEzlXvP4hKdfz9L3PyVg0h9QiWV0o=; b=f5x3YycTFp4HQk nQBO92GO5fOIKp7cwC9emvxxywRlbavUNRVFPn2fUduqlX8p6jaZYk1sjYv3DSSuofBH2sUxTO4s3 V3kAtHJIQhvPSwfaSdumGJgyNrTVtjHEWP7TQIv5nP2DwuTrsi3tor26jgqFaHNu67iUx2Qqtr95y LzmH/QrO2nQAuqdPCQhAxyximTog9wWY3lZUH3BvZkvzoqD27elv0aU82BPKPShwTt5vqWrn/T+bz ARfLeco4kvnNxB76Xf319hkL0ExICSuU4eH7VwD7DYo/otCtrDurhlRjMctHQMuglNHYo96o1jQm1 21P5HK2VbUhGFDHQK+vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq7gi-0000000HKew-3lWr; Fri, 29 Mar 2024 08:34:12 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6br-0000000H8kF-0BP9 for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:25:08 +0000 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5c6bd3100fcso1194154a12.3 for ; Fri, 29 Mar 2024 00:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697106; x=1712301906; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=NVMQ6Sri7O55r+h4zmsIlvECjSh9BcLjrKKnd4MDecZZRZJ8i0Zl5SCVzQFlB61dld OpZDFyQ1wCocePmiPaibwG7WmPn1tmrDzTtRP63eeqkF8A+fytPWHYXDv2qH6i8rWTn0 F87KB2aOIDU4jKitqrhYnzeks7i2pY4vX+ZbI6wfeG30v0TDvsivLA9AbQ5dH5iB6mgK MgDI4N7gwWhZg1jvZ/t46PqPjijyEKTApe5PlFqJgsqh3GJ/J64k16sHdHE44eRtgqf4 K2ziwSCCOWx/E0b3FjgvBn7r/pu3RR87X2V+ijT7mZ6d8LGTQSVZQUpIm7VrXb9ksQm7 hmBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697106; x=1712301906; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IERaZRfF/9oogZdizMupzfKIm+UO6QVYkIeFwIsamZU=; b=NgkhIi/MEQm2RrSid4qzNtRo3k812q9LeeVWrGSu16XPQAU4+fpqQOvKQqjjB9aJrr Yg5nKPLt7x+9UJavmOLmGOd71ndE53SOZmsJnW6FZ28EiFVNCeQ3YoMyw8T72E9SL9zS 9IQzsnEqOqLRiowM3ySNWvhA4QKXhGcyd9kISEFYYpeNeAQj+pSV9moRNf9ZDZMIg2wc 7qgIt8reLYh4JFvQN+lknvlwfdzWmzXCh02qaqYrs9JvKG8tjotDVJ2AfoI8nnmal5eT aQWRNu5+Tvq7OTkkRX2NuJHRgeXX3jvj3pTOk554FgdYWX3Z+wcgB3C9UwYRD9NMU/N3 crVg== X-Forwarded-Encrypted: i=1; AJvYcCX4b5PgOSZQqXNiZyQ96K6dAEZ9oLeOuWPIZmfmmJn58cJU9MN1TAH1f9Ydlb+Ok6CinUbRxijMEchhGERpAizV71zm8Lv6OJRPFQ3e9R2x7jWsbjw= X-Gm-Message-State: AOJu0Yy8cj19OosshV9QRcGSaWaSl9F5gY+KQrWXboMT7PeT3Z6gpt4I ozQUgugrZ+48MGfDaMuDxW7jnNZ+Z/ay5pykLuOteKJqzv1m9LGfYy4XCP+hqyg= X-Google-Smtp-Source: AGHT+IEgFbP2oHNJWaGrzpoC9/WKXB2wk7z5kOFJSRoINaDHcY2EGHO1B7+JnkXlN7mfRYkSUpJEAg== X-Received: by 2002:a17:90a:3ee6:b0:2a0:3a16:7489 with SMTP id k93-20020a17090a3ee600b002a03a167489mr1460482pjc.44.1711697106489; Fri, 29 Mar 2024 00:25:06 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:25:06 -0700 (PDT) From: Samuel Holland To: Andrew Morton , linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Christoph Hellwig , loongarch@lists.linux.dev, amd-gfx@lists.freedesktop.org, Samuel Holland Subject: [PATCH v4 14/15] selftests/fpu: Move FP code to a separate translation unit Date: Fri, 29 Mar 2024 00:18:29 -0700 Message-ID: <20240329072441.591471-15-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002507_222417_3494516E X-CRM114-Status: GOOD ( 20.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This ensures no compiler-generated floating-point code can appear outside kernel_fpu_{begin,end}() sections, and some architectures enforce this separation. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Declare test_fpu() in a header lib/Makefile | 3 ++- lib/test_fpu.h | 8 +++++++ lib/{test_fpu.c => test_fpu_glue.c} | 32 +------------------------ lib/test_fpu_impl.c | 37 +++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 lib/test_fpu.h rename lib/{test_fpu.c => test_fpu_glue.c} (71%) create mode 100644 lib/test_fpu_impl.c diff --git a/lib/Makefile b/lib/Makefile index ffc6b2341b45..fcb35bf50979 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -133,7 +133,8 @@ FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-st endif obj-$(CONFIG_TEST_FPU) += test_fpu.o -CFLAGS_test_fpu.o += $(FPU_CFLAGS) +test_fpu-y := test_fpu_glue.o test_fpu_impl.o +CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS) # Some KUnit files (hooks.o) need to be built-in even when KUnit is a module, # so we can't just use obj-$(CONFIG_KUNIT). diff --git a/lib/test_fpu.h b/lib/test_fpu.h new file mode 100644 index 000000000000..4459807084bc --- /dev/null +++ b/lib/test_fpu.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _LIB_TEST_FPU_H +#define _LIB_TEST_FPU_H + +int test_fpu(void); + +#endif diff --git a/lib/test_fpu.c b/lib/test_fpu_glue.c similarity index 71% rename from lib/test_fpu.c rename to lib/test_fpu_glue.c index e82db19fed84..85963d7be826 100644 --- a/lib/test_fpu.c +++ b/lib/test_fpu_glue.c @@ -19,37 +19,7 @@ #include #include -static int test_fpu(void) -{ - /* - * This sequence of operations tests that rounding mode is - * to nearest and that denormal numbers are supported. - * Volatile variables are used to avoid compiler optimizing - * the calculations away. - */ - volatile double a, b, c, d, e, f, g; - - a = 4.0; - b = 1e-15; - c = 1e-310; - - /* Sets precision flag */ - d = a + b; - - /* Result depends on rounding mode */ - e = a + b / 2; - - /* Denormal and very large values */ - f = b / c; - - /* Depends on denormal support */ - g = a + c * f; - - if (d > a && e > a && g > a) - return 0; - else - return -EINVAL; -} +#include "test_fpu.h" static int test_fpu_get(void *data, u64 *val) { diff --git a/lib/test_fpu_impl.c b/lib/test_fpu_impl.c new file mode 100644 index 000000000000..777894dbbe86 --- /dev/null +++ b/lib/test_fpu_impl.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include "test_fpu.h" + +int test_fpu(void) +{ + /* + * This sequence of operations tests that rounding mode is + * to nearest and that denormal numbers are supported. + * Volatile variables are used to avoid compiler optimizing + * the calculations away. + */ + volatile double a, b, c, d, e, f, g; + + a = 4.0; + b = 1e-15; + c = 1e-310; + + /* Sets precision flag */ + d = a + b; + + /* Result depends on rounding mode */ + e = a + b / 2; + + /* Denormal and very large values */ + f = b / c; + + /* Depends on denormal support */ + g = a + c * f; + + if (d > a && e > a && g > a) + return 0; + else + return -EINVAL; +} From patchwork 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: 13610256 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 A1B5DCD1288 for ; Fri, 29 Mar 2024 07:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aX4Ofjsq1tKghLLht1qMDpatkXvP6c9Zup9D1ZfE8+I=; b=m/r76C14Ker0Nf TkWIwm2hhTufr0NDWqhyz6HTqD67npolBNPeVGYvFbPfWxUgLDlCDsLFj4Yl094WkxTyckZdU+vE3 UZBn9Nj9UYczvDAepdpygtpko1H3SdgZKFQfcfT8nmXDkFFv5UIbOaVsFQzgsI4EueCVcdsEPIIN0 igusWIhRbNtmSzIaDXWjum+mDfE7078w6H78v+2IX+8V86lr0PwFKPncZQIFVL4R6L9sMpGXtoE80 ZxUtwQM80FlC1zsqXJYKn1wc+afAoHo4PTxKQasjxcUXr8q+b/CdNZ+pmxuGTvlWd9T+UJsTrMlui nR8yGeaJwWAWxSTgUE7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6g0-0000000HB6w-2A3r; Fri, 29 Mar 2024 07:29:24 +0000 Received: from mail-pj1-f41.google.com ([209.85.216.41]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bt-0000000H8lQ-12vZ for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:25:11 +0000 Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-29dee60302fso2013249a91.1 for ; Fri, 29 Mar 2024 00:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=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=GYVx54Nhf3X0fyyfj5UpSRrz62DBfcxuHVe6sh9AaHgND/Ymrg9SLEvomTVAZJpGbW 1guTq5huCKPiXjb2oy6SaZ9+zDeC6rh/Vm5N492z1w9a4kdU+ngB1Y07asTWjPcedPRu x07htGoUSvfY0oLicNUs1z9T+MC8Wfq6C/yAw0s9wr1jc73BK+locr/y3BafgAoUBsMi LQ3cA2jocxRMQdwPSL7tvqWTUn6Qt9eV4KbISaHfAGdMkBNIxsLXfRDW+9jqDw1DEmZO yf0r0v9kZLdZOrVixqj+Zb0lONJzVUOq0JMPjpvVNdyvTvvPf7l6soRFYtggYmXZrS0E 809A== X-Forwarded-Encrypted: i=1; AJvYcCVEV+/IhS/WcuV8mM7McQZlr64JpPvW8buoKihSGkbr0XQ7tcB9Rm0S88lxZfKClaIbunKIf8+pSqQfgbHc5TmDpFK9gdYjCIxycPFiarNe+dANysM= X-Gm-Message-State: AOJu0YxPRlF1ABIVlvDVWZEpKZrHgB2IygQjdrU6kGw+JWgckVJIxA1/ md8YEpDPpKB8tSLhg+q+IDLYqegrj+aMcI5Ne0ya0+wrmiYctBVIIzPI5gXtllM= 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_002509_469257_4B5DBD33 X-CRM114-Status: GOOD ( 18.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that ARCH_HAS_KERNEL_FPU_SUPPORT provides a common way to compile and run floating-point code, this test is no longer x86-specific. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v1) lib/Kconfig.debug | 2 +- lib/Makefile | 25 ++----------------------- lib/test_fpu_glue.c | 5 ++++- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index c63a5fbf1f1c..f93e778e0405 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2890,7 +2890,7 @@ config TEST_FREE_PAGES config TEST_FPU tristate "Test floating point operations in kernel space" - depends on X86 && !KCOV_INSTRUMENT_ALL + depends on ARCH_HAS_KERNEL_FPU_SUPPORT && !KCOV_INSTRUMENT_ALL help Enable this option to add /sys/kernel/debug/selftest_helpers/test_fpu which will trigger a sequence of floating point operations. This is used diff --git a/lib/Makefile b/lib/Makefile index fcb35bf50979..e44ad11f77b5 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -110,31 +110,10 @@ CFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE) obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o obj-$(CONFIG_TEST_OBJPOOL) += test_objpool.o -# -# CFLAGS for compiling floating point code inside the kernel. x86/Makefile turns -# off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS -# get appended last to CFLAGS and thus override those previous compiler options. -# -FPU_CFLAGS := -msse -msse2 -ifdef CONFIG_CC_IS_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 -# (8B stack alignment). -# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 -# -# The "-msse" in the first argument is there so that the -# -mpreferred-stack-boundary=3 build error: -# -# -mpreferred-stack-boundary=3 is not between 4 and 12 -# -# can be triggered. Otherwise gcc doesn't complain. -FPU_CFLAGS += -mhard-float -FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4) -endif - obj-$(CONFIG_TEST_FPU) += test_fpu.o test_fpu-y := test_fpu_glue.o test_fpu_impl.o -CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS) +CFLAGS_test_fpu_impl.o += $(CC_FLAGS_FPU) +CFLAGS_REMOVE_test_fpu_impl.o += $(CC_FLAGS_NO_FPU) # Some KUnit files (hooks.o) need to be built-in even when KUnit is a module, # so we can't just use obj-$(CONFIG_KUNIT). diff --git a/lib/test_fpu_glue.c b/lib/test_fpu_glue.c index 85963d7be826..eef282a2715f 100644 --- a/lib/test_fpu_glue.c +++ b/lib/test_fpu_glue.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include "test_fpu.h" @@ -38,6 +38,9 @@ static struct dentry *selftest_dir; static int __init test_fpu_init(void) { + if (!kernel_fpu_available()) + return -EINVAL; + selftest_dir = debugfs_create_dir("selftest_helpers", NULL); if (!selftest_dir) return -ENOMEM;