From patchwork Fri Dec 8 05:54:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484869 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 DF026C10F04 for ; Fri, 8 Dec 2023 05:55:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OlO1KFi1pTEnk33UdyccBVptJ7kQB1sDBjuJcD1R4U8=; b=O7pfkuWqEJ+Thc I0YXHx0tOsJXl9qDbtHDHl79IkrVVZYjwbNAAg2IXF0UR9K/xDlieU3J8FS2CwyLacUR5KH6uEGN7 Nyv6OBuBVjrQgIyOPRbXrdiQuBTqZwN6So1TPHXhusuCbItdC5NYv+ruVrJpBPrtV6DwEtqSIXjy3 QEOp8K1A0ajBkuG2kCKSkUWSH0L/rIApD/sIeHwTprTVo9G6uNemsoK2tQdE8ELbb49/Y8n2bOaAa VjKie45Fe6heC4tSvWVj/HVPIubMYRf1jngwbgXaehVT1Sj0QTS78BFf1ovPZfbK4rlQ2W0inOGn8 /0P2lluw7o62W1ysXayg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpR-00EnWn-08; Fri, 08 Dec 2023 05:55:13 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpJ-00EnNV-1B for linux-riscv@lists.infradead.org; Fri, 08 Dec 2023 05:55:07 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5c5fb06b131so1246105a12.0 for ; Thu, 07 Dec 2023 21:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014904; x=1702619704; 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=cT/f+zG+eBk9GDNM3PRDRS7FWs4vWVwDUJpda1v2enk=; b=gn8TZ+6vw63q5jJ6uxwLwntyZW7WHDWYo5v5z97Tr+ZtMeL1LSOKWQOM1AOHsf7U3l haxw1KDiGZIRfJ4PXCilSMUy8klXNyrSPWdY0L+Ne63NXFJ0nxhawhfM3Gax/k+bRtNw UMp94M2N/lezt50s23w88QBPL5VKbnC64zUFNnQf8jPWhCd9SatZD6xSA7APFPmyLMa4 xBQ0BbZ2nMKsZPAcJTxmEm9RZkj+Sj7W734ODJf8eGpExsXRWnewxMJ4g6gPLgw9LUgJ KOg58PCXHvOVw6wQmIAgP1bFUfXRyKhyOJ5uHs4RXLzJ13t8HxDzpHB7107IzQ2Mb+Z+ iXfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014904; x=1702619704; 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=cT/f+zG+eBk9GDNM3PRDRS7FWs4vWVwDUJpda1v2enk=; b=ViGRgh/bdNFhnd5dm9jELuXht94JhKIfVQtznJoj7JMrEjYjSwpnlpVmB1RVXk5gYH MLIWzMjUaQXePAoA4R3x9KtLkF0wzsAu69fLHDrA0B5axbK1PVXst+7D7GL81jUYa88A z3uzaGR+UknrY+mL3ungRAutWY0RuJakOTQdU4I9f6dkc+8jmxxRY9JDcmRa68gE45SL cjrGga/BgyuE3ynIGPH966dIGWh5EAb/iszzHR3zNM+8xE8u/CH2FSQk8FAMgRt6bi0j Ct3SvpgdpU4WhdX0jdUT9mz7QOx30NR85TTd1kiMhDXFPb/GiRoxL5h2UJF/OeyMyVNc mGPw== X-Gm-Message-State: AOJu0YxAoqCcvuF6bCdtvWt+l5a83HoitVuW6z4tYjatkGGrklFdaVeN alJb9uIj/QPtA4ohRjIREi6UIQ== X-Google-Smtp-Source: AGHT+IHjHZOPQupU2gBIY1LJy6ZLE2Spe4muScdMLjHj9er/qEsoCLB+Of3eLXhwYzBMH5NUihe96w== X-Received: by 2002:a05:6a20:160a:b0:190:14d9:4797 with SMTP id l10-20020a056a20160a00b0019014d94797mr1355279pzj.4.1702014904099; Thu, 07 Dec 2023 21:55:04 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id s22-20020a170902989600b001ce5b859a59sm786250plp.305.2023.12.07.21.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:03 -0800 (PST) From: Samuel Holland To: linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-riscv@lists.infradead.org, Christoph Hellwig Cc: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arch@vger.kernel.org, Samuel Holland Subject: [RFC PATCH 01/12] arch: Add ARCH_HAS_KERNEL_FPU_SUPPORT Date: Thu, 7 Dec 2023 21:54:31 -0800 Message-ID: <20231208055501.2916202-2-samuel.holland@sifive.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231208055501.2916202-1-samuel.holland@sifive.com> References: <20231208055501.2916202-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-20231207_215505_401968_353F7E72 X-CRM114-Status: UNSURE ( 9.40 ) X-CRM114-Notice: Please train this message. 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: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Several architectures provide an API to enable the FPU and run floating-point SIMD code in kernel space. However, the function names, header locations, and semantics are inconsistent across architectures, and FPU support may be gated behind other Kconfig options. Provide a standard way for architectures to declare that kernel space FPU support is available. Architectures selecting this option must implement what is currently the most common API (kernel_fpu_begin() and kernel_fpu_end(), plus a new function kernel_fpu_available()) and provide the appropriate CFLAGS for compiling floating-point C code. Suggested-by: Christoph Hellwig Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- Makefile | 4 ++++ arch/Kconfig | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/Makefile b/Makefile index 511b5616aa41..e65c186cf2c9 100644 --- a/Makefile +++ b/Makefile @@ -969,6 +969,10 @@ KBUILD_CFLAGS += $(CC_FLAGS_CFI) export CC_FLAGS_CFI endif +# Architectures can define flags to add/remove for floating-point support +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..6df834e18e9c 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -1478,6 +1478,15 @@ 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 + An architecture should select this option if it supports running + floating-point code in kernel space. It must export the functions + kernel_fpu_available(), kernel_fpu_begin(), and kernel_fpu_end() from + , and define CC_FLAGS_FPU and/or CC_FLAGS_NO_FPU as + necessary in its Makefile. + source "kernel/gcov/Kconfig" source "scripts/gcc-plugins/Kconfig"