Skip to content

Commit 4129b72

Browse files
Shuo A Liuwenlingz
authored andcommitted
hv: remove unnecessary cancel_event_injection related stuff
cancel_event_injection is not need any more if we do 'scheudle' prior to acrn_handle_pending_request. Commit "921288a6672: hv: fix interrupt lost when do acrn_handle_pending_request twice" bring 'schedule' forward, so remove cancel_event_injection related stuff. Tracked-On: #3374 Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
1 parent ea84917 commit 4129b72

File tree

4 files changed

+20
-74
lines changed

4 files changed

+20
-74
lines changed

hypervisor/arch/x86/guest/vcpu.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ void reset_vcpu(struct acrn_vcpu *vcpu)
579579
vcpu->arch.exception_info.exception = VECTOR_INVALID;
580580
vcpu->arch.cur_context = NORMAL_WORLD;
581581
vcpu->arch.irq_window_enabled = false;
582-
vcpu->arch.inject_event_pending = false;
583582
(void)memset((void *)vcpu->arch.vmcs, 0U, PAGE_SIZE);
584583

585584
for (i = 0; i < NR_WORLD; i++) {
@@ -646,9 +645,6 @@ static void context_switch_out(struct sched_object *prev)
646645
{
647646
struct acrn_vcpu *vcpu = list_entry(prev, struct acrn_vcpu, sched_obj);
648647

649-
/* cancel event(int, gp, nmi and exception) injection */
650-
cancel_event_injection(vcpu);
651-
652648
atomic_store32(&vcpu->running, 0U);
653649
/* do prev vcpu context switch out */
654650
/* For now, we don't need to invalid ept.

hypervisor/arch/x86/guest/virq.c

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,6 @@ int32_t acrn_handle_pending_request(struct acrn_vcpu *vcpu)
365365
bool injected = false;
366366
int32_t ret = 0;
367367
uint32_t tmp;
368-
uint32_t intr_info;
369-
uint32_t error_code;
370368
struct acrn_vcpu_arch *arch = &vcpu->arch;
371369
uint64_t *pending_req_bits = &arch->pending_req;
372370

@@ -387,42 +385,28 @@ int32_t acrn_handle_pending_request(struct acrn_vcpu *vcpu)
387385
vcpu_set_vmcs_eoi_exit(vcpu);
388386
}
389387

390-
/* handling cancelled event injection when vcpu is switched out */
391-
if (arch->inject_event_pending) {
392-
if ((arch->inject_info.intr_info & (EXCEPTION_ERROR_CODE_VALID << 8U)) != 0U) {
393-
error_code = arch->inject_info.error_code;
394-
exec_vmwrite32(VMX_ENTRY_EXCEPTION_ERROR_CODE, error_code);
395-
}
396-
397-
intr_info = arch->inject_info.intr_info;
398-
exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD, intr_info);
399-
400-
arch->inject_event_pending = false;
401-
injected = true;
402-
} else {
403-
/* SDM Vol 3 - table 6-2, inject high priority exception before
404-
* maskable hardware interrupt */
405-
injected = vcpu_inject_hi_exception(vcpu);
406-
if (!injected) {
407-
/* inject NMI before maskable hardware interrupt */
408-
if (bitmap_test_and_clear_lock(ACRN_REQUEST_NMI, pending_req_bits)) {
409-
/* Inject NMI vector = 2 */
410-
exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD,
388+
/* SDM Vol 3 - table 6-2, inject high priority exception before
389+
* maskable hardware interrupt */
390+
injected = vcpu_inject_hi_exception(vcpu);
391+
if (!injected) {
392+
/* inject NMI before maskable hardware interrupt */
393+
if (bitmap_test_and_clear_lock(ACRN_REQUEST_NMI, pending_req_bits)) {
394+
/* Inject NMI vector = 2 */
395+
exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD,
411396
VMX_INT_INFO_VALID | (VMX_INT_TYPE_NMI << 8U) | IDT_NMI);
397+
injected = true;
398+
} else {
399+
/* handling pending vector injection:
400+
* there are many reason inject failed, we need re-inject again
401+
* here should take care
402+
* - SW exception (not maskable by IF)
403+
* - external interrupt, if IF clear, will keep in IDT_VEC_INFO_FIELD
404+
* at next vm exit?
405+
*/
406+
if ((arch->idt_vectoring_info & VMX_INT_INFO_VALID) != 0U) {
407+
exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD, arch->idt_vectoring_info);
408+
arch->idt_vectoring_info = 0U;
412409
injected = true;
413-
} else {
414-
/* handling pending vector injection:
415-
* there are many reason inject failed, we need re-inject again
416-
* here should take care
417-
* - SW exception (not maskable by IF)
418-
* - external interrupt, if IF clear, will keep in IDT_VEC_INFO_FIELD
419-
* at next vm exit?
420-
*/
421-
if ((arch->idt_vectoring_info & VMX_INT_INFO_VALID) != 0U) {
422-
exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD, arch->idt_vectoring_info);
423-
arch->idt_vectoring_info = 0U;
424-
injected = true;
425-
}
426410
}
427411
}
428412
}
@@ -485,31 +469,6 @@ static inline bool acrn_inject_pending_intr(struct acrn_vcpu *vcpu,
485469
return ret;
486470
}
487471

488-
void cancel_event_injection(struct acrn_vcpu *vcpu)
489-
{
490-
uint32_t intinfo;
491-
492-
intinfo = exec_vmread32(VMX_ENTRY_INT_INFO_FIELD);
493-
494-
/*
495-
* If event is injected, we clear VMX_ENTRY_INT_INFO_FIELD,
496-
* save injection info, and mark inject event pending.
497-
* The event will be re-injected in next acrn_handle_pending_request
498-
* call.
499-
*/
500-
if ((intinfo & VMX_INT_INFO_VALID) != 0U) {
501-
vcpu->arch.inject_event_pending = true;
502-
503-
if ((intinfo & (EXCEPTION_ERROR_CODE_VALID << 8U)) != 0U) {
504-
vcpu->arch.inject_info.error_code =
505-
exec_vmread32(VMX_ENTRY_EXCEPTION_ERROR_CODE);
506-
}
507-
508-
vcpu->arch.inject_info.intr_info = intinfo;
509-
exec_vmwrite32(VMX_ENTRY_INT_INFO_FIELD, 0U);
510-
}
511-
}
512-
513472
/*
514473
* @pre vcpu != NULL
515474
*/

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,6 @@ struct ext_context {
264264

265265
#define EOI_EXIT_BITMAP_SIZE 256U
266266

267-
struct event_injection_info {
268-
uint32_t intr_info;
269-
uint32_t error_code;
270-
};
271-
272267
struct cpu_context {
273268
struct run_context run_ctx;
274269
struct ext_context ext_ctx;
@@ -339,8 +334,6 @@ struct acrn_vcpu_arch {
339334

340335
/* interrupt injection information */
341336
uint64_t pending_req;
342-
bool inject_event_pending;
343-
struct event_injection_info inject_info;
344337

345338
/* List of MSRS to be stored and loaded on VM exits or VM entries */
346339
struct msr_store_area msr_area;

hypervisor/include/arch/x86/irq.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ int32_t interrupt_window_vmexit_handler(struct acrn_vcpu *vcpu);
210210
int32_t external_interrupt_vmexit_handler(struct acrn_vcpu *vcpu);
211211
int32_t acrn_handle_pending_request(struct acrn_vcpu *vcpu);
212212

213-
void cancel_event_injection(struct acrn_vcpu *vcpu);
214-
215213
extern uint64_t irq_alloc_bitmap[IRQ_ALLOC_BITMAP_SIZE];
216214

217215
typedef void (*irq_action_t)(uint32_t irq, void *priv_data);

0 commit comments

Comments
 (0)