Skip to content

Commit 17e7171

Browse files
committed
x86/idt/hyperv: Create a block interrupt gates for redirected interrupts
Create a block interrupt gates that start at FIRST_HV_VTL_REDIRECTED_ VECTOR. Service this interrupt with the function hv_vtl_redirected_ interrupt(). Only tell the APIC that the interrupt has been handled. Subsequent changesets will use these interrupt vectors to deliver their corresponding proxy interrupts to a VTL0 guest. Signed-off-by: Ricardo Neri <[email protected]> --- Changes since v1: * None
1 parent 0252b0c commit 17e7171

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

arch/x86/include/asm/hw_irq.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ extern char irq_entries_start[];
121121

122122
extern char spurious_entries_start[];
123123

124+
#ifdef CONFIG_HYPERV_VTL_MODE
125+
extern char hv_vtl_redirected_entries_start[];
126+
#endif
127+
124128
#define VECTOR_UNUSED NULL
125129
#define VECTOR_SHUTDOWN ((void *)-1L)
126130
#define VECTOR_RETRIGGERED ((void *)-2L)

arch/x86/include/asm/idtentry.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,13 @@ DEFINE_IDTENTRY_STUBS(spurious_entries_start, FIRST_SYSTEM_VECTOR,
586586
NR_SYSTEM_VECTORS, spurious_interrupt)
587587
#endif
588588

589+
#ifdef CONFIG_HYPERV_VTL_MODE
590+
DEFINE_IDTENTRY_STUBS(hv_vtl_redirected_entries_start,
591+
FIRST_HV_VTL_REDIRECTED_VECTOR,
592+
NR_HV_VTL_REDIRECTED_VECTORS,
593+
hv_vtl_redirected_interrupt)
594+
#endif
595+
589596
#endif /* __ASSEMBLY__ */
590597

591598
/*
@@ -768,6 +775,9 @@ DECLARE_IDTENTRY_SYSVEC(POSTED_MSI_NOTIFICATION_VECTOR, sysvec_posted_msi_notifi
768775
DECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR, sysvec_hyperv_callback);
769776
DECLARE_IDTENTRY_SYSVEC(HYPERV_REENLIGHTENMENT_VECTOR, sysvec_hyperv_reenlightenment);
770777
DECLARE_IDTENTRY_SYSVEC(HYPERV_STIMER0_VECTOR, sysvec_hyperv_stimer0);
778+
#ifdef CONFIG_HYPERV_VTL_MODE
779+
DECLARE_IDTENTRY_IRQ(X86_TRAP_OTHER, hv_vtl_redirected_interrupt);
780+
#endif
771781
#endif
772782

773783
#if IS_ENABLED(CONFIG_ACRN_GUEST)

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_hyperv_stimer0)
165165
set_irq_regs(old_regs);
166166
}
167167

168+
#ifdef CONFIG_HYPERV_VTL_MODE
169+
DEFINE_IDTENTRY_IRQ(hv_vtl_redirected_interrupt)
170+
{
171+
apic_eoi();
172+
}
173+
#endif
174+
168175
/* For x86/x64, override weak placeholders in hyperv_timer.c */
169176
void hv_setup_stimer0_handler(void (*handler)(void))
170177
{

arch/x86/kernel/idt.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,20 @@ static void __init idt_map_in_cea(void)
278278
idt_descr.address = CPU_ENTRY_AREA_RO_IDT;
279279
}
280280

281+
static void __init idt_setup_hv_vtl_redirected_vectors(void)
282+
{
283+
#ifdef CONFIG_HYPERV_VTL_MODE
284+
int i = FIRST_HV_VTL_REDIRECTED_VECTOR;
285+
286+
for (i = FIRST_HV_VTL_REDIRECTED_VECTOR; i < FIRST_SYSTEM_VECTOR; i++) {
287+
void *entry = hv_vtl_redirected_entries_start +
288+
IDT_ALIGN * (i - FIRST_HV_VTL_REDIRECTED_VECTOR);
289+
if (!WARN_ON(test_and_set_bit(i, system_vectors)))
290+
set_intr_gate(i, entry);
291+
}
292+
#endif
293+
}
294+
281295
/**
282296
* idt_setup_apic_and_irq_gates - Setup APIC/SMP and normal interrupt gates
283297
*/
@@ -288,6 +302,8 @@ void __init idt_setup_apic_and_irq_gates(void)
288302

289303
idt_setup_from_table(idt_table, apic_idts, ARRAY_SIZE(apic_idts), true);
290304

305+
idt_setup_hv_vtl_redirected_vectors();
306+
291307
for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR) {
292308
entry = irq_entries_start + IDT_ALIGN * (i - FIRST_EXTERNAL_VECTOR);
293309
set_intr_gate(i, entry);

0 commit comments

Comments
 (0)