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