Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/fpu: Get rid of CONFIG_AS_FXSAVEQ

This was a "workaround" to probe for binutils which could generate
FXSAVEQ, apparently gas with min version 2.16. In the meantime, minimal
required gas version is 2.20 so all those workarounds for older binutils
can be dropped.

Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andy Lutomirski <luto@kernel.org>
Link: https://lkml.kernel.org/r/20190117232408.GH5023@zn.tnic

+6 -45
-1
arch/x86/Makefile
··· 187 187 cfi-sections := $(call as-instr,.cfi_sections .debug_frame,-DCONFIG_AS_CFI_SECTIONS=1) 188 188 189 189 # does binutils support specific instructions? 190 - asinstr := $(call as-instr,fxsaveq (%rax),-DCONFIG_AS_FXSAVEQ=1) 191 190 asinstr += $(call as-instr,pshufb %xmm0$(comma)%xmm0,-DCONFIG_AS_SSSE3=1) 192 191 avx_instr := $(call as-instr,vxorps %ymm0$(comma)%ymm1$(comma)%ymm2,-DCONFIG_AS_AVX=1) 193 192 avx2_instr :=$(call as-instr,vpbroadcastb %xmm0$(comma)%ymm1,-DCONFIG_AS_AVX2=1)
+6 -44
arch/x86/include/asm/fpu/internal.h
··· 137 137 { 138 138 if (IS_ENABLED(CONFIG_X86_32)) 139 139 return user_insn(fxsave %[fx], [fx] "=m" (*fx), "m" (*fx)); 140 - else if (IS_ENABLED(CONFIG_AS_FXSAVEQ)) 140 + else 141 141 return user_insn(fxsaveq %[fx], [fx] "=m" (*fx), "m" (*fx)); 142 142 143 - /* See comment in copy_fxregs_to_kernel() below. */ 144 - return user_insn(rex64/fxsave (%[fx]), "=m" (*fx), [fx] "R" (fx)); 145 143 } 146 144 147 145 static inline void copy_kernel_to_fxregs(struct fxregs_state *fx) 148 146 { 149 - if (IS_ENABLED(CONFIG_X86_32)) { 147 + if (IS_ENABLED(CONFIG_X86_32)) 150 148 kernel_insn(fxrstor %[fx], "=m" (*fx), [fx] "m" (*fx)); 151 - } else { 152 - if (IS_ENABLED(CONFIG_AS_FXSAVEQ)) { 153 - kernel_insn(fxrstorq %[fx], "=m" (*fx), [fx] "m" (*fx)); 154 - } else { 155 - /* See comment in copy_fxregs_to_kernel() below. */ 156 - kernel_insn(rex64/fxrstor (%[fx]), "=m" (*fx), [fx] "R" (fx), "m" (*fx)); 157 - } 158 - } 149 + else 150 + kernel_insn(fxrstorq %[fx], "=m" (*fx), [fx] "m" (*fx)); 159 151 } 160 152 161 153 static inline int copy_user_to_fxregs(struct fxregs_state __user *fx) 162 154 { 163 155 if (IS_ENABLED(CONFIG_X86_32)) 164 156 return user_insn(fxrstor %[fx], "=m" (*fx), [fx] "m" (*fx)); 165 - else if (IS_ENABLED(CONFIG_AS_FXSAVEQ)) 157 + else 166 158 return user_insn(fxrstorq %[fx], "=m" (*fx), [fx] "m" (*fx)); 167 - 168 - /* See comment in copy_fxregs_to_kernel() below. */ 169 - return user_insn(rex64/fxrstor (%[fx]), "=m" (*fx), [fx] "R" (fx), 170 - "m" (*fx)); 171 159 } 172 160 173 161 static inline void copy_kernel_to_fregs(struct fregs_state *fx) ··· 172 184 { 173 185 if (IS_ENABLED(CONFIG_X86_32)) 174 186 asm volatile( "fxsave %[fx]" : [fx] "=m" (fpu->state.fxsave)); 175 - else if (IS_ENABLED(CONFIG_AS_FXSAVEQ)) 187 + else 176 188 asm volatile("fxsaveq %[fx]" : [fx] "=m" (fpu->state.fxsave)); 177 - else { 178 - /* Using "rex64; fxsave %0" is broken because, if the memory 179 - * operand uses any extended registers for addressing, a second 180 - * REX prefix will be generated (to the assembler, rex64 181 - * followed by semicolon is a separate instruction), and hence 182 - * the 64-bitness is lost. 183 - * 184 - * Using "fxsaveq %0" would be the ideal choice, but is only 185 - * supported starting with gas 2.16. 186 - * 187 - * Using, as a workaround, the properly prefixed form below 188 - * isn't accepted by any binutils version so far released, 189 - * complaining that the same type of prefix is used twice if 190 - * an extended register is needed for addressing (fix submitted 191 - * to mainline 2005-11-21). 192 - * 193 - * asm volatile("rex64/fxsave %0" : "=m" (fpu->state.fxsave)); 194 - * 195 - * This, however, we can work around by forcing the compiler to 196 - * select an addressing mode that doesn't require extended 197 - * registers. 198 - */ 199 - asm volatile( "rex64/fxsave (%[fx])" 200 - : "=m" (fpu->state.fxsave) 201 - : [fx] "R" (&fpu->state.fxsave)); 202 - } 203 189 } 204 190 205 191 /* These macros all use (%edi)/(%rdi) as the single memory argument. */