Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp827464rba; Wed, 27 Mar 2024 13:02:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWmG+2aGvAKRcwHWk7np21BiFRaHsfEtvp5vMt704LgiB3NodMB0CBpDA6MX/yTL/N1XQadh5keXAWo6TXtoz31T1NsRlV1u5LgEHXn+A== X-Google-Smtp-Source: AGHT+IG1SkI2jyMss9hF7ZGTzDTZ9XeUYa6qpD0bVFOmQfnpzTWkDWdfvWNj+7CoiM09g5MmTie6 X-Received: by 2002:ad4:4d0c:0:b0:691:6d13:1850 with SMTP id l12-20020ad44d0c000000b006916d131850mr552794qvl.30.1711569777385; Wed, 27 Mar 2024 13:02:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711569777; cv=pass; d=google.com; s=arc-20160816; b=iFvRdIjAuVmhke3irq8Cq116ot0wWyAHRtW0aeC9TLAqLdcyKTMVfi6I+1i7k+mIrj OLDr2/MN4YIgysKAuv4X8R7tBh16Sf+o5dNOD4zAGA3HjXqaySFf5qACvuob9QAY47xn Uh75ThXZ8RPrieJIm8YzgBdj9TZ5ZRtgTW6uQYYiKpnuzkfsjHaWtUprTUGKidRnOqHY MM4JqXZ34+Ah8Dk1rHMg/nUL7fBprjjJKwt2rIf+lcoPO25AIwcgkOjZxLrJ9cW9+QSJ i9v24VBvy0rr+VI/+sdGO/TUgTb/akjkLsiNbHzyTe1WxbnjGK7TK52J6hr9+niqt1a/ JHvQ== ARC-Message-Signature: i=2; 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=7YKNt/WF/wnD0YRJEikw0HuScFyU0745kXYQrNfvXV8=; fh=H5YLR4526tEV97/NN1FGJ0zBwy5NtSB/EhH+c02r4uc=; b=abNYg3MGaR6BMxsFmMqN8s+g/pdYOo9rAiUO6UgXfPtkVv0dMgljhGRJBjVB9I/QRs olDtlKR/Wl5H29cmzjLjb/F3Ciu/Iu5b8XjNyWEfDRKGwIZ1ABxLbwT4X4S83SjHGJXp WTy8EsCryMCJXZ1OqEKUNwyQds9kCvSAn8c0PKIrWjkqnN8ENMXudfgGf1hR+yKB5Ejh xzhmKhmn+1vhppwZsL6STQA58tGb3oNVbvQ22WUgSbQHKDXGIJGdyLjpT/Izw8rBAhIW I8F91Wwsspl/w4I+hY0j9u3GXDTZBa/At1ARGOZDX5ofNgq77jN1ZK9pmQKDaEj1xUqU AVWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=kbjvTRce; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-121937-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id gu15-20020a056214260f00b00692d62023bcsi12968110qvb.591.2024.03.27.13.02.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121937-linux.lists.archive=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=kbjvTRce; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-121937-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121937-linux.lists.archive=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 24A3B1C2C177 for ; Wed, 27 Mar 2024 20:02:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A43CB153511; Wed, 27 Mar 2024 20:02:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="kbjvTRce" Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 033171534EE for ; Wed, 27 Mar 2024 20:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569726; cv=none; b=JyzfC9rrpmUvK/hyFpyPPspi12emLLilyvkjnnNgHr90F9ggvvVyvfSPEwYO8mt8KDdTvaLpDO2IV4f5qQkmtTSD1aig5HVS6a4xQPzdoz6uqjC+GBgizLoxD202OSOoSPO2mTDaTerpveqj7ochpRqRvM3PCBxDdllphIhBCm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569726; c=relaxed/simple; bh=wYz6G8q6oWeJ4Uvu53c3haCJoG+yI+ujZ5wIFjhs26U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ee1iZF+ISOax9c2gLMLOOFRiZH/UFlSYDSza412dG8lNkIWwUTFOW69WdLWZUSzJF3h+D1j+P1mWxfJVEQlaZrolWbQazKcHwCEPoRY7TfYnnFQbBLZ2nJO0dZeqtno2bc6iIEjeJF/fCq/hu6xwgaXPboNeNUJ976eYxq/cCi8= 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=kbjvTRce; arc=none smtp.client-ip=209.85.214.182 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-pl1-f182.google.com with SMTP id d9443c01a7336-1e0d8403257so2161095ad.1 for ; Wed, 27 Mar 2024 13:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1711569724; x=1712174524; 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=7YKNt/WF/wnD0YRJEikw0HuScFyU0745kXYQrNfvXV8=; b=kbjvTRceVPI80nSKlwxxQxmdyyUwEef69KmqydvyjtbVVq+36C9OakICJY0NuWVmdK m6m9vEaxaDt0YXpODh7YuzbsLw1OUrFtuiCuZuvKnYUwV/2WlIxaVsyPmKxJgn7iemtP 7nPIz/gKZ8nRT5UntUgpyJUM6Zlv3JQGu1pzlFjzqw1HYWQwM9JmrJfkIVK9YFUEPDp9 hS56XIHd4dc67gLz6WsO5u3oqf+VCP/IrpRCm1hdrZuY7T7txIyYd1nxUaNXuKX0Lh9Q d4a8d17eaUDEXWFwuW4c6Ln5SKS/lKjzXDGh7dK4oROhWWLSypjPVFBUu9CWT1C6kDFe oByg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711569724; x=1712174524; 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=7YKNt/WF/wnD0YRJEikw0HuScFyU0745kXYQrNfvXV8=; b=NEzHP/j/bLqbjd8WhR6ZLV2EoDxQAfG7JdtVY/OVln3ZFNo6dH4ZpUWoeXrK3wAv8H padHWjDIZ6xze4uVvg5Z5AoyTXu+dqlIxUYu8WS4LH/X3Yk6rvAInBLvY3Vet7hWj5pH MqHOnSkFkMZicE+DCXWqbAZ/ghnXUw5yiK4yW3rmgZEgeewD8AgwKMG+VATWcWGPHD+L vHGxLb88huIR1VXWgYqMfHp8/mGJAnJu5xKtmrROzCOaip3fkH1iiD0WUw2HhC4Aimlh KawGoL42cvtG80J1rGHoDBzfmYI/cJ6gSuppkJMNo8k83wjMbCfxzYoBcLf0ftxOC7TK diOg== X-Gm-Message-State: AOJu0Yxh8dTwV5MM97M4jGGLJh3awWDYi4MULCE2QS+TlIG3VLA5rNOk xToO7Z5aly0aZ1mFxtzjnnEN1Wdsa5XVMmUYep7gMORXlZbJ9J51Exnc8O/oAVs= X-Received: by 2002:a17:903:8c3:b0:1e0:b874:1e5f with SMTP id lk3-20020a17090308c300b001e0b8741e5fmr850196plb.65.1711569724329; Wed, 27 Mar 2024 13:02:04 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id u4-20020a170902e5c400b001dd0d0d26a4sm9446459plf.147.2024.03.27.13.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 13:02:03 -0700 (PDT) From: Samuel Holland To: Andrew Morton , linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, Christoph Hellwig , loongarch@lists.linux.dev, amd-gfx@lists.freedesktop.org, Samuel Holland , Catalin Marinas , Will Deacon Subject: [PATCH v3 04/14] arm64: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Wed, 27 Mar 2024 13:00:35 -0700 Message-ID: <20240327200157.1097089-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240327200157.1097089-1-samuel.holland@sifive.com> References: <20240327200157.1097089-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.43.1