Skip to content

Commit 2883b4c

Browse files
ubizjakIngo Molnar
authored andcommitted
x86/fpu: Use XSAVE{,OPT,C,S} and XRSTOR{,S} mnemonics in xstate.h
Current minimum required version of binutils is 2.25, which supports XSAVE{,OPT,C,S} and XRSTOR{,S} instruction mnemonics. Replace the byte-wise specification of XSAVE{,OPT,C,S} and XRSTOR{,S} with these proper mnemonics. No functional change intended. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Brian Gerst <brgerst@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20250313130251.383204-1-ubizjak@gmail.com
1 parent d021985 commit 2883b4c

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

arch/x86/kernel/fpu/xstate.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,17 @@ static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u64 ma
9494
/* XSAVE/XRSTOR wrapper functions */
9595

9696
#ifdef CONFIG_X86_64
97-
#define REX_PREFIX "0x48, "
97+
#define REX_SUFFIX "64"
9898
#else
99-
#define REX_PREFIX
99+
#define REX_SUFFIX
100100
#endif
101101

102-
/* These macros all use (%edi)/(%rdi) as the single memory argument. */
103-
#define XSAVE ".byte " REX_PREFIX "0x0f,0xae,0x27"
104-
#define XSAVEOPT ".byte " REX_PREFIX "0x0f,0xae,0x37"
105-
#define XSAVEC ".byte " REX_PREFIX "0x0f,0xc7,0x27"
106-
#define XSAVES ".byte " REX_PREFIX "0x0f,0xc7,0x2f"
107-
#define XRSTOR ".byte " REX_PREFIX "0x0f,0xae,0x2f"
108-
#define XRSTORS ".byte " REX_PREFIX "0x0f,0xc7,0x1f"
102+
#define XSAVE "xsave" REX_SUFFIX " %[xa]"
103+
#define XSAVEOPT "xsaveopt" REX_SUFFIX " %[xa]"
104+
#define XSAVEC "xsavec" REX_SUFFIX " %[xa]"
105+
#define XSAVES "xsaves" REX_SUFFIX " %[xa]"
106+
#define XRSTOR "xrstor" REX_SUFFIX " %[xa]"
107+
#define XRSTORS "xrstors" REX_SUFFIX " %[xa]"
109108

110109
/*
111110
* After this @err contains 0 on success or the trap number when the
@@ -114,10 +113,10 @@ static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u64 ma
114113
#define XSTATE_OP(op, st, lmask, hmask, err) \
115114
asm volatile("1:" op "\n\t" \
116115
"xor %[err], %[err]\n" \
117-
"2:\n\t" \
116+
"2:\n" \
118117
_ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_FAULT_MCE_SAFE) \
119118
: [err] "=a" (err) \
120-
: "D" (st), "m" (*st), "a" (lmask), "d" (hmask) \
119+
: [xa] "m" (*(st)), "a" (lmask), "d" (hmask) \
121120
: "memory")
122121

123122
/*
@@ -137,12 +136,12 @@ static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u64 ma
137136
XSAVEOPT, X86_FEATURE_XSAVEOPT, \
138137
XSAVEC, X86_FEATURE_XSAVEC, \
139138
XSAVES, X86_FEATURE_XSAVES) \
140-
"\n" \
139+
"\n\t" \
141140
"xor %[err], %[err]\n" \
142141
"3:\n" \
143142
_ASM_EXTABLE_TYPE_REG(1b, 3b, EX_TYPE_EFAULT_REG, %[err]) \
144143
: [err] "=r" (err) \
145-
: "D" (st), "m" (*st), "a" (lmask), "d" (hmask) \
144+
: [xa] "m" (*(st)), "a" (lmask), "d" (hmask) \
146145
: "memory")
147146

148147
/*
@@ -156,7 +155,7 @@ static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u64 ma
156155
"3:\n" \
157156
_ASM_EXTABLE_TYPE(1b, 3b, EX_TYPE_FPU_RESTORE) \
158157
: \
159-
: "D" (st), "m" (*st), "a" (lmask), "d" (hmask) \
158+
: [xa] "m" (*(st)), "a" (lmask), "d" (hmask) \
160159
: "memory")
161160

162161
#if defined(CONFIG_X86_64) && defined(CONFIG_X86_DEBUG_FPU)

0 commit comments

Comments
 (0)