Merge tag 'x86_urgent_for_v5.16_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Borislav Petkov:

- Add the model number of a new, Raptor Lake CPU, to intel-family.h

- Do not log spurious corrected MCEs on SKL too, due to an erratum

- Clarify the path of paravirt ops patches upstream

- Add an optimization to avoid writing out AMX components to sigframes
when former are in init state

* tag 'x86_urgent_for_v5.16_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/cpu: Add Raptor Lake to Intel family
x86/mce: Add errata workaround for Skylake SKX37
MAINTAINERS: Add some information to PARAVIRT_OPS entry
x86/fpu: Optimize out sigframe xfeatures when in init state

+71 -4
+9
Documentation/x86/xstate.rst
··· 63 63 the handler allocates a larger xstate buffer for the task so the large 64 64 state can be context switched. In the unlikely cases that the allocation 65 65 fails, the kernel sends SIGSEGV. 66 + 67 + Dynamic features in signal frames 68 + --------------------------------- 69 + 70 + Dynamcally enabled features are not written to the signal frame upon signal 71 + entry if the feature is in its initial configuration. This differs from 72 + non-dynamic features which are always written regardless of their 73 + configuration. Signal handlers can examine the XSAVE buffer's XSTATE_BV 74 + field to determine if a features was written.
+2
MAINTAINERS
··· 14412 14412 M: Deep Shah <sdeep@vmware.com> 14413 14413 M: "VMware, Inc." <pv-drivers@vmware.com> 14414 14414 L: virtualization@lists.linux-foundation.org 14415 + L: x86@kernel.org 14415 14416 S: Supported 14417 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/core 14416 14418 F: Documentation/virt/paravirt_ops.rst 14417 14419 F: arch/*/include/asm/paravirt*.h 14418 14420 F: arch/*/kernel/paravirt*
+12
arch/x86/include/asm/fpu/xcr.h
··· 3 3 #define _ASM_X86_FPU_XCR_H 4 4 5 5 #define XCR_XFEATURE_ENABLED_MASK 0x00000000 6 + #define XCR_XFEATURE_IN_USE_MASK 0x00000001 6 7 7 8 static inline u64 xgetbv(u32 index) 8 9 { ··· 19 18 u32 edx = value >> 32; 20 19 21 20 asm volatile("xsetbv" :: "a" (eax), "d" (edx), "c" (index)); 21 + } 22 + 23 + /* 24 + * Return a mask of xfeatures which are currently being tracked 25 + * by the processor as being in the initial configuration. 26 + * 27 + * Callers should check X86_FEATURE_XGETBV1. 28 + */ 29 + static inline u64 xfeatures_in_use(void) 30 + { 31 + return xgetbv(XCR_XFEATURE_IN_USE_MASK); 22 32 } 23 33 24 34 #endif /* _ASM_X86_FPU_XCR_H */
+7
arch/x86/include/asm/fpu/xstate.h
··· 92 92 #define XFEATURE_MASK_FPSTATE (XFEATURE_MASK_USER_RESTORE | \ 93 93 XFEATURE_MASK_SUPERVISOR_SUPPORTED) 94 94 95 + /* 96 + * Features in this mask have space allocated in the signal frame, but may not 97 + * have that space initialized when the feature is in its init state. 98 + */ 99 + #define XFEATURE_MASK_SIGFRAME_INITOPT (XFEATURE_MASK_XTILE | \ 100 + XFEATURE_MASK_USER_DYNAMIC) 101 + 95 102 extern u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS]; 96 103 97 104 extern void __init update_regset_xstate_info(unsigned int size,
+2
arch/x86/include/asm/intel-family.h
··· 108 108 #define INTEL_FAM6_ALDERLAKE 0x97 /* Golden Cove / Gracemont */ 109 109 #define INTEL_FAM6_ALDERLAKE_L 0x9A /* Golden Cove / Gracemont */ 110 110 111 + #define INTEL_FAM6_RAPTOR_LAKE 0xB7 112 + 111 113 /* "Small Core" Processors (Atom) */ 112 114 113 115 #define INTEL_FAM6_ATOM_BONNELL 0x1C /* Diamondville, Pineview */
+1
arch/x86/kernel/cpu/cpuid-deps.c
··· 76 76 { X86_FEATURE_SGX1, X86_FEATURE_SGX }, 77 77 { X86_FEATURE_SGX2, X86_FEATURE_SGX1 }, 78 78 { X86_FEATURE_XFD, X86_FEATURE_XSAVES }, 79 + { X86_FEATURE_XFD, X86_FEATURE_XGETBV1 }, 79 80 { X86_FEATURE_AMX_TILE, X86_FEATURE_XFD }, 80 81 {} 81 82 };
+3 -2
arch/x86/kernel/cpu/mce/intel.c
··· 547 547 { 548 548 struct cpuinfo_x86 *c = &boot_cpu_data; 549 549 550 - /* MCE errata HSD131, HSM142, HSW131, BDM48, and HSM142 */ 550 + /* MCE errata HSD131, HSM142, HSW131, BDM48, HSM142 and SKX37 */ 551 551 if ((c->x86 == 6) && 552 552 ((c->x86_model == INTEL_FAM6_HASWELL) || 553 553 (c->x86_model == INTEL_FAM6_HASWELL_L) || 554 554 (c->x86_model == INTEL_FAM6_BROADWELL) || 555 - (c->x86_model == INTEL_FAM6_HASWELL_G)) && 555 + (c->x86_model == INTEL_FAM6_HASWELL_G) || 556 + (c->x86_model == INTEL_FAM6_SKYLAKE_X)) && 556 557 (m->bank == 0) && 557 558 ((m->status & 0xa0000000ffffffff) == 0x80000000000f0005)) 558 559 return true;
+35 -2
arch/x86/kernel/fpu/xstate.h
··· 4 4 5 5 #include <asm/cpufeature.h> 6 6 #include <asm/fpu/xstate.h> 7 + #include <asm/fpu/xcr.h> 7 8 8 9 #ifdef CONFIG_X86_64 9 10 DECLARE_PER_CPU(u64, xfd_state); ··· 200 199 } 201 200 202 201 /* 202 + * XSAVE itself always writes all requested xfeatures. Removing features 203 + * from the request bitmap reduces the features which are written. 204 + * Generate a mask of features which must be written to a sigframe. The 205 + * unset features can be optimized away and not written. 206 + * 207 + * This optimization is user-visible. Only use for states where 208 + * uninitialized sigframe contents are tolerable, like dynamic features. 209 + * 210 + * Users of buffers produced with this optimization must check XSTATE_BV 211 + * to determine which features have been optimized out. 212 + */ 213 + static inline u64 xfeatures_need_sigframe_write(void) 214 + { 215 + u64 xfeaures_to_write; 216 + 217 + /* In-use features must be written: */ 218 + xfeaures_to_write = xfeatures_in_use(); 219 + 220 + /* Also write all non-optimizable sigframe features: */ 221 + xfeaures_to_write |= XFEATURE_MASK_USER_SUPPORTED & 222 + ~XFEATURE_MASK_SIGFRAME_INITOPT; 223 + 224 + return xfeaures_to_write; 225 + } 226 + 227 + /* 203 228 * Save xstate to user space xsave area. 204 229 * 205 230 * We don't use modified optimization because xrstor/xrstors might track ··· 247 220 */ 248 221 struct fpstate *fpstate = current->thread.fpu.fpstate; 249 222 u64 mask = fpstate->user_xfeatures; 250 - u32 lmask = mask; 251 - u32 hmask = mask >> 32; 223 + u32 lmask; 224 + u32 hmask; 252 225 int err; 253 226 227 + /* Optimize away writing unnecessary xfeatures: */ 228 + if (fpu_state_size_dynamic()) 229 + mask &= xfeatures_need_sigframe_write(); 230 + 231 + lmask = mask; 232 + hmask = mask >> 32; 254 233 xfd_validate_state(fpstate, mask, false); 255 234 256 235 stac();