Skip to content

Commit 75a03bf

Browse files
JasonChenCJlijinxia
authored andcommitted
exception: use func vcpu_queue_exception to inject exception
use func vcpu_queue_exception for vcpu_inject_gp and exception_vmexit_handler. Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Tian, Kevin <kevin.tian@intel.com>
1 parent ebc7ee2 commit 75a03bf

File tree

7 files changed

+20
-19
lines changed

7 files changed

+20
-19
lines changed

hypervisor/arch/x86/guest/vlapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ vlapic_set_cr8(struct vlapic *vlapic, uint64_t val)
930930
uint8_t tpr;
931931

932932
if (val & ~0xf) {
933-
vcpu_inject_gp(vlapic->vcpu);
933+
vcpu_inject_gp(vlapic->vcpu, 0);
934934
return;
935935
}
936936

hypervisor/arch/x86/guest/vmsr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ int rdmsr_vmexit_handler(struct vcpu *vcpu)
185185
case MSR_IA32_MTRR_CAP:
186186
case MSR_IA32_MTRR_DEF_TYPE:
187187
{
188-
vcpu_inject_gp(vcpu);
188+
vcpu_inject_gp(vcpu, 0);
189189
break;
190190
}
191191
case MSR_IA32_BIOS_SIGN_ID:
@@ -236,7 +236,7 @@ int rdmsr_vmexit_handler(struct vcpu *vcpu)
236236
msr <= MSR_IA32_VMX_TRUE_ENTRY_CTLS))) {
237237
pr_warn("rdmsr: %lx should not come here!", msr);
238238
}
239-
vcpu_inject_gp(vcpu);
239+
vcpu_inject_gp(vcpu, 0);
240240
v = 0;
241241
break;
242242
}
@@ -284,7 +284,7 @@ int wrmsr_vmexit_handler(struct vcpu *vcpu)
284284
case MSR_IA32_MTRR_CAP:
285285
case MSR_IA32_MTRR_DEF_TYPE:
286286
{
287-
vcpu_inject_gp(vcpu);
287+
vcpu_inject_gp(vcpu, 0);
288288
break;
289289
}
290290
case MSR_IA32_BIOS_SIGN_ID:
@@ -348,7 +348,7 @@ int wrmsr_vmexit_handler(struct vcpu *vcpu)
348348
msr <= MSR_IA32_VMX_TRUE_ENTRY_CTLS))) {
349349
pr_warn("rdmsr: %lx should not come here!", msr);
350350
}
351-
vcpu_inject_gp(vcpu);
351+
vcpu_inject_gp(vcpu, 0);
352352
break;
353353
}
354354
}

hypervisor/arch/x86/interrupt.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,10 @@ int vcpu_inject_nmi(struct vcpu *vcpu)
316316
return vcpu_make_request(vcpu, ACRN_REQUEST_NMI);
317317
}
318318

319-
int vcpu_inject_gp(struct vcpu *vcpu)
319+
int vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code)
320320
{
321-
return vcpu_make_request(vcpu, ACRN_REQUEST_GP);
321+
vcpu_queue_exception(vcpu, IDT_GP, err_code);
322+
return vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
322323
}
323324

324325
int interrupt_window_vmexit_handler(struct vcpu *vcpu)
@@ -533,8 +534,8 @@ int exception_vmexit_handler(struct vcpu *vcpu)
533534

534535
/* Handle all other exceptions */
535536
VCPU_RETAIN_RIP(vcpu);
536-
vcpu->arch_vcpu.exception_info.exception = exception_vector;
537-
vcpu->arch_vcpu.exception_info.error = int_err_code;
537+
538+
vcpu_queue_exception(vcpu, exception_vector, int_err_code);
538539

539540
if (exception_vector == IDT_MC) {
540541
/* just print error message for #MC, it then will be injected

hypervisor/arch/x86/vmexit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ static int xsetbv_vmexit_handler(struct vcpu *vcpu)
437437

438438
val64 = exec_vmread(VMX_GUEST_CR4);
439439
if (!(val64 & CR4_OSXSAVE)) {
440-
vcpu_inject_gp(vcpu);
440+
vcpu_inject_gp(vcpu, 0);
441441
return -1;
442442
}
443443

@@ -449,7 +449,7 @@ static int xsetbv_vmexit_handler(struct vcpu *vcpu)
449449

450450
/*to access XCR0,'rcx' should be 0*/
451451
if (ctx_ptr->guest_cpu_regs.regs.rcx != 0) {
452-
vcpu_inject_gp(vcpu);
452+
vcpu_inject_gp(vcpu, 0);
453453
return -1;
454454
}
455455

@@ -458,7 +458,7 @@ static int xsetbv_vmexit_handler(struct vcpu *vcpu)
458458

459459
/*bit 0(x87 state) of XCR0 can't be cleared*/
460460
if (!(val64 & 0x01)) {
461-
vcpu_inject_gp(vcpu);
461+
vcpu_inject_gp(vcpu, 0);
462462
return -1;
463463
}
464464

@@ -467,7 +467,7 @@ static int xsetbv_vmexit_handler(struct vcpu *vcpu)
467467
*to use AVX instructions.
468468
**/
469469
if (((val64 >> 1) & 0x3) == 0x2) {
470-
vcpu_inject_gp(vcpu);
470+
vcpu_inject_gp(vcpu, 0);
471471
return -1;
472472
}
473473

hypervisor/common/hv_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ void vcpu_thread(struct vcpu *vcpu)
117117
pr_fatal("dispatch VM exit handler failed for reason"
118118
" %d, ret = %d!",
119119
vcpu->arch_vcpu.exit_reason & 0xFFFF, ret);
120-
vcpu_inject_gp(vcpu);
120+
vcpu_inject_gp(vcpu, 0);
121121
continue;
122122
}
123123

hypervisor/include/arch/x86/guest/guest.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ int get_req_info(char *str, int str_max);
6464
/*
6565
* VCPU related APIs
6666
*/
67-
#define ACRN_REQUEST_EVENT 0
68-
#define ACRN_REQUEST_EXTINT 1
69-
#define ACRN_REQUEST_NMI 2
70-
#define ACRN_REQUEST_GP 3
67+
#define ACRN_REQUEST_EXCP 0
68+
#define ACRN_REQUEST_EVENT 1
69+
#define ACRN_REQUEST_EXTINT 2
70+
#define ACRN_REQUEST_NMI 3
7171
#define ACRN_REQUEST_TMR_UPDATE 4
7272
#define ACRN_REQUEST_TLB_FLUSH 5
7373
#define ACRN_REQUEST_TRP_FAULT 6

hypervisor/include/arch/x86/irq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ extern spurious_handler_t spurious_handler;
183183

184184
int vcpu_inject_extint(struct vcpu *vcpu);
185185
int vcpu_inject_nmi(struct vcpu *vcpu);
186-
int vcpu_inject_gp(struct vcpu *vcpu);
186+
int vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code);
187187
int vcpu_make_request(struct vcpu *vcpu, int eventid);
188188
int vcpu_queue_exception(struct vcpu *vcpu, int32_t vector, uint32_t err_code);
189189

0 commit comments

Comments
 (0)