Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1704594ybh; Tue, 14 Jul 2020 05:17:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwihrlu1Ubc2OGkibbVltuz8khvyupEeelvWagVD+6jOnhqY+adKKoRZeESZ5zcNgZ/SXli X-Received: by 2002:aa7:db11:: with SMTP id t17mr4042061eds.365.1594729075759; Tue, 14 Jul 2020 05:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594729075; cv=none; d=google.com; s=arc-20160816; b=RmIj7SgfgrLfYX3pTJc0XHB2kcjzV9E6zYU45rhH+F8JFQS4dmSbvI6qyAjxR/ZReo F8c4VkhrByCfXRlZKWR3JbnozCnYm7AcsqHS+gMKQNWLnP7sz16F4HgJyAGgTBIrlz6I Ig4cWJe3Z4fnacG0SrqfeZ8BGY63Y79x+1rnW3mvKdQJfqj1DKORy8jGMBjGES708i/y AKQVyGr1Jlt+iQcRf3Hu3zmSqpGfo/WpRtA1twYASryn7IGIxUexbkHAzszlm/zPG7SL oEZtc5EgHzSRcnK2L4ouunzLthxVFiiO2wjy+2eHlp3SYtxEEx7YUmgBCeQo1VlhYQVs U3ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kCUq9l0lmBjfLJBvL/jcUgnNXmq6MY2jRB52HLnVn0E=; b=gcVY8AVnhUBwggXb4/nsDA4rj9QV3E2TBz68CEoT1ErUR/h5TTFTsbaIkdyLzII1vY M3m+ehYYxvrTD+qxpojrVKH2qKHeEPg701tlTLoYA6adHIy9hT4VZfwfRlXilEOeX9xz E1dTdNX2KqakGMus0pMAwvVy4r81MNBgPbZvCyOpmXUH3ffujdYh3RsD7BH9xJwowoET xWfdSddif0a0cuLkinyFWU+EniVryNkXFxs7Wo9Hoc2AhFsUk7SzIfZkn3plSU4GOdo0 KUooM/whxwC4koZTlMklJlFJTt0HzIHj2l/RnNKIOwrmra4Lmr42g20iScpxyIsLkOiK 2uyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si11352533eds.349.2020.07.14.05.17.32; Tue, 14 Jul 2020 05:17:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728612AbgGNMQK (ORCPT + 99 others); Tue, 14 Jul 2020 08:16:10 -0400 Received: from 8bytes.org ([81.169.241.247]:53376 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728262AbgGNMKu (ORCPT ); Tue, 14 Jul 2020 08:10:50 -0400 Received: from cap.home.8bytes.org (p5b006776.dip0.t-ipconnect.de [91.0.103.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id 850F39B5; Tue, 14 Jul 2020 14:10:46 +0200 (CEST) From: Joerg Roedel To: x86@kernel.org Cc: Joerg Roedel , Joerg Roedel , hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v4 25/75] x86/fpu: Move xgetbv()/xsetbv() into separate header Date: Tue, 14 Jul 2020 14:08:27 +0200 Message-Id: <20200714120917.11253-26-joro@8bytes.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714120917.11253-1-joro@8bytes.org> References: <20200714120917.11253-1-joro@8bytes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel The xgetbv() function is needed in pre-decompression boot code, but asm/fpu/internal.h can't be included there directly. Doing so opens the door to include-hell due to various include-magic in boot/compressed/misc.h. Avoid that by moving xgetbv()/xsetbv() to a separate header file and include this instead. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/fpu/internal.h | 33 +------------------------ arch/x86/include/asm/fpu/xcr.h | 37 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 32 deletions(-) create mode 100644 arch/x86/include/asm/fpu/xcr.h diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index 845e7481ab77..1c724bbace04 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -619,36 +620,4 @@ static inline void switch_fpu_finish(struct fpu *new_fpu) __write_pkru(pkru_val); } -/* - * MXCSR and XCR definitions: - */ - -static inline void ldmxcsr(u32 mxcsr) -{ - asm volatile("ldmxcsr %0" :: "m" (mxcsr)); -} - -extern unsigned int mxcsr_feature_mask; - -#define XCR_XFEATURE_ENABLED_MASK 0x00000000 - -static inline u64 xgetbv(u32 index) -{ - u32 eax, edx; - - asm volatile(".byte 0x0f,0x01,0xd0" /* xgetbv */ - : "=a" (eax), "=d" (edx) - : "c" (index)); - return eax + ((u64)edx << 32); -} - -static inline void xsetbv(u32 index, u64 value) -{ - u32 eax = value; - u32 edx = value >> 32; - - asm volatile(".byte 0x0f,0x01,0xd1" /* xsetbv */ - : : "a" (eax), "d" (edx), "c" (index)); -} - #endif /* _ASM_X86_FPU_INTERNAL_H */ diff --git a/arch/x86/include/asm/fpu/xcr.h b/arch/x86/include/asm/fpu/xcr.h new file mode 100644 index 000000000000..d8e8fafebfdc --- /dev/null +++ b/arch/x86/include/asm/fpu/xcr.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_FPU_XCR_H +#define _ASM_X86_FPU_XCR_H + +/* + * MXCSR and XCR definitions: + */ + +static inline void ldmxcsr(u32 mxcsr) +{ + asm volatile("ldmxcsr %0" :: "m" (mxcsr)); +} + +extern unsigned int mxcsr_feature_mask; + +#define XCR_XFEATURE_ENABLED_MASK 0x00000000 + +static inline u64 xgetbv(u32 index) +{ + u32 eax, edx; + + asm volatile(".byte 0x0f,0x01,0xd0" /* xgetbv */ + : "=a" (eax), "=d" (edx) + : "c" (index)); + return eax + ((u64)edx << 32); +} + +static inline void xsetbv(u32 index, u64 value) +{ + u32 eax = value; + u32 edx = value >> 32; + + asm volatile(".byte 0x0f,0x01,0xd1" /* xsetbv */ + : : "a" (eax), "d" (edx), "c" (index)); +} + +#endif /* _ASM_X86_FPU_XCR_H */ -- 2.27.0