@@ -218,7 +218,7 @@ void fpu_reset_from_exception_fixup(void)
218
218
}
219
219
220
220
#if IS_ENABLED (CONFIG_KVM )
221
- static void __fpstate_reset (struct fpstate * fpstate , u64 xfd );
221
+ static void __fpstate_reset (struct fpstate * fpstate );
222
222
223
223
static void fpu_lock_guest_permissions (void )
224
224
{
@@ -253,8 +253,7 @@ bool fpu_alloc_guest_fpstate(struct fpu_guest *gfpu)
253
253
fpstate -> is_valloc = true;
254
254
fpstate -> is_guest = true;
255
255
256
- /* Leave xfd to 0 (the reset value defined by spec) */
257
- __fpstate_reset (fpstate , 0 );
256
+ __fpstate_reset (fpstate );
258
257
fpstate_init_user (fpstate );
259
258
260
259
gfpu -> fpstate = fpstate ;
@@ -545,33 +544,37 @@ void fpstate_init_user(struct fpstate *fpstate)
545
544
fpstate_init_fstate (fpstate );
546
545
}
547
546
548
- static void __fpstate_reset (struct fpstate * fpstate , u64 xfd )
547
+ static void __fpstate_reset (struct fpstate * fpstate )
549
548
{
550
549
/*
551
550
* Supervisor features (and thus sizes) may diverge between guest
552
551
* FPUs and host FPUs, as some supervisor features are supported
553
552
* for guests despite not being utilized by the host. User
554
553
* features and sizes are always identical, which allows for
555
554
* common guest and userspace ABI.
555
+ *
556
+ * For the host, set XFD to the kernel's desired initialization
557
+ * value. For guests, set XFD to its architectural RESET value.
556
558
*/
557
559
if (fpstate -> is_guest ) {
558
560
fpstate -> size = guest_default_cfg .size ;
559
561
fpstate -> xfeatures = guest_default_cfg .features ;
562
+ fpstate -> xfd = 0 ;
560
563
} else {
561
564
fpstate -> size = fpu_kernel_cfg .default_size ;
562
565
fpstate -> xfeatures = fpu_kernel_cfg .default_features ;
566
+ fpstate -> xfd = init_fpstate .xfd ;
563
567
}
564
568
565
569
fpstate -> user_size = fpu_user_cfg .default_size ;
566
570
fpstate -> user_xfeatures = fpu_user_cfg .default_features ;
567
- fpstate -> xfd = xfd ;
568
571
}
569
572
570
573
void fpstate_reset (struct fpu * fpu )
571
574
{
572
575
/* Set the fpstate pointer to the default fpstate */
573
576
fpu -> fpstate = & fpu -> __fpstate ;
574
- __fpstate_reset (fpu -> fpstate , init_fpstate . xfd );
577
+ __fpstate_reset (fpu -> fpstate );
575
578
576
579
/* Initialize the permission related info in fpu */
577
580
fpu -> perm .__state_perm = fpu_kernel_cfg .default_features ;
0 commit comments