@@ -523,39 +523,13 @@ static inline void switch_fpu_prepare(struct fpu *old_fpu, int cpu)
523
523
*/
524
524
525
525
/*
526
- * Load PKRU from the FPU context if available. Delay loading of the
527
- * complete FPU state until the return to userland .
526
+ * Delay loading of the complete FPU state until the return to userland.
527
+ * PKRU is handled separately .
528
528
*/
529
529
static inline void switch_fpu_finish (struct fpu * new_fpu )
530
530
{
531
- u32 pkru_val = init_pkru_value ;
532
- struct pkru_state * pk ;
533
-
534
- if (!static_cpu_has (X86_FEATURE_FPU ))
535
- return ;
536
-
537
- set_thread_flag (TIF_NEED_FPU_LOAD );
538
-
539
- if (!cpu_feature_enabled (X86_FEATURE_OSPKE ))
540
- return ;
541
-
542
- /*
543
- * PKRU state is switched eagerly because it needs to be valid before we
544
- * return to userland e.g. for a copy_to_user() operation.
545
- */
546
- if (!(current -> flags & PF_KTHREAD )) {
547
- /*
548
- * If the PKRU bit in xsave.header.xfeatures is not set,
549
- * then the PKRU component was in init state, which means
550
- * XRSTOR will set PKRU to 0. If the bit is not set then
551
- * get_xsave_addr() will return NULL because the PKRU value
552
- * in memory is not valid. This means pkru_val has to be
553
- * set to 0 and not to init_pkru_value.
554
- */
555
- pk = get_xsave_addr (& new_fpu -> state .xsave , XFEATURE_PKRU );
556
- pkru_val = pk ? pk -> pkru : 0 ;
557
- }
558
- __write_pkru (pkru_val );
531
+ if (cpu_feature_enabled (X86_FEATURE_FPU ))
532
+ set_thread_flag (TIF_NEED_FPU_LOAD );
559
533
}
560
534
561
535
#endif /* _ASM_X86_FPU_INTERNAL_H */
0 commit comments