From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.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 E5C4241C9D for ; Fri, 29 Mar 2024 07:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711697090; cv=none; b=f40azOMzOfq9D1qs5hjlR4B37QzNEVceq0DfSiz6+l4XBuBTMXx9vHWryrduZ6yZ/knYSZZxBvCQK3hYkUznYPpBufJeoYsPh7P6dkNQSqgQZqcXf0dqTQhfHtt6OgB6wtyDasTbGqKcOiuGpBBbesF5hjUnCwHK4mpssNa9yIw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711697090; c=relaxed/simple; bh=D7Uft9YmOHR561uZNDC4DNCSuflFcrKCYb4nSPMUGXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N4gFE4RxfDIUK3dJiCnc8tzyeqghl2U5wzx/51/5hhXVAnUtZk/u1SyvXXEGFMiOTr86IxP2EdgRh3vVJb5hipfj6hAIHwQC9+fFK3IpaihGclm1hg9Zj6cdkZaLY7TGaIt5FMZutR0g6SCIxrIASbz/QSd2D2DFUKrpYWLhdMM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=KoClgjp9; arc=none smtp.client-ip=209.85.215.173 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="KoClgjp9" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-5d42e7ab8a9so1029646a12.3 for ; Fri, 29 Mar 2024 00:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697088; x=1712301888; darn=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=BaG/5r11zMVVbJK9XMgdhlmzZC0nXZGHxxAlEP5YrDw=; b=KoClgjp9S4ZwCpcqg/7oaqO0Ow8LKo/hRFLLXf67uuNK6lF0K1glOHNtAJ8sAL+dAh ndg07+TP6XcjlRoyjEHF9rO39I+d5JKoctXOBvs2WyuVOBmrVgBCKnRu2K5MPVJP5eZp gYd1z60CICJsvBBZHyDq1oCMq8XKGecZ0oFARdcJMHpMELxzzF4yPvQkNJC9QOHMqeTh +OIyz+a/2OQj9HvS5RoyejYnNJmS/RfQCI5Zr9S2VoAR9ka9X4hdLc3hvLBuE9GG3Ig5 Y2sOKFNev65N1AmChX0RoQFnv1DQq6tHAXg5n/YvlqRwNXSZjYrKUVCk5xkkiPYgM5vk obow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697088; x=1712301888; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BaG/5r11zMVVbJK9XMgdhlmzZC0nXZGHxxAlEP5YrDw=; b=pSVrDzs8JaNfZt9pocbAb1rGX2uxGArZ/5JCX08SXpXvUCyLMTlqLCstzKNARm1tWC USsgG40yIU7aGMR8QwWdn18NE8dManXI5+cYaEfX1/kKRL40A2lvfOA/utkRrxae/4kt GWyZccOdOwN0K0QAhC1sk1CtRqStrp2gPz2uRZCuXHje/RGKnf9R/8JwrrK1JVCVGLDo LELVzIwBbk690VIMZDlwnoDjPMggsM5abvGZ7EIMuA8drClsoli63ODyOKaEdvoYqZZ0 xAxAKm27iJe3dZo8whf8273K53yCgzSoZMJe58lrH9cVL7pVwDAbwz9Xnrj9pchnQAbd pxpQ== X-Gm-Message-State: AOJu0YzkHFwcJvvJ9GH6nDiMgphjS7mDtQ1zRbth4TZlPBFtf3zfrhi5 Kx29EhAjjibUOdLpA2HDUC+tET8haMczXzXx/S6yrSqkheVIMxhsuEBn2SGRd4A= X-Google-Smtp-Source: AGHT+IHyYuok2TNfdiOcE/l5igRa3fLGWQKdU9IqGK1Jb+NsKkae7YWqfCeB+c37aWtPbJ/1sA02qQ== X-Received: by 2002:a05:6a21:6d9f:b0:1a3:55d2:1489 with SMTP id wl31-20020a056a216d9f00b001a355d21489mr1432790pzb.7.1711697088383; Fri, 29 Mar 2024 00:24:48 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:48 -0700 (PDT) From: Samuel Holland To: Andrew Morton , linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Christoph Hellwig , loongarch@lists.linux.dev, amd-gfx@lists.freedesktop.org, Samuel Holland , Catalin Marinas , Will Deacon Subject: [PATCH v4 04/15] arm64: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:19 -0700 Message-ID: <20240329072441.591471-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit arm64 provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Remove file name from header comment arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 9 ++++++++- arch/arm64/include/asm/fpu.h | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/fpu.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7b11c98b3e84..67f0d3b5b7df 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -30,6 +30,7 @@ config ARM64 select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON select ARCH_HAS_KEEPINITRD select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 0e075d3c546b..3e863e5b0169 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -36,7 +36,14 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y) $(warning Detected assembler with broken .inst; disassembly will be unreliable) endif -KBUILD_CFLAGS += -mgeneral-regs-only \ +# The GCC option -ffreestanding is required in order to compile code containing +# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) +CC_FLAGS_FPU := -ffreestanding +# Enable +CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) +CC_FLAGS_NO_FPU := -mgeneral-regs-only + +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \ $(compat_vdso) $(cc_has_k_constraint) KBUILD_CFLAGS += $(call cc-disable-warning, psabi) KBUILD_AFLAGS += $(compat_vdso) diff --git a/arch/arm64/include/asm/fpu.h b/arch/arm64/include/asm/fpu.h new file mode 100644 index 000000000000..2ae50bdce59b --- /dev/null +++ b/arch/arm64/include/asm/fpu.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef __ASM_FPU_H +#define __ASM_FPU_H + +#include + +#define kernel_fpu_available() cpu_has_neon() +#define kernel_fpu_begin() kernel_neon_begin() +#define kernel_fpu_end() kernel_neon_end() + +#endif /* ! __ASM_FPU_H */ -- 2.44.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5DB58CD1288 for ; Fri, 29 Mar 2024 07:25:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CM93jGH0h5XmfTJj2bolxbvWOwYlPbKq/aVtHE7X8VU=; b=MtaBXAyPV8lQgm vitXyrLLOxtUZ6Op3sCK0WBN4oTcTjDST2EDEtTN/Y2KZUB8WDAIVuxNJjWWE5bvn2A5yyP6a+Qyz rnq8U6AfUvoq38LNtqlRc6sAeJ8Wmfb7na1dHkO3RTJ6xoVokBcfLQ0IybBYKPiyFN9VtiC0nyH/p cfIG3ggjQ/vQZvUWc2srQ8PRziEnaSYAguvpsqgiRlGDvbssqDmgMvimY877wvmbLdrwSCBKuwaim bgJbIBHEPbUm8Yv8x3Ma7zn7tFwTbZtTcsnAm8cxht2qZs2nau9XoNFmAJl+gmjKb6nEXCfgl2DUl yPo/bKmYKqNN0jVSMW9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6c9-0000000H8y5-1w5b; Fri, 29 Mar 2024 07:25:25 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bZ-0000000H8YQ-3Hdb for linux-riscv@lists.infradead.org; Fri, 29 Mar 2024 07:24:52 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6eac64f2205so1527615b3a.2 for ; Fri, 29 Mar 2024 00:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697088; x=1712301888; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BaG/5r11zMVVbJK9XMgdhlmzZC0nXZGHxxAlEP5YrDw=; b=ZugzDHWi72bp8dMq8uf7hcbekD7WVZIoSRbr70Hw/XPdrL2rBm0TRvz2oleMasTWli H9xVOe1azIHr59bZQhfSyM6fat7SbFMZCyzNFFMk1WIpKp7y6sbJ5myUWsh6NszUauFE q83X2SIAUVwicHLO54XORC2vqoNWwReO03lLxMgvK/FIk3oFl28BJU7kab7Y6SLmLOQW u75bTI0gyL0+eG+YI78+k1sEysRtwqZVEmOy9cKR02fButWs7tiPqUyI80YYHmCQupOX Xiq0kxZ3ac3j0uMmPcG6rJMeB+t+qDKZ+W65WMDuekBi84mcNUBbUjk1CIsDbH9f9CSY OGkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697088; x=1712301888; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BaG/5r11zMVVbJK9XMgdhlmzZC0nXZGHxxAlEP5YrDw=; b=oAlIEmyl89pz7amzEDI9eE5FooSpV1PER3itq4kbvnwc4Wi1hXErpHOl6sjDpkRrL3 87nXjVVELtOO1nnRjsGaBbMTqTZ0aHzwR/ISBzONqgF1/09f9fpZx5tslknLOjqu26lc bo+zART7uB73acabzmbe1KfCKAcUuCR+Tc1t6il+TNdPhkkPwW6wSXW01c8yvqXPD8uV G1z7UzAKNKlC8+BU52ifJ4/aBcrE6tYwJjALXT50KjIvtYh/tR7n/bAyJYZrW2nZmIOE Kj1XlaitSH3H6UaFRZWp7ACykRcaAbCY/fd7nCxzCryg00hshrvhPaYkaW9rMpe32wXG n7/g== X-Forwarded-Encrypted: i=1; AJvYcCXuHi5HSoFtBJXMOl6Z4f8wTctN2eGeNKqwmKnNvAXdFIsQFsegJ/hycIG8BgXTklhed+Ulgl4mZXlj0jeiMvrGSEdLkjxUzkoytI0DZAcs X-Gm-Message-State: AOJu0YzkOLgS4JGqslCOSRuidJkQHs1CskKaU3q8SAOvWAnXDqhBnJ+N N0sEidnoYZXDsavotCJH155yjmS/XQF8Jnvp5CiM2AZqZRki97oTmbaiUyxbM20= X-Google-Smtp-Source: AGHT+IHyYuok2TNfdiOcE/l5igRa3fLGWQKdU9IqGK1Jb+NsKkae7YWqfCeB+c37aWtPbJ/1sA02qQ== X-Received: by 2002:a05:6a21:6d9f:b0:1a3:55d2:1489 with SMTP id wl31-20020a056a216d9f00b001a355d21489mr1432790pzb.7.1711697088383; Fri, 29 Mar 2024 00:24:48 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:48 -0700 (PDT) From: Samuel Holland To: Andrew Morton , linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Christoph Hellwig , loongarch@lists.linux.dev, amd-gfx@lists.freedesktop.org, Samuel Holland , Catalin Marinas , Will Deacon Subject: [PATCH v4 04/15] arm64: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:19 -0700 Message-ID: <20240329072441.591471-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002450_154891_6A90A9BF X-CRM114-Status: GOOD ( 14.60 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org arm64 provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Remove file name from header comment arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 9 ++++++++- arch/arm64/include/asm/fpu.h | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/fpu.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7b11c98b3e84..67f0d3b5b7df 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -30,6 +30,7 @@ config ARM64 select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON select ARCH_HAS_KEEPINITRD select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 0e075d3c546b..3e863e5b0169 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -36,7 +36,14 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y) $(warning Detected assembler with broken .inst; disassembly will be unreliable) endif -KBUILD_CFLAGS += -mgeneral-regs-only \ +# The GCC option -ffreestanding is required in order to compile code containing +# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) +CC_FLAGS_FPU := -ffreestanding +# Enable +CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) +CC_FLAGS_NO_FPU := -mgeneral-regs-only + +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \ $(compat_vdso) $(cc_has_k_constraint) KBUILD_CFLAGS += $(call cc-disable-warning, psabi) KBUILD_AFLAGS += $(compat_vdso) diff --git a/arch/arm64/include/asm/fpu.h b/arch/arm64/include/asm/fpu.h new file mode 100644 index 000000000000..2ae50bdce59b --- /dev/null +++ b/arch/arm64/include/asm/fpu.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef __ASM_FPU_H +#define __ASM_FPU_H + +#include + +#define kernel_fpu_available() cpu_has_neon() +#define kernel_fpu_begin() kernel_neon_begin() +#define kernel_fpu_end() kernel_neon_end() + +#endif /* ! __ASM_FPU_H */ -- 2.44.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F21DEC6FD1F for ; Fri, 29 Mar 2024 07:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sdkabc5F7aP0ti/8QJtIDbmpbgzqaZaM4YeyyvBiCRc=; b=nuwaedOjVbvRFI uS1ced6XVMHElP80V0jNLRhK6ZznYGJdaHWfiE+zeNdsD9DJuVDqf3c2IpQas54aA29gOyreJDCG+ M+6VwS7F31dwWnimsL923K2WcOTJQY+gqEUKVBoeoBrhzgnn/pBLw+xdHyILOQwg7HepE3Q5bEKZP HXVGgW2+IlEP8OA0GJOUjfLWnjz4Ai4GJJrhMFlmiK33jtGlOsv3SOprv7+ml0Ix3HSAL5GVMbknn ciInVtGen/53+QDaVIMb+4lbpOzM763mepq4T4yWMjMNxJtWwweF/2aTpbkKmV10g8k0gOyA5BqlG 1mM/H1KJXFC1bNuh3vPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6c1-0000000H8rg-1fsN; Fri, 29 Mar 2024 07:25:17 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq6bZ-0000000H8YP-3FJ5 for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 07:24:52 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6e6c0098328so1476623b3a.3 for ; Fri, 29 Mar 2024 00:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697088; x=1712301888; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BaG/5r11zMVVbJK9XMgdhlmzZC0nXZGHxxAlEP5YrDw=; b=ZugzDHWi72bp8dMq8uf7hcbekD7WVZIoSRbr70Hw/XPdrL2rBm0TRvz2oleMasTWli H9xVOe1azIHr59bZQhfSyM6fat7SbFMZCyzNFFMk1WIpKp7y6sbJ5myUWsh6NszUauFE q83X2SIAUVwicHLO54XORC2vqoNWwReO03lLxMgvK/FIk3oFl28BJU7kab7Y6SLmLOQW u75bTI0gyL0+eG+YI78+k1sEysRtwqZVEmOy9cKR02fButWs7tiPqUyI80YYHmCQupOX Xiq0kxZ3ac3j0uMmPcG6rJMeB+t+qDKZ+W65WMDuekBi84mcNUBbUjk1CIsDbH9f9CSY OGkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697088; x=1712301888; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BaG/5r11zMVVbJK9XMgdhlmzZC0nXZGHxxAlEP5YrDw=; b=EpXVY7AWatXk2O5wwLDdvC+YC4Trqa/oLFccBMdQh9+VXzk9ii9Tc/NSKN5rGQeHOl aAnIwo3iZbGlb1zIvgfbStIvHSJ/2qZugMrQLyhDVNx3xZO12FmWRoKE/G6PGXMjhClQ wNCyGQwULFYKGKJZp5GcDckI878Yq/OMP4u94/243HvVTMXPc+DlsrYiJqaDfXWTsapa XMcmdqIpaeOaUDKw3vQEAd4sLG9F/TlKy0c90HvWixAj63k8pOCfaT/c375eBLr7pUrK Q9DPGu+ty1glztXfRxLSt5GsgWhO4yx5vj7gDi+5FRF7E2fSsJXNVR5fDSrLGlDGBkW1 HuJA== X-Forwarded-Encrypted: i=1; AJvYcCWpM31+VfElVWRT8vMkO34pSVmSxY+ZrEr7kl4S2VYBBeT4w8i3ZPIBDIZGGYJlpdj3Nwb8TRIviO+JNLyV7sQyfN794dWuDWlgNhmhoIxcM3/kakk= X-Gm-Message-State: AOJu0YzbGq+37lTWDod2yoU+fEkOlZB0bc8DZD3iitMHMFPBwXnTR6lv /e0h8RRIo+85LelV3zBbuSzjuuktHrtiLJC3vOzrfC2AgxRRvWvo56iikJ+CXM8= X-Google-Smtp-Source: AGHT+IHyYuok2TNfdiOcE/l5igRa3fLGWQKdU9IqGK1Jb+NsKkae7YWqfCeB+c37aWtPbJ/1sA02qQ== X-Received: by 2002:a05:6a21:6d9f:b0:1a3:55d2:1489 with SMTP id wl31-20020a056a216d9f00b001a355d21489mr1432790pzb.7.1711697088383; Fri, 29 Mar 2024 00:24:48 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:48 -0700 (PDT) From: Samuel Holland To: Andrew Morton , linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Christoph Hellwig , loongarch@lists.linux.dev, amd-gfx@lists.freedesktop.org, Samuel Holland , Catalin Marinas , Will Deacon Subject: [PATCH v4 04/15] arm64: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:19 -0700 Message-ID: <20240329072441.591471-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240329_002450_026947_33D0104D X-CRM114-Status: GOOD ( 15.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org arm64 provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Remove file name from header comment arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 9 ++++++++- arch/arm64/include/asm/fpu.h | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/fpu.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7b11c98b3e84..67f0d3b5b7df 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -30,6 +30,7 @@ config ARM64 select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON select ARCH_HAS_KEEPINITRD select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 0e075d3c546b..3e863e5b0169 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -36,7 +36,14 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y) $(warning Detected assembler with broken .inst; disassembly will be unreliable) endif -KBUILD_CFLAGS += -mgeneral-regs-only \ +# The GCC option -ffreestanding is required in order to compile code containing +# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) +CC_FLAGS_FPU := -ffreestanding +# Enable +CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) +CC_FLAGS_NO_FPU := -mgeneral-regs-only + +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \ $(compat_vdso) $(cc_has_k_constraint) KBUILD_CFLAGS += $(call cc-disable-warning, psabi) KBUILD_AFLAGS += $(compat_vdso) diff --git a/arch/arm64/include/asm/fpu.h b/arch/arm64/include/asm/fpu.h new file mode 100644 index 000000000000..2ae50bdce59b --- /dev/null +++ b/arch/arm64/include/asm/fpu.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef __ASM_FPU_H +#define __ASM_FPU_H + +#include + +#define kernel_fpu_available() cpu_has_neon() +#define kernel_fpu_begin() kernel_neon_begin() +#define kernel_fpu_end() kernel_neon_end() + +#endif /* ! __ASM_FPU_H */ -- 2.44.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 4B8B5CD1288 for ; Fri, 29 Mar 2024 07:28:20 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=e4vij1Lv; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4V5X7k6vPmz3vcd for ; Fri, 29 Mar 2024 18:28:18 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=e4vij1Lv; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sifive.com (client-ip=2607:f8b0:4864:20::536; helo=mail-pg1-x536.google.com; envelope-from=samuel.holland@sifive.com; receiver=lists.ozlabs.org) Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4V5X3l1CvDz3cGc for ; Fri, 29 Mar 2024 18:24:50 +1100 (AEDT) Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5d4a1e66750so1061264a12.0 for ; Fri, 29 Mar 2024 00:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711697088; x=1712301888; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BaG/5r11zMVVbJK9XMgdhlmzZC0nXZGHxxAlEP5YrDw=; b=e4vij1Lv1o0TNeR3dWHQ8j20xADz7rtNfLmgd+chFdRd22v+u2eOKv1Cp99RXuTPi/ kbfySz9HwhNpNu0T0xdfdqOvBqj1djG5MTactic0l9pd870WSDCk9OMitcaztOMLUEYx 91X6DCo3d1mwgcr6cDf+j0GwNecv5Crfu5HRPWpKmzNTj/sC/xZQAYk61x80FpweBZNG oiMnZ5g33OrrzCWuJSI4EHvX+UNKn/ANlMPyYrxdXYU1QfQTKHJRGsr6gnKgTrpGl2sd qH17QZMmy7c35HuLD6eoqz4zLs9c5ckw/b0O6IBJDDYgF7cgDM4/yOZ/wJXLJgN/ESyI YnMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711697088; x=1712301888; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BaG/5r11zMVVbJK9XMgdhlmzZC0nXZGHxxAlEP5YrDw=; b=cljtuovb+KKKF+imkbUWxOuC5g9i3A7VEnMawv24h4CIhXBLO4MvdJDEp6pLo9Y0oR TellbvhqNd4QJT/GJw3vTCzTWqkFBwqaOD+rCtVpUui092NP/NSgMCyNIQtWzXXmfAoY Lla66e4J9xuePlTZqCwxf8bvS30umBRftXBo+dBFCiwUJ2dZQGCd6cyqzpbOEwjWRsIR cz+cNx17HCjrCMyw2TcHPQeCEPjgRhQiDVCULzWHFtleNxAGbSPiPlUUtevhK6sfBe/3 9oEcx1euABQj+GbKe1S5+1HbqzzO6mvXdwgNnzcYxdhLndRhrOVSM9mgMdIbpDM8K+De s8WQ== X-Forwarded-Encrypted: i=1; AJvYcCUisJEbX5d2NjEiokJ90twueqZOsA0RxJd3qhwqMw1cA6OZDnTsz+89GwZk2i3G8BYA2WQ53pke6F6Ko1/luUKgqWZxQE7U0UqunNV2BA== X-Gm-Message-State: AOJu0YyUXFDcVJothzb3PYHlh1x4a76nsVgZWGbz8aFUO80ExSPdmPaN ICy5WOOaivOb9aTU158mEQ18G/GOsgptZtPBnYaVjN5HosJbTTLRgipV6Lv2VhY= X-Google-Smtp-Source: AGHT+IHyYuok2TNfdiOcE/l5igRa3fLGWQKdU9IqGK1Jb+NsKkae7YWqfCeB+c37aWtPbJ/1sA02qQ== X-Received: by 2002:a05:6a21:6d9f:b0:1a3:55d2:1489 with SMTP id wl31-20020a056a216d9f00b001a355d21489mr1432790pzb.7.1711697088383; Fri, 29 Mar 2024 00:24:48 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id b8-20020a17090a010800b0029ddac03effsm4971798pjb.11.2024.03.29.00.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 00:24:48 -0700 (PDT) From: Samuel Holland To: Andrew Morton , linux-arm-kernel@lists.infradead.org, x86@kernel.org Subject: [PATCH v4 04/15] arm64: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Fri, 29 Mar 2024 00:18:19 -0700 Message-ID: <20240329072441.591471-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240329072441.591471-1-samuel.holland@sifive.com> References: <20240329072441.591471-1-samuel.holland@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Will Deacon , Catalin Marinas , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Samuel Holland , loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Christoph Hellwig Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" arm64 provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. Add a wrapper header, and export CFLAGS adjustments as found in lib/raid6/Makefile. Reviewed-by: Christoph Hellwig Signed-off-by: Samuel Holland --- (no changes since v2) Changes in v2: - Remove file name from header comment arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 9 ++++++++- arch/arm64/include/asm/fpu.h | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/fpu.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7b11c98b3e84..67f0d3b5b7df 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -30,6 +30,7 @@ config ARM64 select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON select ARCH_HAS_KEEPINITRD select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 0e075d3c546b..3e863e5b0169 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -36,7 +36,14 @@ ifeq ($(CONFIG_BROKEN_GAS_INST),y) $(warning Detected assembler with broken .inst; disassembly will be unreliable) endif -KBUILD_CFLAGS += -mgeneral-regs-only \ +# The GCC option -ffreestanding is required in order to compile code containing +# ARM/NEON intrinsics in a non C99-compliant environment (such as the kernel) +CC_FLAGS_FPU := -ffreestanding +# Enable +CC_FLAGS_FPU += -isystem $(shell $(CC) -print-file-name=include) +CC_FLAGS_NO_FPU := -mgeneral-regs-only + +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) \ $(compat_vdso) $(cc_has_k_constraint) KBUILD_CFLAGS += $(call cc-disable-warning, psabi) KBUILD_AFLAGS += $(compat_vdso) diff --git a/arch/arm64/include/asm/fpu.h b/arch/arm64/include/asm/fpu.h new file mode 100644 index 000000000000..2ae50bdce59b --- /dev/null +++ b/arch/arm64/include/asm/fpu.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef __ASM_FPU_H +#define __ASM_FPU_H + +#include + +#define kernel_fpu_available() cpu_has_neon() +#define kernel_fpu_begin() kernel_neon_begin() +#define kernel_fpu_end() kernel_neon_end() + +#endif /* ! __ASM_FPU_H */ -- 2.44.0