Skip to content

Commit 01f6ea5

Browse files
committed
Merge: x86/fpu: update to v6.2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2398 Update x86/fpu with the latest upstream fixes. Bugzilla: https://bugzilla.redhat.com/2082182 Signed-off-by: Dean Nelson <dnelson@redhat.com> Approved-by: Lenny Szubowicz <lszubowi@redhat.com> Approved-by: Prarit Bhargava <prarit@redhat.com> Approved-by: David Arcari <darcari@redhat.com> Signed-off-by: Jan Stancek <jstancek@redhat.com>
2 parents 36ad44a + 8c783f0 commit 01f6ea5

File tree

18 files changed

+149
-102
lines changed

18 files changed

+149
-102
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
#define X86_FEATURE_INVPCID_SINGLE ( 7*32+ 7) /* Effectively INVPCID && CR4.PCIDE=1 */
204204
#define X86_FEATURE_HW_PSTATE ( 7*32+ 8) /* AMD HW-PState */
205205
#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
206-
/* FREE! ( 7*32+10) */
206+
#define X86_FEATURE_XCOMPACTED ( 7*32+10) /* "" Use compacted XSTATE (XSAVES or XSAVEC) */
207207
#define X86_FEATURE_PTI ( 7*32+11) /* Kernel Page Table Isolation enabled */
208208
#define X86_FEATURE_KERNEL_IBRS ( 7*32+12) /* "" Set/clear IBRS on kernel entry/exit */
209209
#define X86_FEATURE_RSB_VMEXIT ( 7*32+13) /* "" Fill RSB on VM-Exit */

arch/x86/include/asm/fpu/api.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ static inline bool fpstate_is_confidential(struct fpu_guest *gfpu)
162162
}
163163

164164
/* prctl */
165-
struct task_struct;
166-
extern long fpu_xstate_prctl(struct task_struct *tsk, int option, unsigned long arg2);
165+
extern long fpu_xstate_prctl(int option, unsigned long arg2);
167166

168167
extern void fpu_idle_fpregs(void);
169168

arch/x86/include/asm/fpu/internal.h

Whitespace-only changes.

arch/x86/include/asm/fpu/sched.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern void fpu_flush_thread(void);
3939
static inline void switch_fpu_prepare(struct fpu *old_fpu, int cpu)
4040
{
4141
if (cpu_feature_enabled(X86_FEATURE_FPU) &&
42-
!(current->flags & PF_KTHREAD)) {
42+
!(current->flags & (PF_KTHREAD | PF_IO_WORKER))) {
4343
save_fpregs_to_fpstate(old_fpu);
4444
/*
4545
* The save operation preserved register state, so the

arch/x86/include/asm/fpu/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ struct xstate_header {
321321
struct xregs_state {
322322
struct fxregs_state i387;
323323
struct xstate_header header;
324-
u8 extended_state_area[0];
324+
u8 extended_state_area[];
325325
} __attribute__ ((packed, aligned (64)));
326326

327327
/*

arch/x86/include/asm/fpu/xcr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define XCR_XFEATURE_ENABLED_MASK 0x00000000
66
#define XCR_XFEATURE_IN_USE_MASK 0x00000001
77

8-
static inline u64 xgetbv(u32 index)
8+
static __always_inline u64 xgetbv(u32 index)
99
{
1010
u32 eax, edx;
1111

@@ -27,7 +27,7 @@ static inline void xsetbv(u32 index, u64 value)
2727
*
2828
* Callers should check X86_FEATURE_XGETBV1.
2929
*/
30-
static inline u64 xfeatures_in_use(void)
30+
static __always_inline u64 xfeatures_in_use(void)
3131
{
3232
return xgetbv(XCR_XFEATURE_IN_USE_MASK);
3333
}

arch/x86/include/asm/proto.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ void x86_report_nx(void);
4343

4444
extern int reboot_force;
4545

46-
long do_arch_prctl_common(struct task_struct *task, int option,
47-
unsigned long arg2);
46+
long do_arch_prctl_common(int option, unsigned long arg2);
4847

4948
#endif /* _ASM_X86_PROTO_H */

arch/x86/include/asm/special_insns.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ static inline int enqcmds(void __iomem *dst, const void *src)
294294
return 0;
295295
}
296296

297-
static inline void tile_release(void)
297+
static __always_inline void tile_release(void)
298298
{
299299
/*
300300
* Instruction opcode for TILERELEASE; supported in binutils

arch/x86/kernel/fpu/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static inline void fpregs_restore_userregs(void)
5757
struct fpu *fpu = &current->thread.fpu;
5858
int cpu = smp_processor_id();
5959

60-
if (WARN_ON_ONCE(current->flags & PF_KTHREAD))
60+
if (WARN_ON_ONCE(current->flags & (PF_KTHREAD | PF_IO_WORKER)))
6161
return;
6262

6363
if (!fpregs_state_valid(fpu, cpu)) {

arch/x86/kernel/fpu/core.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,6 @@ int fpu_copy_uabi_to_guest_fpstate(struct fpu_guest *gfpu, const void *buf,
391391
{
392392
struct fpstate *kstate = gfpu->fpstate;
393393
const union fpregs_state *ustate = buf;
394-
struct pkru_state *xpkru;
395-
int ret;
396394

397395
if (!cpu_feature_enabled(X86_FEATURE_XSAVE)) {
398396
if (ustate->xsave.header.xfeatures & ~XFEATURE_MASK_FPSSE)
@@ -406,19 +404,15 @@ int fpu_copy_uabi_to_guest_fpstate(struct fpu_guest *gfpu, const void *buf,
406404
if (ustate->xsave.header.xfeatures & ~xcr0)
407405
return -EINVAL;
408406

409-
ret = copy_uabi_from_kernel_to_xstate(kstate, ustate);
410-
if (ret)
411-
return ret;
412-
413-
/* Retrieve PKRU if not in init state */
414-
if (kstate->regs.xsave.header.xfeatures & XFEATURE_MASK_PKRU) {
415-
xpkru = get_xsave_addr(&kstate->regs.xsave, XFEATURE_PKRU);
416-
*vpkru = xpkru->pkru;
417-
}
407+
/*
408+
* Nullify @vpkru to preserve its current value if PKRU's bit isn't set
409+
* in the header. KVM's odd ABI is to leave PKRU untouched in this
410+
* case (all other components are eventually re-initialized).
411+
*/
412+
if (!(ustate->xsave.header.xfeatures & XFEATURE_MASK_PKRU))
413+
vpkru = NULL;
418414

419-
/* Ensure that XCOMP_BV is set up for XSAVES */
420-
xstate_init_xcomp_bv(&kstate->regs.xsave, kstate->xfeatures);
421-
return 0;
415+
return copy_uabi_from_kernel_to_xstate(kstate, ustate, vpkru);
422416
}
423417
EXPORT_SYMBOL_GPL(fpu_copy_uabi_to_guest_fpstate);
424418
#endif /* CONFIG_KVM */
@@ -432,7 +426,7 @@ void kernel_fpu_begin_mask(unsigned int kfpu_mask)
432426

433427
this_cpu_write(in_kernel_fpu, true);
434428

435-
if (!(current->flags & PF_KTHREAD) &&
429+
if (!(current->flags & (PF_KTHREAD | PF_IO_WORKER)) &&
436430
!test_thread_flag(TIF_NEED_FPU_LOAD)) {
437431
set_thread_flag(TIF_NEED_FPU_LOAD);
438432
save_fpregs_to_fpstate(&current->thread.fpu);
@@ -859,12 +853,12 @@ int fpu__exception_code(struct fpu *fpu, int trap_nr)
859853
* Initialize register state that may prevent from entering low-power idle.
860854
* This function will be invoked from the cpuidle driver only when needed.
861855
*/
862-
void fpu_idle_fpregs(void)
856+
noinstr void fpu_idle_fpregs(void)
863857
{
864858
/* Note: AMX_TILE being enabled implies XGETBV1 support */
865859
if (cpu_feature_enabled(X86_FEATURE_AMX_TILE) &&
866860
(xfeatures_in_use() & XFEATURE_MASK_XTILE)) {
867861
tile_release();
868-
fpregs_deactivate(&current->thread.fpu);
862+
__this_cpu_write(fpu_fpregs_owner_ctx, NULL);
869863
}
870864
}

0 commit comments

Comments
 (0)