@@ -218,7 +218,7 @@ void fpu_reset_from_exception_fixup(void)
218218}
219219
220220#if IS_ENABLED (CONFIG_KVM )
221- static void __fpstate_reset (struct fpstate * fpstate , u64 xfd );
221+ static void __fpstate_reset (struct fpstate * fpstate );
222222
223223static void fpu_lock_guest_permissions (void )
224224{
@@ -253,8 +253,7 @@ bool fpu_alloc_guest_fpstate(struct fpu_guest *gfpu)
253253 fpstate -> is_valloc = true;
254254 fpstate -> is_guest = true;
255255
256- /* Leave xfd to 0 (the reset value defined by spec) */
257- __fpstate_reset (fpstate , 0 );
256+ __fpstate_reset (fpstate );
258257 fpstate_init_user (fpstate );
259258
260259 gfpu -> fpstate = fpstate ;
@@ -545,33 +544,37 @@ void fpstate_init_user(struct fpstate *fpstate)
545544 fpstate_init_fstate (fpstate );
546545}
547546
548- static void __fpstate_reset (struct fpstate * fpstate , u64 xfd )
547+ static void __fpstate_reset (struct fpstate * fpstate )
549548{
550549 /*
551550 * Supervisor features (and thus sizes) may diverge between guest
552551 * FPUs and host FPUs, as some supervisor features are supported
553552 * for guests despite not being utilized by the host. User
554553 * features and sizes are always identical, which allows for
555554 * 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.
556558 */
557559 if (fpstate -> is_guest ) {
558560 fpstate -> size = guest_default_cfg .size ;
559561 fpstate -> xfeatures = guest_default_cfg .features ;
562+ fpstate -> xfd = 0 ;
560563 } else {
561564 fpstate -> size = fpu_kernel_cfg .default_size ;
562565 fpstate -> xfeatures = fpu_kernel_cfg .default_features ;
566+ fpstate -> xfd = init_fpstate .xfd ;
563567 }
564568
565569 fpstate -> user_size = fpu_user_cfg .default_size ;
566570 fpstate -> user_xfeatures = fpu_user_cfg .default_features ;
567- fpstate -> xfd = xfd ;
568571}
569572
570573void fpstate_reset (struct fpu * fpu )
571574{
572575 /* Set the fpstate pointer to the default fpstate */
573576 fpu -> fpstate = & fpu -> __fpstate ;
574- __fpstate_reset (fpu -> fpstate , init_fpstate . xfd );
577+ __fpstate_reset (fpu -> fpstate );
575578
576579 /* Initialize the permission related info in fpu */
577580 fpu -> perm .__state_perm = fpu_kernel_cfg .default_features ;
0 commit comments