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 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>
This commit is contained in:
Wei Liu committed 2017-06-28 11:56:52 +01:00
1 parent 873dd3aaeb
commit fd74631103
4 files changed
+28 -10

No files matched your search

+6 -3
View 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);
+14 -7
View 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);
}
+4
View 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
+4
View 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; }
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.