]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86/traps: factor out pv_trap_init
authorWei Liu <wei.liu2@citrix.com>
Mon, 5 Jun 2017 15:15:26 +0000 (16:15 +0100)
committerWei Liu <wei.liu2@citrix.com>
Wed, 28 Jun 2017 10:56:52 +0000 (11:56 +0100)
Factor out pv_trap_init and call it at the beginning of trap_init. We
then need to tune the code to generate stub handlers in entry.S. Take
the chance to tune init_irq_data so that 0x80 and 0x82 can be used for
regular interrupts in !CONFIG_PV case.

While at it, fix some coding style issues in init_irq_data and replace
0x80 with LEGACY_SYSCALL_VECTOR in pv_trap_init.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reivewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/irq.c
xen/arch/x86/traps.c
xen/arch/x86/x86_64/entry.S
xen/include/asm-x86/pv/traps.h

index d9fea2c638a8443333739594787ea83058361c11..113667cdea952908da7977bbe81b0cdbf52f86bb 100644 (file)
@@ -350,7 +350,7 @@ int __init init_irq_data(void)
     struct irq_desc *desc;
     int irq, vector;
 
-    for (vector = 0; vector < NR_VECTORS; ++vector)
+    for ( vector = 0; vector < NR_VECTORS; ++vector )
         this_cpu(vector_irq)[vector] = INT_MIN;
 
     irq_desc = xzalloc_array(struct irq_desc, nr_irqs);
@@ -358,17 +358,20 @@ int __init init_irq_data(void)
     if ( !irq_desc )
         return -ENOMEM;
 
-    for (irq = 0; irq < nr_irqs_gsi; irq++) {
+    for ( irq = 0; irq < nr_irqs_gsi; irq++ )
+    {
         desc = irq_to_desc(irq);
         desc->irq = irq;
         init_one_irq_desc(desc);
     }
-    for (; irq < nr_irqs; irq++)
+    for ( ; irq < nr_irqs; irq++ )
         irq_to_desc(irq)->irq = irq;
 
+#ifdef CONFIG_PV
     /* Never allocate the hypercall vector or Linux/BSD fast-trap vector. */
     set_bit(LEGACY_SYSCALL_VECTOR, used_vectors);
     set_bit(HYPERCALL_VECTOR, used_vectors);
+#endif
     
     /* IRQ_MOVE_CLEANUP_VECTOR used for clean up vectors */
     set_bit(IRQ_MOVE_CLEANUP_VECTOR, used_vectors);
index 7e3cba0ffe8d725ca0190572573b419bf8fed03b..69e1f4bc9a50f657f0f0cc8fe69e376bfbc737af 100644 (file)
@@ -1934,6 +1934,19 @@ void __init init_idt_traps(void)
     this_cpu(compat_gdt_table) = boot_cpu_compat_gdt_table;
 }
 
+void __init pv_trap_init(void)
+{
+    /* The 32-on-64 hypercall vector is only accessible from ring 1. */
+    _set_gate(idt_table + HYPERCALL_VECTOR,
+              SYS_DESC_trap_gate, 1, entry_int82);
+
+    /* Fast trap for int80 (faster than taking the #GP-fixup path). */
+    _set_gate(idt_table + LEGACY_SYSCALL_VECTOR, SYS_DESC_trap_gate, 3,
+              &int80_direct_trap);
+
+    open_softirq(NMI_MCE_SOFTIRQ, nmi_mce_softirq);
+}
+
 extern void (*const autogen_entrypoints[NR_VECTORS])(void);
 void __init trap_init(void)
 {
@@ -1942,12 +1955,7 @@ void __init trap_init(void)
     /* Replace early pagefault with real pagefault handler. */
     set_intr_gate(TRAP_page_fault, &page_fault);
 
-    /* The 32-on-64 hypercall vector is only accessible from ring 1. */
-    _set_gate(idt_table + HYPERCALL_VECTOR,
-              SYS_DESC_trap_gate, 1, entry_int82);
-
-    /* Fast trap for int80 (faster than taking the #GP-fixup path). */
-    _set_gate(idt_table + 0x80, SYS_DESC_trap_gate, 3, &int80_direct_trap);
+    pv_trap_init();
 
     for ( vector = 0; vector < NR_VECTORS; ++vector )
     {
@@ -1968,7 +1976,6 @@ void __init trap_init(void)
 
     cpu_init();
 
-    open_softirq(NMI_MCE_SOFTIRQ, nmi_mce_softirq);
     open_softirq(PCI_SERR_SOFTIRQ, pci_serr_softirq);
 }
 
index 65c771f9791a0344fcc5dc3de9adc716041d4e8b..b6e2397e845e8f56e383cb39b602e7fdc426a95f 100644 (file)
@@ -706,7 +706,11 @@ autogen_stubs: /* Automatically generated stubs. */
         .rept NR_VECTORS
 
         /* Common interrupts, heading towards do_IRQ(). */
+#ifdef CONFIG_PV
         .if vec >= FIRST_DYNAMIC_VECTOR && vec != HYPERCALL_VECTOR && vec != LEGACY_SYSCALL_VECTOR
+#else
+        .if vec >= FIRST_DYNAMIC_VECTOR
+#endif
 
         ALIGN
 1:      pushq $0
index ae981baff29b4f5ed64724f4db10acf2f9126e3b..7279d16ca0891de7b9739af897d5ac37585f2537 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <public/xen.h>
 
+void pv_trap_init(void);
+
 /* Deliver interrupt to PV guest. Return 0 on success. */
 int pv_raise_interrupt(struct vcpu *v, uint8_t vector);
 
@@ -42,6 +44,8 @@ static inline bool pv_trap_callback_registered(const struct vcpu *v,
 
 #include <xen/errno.h>
 
+static inline void pv_trap_init(void) {}
+
 /* Deliver interrupt to PV guest. Return 0 on success. */
 static int pv_raise_interrupt(struct vcpu *v, uint8_t vector) { return -EOPNOTSUPP; }