Skip to content

Commit facaa3e

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/idt: Hide set_intr_gate()
set_intr_gate() is an internal function of the IDT code. The only user left is the KVM code which replaces the pagefault handler eventually. Provide an explicit update_intr_gate() function and make set_intr_gate() static. While at it replace the magic number 14 in the KVM code with the proper trap define. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Paolo Bonzini <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 4447ac1 commit facaa3e

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

arch/x86/include/asm/desc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
390390
desc->limit1 = (limit >> 16) & 0xf;
391391
}
392392

393-
void set_intr_gate(unsigned int n, const void *addr);
393+
void update_intr_gate(unsigned int n, const void *addr);
394394
void alloc_intr_gate(unsigned int n, const void *addr);
395395

396396
extern unsigned long used_vectors[];

arch/x86/kernel/idt.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,22 @@ idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sy
225225
}
226226
}
227227

228+
static void set_intr_gate(unsigned int n, const void *addr)
229+
{
230+
struct idt_data data;
231+
232+
BUG_ON(n > 0xFF);
233+
234+
memset(&data, 0, sizeof(data));
235+
data.vector = n;
236+
data.addr = addr;
237+
data.segment = __KERNEL_CS;
238+
data.bits.type = GATE_INTERRUPT;
239+
data.bits.p = 1;
240+
241+
idt_setup_from_table(idt_table, &data, 1, false);
242+
}
243+
228244
/**
229245
* idt_setup_early_traps - Initialize the idt table with early traps
230246
*
@@ -336,20 +352,11 @@ void idt_invalidate(void *addr)
336352
load_idt(&idt);
337353
}
338354

339-
void set_intr_gate(unsigned int n, const void *addr)
355+
void __init update_intr_gate(unsigned int n, const void *addr)
340356
{
341-
struct idt_data data;
342-
343-
BUG_ON(n > 0xFF);
344-
345-
memset(&data, 0, sizeof(data));
346-
data.vector = n;
347-
data.addr = addr;
348-
data.segment = __KERNEL_CS;
349-
data.bits.type = GATE_INTERRUPT;
350-
data.bits.p = 1;
351-
352-
idt_setup_from_table(idt_table, &data, 1, false);
357+
if (WARN_ON_ONCE(!test_bit(n, used_vectors)))
358+
return;
359+
set_intr_gate(n, addr);
353360
}
354361

355362
void alloc_intr_gate(unsigned int n, const void *addr)

arch/x86/kernel/kvm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ static int kvm_cpu_down_prepare(unsigned int cpu)
455455

456456
static void __init kvm_apf_trap_init(void)
457457
{
458-
set_intr_gate(14, async_page_fault);
458+
update_intr_gate(X86_TRAP_PF, async_page_fault);
459459
}
460460

461461
void __init kvm_guest_init(void)

0 commit comments

Comments
 (0)