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" From patchwork Fri Dec 8 05:54:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484856 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 8D508C10DC1 for ; Fri, 8 Dec 2023 05:55:37 +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=S4neU/V141kbfVqBwzJqbIF4TI1VzuhmAsClsO2CUho=; b=nn5JS5Q4LMs5YA v7BtaNsdNF+05+Q8wiOFNGoxIhGnVn1MCpmSd7BtWkXfRVeV9CgvT4zWAytJwJtH6eeYv3gFSI8eL ug7JGsjwgWIqhzc1GfONQ2GpcenUjGJ32Ir/TnwvrJX8Z52prYELL84SjGaYq7pHP6n8RT6Ncxs9s q9uEbKn2C5RJtWRBx75Syz9Vv4quQA+730uxf+kjKO3cdm9tv7lBYUZ3Te2PeXDaUs1bRGKdLZeEt kPODGRwgKRy2eP6/+CxwIuKIqfT9xWOVejBg7IYPsJHeAbMZuP9mykDamTcjU2s2vTvzQFSVpoGMt XHTvSZNfEgoJB1kIXDoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpO-00EnSK-2P; Fri, 08 Dec 2023 05:55:10 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpK-00EnOP-01 for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:07 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d053c45897so15616255ad.2 for ; Thu, 07 Dec 2023 21:55:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014905; x=1702619705; 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=9S9qeMKPrbOjny9ys0DNZnwzZdal5DwwFbQdO5IaRKs=; b=iqmzunOeLwgk1lT9SQdFwbptO2491/yQQa6UORyWx+L2YH3zMKH+KC32XenFjmEC/n 7cOuozzTRpoaktQ2tN/la+afhI4MITXDKMr+0A/VFIDsdeiJdC0eHWRwQQoBSxk0EH/b VSpr6bkrb/00lBwM7fN02KyHfP0q+77ZiiK2h5NiHP1vh6Uj6/0d+6SHGrI95nIl5wNN +KPM4yCQZ5zIJRCUZTWROQCI+R6bdjBMdmjFnpMYcSN0geIIDPQrn4uL1GeSDsviNZgF 4Pf3vXkS8fzWQbYjDOwhazChivO7eHBhGaMxmu/bTJCRlEBhxQoeTZP5UeXLSjRlqNZi xfZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014905; x=1702619705; 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=9S9qeMKPrbOjny9ys0DNZnwzZdal5DwwFbQdO5IaRKs=; b=Y9afgMeK+mArw9DDsXWNYg8yMPm5/riwu6oQLA3XLJJz9HHM2EzoGauaMvo2PV23nP E07NXxetguxPxrUn4/SNs3qcAxyYenDd+L1zcdTHj+wizyxxuOSkNzoYwSvqf6ptudpK onFkvw2HWma1ZLk3EV0f69I/o6oCGWpKQWry3shmPlgzo8RHlsQYWlxzfAFnx0MUknoD bL/+i5uxQj6Su58pRi4LK8tJYndjQeg9k3OZzfW0R9igm1zG06aD6D5Ch00C8WeTRjFj BK/eyX9KbI3zKEGhpKPEqguTSy5GONdzvnZ5hhg5QUcowTPvZ8KSwOQprKycyHb+Z9l1 Hh8A== X-Gm-Message-State: AOJu0YyO0Ls9VcdJLGQPwcXoDRAdtH+DklL/Kv46AqNzVLcn/h0vMa2L vq6eP2xpm6vO1W1sOh5lAhy4XSm31GxVBY4k8Jy/OyrsiPxo19gNAWssn8MP4cQyNYpmoddJHf3 Ga3+IMWI0rZLvjIxKir1dpjpn9oIS2JeqCDcRxJh18+ImHYi7kFNrJSNwxSV9ahtjnDAAvLl0vS tpTHaw5uAypA18ff9VIDz1k0n+vQ== X-Google-Smtp-Source: AGHT+IHfVmDuQcwcTNkJBCCNyd1od5dj0sgf6cJP7ZkJkjT+CFkpOEIDhByDVUVjY+z9LFISOIDfEQ== X-Received: by 2002:a17:902:6844:b0:1cf:b190:ea07 with SMTP id f4-20020a170902684400b001cfb190ea07mr2955137pln.21.1702014905389; Thu, 07 Dec 2023 21:55:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:05 -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 02/12] ARM: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Thu, 7 Dec 2023 21:54:32 -0800 Message-ID: <20231208055501.2916202-3-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_039791_BF4F6F8D X-CRM114-Status: GOOD ( 14.77 ) 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 ARM 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. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- arch/arm/Kconfig | 1 + arch/arm/Makefile | 7 +++++++ arch/arm/include/asm/fpu.h | 17 +++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 arch/arm/include/asm/fpu.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index f8567e95f98b..92e21a4a2903 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -14,6 +14,7 @@ config ARM select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_KEEPINITRD select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if KERNEL_MODE_NEON select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PTE_SPECIAL if ARM_LPAE diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 5ba42f69f8ce..1dd860dba5f5 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -130,6 +130,13 @@ endif # Accept old syntax despite ".syntax unified" AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W) +# 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_FPU += -march=armv7-a -mfloat-abi=softfp -mfpu=neon + ifeq ($(CONFIG_THUMB2_KERNEL),y) CFLAGS_ISA :=-Wa,-mimplicit-it=always $(AFLAGS_NOWARN) AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb diff --git a/arch/arm/include/asm/fpu.h b/arch/arm/include/asm/fpu.h new file mode 100644 index 000000000000..d01ca06e700a --- /dev/null +++ b/arch/arm/include/asm/fpu.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * linux/arch/arm/include/asm/fpu.h + * + * 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 */ From patchwork Fri Dec 8 05:54:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484858 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 C66A8C4167B for ; Fri, 8 Dec 2023 05:55:45 +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=pNbE395wXVZwO71WdEjWsTpaJfCtJbfudppet5uMF/M=; b=UwkuUp2t1em9Vb VShI0RO7k0fbGfhNBqS4lwkLYxsDJ6AUpPbpychgjytmZ7YeHtKpvy4+FPAjx7jXa23373pfibWZ5 OWuJeAMfZox7gyfOFv6ouCax800bkEpf0KDX5IHhML9iwCxmG/Ab1Oy7D29ZDbGiJD17vzp7nK9tO Vc1KhQ85/hclr2t+cYb3bZLKizemOzG3UzgabVx9VH5vb/8p4Te93xTTdFoFX+fdjG0GTxD+7TNi5 BfEUetMzAc4p5dt4xAKzCIs2zOeGZqcu6VmSszufEPvYrCT89SLU+QAu/gZU3eLVr8mg9CQCqAnrG NwaPuZlqoiXUckLfkJ9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpY-00EnfI-1Y; Fri, 08 Dec 2023 05:55:20 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpL-00EnPQ-2m for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:09 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d0c93b1173so12966655ad.2 for ; Thu, 07 Dec 2023 21:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014907; x=1702619707; 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=LqG7sh4TEQnomN1Pb8iughMffScuejFKYmgaMeTCLmM=; b=FUHitHthdPM0jUOqBAITOp7ZE4hy/7jS9KjMvWwt1k69wh2KFP+BoAD1/moVwGnCa6 L3bKuSAtBQx1TKQnNkVOUtT9czkIZwiEUbDNa6jstTgc8EtkO2qepBPO/BVZVnMX5aut W/t+uYEn6w/CgWJg4E1mZTQ2YTy5MvpAoZiJ6GIVQeFmkdf7OdU8Xpfb+tGzSlvwFVYp EYwtT6N+RRD35OnFNpNzzWrs4Gwn0DE4gyI2MEX7f6Xvr3sHMDGu+F7XcCMPf0MO4i9W aBm4CVp6lvl2nfjH6FSbCdl+Bhf7edazvwBUJzlsP2whZL+TmM+1As5vi/meO7MzJUET 8p8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014907; x=1702619707; 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=LqG7sh4TEQnomN1Pb8iughMffScuejFKYmgaMeTCLmM=; b=hB5K/L1PQC4FvYzMt6+IZPgb9AxMHEC24FPRbjaN2o1zws8DQoBP11S5PNJ5nPhQ+z /It2InEYbaxNg1XvU8sdfViYH4xKb9G2N6RqudR9/jqIYm6XK9a+k+GZRSMw6xQ66+p/ jtsyXLRoo6y9sZWsaZZINS9h7xWfHln2LDKCf2O2wgeZRjcb0/j+OtFGFGWH3/41GD3G Y03mWgTJyvM/lPTkkvuC5T3p4YKhD7t9lmas20oeXY/RpOAHD1kuytJqKFh86uu4rT+p 6o4LnfC1KXeQF/m1ijWgWujIxp9fnCVsDJRBUIRcpA7p8uXNqxzjrpiyArUy6d3gyJyy 5BBw== X-Gm-Message-State: AOJu0Yy08V1h4zJhXO6WgFy3a11ACYrY6/n0T/0DxESG8bxLzyM8pv+/ qSzg1ULfa0oGBLHgyxmLy/X2ZwHjgnId1Aoy39vuVHQ2zxmOJIP/WETsShPKZR9RwprcocvhuNK AXTUTBpbpDrGULqSBmajdqeuie60C20TgWkPuhUVm0XfZf5UKbJNS8T8gkdDEcpgQQUbkbtDXc+ D7txj83cqmjeUxgSnTFqNvFZg8ug== X-Google-Smtp-Source: AGHT+IFmoFC5Jy7QDutaZzebMhgROVCbFnFB+FkSDZrKf0b9QQV81pWWj0y7Aq09xAemAJ7UXgVmYQ== X-Received: by 2002:a17:902:ee45:b0:1d0:6ffd:f205 with SMTP id 5-20020a170902ee4500b001d06ffdf205mr3064563plo.91.1702014906581; Thu, 07 Dec 2023 21:55:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:06 -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 03/12] ARM: crypto: Use CC_FLAGS_FPU for NEON CFLAGS Date: Thu, 7 Dec 2023 21:54:33 -0800 Message-ID: <20231208055501.2916202-4-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_215507_928194_C68F2821 X-CRM114-Status: GOOD ( 11.16 ) 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 Now that CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- arch/arm/lib/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 650404be6768..0ca5aae1bcc3 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -40,8 +40,7 @@ $(obj)/csumpartialcopy.o: $(obj)/csumpartialcopygeneric.S $(obj)/csumpartialcopyuser.o: $(obj)/csumpartialcopygeneric.S ifeq ($(CONFIG_KERNEL_MODE_NEON),y) - NEON_FLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon - CFLAGS_xor-neon.o += $(NEON_FLAGS) + CFLAGS_xor-neon.o += $(CC_FLAGS_FPU) obj-$(CONFIG_XOR_BLOCKS) += xor-neon.o endif From patchwork Fri Dec 8 05:54:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484859 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 564CDC4167B for ; Fri, 8 Dec 2023 05:55:55 +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=WeXbLoKw0xf8h7SqABPokBLWNryVp8DR7U9Kidnpbo8=; b=iyJphzZcFm6SM2 yihL4pcRmZXhj9WqTtin3LKA+hDO1exnjHv2rg1t/EGlfmYzDBRG3YBpE2fD6mtgVOCHUpLoRLtLO MC1Dcx2pibKmgTFRJwbz/2ZEyEHb+VEkhbFNd27f5JFTNjvzKJ44jZvJfn+yM0yBK8/zjexYCiccQ wZr6xgqhGfkJA0SUfoXUfyofv4o8MOfnvRLBYD0mww/ClXzxAFd/Lhacft+VB+0s9669YeGBI6/MG mzLxTUgfGnTcrygg3yTV1XwttbGpXxe1rJXvRhYm6v3O1TUHF1BQ9/NIRilIvWOxkKLqknJBphxCI mj+zTw6jjX45ZSQ8/Hgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpe-00EnlZ-22; Fri, 08 Dec 2023 05:55:26 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpN-00EnQl-1P for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:12 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d05212a7c5so13051855ad.0 for ; Thu, 07 Dec 2023 21:55:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014908; x=1702619708; 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=y10I6kBvaoBdzCYCMFFIBpivZ4OdHpoiZkoWcSRPSMo=; b=ihAzJkk1CpMOsE8CwCCHPo6ViaiJB4JJcWi8p8hMefoECJPC+TzA/x1aPFN0CC82yl qtXmvgdUZxgAlP4AC00vPtWdyLsoJjOIXsebFXmxVaJoRmoZTybBArDYvT+Bc7HkeogE JJFX+thnd/89OCp7ZbDBXMf1QUcD/wSP5PSU4eU07pODSJqCodrwY0Jp9LPWlDBBtol1 MeTG8QnCGYQiWTYiiOjrhxw6Sd2dL/Si0eEw4kN9dvzAF6h9OHJKfpzy9CXagRRJ+EuC 1iQXoKhs8O8QXADOLlUHDysxv8sOw55jyc7pqFZScVlEER7BMd/QZU0dR8Iyya8IB9CY PGBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014908; x=1702619708; 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=y10I6kBvaoBdzCYCMFFIBpivZ4OdHpoiZkoWcSRPSMo=; b=hcyfvs1UUuE9mxI3bGHY3t6VZ4TV7CeRl35y1dRxHArkz7XG8sehDBsO0mIOAfywQo nXj3WBXlvvJZRLoyL1yvzCmHF5uJW6OMR828wD+CugfjJZwtp12MRFHxpS9gFz78vkb5 E6JBYOYmYfzx4rFVGoEMa6Ng0T/nkTS8UtSNHk7bFOuSfZS3OoUE2UW12NLXLwVzXqRW 5TPyTx9VykkLLGD5+PyYeIJVHXkAHCxGSWhLAPNOBzjQUZdCLO78lqlGM3h9NZBdGGA7 CCsI/gjQP1hkwn/+YuUpUbExhc9fp5cnDNNhnLx6TNRS9Xs7MFC9BDKHnTVDsIHjbfzE 10Ig== X-Gm-Message-State: AOJu0Yw+0/06XUlkxpr4B2tp4+za5vr0HfwtI1OrINd2GxPiSzp8Q4q0 XuS5CLjHJOGdJmFjXGTi5jjd82BNtd81IiwntfIdB0qXfo8aXB3tLw2uGCV2V7klJSgH/TwGEGG bmxVZErf8+fvfnC1tVVrBiDQokNIK202DBZjf12T9+QA4HtiOMW/4J72iDGSRSZnp3MD7kTDB+j /++PsLYbikwo70AmLVTyH3XuMBzA== X-Google-Smtp-Source: AGHT+IEV61WWeWMu7V3217Zpahk/hLH31IwX3YH3+NDaZQD5K6JU/sf2eERQjPEIU9FeQqZ//wlz9w== X-Received: by 2002:a17:903:983:b0:1d0:bba1:57c1 with SMTP id mb3-20020a170903098300b001d0bba157c1mr3658032plb.78.1702014907827; Thu, 07 Dec 2023 21:55:07 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:07 -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 04/12] arm64: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Thu, 7 Dec 2023 21:54:34 -0800 Message-ID: <20231208055501.2916202-5-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_215509_474696_9495FE51 X-CRM114-Status: GOOD ( 14.39 ) 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. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- arch/arm64/Kconfig | 1 + arch/arm64/Makefile | 9 ++++++++- arch/arm64/include/asm/fpu.h | 17 +++++++++++++++++ 3 files changed, 26 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..664c0a192ab1 --- /dev/null +++ b/arch/arm64/include/asm/fpu.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * linux/arch/arm64/include/asm/fpu.h + * + * 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 */ From patchwork Fri Dec 8 05:54:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484860 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 6EBC3C10F07 for ; Fri, 8 Dec 2023 05:55:57 +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=x52gPLmBbBjDuRjXx8rCw1yK1kwTormyoSZJVwihxqw=; b=MKFRhoxShdrwGr G27xIkOyfIB5raQNC+8s9jAIh91lR/TwOwdM819/x9JePreG/EbM9jnDp64rJ21A3u2nFL/lro6OG xRuQ1ib0iTcH2MNYbgrzPyzAtSiVIZqHxPcV2p/X5ylWBoIgD6JwL+Vstb64n5t90uoivwucaKzuF 0lqkstwJbKM+jhTSDVKWIrTBuEuSKckYdv1BieVqFpHp/rRz0IGhjpwE1ZUEazCCT35fAoP+rmpeR bhbor+ovawSouYopSQ3wXFRIoKqD6T/5BpDidarIU8xlsTTbkeiwNFrIqCVUT9GunNz3SLU877q+5 UoN207x21r/LyfPYD0tA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpd-00Enjn-0w; Fri, 08 Dec 2023 05:55:25 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpO-00EnRY-0C for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:12 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6ce94f62806so1087045b3a.1 for ; Thu, 07 Dec 2023 21:55:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014909; x=1702619709; 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=oJ/tAo5hDwQPfRruz9afcRfXvkx00dxKddYKFVNcdvc=; b=jccfBESigWBjLCt/CBzQ5AFtMf/HijF3glv6eAocD+mJ2bzBWKnookAWCkrBs2BqR5 +WzLQCEJURCdsFOHo1jG32gvs+teGNnII8qBdvveaobQ4i7bCZ7sHZtgehO8wa0MsVC9 KPQa7PqTB3EX3M8+tEO5J+Hz3+Ou8uTFhEWpGCCxsBI3dis2yzdusKDiLxBSE8DqB3Ma oJkkTvC2TZjLNsmmmxSc6Wivcj5WjpwkhobmdS2gBQYA7nFl/EK5E3JKgNU24aXaduKk 8cpTCKJhzdaXjNZWqx2N8/Yx/6J1Gz1QGeJv7siYcO5lyPF0KT0HZaLN7CAkcA9O8MQ9 HsiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014909; x=1702619709; 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=oJ/tAo5hDwQPfRruz9afcRfXvkx00dxKddYKFVNcdvc=; b=PXDx6Kn9Gm+2/8vOudHBW3pWW7yv1RLd3DJr2sxANL3DC/OnUwAm7Qm1sEP0hWzoAp 4gsqlyEVwYWAuws9/h/kgr/6DVVAJd18wyuh4jjz7Z+C45c+ds4T6OvopdzFNgO6ycR+ REFJJPRnhn2JQ2Ly9kSJqSBJCbYAhzHhNjbyUvIqUnoa9p+kzz6T/FY0ZvaO2+wvCFDn 7C3rGEo82g7IrTuCXlsiF5z1fm0qWfrjdugNK9+sICcAagTqv8sDgf5eRr3Pbxiej981 uI6wE2d9XhjgbXKjG5HlFZT8jkbkbgK6g5ru0crySm3XiChynqYB9mOrGU+ro+goFUZR RcYQ== X-Gm-Message-State: AOJu0Yzy2tA3rtPoUucq1+dZXehnU+CzHq42beQ4Cq+fKvjz/x31zIyk BA/UP+RJMb1/vglnlI1EEYnxjHbahGw2j8dsWWxBK2yYDd10QPh/mYbMIxTQ1QrafSegven8IPp Y8+/fTBPyCy9leLpDkqPrtKVC+stc/Gi/63I8paa90bqBY1XTR+4rqu24doTEwcEJb/ud/nyRzL 11nBpVwQLFxOZpDdSvaOfsdsQB0g== X-Google-Smtp-Source: AGHT+IHgMEmtold3cNsq0/10/gSamuXTn7dqDmNr7pkUJjR3cZZJuyMG6U/Bp0CgIPL33Lkbwgh+tw== X-Received: by 2002:a05:6a20:4282:b0:181:74fe:ba83 with SMTP id o2-20020a056a20428200b0018174feba83mr4264495pzj.40.1702014909013; Thu, 07 Dec 2023 21:55:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:08 -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 05/12] lib/raid6: Use CC_FLAGS_FPU for NEON CFLAGS Date: Thu, 7 Dec 2023 21:54:35 -0800 Message-ID: <20231208055501.2916202-6-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_215510_123501_CC3E874A X-CRM114-Status: GOOD ( 10.27 ) 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 Now that CC_FLAGS_FPU is exported and can be used anywhere in the source tree, use it instead of duplicating the flags here. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- lib/raid6/Makefile | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile index 1c5420ff254e..309fea97efc6 100644 --- a/lib/raid6/Makefile +++ b/lib/raid6/Makefile @@ -33,25 +33,6 @@ CFLAGS_REMOVE_vpermxor8.o += -msoft-float endif endif -# 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) -ifeq ($(CONFIG_KERNEL_MODE_NEON),y) -NEON_FLAGS := -ffreestanding -# Enable -NEON_FLAGS += -isystem $(shell $(CC) -print-file-name=include) -ifeq ($(ARCH),arm) -NEON_FLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=neon -endif -CFLAGS_recov_neon_inner.o += $(NEON_FLAGS) -ifeq ($(ARCH),arm64) -CFLAGS_REMOVE_recov_neon_inner.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon1.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon2.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon4.o += -mgeneral-regs-only -CFLAGS_REMOVE_neon8.o += -mgeneral-regs-only -endif -endif - quiet_cmd_unroll = UNROLL $@ cmd_unroll = $(AWK) -v N=$* -f $(srctree)/$(src)/unroll.awk < $< > $@ @@ -75,10 +56,14 @@ targets += vpermxor1.c vpermxor2.c vpermxor4.c vpermxor8.c $(obj)/vpermxor%.c: $(src)/vpermxor.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) -CFLAGS_neon1.o += $(NEON_FLAGS) -CFLAGS_neon2.o += $(NEON_FLAGS) -CFLAGS_neon4.o += $(NEON_FLAGS) -CFLAGS_neon8.o += $(NEON_FLAGS) +CFLAGS_neon1.o += $(CC_FLAGS_FPU) +CFLAGS_neon2.o += $(CC_FLAGS_FPU) +CFLAGS_neon4.o += $(CC_FLAGS_FPU) +CFLAGS_neon8.o += $(CC_FLAGS_FPU) +CFLAGS_REMOVE_neon1.o += $(CC_FLAGS_NO_FPU) +CFLAGS_REMOVE_neon2.o += $(CC_FLAGS_NO_FPU) +CFLAGS_REMOVE_neon4.o += $(CC_FLAGS_NO_FPU) +CFLAGS_REMOVE_neon8.o += $(CC_FLAGS_NO_FPU) targets += neon1.c neon2.c neon4.c neon8.c $(obj)/neon%.c: $(src)/neon.uc $(src)/unroll.awk FORCE $(call if_changed,unroll) From patchwork Fri Dec 8 05:54:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484862 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 0BB16C10DC1 for ; Fri, 8 Dec 2023 05:56:04 +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=rNW9QYD+WjwIeZs+jCU6v8YbgrHCuzZz9L1g3qcjwaQ=; b=c3xDD7yfPl/gFd LhcMwjtpxzhsdsaIXKEz0Bo3yUqCgXBggk7rT6Iz+4UzFbcbmsc6aGISsy+KkLH4TrrOo8xadJ/aD z4yFcTpcxZdWR/WIgzUP2jKer6d3n6m7FSKN8CPixnYkdXFXahz5Bgr3V+MJCYYTQkhJgikLwgFx2 8vQ1nK0AI6p16jqZ8+E4IRLJWxwnt197Kc3W4Z2RUoWKrFg5qAhPsPHRk9fkRl7R0zVrqg2fE86lv kBAC5QGUo04iWy06GDsuqgFi8E6H8GacbsT4MfX0SyMFUUfFu6UlMY+hf9S+8MQclXwvKotY5p5mX Z67ZODTv31Z08bMxyorg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpi-00Enpm-1G; Fri, 08 Dec 2023 05:55:30 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpP-00EnSz-03 for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:14 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d0a5422c80so15560305ad.3 for ; Thu, 07 Dec 2023 21:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014910; x=1702619710; 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=kq9/CzymS2t6cI6IAaf6StcamgWHCvrnQt5+bd0vsJ4=; b=Dzh2WQ7oy9VFsC+B7FfQdc1x5/1QNszNPAuu2N99DNxEN8zYOWaJcgO3F0NJOjnKEA aUHVFYYBbnh4eND7fiHrX9w7Lm+uxEivf5odtsxTVkavqH1m/RzGRL7OBc0ZouH/tEPY qIKHfiihfnEVtArYhxW3ScBFIoa6gArQnC/Y7EBnLaIxRPTIWwsBviBwr+bKuC3IWRK7 KqRt4Z8PAGkUXWzoRwbHXIytjevo7dsJ23AeWV7+xkuzYMm3EkZLbVA90C2VDvyYL+YX O4dGyV4PQzWu+HQrreN3Km/JkJuOR3YJumyfJ0UKdJDgRzUYG8VURCB96i+D9OkRoSt9 63MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014910; x=1702619710; 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=kq9/CzymS2t6cI6IAaf6StcamgWHCvrnQt5+bd0vsJ4=; b=L3rOu3ERozzSfE3r3qHJ98eJbMOlL4FvVcOZw6N0HlAbCc2z4onaUMVtenf1tD0FEG 1JltH64kEkZScoZPh6tJ6TWmHmwDZzJdKg3jMQL4mZ6c8fDZ5M5Rx1SlgrVBFQkRSsvh rR/zZ9MIHQsq2bvcYlmqtWwGjJT6LnU1KhIERvtoombQe/c8LLKBLwJpeGiX1T7ZDV8J MAwaiQeIX0D0Qw+4FcZNO53B7Wtg8TR3Eo72r/KbPjWqt3+Ndq24P6nlsA2YpF1RiL7l FgpbckI7Qz5RalHs1Dwvidlmfg3kssPxJDg9mLx6Dv9nxAoNhL2P1L+J3IoE6tDHBCAf 0qvA== X-Gm-Message-State: AOJu0YyVFEcVYLNc0Xuvg+K/kodlP+HKseyJr1PraErpScdvFX3cO4uK vSF4slKjcFhXhRhtZUT+j/BpCnRC+D3nOf1WF+62rEX2pgMPp3/RxbwzPou+vswYOxoUUY3fqCx cWLzsuFE/YsvPKm9zktRuz7OQ7KMdYv/TNUjjPNVOXesL/sBm7GmYGpPi3PQjpKSRRvyCjMbGrT sywGqoX/p26aUjzrdZFwBzX0Uidg== X-Google-Smtp-Source: AGHT+IHV6F7Dn38rHWvZV+XaXS58Ch7TWuC4F5MVn7OmuYlLci2zlP9Fr0nUwpZzieoBTkpnbrTn6A== X-Received: by 2002:a17:903:2290:b0:1b8:90bd:d157 with SMTP id b16-20020a170903229000b001b890bdd157mr4496557plh.26.1702014910345; Thu, 07 Dec 2023 21:55:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:09 -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 06/12] LoongArch: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Thu, 7 Dec 2023 21:54:36 -0800 Message-ID: <20231208055501.2916202-7-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_215511_066055_44455CFD X-CRM114-Status: GOOD ( 12.20 ) 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 LoongArch already provides kernel_fpu_begin() and kernel_fpu_end() in asm/fpu.h, so it only needs to add kernel_fpu_available() and export the CFLAGS adjustments. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig Acked-by: WANG Xuerui --- arch/loongarch/Kconfig | 1 + arch/loongarch/Makefile | 5 ++++- arch/loongarch/include/asm/fpu.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index ee123820a476..65d4475565b8 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -15,6 +15,7 @@ config LOONGARCH select ARCH_HAS_CPU_FINALIZE_INIT select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if CPU_HAS_FPU select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PTE_SPECIAL diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index 204b94b2e6aa..f5c4f7e921db 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -25,6 +25,9 @@ endif 32bit-emul = elf32loongarch 64bit-emul = elf64loongarch +CC_FLAGS_FPU := -mfpu=64 +CC_FLAGS_NO_FPU := -msoft-float + ifdef CONFIG_DYNAMIC_FTRACE KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY CC_FLAGS_FTRACE := -fpatchable-function-entry=2 @@ -46,7 +49,7 @@ ld-emul = $(64bit-emul) cflags-y += -mabi=lp64s endif -cflags-y += -pipe -msoft-float +cflags-y += -pipe $(CC_FLAGS_NO_FPU) LDFLAGS_vmlinux += -static -n -nostdlib # When the assembler supports explicit relocation hint, we must use it. diff --git a/arch/loongarch/include/asm/fpu.h b/arch/loongarch/include/asm/fpu.h index c2d8962fda00..3177674228f8 100644 --- a/arch/loongarch/include/asm/fpu.h +++ b/arch/loongarch/include/asm/fpu.h @@ -21,6 +21,7 @@ struct sigcontext; +#define kernel_fpu_available() cpu_has_fpu extern void kernel_fpu_begin(void); extern void kernel_fpu_end(void); From patchwork Fri Dec 8 05:54:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484861 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 A2391C10F09 for ; Fri, 8 Dec 2023 05:55:58 +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=B6gq8bj1QTWhtx8WZIBv59H5DPVvWgD/m72qD4EOPSw=; b=pcBA9sUWiNOOel U5df6y8E8PaDvSdm8JaeVUSoxmpnp2niTQL7RyS9Qsj71QZEA+zJLE4dvmw4gRYJEeoCDBEAuphzy Dx4DYUEaZ9a7DZaO8uVJPOzBLFRSIC5wcwCpvnkkJC+7iIgIF4thxbr9StptvtK4S63kWSBOn65CU nuWyRyw4CYaIt0YDTxir6HT+a5OrmBMoVf9OvGBsG4IS11OT2Y87FnWv5Nge16FYN0LyH4tpwVxA4 MowGlZ8HI8fVyPDbFFLrasCifnX9es/dHh2M/iVjXY8cAB4/rD6Kvu5K+VQWnpgqpjxY/mROe0It0 kKYbjQkkJMQBArvDGNTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpk-00EnrR-03; Fri, 08 Dec 2023 05:55:32 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpQ-00EnVJ-0Z for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:16 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d1e1edb10bso15914465ad.1 for ; Thu, 07 Dec 2023 21:55:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014911; x=1702619711; 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=+YzUuPYE3yay4aPXmYR/ZrTN/zes857jj0i/rwk/8vA=; b=lvQRBf1m4SlTAV5W3l5dZxaIt+LuC/kMu70XtARHO4hjOezNCyqOm3NcUDJW5kKXss 9EEDuDX2tH68IXPFjsPQF4NVHBJmnNBmpnrtVeON7WVsKadTzvK+IjYuKFFySxbd96hW 2N67IPfe9Jb5ZOZieowlJDPXy3uCw8/EdCtlrH7GlDmkZxOrbWsUos01dWkaRNeJRdSR C1oz2nBtd1I60ieOtqIgMw2rL7DrgkJiKgsyZedb+TzWLw9N9bv847Iqpaeb1w9auI0E W/vOML2gpZ8A6P3VUD7sr3OQTE7588sx67xaCDegLUd8MujFsS64pY3WM1ERcX3uH6gf cBzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014911; x=1702619711; 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=+YzUuPYE3yay4aPXmYR/ZrTN/zes857jj0i/rwk/8vA=; b=t4nx9kuJySxmxRP0Iq7zZ/Z7zlwRco8/YoH+wY56ZFAuhVjUZC8SJBcrt4Qs9GYHl5 6ZGRqvJUR7f4F0lgzFCS6EzbtZ443qdI/2yUU1Rakxm1aVGYDsISmmSsNkixsl2oh20i kTorf6khpIxRV0V6QkNWcifDpBYrYp62mJx6BzBstH2xBpEpwidtihFEWww9fzCuhew4 8D7LRCcOQk9NNTB5Ywtxj5E5Bxor6SU0uUOjToZ5mdcFq/JDEiP0CZiGxM8kFIxaAOw/ h8FVMYHX+jt/4kOk4FI5D8nYsi7qK90BsndW6WfUTruQiyGmIuD0OwvSz9fvrOzkTv2X +d3w== X-Gm-Message-State: AOJu0YwZOBIcrL9miZYiw95ZlsJW59DiObAwSKIldrj+f8KXA6vsp6iB BP/PR2IoYd/IOVkHzSxRziT8k/ApHBzsylOHCwri44qn5KdVgThuUdW2xJ/ZsmqGrl3rW28K8Cp IYAsD1+NI/Ljk0p7nLIaZtAY7vQ4wA5TzdwsPUaGEKaS0T4lz82/tSaVIWrhcD8ggwK2vNIIwxl nMGYYrpkZkOikCGFPLc/XmGSUrEg== X-Google-Smtp-Source: AGHT+IGkpKPNTZyORkUclzuJiqEGnd764SXTk1kHONQX0GukAsvi/MYXEyo8qWiBUacvBaveWOlV4w== X-Received: by 2002:a17:902:7e82:b0:1d0:b9f4:800f with SMTP id z2-20020a1709027e8200b001d0b9f4800fmr3698333pla.109.1702014911528; Thu, 07 Dec 2023 21:55:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:11 -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 07/12] powerpc: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Thu, 7 Dec 2023 21:54:37 -0800 Message-ID: <20231208055501.2916202-8-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_215512_261721_AB98167C X-CRM114-Status: GOOD ( 14.60 ) 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 PowerPC provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. The PowerPC API also requires a non-preemptible context. Add a wrapper header, and export the CFLAGS adjustments. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- arch/powerpc/Kconfig | 1 + arch/powerpc/Makefile | 5 ++++- arch/powerpc/include/asm/fpu.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/include/asm/fpu.h diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 6f105ee4f3cf..e96cb5b7c571 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -137,6 +137,7 @@ config PPC select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_HUGEPD if HUGETLB_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if PPC_FPU select ARCH_HAS_MEMBARRIER_CALLBACKS select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_MEMREMAP_COMPAT_ALIGN if PPC_64S_HASH_MMU diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index f19dbaa1d541..2d5f21baf6ff 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -142,6 +142,9 @@ CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD)) CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata) +CC_FLAGS_FPU := $(call cc-option,-mhard-float) +CC_FLAGS_NO_FPU += $(call cc-option,-msoft-float) + ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY @@ -163,7 +166,7 @@ asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(asinstr) KBUILD_AFLAGS += $(AFLAGS-y) -KBUILD_CFLAGS += $(call cc-option,-msoft-float) +KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU) KBUILD_CFLAGS += $(CFLAGS-y) CPP = $(CC) -E $(KBUILD_CFLAGS) diff --git a/arch/powerpc/include/asm/fpu.h b/arch/powerpc/include/asm/fpu.h new file mode 100644 index 000000000000..ca584e4bc40f --- /dev/null +++ b/arch/powerpc/include/asm/fpu.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef _ASM_POWERPC_FPU_H +#define _ASM_POWERPC_FPU_H + +#include + +#include +#include + +#define kernel_fpu_available() (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) + +static inline void kernel_fpu_begin(void) +{ + preempt_disable(); + enable_kernel_fp(); +} + +static inline void kernel_fpu_end(void) +{ + disable_kernel_fp(); + preempt_enable(); +} + +#endif /* ! _ASM_POWERPC_FPU_H */ From patchwork Fri Dec 8 05:54:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484863 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 B04C5C10F07 for ; Fri, 8 Dec 2023 05:56:05 +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=LI9z/Ogex6hXWEpCpNgljA3ydO/DHhYEc/iEycOvX0U=; b=HVtBAXT+hT+TM3 m8csaFqFomoI6hASFAPvvf+ENMVQSGx1bpl3dsJ4FKrzs8xRxT3VpebtSHNaE9zAOLgRZe2y201Dg tvZhIbJc9ijNXZrPrZweuRNtv4KYrYnck20ukip3Bn2maC+ZF44z1aipkr3R2/v2XSqAmBfVhA/Ip NlYS8m0ffBZ+oBtjyEuyDJqJl6n2gAR3I6UlzVAelP//Z4UKrxlXB3Fotcfs+sYJOyTc/ezp3iz8l dAkwf3esZYXJT6Of6iA2eptQITXAB+xCBEdVmj/tl1028eWDWuvy7+7dvl3jyLJHwrfemXchVNJLa 066/JfzOpg229S+vfxhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpk-00EnsI-2S; Fri, 08 Dec 2023 05:55:32 +0000 Received: from mail-pl1-f170.google.com ([209.85.214.170]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpR-00EnX1-33 for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:18 +0000 Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1d076ebf79cso13241855ad.1 for ; Thu, 07 Dec 2023 21:55:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014913; x=1702619713; 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=wOdH6gQ2/kSr11qF6anDkZP04y2oGGJwChsMHemqfok=; b=IaFp8F9+mFxvVuFc7NVEbd6RlGzKzTm0buK6UFviPqpmbkQNZbT16xwN2kcH6e5YcO Lp5Jv8ai0LCfTZGOkTw7LAiCil8TfCGYGeJouFXZ0X2+L4juhBojeOEQJqmf1miS+qh5 2L5F2EaZnkT2W2PIz/74804fP+3al1sxnHs37v+Ww+L3Ojh64Dy1l83v0a5CebpThA6W QHUjzkbbDENw1VGcR0FcWiH74lQ7hU7gE52p+kso+G76Sfa4ewkYZEcC1/3+cL461lTJ skWdrJKLMdvTwt/VKL+W+NHJOQggZ8en+VQ6Jd4OcuB+opSdTOeaCAwcZ5Zlbf7AQ/Y7 oJLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014913; x=1702619713; 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=wOdH6gQ2/kSr11qF6anDkZP04y2oGGJwChsMHemqfok=; b=S8xVeaOKwsigNMthkstRgJ1fGv0ji84kcNzAXr4LILUvNkeyFI1ywTinJjAQXitxfw H5ffG9enpf12CF+1N7aC9fKTzuQcog2mTQ2kGMPD81yhS7lZWq2ohCpJhgCSq7kQ2ghL rK1ZS2N+iDNtSdj4I7ekwfOK0ARLSYx5XWqJnf8TQfc6pcmNhs95LIpNSOQc5Pl6Z6Kb KLsu/1hSM8yLf616MA9dUOj/VnX4TuEJTD8qQ/m2ByrRkWSF/RhPLqnegcrSzjitLMcC PoB8B7XjLHZfUdSYltc50l28wE8Y/WsfC/GSB3Qt/6+i4SGzYeHUj28FhwEFR2Mh+YGg 6y4A== X-Gm-Message-State: AOJu0YytXjbWS8LrmGnL5J/e5HFKWEZR4uUAejDv7qDHjSGg6GwwMVaw uPUBfAfqOhQG3nu51J+0DDvBMBlfN1RU7/PMARoE+NNRrDqrUPR4Er8rP9grKFKOE9QQyd/tgOl tYm0ymwmJ/lTj4G3dpMaOdzMGDJ+LYjp9FQvcRpSAbWxkjejLRkM1MYAJvaDNePkuOaSQfBYQUF uotFzZo3Q31KaD3RXGNvgGyvVTfg== X-Google-Smtp-Source: AGHT+IF6KW8xi8WlWkg/kkkF64YaWdAU9w8XTSDFOxfj/W9T6fcHp2B4VJ43fwnOYGHYYluHTLhnIQ== X-Received: by 2002:a17:902:64d0:b0:1d2:eea4:a7d7 with SMTP id y16-20020a17090264d000b001d2eea4a7d7mr180399pli.5.1702014912711; Thu, 07 Dec 2023 21:55:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:12 -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 08/12] x86: Implement ARCH_HAS_KERNEL_FPU_SUPPORT Date: Thu, 7 Dec 2023 21:54:38 -0800 Message-ID: <20231208055501.2916202-9-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_215514_006619_C38B90E0 X-CRM114-Status: GOOD ( 15.29 ) 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 x86 already provides kernel_fpu_begin() and kernel_fpu_end(), but in a different header. Add a wrapper header, and export the CFLAGS adjustments as found in lib/Makefile. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- arch/x86/Kconfig | 1 + arch/x86/Makefile | 20 ++++++++++++++++++++ arch/x86/include/asm/fpu.h | 13 +++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 arch/x86/include/asm/fpu.h diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 3762f41bb092..1fe7f2d8d017 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -81,6 +81,7 @@ config X86 select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_KCOV if X86_64 + select ARCH_HAS_KERNEL_FPU_SUPPORT select ARCH_HAS_MEM_ENCRYPT select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 1a068de12a56..71576c8dbe79 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -70,6 +70,26 @@ export BITS KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2 +# +# CFLAGS for compiling floating point code inside the kernel. +# +CC_FLAGS_FPU := -msse -msse2 +ifdef CONFIG_CC_IS_GCC +# Stack alignment mismatch, proceed with caution. +# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 +# (8B stack alignment). +# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 +# +# The "-msse" in the first argument is there so that the +# -mpreferred-stack-boundary=3 build error: +# +# -mpreferred-stack-boundary=3 is not between 4 and 12 +# +# can be triggered. Otherwise gcc doesn't complain. +CC_FLAGS_FPU += -mhard-float +CC_FLAGS_FPU += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4) +endif + ifeq ($(CONFIG_X86_KERNEL_IBT),y) # # Kernel IBT has S_CET.NOTRACK_EN=0, as such the compilers must not generate diff --git a/arch/x86/include/asm/fpu.h b/arch/x86/include/asm/fpu.h new file mode 100644 index 000000000000..b2743fe19339 --- /dev/null +++ b/arch/x86/include/asm/fpu.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef _ASM_X86_FPU_H +#define _ASM_X86_FPU_H + +#include + +#define kernel_fpu_available() true + +#endif /* ! _ASM_X86_FPU_H */ From patchwork Fri Dec 8 05:54:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484864 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 9C336C4167B for ; Fri, 8 Dec 2023 05:56:08 +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=eVBMxIBU6bsGkW+/3Vm9pA5k4Zz03XfW8e1kIGp56Nw=; b=cBt1L/p90Bpmig wbgP2JmDlKyZg/A+w0EuwDma/j9/FLCWvz3U7WDSq7IV/z5QkLiQxrzRWS53VCJyHgQrsZCvwxG3r AvyWUqspWFaKE95vX74YQc2hkoHeYqTIhYY9mSNp0FOtYLA3fJgZ0efPz5T3/Kuekisx4mPH2hBhf RyFYWdoh6er2Ud2/ATgR8RgwmpNnsEBhsgEOu118o0/ciUa6yYx17B3+RWkkYMWgc7XryP88NJPdf wsJh0q9xmVAaDO76LDniCEGpV6oRiGvDZbU4482mF/twgDEs+iCkvk58Ya2Kmu66aV/tocPKJK1nB DHSuk37p4gEMSxikAL2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTps-00Eo13-2Q; Fri, 08 Dec 2023 05:55:40 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpS-00EnZ8-2U for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:20 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d0bcc0c313so12829745ad.3 for ; Thu, 07 Dec 2023 21:55:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014914; x=1702619714; 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=YYvZSY93/xrjeeL5ETwAXbtukKNXxCCQ4+T0woOWU40=; b=G5Q93xIFpJD7J173VGxTNQpO2GeiRevGG3aj+vPSj5YabG6GtzlW8hMcOdOAIaoPAL ydHm8T1Yrbu5jbTWMP0K6F9TBTy1QKBkqr+z/B7MsObiiaGSqrnhasxp1AlLouZypaS/ 85RH2/8Yjci+p6wUpRezSVlemCghv6rX5Lif6ihs/Ahzh3bPYr0SUvs3pAMJgliNIZvv AAXH/TmR5EFR1KLVFRT11oObBmFRTAVqnTwn6hPruy5xGeuXb/j1KB3SBmPgAJxUcbmO iHtruB5zn40R0aq7d5mClZVDpJI2D59SOpGbTf+54JvIuXAQYqMBoixmCzfOhddp1NNE 3gRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014914; x=1702619714; 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=YYvZSY93/xrjeeL5ETwAXbtukKNXxCCQ4+T0woOWU40=; b=TzbAsRbAKmX3tjC8qS7spW/8gN2MN3BnHP+quu2v41twFe4bdkU4VqE37xTPIFneP5 gGdq1K8cZmsnmELAzXrwS3+3+kPwqoVhFiIbOJB5OHOzRdBrA8zNAPvMn5DkgYiOfI1F 3fi/uQIVtoQtaMmW4jZa64H9vujMKq02TWewqZe/RtmvFXaoBB5i/Qb0eAxZypq/yoju gn8eT4RW+tpvrpqosS8kdvWUJAmp5U56jhA6nmY564F5d96+DLpsYr65/+X4MdMypmoO I30r34FP/tLRNqujfzu58GIXwAjKjNxsdpCQSwSWgWAaQLeZgK5zZDSLw7piARJcLi7h DNKA== X-Gm-Message-State: AOJu0YyAGDgALcwU1p9jtpPVuHsug/7VJMJX3z++58VWDZm+catzSBCD tnFBIVDCdI5HT6zI66MPM/TZEeonF7cjMOVPdZsB1K1hXUzLv20IOjD/PpnIKOG2sQ3ObnVoEZR 3bKi/3h8jTU9XRpMYbUxHPV0sPYTvFg0iyhxFasAAoRSmtvCa8BlwVMb1/5zbW34vrDg86ShBWr xGtONfz4BhVBujJgeco1sTvDT9GQ== X-Google-Smtp-Source: AGHT+IEX6fsur3fhby/cWKLu/7STh1pjdXEZxMWOcghK1shSxSRPNcFQAcmIt0ejFquarrBp9mMVPA== X-Received: by 2002:a17:902:e541:b0:1d0:a084:affd with SMTP id n1-20020a170902e54100b001d0a084affdmr3001010plf.73.1702014913936; Thu, 07 Dec 2023 21:55:13 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:13 -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 09/12] riscv: Add support for kernel-mode FPU Date: Thu, 7 Dec 2023 21:54:39 -0800 Message-ID: <20231208055501.2916202-10-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_215514_845776_2D040AA6 X-CRM114-Status: GOOD ( 16.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 This is motivated by the amdgpu DRM driver, which needs floating-point code to support recent hardware. That code is not performance-critical, so only provide a minimal non-preemptible implementation for now. Use a similar trick as ARM to force placing floating-point code in a separate translation unit, so it is not possible for compiler-generated floating-point code to appear outside kernel_fpu_{begin,end}(). Signed-off-by: Samuel Holland --- arch/riscv/Kconfig | 1 + arch/riscv/Makefile | 3 +++ arch/riscv/include/asm/fpu.h | 26 ++++++++++++++++++++++++++ arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/kernel_mode_fpu.c | 28 ++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 arch/riscv/include/asm/fpu.h create mode 100644 arch/riscv/kernel/kernel_mode_fpu.c diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 95a2a06acc6a..cf0967928e6d 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -27,6 +27,7 @@ config RISCV select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE select ARCH_HAS_KCOV + select ARCH_HAS_KERNEL_FPU_SUPPORT if FPU select ARCH_HAS_MMIOWB select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PMEM_API diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index a74be78678eb..2e719c369210 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -81,6 +81,9 @@ KBUILD_CFLAGS += -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64i KBUILD_AFLAGS += -march=$(riscv-march-y) +# For C code built with floating-point support, exclude V but keep F and D. +CC_FLAGS_FPU := -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)([^v_]*)v?/\1\2/') + KBUILD_CFLAGS += -mno-save-restore KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET) diff --git a/arch/riscv/include/asm/fpu.h b/arch/riscv/include/asm/fpu.h new file mode 100644 index 000000000000..8cd027acc015 --- /dev/null +++ b/arch/riscv/include/asm/fpu.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2023 SiFive + */ + +#ifndef _ASM_RISCV_FPU_H +#define _ASM_RISCV_FPU_H + +#include + +#define kernel_fpu_available() has_fpu() + +#ifdef __riscv_f + +#define kernel_fpu_begin() \ + static_assert(false, "floating-point code must use a separate translation unit") +#define kernel_fpu_end() kernel_fpu_begin() + +#else + +void kernel_fpu_begin(void); +void kernel_fpu_end(void); + +#endif + +#endif /* ! _ASM_RISCV_FPU_H */ diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index fee22a3d1b53..662c483e338d 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -62,6 +62,7 @@ obj-$(CONFIG_MMU) += vdso.o vdso/ obj-$(CONFIG_RISCV_MISALIGNED) += traps_misaligned.o obj-$(CONFIG_FPU) += fpu.o +obj-$(CONFIG_FPU) += kernel_mode_fpu.o obj-$(CONFIG_RISCV_ISA_V) += vector.o obj-$(CONFIG_SMP) += smpboot.o obj-$(CONFIG_SMP) += smp.o diff --git a/arch/riscv/kernel/kernel_mode_fpu.c b/arch/riscv/kernel/kernel_mode_fpu.c new file mode 100644 index 000000000000..9b2024cc056b --- /dev/null +++ b/arch/riscv/kernel/kernel_mode_fpu.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2023 SiFive + */ + +#include +#include + +#include +#include +#include +#include + +void kernel_fpu_begin(void) +{ + preempt_disable(); + fstate_save(current, task_pt_regs(current)); + csr_set(CSR_SSTATUS, SR_FS); +} +EXPORT_SYMBOL_GPL(kernel_fpu_begin); + +void kernel_fpu_end(void) +{ + csr_clear(CSR_SSTATUS, SR_FS); + fstate_restore(current, task_pt_regs(current)); + preempt_enable(); +} +EXPORT_SYMBOL_GPL(kernel_fpu_end); From patchwork Fri Dec 8 05:54:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484867 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 7CB0BC4167B for ; Fri, 8 Dec 2023 05:57:51 +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=x/SI9v+C2i6QajPBqykFxhRyviIPP+zkHTNa3iBcBkA=; b=USMBiNUZ2qHkQJ uvylnt54Ymr7D5BymMIkEpcEsH7283EZX6YPixdlyqOtxO5dSITUGYELC83biwdFvbncpEqaB9SG0 yXWNRzhcvqE8uxzdGp0OkBIy+06iuDujOtIxvYh8gHOd0ZN7a8ddT5sGkkCgWrSwF92aUdbgSOHqb mzLY07RmMoVIZ/3sBLg4lcDcqyOgukA7m0pjZXjpePPxD2Dn70I5UPPAq0c0l0rZkoyrYkVcA1BOI /zJ5HW+71w8GBfpQuk9AsTtOzk+0kDbGMe7X8RoyiJBMDePAaOkOnde+24mehoa2LrFPXx/ZBoGW8 rvglecAxfFGJcfdlOG/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTrZ-00EpIL-0X; Fri, 08 Dec 2023 05:57:25 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTrX-00EpH0-2N for linux-arm-kernel@bombadil.infradead.org; Fri, 08 Dec 2023 05:57:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=/zgqNM1BLjQpwqOX8AAkpOEPaYmCztUSTZLlWDykd+Y=; b=qId0ISnG6fN5NVfjhRi+FNHHGR YBJ5+4BNhu2QzK3epoQiDe82gRSlzMf+aAYv3SumShftMROGdlQbwNf48KaPCq8op8WQqhBmQ1S6g H/e7Vo+fudT1Tku+98iu1iKKYK5XmZ7SmCAwqrZNz0W+ur+QwKGfjFBHQq6ydlvUuaKFroTZZw1ES ZAzSFSrlpfwFRJoBgReXTN0kJrBpyMPkG3G+yktb5qCGgus75YvxjdG0sew8jf5swDmoZFlhXefxQ pxwA9HdV0HlQtsA2Dlo5XEINFaBRKVBYcFYC9hS4XUnxtZatQQgtlNTT4PTvrQG9ER0tDj3Tc3ICq RPYgsRMw==; Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpZ-006Uon-0h for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:57:21 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1d0538d9bbcso15753925ad.3 for ; Thu, 07 Dec 2023 21:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014915; x=1702619715; 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=/zgqNM1BLjQpwqOX8AAkpOEPaYmCztUSTZLlWDykd+Y=; b=ImRXIaPLxiSGmSj+p+/pqFbT+z5lpsgojRvi/rUl5eKjGVh7wt2PydY0FACT7ZSKRa OwmcbAt0yi3XbTOJRvocUDrYV0DfKs9zV/75gh/MUYTO4dc8mPuTkr+Som4cnS5U0s7i 0gvaU0sRMyeivcIsV3umfPTavsyXpzVaMAbH0NJa5FOnH/e6kkoFLUSCJdtlwzGEt1qb N8cRedTt8sXm/ViqRaQS/WZp1d31x5FnQ6oeVd+iNDE+gWEOBj0dwYYNjwPw3ajvjN1y 614vHip3USoPjj0MsjFnV6+eceGiGTdEJR/oR5yk9NEr6QwTn79A/5xCzaySbVBEpBDa aoJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014915; x=1702619715; 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=/zgqNM1BLjQpwqOX8AAkpOEPaYmCztUSTZLlWDykd+Y=; b=MQDqjBTwdEt9YoGDXrxpk9cwvvO8aPBkK8o4qr76bPoKu54oznWH5AL8MdWToYT8tv XjYWk8PrjkE1dg/7rB58XperJma0R1lLnoLxRFdC/5aQGjJ1Fa8tCXd+8KmqyAWJ/fhI cznb1pF1GBjeEfCgAnLMWkqzIcLk4hLZpByNVAEuz/quOFih6qjvjv/dNNkRdcCEVKyH idfxvF8ApC8EMk0/SUgPOENgHkXiztzzi2vHYy0Ty29VD77C6wK24Wf6WpIUAx/DrzXJ U7fAl5ATOF5bs9VEfEgCeQrWJgnbLyzPS6GQmymLmmqr1YZqJZ7jSTHipVfcBFhztJjT ZluA== X-Gm-Message-State: AOJu0Yy/74j70nQ/WH4FWFxEd52/F5I3wntJwXz3AFYqTUE1KI2YSJ+/ BE3w2u5XMjOPYm5KcPaYv4giCwwpnbXMnfIgI1YBFuK6VjaQCQCF+9zZuJfgHaD+SXHL84p0cuq t05da49jkhIiMYHIFVSggltqw4s1Hr9jmJSEzjSR90/gl0W5Dy/TzaoACk7onwJqWy/2ZyaiHKw /tA/i1mgyOQ1zX6OCaoqEXcTnF2Q== X-Google-Smtp-Source: AGHT+IEeohhdRoDbIB76rfeg/hp1f0wvfoQ9mNCmH7fkkS6XWgt0u4/Ycqf6R8fGDv+mLvCYfXsFug== X-Received: by 2002:a17:902:e88a:b0:1d0:68a:4a46 with SMTP id w10-20020a170902e88a00b001d0068a4a46mr4585686plg.3.1702014915181; Thu, 07 Dec 2023 21:55:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:14 -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 10/12] drm/amd/display: Use ARCH_HAS_KERNEL_FPU_SUPPORT Date: Thu, 7 Dec 2023 21:54:40 -0800 Message-ID: <20231208055501.2916202-11-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-20231208_055521_766191_46E9FE7B X-CRM114-Status: GOOD ( 14.60 ) 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 Now that all previously-supported architectures select ARCH_HAS_KERNEL_FPU_SUPPORT, this code can depend on that symbol instead of the existing list of architectures. It can also take advantage of the common kernel-mode FPU API and method of adjusting CFLAGS. Signed-off-by: Samuel Holland Signed-off-by: Michael Ellerman --- drivers/gpu/drm/amd/display/Kconfig | 2 +- .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 33 +---------------- drivers/gpu/drm/amd/display/dc/dml/Makefile | 36 ++----------------- drivers/gpu/drm/amd/display/dc/dml2/Makefile | 36 ++----------------- 4 files changed, 6 insertions(+), 101 deletions(-) diff --git a/drivers/gpu/drm/amd/display/Kconfig b/drivers/gpu/drm/amd/display/Kconfig index 901d1961b739..5fcd4f778dc3 100644 --- a/drivers/gpu/drm/amd/display/Kconfig +++ b/drivers/gpu/drm/amd/display/Kconfig @@ -8,7 +8,7 @@ config DRM_AMD_DC depends on BROKEN || !CC_IS_CLANG || ARM64 || RISCV || SPARC64 || X86_64 select SND_HDA_COMPONENT if SND_HDA_CORE # !CC_IS_CLANG: https://github.com/ClangBuiltLinux/linux/issues/1752 - select DRM_AMD_DC_FP if (X86 || LOONGARCH || (PPC64 && ALTIVEC) || (ARM64 && KERNEL_MODE_NEON && !CC_IS_CLANG)) + select DRM_AMD_DC_FP if ARCH_HAS_KERNEL_FPU_SUPPORT && (!ARM64 || !CC_IS_CLANG) help Choose this option if you want to use the new display engine support for AMDGPU. This adds required support for Vega and diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c index 4ae4720535a5..b64f917174ca 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c @@ -26,16 +26,7 @@ #include "dc_trace.h" -#if defined(CONFIG_X86) -#include -#elif defined(CONFIG_PPC64) -#include -#include -#elif defined(CONFIG_ARM64) -#include -#elif defined(CONFIG_LOONGARCH) #include -#endif /** * DOC: DC FPU manipulation overview @@ -87,20 +78,9 @@ void dc_fpu_begin(const char *function_name, const int line) WARN_ON_ONCE(!in_task()); preempt_disable(); depth = __this_cpu_inc_return(fpu_recursion_depth); - if (depth == 1) { -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) + BUG_ON(!kernel_fpu_available()); kernel_fpu_begin(); -#elif defined(CONFIG_PPC64) - if (cpu_has_feature(CPU_FTR_VSX_COMP)) - enable_kernel_vsx(); - else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) - enable_kernel_altivec(); - else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) - enable_kernel_fp(); -#elif defined(CONFIG_ARM64) - kernel_neon_begin(); -#endif } TRACE_DCN_FPU(true, function_name, line, depth); @@ -122,18 +102,7 @@ void dc_fpu_end(const char *function_name, const int line) depth = __this_cpu_dec_return(fpu_recursion_depth); if (depth == 0) { -#if defined(CONFIG_X86) || defined(CONFIG_LOONGARCH) kernel_fpu_end(); -#elif defined(CONFIG_PPC64) - if (cpu_has_feature(CPU_FTR_VSX_COMP)) - disable_kernel_vsx(); - else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) - disable_kernel_altivec(); - else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) - disable_kernel_fp(); -#elif defined(CONFIG_ARM64) - kernel_neon_end(); -#endif } else { WARN_ON_ONCE(depth < 0); } diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/amd/display/dc/dml/Makefile index ea7d60f9a9b4..5aad0f572ba3 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -25,40 +25,8 @@ # It provides the general basic services required by other DAL # subcomponents. -ifdef CONFIG_X86 -dml_ccflags-$(CONFIG_CC_IS_GCC) := -mhard-float -dml_ccflags := $(dml_ccflags-y) -msse -endif - -ifdef CONFIG_PPC64 -dml_ccflags := -mhard-float -maltivec -endif - -ifdef CONFIG_ARM64 -dml_rcflags := -mgeneral-regs-only -endif - -ifdef CONFIG_LOONGARCH -dml_ccflags := -mfpu=64 -dml_rcflags := -msoft-float -endif - -ifdef CONFIG_CC_IS_GCC -ifneq ($(call gcc-min-version, 70100),y) -IS_OLD_GCC = 1 -endif -endif - -ifdef CONFIG_X86 -ifdef IS_OLD_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 -# (8B stack alignment). -dml_ccflags += -mpreferred-stack-boundary=4 -else -dml_ccflags += -msse2 -endif -endif +dml_ccflags := $(CC_FLAGS_FPU) +dml_rcflags := $(CC_FLAGS_NO_FPU) ifneq ($(CONFIG_FRAME_WARN),0) frame_warn_flag := -Wframe-larger-than=2048 diff --git a/drivers/gpu/drm/amd/display/dc/dml2/Makefile b/drivers/gpu/drm/amd/display/dc/dml2/Makefile index acff3449b8d7..4f6c804a26ad 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml2/Makefile @@ -24,40 +24,8 @@ # # Makefile for dml2. -ifdef CONFIG_X86 -dml2_ccflags-$(CONFIG_CC_IS_GCC) := -mhard-float -dml2_ccflags := $(dml2_ccflags-y) -msse -endif - -ifdef CONFIG_PPC64 -dml2_ccflags := -mhard-float -maltivec -endif - -ifdef CONFIG_ARM64 -dml2_rcflags := -mgeneral-regs-only -endif - -ifdef CONFIG_LOONGARCH -dml2_ccflags := -mfpu=64 -dml2_rcflags := -msoft-float -endif - -ifdef CONFIG_CC_IS_GCC -ifeq ($(call cc-ifversion, -lt, 0701, y), y) -IS_OLD_GCC = 1 -endif -endif - -ifdef CONFIG_X86 -ifdef IS_OLD_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 -# (8B stack alignment). -dml2_ccflags += -mpreferred-stack-boundary=4 -else -dml2_ccflags += -msse2 -endif -endif +dml2_ccflags := $(CC_FLAGS_FPU) +dml2_rcflags := $(CC_FLAGS_NO_FPU) ifneq ($(CONFIG_FRAME_WARN),0) ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y) From patchwork Fri Dec 8 05:54:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484865 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 71AF8C4167B for ; Fri, 8 Dec 2023 05:56:14 +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=1dRKoi4mW+btqaBwC5JFdND2xh6NikqtWR5R2NF4r4M=; b=4hSP0wut9jdeXz g7fgG2NFggJYDFwzuBTGpfyzPID+k771xxQ8ywy0X42gT98+Z0WdF4Ob48kPo6HyzBDBrL69sanpa +c5C4clod4apuW56KhDhyIi3e65Cqy5j0UfHA1wWly7dDfNsSM2n3tW+Dd+vpGWZBUfyhV4eM3Cbl r9KeiRAq+JKTGfsAaWcFtLuEQhyAalhUwmRhu8kB+h1kv405mrZq/pFtyCoO6K4qnOeiXS0OwBpAg BdatMxn7H1i1CcCShyX58XwNCnkAojrTItpC1UJKsI0dWjtRQ3ZISEaWxLRBKjTWlJ/oKCHvdz4/L 8p9R1ia4E1ooJx32zhIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpx-00Eo5I-2k; Fri, 08 Dec 2023 05:55:45 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpV-00EnbR-0K for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:22 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d03bcf27e9so14678625ad.0 for ; Thu, 07 Dec 2023 21:55:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014916; x=1702619716; 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=jlkhIfYEZ3lvxXxXZeJnWgi8rztsMBcyR5bRnlna3ss=; b=GqtFeIFWpOmY4GYXQcv1dhgPyXwHpXOcQR++aVxXQWmk7Qbr7mDbVuZgL7ff+1iy5p CfppDYOSWJOZNBZ8XjzPn64Kl9bLQX0CNgm80QmRFEPo794ZOtTkOZSswAzbf8gQEX7E BIJCmsNfeokzHftLKcl7Tp3+6JI34VwZD1ibY5xMFzFVz8o+PeGnjQm+yvmsyr2WulEc twfeK5H6twFwzljDqpINBJJMGMP2IBt88MdqBOZNJawzUj6OmqN1fR+wP1K9Ge2x6wNj zNA+STp1Hiwh1OT4Th9Roabq3mwdD+qfx0yR14c4VjGiPVBDwqTyQpEIV3T8nyx2g9d6 oBwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014916; x=1702619716; 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=jlkhIfYEZ3lvxXxXZeJnWgi8rztsMBcyR5bRnlna3ss=; b=FiVV32wgRwyhIy1zpGixFVhQzWp/XTaIbUnqLbW7jAjMPbWsqEtEaoebnF/nbkzQVO t9Qx2O4+6wxCjZ034BP70VgdOz5aE2CyUrVhInpFHjgAAXCn639GDpgjzX67u75VuYdT 7tz3XryfqcL2/p+wnad1vDYbY2FVf1G5fQrm+j1MxVj13lmSnPa1JDVKYUCTy5F1WvnD si2zQaUEMNTt2WdoQVQozKvlvGTZWXWObqRAcvT/o8gVkqHGMTvX8IGZmcfxKDOxhpxy ArK8WW4BpRPJt0gQ7BWhnDD6+UJ2iDMGG5uRXdWi37qcjVBElfJuz3uYKNkakykP2Fdj pkGg== X-Gm-Message-State: AOJu0Yx6OLawXeyCwr+rFoqHh0xBjUHcAHZNw+/eRNj0FlpJqENKDjPH 9v6GKWN6TkzxxRAvizX6kopHoJGq6ETe1CWbfqhNrAT5AD2Zp46FVgLOfI5E2TPixk9z0PRlw45 7VNXoAsEpzIHljAMH12BFb33oKInlgwIVxYoo2MDf/itf07/3+ZiC7e7gU78WkxXdfY7wsJ4BiO sCxL2Hz/6K0wm7HF0uNHDEKfbFSw== X-Google-Smtp-Source: AGHT+IFq3S7FmJealx+s/zAc0NWuz2K3VM/cjjAkpGlz2K3tHlLviwkN/+BPcQyJZRioERW0JqTrBw== X-Received: by 2002:a17:902:b60f:b0:1d0:c7e0:c82c with SMTP id b15-20020a170902b60f00b001d0c7e0c82cmr2930083pls.8.1702014916347; Thu, 07 Dec 2023 21:55:16 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:16 -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 11/12] selftests/fpu: Move FP code to a separate translation unit Date: Thu, 7 Dec 2023 21:54:41 -0800 Message-ID: <20231208055501.2916202-12-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_215517_181373_C9C85D19 X-CRM114-Status: GOOD ( 17.90 ) 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 This ensures no compiler-generated floating-point code can appear outside kernel_fpu_{begin,end}() sections, and some architectures enforce this separation. Signed-off-by: Samuel Holland --- lib/Makefile | 3 ++- lib/{test_fpu.c => test_fpu_glue.c} | 32 +------------------------- lib/test_fpu_impl.c | 35 +++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 32 deletions(-) rename lib/{test_fpu.c => test_fpu_glue.c} (71%) create mode 100644 lib/test_fpu_impl.c diff --git a/lib/Makefile b/lib/Makefile index 6b09731d8e61..e7cbd54944a2 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -132,7 +132,8 @@ FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-st endif obj-$(CONFIG_TEST_FPU) += test_fpu.o -CFLAGS_test_fpu.o += $(FPU_CFLAGS) +test_fpu-y := test_fpu_glue.o test_fpu_impl.o +CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS) obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/ diff --git a/lib/test_fpu.c b/lib/test_fpu_glue.c similarity index 71% rename from lib/test_fpu.c rename to lib/test_fpu_glue.c index e82db19fed84..2761b51117b0 100644 --- a/lib/test_fpu.c +++ b/lib/test_fpu_glue.c @@ -19,37 +19,7 @@ #include #include -static int test_fpu(void) -{ - /* - * This sequence of operations tests that rounding mode is - * to nearest and that denormal numbers are supported. - * Volatile variables are used to avoid compiler optimizing - * the calculations away. - */ - volatile double a, b, c, d, e, f, g; - - a = 4.0; - b = 1e-15; - c = 1e-310; - - /* Sets precision flag */ - d = a + b; - - /* Result depends on rounding mode */ - e = a + b / 2; - - /* Denormal and very large values */ - f = b / c; - - /* Depends on denormal support */ - g = a + c * f; - - if (d > a && e > a && g > a) - return 0; - else - return -EINVAL; -} +int test_fpu(void); static int test_fpu_get(void *data, u64 *val) { diff --git a/lib/test_fpu_impl.c b/lib/test_fpu_impl.c new file mode 100644 index 000000000000..2ff01980bc22 --- /dev/null +++ b/lib/test_fpu_impl.c @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +int test_fpu(void) +{ + /* + * This sequence of operations tests that rounding mode is + * to nearest and that denormal numbers are supported. + * Volatile variables are used to avoid compiler optimizing + * the calculations away. + */ + volatile double a, b, c, d, e, f, g; + + a = 4.0; + b = 1e-15; + c = 1e-310; + + /* Sets precision flag */ + d = a + b; + + /* Result depends on rounding mode */ + e = a + b / 2; + + /* Denormal and very large values */ + f = b / c; + + /* Depends on denormal support */ + g = a + c * f; + + if (d > a && e > a && g > a) + return 0; + else + return -EINVAL; +} From patchwork Fri Dec 8 05:54:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13484866 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 3EDA2C4167B for ; Fri, 8 Dec 2023 05:56:25 +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=XVqZgcVoIjtSt5VYtBMX5R0lKM244qLhhXXAGOvuj9E=; b=LxGn0bEdr29Qm0 5UXPX/Hq2r4TRz/hJ/irXOkQOzjy09R1NKuIguMd7INa9UgRcpuW6qRjgEXMLEnX1x11tycicwRpL ym75cYELmC5K+ca7NdDLzALOHta4krVYuWWpu9ogMiq3uhtH0bDVvrl+F76MzLoci197VEK21WbUb 6DKCljw4gLwIuXxzordOwLQCsrImZHM2jv2WGJgutWxuqujGC7aAXKUc8bhbGtt58HAKUZunGy0J6 f89HJA095xNPBA+FtSKSlNeExh2Sead9fb4wxA4LNRZ7yAWc0qXaca/J7mjv/Ef30GevPQdQ1unDl NypX3ew9hn2xfq7PgTYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBTqC-00EoJc-0h; Fri, 08 Dec 2023 05:56:00 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpl-00Ensl-2I for linux-arm-kernel@bombadil.infradead.org; Fri, 08 Dec 2023 05:55:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=pcpcBg9iqyFf2P75H/RgUfyoTRLcpINzc/uQQUbU4hE=; b=Mo5M77j28u/tg+qyQPuS2awBmN RBIe31XCZh8GRKrtRCMoZzAjB4Fq2Im6II8aDJTwZOQLyS50Lu+mGBc4epCtAGe7POhMuZOSLpLZA BqAj/SBmJFTscAsFPLSQjI1QwS0cAJ02RdNWYIqVT5GptutoiBG08IqTZCWS3qVqYg7VYSTdqAdRx H7MGh9WzKILoIez08JXgM+dtYRInSUdh5JLwKpzYFHhR4qtGbG+yDu8Nh6c3Ks6Xpb0jAZ1IlanUc e28mCTENzWijspXuRhd6/ayiqwCctTOfUPj31MB5m8IpLo6D4KHzJI8xEotJAT14PLNo2gKwqwX4C GoQGTJhg==; Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBTpb-006Uop-2g for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 05:55:29 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d2e6e14865so6660305ad.0 for ; Thu, 07 Dec 2023 21:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1702014918; x=1702619718; 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=pcpcBg9iqyFf2P75H/RgUfyoTRLcpINzc/uQQUbU4hE=; b=SK3T8DFUqCKOqGSVqysl24NZjs8TlPymXuKb2JwaQ1MLXPM8MmvLpvQpEEjqUzekaW Wfq/G4VJS+DRRRwXWBHqP/sbz5G9RGghpIgX98KLIp8bP0B16twqbWOfQ73p5xqW4iIU seulVQAFuAw83SUBfQjmmu80A+gJJndC1WqMv656TheKG+l8dIPheEY8ptJg5jRePtI1 /HloT7V4RIdMuK9HVJM4I0tEgAgM3N5p1ULuatnkddY41mzmbfqzOD0+as/b/r7/9jaQ NQkczsFXVoNMRvSmFQaohBK0OCHB14pHNyLn2M9OwcucB3NhUsQJvtzrV/RwD5QBWPDJ Tlyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014918; x=1702619718; 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=pcpcBg9iqyFf2P75H/RgUfyoTRLcpINzc/uQQUbU4hE=; b=pS5gklnZ6BerJY3TtGTJXOPyB0AEMv2IKCpSM0qS1iqRs+KETJL1CuF3CzFyoPX5Gu IhaBUgD0709yN18yh9RmX1gDCNmLMuDlJMnhoYgS8Kf53h6OoxxgaJfbvTO19vg44gJa ZyP5oL0hQNLFcA5XLURrx1fpMK+pHx8oxSVSh9Uen7RSwFDuQ3WxTxCD+Ez31nm/JtnR lGWG/zooSxJOi9yUOrlmCaUUCSG5X+BBP3cy8wsh6cA3AtBC8X1nQIDwCio8lX5Eh83Y 5z3LGawotcKqgSkbYQcT3sLuqA5rFT+AQBfpHOw0fKtjHwCVDG6uUvbpai8/Dr2CMlia oxRw== X-Gm-Message-State: AOJu0Yy8JN/5WMYKPg3vf0bDiWdVqyKtgwUb75QcFa1HFUaH4hWZbOTX NbNl43i2hP47Cmi8OBB8D9f1YMA0Jka4h6bYcTRda45n3eT38vNbP7fQvsWwmZFFw2FQALBia0B WGDZxXJ3GbZAGkWioh+cXszcakDtTK6WEuDsDRKCS8YsRl3XlA1Rsjs2O5MEB4cpJy9C3WL0r+h m98a+OL6KGh/zRXT9C3LDh8egLWg== X-Google-Smtp-Source: AGHT+IEd1Q8NqQMc7dge0J/g+8VD/1S9VTAlw4GMwW5YWZLRIvv4qPwcnwD5N+VJxlW0x3wmr8JadA== X-Received: by 2002:a17:902:ab0f:b0:1d2:eee7:2a7e with SMTP id ik15-20020a170902ab0f00b001d2eee72a7emr114365plb.61.1702014917640; Thu, 07 Dec 2023 21:55:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:55:17 -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 12/12] selftests/fpu: Allow building on other architectures Date: Thu, 7 Dec 2023 21:54:42 -0800 Message-ID: <20231208055501.2916202-13-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-20231208_055524_368903_D5C66D72 X-CRM114-Status: GOOD ( 17.23 ) 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 Now that ARCH_HAS_KERNEL_FPU_SUPPORT provides a common way to compile and run floating-point code, this test is no longer x86-specific. Signed-off-by: Samuel Holland Reviewed-by: Christoph Hellwig --- lib/Kconfig.debug | 2 +- lib/Makefile | 25 ++----------------------- lib/test_fpu_glue.c | 5 ++++- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index cc7d53d9dc01..bbab0b054e09 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2933,7 +2933,7 @@ config TEST_FREE_PAGES config TEST_FPU tristate "Test floating point operations in kernel space" - depends on X86 && !KCOV_INSTRUMENT_ALL + depends on ARCH_HAS_KERNEL_FPU_SUPPORT && !KCOV_INSTRUMENT_ALL help Enable this option to add /sys/kernel/debug/selftest_helpers/test_fpu which will trigger a sequence of floating point operations. This is used diff --git a/lib/Makefile b/lib/Makefile index e7cbd54944a2..b9f28558c9bd 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -109,31 +109,10 @@ CFLAGS_test_fprobe.o += $(CC_FLAGS_FTRACE) obj-$(CONFIG_FPROBE_SANITY_TEST) += test_fprobe.o obj-$(CONFIG_TEST_OBJPOOL) += test_objpool.o -# -# CFLAGS for compiling floating point code inside the kernel. x86/Makefile turns -# off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS -# get appended last to CFLAGS and thus override those previous compiler options. -# -FPU_CFLAGS := -msse -msse2 -ifdef CONFIG_CC_IS_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 -# (8B stack alignment). -# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 -# -# The "-msse" in the first argument is there so that the -# -mpreferred-stack-boundary=3 build error: -# -# -mpreferred-stack-boundary=3 is not between 4 and 12 -# -# can be triggered. Otherwise gcc doesn't complain. -FPU_CFLAGS += -mhard-float -FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4) -endif - obj-$(CONFIG_TEST_FPU) += test_fpu.o test_fpu-y := test_fpu_glue.o test_fpu_impl.o -CFLAGS_test_fpu_impl.o += $(FPU_CFLAGS) +CFLAGS_test_fpu_impl.o += $(CC_FLAGS_FPU) +CFLAGS_REMOVE_test_fpu_impl.o += $(CC_FLAGS_NO_FPU) obj-$(CONFIG_TEST_LIVEPATCH) += livepatch/ diff --git a/lib/test_fpu_glue.c b/lib/test_fpu_glue.c index 2761b51117b0..2e0b4027a5e3 100644 --- a/lib/test_fpu_glue.c +++ b/lib/test_fpu_glue.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include int test_fpu(void); @@ -38,6 +38,9 @@ static struct dentry *selftest_dir; static int __init test_fpu_init(void) { + if (!kernel_fpu_available()) + return -EINVAL; + selftest_dir = debugfs_create_dir("selftest_helpers", NULL); if (!selftest_dir) return -ENOMEM;