Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2139473rdb; Thu, 7 Dec 2023 21:57:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6633KZFy1QIlIggrKYESzlxcYkprjS4vQ70M28wZkW12IRHbcFkFRzl1NGSc75hL4lD4c X-Received: by 2002:a05:6808:1206:b0:3b8:b063:825b with SMTP id a6-20020a056808120600b003b8b063825bmr4285632oil.93.1702015020943; Thu, 07 Dec 2023 21:57:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702015020; cv=none; d=google.com; s=arc-20160816; b=MS7ww3YKTp2DgHZhldAF2DxSIasg9biQwPiHjeBh1JfFJwHbGn2Zf6N2OQQ9U1VuI+ /f/x3FMRJI7AntlfUqwB6EWwKZmktkvTjMDz3dc1cgfZQvspkOt9EMM1kBAE7yuwnmdZ SdU2H/2fgZD4ez1J/HlbZrJkMinTkQJt8wecRoknvowt64xojh3uNu3M7J2Ztxpj1CyO WQPbkRO1xcTN+amP1qAhPR09QxHW4SdQ6jNnZVBHbuyRMgmDZ6oilFxQ8fC3GI9/nmkc uU1lGsh8V/BR4bn7zxkKPxaz2xLsPkK4AEpngdSmYIEMxK0r/dNOOHNZ8cOCVfJ+q82d rVIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wOdH6gQ2/kSr11qF6anDkZP04y2oGGJwChsMHemqfok=; fh=GWiN7/yH5ZaeB7dNf34H6takS9oI70VVB29etA3Fg9Y=; b=qkUUrjcL16dyXRyJc2MumAKtOzxLQliNeTlajLWIY9ggJyVhwNW5KNoPeKROWonYQy RY+6hXZqnmOsMYwTGUHnrvgrdiPl4h/8vRvqiHMQdznH4/5wCNYj5frCvBf6GcAOpeg/ e4BgrW5QXD+U12cncruq8oRhMXgYLM6JxTBG1ruM0EoLPVXOwGcCeBaUOkrMBNWP6nxV 4pDP0YaxIFWLwnZuyxWnu/JK4VWhWyIFEZp1W7gVSkDjfYttc3mqpZuxCplfsPUOT7z2 yjet3MaimNWWtQXGem8iOLnM01HMFaCISwMI7tAHWZtGmHGiwCEkQa8LwdEqwHb4KoEr fU5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=T4LqkHlr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id ko19-20020a056a00461300b006ce83264887si1008611pfb.57.2023.12.07.21.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 21:57:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=T4LqkHlr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 699A7807C5C8; Thu, 7 Dec 2023 21:55:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233276AbjLHFz1 (ORCPT + 99 others); Fri, 8 Dec 2023 00:55:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573221AbjLHFzI (ORCPT ); Fri, 8 Dec 2023 00:55:08 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35DF41734 for ; Thu, 7 Dec 2023 21:55:13 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d04d286bc0so13129585ad.3 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=1702014912; x=1702619712; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wOdH6gQ2/kSr11qF6anDkZP04y2oGGJwChsMHemqfok=; b=T4LqkHlraVGMzq4C9tWiv8BniomaaUN0FsEXm/RKku0Y5B7y0fPRi1ZQycLzyVP+0T IHZ0KKRXegLktdCL8wQpOigg1hzXyG0Fz4BXDxfWLPffxhqCHZEDogY/hO8fn9bAbLb7 x8VUn4CTv6a21gYTRxMoTNw2CY7FvLNyba3L4EdLCEgxUZSRQGsnS1jKsSHvZh9OQYTG YRmz1T4U+c+XzwmhOgwFh4Io9cyrrIiEUf7TjeDEPiRsKpJ5PyQ5p8GJ1DwZwOWN8Okk PsdM4+U3fxLvx7l35UejxLDN9Xm98edMr5ZgoYi70LOXuLMtEUpdG6zNBUri8pNK+SQM iDkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702014912; x=1702619712; 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=wO6KAk4usKap7zcH1GI30EBEjMdsoTfvLFdcQJVNyn4QUpGr9lDkiBL8dUJ6u1m58k yY0hLr6PChM44Pwk3BEEYz/4gJfWaLnRbgnBt2EJu1X2FlBC91CO3J6HcHhB60CKL8im pXqmEWf6y7xkwSexMS0rALVawY0BgkWH1x6B7suhSVJxyCYz3mntEI3vPBEh5WY+Annd 156oS8hYcULEWXHjftS56K8db76pIZGxxKzLSlGK7sppWdlo/rwQ5CwI60VL+6kdTlXo jh15Cs58U+/aCNM3YL5WaZonQee75xfXpDpBwf9HMJ69+dfNVbjd2VsEoN517zms5KmA y/XQ== X-Gm-Message-State: AOJu0YywjgxLTUzingKrJnJfu1Ie3uLFiqVn2PX903BGsj1HhqYi0KK6 YrFZS4Ik4k4wS0RXFcGp1BFm2iIt/sz5jHgpTh0= 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 07 Dec 2023 21:55:45 -0800 (PST) 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 --- 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 */ -- 2.42.0