Skip to content

Commit 2686fe7

Browse files
mingqiangchilijinxia
authored andcommitted
hv: no need to return error when inject GP
GP fault is a normal case,no need to return error. Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 809eb9f commit 2686fe7

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

hypervisor/arch/x86/virq.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,10 @@ void vcpu_inject_nmi(struct vcpu *vcpu)
290290
vcpu_make_request(vcpu, ACRN_REQUEST_NMI);
291291
}
292292

293-
int vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code)
293+
void vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code)
294294
{
295295
vcpu_queue_exception(vcpu, IDT_GP, err_code);
296296
vcpu_make_request(vcpu, ACRN_REQUEST_EXCP);
297-
return 0;
298297
}
299298

300299
int vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code)

hypervisor/arch/x86/vmexit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ static int xsetbv_vmexit_handler(struct vcpu *vcpu)
308308
val64 = exec_vmread(VMX_GUEST_CR4);
309309
if ((val64 & CR4_OSXSAVE) == 0U) {
310310
vcpu_inject_gp(vcpu, 0U);
311-
return -1;
311+
return 0;
312312
}
313313

314314
idx = vcpu->arch_vcpu.cur_context;
@@ -320,7 +320,7 @@ static int xsetbv_vmexit_handler(struct vcpu *vcpu)
320320
/*to access XCR0,'rcx' should be 0*/
321321
if (ctx_ptr->guest_cpu_regs.regs.rcx != 0UL) {
322322
vcpu_inject_gp(vcpu, 0U);
323-
return -1;
323+
return 0;
324324
}
325325

326326
val64 = ((ctx_ptr->guest_cpu_regs.regs.rax) & 0xffffffffUL) |
@@ -329,7 +329,7 @@ static int xsetbv_vmexit_handler(struct vcpu *vcpu)
329329
/*bit 0(x87 state) of XCR0 can't be cleared*/
330330
if ((val64 & 0x01UL) == 0UL) {
331331
vcpu_inject_gp(vcpu, 0U);
332-
return -1;
332+
return 0;
333333
}
334334

335335
/*XCR0[2:1] (SSE state & AVX state) can't not be
@@ -338,7 +338,7 @@ static int xsetbv_vmexit_handler(struct vcpu *vcpu)
338338
**/
339339
if (((val64 >> 1UL) & 0x3UL) == 0x2UL) {
340340
vcpu_inject_gp(vcpu, 0U);
341-
return -1;
341+
return 0;
342342
}
343343

344344
write_xcr(0, val64);

hypervisor/arch/x86/vmx.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ int vmx_wrmsr_pat(struct vcpu *vcpu, uint64_t value)
317317
(PAT_FIELD_RSV_BITS & field) != 0U)) {
318318
pr_err("invalid guest IA32_PAT: 0x%016llx", value);
319319
vcpu_inject_gp(vcpu, 0U);
320-
return -EINVAL;
320+
return 0;
321321
}
322322
}
323323

@@ -365,7 +365,7 @@ int vmx_write_cr0(struct vcpu *vcpu, uint64_t cr0)
365365
if ((cr0 & (cr0_always_off_mask | CR0_RESERVED_MASK)) != 0U) {
366366
pr_err("Not allow to set always off / reserved bits for CR0");
367367
vcpu_inject_gp(vcpu, 0U);
368-
return -EINVAL;
368+
return 0;
369369
}
370370

371371
/* TODO: Check all invalid guest statuses according to the change of
@@ -376,7 +376,7 @@ int vmx_write_cr0(struct vcpu *vcpu, uint64_t cr0)
376376
if ((context->cr4 & CR4_PAE) == 0U) {
377377
pr_err("Can't enable long mode when PAE disabled");
378378
vcpu_inject_gp(vcpu, 0U);
379-
return -EINVAL;
379+
return 0;
380380
}
381381
/* Enable long mode */
382382
pr_dbg("VMM: Enable long mode");
@@ -403,7 +403,7 @@ int vmx_write_cr0(struct vcpu *vcpu, uint64_t cr0)
403403
if ((cr0 & CR0_CD) == 0U && ((cr0 & CR0_NW) != 0U)) {
404404
pr_err("not allow to set CR0.NW while clearing CR0.CD");
405405
vcpu_inject_gp(vcpu, 0U);
406-
return -EINVAL;
406+
return 0;
407407
}
408408

409409
/* No action if only CR0.NW is changed */
@@ -500,14 +500,14 @@ int vmx_write_cr4(struct vcpu *vcpu, uint64_t cr4)
500500
if((cr4 & cr4_always_off_mask) != 0U) {
501501
pr_err("Not allow to set reserved/always off bits for CR4");
502502
vcpu_inject_gp(vcpu, 0U);
503-
return -EINVAL;
503+
return 0;
504504
}
505505

506506
/* Do NOT support nested guest */
507507
if ((cr4 & CR4_VMXE) != 0U) {
508508
pr_err("Nested guest not supported");
509509
vcpu_inject_gp(vcpu, 0U);
510-
return -EINVAL;
510+
return 0;
511511
}
512512

513513
/* Aways off bits and reserved bits has been filtered above */

hypervisor/include/arch/x86/irq.h

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

9797
void vcpu_inject_extint(struct vcpu *vcpu);
9898
void vcpu_inject_nmi(struct vcpu *vcpu);
99-
int vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code);
99+
void vcpu_inject_gp(struct vcpu *vcpu, uint32_t err_code);
100100
int vcpu_inject_pf(struct vcpu *vcpu, uint64_t addr, uint32_t err_code);
101101
void vcpu_make_request(struct vcpu *vcpu, int eventid);
102102
int vcpu_queue_exception(struct vcpu *vcpu, uint32_t vector, uint32_t err_code);

0 commit comments

Comments
 (0)