diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2017-08-28 02:47:59 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-08-29 06:07:29 -0400 |
commit | facaa3e3c813848e6b49ee37a42a3688832e63cd (patch) | |
tree | 0e7fc7f9efd1aa19fd3e4d076d9cf673c6830d45 | |
parent | 4447ac1195a845b18f2f427686f116ab77c5b268 (diff) |
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 <tglx@linutronix.de>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20170828064959.663008004@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/desc.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/idt.c | 33 | ||||
-rw-r--r-- | arch/x86/kernel/kvm.c | 2 |
3 files changed, 22 insertions, 15 deletions
diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h index 33f84f29a724..1a2ba368da39 100644 --- a/arch/x86/include/asm/desc.h +++ b/arch/x86/include/asm/desc.h | |||
@@ -390,7 +390,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit) | |||
390 | desc->limit1 = (limit >> 16) & 0xf; | 390 | desc->limit1 = (limit >> 16) & 0xf; |
391 | } | 391 | } |
392 | 392 | ||
393 | void set_intr_gate(unsigned int n, const void *addr); | 393 | void update_intr_gate(unsigned int n, const void *addr); |
394 | void alloc_intr_gate(unsigned int n, const void *addr); | 394 | void alloc_intr_gate(unsigned int n, const void *addr); |
395 | 395 | ||
396 | extern unsigned long used_vectors[]; | 396 | extern unsigned long used_vectors[]; |
diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c index b609eac3d73c..61b490c69250 100644 --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c | |||
@@ -225,6 +225,22 @@ idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sy | |||
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
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 | |||
228 | /** | 244 | /** |
229 | * idt_setup_early_traps - Initialize the idt table with early traps | 245 | * idt_setup_early_traps - Initialize the idt table with early traps |
230 | * | 246 | * |
@@ -336,20 +352,11 @@ void idt_invalidate(void *addr) | |||
336 | load_idt(&idt); | 352 | load_idt(&idt); |
337 | } | 353 | } |
338 | 354 | ||
339 | void set_intr_gate(unsigned int n, const void *addr) | 355 | void __init update_intr_gate(unsigned int n, const void *addr) |
340 | { | 356 | { |
341 | struct idt_data data; | 357 | if (WARN_ON_ONCE(!test_bit(n, used_vectors))) |
342 | 358 | return; | |
343 | BUG_ON(n > 0xFF); | 359 | set_intr_gate(n, addr); |
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); | ||
353 | } | 360 | } |
354 | 361 | ||
355 | void alloc_intr_gate(unsigned int n, const void *addr) | 362 | void alloc_intr_gate(unsigned int n, const void *addr) |
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 6ed9242b5fa7..874827b0d7ca 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c | |||
@@ -455,7 +455,7 @@ static int kvm_cpu_down_prepare(unsigned int cpu) | |||
455 | 455 | ||
456 | static void __init kvm_apf_trap_init(void) | 456 | static void __init kvm_apf_trap_init(void) |
457 | { | 457 | { |
458 | set_intr_gate(14, async_page_fault); | 458 | update_intr_gate(X86_TRAP_PF, async_page_fault); |
459 | } | 459 | } |
460 | 460 | ||
461 | void __init kvm_guest_init(void) | 461 | void __init kvm_guest_init(void) |