2019-06-02 22:44:59 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2017-08-27 23:47:43 -07:00
|
|
|
/*
|
|
|
|
* Interrupt descriptor table related code
|
|
|
|
*/
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
|
2020-05-28 07:53:19 -07:00
|
|
|
#include <asm/cpu_entry_area.h>
|
2020-05-28 07:53:20 -07:00
|
|
|
#include <asm/set_memory.h>
|
2017-08-27 23:47:49 -07:00
|
|
|
#include <asm/traps.h>
|
|
|
|
#include <asm/proto.h>
|
2017-08-27 23:47:43 -07:00
|
|
|
#include <asm/desc.h>
|
2018-07-29 03:15:33 -07:00
|
|
|
#include <asm/hw_irq.h>
|
2023-06-23 04:14:08 -07:00
|
|
|
#include <asm/ia32.h>
|
2022-03-08 08:30:24 -07:00
|
|
|
#include <asm/idtentry.h>
|
2017-08-27 23:47:43 -07:00
|
|
|
|
2017-08-27 23:47:49 -07:00
|
|
|
#define DPL0 0x0
|
|
|
|
#define DPL3 0x3
|
|
|
|
|
|
|
|
#define DEFAULT_STACK 0
|
|
|
|
|
|
|
|
#define G(_vector, _addr, _ist, _type, _dpl, _segment) \
|
|
|
|
{ \
|
|
|
|
.vector = _vector, \
|
|
|
|
.bits.ist = _ist, \
|
|
|
|
.bits.type = _type, \
|
|
|
|
.bits.dpl = _dpl, \
|
|
|
|
.bits.p = 1, \
|
|
|
|
.addr = _addr, \
|
|
|
|
.segment = _segment, \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Interrupt gate */
|
|
|
|
#define INTG(_vector, _addr) \
|
|
|
|
G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL0, __KERNEL_CS)
|
|
|
|
|
|
|
|
/* System interrupt gate */
|
|
|
|
#define SYSG(_vector, _addr) \
|
|
|
|
G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL3, __KERNEL_CS)
|
|
|
|
|
2021-05-07 04:02:12 -07:00
|
|
|
#ifdef CONFIG_X86_64
|
2019-04-14 08:59:45 -07:00
|
|
|
/*
|
|
|
|
* Interrupt gate with interrupt stack. The _ist index is the index in
|
|
|
|
* the tss.ist[] array, but for the descriptor it needs to start at 1.
|
|
|
|
*/
|
2017-08-27 23:47:49 -07:00
|
|
|
#define ISTG(_vector, _addr, _ist) \
|
2019-04-14 08:59:45 -07:00
|
|
|
G(_vector, _addr, _ist + 1, GATE_INTERRUPT, DPL0, __KERNEL_CS)
|
2021-05-07 04:02:12 -07:00
|
|
|
#else
|
|
|
|
#define ISTG(_vector, _addr, _ist) INTG(_vector, _addr)
|
|
|
|
#endif
|
2017-08-27 23:47:49 -07:00
|
|
|
|
|
|
|
/* Task gate */
|
|
|
|
#define TSKG(_vector, _gdt) \
|
|
|
|
G(_vector, NULL, DEFAULT_STACK, GATE_TASK, DPL0, _gdt << 3)
|
|
|
|
|
2020-05-28 07:53:18 -07:00
|
|
|
#define IDT_TABLE_SIZE (IDT_ENTRIES * sizeof(gate_desc))
|
2020-04-28 02:38:23 -07:00
|
|
|
|
|
|
|
static bool idt_setup_done __initdata;
|
|
|
|
|
2017-08-27 23:47:50 -07:00
|
|
|
/*
|
|
|
|
* Early traps running on the DEFAULT_STACK because the other interrupt
|
|
|
|
* stacks work only after cpu_init().
|
|
|
|
*/
|
2017-12-21 17:18:21 -07:00
|
|
|
static const __initconst struct idt_data early_idts[] = {
|
2020-02-25 15:33:26 -07:00
|
|
|
INTG(X86_TRAP_DB, asm_exc_debug),
|
2020-02-25 15:16:16 -07:00
|
|
|
SYSG(X86_TRAP_BP, asm_exc_int3),
|
2020-05-28 07:53:17 -07:00
|
|
|
|
2017-08-27 23:47:50 -07:00
|
|
|
#ifdef CONFIG_X86_32
|
2020-05-28 07:53:17 -07:00
|
|
|
/*
|
|
|
|
* Not possible on 64-bit. See idt_setup_early_pf() for details.
|
|
|
|
*/
|
2020-05-21 13:05:28 -07:00
|
|
|
INTG(X86_TRAP_PF, asm_exc_page_fault),
|
2017-08-27 23:47:50 -07:00
|
|
|
#endif
|
x86/traps: Add #VE support for TDX guest
Virtualization Exceptions (#VE) are delivered to TDX guests due to
specific guest actions which may happen in either user space or the
kernel:
* Specific instructions (WBINVD, for example)
* Specific MSR accesses
* Specific CPUID leaf accesses
* Access to specific guest physical addresses
Syscall entry code has a critical window where the kernel stack is not
yet set up. Any exception in this window leads to hard to debug issues
and can be exploited for privilege escalation. Exceptions in the NMI
entry code also cause issues. Returning from the exception handler with
IRET will re-enable NMIs and nested NMI will corrupt the NMI stack.
For these reasons, the kernel avoids #VEs during the syscall gap and
the NMI entry code. Entry code paths do not access TD-shared memory,
MMIO regions, use #VE triggering MSRs, instructions, or CPUID leaves
that might generate #VE. VMM can remove memory from TD at any point,
but access to unaccepted (or missing) private memory leads to VM
termination, not to #VE.
Similarly to page faults and breakpoints, #VEs are allowed in NMI
handlers once the kernel is ready to deal with nested NMIs.
During #VE delivery, all interrupts, including NMIs, are blocked until
TDGETVEINFO is called. It prevents #VE nesting until the kernel reads
the VE info.
TDGETVEINFO retrieves the #VE info from the TDX module, which also
clears the "#VE valid" flag. This must be done before anything else as
any #VE that occurs while the valid flag is set escalates to #DF by TDX
module. It will result in an oops.
Virtual NMIs are inhibited if the #VE valid flag is set. NMI will not be
delivered until TDGETVEINFO is called.
For now, convert unhandled #VE's (everything, until later in this
series) so that they appear just like a #GP by calling the
ve_raise_fault() directly. The ve_raise_fault() function is similar
to #GP handler and is responsible for sending SIGSEGV to userspace
and CPU die and notifying debuggers and other die chain users.
Co-developed-by: Sean Christopherson <sean.j.christopherson@intel.com>
Co-developed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lkml.kernel.org/r/20220405232939.73860-8-kirill.shutemov@linux.intel.com
2022-04-05 16:29:16 -07:00
|
|
|
#ifdef CONFIG_INTEL_TDX_GUEST
|
|
|
|
INTG(X86_TRAP_VE, asm_exc_virtualization_exception),
|
|
|
|
#endif
|
2017-08-27 23:47:50 -07:00
|
|
|
};
|
|
|
|
|
2017-08-27 23:47:53 -07:00
|
|
|
/*
|
|
|
|
* The default IDT entries which are set up in trap_init() before
|
|
|
|
* cpu_init() is invoked. Interrupt stacks cannot be used at that point and
|
|
|
|
* the traps which use them are reinitialized with IST after cpu_init() has
|
|
|
|
* set up TSS.
|
|
|
|
*/
|
2017-12-21 17:18:21 -07:00
|
|
|
static const __initconst struct idt_data def_idts[] = {
|
2020-02-25 15:16:14 -07:00
|
|
|
INTG(X86_TRAP_DE, asm_exc_divide_error),
|
2021-05-07 04:02:12 -07:00
|
|
|
ISTG(X86_TRAP_NMI, asm_exc_nmi, IST_INDEX_NMI),
|
2020-02-25 15:16:17 -07:00
|
|
|
INTG(X86_TRAP_BR, asm_exc_bounds),
|
2020-02-25 15:16:18 -07:00
|
|
|
INTG(X86_TRAP_UD, asm_exc_invalid_op),
|
2020-02-25 15:16:19 -07:00
|
|
|
INTG(X86_TRAP_NM, asm_exc_device_not_available),
|
2020-02-25 15:16:20 -07:00
|
|
|
INTG(X86_TRAP_OLD_MF, asm_exc_coproc_segment_overrun),
|
2020-02-25 15:16:22 -07:00
|
|
|
INTG(X86_TRAP_TS, asm_exc_invalid_tss),
|
2020-02-25 15:16:23 -07:00
|
|
|
INTG(X86_TRAP_NP, asm_exc_segment_not_present),
|
2020-02-25 15:16:24 -07:00
|
|
|
INTG(X86_TRAP_SS, asm_exc_stack_segment),
|
2020-02-25 15:16:25 -07:00
|
|
|
INTG(X86_TRAP_GP, asm_exc_general_protection),
|
2020-02-25 15:16:26 -07:00
|
|
|
INTG(X86_TRAP_SPURIOUS, asm_exc_spurious_interrupt_bug),
|
2020-02-25 15:16:27 -07:00
|
|
|
INTG(X86_TRAP_MF, asm_exc_coprocessor_error),
|
2020-02-25 15:16:28 -07:00
|
|
|
INTG(X86_TRAP_AC, asm_exc_alignment_check),
|
2020-02-25 15:16:29 -07:00
|
|
|
INTG(X86_TRAP_XF, asm_exc_simd_coprocessor_error),
|
2017-08-27 23:47:53 -07:00
|
|
|
|
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
TSKG(X86_TRAP_DF, GDT_ENTRY_DOUBLEFAULT_TSS),
|
|
|
|
#else
|
2021-05-07 04:02:12 -07:00
|
|
|
ISTG(X86_TRAP_DF, asm_exc_double_fault, IST_INDEX_DF),
|
2017-08-27 23:47:53 -07:00
|
|
|
#endif
|
2021-05-07 04:02:12 -07:00
|
|
|
ISTG(X86_TRAP_DB, asm_exc_debug, IST_INDEX_DB),
|
2017-08-27 23:47:53 -07:00
|
|
|
|
|
|
|
#ifdef CONFIG_X86_MCE
|
2021-05-07 04:02:12 -07:00
|
|
|
ISTG(X86_TRAP_MC, asm_exc_machine_check, IST_INDEX_MCE),
|
2022-03-08 08:30:35 -07:00
|
|
|
#endif
|
|
|
|
|
2023-06-12 17:10:53 -07:00
|
|
|
#ifdef CONFIG_X86_CET
|
2022-03-08 08:30:35 -07:00
|
|
|
INTG(X86_TRAP_CP, asm_exc_control_protection),
|
2021-05-07 04:02:12 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_AMD_MEM_ENCRYPT
|
|
|
|
ISTG(X86_TRAP_VC, asm_exc_vmm_communication, IST_INDEX_VC),
|
2017-08-27 23:47:53 -07:00
|
|
|
#endif
|
|
|
|
|
2020-02-25 15:16:15 -07:00
|
|
|
SYSG(X86_TRAP_OF, asm_exc_overflow),
|
2023-06-23 04:14:08 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct idt_data ia32_idt[] __initconst = {
|
2017-08-27 23:47:53 -07:00
|
|
|
#if defined(CONFIG_IA32_EMULATION)
|
2023-12-04 01:31:39 -07:00
|
|
|
SYSG(IA32_SYSCALL_VECTOR, asm_int80_emulation),
|
2017-08-27 23:47:53 -07:00
|
|
|
#elif defined(CONFIG_X86_32)
|
|
|
|
SYSG(IA32_SYSCALL_VECTOR, entry_INT80_32),
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2017-08-27 23:47:54 -07:00
|
|
|
/*
|
|
|
|
* The APIC and SMP idt entries
|
|
|
|
*/
|
2017-12-21 17:18:21 -07:00
|
|
|
static const __initconst struct idt_data apic_idts[] = {
|
2017-08-27 23:47:54 -07:00
|
|
|
#ifdef CONFIG_SMP
|
2020-05-21 13:05:45 -07:00
|
|
|
INTG(RESCHEDULE_VECTOR, asm_sysvec_reschedule_ipi),
|
2020-05-21 13:05:40 -07:00
|
|
|
INTG(CALL_FUNCTION_VECTOR, asm_sysvec_call_function),
|
|
|
|
INTG(CALL_FUNCTION_SINGLE_VECTOR, asm_sysvec_call_function_single),
|
|
|
|
INTG(REBOOT_VECTOR, asm_sysvec_reboot),
|
2017-08-27 23:47:54 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_THERMAL_VECTOR
|
2020-05-21 13:05:41 -07:00
|
|
|
INTG(THERMAL_APIC_VECTOR, asm_sysvec_thermal),
|
2017-08-27 23:47:54 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_MCE_THRESHOLD
|
2020-05-21 13:05:41 -07:00
|
|
|
INTG(THRESHOLD_APIC_VECTOR, asm_sysvec_threshold),
|
2017-08-27 23:47:54 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_MCE_AMD
|
2020-05-21 13:05:41 -07:00
|
|
|
INTG(DEFERRED_ERROR_VECTOR, asm_sysvec_deferred_error),
|
2017-08-27 23:47:54 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_LOCAL_APIC
|
2020-05-21 13:05:41 -07:00
|
|
|
INTG(LOCAL_TIMER_VECTOR, asm_sysvec_apic_timer_interrupt),
|
|
|
|
INTG(X86_PLATFORM_IPI_VECTOR, asm_sysvec_x86_platform_ipi),
|
2024-01-04 13:15:43 -07:00
|
|
|
# if IS_ENABLED(CONFIG_KVM)
|
2020-05-21 13:05:42 -07:00
|
|
|
INTG(POSTED_INTR_VECTOR, asm_sysvec_kvm_posted_intr_ipi),
|
|
|
|
INTG(POSTED_INTR_WAKEUP_VECTOR, asm_sysvec_kvm_posted_intr_wakeup_ipi),
|
|
|
|
INTG(POSTED_INTR_NESTED_VECTOR, asm_sysvec_kvm_posted_intr_nested_ipi),
|
2017-08-27 23:47:54 -07:00
|
|
|
# endif
|
|
|
|
# ifdef CONFIG_IRQ_WORK
|
2020-05-21 13:05:41 -07:00
|
|
|
INTG(IRQ_WORK_VECTOR, asm_sysvec_irq_work),
|
|
|
|
# endif
|
|
|
|
INTG(SPURIOUS_APIC_VECTOR, asm_sysvec_spurious_apic_interrupt),
|
|
|
|
INTG(ERROR_APIC_VECTOR, asm_sysvec_error_interrupt),
|
2024-04-23 10:41:10 -07:00
|
|
|
# ifdef CONFIG_X86_POSTED_MSI
|
|
|
|
INTG(POSTED_MSI_NOTIFICATION_VECTOR, asm_sysvec_posted_msi_notification),
|
|
|
|
# endif
|
2017-08-27 23:47:54 -07:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2020-05-28 07:53:20 -07:00
|
|
|
/* Must be page-aligned because the real IDT is used in the cpu entry area */
|
|
|
|
static gate_desc idt_table[IDT_ENTRIES] __page_aligned_bss;
|
2017-08-27 23:47:43 -07:00
|
|
|
|
2020-06-19 13:51:02 -07:00
|
|
|
static struct desc_ptr idt_descr __ro_after_init = {
|
2020-05-28 07:53:18 -07:00
|
|
|
.size = IDT_TABLE_SIZE - 1,
|
2017-08-27 23:47:43 -07:00
|
|
|
.address = (unsigned long) idt_table,
|
|
|
|
};
|
|
|
|
|
2020-05-28 07:53:20 -07:00
|
|
|
void load_current_idt(void)
|
|
|
|
{
|
|
|
|
lockdep_assert_irqs_disabled();
|
|
|
|
load_idt(&idt_descr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_F00F_BUG
|
|
|
|
bool idt_is_f00f_address(unsigned long address)
|
|
|
|
{
|
|
|
|
return ((address - idt_descr.address) >> 3) == 6;
|
|
|
|
}
|
2017-08-27 23:47:43 -07:00
|
|
|
#endif
|
2017-08-27 23:47:46 -07:00
|
|
|
|
2020-05-28 07:53:16 -07:00
|
|
|
static __init void
|
2017-08-27 23:47:57 -07:00
|
|
|
idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sys)
|
2017-08-27 23:47:49 -07:00
|
|
|
{
|
|
|
|
gate_desc desc;
|
|
|
|
|
|
|
|
for (; size > 0; t++, size--) {
|
|
|
|
idt_init_desc(&desc, t);
|
|
|
|
write_idt_entry(idt, t->vector, &desc);
|
2017-08-27 23:47:57 -07:00
|
|
|
if (sys)
|
2017-09-13 14:29:26 -07:00
|
|
|
set_bit(t->vector, system_vectors);
|
2017-08-27 23:47:49 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-28 07:53:16 -07:00
|
|
|
static __init void set_intr_gate(unsigned int n, const void *addr)
|
2017-08-27 23:47:59 -07:00
|
|
|
{
|
|
|
|
struct idt_data data;
|
|
|
|
|
2020-09-07 06:15:29 -07:00
|
|
|
init_idt_data(&data, n, addr);
|
2017-08-27 23:47:59 -07:00
|
|
|
|
|
|
|
idt_setup_from_table(idt_table, &data, 1, false);
|
|
|
|
}
|
|
|
|
|
2017-08-27 23:47:50 -07:00
|
|
|
/**
|
|
|
|
* idt_setup_early_traps - Initialize the idt table with early traps
|
|
|
|
*
|
|
|
|
* On X8664 these traps do not use interrupt stacks as they can't work
|
|
|
|
* before cpu_init() is invoked and sets up TSS. The IST variants are
|
|
|
|
* installed after that.
|
|
|
|
*/
|
|
|
|
void __init idt_setup_early_traps(void)
|
|
|
|
{
|
2017-08-27 23:47:57 -07:00
|
|
|
idt_setup_from_table(idt_table, early_idts, ARRAY_SIZE(early_idts),
|
|
|
|
true);
|
2017-08-27 23:47:50 -07:00
|
|
|
load_idt(&idt_descr);
|
|
|
|
}
|
|
|
|
|
2017-08-27 23:47:53 -07:00
|
|
|
/**
|
|
|
|
* idt_setup_traps - Initialize the idt table with default traps
|
|
|
|
*/
|
|
|
|
void __init idt_setup_traps(void)
|
|
|
|
{
|
2017-08-27 23:47:57 -07:00
|
|
|
idt_setup_from_table(idt_table, def_idts, ARRAY_SIZE(def_idts), true);
|
2023-06-23 04:14:08 -07:00
|
|
|
|
|
|
|
if (ia32_enabled())
|
|
|
|
idt_setup_from_table(idt_table, ia32_idt, ARRAY_SIZE(ia32_idt), true);
|
2017-08-27 23:47:53 -07:00
|
|
|
}
|
|
|
|
|
2017-08-27 23:47:50 -07:00
|
|
|
#ifdef CONFIG_X86_64
|
2020-05-28 07:53:20 -07:00
|
|
|
/*
|
|
|
|
* Early traps running on the DEFAULT_STACK because the other interrupt
|
|
|
|
* stacks work only after cpu_init().
|
|
|
|
*/
|
|
|
|
static const __initconst struct idt_data early_pf_idts[] = {
|
|
|
|
INTG(X86_TRAP_PF, asm_exc_page_fault),
|
|
|
|
};
|
|
|
|
|
2017-08-27 23:47:50 -07:00
|
|
|
/**
|
|
|
|
* idt_setup_early_pf - Initialize the idt table with early pagefault handler
|
|
|
|
*
|
|
|
|
* On X8664 this does not use interrupt stacks as they can't work before
|
|
|
|
* cpu_init() is invoked and sets up TSS. The IST variant is installed
|
|
|
|
* after that.
|
|
|
|
*
|
2020-05-28 07:53:17 -07:00
|
|
|
* Note, that X86_64 cannot install the real #PF handler in
|
2021-03-18 07:28:01 -07:00
|
|
|
* idt_setup_early_traps() because the memory initialization needs the #PF
|
2020-05-28 07:53:17 -07:00
|
|
|
* handler from the early_idt_handler_array to initialize the early page
|
|
|
|
* tables.
|
2017-08-27 23:47:50 -07:00
|
|
|
*/
|
|
|
|
void __init idt_setup_early_pf(void)
|
|
|
|
{
|
|
|
|
idt_setup_from_table(idt_table, early_pf_idts,
|
2017-08-27 23:47:57 -07:00
|
|
|
ARRAY_SIZE(early_pf_idts), true);
|
2017-08-27 23:47:50 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-05-28 07:53:19 -07:00
|
|
|
static void __init idt_map_in_cea(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Set the IDT descriptor to a fixed read-only location in the cpu
|
|
|
|
* entry area, so that the "sidt" instruction will not leak the
|
|
|
|
* location of the kernel, and to defend the IDT against arbitrary
|
|
|
|
* memory write vulnerabilities.
|
|
|
|
*/
|
|
|
|
cea_set_pte(CPU_ENTRY_AREA_RO_IDT_VADDR, __pa_symbol(idt_table),
|
|
|
|
PAGE_KERNEL_RO);
|
|
|
|
idt_descr.address = CPU_ENTRY_AREA_RO_IDT;
|
|
|
|
}
|
|
|
|
|
2017-08-27 23:47:54 -07:00
|
|
|
/**
|
|
|
|
* idt_setup_apic_and_irq_gates - Setup APIC/SMP and normal interrupt gates
|
|
|
|
*/
|
|
|
|
void __init idt_setup_apic_and_irq_gates(void)
|
|
|
|
{
|
2017-08-27 23:47:55 -07:00
|
|
|
int i = FIRST_EXTERNAL_VECTOR;
|
|
|
|
void *entry;
|
|
|
|
|
2017-08-27 23:47:57 -07:00
|
|
|
idt_setup_from_table(idt_table, apic_idts, ARRAY_SIZE(apic_idts), true);
|
2017-08-27 23:47:55 -07:00
|
|
|
|
2017-09-13 14:29:26 -07:00
|
|
|
for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR) {
|
2022-03-08 08:30:24 -07:00
|
|
|
entry = irq_entries_start + IDT_ALIGN * (i - FIRST_EXTERNAL_VECTOR);
|
2017-08-27 23:47:55 -07:00
|
|
|
set_intr_gate(i, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_LOCAL_APIC
|
2018-05-22 19:35:55 -07:00
|
|
|
for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
|
2020-04-28 02:38:24 -07:00
|
|
|
/*
|
|
|
|
* Don't set the non assigned system vectors in the
|
|
|
|
* system_vectors bitmap. Otherwise they show up in
|
|
|
|
* /proc/interrupts.
|
|
|
|
*/
|
2022-03-08 08:30:24 -07:00
|
|
|
entry = spurious_entries_start + IDT_ALIGN * (i - FIRST_SYSTEM_VECTOR);
|
2019-06-28 04:11:54 -07:00
|
|
|
set_intr_gate(i, entry);
|
2017-08-27 23:47:55 -07:00
|
|
|
}
|
2018-05-22 19:35:55 -07:00
|
|
|
#endif
|
2020-05-28 07:53:19 -07:00
|
|
|
/* Map IDT into CPU entry area and reload it. */
|
|
|
|
idt_map_in_cea();
|
|
|
|
load_idt(&idt_descr);
|
|
|
|
|
2020-05-28 07:53:20 -07:00
|
|
|
/* Make the IDT table read only */
|
|
|
|
set_memory_ro((unsigned long)&idt_table, 1);
|
|
|
|
|
2020-04-28 02:38:23 -07:00
|
|
|
idt_setup_done = true;
|
2017-08-27 23:47:54 -07:00
|
|
|
}
|
|
|
|
|
2017-08-27 23:47:47 -07:00
|
|
|
/**
|
|
|
|
* idt_setup_early_handler - Initializes the idt table with early handlers
|
|
|
|
*/
|
|
|
|
void __init idt_setup_early_handler(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_EXCEPTION_VECTORS; i++)
|
|
|
|
set_intr_gate(i, early_idt_handler_array[i]);
|
2017-08-27 23:47:48 -07:00
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
for ( ; i < NR_VECTORS; i++)
|
|
|
|
set_intr_gate(i, early_ignore_irq);
|
|
|
|
#endif
|
2017-08-27 23:47:47 -07:00
|
|
|
load_idt(&idt_descr);
|
|
|
|
}
|
|
|
|
|
2017-08-27 23:47:46 -07:00
|
|
|
/**
|
|
|
|
* idt_invalidate - Invalidate interrupt descriptor table
|
|
|
|
*/
|
2021-05-19 14:21:50 -07:00
|
|
|
void idt_invalidate(void)
|
2017-08-27 23:47:46 -07:00
|
|
|
{
|
2021-05-19 14:21:50 -07:00
|
|
|
static const struct desc_ptr idt = { .address = 0, .size = 0 };
|
2017-08-27 23:47:46 -07:00
|
|
|
|
|
|
|
load_idt(&idt);
|
|
|
|
}
|
2017-08-27 23:47:57 -07:00
|
|
|
|
2023-12-05 03:50:16 -07:00
|
|
|
void __init idt_install_sysvec(unsigned int n, const void *function)
|
2017-08-27 23:47:57 -07:00
|
|
|
{
|
2020-04-28 02:38:23 -07:00
|
|
|
if (WARN_ON(n < FIRST_SYSTEM_VECTOR))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (WARN_ON(idt_setup_done))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!WARN_ON(test_and_set_bit(n, system_vectors)))
|
2023-12-05 03:50:16 -07:00
|
|
|
set_intr_gate(n, function);
|
2017-08-27 23:47:57 -07:00
|
|
|
}
|