hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/x86/include/asm/desc.h
....@@ -40,11 +40,6 @@
4040 desc->l = 0;
4141 }
4242
43
-extern struct desc_ptr idt_descr;
44
-extern gate_desc idt_table[];
45
-extern const struct desc_ptr debug_idt_descr;
46
-extern gate_desc debug_idt_table[];
47
-
4843 struct gdt_page {
4944 struct desc_struct gdt[GDT_ENTRIES];
5045 } __attribute__((aligned(PAGE_SIZE)));
....@@ -108,7 +103,7 @@
108103 return !(desc[0] | desc[1]);
109104 }
110105
111
-#ifdef CONFIG_PARAVIRT
106
+#ifdef CONFIG_PARAVIRT_XXL
112107 #include <asm/paravirt.h>
113108 #else
114109 #define load_TR_desc() native_load_tr_desc()
....@@ -134,7 +129,7 @@
134129 static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
135130 {
136131 }
137
-#endif /* CONFIG_PARAVIRT */
132
+#endif /* CONFIG_PARAVIRT_XXL */
138133
139134 #define store_ldt(ldt) asm("sldt %0" : "=m"(ldt))
140135
....@@ -214,7 +209,7 @@
214209 asm volatile("lgdt %0"::"m" (*dtr));
215210 }
216211
217
-static inline void native_load_idt(const struct desc_ptr *dtr)
212
+static __always_inline void native_load_idt(const struct desc_ptr *dtr)
218213 {
219214 asm volatile("lidt %0"::"m" (*dtr));
220215 }
....@@ -386,64 +381,50 @@
386381 desc->limit1 = (limit >> 16) & 0xf;
387382 }
388383
389
-void update_intr_gate(unsigned int n, const void *addr);
390384 void alloc_intr_gate(unsigned int n, const void *addr);
385
+
386
+static inline void init_idt_data(struct idt_data *data, unsigned int n,
387
+ const void *addr)
388
+{
389
+ BUG_ON(n > 0xFF);
390
+
391
+ memset(data, 0, sizeof(*data));
392
+ data->vector = n;
393
+ data->addr = addr;
394
+ data->segment = __KERNEL_CS;
395
+ data->bits.type = GATE_INTERRUPT;
396
+ data->bits.p = 1;
397
+}
398
+
399
+static inline void idt_init_desc(gate_desc *gate, const struct idt_data *d)
400
+{
401
+ unsigned long addr = (unsigned long) d->addr;
402
+
403
+ gate->offset_low = (u16) addr;
404
+ gate->segment = (u16) d->segment;
405
+ gate->bits = d->bits;
406
+ gate->offset_middle = (u16) (addr >> 16);
407
+#ifdef CONFIG_X86_64
408
+ gate->offset_high = (u32) (addr >> 32);
409
+ gate->reserved = 0;
410
+#endif
411
+}
391412
392413 extern unsigned long system_vectors[];
393414
394
-#ifdef CONFIG_X86_64
395
-DECLARE_PER_CPU(u32, debug_idt_ctr);
396
-static inline bool is_debug_idt_enabled(void)
397
-{
398
- if (this_cpu_read(debug_idt_ctr))
399
- return true;
400
-
401
- return false;
402
-}
403
-
404
-static inline void load_debug_idt(void)
405
-{
406
- load_idt((const struct desc_ptr *)&debug_idt_descr);
407
-}
408
-#else
409
-static inline bool is_debug_idt_enabled(void)
410
-{
411
- return false;
412
-}
413
-
414
-static inline void load_debug_idt(void)
415
-{
416
-}
417
-#endif
418
-
419
-/*
420
- * The load_current_idt() must be called with interrupts disabled
421
- * to avoid races. That way the IDT will always be set back to the expected
422
- * descriptor. It's also called when a CPU is being initialized, and
423
- * that doesn't need to disable interrupts, as nothing should be
424
- * bothering the CPU then.
425
- */
426
-static inline void load_current_idt(void)
427
-{
428
- if (is_debug_idt_enabled())
429
- load_debug_idt();
430
- else
431
- load_idt((const struct desc_ptr *)&idt_descr);
432
-}
433
-
415
+extern void load_current_idt(void);
434416 extern void idt_setup_early_handler(void);
435417 extern void idt_setup_early_traps(void);
436418 extern void idt_setup_traps(void);
437419 extern void idt_setup_apic_and_irq_gates(void);
420
+extern bool idt_is_f00f_address(unsigned long address);
438421
439422 #ifdef CONFIG_X86_64
440423 extern void idt_setup_early_pf(void);
441424 extern void idt_setup_ist_traps(void);
442
-extern void idt_setup_debugidt_traps(void);
443425 #else
444426 static inline void idt_setup_early_pf(void) { }
445427 static inline void idt_setup_ist_traps(void) { }
446
-static inline void idt_setup_debugidt_traps(void) { }
447428 #endif
448429
449430 extern void idt_invalidate(void *addr);