x86/entry: Move nmi entry/exit into common code
[linux-block.git] / arch / x86 / include / asm / idtentry.h
CommitLineData
53aaf262
TG
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_X86_IDTENTRY_H
3#define _ASM_X86_IDTENTRY_H
4
5/* Interrupts/Exceptions */
6#include <asm/trapnr.h>
7
8#ifndef __ASSEMBLY__
27d6b4d1 9#include <linux/entry-common.h>
6368558c
TG
10#include <linux/hardirq.h>
11
12#include <asm/irq_stack.h>
53aaf262
TG
13
14/**
15 * DECLARE_IDTENTRY - Declare functions for simple IDT entry points
16 * No error code pushed by hardware
17 * @vector: Vector number (ignored for C)
18 * @func: Function name of the entry point
19 *
20 * Declares three functions:
21 * - The ASM entry point: asm_##func
22 * - The XEN PV trap entry point: xen_##func (maybe unused)
23 * - The C handler called from the ASM entry point
24 *
25 * Note: This is the C variant of DECLARE_IDTENTRY(). As the name says it
26 * declares the entry points for usage in C code. There is an ASM variant
27 * as well which is used to emit the entry stubs in entry_32/64.S.
28 */
29#define DECLARE_IDTENTRY(vector, func) \
30 asmlinkage void asm_##func(void); \
31 asmlinkage void xen_asm_##func(void); \
32 __visible void func(struct pt_regs *regs)
33
34/**
35 * DEFINE_IDTENTRY - Emit code for simple IDT entry points
36 * @func: Function name of the entry point
37 *
38 * @func is called from ASM entry code with interrupts disabled.
39 *
40 * The macro is written so it acts as function definition. Append the
41 * body with a pair of curly brackets.
42 *
a27a0a55
TG
43 * irqentry_enter() contains common code which has to be invoked before
44 * arbitrary code in the body. irqentry_exit() contains common code
53aaf262
TG
45 * which has to run before returning to the low level assembly code.
46 */
47#define DEFINE_IDTENTRY(func) \
48static __always_inline void __##func(struct pt_regs *regs); \
49 \
50__visible noinstr void func(struct pt_regs *regs) \
51{ \
a27a0a55 52 irqentry_state_t state = irqentry_enter(regs); \
fa95d7dc 53 \
53aaf262
TG
54 instrumentation_begin(); \
55 __##func (regs); \
56 instrumentation_end(); \
a27a0a55 57 irqentry_exit(regs, state); \
53aaf262
TG
58} \
59 \
60static __always_inline void __##func(struct pt_regs *regs)
61
d7729050
TG
62/* Special case for 32bit IRET 'trap' */
63#define DECLARE_IDTENTRY_SW DECLARE_IDTENTRY
64#define DEFINE_IDTENTRY_SW DEFINE_IDTENTRY
65
aabfe538
TG
66/**
67 * DECLARE_IDTENTRY_ERRORCODE - Declare functions for simple IDT entry points
68 * Error code pushed by hardware
69 * @vector: Vector number (ignored for C)
70 * @func: Function name of the entry point
71 *
72 * Declares three functions:
73 * - The ASM entry point: asm_##func
74 * - The XEN PV trap entry point: xen_##func (maybe unused)
75 * - The C handler called from the ASM entry point
76 *
77 * Same as DECLARE_IDTENTRY, but has an extra error_code argument for the
78 * C-handler.
79 */
80#define DECLARE_IDTENTRY_ERRORCODE(vector, func) \
81 asmlinkage void asm_##func(void); \
82 asmlinkage void xen_asm_##func(void); \
83 __visible void func(struct pt_regs *regs, unsigned long error_code)
84
85/**
86 * DEFINE_IDTENTRY_ERRORCODE - Emit code for simple IDT entry points
87 * Error code pushed by hardware
88 * @func: Function name of the entry point
89 *
90 * Same as DEFINE_IDTENTRY, but has an extra error_code argument
91 */
92#define DEFINE_IDTENTRY_ERRORCODE(func) \
93static __always_inline void __##func(struct pt_regs *regs, \
94 unsigned long error_code); \
95 \
96__visible noinstr void func(struct pt_regs *regs, \
97 unsigned long error_code) \
98{ \
a27a0a55 99 irqentry_state_t state = irqentry_enter(regs); \
fa95d7dc 100 \
aabfe538
TG
101 instrumentation_begin(); \
102 __##func (regs, error_code); \
103 instrumentation_end(); \
a27a0a55 104 irqentry_exit(regs, state); \
aabfe538
TG
105} \
106 \
107static __always_inline void __##func(struct pt_regs *regs, \
108 unsigned long error_code)
109
0dc6cdc2
TG
110/**
111 * DECLARE_IDTENTRY_RAW - Declare functions for raw IDT entry points
112 * No error code pushed by hardware
113 * @vector: Vector number (ignored for C)
114 * @func: Function name of the entry point
115 *
116 * Maps to DECLARE_IDTENTRY().
117 */
118#define DECLARE_IDTENTRY_RAW(vector, func) \
119 DECLARE_IDTENTRY(vector, func)
120
121/**
122 * DEFINE_IDTENTRY_RAW - Emit code for raw IDT entry points
123 * @func: Function name of the entry point
124 *
125 * @func is called from ASM entry code with interrupts disabled.
126 *
127 * The macro is written so it acts as function definition. Append the
128 * body with a pair of curly brackets.
129 *
130 * Contrary to DEFINE_IDTENTRY() this does not invoke the
131 * idtentry_enter/exit() helpers before and after the body invocation. This
132 * needs to be done in the body itself if applicable. Use if extra work
133 * is required before the enter/exit() helpers are invoked.
134 */
135#define DEFINE_IDTENTRY_RAW(func) \
136__visible noinstr void func(struct pt_regs *regs)
137
6a8dfa8e
TG
138/**
139 * DECLARE_IDTENTRY_RAW_ERRORCODE - Declare functions for raw IDT entry points
140 * Error code pushed by hardware
141 * @vector: Vector number (ignored for C)
142 * @func: Function name of the entry point
143 *
144 * Maps to DECLARE_IDTENTRY_ERRORCODE()
145 */
146#define DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func) \
147 DECLARE_IDTENTRY_ERRORCODE(vector, func)
148
149/**
150 * DEFINE_IDTENTRY_RAW_ERRORCODE - Emit code for raw IDT entry points
151 * @func: Function name of the entry point
152 *
153 * @func is called from ASM entry code with interrupts disabled.
154 *
155 * The macro is written so it acts as function definition. Append the
156 * body with a pair of curly brackets.
157 *
158 * Contrary to DEFINE_IDTENTRY_ERRORCODE() this does not invoke the
a27a0a55 159 * irqentry_enter/exit() helpers before and after the body invocation. This
6a8dfa8e
TG
160 * needs to be done in the body itself if applicable. Use if extra work
161 * is required before the enter/exit() helpers are invoked.
162 */
163#define DEFINE_IDTENTRY_RAW_ERRORCODE(func) \
164__visible noinstr void func(struct pt_regs *regs, unsigned long error_code)
165
0bf7c314
TG
166/**
167 * DECLARE_IDTENTRY_IRQ - Declare functions for device interrupt IDT entry
168 * points (common/spurious)
169 * @vector: Vector number (ignored for C)
170 * @func: Function name of the entry point
171 *
172 * Maps to DECLARE_IDTENTRY_ERRORCODE()
173 */
174#define DECLARE_IDTENTRY_IRQ(vector, func) \
175 DECLARE_IDTENTRY_ERRORCODE(vector, func)
176
177/**
178 * DEFINE_IDTENTRY_IRQ - Emit code for device interrupt IDT entry points
179 * @func: Function name of the entry point
180 *
181 * The vector number is pushed by the low level entry stub and handed
182 * to the function as error_code argument which needs to be truncated
183 * to an u8 because the push is sign extending.
184 *
0bf7c314 185 * irq_enter/exit_rcu() are invoked before the function body and the
790ce3b4
TG
186 * KVM L1D flush request is set. Stack switching to the interrupt stack
187 * has to be done in the function body if necessary.
0bf7c314
TG
188 */
189#define DEFINE_IDTENTRY_IRQ(func) \
190static __always_inline void __##func(struct pt_regs *regs, u8 vector); \
191 \
192__visible noinstr void func(struct pt_regs *regs, \
193 unsigned long error_code) \
194{ \
a27a0a55 195 irqentry_state_t state = irqentry_enter(regs); \
0bf7c314
TG
196 \
197 instrumentation_begin(); \
198 irq_enter_rcu(); \
199 kvm_set_cpu_l1tf_flush_l1d(); \
200 __##func (regs, (u8)error_code); \
201 irq_exit_rcu(); \
0bf7c314 202 instrumentation_end(); \
a27a0a55 203 irqentry_exit(regs, state); \
0bf7c314
TG
204} \
205 \
206static __always_inline void __##func(struct pt_regs *regs, u8 vector)
207
6368558c
TG
208/**
209 * DECLARE_IDTENTRY_SYSVEC - Declare functions for system vector entry points
210 * @vector: Vector number (ignored for C)
211 * @func: Function name of the entry point
212 *
213 * Declares three functions:
214 * - The ASM entry point: asm_##func
215 * - The XEN PV trap entry point: xen_##func (maybe unused)
216 * - The C handler called from the ASM entry point
217 *
218 * Maps to DECLARE_IDTENTRY().
219 */
220#define DECLARE_IDTENTRY_SYSVEC(vector, func) \
221 DECLARE_IDTENTRY(vector, func)
222
223/**
224 * DEFINE_IDTENTRY_SYSVEC - Emit code for system vector IDT entry points
225 * @func: Function name of the entry point
226 *
a27a0a55 227 * irqentry_enter/exit() and irq_enter/exit_rcu() are invoked before the
6368558c
TG
228 * function body. KVM L1D flush request is set.
229 *
230 * Runs the function on the interrupt stack if the entry hit kernel mode
231 */
232#define DEFINE_IDTENTRY_SYSVEC(func) \
233static void __##func(struct pt_regs *regs); \
234 \
235__visible noinstr void func(struct pt_regs *regs) \
236{ \
a27a0a55 237 irqentry_state_t state = irqentry_enter(regs); \
6368558c
TG
238 \
239 instrumentation_begin(); \
240 irq_enter_rcu(); \
241 kvm_set_cpu_l1tf_flush_l1d(); \
a7b3474c 242 run_sysvec_on_irqstack_cond(__##func, regs); \
6368558c 243 irq_exit_rcu(); \
6368558c 244 instrumentation_end(); \
a27a0a55 245 irqentry_exit(regs, state); \
6368558c
TG
246} \
247 \
248static noinline void __##func(struct pt_regs *regs)
249
250/**
251 * DEFINE_IDTENTRY_SYSVEC_SIMPLE - Emit code for simple system vector IDT
252 * entry points
253 * @func: Function name of the entry point
254 *
255 * Runs the function on the interrupted stack. No switch to IRQ stack and
256 * only the minimal __irq_enter/exit() handling.
257 *
258 * Only use for 'empty' vectors like reschedule IPI and KVM posted
259 * interrupt vectors.
260 */
261#define DEFINE_IDTENTRY_SYSVEC_SIMPLE(func) \
262static __always_inline void __##func(struct pt_regs *regs); \
263 \
264__visible noinstr void func(struct pt_regs *regs) \
265{ \
a27a0a55 266 irqentry_state_t state = irqentry_enter(regs); \
6368558c
TG
267 \
268 instrumentation_begin(); \
269 __irq_enter_raw(); \
270 kvm_set_cpu_l1tf_flush_l1d(); \
271 __##func (regs); \
272 __irq_exit_raw(); \
273 instrumentation_end(); \
a27a0a55 274 irqentry_exit(regs, state); \
6368558c
TG
275} \
276 \
277static __always_inline void __##func(struct pt_regs *regs)
278
2f6474e4
TG
279/**
280 * DECLARE_IDTENTRY_XENCB - Declare functions for XEN HV callback entry point
281 * @vector: Vector number (ignored for C)
282 * @func: Function name of the entry point
283 *
284 * Declares three functions:
285 * - The ASM entry point: asm_##func
286 * - The XEN PV trap entry point: xen_##func (maybe unused)
287 * - The C handler called from the ASM entry point
288 *
289 * Maps to DECLARE_IDTENTRY(). Distinct entry point to handle the 32/64-bit
290 * difference
291 */
292#define DECLARE_IDTENTRY_XENCB(vector, func) \
293 DECLARE_IDTENTRY(vector, func)
6a8dfa8e 294
2c058b03
TG
295#ifdef CONFIG_X86_64
296/**
297 * DECLARE_IDTENTRY_IST - Declare functions for IST handling IDT entry points
298 * @vector: Vector number (ignored for C)
299 * @func: Function name of the entry point
300 *
f08e32ec
TG
301 * Maps to DECLARE_IDTENTRY_RAW, but declares also the NOIST C handler
302 * which is called from the ASM entry point on user mode entry
2c058b03
TG
303 */
304#define DECLARE_IDTENTRY_IST(vector, func) \
f08e32ec
TG
305 DECLARE_IDTENTRY_RAW(vector, func); \
306 __visible void noist_##func(struct pt_regs *regs)
2c058b03 307
a13644f3
JR
308/**
309 * DECLARE_IDTENTRY_VC - Declare functions for the VC entry point
310 * @vector: Vector number (ignored for C)
311 * @func: Function name of the entry point
312 *
313 * Maps to DECLARE_IDTENTRY_RAW_ERRORCODE, but declares also the
314 * safe_stack C handler.
315 */
316#define DECLARE_IDTENTRY_VC(vector, func) \
317 DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func); \
0786138c 318 __visible noinstr void ist_##func(struct pt_regs *regs, unsigned long error_code); \
a13644f3
JR
319 __visible noinstr void safe_stack_##func(struct pt_regs *regs, unsigned long error_code)
320
2c058b03
TG
321/**
322 * DEFINE_IDTENTRY_IST - Emit code for IST entry points
323 * @func: Function name of the entry point
324 *
325 * Maps to DEFINE_IDTENTRY_RAW
326 */
327#define DEFINE_IDTENTRY_IST(func) \
328 DEFINE_IDTENTRY_RAW(func)
329
f08e32ec
TG
330/**
331 * DEFINE_IDTENTRY_NOIST - Emit code for NOIST entry points which
332 * belong to a IST entry point (MCE, DB)
333 * @func: Function name of the entry point. Must be the same as
334 * the function name of the corresponding IST variant
335 *
336 * Maps to DEFINE_IDTENTRY_RAW().
337 */
338#define DEFINE_IDTENTRY_NOIST(func) \
339 DEFINE_IDTENTRY_RAW(noist_##func)
340
6a8dfa8e
TG
341/**
342 * DECLARE_IDTENTRY_DF - Declare functions for double fault
343 * @vector: Vector number (ignored for C)
344 * @func: Function name of the entry point
345 *
346 * Maps to DECLARE_IDTENTRY_RAW_ERRORCODE
347 */
348#define DECLARE_IDTENTRY_DF(vector, func) \
349 DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func)
350
351/**
352 * DEFINE_IDTENTRY_DF - Emit code for double fault
353 * @func: Function name of the entry point
354 *
355 * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
356 */
357#define DEFINE_IDTENTRY_DF(func) \
358 DEFINE_IDTENTRY_RAW_ERRORCODE(func)
359
a13644f3
JR
360/**
361 * DEFINE_IDTENTRY_VC_SAFE_STACK - Emit code for VMM communication handler
362 which runs on a safe stack.
363 * @func: Function name of the entry point
364 *
365 * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
366 */
367#define DEFINE_IDTENTRY_VC_SAFE_STACK(func) \
368 DEFINE_IDTENTRY_RAW_ERRORCODE(safe_stack_##func)
369
370/**
371 * DEFINE_IDTENTRY_VC_IST - Emit code for VMM communication handler
372 which runs on the VC fall-back stack
373 * @func: Function name of the entry point
374 *
375 * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
376 */
377#define DEFINE_IDTENTRY_VC_IST(func) \
378 DEFINE_IDTENTRY_RAW_ERRORCODE(ist_##func)
379
380/**
381 * DEFINE_IDTENTRY_VC - Emit code for VMM communication handler
382 * @func: Function name of the entry point
383 *
384 * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
385 */
386#define DEFINE_IDTENTRY_VC(func) \
387 DEFINE_IDTENTRY_RAW_ERRORCODE(func)
388
2c058b03 389#else /* CONFIG_X86_64 */
6a8dfa8e 390
6a8dfa8e
TG
391/**
392 * DECLARE_IDTENTRY_DF - Declare functions for double fault 32bit variant
393 * @vector: Vector number (ignored for C)
394 * @func: Function name of the entry point
395 *
396 * Declares two functions:
397 * - The ASM entry point: asm_##func
398 * - The C handler called from the C shim
399 */
400#define DECLARE_IDTENTRY_DF(vector, func) \
401 asmlinkage void asm_##func(void); \
402 __visible void func(struct pt_regs *regs, \
403 unsigned long error_code, \
404 unsigned long address)
405
406/**
407 * DEFINE_IDTENTRY_DF - Emit code for double fault on 32bit
408 * @func: Function name of the entry point
409 *
410 * This is called through the doublefault shim which already provides
411 * cr2 in the address argument.
412 */
413#define DEFINE_IDTENTRY_DF(func) \
414__visible noinstr void func(struct pt_regs *regs, \
415 unsigned long error_code, \
416 unsigned long address)
417
2c058b03
TG
418#endif /* !CONFIG_X86_64 */
419
420/* C-Code mapping */
13cbc0cd
AL
421#define DECLARE_IDTENTRY_NMI DECLARE_IDTENTRY_RAW
422#define DEFINE_IDTENTRY_NMI DEFINE_IDTENTRY_RAW
423
424#ifdef CONFIG_X86_64
2c058b03
TG
425#define DECLARE_IDTENTRY_MCE DECLARE_IDTENTRY_IST
426#define DEFINE_IDTENTRY_MCE DEFINE_IDTENTRY_IST
f08e32ec 427#define DEFINE_IDTENTRY_MCE_USER DEFINE_IDTENTRY_NOIST
2c058b03 428
2c058b03
TG
429#define DECLARE_IDTENTRY_DEBUG DECLARE_IDTENTRY_IST
430#define DEFINE_IDTENTRY_DEBUG DEFINE_IDTENTRY_IST
f08e32ec 431#define DEFINE_IDTENTRY_DEBUG_USER DEFINE_IDTENTRY_NOIST
13cbc0cd 432#endif
2c058b03 433
53aaf262
TG
434#else /* !__ASSEMBLY__ */
435
436/*
437 * The ASM variants for DECLARE_IDTENTRY*() which emit the ASM entry stubs.
438 */
439#define DECLARE_IDTENTRY(vector, func) \
e2dcb5f1 440 idtentry vector asm_##func func has_error_code=0
53aaf262 441
aabfe538 442#define DECLARE_IDTENTRY_ERRORCODE(vector, func) \
e2dcb5f1 443 idtentry vector asm_##func func has_error_code=1
aabfe538 444
d7729050
TG
445/* Special case for 32bit IRET 'trap'. Do not emit ASM code */
446#define DECLARE_IDTENTRY_SW(vector, func)
447
0dc6cdc2
TG
448#define DECLARE_IDTENTRY_RAW(vector, func) \
449 DECLARE_IDTENTRY(vector, func)
450
6a8dfa8e
TG
451#define DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func) \
452 DECLARE_IDTENTRY_ERRORCODE(vector, func)
453
0bf7c314
TG
454/* Entries for common/spurious (device) interrupts */
455#define DECLARE_IDTENTRY_IRQ(vector, func) \
456 idtentry_irq vector func
457
6368558c
TG
458/* System vector entries */
459#define DECLARE_IDTENTRY_SYSVEC(vector, func) \
460 idtentry_sysvec vector func
461
2c058b03
TG
462#ifdef CONFIG_X86_64
463# define DECLARE_IDTENTRY_MCE(vector, func) \
464 idtentry_mce_db vector asm_##func func
465
466# define DECLARE_IDTENTRY_DEBUG(vector, func) \
467 idtentry_mce_db vector asm_##func func
468
6a8dfa8e
TG
469# define DECLARE_IDTENTRY_DF(vector, func) \
470 idtentry_df vector asm_##func func
471
2f6474e4
TG
472# define DECLARE_IDTENTRY_XENCB(vector, func) \
473 DECLARE_IDTENTRY(vector, func)
474
a13644f3
JR
475# define DECLARE_IDTENTRY_VC(vector, func) \
476 idtentry_vc vector asm_##func func
477
2c058b03
TG
478#else
479# define DECLARE_IDTENTRY_MCE(vector, func) \
480 DECLARE_IDTENTRY(vector, func)
481
6a8dfa8e
TG
482/* No ASM emitted for DF as this goes through a C shim */
483# define DECLARE_IDTENTRY_DF(vector, func)
484
2f6474e4
TG
485/* No ASM emitted for XEN hypervisor callback */
486# define DECLARE_IDTENTRY_XENCB(vector, func)
487
2c058b03
TG
488#endif
489
490/* No ASM code emitted for NMI */
491#define DECLARE_IDTENTRY_NMI(vector, func)
492
633260fa
TG
493/*
494 * ASM code to emit the common vector entry stubs where each stub is
495 * packed into 8 bytes.
496 *
497 * Note, that the 'pushq imm8' is emitted via '.byte 0x6a, vector' because
498 * GCC treats the local vector variable as unsigned int and would expand
499 * all vectors above 0x7F to a 5 byte push. The original code did an
500 * adjustment of the vector number to be in the signed byte range to avoid
501 * this. While clever it's mindboggling counterintuitive and requires the
502 * odd conversion back to a real vector number in the C entry points. Using
503 * .byte achieves the same thing and the only fixup needed in the C entry
504 * point is to mask off the bits above bit 7 because the push is sign
505 * extending.
506 */
507 .align 8
508SYM_CODE_START(irq_entries_start)
509 vector=FIRST_EXTERNAL_VECTOR
633260fa
TG
510 .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
511 UNWIND_HINT_IRET_REGS
6ee93f8d 5120 :
633260fa 513 .byte 0x6a, vector
fa5e5c40 514 jmp asm_common_interrupt
633260fa
TG
515 nop
516 /* Ensure that the above is 8 bytes max */
6ee93f8d
JC
517 . = 0b + 8
518 vector = vector+1
633260fa
TG
519 .endr
520SYM_CODE_END(irq_entries_start)
521
522#ifdef CONFIG_X86_LOCAL_APIC
523 .align 8
524SYM_CODE_START(spurious_entries_start)
525 vector=FIRST_SYSTEM_VECTOR
633260fa
TG
526 .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
527 UNWIND_HINT_IRET_REGS
6ee93f8d 5280 :
633260fa 529 .byte 0x6a, vector
fa5e5c40 530 jmp asm_spurious_interrupt
633260fa
TG
531 nop
532 /* Ensure that the above is 8 bytes max */
6ee93f8d
JC
533 . = 0b + 8
534 vector = vector+1
633260fa
TG
535 .endr
536SYM_CODE_END(spurious_entries_start)
537#endif
538
53aaf262
TG
539#endif /* __ASSEMBLY__ */
540
9d06c402
TG
541/*
542 * The actual entry points. Note that DECLARE_IDTENTRY*() serves two
543 * purposes:
544 * - provide the function declarations when included from C-Code
545 * - emit the ASM stubs when included from entry_32/64.S
546 *
547 * This avoids duplicate defines and ensures that everything is consistent.
548 */
549
2f6474e4
TG
550/*
551 * Dummy trap number so the low level ASM macro vector number checks do not
552 * match which results in emitting plain IDTENTRY stubs without bells and
553 * whistels.
554 */
555#define X86_TRAP_OTHER 0xFFFF
556
9d06c402
TG
557/* Simple exception entry points. No hardware error code */
558DECLARE_IDTENTRY(X86_TRAP_DE, exc_divide_error);
4b6b9111 559DECLARE_IDTENTRY(X86_TRAP_OF, exc_overflow);
58d9c81f 560DECLARE_IDTENTRY(X86_TRAP_BR, exc_bounds);
866ae2cc 561DECLARE_IDTENTRY(X86_TRAP_NM, exc_device_not_available);
f95658fd 562DECLARE_IDTENTRY(X86_TRAP_OLD_MF, exc_coproc_segment_overrun);
dad7106f 563DECLARE_IDTENTRY(X86_TRAP_SPURIOUS, exc_spurious_interrupt_bug);
14a8bd2a 564DECLARE_IDTENTRY(X86_TRAP_MF, exc_coprocessor_error);
48227e21 565DECLARE_IDTENTRY(X86_TRAP_XF, exc_simd_coprocessor_error);
9d06c402 566
d7729050
TG
567/* 32bit software IRET trap. Do not emit ASM code */
568DECLARE_IDTENTRY_SW(X86_TRAP_IRET, iret_error);
569
97b3d290
TG
570/* Simple exception entries with error code pushed by hardware */
571DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_TS, exc_invalid_tss);
99a3fb8d 572DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_NP, exc_segment_not_present);
fd9689bf 573DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_SS, exc_stack_segment);
be4c11af 574DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_GP, exc_general_protection);
436608bb 575DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_AC, exc_alignment_check);
97b3d290 576
8edd7e37 577/* Raw exception entries which need extra work */
15a416e8 578DECLARE_IDTENTRY_RAW(X86_TRAP_UD, exc_invalid_op);
91eeafea
TG
579DECLARE_IDTENTRY_RAW(X86_TRAP_BP, exc_int3);
580DECLARE_IDTENTRY_RAW_ERRORCODE(X86_TRAP_PF, exc_page_fault);
8edd7e37 581
8cd501c1 582#ifdef CONFIG_X86_MCE
13cbc0cd 583#ifdef CONFIG_X86_64
8cd501c1 584DECLARE_IDTENTRY_MCE(X86_TRAP_MC, exc_machine_check);
13cbc0cd
AL
585#else
586DECLARE_IDTENTRY_RAW(X86_TRAP_MC, exc_machine_check);
587#endif
8cd501c1
TG
588#endif
589
6271fef0
TG
590/* NMI */
591DECLARE_IDTENTRY_NMI(X86_TRAP_NMI, exc_nmi);
76fdb041 592#ifdef CONFIG_XEN_PV
f41f0824
AL
593DECLARE_IDTENTRY_RAW(X86_TRAP_NMI, xenpv_exc_nmi);
594#endif
6271fef0 595
2bbc68f8 596/* #DB */
13cbc0cd 597#ifdef CONFIG_X86_64
2bbc68f8 598DECLARE_IDTENTRY_DEBUG(X86_TRAP_DB, exc_debug);
13cbc0cd
AL
599#else
600DECLARE_IDTENTRY_RAW(X86_TRAP_DB, exc_debug);
601#endif
76fdb041 602#ifdef CONFIG_XEN_PV
f41f0824
AL
603DECLARE_IDTENTRY_RAW(X86_TRAP_DB, xenpv_exc_debug);
604#endif
2bbc68f8 605
c29c775a
TG
606/* #DF */
607DECLARE_IDTENTRY_DF(X86_TRAP_DF, exc_double_fault);
608
0786138c
TL
609/* #VC */
610#ifdef CONFIG_AMD_MEM_ENCRYPT
611DECLARE_IDTENTRY_VC(X86_TRAP_VC, exc_vmm_communication);
612#endif
613
2f6474e4
TG
614#ifdef CONFIG_XEN_PV
615DECLARE_IDTENTRY_XENCB(X86_TRAP_OTHER, exc_xen_hypervisor_callback);
616#endif
617
fa5e5c40
TG
618/* Device interrupts common/spurious */
619DECLARE_IDTENTRY_IRQ(X86_TRAP_OTHER, common_interrupt);
620#ifdef CONFIG_X86_LOCAL_APIC
621DECLARE_IDTENTRY_IRQ(X86_TRAP_OTHER, spurious_interrupt);
622#endif
623
db0338ee
TG
624/* System vector entry points */
625#ifdef CONFIG_X86_LOCAL_APIC
626DECLARE_IDTENTRY_SYSVEC(ERROR_APIC_VECTOR, sysvec_error_interrupt);
627DECLARE_IDTENTRY_SYSVEC(SPURIOUS_APIC_VECTOR, sysvec_spurious_apic_interrupt);
628DECLARE_IDTENTRY_SYSVEC(LOCAL_TIMER_VECTOR, sysvec_apic_timer_interrupt);
629DECLARE_IDTENTRY_SYSVEC(X86_PLATFORM_IPI_VECTOR, sysvec_x86_platform_ipi);
630#endif
631
582f9191 632#ifdef CONFIG_SMP
13cad985 633DECLARE_IDTENTRY(RESCHEDULE_VECTOR, sysvec_reschedule_ipi);
582f9191
TG
634DECLARE_IDTENTRY_SYSVEC(IRQ_MOVE_CLEANUP_VECTOR, sysvec_irq_move_cleanup);
635DECLARE_IDTENTRY_SYSVEC(REBOOT_VECTOR, sysvec_reboot);
636DECLARE_IDTENTRY_SYSVEC(CALL_FUNCTION_SINGLE_VECTOR, sysvec_call_function_single);
637DECLARE_IDTENTRY_SYSVEC(CALL_FUNCTION_VECTOR, sysvec_call_function);
638#endif
639
720909a7 640#ifdef CONFIG_X86_LOCAL_APIC
720909a7
TG
641# ifdef CONFIG_X86_MCE_THRESHOLD
642DECLARE_IDTENTRY_SYSVEC(THRESHOLD_APIC_VECTOR, sysvec_threshold);
643# endif
644
645# ifdef CONFIG_X86_MCE_AMD
646DECLARE_IDTENTRY_SYSVEC(DEFERRED_ERROR_VECTOR, sysvec_deferred_error);
647# endif
648
649# ifdef CONFIG_X86_THERMAL_VECTOR
650DECLARE_IDTENTRY_SYSVEC(THERMAL_APIC_VECTOR, sysvec_thermal);
651# endif
652
653# ifdef CONFIG_IRQ_WORK
654DECLARE_IDTENTRY_SYSVEC(IRQ_WORK_VECTOR, sysvec_irq_work);
655# endif
656#endif
657
9c3b1f49
TG
658#ifdef CONFIG_HAVE_KVM
659DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_VECTOR, sysvec_kvm_posted_intr_ipi);
660DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_WAKEUP_VECTOR, sysvec_kvm_posted_intr_wakeup_ipi);
661DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_NESTED_VECTOR, sysvec_kvm_posted_intr_nested_ipi);
662#endif
663
a16be368
TG
664#if IS_ENABLED(CONFIG_HYPERV)
665DECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR, sysvec_hyperv_callback);
5769fe26
SD
666DECLARE_IDTENTRY_SYSVEC(HYPERV_REENLIGHTENMENT_VECTOR, sysvec_hyperv_reenlightenment);
667DECLARE_IDTENTRY_SYSVEC(HYPERV_STIMER0_VECTOR, sysvec_hyperv_stimer0);
a16be368
TG
668#endif
669
670#if IS_ENABLED(CONFIG_ACRN_GUEST)
671DECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR, sysvec_acrn_hv_callback);
672#endif
673
cb09ea29
TG
674#ifdef CONFIG_XEN_PVHVM
675DECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR, sysvec_xen_hvm_callback);
676#endif
677
26d05b36
PB
678#ifdef CONFIG_KVM_GUEST
679DECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR, sysvec_kvm_asyncpf_interrupt);
680#endif
681
2f6474e4
TG
682#undef X86_TRAP_OTHER
683
53aaf262 684#endif