xref: /kernel/linux/linux-6.6/arch/x86/kernel/idt.c (revision 62306a36)
162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Interrupt descriptor table related code
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci#include <linux/interrupt.h>
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include <asm/cpu_entry_area.h>
862306a36Sopenharmony_ci#include <asm/set_memory.h>
962306a36Sopenharmony_ci#include <asm/traps.h>
1062306a36Sopenharmony_ci#include <asm/proto.h>
1162306a36Sopenharmony_ci#include <asm/desc.h>
1262306a36Sopenharmony_ci#include <asm/hw_irq.h>
1362306a36Sopenharmony_ci#include <asm/idtentry.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define DPL0		0x0
1662306a36Sopenharmony_ci#define DPL3		0x3
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define DEFAULT_STACK	0
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define G(_vector, _addr, _ist, _type, _dpl, _segment)	\
2162306a36Sopenharmony_ci	{						\
2262306a36Sopenharmony_ci		.vector		= _vector,		\
2362306a36Sopenharmony_ci		.bits.ist	= _ist,			\
2462306a36Sopenharmony_ci		.bits.type	= _type,		\
2562306a36Sopenharmony_ci		.bits.dpl	= _dpl,			\
2662306a36Sopenharmony_ci		.bits.p		= 1,			\
2762306a36Sopenharmony_ci		.addr		= _addr,		\
2862306a36Sopenharmony_ci		.segment	= _segment,		\
2962306a36Sopenharmony_ci	}
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci/* Interrupt gate */
3262306a36Sopenharmony_ci#define INTG(_vector, _addr)				\
3362306a36Sopenharmony_ci	G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL0, __KERNEL_CS)
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/* System interrupt gate */
3662306a36Sopenharmony_ci#define SYSG(_vector, _addr)				\
3762306a36Sopenharmony_ci	G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL3, __KERNEL_CS)
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#ifdef CONFIG_X86_64
4062306a36Sopenharmony_ci/*
4162306a36Sopenharmony_ci * Interrupt gate with interrupt stack. The _ist index is the index in
4262306a36Sopenharmony_ci * the tss.ist[] array, but for the descriptor it needs to start at 1.
4362306a36Sopenharmony_ci */
4462306a36Sopenharmony_ci#define ISTG(_vector, _addr, _ist)			\
4562306a36Sopenharmony_ci	G(_vector, _addr, _ist + 1, GATE_INTERRUPT, DPL0, __KERNEL_CS)
4662306a36Sopenharmony_ci#else
4762306a36Sopenharmony_ci#define ISTG(_vector, _addr, _ist)	INTG(_vector, _addr)
4862306a36Sopenharmony_ci#endif
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci/* Task gate */
5162306a36Sopenharmony_ci#define TSKG(_vector, _gdt)				\
5262306a36Sopenharmony_ci	G(_vector, NULL, DEFAULT_STACK, GATE_TASK, DPL0, _gdt << 3)
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define IDT_TABLE_SIZE		(IDT_ENTRIES * sizeof(gate_desc))
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_cistatic bool idt_setup_done __initdata;
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/*
5962306a36Sopenharmony_ci * Early traps running on the DEFAULT_STACK because the other interrupt
6062306a36Sopenharmony_ci * stacks work only after cpu_init().
6162306a36Sopenharmony_ci */
6262306a36Sopenharmony_cistatic const __initconst struct idt_data early_idts[] = {
6362306a36Sopenharmony_ci	INTG(X86_TRAP_DB,		asm_exc_debug),
6462306a36Sopenharmony_ci	SYSG(X86_TRAP_BP,		asm_exc_int3),
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci#ifdef CONFIG_X86_32
6762306a36Sopenharmony_ci	/*
6862306a36Sopenharmony_ci	 * Not possible on 64-bit. See idt_setup_early_pf() for details.
6962306a36Sopenharmony_ci	 */
7062306a36Sopenharmony_ci	INTG(X86_TRAP_PF,		asm_exc_page_fault),
7162306a36Sopenharmony_ci#endif
7262306a36Sopenharmony_ci#ifdef CONFIG_INTEL_TDX_GUEST
7362306a36Sopenharmony_ci	INTG(X86_TRAP_VE,		asm_exc_virtualization_exception),
7462306a36Sopenharmony_ci#endif
7562306a36Sopenharmony_ci};
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/*
7862306a36Sopenharmony_ci * The default IDT entries which are set up in trap_init() before
7962306a36Sopenharmony_ci * cpu_init() is invoked. Interrupt stacks cannot be used at that point and
8062306a36Sopenharmony_ci * the traps which use them are reinitialized with IST after cpu_init() has
8162306a36Sopenharmony_ci * set up TSS.
8262306a36Sopenharmony_ci */
8362306a36Sopenharmony_cistatic const __initconst struct idt_data def_idts[] = {
8462306a36Sopenharmony_ci	INTG(X86_TRAP_DE,		asm_exc_divide_error),
8562306a36Sopenharmony_ci	ISTG(X86_TRAP_NMI,		asm_exc_nmi, IST_INDEX_NMI),
8662306a36Sopenharmony_ci	INTG(X86_TRAP_BR,		asm_exc_bounds),
8762306a36Sopenharmony_ci	INTG(X86_TRAP_UD,		asm_exc_invalid_op),
8862306a36Sopenharmony_ci	INTG(X86_TRAP_NM,		asm_exc_device_not_available),
8962306a36Sopenharmony_ci	INTG(X86_TRAP_OLD_MF,		asm_exc_coproc_segment_overrun),
9062306a36Sopenharmony_ci	INTG(X86_TRAP_TS,		asm_exc_invalid_tss),
9162306a36Sopenharmony_ci	INTG(X86_TRAP_NP,		asm_exc_segment_not_present),
9262306a36Sopenharmony_ci	INTG(X86_TRAP_SS,		asm_exc_stack_segment),
9362306a36Sopenharmony_ci	INTG(X86_TRAP_GP,		asm_exc_general_protection),
9462306a36Sopenharmony_ci	INTG(X86_TRAP_SPURIOUS,		asm_exc_spurious_interrupt_bug),
9562306a36Sopenharmony_ci	INTG(X86_TRAP_MF,		asm_exc_coprocessor_error),
9662306a36Sopenharmony_ci	INTG(X86_TRAP_AC,		asm_exc_alignment_check),
9762306a36Sopenharmony_ci	INTG(X86_TRAP_XF,		asm_exc_simd_coprocessor_error),
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#ifdef CONFIG_X86_32
10062306a36Sopenharmony_ci	TSKG(X86_TRAP_DF,		GDT_ENTRY_DOUBLEFAULT_TSS),
10162306a36Sopenharmony_ci#else
10262306a36Sopenharmony_ci	ISTG(X86_TRAP_DF,		asm_exc_double_fault, IST_INDEX_DF),
10362306a36Sopenharmony_ci#endif
10462306a36Sopenharmony_ci	ISTG(X86_TRAP_DB,		asm_exc_debug, IST_INDEX_DB),
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci#ifdef CONFIG_X86_MCE
10762306a36Sopenharmony_ci	ISTG(X86_TRAP_MC,		asm_exc_machine_check, IST_INDEX_MCE),
10862306a36Sopenharmony_ci#endif
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci#ifdef CONFIG_X86_CET
11162306a36Sopenharmony_ci	INTG(X86_TRAP_CP,		asm_exc_control_protection),
11262306a36Sopenharmony_ci#endif
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#ifdef CONFIG_AMD_MEM_ENCRYPT
11562306a36Sopenharmony_ci	ISTG(X86_TRAP_VC,		asm_exc_vmm_communication, IST_INDEX_VC),
11662306a36Sopenharmony_ci#endif
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci	SYSG(X86_TRAP_OF,		asm_exc_overflow),
11962306a36Sopenharmony_ci#if defined(CONFIG_IA32_EMULATION)
12062306a36Sopenharmony_ci	SYSG(IA32_SYSCALL_VECTOR,	asm_int80_emulation),
12162306a36Sopenharmony_ci#elif defined(CONFIG_X86_32)
12262306a36Sopenharmony_ci	SYSG(IA32_SYSCALL_VECTOR,	entry_INT80_32),
12362306a36Sopenharmony_ci#endif
12462306a36Sopenharmony_ci};
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci/*
12762306a36Sopenharmony_ci * The APIC and SMP idt entries
12862306a36Sopenharmony_ci */
12962306a36Sopenharmony_cistatic const __initconst struct idt_data apic_idts[] = {
13062306a36Sopenharmony_ci#ifdef CONFIG_SMP
13162306a36Sopenharmony_ci	INTG(RESCHEDULE_VECTOR,			asm_sysvec_reschedule_ipi),
13262306a36Sopenharmony_ci	INTG(CALL_FUNCTION_VECTOR,		asm_sysvec_call_function),
13362306a36Sopenharmony_ci	INTG(CALL_FUNCTION_SINGLE_VECTOR,	asm_sysvec_call_function_single),
13462306a36Sopenharmony_ci	INTG(REBOOT_VECTOR,			asm_sysvec_reboot),
13562306a36Sopenharmony_ci#endif
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci#ifdef CONFIG_X86_THERMAL_VECTOR
13862306a36Sopenharmony_ci	INTG(THERMAL_APIC_VECTOR,		asm_sysvec_thermal),
13962306a36Sopenharmony_ci#endif
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci#ifdef CONFIG_X86_MCE_THRESHOLD
14262306a36Sopenharmony_ci	INTG(THRESHOLD_APIC_VECTOR,		asm_sysvec_threshold),
14362306a36Sopenharmony_ci#endif
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci#ifdef CONFIG_X86_MCE_AMD
14662306a36Sopenharmony_ci	INTG(DEFERRED_ERROR_VECTOR,		asm_sysvec_deferred_error),
14762306a36Sopenharmony_ci#endif
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci#ifdef CONFIG_X86_LOCAL_APIC
15062306a36Sopenharmony_ci	INTG(LOCAL_TIMER_VECTOR,		asm_sysvec_apic_timer_interrupt),
15162306a36Sopenharmony_ci	INTG(X86_PLATFORM_IPI_VECTOR,		asm_sysvec_x86_platform_ipi),
15262306a36Sopenharmony_ci# ifdef CONFIG_HAVE_KVM
15362306a36Sopenharmony_ci	INTG(POSTED_INTR_VECTOR,		asm_sysvec_kvm_posted_intr_ipi),
15462306a36Sopenharmony_ci	INTG(POSTED_INTR_WAKEUP_VECTOR,		asm_sysvec_kvm_posted_intr_wakeup_ipi),
15562306a36Sopenharmony_ci	INTG(POSTED_INTR_NESTED_VECTOR,		asm_sysvec_kvm_posted_intr_nested_ipi),
15662306a36Sopenharmony_ci# endif
15762306a36Sopenharmony_ci# ifdef CONFIG_IRQ_WORK
15862306a36Sopenharmony_ci	INTG(IRQ_WORK_VECTOR,			asm_sysvec_irq_work),
15962306a36Sopenharmony_ci# endif
16062306a36Sopenharmony_ci	INTG(SPURIOUS_APIC_VECTOR,		asm_sysvec_spurious_apic_interrupt),
16162306a36Sopenharmony_ci	INTG(ERROR_APIC_VECTOR,			asm_sysvec_error_interrupt),
16262306a36Sopenharmony_ci#endif
16362306a36Sopenharmony_ci};
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci/* Must be page-aligned because the real IDT is used in the cpu entry area */
16662306a36Sopenharmony_cistatic gate_desc idt_table[IDT_ENTRIES] __page_aligned_bss;
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_cistatic struct desc_ptr idt_descr __ro_after_init = {
16962306a36Sopenharmony_ci	.size		= IDT_TABLE_SIZE - 1,
17062306a36Sopenharmony_ci	.address	= (unsigned long) idt_table,
17162306a36Sopenharmony_ci};
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_civoid load_current_idt(void)
17462306a36Sopenharmony_ci{
17562306a36Sopenharmony_ci	lockdep_assert_irqs_disabled();
17662306a36Sopenharmony_ci	load_idt(&idt_descr);
17762306a36Sopenharmony_ci}
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci#ifdef CONFIG_X86_F00F_BUG
18062306a36Sopenharmony_cibool idt_is_f00f_address(unsigned long address)
18162306a36Sopenharmony_ci{
18262306a36Sopenharmony_ci	return ((address - idt_descr.address) >> 3) == 6;
18362306a36Sopenharmony_ci}
18462306a36Sopenharmony_ci#endif
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_cistatic __init void
18762306a36Sopenharmony_ciidt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sys)
18862306a36Sopenharmony_ci{
18962306a36Sopenharmony_ci	gate_desc desc;
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_ci	for (; size > 0; t++, size--) {
19262306a36Sopenharmony_ci		idt_init_desc(&desc, t);
19362306a36Sopenharmony_ci		write_idt_entry(idt, t->vector, &desc);
19462306a36Sopenharmony_ci		if (sys)
19562306a36Sopenharmony_ci			set_bit(t->vector, system_vectors);
19662306a36Sopenharmony_ci	}
19762306a36Sopenharmony_ci}
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_cistatic __init void set_intr_gate(unsigned int n, const void *addr)
20062306a36Sopenharmony_ci{
20162306a36Sopenharmony_ci	struct idt_data data;
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci	init_idt_data(&data, n, addr);
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci	idt_setup_from_table(idt_table, &data, 1, false);
20662306a36Sopenharmony_ci}
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci/**
20962306a36Sopenharmony_ci * idt_setup_early_traps - Initialize the idt table with early traps
21062306a36Sopenharmony_ci *
21162306a36Sopenharmony_ci * On X8664 these traps do not use interrupt stacks as they can't work
21262306a36Sopenharmony_ci * before cpu_init() is invoked and sets up TSS. The IST variants are
21362306a36Sopenharmony_ci * installed after that.
21462306a36Sopenharmony_ci */
21562306a36Sopenharmony_civoid __init idt_setup_early_traps(void)
21662306a36Sopenharmony_ci{
21762306a36Sopenharmony_ci	idt_setup_from_table(idt_table, early_idts, ARRAY_SIZE(early_idts),
21862306a36Sopenharmony_ci			     true);
21962306a36Sopenharmony_ci	load_idt(&idt_descr);
22062306a36Sopenharmony_ci}
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci/**
22362306a36Sopenharmony_ci * idt_setup_traps - Initialize the idt table with default traps
22462306a36Sopenharmony_ci */
22562306a36Sopenharmony_civoid __init idt_setup_traps(void)
22662306a36Sopenharmony_ci{
22762306a36Sopenharmony_ci	idt_setup_from_table(idt_table, def_idts, ARRAY_SIZE(def_idts), true);
22862306a36Sopenharmony_ci}
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci#ifdef CONFIG_X86_64
23162306a36Sopenharmony_ci/*
23262306a36Sopenharmony_ci * Early traps running on the DEFAULT_STACK because the other interrupt
23362306a36Sopenharmony_ci * stacks work only after cpu_init().
23462306a36Sopenharmony_ci */
23562306a36Sopenharmony_cistatic const __initconst struct idt_data early_pf_idts[] = {
23662306a36Sopenharmony_ci	INTG(X86_TRAP_PF,		asm_exc_page_fault),
23762306a36Sopenharmony_ci};
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci/**
24062306a36Sopenharmony_ci * idt_setup_early_pf - Initialize the idt table with early pagefault handler
24162306a36Sopenharmony_ci *
24262306a36Sopenharmony_ci * On X8664 this does not use interrupt stacks as they can't work before
24362306a36Sopenharmony_ci * cpu_init() is invoked and sets up TSS. The IST variant is installed
24462306a36Sopenharmony_ci * after that.
24562306a36Sopenharmony_ci *
24662306a36Sopenharmony_ci * Note, that X86_64 cannot install the real #PF handler in
24762306a36Sopenharmony_ci * idt_setup_early_traps() because the memory initialization needs the #PF
24862306a36Sopenharmony_ci * handler from the early_idt_handler_array to initialize the early page
24962306a36Sopenharmony_ci * tables.
25062306a36Sopenharmony_ci */
25162306a36Sopenharmony_civoid __init idt_setup_early_pf(void)
25262306a36Sopenharmony_ci{
25362306a36Sopenharmony_ci	idt_setup_from_table(idt_table, early_pf_idts,
25462306a36Sopenharmony_ci			     ARRAY_SIZE(early_pf_idts), true);
25562306a36Sopenharmony_ci}
25662306a36Sopenharmony_ci#endif
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_cistatic void __init idt_map_in_cea(void)
25962306a36Sopenharmony_ci{
26062306a36Sopenharmony_ci	/*
26162306a36Sopenharmony_ci	 * Set the IDT descriptor to a fixed read-only location in the cpu
26262306a36Sopenharmony_ci	 * entry area, so that the "sidt" instruction will not leak the
26362306a36Sopenharmony_ci	 * location of the kernel, and to defend the IDT against arbitrary
26462306a36Sopenharmony_ci	 * memory write vulnerabilities.
26562306a36Sopenharmony_ci	 */
26662306a36Sopenharmony_ci	cea_set_pte(CPU_ENTRY_AREA_RO_IDT_VADDR, __pa_symbol(idt_table),
26762306a36Sopenharmony_ci		    PAGE_KERNEL_RO);
26862306a36Sopenharmony_ci	idt_descr.address = CPU_ENTRY_AREA_RO_IDT;
26962306a36Sopenharmony_ci}
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci/**
27262306a36Sopenharmony_ci * idt_setup_apic_and_irq_gates - Setup APIC/SMP and normal interrupt gates
27362306a36Sopenharmony_ci */
27462306a36Sopenharmony_civoid __init idt_setup_apic_and_irq_gates(void)
27562306a36Sopenharmony_ci{
27662306a36Sopenharmony_ci	int i = FIRST_EXTERNAL_VECTOR;
27762306a36Sopenharmony_ci	void *entry;
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ci	idt_setup_from_table(idt_table, apic_idts, ARRAY_SIZE(apic_idts), true);
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci	for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR) {
28262306a36Sopenharmony_ci		entry = irq_entries_start + IDT_ALIGN * (i - FIRST_EXTERNAL_VECTOR);
28362306a36Sopenharmony_ci		set_intr_gate(i, entry);
28462306a36Sopenharmony_ci	}
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_ci#ifdef CONFIG_X86_LOCAL_APIC
28762306a36Sopenharmony_ci	for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
28862306a36Sopenharmony_ci		/*
28962306a36Sopenharmony_ci		 * Don't set the non assigned system vectors in the
29062306a36Sopenharmony_ci		 * system_vectors bitmap. Otherwise they show up in
29162306a36Sopenharmony_ci		 * /proc/interrupts.
29262306a36Sopenharmony_ci		 */
29362306a36Sopenharmony_ci		entry = spurious_entries_start + IDT_ALIGN * (i - FIRST_SYSTEM_VECTOR);
29462306a36Sopenharmony_ci		set_intr_gate(i, entry);
29562306a36Sopenharmony_ci	}
29662306a36Sopenharmony_ci#endif
29762306a36Sopenharmony_ci	/* Map IDT into CPU entry area and reload it. */
29862306a36Sopenharmony_ci	idt_map_in_cea();
29962306a36Sopenharmony_ci	load_idt(&idt_descr);
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci	/* Make the IDT table read only */
30262306a36Sopenharmony_ci	set_memory_ro((unsigned long)&idt_table, 1);
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci	idt_setup_done = true;
30562306a36Sopenharmony_ci}
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci/**
30862306a36Sopenharmony_ci * idt_setup_early_handler - Initializes the idt table with early handlers
30962306a36Sopenharmony_ci */
31062306a36Sopenharmony_civoid __init idt_setup_early_handler(void)
31162306a36Sopenharmony_ci{
31262306a36Sopenharmony_ci	int i;
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_ci	for (i = 0; i < NUM_EXCEPTION_VECTORS; i++)
31562306a36Sopenharmony_ci		set_intr_gate(i, early_idt_handler_array[i]);
31662306a36Sopenharmony_ci#ifdef CONFIG_X86_32
31762306a36Sopenharmony_ci	for ( ; i < NR_VECTORS; i++)
31862306a36Sopenharmony_ci		set_intr_gate(i, early_ignore_irq);
31962306a36Sopenharmony_ci#endif
32062306a36Sopenharmony_ci	load_idt(&idt_descr);
32162306a36Sopenharmony_ci}
32262306a36Sopenharmony_ci
32362306a36Sopenharmony_ci/**
32462306a36Sopenharmony_ci * idt_invalidate - Invalidate interrupt descriptor table
32562306a36Sopenharmony_ci */
32662306a36Sopenharmony_civoid idt_invalidate(void)
32762306a36Sopenharmony_ci{
32862306a36Sopenharmony_ci	static const struct desc_ptr idt = { .address = 0, .size = 0 };
32962306a36Sopenharmony_ci
33062306a36Sopenharmony_ci	load_idt(&idt);
33162306a36Sopenharmony_ci}
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_civoid __init alloc_intr_gate(unsigned int n, const void *addr)
33462306a36Sopenharmony_ci{
33562306a36Sopenharmony_ci	if (WARN_ON(n < FIRST_SYSTEM_VECTOR))
33662306a36Sopenharmony_ci		return;
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci	if (WARN_ON(idt_setup_done))
33962306a36Sopenharmony_ci		return;
34062306a36Sopenharmony_ci
34162306a36Sopenharmony_ci	if (!WARN_ON(test_and_set_bit(n, system_vectors)))
34262306a36Sopenharmony_ci		set_intr_gate(n, addr);
34362306a36Sopenharmony_ci}
344