@@ -3410,8 +3410,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm)
3410
3410
dump_ghcb (svm );
3411
3411
}
3412
3412
3413
- ghcb_set_sw_exit_info_1 (svm -> sev_es .ghcb , GHCB_HV_RESP_MALFORMED_INPUT );
3414
- ghcb_set_sw_exit_info_2 (svm -> sev_es .ghcb , reason );
3413
+ svm_vmgexit_bad_input (svm , reason );
3415
3414
3416
3415
/* Resume the guest to "return" the error code. */
3417
3416
return 1 ;
@@ -3554,8 +3553,7 @@ static int setup_vmgexit_scratch(struct vcpu_svm *svm, bool sync, u64 len)
3554
3553
return 0 ;
3555
3554
3556
3555
e_scratch :
3557
- ghcb_set_sw_exit_info_1 (svm -> sev_es .ghcb , GHCB_HV_RESP_MALFORMED_INPUT );
3558
- ghcb_set_sw_exit_info_2 (svm -> sev_es .ghcb , GHCB_ERR_INVALID_SCRATCH_AREA );
3556
+ svm_vmgexit_bad_input (svm , GHCB_ERR_INVALID_SCRATCH_AREA );
3559
3557
3560
3558
return 1 ;
3561
3559
}
@@ -3655,7 +3653,14 @@ static void snp_complete_psc(struct vcpu_svm *svm, u64 psc_ret)
3655
3653
svm -> sev_es .psc_inflight = 0 ;
3656
3654
svm -> sev_es .psc_idx = 0 ;
3657
3655
svm -> sev_es .psc_2m = false;
3658
- ghcb_set_sw_exit_info_2 (svm -> sev_es .ghcb , psc_ret );
3656
+
3657
+ /*
3658
+ * PSC requests always get a "no action" response in SW_EXITINFO1, with
3659
+ * a PSC-specific return code in SW_EXITINFO2 that provides the "real"
3660
+ * return code. E.g. if the PSC request was interrupted, the need to
3661
+ * retry is communicated via SW_EXITINFO2, not SW_EXITINFO1.
3662
+ */
3663
+ svm_vmgexit_no_action (svm , psc_ret );
3659
3664
}
3660
3665
3661
3666
static void __snp_complete_one_psc (struct vcpu_svm * svm )
@@ -4058,7 +4063,8 @@ static int snp_handle_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t resp_
4058
4063
goto out_unlock ;
4059
4064
}
4060
4065
4061
- ghcb_set_sw_exit_info_2 (svm -> sev_es .ghcb , SNP_GUEST_ERR (0 , fw_err ));
4066
+ /* No action is requested *from KVM* if there was a firmware error. */
4067
+ svm_vmgexit_no_action (svm , SNP_GUEST_ERR (0 , fw_err ));
4062
4068
4063
4069
ret = 1 ; /* resume guest */
4064
4070
@@ -4114,8 +4120,7 @@ static int snp_handle_ext_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t r
4114
4120
return snp_handle_guest_req (svm , req_gpa , resp_gpa );
4115
4121
4116
4122
request_invalid :
4117
- ghcb_set_sw_exit_info_1 (svm -> sev_es .ghcb , GHCB_HV_RESP_MALFORMED_INPUT );
4118
- ghcb_set_sw_exit_info_2 (svm -> sev_es .ghcb , GHCB_ERR_INVALID_INPUT );
4123
+ svm_vmgexit_bad_input (svm , GHCB_ERR_INVALID_INPUT );
4119
4124
return 1 ; /* resume guest */
4120
4125
}
4121
4126
@@ -4307,8 +4312,7 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
4307
4312
if (ret )
4308
4313
return ret ;
4309
4314
4310
- ghcb_set_sw_exit_info_1 (svm -> sev_es .ghcb , GHCB_HV_RESP_NO_ACTION );
4311
- ghcb_set_sw_exit_info_2 (svm -> sev_es .ghcb , 0 );
4315
+ svm_vmgexit_success (svm , 0 );
4312
4316
4313
4317
exit_code = kvm_ghcb_get_sw_exit_code (control );
4314
4318
switch (exit_code ) {
@@ -4352,21 +4356,19 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
4352
4356
break ;
4353
4357
case 1 :
4354
4358
/* Get AP jump table address */
4355
- ghcb_set_sw_exit_info_2 (svm -> sev_es . ghcb , sev -> ap_jump_table );
4359
+ svm_vmgexit_success (svm , sev -> ap_jump_table );
4356
4360
break ;
4357
4361
default :
4358
4362
pr_err ("svm: vmgexit: unsupported AP jump table request - exit_info_1=%#llx\n" ,
4359
4363
control -> exit_info_1 );
4360
- ghcb_set_sw_exit_info_1 (svm -> sev_es .ghcb , GHCB_HV_RESP_MALFORMED_INPUT );
4361
- ghcb_set_sw_exit_info_2 (svm -> sev_es .ghcb , GHCB_ERR_INVALID_INPUT );
4364
+ svm_vmgexit_bad_input (svm , GHCB_ERR_INVALID_INPUT );
4362
4365
}
4363
4366
4364
4367
ret = 1 ;
4365
4368
break ;
4366
4369
}
4367
4370
case SVM_VMGEXIT_HV_FEATURES :
4368
- ghcb_set_sw_exit_info_2 (svm -> sev_es .ghcb , GHCB_HV_FT_SUPPORTED );
4369
-
4371
+ svm_vmgexit_success (svm , GHCB_HV_FT_SUPPORTED );
4370
4372
ret = 1 ;
4371
4373
break ;
4372
4374
case SVM_VMGEXIT_TERM_REQUEST :
@@ -4387,8 +4389,7 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
4387
4389
case SVM_VMGEXIT_AP_CREATION :
4388
4390
ret = sev_snp_ap_creation (svm );
4389
4391
if (ret ) {
4390
- ghcb_set_sw_exit_info_1 (svm -> sev_es .ghcb , GHCB_HV_RESP_MALFORMED_INPUT );
4391
- ghcb_set_sw_exit_info_2 (svm -> sev_es .ghcb , GHCB_ERR_INVALID_INPUT );
4392
+ svm_vmgexit_bad_input (svm , GHCB_ERR_INVALID_INPUT );
4392
4393
}
4393
4394
4394
4395
ret = 1 ;
@@ -4624,7 +4625,7 @@ void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
4624
4625
* Return from an AP Reset Hold VMGEXIT, where the guest will
4625
4626
* set the CS and RIP. Set SW_EXIT_INFO_2 to a non-zero value.
4626
4627
*/
4627
- ghcb_set_sw_exit_info_2 (svm -> sev_es . ghcb , 1 );
4628
+ svm_vmgexit_success (svm , 1 );
4628
4629
break ;
4629
4630
case AP_RESET_HOLD_MSR_PROTO :
4630
4631
/*
0 commit comments