@@ -94,25 +94,15 @@ static void vc_finish_insn(struct es_em_ctxt *ctxt)
9494 ctxt -> regs -> ip += ctxt -> insn .length ;
9595}
9696
97- static enum es_result sev_es_ghcb_hv_call (struct ghcb * ghcb ,
98- struct es_em_ctxt * ctxt ,
99- u64 exit_code , u64 exit_info_1 ,
100- u64 exit_info_2 )
97+ static enum es_result verify_exception_info (struct ghcb * ghcb , struct es_em_ctxt * ctxt )
10198{
102- enum es_result ret ;
99+ u32 ret ;
103100
104- /* Fill in protocol and format specifiers */
105- ghcb -> protocol_version = GHCB_PROTOCOL_MAX ;
106- ghcb -> ghcb_usage = GHCB_DEFAULT_USAGE ;
101+ ret = ghcb -> save . sw_exit_info_1 & GENMASK_ULL ( 31 , 0 );
102+ if (! ret )
103+ return ES_OK ;
107104
108- ghcb_set_sw_exit_code (ghcb , exit_code );
109- ghcb_set_sw_exit_info_1 (ghcb , exit_info_1 );
110- ghcb_set_sw_exit_info_2 (ghcb , exit_info_2 );
111-
112- sev_es_wr_ghcb_msr (__pa (ghcb ));
113- VMGEXIT ();
114-
115- if ((ghcb -> save .sw_exit_info_1 & 0xffffffff ) == 1 ) {
105+ if (ret == 1 ) {
116106 u64 info = ghcb -> save .sw_exit_info_2 ;
117107 unsigned long v ;
118108
@@ -124,19 +114,34 @@ static enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb,
124114 ((v == X86_TRAP_GP ) || (v == X86_TRAP_UD )) &&
125115 ((info & SVM_EVTINJ_TYPE_MASK ) == SVM_EVTINJ_TYPE_EXEPT )) {
126116 ctxt -> fi .vector = v ;
117+
127118 if (info & SVM_EVTINJ_VALID_ERR )
128119 ctxt -> fi .error_code = info >> 32 ;
129- ret = ES_EXCEPTION ;
130- } else {
131- ret = ES_VMM_ERROR ;
120+
121+ return ES_EXCEPTION ;
132122 }
133- } else if (ghcb -> save .sw_exit_info_1 & 0xffffffff ) {
134- ret = ES_VMM_ERROR ;
135- } else {
136- ret = ES_OK ;
137123 }
138124
139- return ret ;
125+ return ES_VMM_ERROR ;
126+ }
127+
128+ static enum es_result sev_es_ghcb_hv_call (struct ghcb * ghcb ,
129+ struct es_em_ctxt * ctxt ,
130+ u64 exit_code , u64 exit_info_1 ,
131+ u64 exit_info_2 )
132+ {
133+ /* Fill in protocol and format specifiers */
134+ ghcb -> protocol_version = GHCB_PROTOCOL_MAX ;
135+ ghcb -> ghcb_usage = GHCB_DEFAULT_USAGE ;
136+
137+ ghcb_set_sw_exit_code (ghcb , exit_code );
138+ ghcb_set_sw_exit_info_1 (ghcb , exit_info_1 );
139+ ghcb_set_sw_exit_info_2 (ghcb , exit_info_2 );
140+
141+ sev_es_wr_ghcb_msr (__pa (ghcb ));
142+ VMGEXIT ();
143+
144+ return verify_exception_info (ghcb , ctxt );
140145}
141146
142147/*
0 commit comments