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: 13505552 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB865C47073 for ; Thu, 28 Dec 2023 01:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LGVK4kYsxtabXqM+GuS/d/Fa0Ha2g9g9X/u9LgM3guw=; b=XZycPHZRLiDzId 7Z0d8vcML2MJrYLt5dK+WCc9UCQB6IIpF8a45nC1Ag0C7PSmCccx/SEgPe/AbgrqIxqumt5vkFK6E 9DfU0MZWLq7IUoJlcDoGnwfTzTvgtL8Q+xHQCiYnr3m9up1mREoeAl/irN0oWKsN7j23/Mfl/ioma HtX0M41lFRFcLYh8xD/xN7duDsa/qQqoBnwDJAViePld3Q9iXRAxzmduziLmteRZHhOwj2oQdOw0j SC0huRxcWUjKAuAI85IgLMZ4qBDEUKQciJdDrmiwFw9ft6jfdLYgHXozXykyN39nx3O9SLTkbV/Dc xPW3A6UwI8TaaRnx51tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIfQG-00FsAE-0P; Thu, 28 Dec 2023 01:42:56 +0000 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIfPp-00FrkQ-1h for linux-arm-kernel@lists.infradead.org; Thu, 28 Dec 2023 01:42:31 +0000 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3bbc648bed4so789104b6e.3 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=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UB0U1us+sHbYZzCVyIg23Xjh36gyEMV3F74ABUc7NA8=; b=ey0B73bLGs8CdoU++1wQWZFhrq8xrnaNLQthryOblS1nrKtPrRTwlLyohU7WhErmIs bpDhVIEnEwzaUmlskzNaMnM8a2aCpp331gei4ymDrT4WSIAb96NMXZivOOIu4CHoG+Ge O/BwdLsobS70Udz4D3oCBXj3xz5msOTFcJAB7bDW09PC7FXGK7bma6NJY9C+Nouu/8N4 j3Po+TQcI9NJCvyG8AV/koplndX6gs6Eq01KRDAzrR5aEioB7aQGRLMZqEAsEo09BQoT U049oqGbQOwz0iHUoejbpLuSfokfsgymNZbL1TAjeq4etYa4dbngbgL+uL7v6uGqb7aN +4zA== 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=wQxbR6/PDT0WESxYXDGztEj4fk4cskZut9u2nNkEfHVbA2GfigsBOMLTDPhj+MXuGT YL3DvLZ+4nkeiEO9Hl70w6QcowskdDC4U7RrvRWj2nTz9qWaPthAPsDrFeTcNgMOIj/n uzRGf+z+S111S3LmYIkTPugZSFFnaf257xGyfK2/w06utbq7eofphxwHsZgLHjpcSHzt ZcbGlkUlalNb++3SnwnRvCgtYvGVHWZEa1hErI5VgxrMfBKTuKLauCgOIiFtj/lfkTYr UGmSXPb3vHITb6Rtk5UAj6aAuPQy7U375+ECh0DA0GWe+R8CF601Ys9rkEkepXGHGWu/ tMvg== X-Gm-Message-State: AOJu0Yxd1lZR7UPruiX6c7Y0+XnIOkOJNL5ar1ovMaZ2U9jFwhhZOaZq pco+QM7l1jB67b4pgPKA6G5z/IPVvv78/Qk/wArtYFl7FtgqJptH9w3zIWgt45AX3MHT/gNa+iZ vGjIRSNvmOSadketDsmYk/xOkY/aNbdmAdyAHyFwT7dP3F22Qlns5O3rfZ7ie9QPypRlV5dEvtx 7gaR70DdENMMbP22T1qFJM15HImnGWeTR9Vg== X-Google-Smtp-Source: AGHT+IGpivtFhMAB3UbcfS1StWXrUWSkj+hLT17JMH2Q4rov0k82hYGdvWTiR/shQbloO22mN5mO3A== 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231227_174229_611509_83781126 X-CRM114-Status: GOOD ( 14.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 */