@@ -3410,8 +3410,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm)
34103410 dump_ghcb (svm );
34113411 }
34123412
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 );
34153414
34163415 /* Resume the guest to "return" the error code. */
34173416 return 1 ;
@@ -3554,8 +3553,7 @@ static int setup_vmgexit_scratch(struct vcpu_svm *svm, bool sync, u64 len)
35543553 return 0 ;
35553554
35563555e_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 );
35593557
35603558 return 1 ;
35613559}
@@ -3655,7 +3653,14 @@ static void snp_complete_psc(struct vcpu_svm *svm, u64 psc_ret)
36553653 svm -> sev_es .psc_inflight = 0 ;
36563654 svm -> sev_es .psc_idx = 0 ;
36573655 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 );
36593664}
36603665
36613666static 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_
40584063 goto out_unlock ;
40594064 }
40604065
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 ));
40624068
40634069 ret = 1 ; /* resume guest */
40644070
@@ -4114,8 +4120,7 @@ static int snp_handle_ext_guest_req(struct vcpu_svm *svm, gpa_t req_gpa, gpa_t r
41144120 return snp_handle_guest_req (svm , req_gpa , resp_gpa );
41154121
41164122request_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 );
41194124 return 1 ; /* resume guest */
41204125}
41214126
@@ -4307,8 +4312,7 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
43074312 if (ret )
43084313 return ret ;
43094314
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 );
43124316
43134317 exit_code = kvm_ghcb_get_sw_exit_code (control );
43144318 switch (exit_code ) {
@@ -4352,21 +4356,19 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
43524356 break ;
43534357 case 1 :
43544358 /* 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 );
43564360 break ;
43574361 default :
43584362 pr_err ("svm: vmgexit: unsupported AP jump table request - exit_info_1=%#llx\n" ,
43594363 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 );
43624365 }
43634366
43644367 ret = 1 ;
43654368 break ;
43664369 }
43674370 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 );
43704372 ret = 1 ;
43714373 break ;
43724374 case SVM_VMGEXIT_TERM_REQUEST :
@@ -4387,8 +4389,7 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu)
43874389 case SVM_VMGEXIT_AP_CREATION :
43884390 ret = sev_snp_ap_creation (svm );
43894391 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 );
43924393 }
43934394
43944395 ret = 1 ;
@@ -4624,7 +4625,7 @@ void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
46244625 * Return from an AP Reset Hold VMGEXIT, where the guest will
46254626 * set the CS and RIP. Set SW_EXIT_INFO_2 to a non-zero value.
46264627 */
4627- ghcb_set_sw_exit_info_2 (svm -> sev_es . ghcb , 1 );
4628+ svm_vmgexit_success (svm , 1 );
46284629 break ;
46294630 case AP_RESET_HOLD_MSR_PROTO :
46304631 /*
0 commit comments