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: 13484855 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 7231BC4167B for ; Fri, 8 Dec 2023 05:55:36 +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=SS4tAWh8SqQA9chZ9Fu6aMSi5g50kjHNC/cJt8VLW+Q=; b=jBeE5US4BGWVK6 HRRfMvdrgypxiI6rJu+nkYWSJPYWcc9pTcPJbmqGura314YAMmXEYpHVbETu1m54oBs79CNtNKw7V Ca9pYUz5IKjpmpaO8jfzfS9aN+E6hxi6yH/wEHKhcPHqwbh+woIk1iB15QkTBWBCvn6KFn5cFh+Fk omB5R8fvbyvFDQe82gLcGsnJExO8prhv29iLU4+BQp+4rdxAT9C40RhZb/QTL93RL6pyQ/uIaiQte rUUjJYr835jP3i+hHmaH7sKc5j5J8OnXf7ObuoiCyeMtpnIUwNdsXrfBTplWjyuzSBCe5gHhKqv2h gi+PHeBtrwvLsdwstDEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpN-00EnRJ-1P; Fri, 08 Dec 2023 05:55:09 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpK-00EnNY-1I for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:07 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6ce93552cb5so1127707b3a.3 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=oajZaxOd74RapHhM5+f3DYISeTHHlwjRFzGJi6v3uHUxVn2L/IYblEzBnkdE/3b5jS PYY7/rbAHWaZx4J5JnaiVXYOysJXF51WY8NAVaXqojUm1bZsF0fGJkYXbA3XVaQ4J7ie MyJ/f8xuYIpUciOISCEgvYX9IDtt1Th8ozRcC/Xk40si2f0/BtXeYn3V1vEuvuNY+LB0 JP1wUc7uK7FOjM9MvamUGeFG98ik2mGqDKQW+6+YtBB1asnKUuARxeiPZ9Q/VTqDJ6x+ uP7sPKYC9KATplw4w0I8raXNipidEHeztqG4ctu8ebKXb+0ow94IVpXIP5BwVWz8QtDk 5mGw== X-Gm-Message-State: AOJu0YxstDgM8k+1ZOJc0wbDXkaIg7LbtkrKsYW26YPRJKfoCsDoKB7+ r0ZEEUHzydNLGReB5easSP3UXrsovRYah4AycuUjXtFAsjeJBM/ka3XvI2C62eW23mlyi2gfPMg s1F/Hq3LMZbVyph8jZ9LEMTfp1MxzaPVf/loaCzCerRBWhjggOT7sW/u/HQQd8LJwPJFfhXmnqz l7nzZMW8X9VjONXVv4sylQgYwSlg== 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_215506_442485_2314F5C2 X-CRM114-Status: GOOD ( 10.96 ) 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 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"