Skip to content

Commit a87757d

Browse files
JasonChenCJjren1
authored andcommitted
uefi: remove old interrupt injection method
we added uefi stub for hv, and want vm0 continue running under uefi env to boot other uefi payload (osloader or bzImage). during this, the uefi timer irq need be handled elegantly. there are 3 types for uefi timer: 1. 8254 based on IRQ0 of PIC 2. HPET based on IOAPIC 3. HPET based on MSI currently, we only support type 3 (HPET+MSI). But we are following a in-correct flow to handle this timer interrupt: - we set VMX_ENTRY_INT_INFO_FIELD directly if a timer interrupt happened before vcpu launching, this will make its vlapic mess up, which finally cause hpet timer stop. this patch remove this in-correct approach, the new approach patch will be followed by next patch. Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
1 parent 23efb5a commit a87757d

File tree

5 files changed

+18
-46
lines changed

5 files changed

+18
-46
lines changed

hypervisor/arch/x86/interrupt.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,10 @@ int external_interrupt_handler(struct vcpu *vcpu)
270270
struct intr_ctx ctx;
271271

272272
ctx.vector = vector;
273-
/* do not RETAIN RIP for spurious interrupt */
274-
if (dispatch_interrupt(&ctx) == 0)
275-
VCPU_RETAIN_RIP(vcpu);
273+
274+
dispatch_interrupt(&ctx);
275+
276+
VCPU_RETAIN_RIP(vcpu);
276277

277278
TRACE_2L(TRC_VMEXIT_EXTERNAL_INTERRUPT, vector, 0);
278279

hypervisor/arch/x86/irq.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ void dispatch_exception(struct intr_ctx *ctx)
443443
cpu_halt(cpu_id);
444444
}
445445

446-
int handle_spurious_interrupt(int vector)
446+
void handle_spurious_interrupt(int vector)
447447
{
448448
send_lapic_eoi();
449449

@@ -452,13 +452,11 @@ int handle_spurious_interrupt(int vector)
452452
pr_warn("Spurious vector: 0x%x.", vector);
453453

454454
if (spurious_handler)
455-
return spurious_handler(vector);
456-
else
457-
return 0;
455+
spurious_handler(vector);
458456
}
459457

460458
/* do_IRQ() */
461-
int dispatch_interrupt(struct intr_ctx *ctx)
459+
void dispatch_interrupt(struct intr_ctx *ctx)
462460
{
463461
int vr = ctx->vector;
464462
int irq = vector_to_irq[vr];
@@ -479,9 +477,10 @@ int dispatch_interrupt(struct intr_ctx *ctx)
479477
}
480478

481479
desc->irq_handler(desc, desc->handler_data);
482-
return 0;
480+
return;
483481
ERR:
484-
return handle_spurious_interrupt(vr);
482+
handle_spurious_interrupt(vr);
483+
return;
485484
}
486485

487486
int handle_level_interrupt_common(struct irq_desc *desc,

hypervisor/arch/x86/vmx.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#ifdef CONFIG_EFI_STUB
3737
#include <acrn_efi.h>
3838
extern struct efi_ctx* efi_ctx;
39-
extern int efi_launch_vector;
4039
#endif
4140

4241
#define PAT_POWER_ON_VALUE (PAT_MEM_TYPE_WB + \
@@ -1282,16 +1281,10 @@ static void override_uefi_vmcs(struct vcpu *vcpu)
12821281
}
12831282

12841283
/* Interrupt */
1285-
if (efi_launch_vector > 0) {
1286-
field = VMX_GUEST_RFLAGS;
1287-
cur_context->rflags = 0x2;
1288-
cur_context->rflags |= 1 << 9; /* enable intr for efi stub */
1289-
exec_vmwrite(field, cur_context->rflags);
1290-
exec_vmwrite(VMX_ENTRY_INT_INFO_FIELD,
1291-
VMX_INT_INFO_VALID |
1292-
(efi_launch_vector & 0xFF));
1293-
efi_launch_vector = -1;
1294-
}
1284+
field = VMX_GUEST_RFLAGS;
1285+
cur_context->rflags = 0x2;
1286+
cur_context->rflags |= 1 << 9; /* enable intr for efi stub */
1287+
exec_vmwrite(field, cur_context->rflags);
12951288
}
12961289
#endif
12971290

hypervisor/bsp/uefi/uefi.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,12 @@
5656
uint32_t efi_physical_available_ap_bitmap = 0;
5757
uint32_t efi_wake_up_ap_bitmap = 0;
5858
struct efi_ctx* efi_ctx = NULL;
59-
int efi_launch_vector;
6059
extern uint32_t up_count;
6160
extern unsigned long pcpu_sync;
6261

63-
bool in_efi_boot_svc(void)
62+
void efi_spurious_handler(int vector)
6463
{
65-
return (efi_wake_up_ap_bitmap != efi_physical_available_ap_bitmap);
66-
}
67-
68-
int efi_spurious_handler(int vector)
69-
{
70-
struct vcpu* vcpu;
71-
72-
if (get_cpu_id() != 0)
73-
return 0;
74-
75-
vcpu = per_cpu(vcpu, 0);
76-
if (vcpu && vcpu->launched) {
77-
int ret = vlapic_set_intr(vcpu, vector, 0);
78-
if (ret && in_efi_boot_svc())
79-
exec_vmwrite(VMX_ENTRY_INT_INFO_FIELD,
80-
VMX_INT_INFO_VALID | vector);
81-
} else
82-
efi_launch_vector = vector;
83-
84-
return 1;
64+
return;
8565
}
8666

8767
int sipi_from_efi_boot_service_exit(uint32_t dest, uint32_t mode, uint32_t vec)
@@ -155,6 +135,5 @@ void init_bsp(void)
155135
vm_sw_loader = uefi_sw_loader;
156136

157137
spurious_handler = efi_spurious_handler;
158-
efi_launch_vector = -1;
159138
#endif
160139
}

hypervisor/include/arch/x86/irq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void update_irq_handler(int irq, irq_handler_t func);
111111

112112
int init_default_irqs(unsigned int cpu);
113113

114-
int dispatch_interrupt(struct intr_ctx *ctx);
114+
void dispatch_interrupt(struct intr_ctx *ctx);
115115

116116
struct dev_handler_node*
117117
pri_register_handler(int irq,
@@ -133,7 +133,7 @@ int get_cpu_interrupt_info(char *str, int str_max);
133133

134134
void setup_notification(void);
135135

136-
typedef int (*spurious_handler_t)(int);
136+
typedef void (*spurious_handler_t)(int);
137137
extern spurious_handler_t spurious_handler;
138138

139139
/*

0 commit comments

Comments
 (0)