-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x86/fpu: Move xgetbv()/xsetbv() into a separate header
The xgetbv() function is needed in the 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 it instead. Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20200907131613.12703-27-joro@8bytes.org
- Loading branch information
Joerg Roedel
authored and
Borislav Petkov
committed
Sep 7, 2020
1 parent
25189d0
commit 1b4fb85
Showing
2 changed files
with
35 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* 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("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("xsetbv" :: "a" (eax), "d" (edx), "c" (index)); | ||
} | ||
|
||
#endif /* _ASM_X86_FPU_XCR_H */ |