From patchwork Thu Dec 28 01:41:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1758349dyb; Wed, 27 Dec 2023 17:43:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUDOR4+TFdfIONOoqKkD2/yQAorek13zRqm/y5g/3cpZ2IalFJE7jsSfgYINCDmTD0Pncm X-Received: by 2002:a2e:9442:0:b0:2cc:72af:7cfb with SMTP id o2-20020a2e9442000000b002cc72af7cfbmr3694561ljh.26.1703727799805; Wed, 27 Dec 2023 17:43:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727799; cv=none; d=google.com; s=arc-20160816; b=U6hIK6ys0XvAAqWck9eH89XInX3vl1myILuqxl3zc4puyMoLuUiUlAsK+zgVoPlcON PxGVipHar5hVyIY0DUVJzEc8gC9JPXyAC5VKTJVe/kyaDe9UQqlPBCSCIqTwNsV7NS1l BmVj0i03BgVVodlhsDeRGddF8zqPaGadp/AppFyQfxGwTJNVSEZsGzkTq/eQwxDJKE6y IQiAegvNPyPKwR76/mdeWAu00JG5TZOwfQ8ljU40fa4D49DY3BA9Cdtw+BcT+zRt6dip hoPpHJuEV9Lcd/U3AR8xaNpZrzPojuw06Lbseh41YD5dLf/ogkDJjCyOm1ULq4POxwkY CkgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=oKGphS+JVbRrpyRYNMXZcp4xlaDyNlE0PfrLYNqYsRU=; fh=94uOV5sWmRw3BrY72TFM31lKigqzeHCm+E+w2ZFcL9E=; b=sqT1xrgX3WzOz7R9Po2u/gokrOZ/k+9eL7G/xcYEDvNXM0n67FaKpWYoLz+6yJa2nG IAjJKuQJEx6/gIfK+bFoIvdwoXkU29MEMppKr6qDveV+NIPunKeRQqRr/ygd5fdEL30L XBq6wiN28A1lnz62QVR8OZBAJXuGhAZZWRncLw1XE08hDlypVmZvxA+f55smInhPhb2D rk+wd8hBHmIYCrvQiyIY8FQbAvnO8L0dIVwzj1UVHVAZJCa4kU/s4aXLbSU+3SwqVbsq V+Qp7jV4ofLK/hR0bbhMYtgehChGHKvUrU/A7wWlvfJBT3Rfdp+K8qjcVZbSlwiMEAiM 2vpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=dYxiGMkR; spf=pass (google.com: domain of linux-kernel+bounces-12369-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12369-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 22-20020a508e56000000b0055411420e18si6535347edx.232.2023.12.27.17.43.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:43:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12369-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=dYxiGMkR; spf=pass (google.com: domain of linux-kernel+bounces-12369-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12369-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 389971F212C1 for ; Thu, 28 Dec 2023 01:43:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 167085232; Thu, 28 Dec 2023 01:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="dYxiGMkR" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D925D1396 for ; Thu, 28 Dec 2023 01:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3bbd11b2f95so106904b6e.0 for ; Wed, 27 Dec 2023 17:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727744; x=1704332544; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oKGphS+JVbRrpyRYNMXZcp4xlaDyNlE0PfrLYNqYsRU=; b=dYxiGMkR8n7fryIbd7uBY43jviOEm2um6UWd7s+0iy6Z7TDynEFdSxvwFnnpybc+Y9 fUJXc74LweXH5Q+/u3YiWvrqBXGlEJrhUOak+MQ8Do0Yc8BKKZnmx9fCgKWa91hlPmcb qNLzP2jTbfW3vqpvjUiXo5yqaLidistyDM7RuVuBvqnWBlk0qa6E3+RUbBKAuFyhRQBe bbpG1YmRgzJwopYLDz1Qmj2NzM27Th4PvyZeVUj09qkcxuOe3ytUY7bQmAHXtAShsuVC 83ePFfCc2HVpwtGztpEiY2w0b/xKwoK+xcGKkJLV3mNfpI5woQLdAEeDtAohHrl3ezFr mQLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727744; x=1704332544; 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=oKGphS+JVbRrpyRYNMXZcp4xlaDyNlE0PfrLYNqYsRU=; b=SJG8+ttVrNtwKu/cLvpwo9B9HI0WmXLD3iEHuV0F6EiVRBWH4uksV/m5jsMcEJoGHm kaBoYXHUz7ZjrE2Ts2z6CA/0tKvYRquK0aTN34c7dWt8apd7G55O3ByObCOFCktw7d+a /2qEK8TOG/bAewotPN8VgBL/t94TRsxze94tYg/x6XUWKWCTcEeYvsJcoNhGENTa3wQF +oXDdpVf1L2YkAnS6vH4yKYfXvYrel1sEg6oYYjOzQGuVrit8IOiA+bYYAqgQDhlT5Is PDP/gB1GjD+3xDzpK2jgAODX/ZrYFChMXde3YH4VqU8gKDs1J2DDGgP6SjyHHAwyGu1x dcVg== X-Gm-Message-State: AOJu0Yz1vHF7CCppK0vuEOzy/vF8kKd04r6XqF6F4/K3CcMGq1OaJIPm OYAo72owoh3zJB0arefVQjx2O/gqDFohJg== X-Received: by 2002:aca:2413:0:b0:3bb:c658:40f with SMTP id n19-20020aca2413000000b003bbc658040fmr1920457oic.117.1703727743938; Wed, 27 Dec 2023 17:42:23 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:23 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH v2 01/14] arch: Add ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Dec 2023 17:41:51 -0800 Message-ID: <20231228014220.3562640-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488081183144620 X-GMAIL-MSGID: 1786488081183144620 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 Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- 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 ee995fc2b0e5..79c9e0b56ab8 100644 --- a/Makefile +++ b/Makefile @@ -969,6 +969,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) KBUILD_CFLAGS += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT) endif diff --git a/arch/Kconfig b/arch/Kconfig index f4b210ab0612..e1c01ce819ed 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1478,6 +1478,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 Thu Dec 28 01:41:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1758320dyb; Wed, 27 Dec 2023 17:43:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtcqHYQi/4qZQ8X2i+tXM/7K08L6jPKgZ7IduF/5Q+ZM2yqKvqa2rucw3YGsGnLH0G5rCF X-Received: by 2002:aa7:82d0:0:b0:6d9:aa5e:3969 with SMTP id f16-20020aa782d0000000b006d9aa5e3969mr7087992pfn.40.1703727794469; Wed, 27 Dec 2023 17:43:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727794; cv=none; d=google.com; s=arc-20160816; b=n7j1CoIyYeN4CKoMaafz9/UkCbf0UvBzDC9Cl0QIZh40Am3y3wvhlY3ViC8khEmSV9 jmtryTzBXv/EYdLerPOFznx6lfzAGY5jhZ8+VMw1UR53t8sjLG/8AGKJp7rPFNv3zXJt cDL9srNzgp7pveRoy+JtXs3MuzCVzJaDg0v2i6u5zzXH4MNeppPPlo8P1+Zr/sykXvvP fGoudK33Cuzeqv+OhYnNuGsdengTrIldVa+zIsr856hhM4y8EDBv9Qek3Ll+rZAm2s6B Ar2c4Kp531RZyRPtllzEDi0yz7sZobDlBrLGFPDT15GAuCpcmXnRwDfPQGhArWcy5V28 FYfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=xuiZ+dA63qa6KuTRM/9EMSF12UiDXQURMhZ59hCd4g8=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=g2nz/hEWidB82jV5/gy5DZddz6glUuvWXXh63WB8F3MP1ZsfE3CTnCO6LKJBmpNmK4 P6STZR4qyWGn8HSdf9ySZ5IaNx26e3fx3G9BF4tS2zT1g1T+rL98NZ070//lvLxzj/Hp 7T10C+gzMs8e8gEYluCOSBoIDIIZL+47dVuUS5w+LYEJka0VM+fH3LpLpI2toPtOgTmH btiAKaS10krm7c/FGhCRicGELQOnARNnKCu4AMWXJxjh35QGMAHm3zdcZt8RT4G4aN++ JQhaAm7NhyO1zOyFCJPqSO9roIf49MQe8hCZ1muqcmVYpPom40u4pHpFDZS2GkpX/jjT eevg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=hrprsTQ7; spf=pass (google.com: domain of linux-kernel+bounces-12368-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12368-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j12-20020aa78dcc000000b006d99a0c4b34si8644865pfr.180.2023.12.27.17.43.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:43:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12368-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=hrprsTQ7; spf=pass (google.com: domain of linux-kernel+bounces-12368-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12368-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 43BB3283F03 for ; Thu, 28 Dec 2023 01:43:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C36CF46A6; Thu, 28 Dec 2023 01:42:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="hrprsTQ7" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC18F15C4 for ; Thu, 28 Dec 2023 01:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6d98ce84e18so3891032b3a.3 for ; Wed, 27 Dec 2023 17:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727745; x=1704332545; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xuiZ+dA63qa6KuTRM/9EMSF12UiDXQURMhZ59hCd4g8=; b=hrprsTQ71tPBhB2Fb/uL9FCkSQ7BtyqZJrmMSgxTQxDECXYvzerZcG5VXtzqhIhvk8 VHTf336LUSs3GJ8YczHMGB6xTrkQGjCf1NA9gOiq1bEMfMA70gCy13o0fqeg0LAnPBlX bqfySVi47x95fL3M5cUDfJmhRMetJXHR3uhzCSeDlm3Bi+7s0ikAa55hhPxK70GiZoUY cnfga12XDILrBR0P7wblA5Z6DAj8MW+dJ9Ov3wP2BEGNfpgri9DimtrN0+ZVN+FEsmR3 lunUaE5XV4gSo7HKgNB32RexxF4VjJkjmEooeo5jF8gVNkVIlDbLSBhRRLNhCT+TpyLp 2c6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727745; x=1704332545; 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=xuiZ+dA63qa6KuTRM/9EMSF12UiDXQURMhZ59hCd4g8=; b=BxzqfOV7fR1P64akSowKzZSxUIs6LkMClRAqGQjCkSfLYBZNnodTyVEtpwL+d548fZ DsYIa5UZxQK7d84EX1jAlLcHSAR1JmIZCRdn4Z9RjHhRDz1T3nSMDuzgnaoZL5WhAbik UlLp4UPxUpG72pZINzpDgIDsRRjTIMZykBuUArfXxndrno3DbKnN4aREqC1PfQkzlhZq jDpt2SI6Dzojuulw5DW+iZqBPVdPMyZMNTIHVnKj23uq1G3YSBlClumJts76XlxIjnFT KeL3r18iIl5LHLS507rJFpKArnYt/Z5Roz4a3Gp+LLTx/JaFX2WpBqoexV7x5QLkVTA3 KnFQ== X-Gm-Message-State: AOJu0YzdgYjzMpP7aFCMPKP7sUEypzk5vh6eVhuShAfWh6A9x7/oQ2s2 iUpX4uMH9ldaBwnwzBp3zPbUBUUVn4XzOA== X-Received: by 2002:aa7:9142:0:b0:6d9:cbb1:7818 with SMTP id 2-20020aa79142000000b006d9cbb17818mr4021989pfi.20.1703727745150; Wed, 27 Dec 2023 17:42:25 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:24 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 02/14] ARM: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Dec 2023 17:41:52 -0800 Message-ID: <20231228014220.3562640-3-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488075669209139 X-GMAIL-MSGID: 1786488075669209139 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 --- 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 f8567e95f98b..92e21a4a2903 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -14,6 +14,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 5ba42f69f8ce..1dd860dba5f5 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 Thu Dec 28 01:41:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183612 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1758553dyb; Wed, 27 Dec 2023 17:43:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGlGZ5UNjzwGHP5aefBAvhdPpPyKAl38asV1ygbZA75/QphApCdTUC+vHOwVOR3jD+J1AjE X-Received: by 2002:a05:6214:500e:b0:67f:5b6a:5be0 with SMTP id jo14-20020a056214500e00b0067f5b6a5be0mr13072081qvb.26.1703727838957; Wed, 27 Dec 2023 17:43:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727838; cv=none; d=google.com; s=arc-20160816; b=wYihNQ5AQwGtJJPUI0JYkBVdq/WYpXZ73zBeyDuDSnysSxejyMRFEumo5ZqbpYzmid B2wxMKcTGFVEse28XPhGEJqauLX8Ii62uTinjbfxtDBDC9WN31aveOnZcP+byyzRl0TB rxst7dTCMOe4Hwi0u2mwk0ztX7YJd/qTmR/nrl1JWHoNq62TBoVoMxedSwupb0cdNCzn lNhQfQe14tBcm7Z0CM7FyLuhlbDiRtFdwBjFpGXU0OKssvjxJ7cMzhovNQsZVtG2Wk9m GX/jxC7s6FRP+UTD/5FyBZ0opOvG6cgT/3Vqn1QcmXZaWxKPVKJ6nldSc/NPRpSu1Xuh /vMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bJe+2iWG7zhbu2gjOAPKG3r+a1/tBb6PXcWtzUfSG2Y=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=rnC8ftWn2HchUnIpX/Dc4BgznNQHTsPvMZYwIxUDj1EIr6ulkVEjVPQunh3PWotBJH gr3815NqOkCGXP7X9rbQ5SvPEk2Y+1GyCOzAgZhnn0n12m0uppXzIVtHbNhyOev2+afT jDojG/l0J5H8KMKLCd1x3kq4soQQ3A7/QAGzDUysczUiUOFqZJU7do4l4/j92LxZas/1 TqDgIvn+fQysEceZl1+WI0T8LpcOQhdtiUWo7aALcYa6guRjUvA/IpLtSYKXy/WKLQ70 i7Nlqx+C9zAZ8kxuuam4tcViTYHWodACMzNMCt/Mjcb1xgngsuLmdYklU7Udy6ujS6XW 8LxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=IRj4wDWM; spf=pass (google.com: domain of linux-kernel+bounces-12371-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12371-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p4-20020a0c8c84000000b00680684164a6si1517103qvb.304.2023.12.27.17.43.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:43:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12371-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=IRj4wDWM; spf=pass (google.com: domain of linux-kernel+bounces-12371-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12371-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BB2F01C21580 for ; Thu, 28 Dec 2023 01:43:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E05EF6FC3; Thu, 28 Dec 2023 01:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="IRj4wDWM" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D55B03D8C for ; Thu, 28 Dec 2023 01:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-204520717b3so3179291fac.0 for ; Wed, 27 Dec 2023 17:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727748; x=1704332548; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bJe+2iWG7zhbu2gjOAPKG3r+a1/tBb6PXcWtzUfSG2Y=; b=IRj4wDWMchpe5e/SlDtZMjWCwEWx6bf7LCeVjTNfmaCvVOOK0CNgHJ0+I5Ttx1qYfw IJa6H5PuBZ4y+0P/lRAdb90JZKw9KnYAaRErnR6Rpj6xq8Vfc0JmK3I2GJqRe/jIbVqF gYUTK63PSAJhI13bAxb5gwp4Ti3d+gAPlaz6TSULeYg2LCA//Tq05BpUDWNOT8hDnfdp aRL4i+pJ9NP4gaNohjf+05d3bwlDk32npHj/GxiO/xCnWEBj0TASIGagmkTURtqd3kPn aNbZlCDfe/OMtBhOfA/Uy6bBjk0ciqWNRa37xEwqdsNnGUd0JH40B45m7mG3vNC4LPaQ eXzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727748; x=1704332548; 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=bJe+2iWG7zhbu2gjOAPKG3r+a1/tBb6PXcWtzUfSG2Y=; b=lcRBODFFc1JQhl5bYj8rexMR1dCJ68VyuOgTZmTQUoTI/HyBbvsFO2xreNjAPiMsNz QYsVaNIRpCKyMt/oPDcCFaC7qWcM5hHh/OWPZFx2dsA1q56YT93V1nH3mU4HWTWY3b5p njSHFaKRCzP3J9COtfK/dJIPK15TrsT3FjLG1aXJyeoxV17MnqNz41CtHlbduMiIzSU2 lrLH2ij+1OpRL27g1ujxBZDZi0hKQpDMna2KPSd3GJAWWqxVvJwnm9gl/k19hFUBfIt8 X6aJLzx0bKGF3HgWMxuWRdVc95BtPhezoZ1M+DCGJ2BQ8CDJ/gK6cVDGtctxWrQGNc1q 0aSw== X-Gm-Message-State: AOJu0Yy5SAc67tl3/+D/5gsL9ntS7fNUD/ic0nK5+TObsS43FFIxFevR wP/XLzTEk2qGR+Zdd9kXwA9p4+m4DGbZoZUo1Qn4iGaakhk= X-Received: by 2002:a05:6870:355:b0:203:e0bc:5e11 with SMTP id n21-20020a056870035500b00203e0bc5e11mr10237951oaf.70.1703727746413; Wed, 27 Dec 2023 17:42:26 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:26 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 03/14] ARM: crypto: Use CC_FLAGS_FPU for NEON CFLAGS Date: Wed, 27 Dec 2023 17:41:53 -0800 Message-ID: <20231228014220.3562640-4-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488122497856925 X-GMAIL-MSGID: 1786488122497856925 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 Thu Dec 28 01:41:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1758525dyb; Wed, 27 Dec 2023 17:43:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGmwlhV/SWuGzYpiZZJLBwN894xkrRrOYxJBvb3D/0Zwk7GWVS5cLSbAwTR65dniuoK9uk X-Received: by 2002:a17:90b:f0c:b0:28c:2b2c:1bf4 with SMTP id br12-20020a17090b0f0c00b0028c2b2c1bf4mr1973872pjb.15.1703727832759; Wed, 27 Dec 2023 17:43:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727832; cv=none; d=google.com; s=arc-20160816; b=pM/fA78Saxvx+FGQ9YV4rDqpSM7JSVf9pWunvO0gwA5eAqe1UbxL95E9ZZEyD617d9 aT0jtnJTRVs+JjnEhOkA/+jokTC9ySDhTkFcfjBUNUEwG9Sym7+xnKaV1Mu/vhQuwDbH DBdrv6SJBHKmONcGI5o13F6GwQYkJ9zHGTvA9+fZldJoFh9EGSkF038XjVFlPEw+AH/u UsS5dxbB5ML0Swe5rXdd9FNr3AlnZUzYMj0QYt0//x/xbGuSz+19noOYjWxz0vSpNrok NarkoTJCKtOMyuEpfwFjMliwnGCjYbhL7f/w3X/7Gf51TjsOOYQUI+Gq2OfPLKaK6r1I 8hOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UB0U1us+sHbYZzCVyIg23Xjh36gyEMV3F74ABUc7NA8=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=av6FulRuOEwupQGuabSTCQKUyQAjyKfTcYEa1v0Xx7CMhXpnz1yn9/k3YWm8zwM9WK QSOAFQgEeuiwf/qsU7F7ATt/Yy6LZ/YcLvfCKIxbjhK9wx4rWujotwhJ0FfcWP/V6fHV jRRoLFeiCS6OOtzJs+tJALiO8LInwJehX6pC8hMH6tckEbOL7sdM5Yh37z3vvAhfeZEo 86HXubEtE337TQPRX+XKfS7GqJNTznETbSuIQD89r1DdDZEehfni3dkhMUxPPavEzf1W PIngiYcwusXn3d4EacRbRkx+Qx+xrcG27f0AN+BmTLmQOfsC+zOx/T5an1y7NnTnqm4n OOKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=RbDzr93O; spf=pass (google.com: domain of linux-kernel+bounces-12370-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12370-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e12-20020a170902ed8c00b001d0791ce87bsi11909060plj.181.2023.12.27.17.43.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:43:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12370-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=RbDzr93O; spf=pass (google.com: domain of linux-kernel+bounces-12370-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12370-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8950A283E5D for ; Thu, 28 Dec 2023 01:43:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8CE366FAC; Thu, 28 Dec 2023 01:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="RbDzr93O" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 800B533F7 for ; Thu, 28 Dec 2023 01:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3bbbc6bcc78so1364706b6e.1 for ; Wed, 27 Dec 2023 17:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727747; x=1704332547; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UB0U1us+sHbYZzCVyIg23Xjh36gyEMV3F74ABUc7NA8=; b=RbDzr93O9f8Q/vVlCjgidlyK5aK8cgopcvJ0LmfHTp6G6O2AZqBp4gHxRIRTY1fk+l nJIHT/9NmtPDtWpBhWa/3IWalcwgc+gzmYxFFQUYwlQ//wi40lEdMeaQVUi67ff9T9QB QB+xbZJoaj4LNwpccEwKt9gdPV0EYmInXrXCyDv7F0VNGPKomv6Qa8jM5duiKfUUE2OA wXgg7jtVkZ1rNbrVcky/2b8qlZLZRXLbKLJb5ZZ4d8T+qBomhLYtJ7Z1bNkF0Hd7lpBC fDSMyQWsFXcEM6WN2/Iw2PbP7XLGVKiAJYWuXN8azyelJYaTSJkcHq2fIN8B7d+iw0/D eoGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727747; x=1704332547; 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=UB0U1us+sHbYZzCVyIg23Xjh36gyEMV3F74ABUc7NA8=; b=c8OuTSL69Rk4BLyDgs4NhdBgQGrxpY9ODL7rqrPvR8H6DvK0ByoV+fcXsDmr0IOqBx MAQeM1K2wMfBzEz1Y0Pyw3pH23uP7bW06kXRt8ZZdofCZOxtzdW56jT4CRGWE3j7nu2Y lV+E2WuEJmD+5ppISlMh+e8BpYdtBx7aBrTtOyTuioogVHEtjwYNEl66T8PE8+Au925H cuG1Qzt+vvohFcik5skkPu+CNbaf59uDL5ir40GqnVCklGI4HUxuEykX3l6IptbnXuCY a3JKcmCm86QB1pt2JKuzIzi89o+WbQMfgq6dYoup6I3teOVs9nJLoWw+a+N3TVX0scUX /DoQ== X-Gm-Message-State: AOJu0YxcNT4a3LWF2jpE3wp2pT60VeOmoAPVIaXN2TQcexyBcLo+ODrU oA4EmHOdGfIhj2NFEvoB14P0V3LlXjwdNA== X-Received: by 2002:a05:6808:148e:b0:3bb:c453:df38 with SMTP id e14-20020a056808148e00b003bbc453df38mr2614480oiw.60.1703727747728; Wed, 27 Dec 2023 17:42:27 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:27 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 04/14] arm64: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Dec 2023 17:41:54 -0800 Message-ID: <20231228014220.3562640-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488116040995025 X-GMAIL-MSGID: 1786488116040995025 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 --- 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 7b071a00425d..485ac389ac11 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 9a2d3723cd0f..4a65f24c7998 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 Thu Dec 28 01:41:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183616 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1759155dyb; Wed, 27 Dec 2023 17:46:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFl9hKpOu4fE6ruwTKRW6QwUR9qUDQK8pM4HSlf2rDaHAz4XwBKR4OHcODNNrOI9KNd85GO X-Received: by 2002:a17:902:d891:b0:1d4:6a34:b439 with SMTP id b17-20020a170902d89100b001d46a34b439mr4151102plz.130.1703727978235; Wed, 27 Dec 2023 17:46:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727978; cv=none; d=google.com; s=arc-20160816; b=aNbZzXnb6W652zlUVw80nBIAswPTmXCFSbbkSmlKqKeSoRT7yj4PjSUz0xKdnh2M2H mfO4FV5Bo3yjN5Cl50ng80aiTuytkU9wW1FEZ+AuF5ytJ+U5+icWAQLuKFg8nXY8rayJ R7KUsOGA4PtB0w4cm2Az8RCKLjMXauFsiz1M+kziOOXXKGms5cfPEAUCkt/I7xCfUl1w 0QKkWggrWpK98WjMe25eDiVzZOBYk0IKq752M86/7XEO4rPir0fT7Tf3iyUsSkqw/30Q aZvSH/qITo1JfPRDVyzBlJNG3kPjOLrUXlAedGGRbkRymgZhJudWy4GkvcJ8m7SYt2AQ jr/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BoxXzLgzl7b5Y0xu5pjyo/VkU/XWb+SGTLxU4jp8p0k=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=ZdpJwE+ewuYxg9V8grmixKEZ/O9Zew3+Q02IrpyaV9EgcVWFCzNJGL77DGdY/T6Q6I IHl2MS+KehPCYlbpOKRb0yMIoiiWiVTdSsuavHWROVpLzqW5n5AcXW1vOFB9y/puyvOx oXGJvBkl2yN4qHf5j8h3S5NqJZTMj6rlM3cGk6V7ljn0NdVCgROrpsLjtq2Q9fOwtEjj 9iyH8Q7EGnIsZRj3+sD45d+uxqHySaChpIBDktmMmkDzp7Dqlc99WhbkQJckz+AxK7UI ca+G670OJJ+p/hqCP5jbazEuwayX1Ex8PxauVVBlj+80jRdc2/KzhzseLbrIn5s5YKtS ZJcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=PUF+l61d; spf=pass (google.com: domain of linux-kernel+bounces-12372-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12372-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o15-20020a170902d4cf00b001d44ca8eeebsi3215819plg.480.2023.12.27.17.46.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:46:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12372-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=PUF+l61d; spf=pass (google.com: domain of linux-kernel+bounces-12372-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12372-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3A264B22981 for ; Thu, 28 Dec 2023 01:44:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BC237460; Thu, 28 Dec 2023 01:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="PUF+l61d" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94AB54695 for ; Thu, 28 Dec 2023 01:42:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6da16ec9be4so289649b3a.1 for ; Wed, 27 Dec 2023 17:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727749; x=1704332549; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BoxXzLgzl7b5Y0xu5pjyo/VkU/XWb+SGTLxU4jp8p0k=; b=PUF+l61dULBFx9BqJizRUQY7BSXzK1zIywqoOajIVLWAfCtySt9aPUkDC/IgSBclRm iqDsd7U66v//+5QULCMm99mwLWnhP1gkKEalhz3J55IwPdcin5uhKNW2zTkXniFnJo2x hyfhsAE69ien/ff0dSVQiVB4NL/0ndLQeB/NKYJjDeN61YCO9glHmPYIx+L2wak463TE vDp4BM+gWhOKbocJ5a7noEPqUL7m3zqZ1KGgCAJ3O01x9/uWFxA2DY+CEZX3oHc/GWCA 4uVczuRwLIq/osigNc/pWe6sgayCeWlJZTfD3Dia3MFWkCTSREYU8nQqqQ+Tf3ain4/h U9uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727749; x=1704332549; 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=BoxXzLgzl7b5Y0xu5pjyo/VkU/XWb+SGTLxU4jp8p0k=; b=Gp94ePxIJ0ZiUw8wkRpQt1rqrrSqtLBqP8cN4dCUur6kSx+vE9yRYrcCFCVicBrqAF 3lLLHazixhU6H4A6PFa2jkBRR/fydccdEm91vMDttuuwFdNXlQXekLmS1acfxpyTcdh0 PEpewjSvAT09cKRSMQ5A3AQnnTmcCESBBfEvB0JhGU0jfX/avVzQPEehFsq0HX8Mh1/l PNMM2jljwthU9/7vlabh8SlBswuVGXcAn0uT7GRgNLHwGqpZWY4E5OdGDDBO4TT74YrL X+anpkFqNqxtov05TkPuGifi0yemNkbEfV16rCBKn0vJPLTL7YDGVUnQ0/YhLBMxZ85J MDcA== X-Gm-Message-State: AOJu0YyRI2HTxE8P+Oho+pyf8e4PeIdETrsCPbFe4Avxr2bnf9hRmGgf y/olEGiVVFbiw1IA0M/T2qE/27MYI0Hjow== X-Received: by 2002:a05:6a00:4c81:b0:6d9:bc67:82a with SMTP id eb1-20020a056a004c8100b006d9bc67082amr5349494pfb.54.1703727748958; Wed, 27 Dec 2023 17:42:28 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:28 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 05/14] arm64: crypto: Use CC_FLAGS_FPU for NEON CFLAGS Date: Wed, 27 Dec 2023 17:41:55 -0800 Message-ID: <20231228014220.3562640-6-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488268390051671 X-GMAIL-MSGID: 1786488268390051671 Now that CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Signed-off-by: Samuel Holland --- 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 Thu Dec 28 01:41:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183618 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1759402dyb; Wed, 27 Dec 2023 17:47:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMBSLRu8Ir7FSjej4fun/RuYpi5E5eiMjNy+GbUX66EE8hNpYAbAQ7oDlN8ZQbtdeKNxxe X-Received: by 2002:a17:902:c40d:b0:1d4:6732:b282 with SMTP id k13-20020a170902c40d00b001d46732b282mr4712766plk.58.1703728035708; Wed, 27 Dec 2023 17:47:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703728035; cv=none; d=google.com; s=arc-20160816; b=hCOL5/Xz4Hszl58JNNFCOLmNO24I3O9Kc4U7DAWJdrO8pgt/Z2WpWrBUHwkdtMFjaB Ez0+9LC55GaZEwR0eRSlfyiy67XoOP/8dPPG0GLL4qQZGaNZchCcOEW+qUjhQEKXP8ag A9Wsg4lcYvqWMdA0KZdYXyNS1+bgicv+kr4igsTW4gV5IqY5XneY7v81Lowl5RxwhFyL YLY+6obDnT0I8y1pfiZ47p8xTwg1xw+NWrKzaFcx4vSvebsvhQUVcOqnBtUUKXGOE4X3 NsWj5up/RJGVvjw/M8VDRRKmfbQ7EqVIKR1nfAuTIc7ij1Uwz/aA46/mdk8vvCkOT9NQ JwUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5jd6BNzjMN3b9R+N9FmyfxlTWIL2mCpzUIRSa4mv1F0=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=uqJwIw6ABiTUCZdNTt7P10MIRW927BrDn3aQLxVL9EolXWvlr0H+pGg6AgfkYnginl VNndAxqKCQG3loCveBBTNAn6cizcKtJw9jpY4aj1hbY9IGmeY7y0JdnvVuD5mNP7dQFu WeiKU04g31qU6eGSDmzkwktHvWNxIpThXnros0A83W9PEYHyL7SZKi11N1iW3sInvXcF e4peQGmv3aEnt7jfeuaisQOQZ/ynTMfNp9XZ6t2o+VKymbTc6ueDcbX04E2P6s905Nm0 2R59YPF3HtAhrQ2LGcRKgwHzewx5jd5IIMfN/paWdAFUHko/dso5G0cyKGahhpPnPafn S79w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=AdXBpeTy; spf=pass (google.com: domain of linux-kernel+bounces-12373-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12373-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l13-20020a170902f68d00b001d3f2c51623si7811580plg.378.2023.12.27.17.47.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:47:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12373-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=AdXBpeTy; spf=pass (google.com: domain of linux-kernel+bounces-12373-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12373-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C6BB3B219D1 for ; Thu, 28 Dec 2023 01:44:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24AEE79E1; Thu, 28 Dec 2023 01:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="AdXBpeTy" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41F916AA2 for ; Thu, 28 Dec 2023 01:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6d9af1f12d5so2545754b3a.3 for ; Wed, 27 Dec 2023 17:42:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727750; x=1704332550; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5jd6BNzjMN3b9R+N9FmyfxlTWIL2mCpzUIRSa4mv1F0=; b=AdXBpeTyy160x/SIhJk2nyA5lcOeI2kcGqCaAQxHr61jm4u2PSwzafBrwdsQkRrjt2 POF3eAztsFmqFANbGg8yUhzB6OwPNuI8PfVEYXUuLsXDOgzsEzefrjG2zts57dHisRkZ HcuoYUx7q/bRLbLKofTlj3tjIK6cGIQeDU74IRdm55wjHStmZfogUiA7y105qS6+fMWh 6u0kUKAoiYrhOwPbzI3KyIGNCH7Qlkk0UkzONbXdVORLgLxPTm37ysGmeukOPs8n6wN/ 0gc3z949PCYlhOf58oFA5PUe0fFCT/BenHBZTM1Yk5ISnoEr777RXBRxrls/xYFD7Z4L iYkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727750; x=1704332550; 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=5jd6BNzjMN3b9R+N9FmyfxlTWIL2mCpzUIRSa4mv1F0=; b=QSX433l7nIWNGLw17PraSXm7r+47I4SBdy33qfkFFYcrwJd5X0gAl0NuHJxcAak69J fa8JEy2xfGn1vv4QuCzp/3QIoSntV2J8gy+1Lswo7axWrioJoV7BchpKZxrTXDZjATjQ E2LQRazB9sIFc2X2bQsz6bctsV0oTer4OZ8/hZlLKVlrLAmkUmCaL9GMa5rHP3fk3YCm +k7q+9nhYfHahYDnASPg1pteJkX8AygzLkOaAonxiDI66Ewivkgq17/qcQf3mFznJDN8 8NOdk35U++mmHlqVo83bmRjbnPjeoYlX+jcxz2Vls1O63Ds5D11otaFPJkTIeLrUkjM0 LS/Q== X-Gm-Message-State: AOJu0YySWvRQ+0TzZm2wEjjQhcH4u+a8bx6PmQM32b9A7IXXSfKnOq1F yx2ciASZ+3fe5QlOPWQdixprKVzg8FpI4Q== X-Received: by 2002:a05:6a00:214d:b0:6d9:f66a:b5f6 with SMTP id o13-20020a056a00214d00b006d9f66ab5f6mr2059083pfk.34.1703727750207; Wed, 27 Dec 2023 17:42:30 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:29 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 06/14] lib/raid6: Use CC_FLAGS_FPU for NEON CFLAGS Date: Wed, 27 Dec 2023 17:41:56 -0800 Message-ID: <20231228014220.3562640-7-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488328542612287 X-GMAIL-MSGID: 1786488328542612287 Now that CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v1) lib/raid6/Makefile | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile index 1c5420ff254e..309fea97efc6 100644 --- a/lib/raid6/Makefile +++ b/lib/raid6/Makefile @@ -33,25 +33,6 @@ CFLAGS_REMOVE_vpermxor8.o += -msoft-float endif endif -# The GCC option -ffreestanding is required in order to compile code containing -# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) -ifeq ($(CONFIG_KERNEL_MODE_NEON),y) -NEON_FLAGS := -ffreestanding -# Enable -NEON_FLAGS += -isystem $(shell $(CC) -print-file-name=include) -ifeq ($(ARCH),arm) -NEON_FLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=neon -endif -CFLAGS_recov_neon_inner.o += $(NEON_FLAGS) -ifeq ($(ARCH),arm64) -CFLAGS_REMOVE_recov_neon_inner.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon1.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon2.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon4.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon8.o += -mgeneral-regs-only -endif -endif - quiet_cmd_unroll = UNROLL $@ cmd_unroll = $(AWK) -v N=$* -f $(srctree)/$(src)/unroll.awk < $< > $@ @@ -75,10 +56,14 @@ targets += vpermxor1.c vpermxor2.c vpermxor4.c vpermxor8.c $(obj)/vpermxor%.c: $(src)/vpermxor.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -CFLAGS_neon1.o += $(NEON_FLAGS) -CFLAGS_neon2.o += $(NEON_FLAGS) -CFLAGS_neon4.o += $(NEON_FLAGS) -CFLAGS_neon8.o += $(NEON_FLAGS) +CFLAGS_neon1.o += $(CC_FLAGS_FPU) +CFLAGS_neon2.o += $(CC_FLAGS_FPU) +CFLAGS_neon4.o += $(CC_FLAGS_FPU) +CFLAGS_neon8.o += $(CC_FLAGS_FPU) +CFLAGS_REMOVE_neon1.o += $(CC_FLAGS_NO_FPU) +CFLAGS_REMOVE_neon2.o += $(CC_FLAGS_NO_FPU) +CFLAGS_REMOVE_neon4.o += $(CC_FLAGS_NO_FPU) +CFLAGS_REMOVE_neon8.o += $(CC_FLAGS_NO_FPU) targets += neon1.c neon2.c neon4.c neon8.c $(obj)/neon%.c: $(src)/neon.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) From patchwork Thu Dec 28 01:41:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183613 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1758714dyb; Wed, 27 Dec 2023 17:44:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNmY+a1+P2X6SE8IuoMLVFFm+Ywr4lAdDcvb94yeQtncQNjpPPrj9f3LsrnoIKv97vxJAZ X-Received: by 2002:a17:902:780e:b0:1d3:e3a8:19fa with SMTP id p14-20020a170902780e00b001d3e3a819famr4016432pll.74.1703727879181; Wed, 27 Dec 2023 17:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727879; cv=none; d=google.com; s=arc-20160816; b=Oo6tarWXsr1IHSN7AKD2DGbCa7KRI8+lXuIZb+aSvMCoTtfCjo0jACPo192NI4ZsJp QDo0pGRqrXq5LlLqPX6Wb89WW3GhLZkzt1ewyPlTsFGm4JX5bObGP+ZAZlMu6Y1wKKas wZQR8XseLPwjcpZhcF8MXBCFN4qR1R9H1mfBA0FkSJ6isnHeHaXJ4oNAdpKjIFJ+8/t2 T8UYQ4Mv9ndTa3Yzzv3mp1+BgniotG2H/HPqikxly0zs414/YLaTCq160vVCyexpNUo6 K216cxnM6jA+9Q3yoNc1uzDnGyGSMsjV2DLcYPCTUD74e/8XYKndUnhWyCNHLn3SgWVa SSnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=h+RheApEuJN9kaaLRvICyPNbTjOVIvY5kEzb7DbTZjA=; fh=KKHhbkk9BIzPR3bk7ePhX57mmPOUuMWk2RXQROtgr3E=; b=OxG2MWP6yAs73AFP8EWKQE3eAYJQ+gqVskJLOxuNytGZTLWndotRsam+zAUvmySKjc zocYQUlwSyPriCZrG/NFaxhal/nnlU0Aeq04Br9Kesn8/YlfavEynQ3oYh/7LSq491sK 1OMQXWbbwI9TebOgwzGQXwMdFO+fpBi8fuk/KjgP7Je8qphqp4JHcdj3Cv2wieU03ROS 74asWLvzAekK0ojzmxttrIQNNti+8N1+ZsFACmApv+o5/DyRZ8wmCBeOZRM7JXK9EVZ+ +UC19WdNICyLLsrAHRO99rzrz1CrpiOCHOROnE0loEDY0LXZAgTqcYlEgTwjs57TQpWG NEtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=HRrYqQ1M; spf=pass (google.com: domain of linux-kernel+bounces-12374-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12374-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u21-20020a170902a61500b001d3fe0117e3si8360905plq.293.2023.12.27.17.44.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:44:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12374-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=HRrYqQ1M; spf=pass (google.com: domain of linux-kernel+bounces-12374-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12374-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EAA96283F58 for ; Thu, 28 Dec 2023 01:44:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D15A847B; Thu, 28 Dec 2023 01:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="HRrYqQ1M" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 500A96FA1 for ; Thu, 28 Dec 2023 01:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3bbc648bed4so789129b6e.3 for ; Wed, 27 Dec 2023 17:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727751; x=1704332551; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h+RheApEuJN9kaaLRvICyPNbTjOVIvY5kEzb7DbTZjA=; b=HRrYqQ1M7T0XagVlhzUysvM9h33SsHQx78QCtwD64qF9ARhh6CyP41vp/N/j33EgIU mNz6+to30yKSSb20LzoHL2cPnBQD8Hc2n2kxzurBvj0nDOYXzQqmMoq4or1RxJXI7jty lGlV3AMjF4i87DGQRnIciQRHVy3TlSz+aBC1sBA0cd6Dxq2kwU9cEqdhklsKaL7Sgw0C nTj8VqriRvejZYFmTOxTOpjNwfm2Sj5TNf0N6+7dGXPqcFamMPQyJnxsott79G3oAGdl FP4CNfENvZz6Ki9qM/3kZ4rEurusCICr72v/yheVsCFvxj5reqYatDQ8gDYbwMreoMn+ dOdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727751; x=1704332551; 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=h+RheApEuJN9kaaLRvICyPNbTjOVIvY5kEzb7DbTZjA=; b=BR8U5i6huZ1yvleX2OogpmSm2/2o/nEskffRezPqW1AkzDZCH7vLY62z/Mg0ZdP/Tv 0TyKT9+4IU8lL0HSxPd3xQ3PhO5dxaYKWVrPIiSuIFAcjMh4gz4LQrFzJ4PmAISpNjNU tPG5ilJPmMnmbBT8QcDmHXdqu72NpDu5Tqgs+IBAxmUJuOqmuOv+/+Gfj/E2XNBrgzmt 9wtX3M2Kndha7cBZZrPKgWMOpBPJ5SZqUAJ+Zni6bziiV2xPro7LYvACzwI67puQ36SQ +B2q17Rkr2PsloPrWOxFkfa/Lhrj0KmV6vl11hnLEk9tLgRcMkJ3CqjUPuEnryn1ybN1 8iVg== X-Gm-Message-State: AOJu0YzzD0AKZNSbltuz6W3GEPvc8zpu57LAElh74QCnpHrcTWHu6wHb ZoQJbR/eP5hiQ1L3A76FlqNGUbQODP42rA== X-Received: by 2002:a05:6808:6544:b0:3bb:b063:1afe with SMTP id fn4-20020a056808654400b003bbb0631afemr7698441oib.113.1703727751522; Wed, 27 Dec 2023 17:42:31 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:31 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland , WANG Xuerui Subject: [PATCH v2 07/14] LoongArch: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Dec 2023 17:41:57 -0800 Message-ID: <20231228014220.3562640-8-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488164199772924 X-GMAIL-MSGID: 1786488164199772924 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 v1) 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 ee123820a476..65d4475565b8 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -15,6 +15,7 @@ config LOONGARCH select ARCH_HAS_CPU_FINALIZE_INIT 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 4ba8d67ddb09..1afe28feaba5 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -25,6 +25,9 @@ endif 32bit-emul = elf32loongarch 64bit-emul = elf64loongarch +CC_FLAGS_FPU := -mfpu=64 +CC_FLAGS_NO_FPU := -msoft-float + ifdef CONFIG_DYNAMIC_FTRACE KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY CC_FLAGS_FTRACE := -fpatchable-function-entry=2 @@ -46,7 +49,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 Thu Dec 28 01:41:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1759553dyb; Wed, 27 Dec 2023 17:47:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0RkyhmfECpOwCK8CAEnXncM3FOLCGZ4SzW3Vcr01JLXbLHsb1rq3zK0DRaFPUxGhWFUjU X-Received: by 2002:a05:6e02:3204:b0:35f:f5f8:3440 with SMTP id cd4-20020a056e02320400b0035ff5f83440mr5271784ilb.36.1703728071162; Wed, 27 Dec 2023 17:47:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703728071; cv=none; d=google.com; s=arc-20160816; b=XsKZHm+qE+Bm8D6VsruBzHeH0ajvePHrbDFuZpepkGZMaKMpXWpusVlPYjoRgh4N82 wT87hHol1TqHOoaHYkSRbz2o1zVa2N0KxI1wR+7lzZ4ccP9AdKRiPLxuUzAA9ELYUQcm 83CDJK804+lLFha07vGcwldVZuXoBZ6B6CYRs9CO6hhLvnPk9OZulzo47WENCnls+zkz 9D4EjhR5TOePnnzvTjsPobAJavzU1zHsTiTt23p7habI8JMoHiI2duymAzQ5/TQHvJWI nJ6vaDLe0F6Gr/pGRGbnd9972psk3J4qq4AtcH+IG3u2+ae5u89fev4Q78iynVaaIgzO 1D7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5FK4PuyaVW5o+fowKBsFSathMMiGJoXogQryv4/PrHo=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=BnntZWxu7p78yWyDuuUqLhNagiPV0b5Zvzv2ukOrMRiRCnl2lvtI29DiTgdsz1ebPF DIemPAiZVd/mjNvLRgiYpG4TDE2OKVAWCqfTFNbnODHjrAO0Otv3FHc64/lXH7RPZZgy 4u5FN1TPWbKpMKCjqvW1F7LWvrcpHIZNXOyvFELtNHXyKaq1u3EVEbLhfhDFsk14mBki BbLmGInL7H3S/H2/k9ZK2oqlzaNRaNlc73vwsMgmgL9R4/iECnLMnJQFdyBYHqiSVNEQ b+SFJvKh5Oz8xpykOb204/SMJFkOkC5mAWGvzVnvVGLDcl/o1Y6o60KHkgZe80Bz/Syr qotg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="A3vs/6WJ"; spf=pass (google.com: domain of linux-kernel+bounces-12375-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12375-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x15-20020a63170f000000b005b99697d854si11839513pgl.673.2023.12.27.17.47.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:47:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12375-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="A3vs/6WJ"; spf=pass (google.com: domain of linux-kernel+bounces-12375-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12375-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0D22AB23196 for ; Thu, 28 Dec 2023 01:44:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 513F98498; Thu, 28 Dec 2023 01:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="A3vs/6WJ" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6147B6FDE for ; Thu, 28 Dec 2023 01:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6d099d316a8so5281263b3a.0 for ; Wed, 27 Dec 2023 17:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727752; x=1704332552; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5FK4PuyaVW5o+fowKBsFSathMMiGJoXogQryv4/PrHo=; b=A3vs/6WJqtpqWypgk3xYBHVrxyzR+FXXJ2nkBmSRynPIfG1DxMKQsrPZDBjh3V0acI mKMM6M5ABYc4vGkyBE0QL25Te1qrX0cFdhjJBjSOrbA/7QPlLlNk0S9eVAhsrfLMbY4b nEFfJje/WknaBfQia1fQnYPbzgoA/6OVKgH7MX9uqz045O0hXqrALfB1FqYU7n4A5uEB qx9DN6tTO/7sg/4rHlxwGDfgcq986CjQrxJUP0oaVyqt0Iwfe8YBPMT+ni8s2triDgJr 1mjdgZJbfi/e7X2BGupObKbUkNSPqD0Ld2Paq7Z0LO00yT6W4Y327PD8wkZYRoldTcId rQwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727752; x=1704332552; 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=5FK4PuyaVW5o+fowKBsFSathMMiGJoXogQryv4/PrHo=; b=eg64Ef7bmhYfJCcd6bkPyaapfH34OzdNZo7OL2egOkf0tOeaQCz8IS2KrjI2HaIAsn 5GsRV6/XpAOXH2vgsED10f6NYCLVfRtOfqf72jtKhlojWBwkXTEWZeeKw0Vd76MxleR0 7dBlv9UKz5GcutGVDELPWfcrA18l4rMJHqYA0iNix6WwirT5qznpZX3b0/xmW4XKu7G8 3R9ep9THiUysVyDsieVvymwwA8+UcOfxKbm7qdF5FP8qsRU4dUMXvMZKQ7Jz/qjWgpzn yEeHBtNIfLhHv3zPrIqp2ElNCA89fEVVlA7hTjLnD3as9ekyH2PyQWBHaZJELAfPGA5M VT/A== X-Gm-Message-State: AOJu0YxJYLS9cs80AMB5mbV6Zw+IpLfqBK5e1/0G8to4JxjpVq7Lmsek dYMNHMmMkmaWCTE3q+HSrqbxg4GTkcLrVQ== X-Received: by 2002:a05:6a21:612:b0:194:f17b:f877 with SMTP id ll18-20020a056a21061200b00194f17bf877mr9226487pzb.61.1703727752746; Wed, 27 Dec 2023 17:42:32 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:32 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 08/14] powerpc: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Dec 2023 17:41:58 -0800 Message-ID: <20231228014220.3562640-9-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488365751561619 X-GMAIL-MSGID: 1786488365751561619 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. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland Acked-by: Michael Ellerman (powerpc) --- (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 6f105ee4f3cf..e96cb5b7c571 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 f19dbaa1d541..91106970a8c1 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -142,6 +142,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 @@ -163,7 +166,7 @@ asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(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 Thu Dec 28 01:41:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1759735dyb; Wed, 27 Dec 2023 17:48:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSMFVGQPaiMHTnSzK7p8UD42a7hp2GRBouRHo2SolrCmRB3KqrftQTkQLtwjsLJB65kVIL X-Received: by 2002:a05:6808:2120:b0:3b8:969e:88d7 with SMTP id r32-20020a056808212000b003b8969e88d7mr12874530oiw.6.1703728109170; Wed, 27 Dec 2023 17:48:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703728109; cv=none; d=google.com; s=arc-20160816; b=EDSjzKnsgW8uIgwrnABLCGb+6dD6iDZSXq6kUmU0d+PhsN23BoUtd/ObRWstlkxtMI UaV+hSDsS/BQaa+TCDHCFU+lnzri5p00RHpIs1SgNpTatLHNOdUN7eckH+n/0ZhESiAu wvbe0QfzrPqNj6VlWR6Z1HP1cJBAmLLkyOAq8EoSHlECunDnsQhSy58Jiv3k+Ak5a3Mr T81nEMZpzwcDIVM0MURliq8p9WQPZ6vh4Dx8Y57l2Yqt63GwtFISEVy/4tzn6cu9X5Cm A+HBLl2HOWsmhAoqV03W0SI2zk3e4Wpkfow8am0KzorXYFJ7KZw05A0yleqECMMdE+RC E2SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eH3LxR+7tKPhQkN8usVAFkK9L6kG8awbjmN4hDMh6eY=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=CgWV5QlNPeIXE30OtbQxlnepm+07rYJXXaTpNJQ9waDQ786ndfw/FjY0i/5y+87OMO khFQAkJUxFk/ogmYfv0cwc8bXhkeOaijxumgd9e+0QfWzL1ICJ5Qv0RZUyzGwAdMEmR/ oYN3jzLE6es/D80hqQMD7Tfc2+UmMWRNvQWLF1c4k1gKTRbK5hsMNliCislTWIlffMmF /y+VWeeMyaeJ7wZ5BRqXaYjHQd8tdKJSP7nn3OfoTDFLU+V76gYagWBGF90na5TKzr7r /KO21FEdG1jY7UaS9cM3FFARtLEyH+ktRJEY8G6tcuJrzUa2L5imMk3Iwy6CiTQiqkZ/ pk8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="Z/n/iW+3"; spf=pass (google.com: domain of linux-kernel+bounces-12376-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12376-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id n10-20020a056a0007ca00b006d9abd892fbsi7307034pfu.175.2023.12.27.17.48.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:48:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12376-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="Z/n/iW+3"; spf=pass (google.com: domain of linux-kernel+bounces-12376-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12376-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A9119B20E25 for ; Thu, 28 Dec 2023 01:45:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94C0EB67C; Thu, 28 Dec 2023 01:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="Z/n/iW+3" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEEE579C1 for ; Thu, 28 Dec 2023 01:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3bbd1fab03cso66679b6e.1 for ; Wed, 27 Dec 2023 17:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727754; x=1704332554; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eH3LxR+7tKPhQkN8usVAFkK9L6kG8awbjmN4hDMh6eY=; b=Z/n/iW+3C1ToV/2uNhbi4ZSe8q6Z/gPbzkXXu8cnrzriAHPGZt4UvjtjIBcf/3MaMt 9Xz20BL8KnGoureDgTLMQfXltIDR+BoI1Y+cpAjqPKWo2A7n6ovc/Yku3tWFeUo08xmB AK2stlbE92d1/vNYYO5msb5npjeM8FdrIK69vaj2e/lSTdoKPY0SwTXnA/sq1B1F7Ja5 v6scMGV9xloBsfur252Hci74HVmZdlqOoq+OMUuuq0vSpGUZpy+XVxhBcPNiDezw+EJR 07UvNiP4o+DQQtGanCI/0bezPg2MhUpGXs2OC0bBhM0LxI5wCn3/qc54CFOvXISYz3g6 ENcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727754; x=1704332554; 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=eH3LxR+7tKPhQkN8usVAFkK9L6kG8awbjmN4hDMh6eY=; b=jD9YYmIYMt+NJwqd5pCAddNFl7MF5eG9Ga/yXlZD1wIxMFtZcXSTZUMU6cqxFLCDlu s+aca6imLiJbeoNosytsI1gb43KBxA7LjF/AYrzJPVUR5EzXufNR/KmA6qpH/8KewhgY KlQjVWeu2iaIQbWZ7OJWoTRya2C29M+oZE1RvNgoHyB5zOqZaxh2EeGVGsUZsjkKXIqO lMKid5KdfRGW2rxo/QZx89OgG4HGZ8bae4rTn7KZkxn5Md2hRvaiN8nfByLtcrblOm+1 iylXNKEBPqU0/U4RhoKEmCMP2y7bn7dL8QI3IH7VjyqTvqb0E6/KwByuydNy9rgWdFum kluA== X-Gm-Message-State: AOJu0YyLuVvkAGv6dh8UuAq6FeA+21cV8cSY+FtRcONpqZOsUYI9OGxW u2yBP6bYOe/KIAshS0PNEkbxg0pzPvYReA== X-Received: by 2002:a05:6808:2204:b0:3bb:6f23:8244 with SMTP id bd4-20020a056808220400b003bb6f238244mr12160740oib.70.1703727754042; Wed, 27 Dec 2023 17:42:34 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:33 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 09/14] x86: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Dec 2023 17:41:59 -0800 Message-ID: <20231228014220.3562640-10-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488405911224179 X-GMAIL-MSGID: 1786488405911224179 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 3762f41bb092..1fe7f2d8d017 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -81,6 +81,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 1a068de12a56..71576c8dbe79 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -70,6 +70,26 @@ export BITS KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx 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 Thu Dec 28 01:42:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183614 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1758922dyb; Wed, 27 Dec 2023 17:45:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzYhiVveMThM+cEMb/hZnpUTZFWgGUlhjTlskfUs8IY+C8alMus6qjy0CVvUc8jrLiFQQ9 X-Received: by 2002:a05:620a:44c4:b0:781:7005:23b7 with SMTP id y4-20020a05620a44c400b00781700523b7mr773278qkp.134.1703727921177; Wed, 27 Dec 2023 17:45:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727921; cv=none; d=google.com; s=arc-20160816; b=jnVT9ecWnbOZPvlDb5Ul8LriCOKxW+qrnldp8+Kiuz8IHioSwAfxroJVZl3SdRQ+1o zvRY3hOM1ZpouU9VbFPevtcZiryjzvS+oCMsaSzlc6xvLfJKgDfng7t/AxT0+9xAMpHE FTw8Qi2tRuvb7a5DSdhHmjXp8ykjz83wi6iWbZTIzRov0atYxuaACvsji9JCyXppZgeb HL2OfDBrBQ/+us6ycFZe2ssQ8e25retv8/zugTZ9KYVUwXz4My3XuW9JmmL0VdELUMFC Dx3HD9nMIIVYaU1E08eEJRmWmczyeMuRusUpbNVST9llJv+hviVzwdw36DYEiYd6r0FR jG2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7lB3PwOsXsU0eA+wVy54fia689m8tbEsIcyHsrS82lA=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=Kc97cm+ZIdi5JTgtdT7iIGJwkYTJvTWkDi8DvG+ZRvr4nGi5DyN+KInPZXn6RQMxQE +/UDqvf/GmmExV561w6R+qZ8vSTLCb0aELF+7bbHhgkWmd9xL7C54QE2A+jHISfPkeRR 7Bh1fDJP/gTp5i4Vzvw5Qhl4+9SyLHMUkBbjVTV0xqS3cyNAmzrqsZ/KLJ87hZCu38jr k8kukQ9PtMx0LpAvjr/L8ptUuK0GV3LE9IYsEv2X/fD+1wy6C5LAUU9tpAW01pqLyFfz ZrvjYcGvOiuPPWHi97uWE/oGH3eDD2o9qdhcDPpjI3A5KeI0Z5+3gqvr/kLpwHXBJagg 5T0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=R36n+Nhx; spf=pass (google.com: domain of linux-kernel+bounces-12377-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12377-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t15-20020a05620a450f00b007777245a946si16612655qkp.41.2023.12.27.17.45.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:45:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12377-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=R36n+Nhx; spf=pass (google.com: domain of linux-kernel+bounces-12377-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12377-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F2C1D1C21035 for ; Thu, 28 Dec 2023 01:45:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6074BC12A; Thu, 28 Dec 2023 01:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="R36n+Nhx" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72A4563CD for ; Thu, 28 Dec 2023 01:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3bbd11777c2so97071b6e.1 for ; Wed, 27 Dec 2023 17:42:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727755; x=1704332555; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7lB3PwOsXsU0eA+wVy54fia689m8tbEsIcyHsrS82lA=; b=R36n+Nhxv2ci/t7udVXZLBbXXNdq+2qk4+dSW/KR48C9REzX+GNf1WuMlFuHzE7AJI Bt0QG4ouo5TvpSX+PpCTXpBeYh8XO2hG0TXxZJG4H2zHNHZkQGoz5mUBDiu769b5X+Xm G9Za+MuMqsJrE8IE4gJ9M1oGSTc5W7TeQin1Hml5GpqosqXr/dhyqeQ4CfK4GC3gxP4o kNtOA8oHTB6nkFG9pqDpnkAG5F+TUMxovUVHoa0yUZMUWrBD8l8mxmJIKeVMWxR1Lv09 8eaD7oFgk3Wicha4tbOy4PjIxdbVjFLLjlZ39QsF07AaEnfX8sO29FMOYW+AoftaRl+W 7T7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727755; x=1704332555; 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=7lB3PwOsXsU0eA+wVy54fia689m8tbEsIcyHsrS82lA=; b=e9uAWfbmnJ0/2TcZhdPz/G26tQHLIiVO28j50SbJ411G7hIJCZ4dPudmP3NmPp6b31 +wmaNYS+o18HSsQJrOwiSgOAIQ9DCVoAF7+p8vX3gyw8YSqkGlEigxQDaFvMK+2LIrh+ xNjer/C9lKPJ9sez7auE7I/447vKwYH0W9Msvd62y+2qh+fUuMiTUSJsUzmFjpxq86v6 Qf0Ev4LzMZMr+fd6OoAwJPExG1kPZLDaTaEwwcndsxblDdut3O7cxIUgpiqlx9BJb6cz 8zaRSbvHJcjsnrQVYnPMn9m96ob2XA7UTKL35l+TZ5sDylVSgD012g1mxBRtdtmW87TK 4gpw== X-Gm-Message-State: AOJu0YwkSShGfHDRPwVIK5WCHkOfSJEuYqft0KofHIHZLc+F8pwoVvNV 8/ywzVtYAYGfLqEVfnVbhGPqhr9AwVLQDg== X-Received: by 2002:a05:6358:9213:b0:174:cf3a:749 with SMTP id d19-20020a056358921300b00174cf3a0749mr9824262rwb.36.1703727755495; Wed, 27 Dec 2023 17:42:35 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:35 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 10/14] riscv: Add support for kernel-mode FPU Date: Wed, 27 Dec 2023 17:42:00 -0800 Message-ID: <20231228014220.3562640-11-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488208840961212 X-GMAIL-MSGID: 1786488208840961212 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. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig Reviewed-by: Palmer Dabbelt Acked-by: Palmer Dabbelt --- 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 24c1799e2ec4..4d4d1d64ce34 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 FPU select ARCH_HAS_MMIOWB select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PMEM_API diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index a74be78678eb..2e719c369210 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -81,6 +81,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 fee22a3d1b53..662c483e338d 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -62,6 +62,7 @@ obj-$(CONFIG_MMU) += vdso.o vdso/ obj-$(CONFIG_RISCV_MISALIGNED) += traps_misaligned.o obj-$(CONFIG_FPU) += fpu.o +obj-$(CONFIG_FPU) += kernel_mode_fpu.o obj-$(CONFIG_RISCV_ISA_V) += vector.o obj-$(CONFIG_SMP) += smpboot.o obj-$(CONFIG_SMP) += smp.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 Thu Dec 28 01:42:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183615 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1759069dyb; Wed, 27 Dec 2023 17:45:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpH9/OXQKbfOyd1OdaZyqRDgUA55b16/NbCTWTfFmdzlhdlUpVBQLSxT2grBwcTGluQ0UO X-Received: by 2002:a05:6a21:1507:b0:196:2fb1:8014 with SMTP id nq7-20020a056a21150700b001962fb18014mr2006120pzb.37.1703727953546; Wed, 27 Dec 2023 17:45:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727953; cv=none; d=google.com; s=arc-20160816; b=DJRb/o6kiY9aPTPO1eCBpZ2okA05ry+KuncTiavRAIalxl+ggGgglb7lhmhtcaYFM/ YhdFrLdZVw5yDufBhxyY0hDlRVBLtLpoEI1VGynI5l+Y9OLbKOtFCUfn5P9ZL6MKrW60 P7n2VauUnpJaFwE148lGAcmp1hIeWJUNiJcV18wfD1kgi0GZiU2srVORyRM92iSDPHUD ZjwN9VTIQMVA6M5FfUoY93uuq59m3N0SB2LBHQEHZtF/owNXy0PN8p7enSVc8ruZhQcj vt9fkvIFwCkRfzqIktGs3bWU1vDOi5QKIEglxZIDZgQGvOfBXLE5JPgRPTD3E1+i0GxA Av9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=g3Nao5aFqcs14j7uzTeCL4obzFSkk9OE7jeAS4fIG/k=; fh=JJk1/8XGS6rFVWVttU2E1kjrx08LqtvmAio0w7AmBuc=; b=se0L+ZG0Pn0+hTrvrD902z5pqz71+x6Kt6ghOae2JM/4oB51xLUUi++0v/PRREztBU 0xo4MjGG3yA5AroozqRt/MB++IJhiTCz84x58IajFXSOmAnD1EIfHWh+pHoczC9Zk9tw M0rmzvrIBHHltPhEzYaF5gd+YgcnBI7M5tEy9xD9VyNbOR7VgJK897wfVZMdwcW+pd4Z c5KTT3P6F66MWteX0eN0LoIbCqIOLcR0tiaBXkMkFQcHfP3qwXzeEgR0V8BuWNHzr/15 OGlbNZBe8nDX9srXSgwTjw4c8zuME3ysmf6gGXxj7+qAtmn3IqWakBstd0F/ywKIw7ao bZww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=ZFKOQfn+; spf=pass (google.com: domain of linux-kernel+bounces-12379-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12379-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id r13-20020a17090aa08d00b0028b6f9f3660si15405200pjp.133.2023.12.27.17.45.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:45:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12379-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=ZFKOQfn+; spf=pass (google.com: domain of linux-kernel+bounces-12379-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12379-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 53F6E281564 for ; Thu, 28 Dec 2023 01:45:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4DC1DF4A; Thu, 28 Dec 2023 01:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="ZFKOQfn+" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6EBE98826 for ; Thu, 28 Dec 2023 01:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6da202aa138so51999b3a.2 for ; Wed, 27 Dec 2023 17:42:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727757; x=1704332557; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g3Nao5aFqcs14j7uzTeCL4obzFSkk9OE7jeAS4fIG/k=; b=ZFKOQfn+flb1yljOg1I0thtFnTF5M53pXHXgyuZaSQmH/mp0Ou6imI43cipjv6GCTJ thz4YrX3zO6YNcBL5TWXAn22hZVlxX009H6nyYbIxqtp/9ZQRbtTdxq9SmWmgO0pMxyS ITIV2E645ndM6RY8PfHovuMyJ2cduJw9cQg8a4Vi8QLdnNS1VmZr02FZ5qAldSXxBE7L UbPZr9oOEXLweoGtkhpnbgresAYrx1D5TDV+qcDYJKqvc0ChYo2iaNEXDNH70NuCXtyG v0WX9zO4JAE3ZUnw37EPADjNso5+5QwInbAI2pczmVQoTKA5C0C56LW37ZqM+9kv/E3i Yn0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727757; x=1704332557; 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=g3Nao5aFqcs14j7uzTeCL4obzFSkk9OE7jeAS4fIG/k=; b=VjyZYGWvNDgOfVMEp4ej5mLa4tV72vUuQxL6XZ8HQsNMEru6gVnXn24ZjwQ/mqCkwt XeVtpjxjEHXw6L6FIbyu8T6NY17GRBg8krhxI88fxbfTynQQSV1IfLbPeNookQVQvj7N z6gAYExAn6PuWLf30A+tmFhYKgsw90omtudg5XEXkZ6G8EQj4MgRpIhwyqhsyMyOilVM 3yBrnsntmt8gc6xSk7NQfnrD7NTI5fLhFF+VQOexekCnqd4Zo2nW+GO2W60GCPulN8W6 PSzXsQwabfT9m5T8bfQGP6YJWXonhe7TmPzscbgyW2oP9EwIP4RX0fWYDTc/GBoEw43u M81w== X-Gm-Message-State: AOJu0YyA4aP1ehhdccoedz7PY1cawT0BINBgpFoi8vlvupZxS4PDVwSI 2sSbvm9/JluFcesUCyCivaOdr5gAW7Ia5g== X-Received: by 2002:aa7:91d5:0:b0:6d2:95d4:9c37 with SMTP id z21-20020aa791d5000000b006d295d49c37mr9390922pfa.30.1703727756811; Wed, 27 Dec 2023 17:42:36 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:36 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Michael Ellerman , Samuel Holland Subject: [PATCH v2 11/14] drm/amd/display: Only use hard-float, not altivec on powerpc Date: Wed, 27 Dec 2023 17:42:01 -0800 Message-ID: <20231228014220.3562640-12-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488242980606562 X-GMAIL-MSGID: 1786488242980606562 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 Signed-off-by: Samuel Holland --- 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 6042a5a6a44f..554c39024a40 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 Thu Dec 28 01:42:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183621 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1760005dyb; Wed, 27 Dec 2023 17:49:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IELPHHeQOISDo6TrP8a+IqA3R8v7okmcbGk67qzsONjinn0oVgyowadlSsLIus9MuqooCDv X-Received: by 2002:a05:6e02:2142:b0:360:144:f2a7 with SMTP id d2-20020a056e02214200b003600144f2a7mr6019804ilv.60.1703728166504; Wed, 27 Dec 2023 17:49:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703728166; cv=none; d=google.com; s=arc-20160816; b=ODtpI3U7E2rrL6eZg0gqSYnIuw29ZebiV7hyc3Vl+PPvj6v4Tmj/LG/d2GtwVAx5yD 470GRDyniDJPzcw0+sAnhl3VtsKhETJVJ3Y4aogFrAAA/Q4N7SMCZJt9SzV005/Vxe6j QSbwDvhZSWkY1AYf2Qx1IVHrIEHjNTo0XXfmozCmu6NqN8C6DTN+Xuwi05I7UtAtxNSL UTaBsQn1J2OazOLddoaDvG8j4cC9iyzYPl3AeR/CTn0B7+TWcKuhMCFyR0Zz8gWhC6o5 x1kfq5X/Ir2qGsBgd8Vqjl7obMUY3dnnbu/60l6JGJFmWDVdYjxlnQaZ6r5RjtRVfvRL 4+dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=C2MND6WwIohPzgleMTaIy0ci/VPA95sqr1KaUSNr79k=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=EySf+krab62amFTzr1Ky+MgnIPhd3qnBpS30ItS5g2K+hnwq73VdrErKNxW2d68xi8 3D6zdtykBH0vRBU5HM+RyJ3MJRlpu3hs1XVE4iiizJrGR9AOzpUeYt8PpMKtlf5xlqOJ aoSR1r1HAVYWrybPsZCNNAQtM6nDdMP9RViNndEmHoeme7ADpe2HvoFLYG0SEHUbdo0q zvKOgV1cxxqkJxS/DylHKL0k5WUsXp63OQKZ4Tdw7dyQNHs5Bm5JA19ZeVEb1436w+8A eK7sg/ybbl6xrkjOzFoosw94WYiw4E0NHZ+SEonMf5Wnr1UOC5BUhRE64MvO3PE7Gj2N NJrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=BelVkE1g; spf=pass (google.com: domain of linux-kernel+bounces-12378-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12378-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k186-20020a6384c3000000b005cdf89d1da3si9261677pgd.832.2023.12.27.17.49.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:49:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12378-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=BelVkE1g; spf=pass (google.com: domain of linux-kernel+bounces-12378-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12378-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D6D80B23019 for ; Thu, 28 Dec 2023 01:45:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97259DDB2; Thu, 28 Dec 2023 01:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="BelVkE1g" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A7DD8C0A for ; Thu, 28 Dec 2023 01:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6d9af1f12d5so2545809b3a.3 for ; Wed, 27 Dec 2023 17:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727758; x=1704332558; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C2MND6WwIohPzgleMTaIy0ci/VPA95sqr1KaUSNr79k=; b=BelVkE1gP+ExM/Q1wxZRzHWTPmAX9hejhcDS/DdsfhMuiNXUUN21wJ7qaIQMr2VEYw OL8jL7/1pKXo+qtIKXYSvCTglFODibzGqQv0aW8wTgo5rxdfHR1dVqPoDWLiHjAbxU1i 4duCMKJTh562W2jiY692tdqEMNub3rEK713diQW9Wa0XsuJdJGNvUM7fX8sDT6pEi6qi 62i18E65meJ/pt3+NzS6yERSy3/tMobdVf7EyoWEaHt7IOpdndlDukkW1qEm6kQFqNoK E2xupJVjmZHLjIbBdiAK3OAMw/DT5AxzLcuxqmyb2dcDFKBGTQHShJ4F+xCP2GHy5MqH tZHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727758; x=1704332558; 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=C2MND6WwIohPzgleMTaIy0ci/VPA95sqr1KaUSNr79k=; b=PqOkovbQwg6Pox9dwhUoaYKIGhD60zpjZg5N2aFkxGyeTFPCmEBG+gj/+hSBRC2Qbk 9PLKINIhPDVZ8fyJZ01TndRr94tuPomrS+5IKL+vbExM8GwhRV59h7ICr7GVl3YdaqhJ UzM68igLO1sVRaoOqfjdVT8BPNuOw4HH0M1WkhvdEyto0LRSOICS3F/GHYYAKK5k/UvU obBSANZdN+g4ULWtThPXux9FlNfDf7BVhMuGUkIMefNDfAUgZT475LT6KxX82g0c1dUO SiqDmMaTVZA2CpafQtrCiTcvljqgFnMf2na87kdo2j8Y3BQAVaOE1SwFQIYL/L0NYJp9 VUPQ== X-Gm-Message-State: AOJu0YwlmFc9IFpVtxhI9UXfztYW+smv0v8MGY1XwET45hrY/n5J0gZs mJGtDyeela2GoCh3PLDRqd0WlJNWoItKVg== X-Received: by 2002:a05:6a20:7fa9:b0:195:105d:f40f with SMTP id d41-20020a056a207fa900b00195105df40fmr11064267pzj.81.1703727758078; Wed, 27 Dec 2023 17:42:38 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:37 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 12/14] drm/amd/display: Use ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Dec 2023 17:42:02 -0800 Message-ID: <20231228014220.3562640-13-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488465871117741 X-GMAIL-MSGID: 1786488465871117741 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. Signed-off-by: Samuel Holland --- 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 554c39024a40..be15d366b786 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 Thu Dec 28 01:42:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1760234dyb; Wed, 27 Dec 2023 17:50:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnyqTANQ8dfNOI9SL7ylX7ka0iMFGNHDcDaOuTqncTrJrPTBesYJiNZYGI4JawH2YaYE8e X-Received: by 2002:a17:902:d2cb:b0:1d4:2330:85a3 with SMTP id n11-20020a170902d2cb00b001d4233085a3mr4264717plc.20.1703728203182; Wed, 27 Dec 2023 17:50:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703728203; cv=none; d=google.com; s=arc-20160816; b=S3gNNGNBZOwfuFzrSyDfcrbBPOPVi4pjq7EOnNwvHxIzqxLiyhf6YR4cFZFRz39E3g x1NWh9IwZK8Uop92TbN1NOz8MtSYjm89EQ8dQBFQv6JuSa+FdKUQCZEU0y6SGGGIPNMO 9Z1xyZr0v2nCIJqYfSPTVYixoHUQ+vGhzTKUQV61MSar9TBwzes3TMFoR8mdhzk4JXBH TzRUiTeLkNkNnVw595S0XphSW6wJVwlPZ8vgg6uYvK01MsaiEQ2Qc1pRpyB8TmTOZgro sNRRXfr6Se9kw03obN9ETIOX8HBRUklOhQ09DzWGcm3uUA3rpm1CyPIjRGAhWJNY8wlJ 2Miw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cNUGRAFHmKzY6lG9DcfUZlQ4QTwCBjkCL5t9hP4xKAE=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=oGlLh3lvNQl4Q9ySRZraITrUK1ZQrGheoI4hPlMx8GAyEq/rT4SBTxqBJkfWTVwvv4 8oxr/1BwOvIBWh/D/i53ceS1Cmi2LZd3TSaNSwDADXtc8wAnU9h40AlzxKC7NNWZNmPn sqBciyktDiKxAo3/1HmL63WGvQdYzdIbT/VAE3eHt6ShFUa6a1rsoRPot09BRFL8AYsI Z+niq4J4soTgW2pu7UDd+PK5QHAuiLRgdqhD90n8nJdo9Sjmodcl2BLFs8shzdNzbWT7 UeFGrVk30TMky3vUM+4sbqKlANbg2NAXifdDPJ9/uGkVy/QENr8WN3CbN4rG44uDbaTm vOzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=GqNicyL4; spf=pass (google.com: domain of linux-kernel+bounces-12380-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12380-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x15-20020a170902a38f00b001d38d9dee98si12076217pla.573.2023.12.27.17.50.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:50:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12380-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=GqNicyL4; spf=pass (google.com: domain of linux-kernel+bounces-12380-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12380-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E041AB230E2 for ; Thu, 28 Dec 2023 01:46:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69393AD57; Thu, 28 Dec 2023 01:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="GqNicyL4" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oo1-f48.google.com (mail-oo1-f48.google.com [209.85.161.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 301C3BE73 for ; Thu, 28 Dec 2023 01:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-oo1-f48.google.com with SMTP id 006d021491bc7-594c7241fa9so894489eaf.0 for ; Wed, 27 Dec 2023 17:42:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727759; x=1704332559; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cNUGRAFHmKzY6lG9DcfUZlQ4QTwCBjkCL5t9hP4xKAE=; b=GqNicyL4HRL32ZlN0VfuvcMGrPr8Ec3ZI1q0Dx2AbK1QdgMQxIa4SOwedFwZHhHw9o Tzge5pdNAGVg9SB4lKcOcg0OcidwWRd0niq6G5xGMv1aNRjvC9htZk5hh15tyG8mre89 emtFnBn+cWSGhdr2oeWMAoUs3EUG746eOtMqpz4jGeXcZzEOxndxUJm3yriiRhPtEJvC ySqwfWOueZNzB2unRwfUJbKuAsb2WfJWd+MYMrdOZ7AvzGpNw8LKLD+gzT2ZYl3MZnKq CVjSzOjbP379aTv718iE+AjGteQsrnO8tSJYb4OwNFRqpv12xFAhllkgBFhrTNypVpY4 M/Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727759; x=1704332559; 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=cNUGRAFHmKzY6lG9DcfUZlQ4QTwCBjkCL5t9hP4xKAE=; b=NOE1pSjXlmJjYY6D+DfmSmp2u+Uu00vgDx4k8Rs1RyiIL8Gz5lenht6GafpWIVgjXr FhJMQvFro65IDRrr02T7RuzkdeXohteoAjEK8V8wSt4dLiAlJuq0Dh4cDAJW2VIVkjMH mO2fOgeqpDiBOC12xvnKmmzNCNpXFDcT/4Ts44Yt3iiME+HGvxT4U4v7XrbRNs1lYaU2 LaZHhqJfd5YJuRs3w+K53vDhDtFi386yVRYmJroEqGBPHMGMYqTwufjA9D3AgxvwK5yH ET3E5pHOAU1xEsRUB8u/4qI2a8lBCtVD6xRQN4euTBB8/qW4UwCJjzj8gXiJoiBabWT2 L9ig== X-Gm-Message-State: AOJu0YzclPrpbkZsRatpC2oW8JKjOc3vvnYBfFVftm1BjSscCga7KGp9 dpsHvYhssPILMPCWB2fnrvqrEfA4CNclNg== X-Received: by 2002:a05:6358:3a1b:b0:172:c06c:fce3 with SMTP id g27-20020a0563583a1b00b00172c06cfce3mr5190091rwe.58.1703727759326; Wed, 27 Dec 2023 17:42:39 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:39 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 13/14] selftests/fpu: Move FP code to a separate translation unit Date: Wed, 27 Dec 2023 17:42:03 -0800 Message-ID: <20231228014220.3562640-14-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488504458198268 X-GMAIL-MSGID: 1786488504458198268 This ensures no compiler-generated floating-point code can appear outside kernel_fpu_{begin,end}() sections, and some architectures enforce this separation. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- 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 6b09731d8e61..e7cbd54944a2 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -132,7 +132,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) obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/ 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 Thu Dec 28 01:42:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 183617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1759164dyb; Wed, 27 Dec 2023 17:46:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLHbj/MOHPdnH1wuWHByE8gn5HJ7fK1QNpQYR6gk8IycRhcK7YJrDn95LlFBppYsaJzzSs X-Received: by 2002:a05:651c:b12:b0:2cc:c70f:de47 with SMTP id b18-20020a05651c0b1200b002ccc70fde47mr1016345ljr.159.1703727981519; Wed, 27 Dec 2023 17:46:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727981; cv=none; d=google.com; s=arc-20160816; b=NrYi4vZM+ajkpTAjdl6yxI5dZMq+Y0s/lsT4wd9LeQbe8kEGlY+lbAs/Pb/3elinUi MdmvyFnBu/N1GY0IcB5kc3i6zFP1IdF/GvpV5mOLUmpf9+Xbx3l/EZSK0JueDt7IVd2r dPIwUzKMi0XV7kM2sMt/S/Cw9UqxdRArVv8SRY7/+vRHsWeN6k8+8VHbN1t8Z1mzwsu4 AL+00ak7LI0864WP23GSUdlDoK+XGZGr3gx7bKgIy9MT82VYMI8Vk3sybECaMCZBFbLf yliOA8jCUAyUQo6roif4HPIFPAAgo/PHRQjcHj4ZXil3pu3faqdMkDNRFNUzu3+TSTNE Yo8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2e+fg9SOqP34XnXL5jU4pEY4/pq3fOIOqFLUTdc21ng=; fh=xcb3qhkLQEi6t+Vw3J1T1wFra1a2BdIsNlygM9Jzpag=; b=UpNwrAmxX4MyrBNCGFpkajnBZX1hjRwfx+7fTYThq888/vnmi/p8gLFN5PgKEYxOMF 8NcgGjHlJt39Ts0hwnnOdvHgF7FU2Y8GJxCkMP96WoTOCEZZ+zW5VS2NWJqbcI5dRtUK VE+MC3oKbbfm3O4jHvvUWpYw8X3sQxWJ0OyStEcio6PJOK5D2TWxxo/IxPpx1A2uJgXf nNBDHP3C8Ck4wdwGQ58OyMmKrkQIZRwIbd5SYuas8mLK3FqkaZSuh9HFbiOYeIFZoSZ6 Hm6TXqfnVsLA0X0gKc2QlaJylxnL6BZ8eGny9r+vid9YQfiZYFFyzWJ7ZAzTCD15hDuG poqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=YoxALhq0; spf=pass (google.com: domain of linux-kernel+bounces-12381-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12381-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id cm12-20020a0564020c8c00b00553ffeb0bd4si6788074edb.503.2023.12.27.17.46.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:46:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12381-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=YoxALhq0; spf=pass (google.com: domain of linux-kernel+bounces-12381-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12381-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1758F1F207BE for ; Thu, 28 Dec 2023 01:46:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F4182E57F; Thu, 28 Dec 2023 01:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="YoxALhq0" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F9BBC8DB for ; Thu, 28 Dec 2023 01:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3bba50cd318so2958095b6e.0 for ; Wed, 27 Dec 2023 17:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1703727760; x=1704332560; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2e+fg9SOqP34XnXL5jU4pEY4/pq3fOIOqFLUTdc21ng=; b=YoxALhq02Fmi9ReMVGIwjahtKjVj6kNk3VeVBawkhoMXovbiHRalWXzlXLflUC8Zqn JpeusyL00ySE9yvPdsrxVIE1hGjtqCX/llVuL1kzfPw4BESGXG8FqkZvH+2WugiBjRQX f3GCQdgPimXgPXAUs2Axo1T0UtEdI3RvHDXUrXZp/uQqVGU6LFeOoLHr7MeYknBP6j5x LQXkfpyoS22w/KJoBgKwiBRPH7eYuBRxI1ExsXOvh9OiZzPfbGkIlDifX11sH1ZZM4YR TUq1cQSSZ4moblEiXv2rxwxSxysJtBfCpfWCSX46MhP3SJtTl4kn6frXlIqOjxPUgCI9 tFfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703727760; x=1704332560; 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=2e+fg9SOqP34XnXL5jU4pEY4/pq3fOIOqFLUTdc21ng=; b=emxh7Y/vrCMk81dAc+V0duOZME1tsEUvb0d7jJNFTuZbzZfRxWkFQYA8WxlpKnkxw9 Sh6DFruU2M9Jfe1kCmc/ime6kCKT/59UgmnbbAawULmEVQ9a7UqvdpGmDc1wp4BVsgnR vdimO03ulGmRJng7IjNiCJrpXN3QSqf8QgbJjv2V+sTdOPyFbj35UEwQBT2zC6K9SO7V lsmOSVEGsyp1xiN3EIsj3P4R3fZwuMdI63MIrBl3Aeefi3ezQaKQgCDJdCxxtGjYMsmo ywSKoD0mUnINI33GTjaCABi8osNYQELOYweu50LNmBvZaMGQbA8bde4D7yALfsuBjXHY cgKw== X-Gm-Message-State: AOJu0YyB0++ToiDnPLjHIfF9KFZi2i41jossycAUN+DCq9uZVf4jHmFK WUHjMpEpK/1TFxa8zcjKyumNrmUu7ElZJw== X-Received: by 2002:a05:6808:159d:b0:3bb:76ca:f143 with SMTP id t29-20020a056808159d00b003bb76caf143mr11199985oiw.54.1703727760626; Wed, 27 Dec 2023 17:42:40 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id g24-20020aa78758000000b006d49ed3effasm7335440pfo.63.2023.12.27.17.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:42:40 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [PATCH v2 14/14] selftests/fpu: Allow building on other architectures Date: Wed, 27 Dec 2023 17:42:04 -0800 Message-ID: <20231228014220.3562640-15-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231228014220.3562640-1-samuel.holland@sifive.com> References: <20231228014220.3562640-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786488271957467880 X-GMAIL-MSGID: 1786488271957467880 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 4405f81248fb..4596100eeb14 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2918,7 +2918,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 e7cbd54944a2..b9f28558c9bd 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -109,31 +109,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) obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/ 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;