mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
x86/idt: Factor out enabling and disabling of ISTs
All alteration of IST settings (other than the crash path) happen in an identical triple. Introduce helpers to keep the triple in sync, and reduce the risk of opencoded mistakes. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Doug Goldstein <cardoe@cardoe.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
78aca25302
commit
f9fc2e584d
5 files changed
+19
-15
No files matched your search
@@ -771,9 +771,7 @@ void load_system_tables(void)
|
||||
ltr(TSS_ENTRY << 3);
|
||||
lldt(0);
|
||||
|
||||
set_ist(&idt_tables[cpu][TRAP_double_fault], IST_DF);
|
||||
set_ist(&idt_tables[cpu][TRAP_nmi], IST_NMI);
|
||||
set_ist(&idt_tables[cpu][TRAP_machine_check], IST_MCE);
|
||||
enable_each_ist(idt_tables[cpu]);
|
||||
|
||||
/*
|
||||
* Bottom-of-stack must be 16-byte aligned!
|
||||
|
||||
@@ -1038,9 +1038,7 @@ static void svm_ctxt_switch_from(struct vcpu *v)
|
||||
svm_vmload_pa(per_cpu(host_vmcb, cpu));
|
||||
|
||||
/* Resume use of ISTs now that the host TR is reinstated. */
|
||||
set_ist(&idt_tables[cpu][TRAP_double_fault], IST_DF);
|
||||
set_ist(&idt_tables[cpu][TRAP_nmi], IST_NMI);
|
||||
set_ist(&idt_tables[cpu][TRAP_machine_check], IST_MCE);
|
||||
enable_each_ist(idt_tables[cpu]);
|
||||
}
|
||||
|
||||
static void svm_ctxt_switch_to(struct vcpu *v)
|
||||
@@ -1059,9 +1057,7 @@ static void svm_ctxt_switch_to(struct vcpu *v)
|
||||
* Cannot use ISTs for NMI/#MC/#DF while we are running with the guest TR.
|
||||
* But this doesn't matter: the IST is only req'd to handle SYSCALL/SYSRET.
|
||||
*/
|
||||
set_ist(&idt_tables[cpu][TRAP_double_fault], IST_NONE);
|
||||
set_ist(&idt_tables[cpu][TRAP_nmi], IST_NONE);
|
||||
set_ist(&idt_tables[cpu][TRAP_machine_check], IST_NONE);
|
||||
disable_each_ist(idt_tables[cpu]);
|
||||
|
||||
svm_restore_dr(v);
|
||||
|
||||
|
||||
@@ -919,9 +919,7 @@ static int cpu_smpboot_alloc(unsigned int cpu)
|
||||
if ( idt_tables[cpu] == NULL )
|
||||
goto out;
|
||||
memcpy(idt_tables[cpu], idt_table, IDT_ENTRIES * sizeof(idt_entry_t));
|
||||
set_ist(&idt_tables[cpu][TRAP_double_fault], IST_NONE);
|
||||
set_ist(&idt_tables[cpu][TRAP_nmi], IST_NONE);
|
||||
set_ist(&idt_tables[cpu][TRAP_machine_check], IST_NONE);
|
||||
disable_each_ist(idt_tables[cpu]);
|
||||
|
||||
rc = setup_cpu_root_pgt(cpu);
|
||||
if ( rc )
|
||||
|
||||
@@ -1889,9 +1889,7 @@ void __init init_idt_traps(void)
|
||||
set_intr_gate(TRAP_simd_error,&simd_coprocessor_error);
|
||||
|
||||
/* Specify dedicated interrupt stacks for NMI, #DF, and #MC. */
|
||||
set_ist(&idt_table[TRAP_double_fault], IST_DF);
|
||||
set_ist(&idt_table[TRAP_nmi], IST_NMI);
|
||||
set_ist(&idt_table[TRAP_machine_check], IST_MCE);
|
||||
enable_each_ist(idt_table);
|
||||
|
||||
/* CPU0 uses the master IDT. */
|
||||
idt_tables[0] = idt_table;
|
||||
|
||||
@@ -459,6 +459,20 @@ static always_inline void set_ist(idt_entry_t *idt, unsigned long ist)
|
||||
_write_gate_lower(idt, &new);
|
||||
}
|
||||
|
||||
static inline void enable_each_ist(idt_entry_t *idt)
|
||||
{
|
||||
set_ist(&idt[TRAP_double_fault], IST_DF);
|
||||
set_ist(&idt[TRAP_nmi], IST_NMI);
|
||||
set_ist(&idt[TRAP_machine_check], IST_MCE);
|
||||
}
|
||||
|
||||
static inline void disable_each_ist(idt_entry_t *idt)
|
||||
{
|
||||
set_ist(&idt[TRAP_double_fault], IST_NONE);
|
||||
set_ist(&idt[TRAP_nmi], IST_NONE);
|
||||
set_ist(&idt[TRAP_machine_check], IST_NONE);
|
||||
}
|
||||
|
||||
#define IDT_ENTRIES 256
|
||||
extern idt_entry_t idt_table[];
|
||||
extern idt_entry_t *idt_tables[];
|
||||
|
||||