|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v5 08/13] x86/traps: factor out pv_trap_init
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 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@xxxxxxxxxx>
---
xen/arch/x86/irq.c | 9 ++++++---
xen/arch/x86/traps.c | 23 +++++++++++++++--------
xen/arch/x86/x86_64/entry.S | 4 ++++
xen/include/asm-x86/pv/traps.h | 4 ++++
4 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 523d089006..b2709f4988 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -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);
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 7e3cba0ffe..d89409ff05 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -1934,21 +1934,29 @@ 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)
{
unsigned int vector;
+ pv_trap_init();
+
/* 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);
-
for ( vector = 0; vector < NR_VECTORS; ++vector )
{
if ( autogen_entrypoints[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);
}
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 65c771f979..b6e2397e84 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -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
diff --git a/xen/include/asm-x86/pv/traps.h b/xen/include/asm-x86/pv/traps.h
index 72e54a09a6..e64c713700 100644
--- a/xen/include/asm-x86/pv/traps.h
+++ b/xen/include/asm-x86/pv/traps.h
@@ -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);
@@ -36,6 +38,8 @@ bool pv_emulate_invalid_op(struct cpu_user_regs *regs);
#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; }
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |