Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_X86_IDTENTRY_H
0003 #define _ASM_X86_IDTENTRY_H
0004 
0005 /* Interrupts/Exceptions */
0006 #include <asm/trapnr.h>
0007 
0008 #define IDT_ALIGN   (8 * (1 + HAS_KERNEL_IBT))
0009 
0010 #ifndef __ASSEMBLY__
0011 #include <linux/entry-common.h>
0012 #include <linux/hardirq.h>
0013 
0014 #include <asm/irq_stack.h>
0015 
0016 /**
0017  * DECLARE_IDTENTRY - Declare functions for simple IDT entry points
0018  *            No error code pushed by hardware
0019  * @vector: Vector number (ignored for C)
0020  * @func:   Function name of the entry point
0021  *
0022  * Declares three functions:
0023  * - The ASM entry point: asm_##func
0024  * - The XEN PV trap entry point: xen_##func (maybe unused)
0025  * - The C handler called from the ASM entry point
0026  *
0027  * Note: This is the C variant of DECLARE_IDTENTRY(). As the name says it
0028  * declares the entry points for usage in C code. There is an ASM variant
0029  * as well which is used to emit the entry stubs in entry_32/64.S.
0030  */
0031 #define DECLARE_IDTENTRY(vector, func)                  \
0032     asmlinkage void asm_##func(void);               \
0033     asmlinkage void xen_asm_##func(void);               \
0034     __visible void func(struct pt_regs *regs)
0035 
0036 /**
0037  * DEFINE_IDTENTRY - Emit code for simple IDT entry points
0038  * @func:   Function name of the entry point
0039  *
0040  * @func is called from ASM entry code with interrupts disabled.
0041  *
0042  * The macro is written so it acts as function definition. Append the
0043  * body with a pair of curly brackets.
0044  *
0045  * irqentry_enter() contains common code which has to be invoked before
0046  * arbitrary code in the body. irqentry_exit() contains common code
0047  * which has to run before returning to the low level assembly code.
0048  */
0049 #define DEFINE_IDTENTRY(func)                       \
0050 static __always_inline void __##func(struct pt_regs *regs);     \
0051                                     \
0052 __visible noinstr void func(struct pt_regs *regs)           \
0053 {                                   \
0054     irqentry_state_t state = irqentry_enter(regs);          \
0055                                     \
0056     instrumentation_begin();                    \
0057     __##func (regs);                        \
0058     instrumentation_end();                      \
0059     irqentry_exit(regs, state);                 \
0060 }                                   \
0061                                     \
0062 static __always_inline void __##func(struct pt_regs *regs)
0063 
0064 /* Special case for 32bit IRET 'trap' */
0065 #define DECLARE_IDTENTRY_SW DECLARE_IDTENTRY
0066 #define DEFINE_IDTENTRY_SW  DEFINE_IDTENTRY
0067 
0068 /**
0069  * DECLARE_IDTENTRY_ERRORCODE - Declare functions for simple IDT entry points
0070  *              Error code pushed by hardware
0071  * @vector: Vector number (ignored for C)
0072  * @func:   Function name of the entry point
0073  *
0074  * Declares three functions:
0075  * - The ASM entry point: asm_##func
0076  * - The XEN PV trap entry point: xen_##func (maybe unused)
0077  * - The C handler called from the ASM entry point
0078  *
0079  * Same as DECLARE_IDTENTRY, but has an extra error_code argument for the
0080  * C-handler.
0081  */
0082 #define DECLARE_IDTENTRY_ERRORCODE(vector, func)            \
0083     asmlinkage void asm_##func(void);               \
0084     asmlinkage void xen_asm_##func(void);               \
0085     __visible void func(struct pt_regs *regs, unsigned long error_code)
0086 
0087 /**
0088  * DEFINE_IDTENTRY_ERRORCODE - Emit code for simple IDT entry points
0089  *                 Error code pushed by hardware
0090  * @func:   Function name of the entry point
0091  *
0092  * Same as DEFINE_IDTENTRY, but has an extra error_code argument
0093  */
0094 #define DEFINE_IDTENTRY_ERRORCODE(func)                 \
0095 static __always_inline void __##func(struct pt_regs *regs,      \
0096                      unsigned long error_code);     \
0097                                     \
0098 __visible noinstr void func(struct pt_regs *regs,           \
0099                 unsigned long error_code)           \
0100 {                                   \
0101     irqentry_state_t state = irqentry_enter(regs);          \
0102                                     \
0103     instrumentation_begin();                    \
0104     __##func (regs, error_code);                    \
0105     instrumentation_end();                      \
0106     irqentry_exit(regs, state);                 \
0107 }                                   \
0108                                     \
0109 static __always_inline void __##func(struct pt_regs *regs,      \
0110                      unsigned long error_code)
0111 
0112 /**
0113  * DECLARE_IDTENTRY_RAW - Declare functions for raw IDT entry points
0114  *            No error code pushed by hardware
0115  * @vector: Vector number (ignored for C)
0116  * @func:   Function name of the entry point
0117  *
0118  * Maps to DECLARE_IDTENTRY().
0119  */
0120 #define DECLARE_IDTENTRY_RAW(vector, func)              \
0121     DECLARE_IDTENTRY(vector, func)
0122 
0123 /**
0124  * DEFINE_IDTENTRY_RAW - Emit code for raw IDT entry points
0125  * @func:   Function name of the entry point
0126  *
0127  * @func is called from ASM entry code with interrupts disabled.
0128  *
0129  * The macro is written so it acts as function definition. Append the
0130  * body with a pair of curly brackets.
0131  *
0132  * Contrary to DEFINE_IDTENTRY() this does not invoke the
0133  * idtentry_enter/exit() helpers before and after the body invocation. This
0134  * needs to be done in the body itself if applicable. Use if extra work
0135  * is required before the enter/exit() helpers are invoked.
0136  */
0137 #define DEFINE_IDTENTRY_RAW(func)                   \
0138 __visible noinstr void func(struct pt_regs *regs)
0139 
0140 /**
0141  * DECLARE_IDTENTRY_RAW_ERRORCODE - Declare functions for raw IDT entry points
0142  *                  Error code pushed by hardware
0143  * @vector: Vector number (ignored for C)
0144  * @func:   Function name of the entry point
0145  *
0146  * Maps to DECLARE_IDTENTRY_ERRORCODE()
0147  */
0148 #define DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func)            \
0149     DECLARE_IDTENTRY_ERRORCODE(vector, func)
0150 
0151 /**
0152  * DEFINE_IDTENTRY_RAW_ERRORCODE - Emit code for raw IDT entry points
0153  * @func:   Function name of the entry point
0154  *
0155  * @func is called from ASM entry code with interrupts disabled.
0156  *
0157  * The macro is written so it acts as function definition. Append the
0158  * body with a pair of curly brackets.
0159  *
0160  * Contrary to DEFINE_IDTENTRY_ERRORCODE() this does not invoke the
0161  * irqentry_enter/exit() helpers before and after the body invocation. This
0162  * needs to be done in the body itself if applicable. Use if extra work
0163  * is required before the enter/exit() helpers are invoked.
0164  */
0165 #define DEFINE_IDTENTRY_RAW_ERRORCODE(func)             \
0166 __visible noinstr void func(struct pt_regs *regs, unsigned long error_code)
0167 
0168 /**
0169  * DECLARE_IDTENTRY_IRQ - Declare functions for device interrupt IDT entry
0170  *            points (common/spurious)
0171  * @vector: Vector number (ignored for C)
0172  * @func:   Function name of the entry point
0173  *
0174  * Maps to DECLARE_IDTENTRY_ERRORCODE()
0175  */
0176 #define DECLARE_IDTENTRY_IRQ(vector, func)              \
0177     DECLARE_IDTENTRY_ERRORCODE(vector, func)
0178 
0179 /**
0180  * DEFINE_IDTENTRY_IRQ - Emit code for device interrupt IDT entry points
0181  * @func:   Function name of the entry point
0182  *
0183  * The vector number is pushed by the low level entry stub and handed
0184  * to the function as error_code argument which needs to be truncated
0185  * to an u8 because the push is sign extending.
0186  *
0187  * irq_enter/exit_rcu() are invoked before the function body and the
0188  * KVM L1D flush request is set. Stack switching to the interrupt stack
0189  * has to be done in the function body if necessary.
0190  */
0191 #define DEFINE_IDTENTRY_IRQ(func)                   \
0192 static void __##func(struct pt_regs *regs, u32 vector);         \
0193                                     \
0194 __visible noinstr void func(struct pt_regs *regs,           \
0195                 unsigned long error_code)           \
0196 {                                   \
0197     irqentry_state_t state = irqentry_enter(regs);          \
0198     u32 vector = (u32)(u8)error_code;               \
0199                                     \
0200     instrumentation_begin();                    \
0201     kvm_set_cpu_l1tf_flush_l1d();                   \
0202     run_irq_on_irqstack_cond(__##func, regs, vector);       \
0203     instrumentation_end();                      \
0204     irqentry_exit(regs, state);                 \
0205 }                                   \
0206                                     \
0207 static noinline void __##func(struct pt_regs *regs, u32 vector)
0208 
0209 /**
0210  * DECLARE_IDTENTRY_SYSVEC - Declare functions for system vector entry points
0211  * @vector: Vector number (ignored for C)
0212  * @func:   Function name of the entry point
0213  *
0214  * Declares three functions:
0215  * - The ASM entry point: asm_##func
0216  * - The XEN PV trap entry point: xen_##func (maybe unused)
0217  * - The C handler called from the ASM entry point
0218  *
0219  * Maps to DECLARE_IDTENTRY().
0220  */
0221 #define DECLARE_IDTENTRY_SYSVEC(vector, func)               \
0222     DECLARE_IDTENTRY(vector, func)
0223 
0224 /**
0225  * DEFINE_IDTENTRY_SYSVEC - Emit code for system vector IDT entry points
0226  * @func:   Function name of the entry point
0227  *
0228  * irqentry_enter/exit() and irq_enter/exit_rcu() are invoked before the
0229  * function body. KVM L1D flush request is set.
0230  *
0231  * Runs the function on the interrupt stack if the entry hit kernel mode
0232  */
0233 #define DEFINE_IDTENTRY_SYSVEC(func)                    \
0234 static void __##func(struct pt_regs *regs);             \
0235                                     \
0236 __visible noinstr void func(struct pt_regs *regs)           \
0237 {                                   \
0238     irqentry_state_t state = irqentry_enter(regs);          \
0239                                     \
0240     instrumentation_begin();                    \
0241     kvm_set_cpu_l1tf_flush_l1d();                   \
0242     run_sysvec_on_irqstack_cond(__##func, regs);            \
0243     instrumentation_end();                      \
0244     irqentry_exit(regs, state);                 \
0245 }                                   \
0246                                     \
0247 static noinline void __##func(struct pt_regs *regs)
0248 
0249 /**
0250  * DEFINE_IDTENTRY_SYSVEC_SIMPLE - Emit code for simple system vector IDT
0251  *                 entry points
0252  * @func:   Function name of the entry point
0253  *
0254  * Runs the function on the interrupted stack. No switch to IRQ stack and
0255  * only the minimal __irq_enter/exit() handling.
0256  *
0257  * Only use for 'empty' vectors like reschedule IPI and KVM posted
0258  * interrupt vectors.
0259  */
0260 #define DEFINE_IDTENTRY_SYSVEC_SIMPLE(func)             \
0261 static __always_inline void __##func(struct pt_regs *regs);     \
0262                                     \
0263 __visible noinstr void func(struct pt_regs *regs)           \
0264 {                                   \
0265     irqentry_state_t state = irqentry_enter(regs);          \
0266                                     \
0267     instrumentation_begin();                    \
0268     __irq_enter_raw();                      \
0269     kvm_set_cpu_l1tf_flush_l1d();                   \
0270     __##func (regs);                        \
0271     __irq_exit_raw();                       \
0272     instrumentation_end();                      \
0273     irqentry_exit(regs, state);                 \
0274 }                                   \
0275                                     \
0276 static __always_inline void __##func(struct pt_regs *regs)
0277 
0278 /**
0279  * DECLARE_IDTENTRY_XENCB - Declare functions for XEN HV callback entry point
0280  * @vector: Vector number (ignored for C)
0281  * @func:   Function name of the entry point
0282  *
0283  * Declares three functions:
0284  * - The ASM entry point: asm_##func
0285  * - The XEN PV trap entry point: xen_##func (maybe unused)
0286  * - The C handler called from the ASM entry point
0287  *
0288  * Maps to DECLARE_IDTENTRY(). Distinct entry point to handle the 32/64-bit
0289  * difference
0290  */
0291 #define DECLARE_IDTENTRY_XENCB(vector, func)                \
0292     DECLARE_IDTENTRY(vector, func)
0293 
0294 #ifdef CONFIG_X86_64
0295 /**
0296  * DECLARE_IDTENTRY_IST - Declare functions for IST handling IDT entry points
0297  * @vector: Vector number (ignored for C)
0298  * @func:   Function name of the entry point
0299  *
0300  * Maps to DECLARE_IDTENTRY_RAW, but declares also the NOIST C handler
0301  * which is called from the ASM entry point on user mode entry
0302  */
0303 #define DECLARE_IDTENTRY_IST(vector, func)              \
0304     DECLARE_IDTENTRY_RAW(vector, func);             \
0305     __visible void noist_##func(struct pt_regs *regs)
0306 
0307 /**
0308  * DECLARE_IDTENTRY_VC - Declare functions for the VC entry point
0309  * @vector: Vector number (ignored for C)
0310  * @func:   Function name of the entry point
0311  *
0312  * Maps to DECLARE_IDTENTRY_RAW_ERRORCODE, but declares also the
0313  * safe_stack C handler.
0314  */
0315 #define DECLARE_IDTENTRY_VC(vector, func)               \
0316     DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func);           \
0317     __visible noinstr void kernel_##func(struct pt_regs *regs, unsigned long error_code);   \
0318     __visible noinstr void   user_##func(struct pt_regs *regs, unsigned long error_code)
0319 
0320 /**
0321  * DEFINE_IDTENTRY_IST - Emit code for IST entry points
0322  * @func:   Function name of the entry point
0323  *
0324  * Maps to DEFINE_IDTENTRY_RAW
0325  */
0326 #define DEFINE_IDTENTRY_IST(func)                   \
0327     DEFINE_IDTENTRY_RAW(func)
0328 
0329 /**
0330  * DEFINE_IDTENTRY_NOIST - Emit code for NOIST entry points which
0331  *             belong to a IST entry point (MCE, DB)
0332  * @func:   Function name of the entry point. Must be the same as
0333  *      the function name of the corresponding IST variant
0334  *
0335  * Maps to DEFINE_IDTENTRY_RAW().
0336  */
0337 #define DEFINE_IDTENTRY_NOIST(func)                 \
0338     DEFINE_IDTENTRY_RAW(noist_##func)
0339 
0340 /**
0341  * DECLARE_IDTENTRY_DF - Declare functions for double fault
0342  * @vector: Vector number (ignored for C)
0343  * @func:   Function name of the entry point
0344  *
0345  * Maps to DECLARE_IDTENTRY_RAW_ERRORCODE
0346  */
0347 #define DECLARE_IDTENTRY_DF(vector, func)               \
0348     DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func)
0349 
0350 /**
0351  * DEFINE_IDTENTRY_DF - Emit code for double fault
0352  * @func:   Function name of the entry point
0353  *
0354  * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
0355  */
0356 #define DEFINE_IDTENTRY_DF(func)                    \
0357     DEFINE_IDTENTRY_RAW_ERRORCODE(func)
0358 
0359 /**
0360  * DEFINE_IDTENTRY_VC_KERNEL - Emit code for VMM communication handler
0361                    when raised from kernel mode
0362  * @func:   Function name of the entry point
0363  *
0364  * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
0365  */
0366 #define DEFINE_IDTENTRY_VC_KERNEL(func)             \
0367     DEFINE_IDTENTRY_RAW_ERRORCODE(kernel_##func)
0368 
0369 /**
0370  * DEFINE_IDTENTRY_VC_USER - Emit code for VMM communication handler
0371                  when raised from user mode
0372  * @func:   Function name of the entry point
0373  *
0374  * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
0375  */
0376 #define DEFINE_IDTENTRY_VC_USER(func)               \
0377     DEFINE_IDTENTRY_RAW_ERRORCODE(user_##func)
0378 
0379 #else   /* CONFIG_X86_64 */
0380 
0381 /**
0382  * DECLARE_IDTENTRY_DF - Declare functions for double fault 32bit variant
0383  * @vector: Vector number (ignored for C)
0384  * @func:   Function name of the entry point
0385  *
0386  * Declares two functions:
0387  * - The ASM entry point: asm_##func
0388  * - The C handler called from the C shim
0389  */
0390 #define DECLARE_IDTENTRY_DF(vector, func)               \
0391     asmlinkage void asm_##func(void);               \
0392     __visible void func(struct pt_regs *regs,           \
0393                 unsigned long error_code,           \
0394                 unsigned long address)
0395 
0396 /**
0397  * DEFINE_IDTENTRY_DF - Emit code for double fault on 32bit
0398  * @func:   Function name of the entry point
0399  *
0400  * This is called through the doublefault shim which already provides
0401  * cr2 in the address argument.
0402  */
0403 #define DEFINE_IDTENTRY_DF(func)                    \
0404 __visible noinstr void func(struct pt_regs *regs,           \
0405                 unsigned long error_code,           \
0406                 unsigned long address)
0407 
0408 #endif  /* !CONFIG_X86_64 */
0409 
0410 /* C-Code mapping */
0411 #define DECLARE_IDTENTRY_NMI        DECLARE_IDTENTRY_RAW
0412 #define DEFINE_IDTENTRY_NMI     DEFINE_IDTENTRY_RAW
0413 
0414 #ifdef CONFIG_X86_64
0415 #define DECLARE_IDTENTRY_MCE        DECLARE_IDTENTRY_IST
0416 #define DEFINE_IDTENTRY_MCE     DEFINE_IDTENTRY_IST
0417 #define DEFINE_IDTENTRY_MCE_USER    DEFINE_IDTENTRY_NOIST
0418 
0419 #define DECLARE_IDTENTRY_DEBUG      DECLARE_IDTENTRY_IST
0420 #define DEFINE_IDTENTRY_DEBUG       DEFINE_IDTENTRY_IST
0421 #define DEFINE_IDTENTRY_DEBUG_USER  DEFINE_IDTENTRY_NOIST
0422 #endif
0423 
0424 #else /* !__ASSEMBLY__ */
0425 
0426 /*
0427  * The ASM variants for DECLARE_IDTENTRY*() which emit the ASM entry stubs.
0428  */
0429 #define DECLARE_IDTENTRY(vector, func)                  \
0430     idtentry vector asm_##func func has_error_code=0
0431 
0432 #define DECLARE_IDTENTRY_ERRORCODE(vector, func)            \
0433     idtentry vector asm_##func func has_error_code=1
0434 
0435 /* Special case for 32bit IRET 'trap'. Do not emit ASM code */
0436 #define DECLARE_IDTENTRY_SW(vector, func)
0437 
0438 #define DECLARE_IDTENTRY_RAW(vector, func)              \
0439     DECLARE_IDTENTRY(vector, func)
0440 
0441 #define DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func)            \
0442     DECLARE_IDTENTRY_ERRORCODE(vector, func)
0443 
0444 /* Entries for common/spurious (device) interrupts */
0445 #define DECLARE_IDTENTRY_IRQ(vector, func)              \
0446     idtentry_irq vector func
0447 
0448 /* System vector entries */
0449 #define DECLARE_IDTENTRY_SYSVEC(vector, func)               \
0450     idtentry_sysvec vector func
0451 
0452 #ifdef CONFIG_X86_64
0453 # define DECLARE_IDTENTRY_MCE(vector, func)             \
0454     idtentry_mce_db vector asm_##func func
0455 
0456 # define DECLARE_IDTENTRY_DEBUG(vector, func)               \
0457     idtentry_mce_db vector asm_##func func
0458 
0459 # define DECLARE_IDTENTRY_DF(vector, func)              \
0460     idtentry_df vector asm_##func func
0461 
0462 # define DECLARE_IDTENTRY_XENCB(vector, func)               \
0463     DECLARE_IDTENTRY(vector, func)
0464 
0465 # define DECLARE_IDTENTRY_VC(vector, func)              \
0466     idtentry_vc vector asm_##func func
0467 
0468 #else
0469 # define DECLARE_IDTENTRY_MCE(vector, func)             \
0470     DECLARE_IDTENTRY(vector, func)
0471 
0472 /* No ASM emitted for DF as this goes through a C shim */
0473 # define DECLARE_IDTENTRY_DF(vector, func)
0474 
0475 /* No ASM emitted for XEN hypervisor callback */
0476 # define DECLARE_IDTENTRY_XENCB(vector, func)
0477 
0478 #endif
0479 
0480 /* No ASM code emitted for NMI */
0481 #define DECLARE_IDTENTRY_NMI(vector, func)
0482 
0483 /*
0484  * ASM code to emit the common vector entry stubs where each stub is
0485  * packed into IDT_ALIGN bytes.
0486  *
0487  * Note, that the 'pushq imm8' is emitted via '.byte 0x6a, vector' because
0488  * GCC treats the local vector variable as unsigned int and would expand
0489  * all vectors above 0x7F to a 5 byte push. The original code did an
0490  * adjustment of the vector number to be in the signed byte range to avoid
0491  * this. While clever it's mindboggling counterintuitive and requires the
0492  * odd conversion back to a real vector number in the C entry points. Using
0493  * .byte achieves the same thing and the only fixup needed in the C entry
0494  * point is to mask off the bits above bit 7 because the push is sign
0495  * extending.
0496  */
0497     .align IDT_ALIGN
0498 SYM_CODE_START(irq_entries_start)
0499     vector=FIRST_EXTERNAL_VECTOR
0500     .rept NR_EXTERNAL_VECTORS
0501     UNWIND_HINT_IRET_REGS
0502 0 :
0503     ENDBR
0504     .byte   0x6a, vector
0505     jmp asm_common_interrupt
0506     /* Ensure that the above is IDT_ALIGN bytes max */
0507     .fill 0b + IDT_ALIGN - ., 1, 0xcc
0508     vector = vector+1
0509     .endr
0510 SYM_CODE_END(irq_entries_start)
0511 
0512 #ifdef CONFIG_X86_LOCAL_APIC
0513     .align IDT_ALIGN
0514 SYM_CODE_START(spurious_entries_start)
0515     vector=FIRST_SYSTEM_VECTOR
0516     .rept NR_SYSTEM_VECTORS
0517     UNWIND_HINT_IRET_REGS
0518 0 :
0519     ENDBR
0520     .byte   0x6a, vector
0521     jmp asm_spurious_interrupt
0522     /* Ensure that the above is IDT_ALIGN bytes max */
0523     .fill 0b + IDT_ALIGN - ., 1, 0xcc
0524     vector = vector+1
0525     .endr
0526 SYM_CODE_END(spurious_entries_start)
0527 #endif
0528 
0529 #endif /* __ASSEMBLY__ */
0530 
0531 /*
0532  * The actual entry points. Note that DECLARE_IDTENTRY*() serves two
0533  * purposes:
0534  *  - provide the function declarations when included from C-Code
0535  *  - emit the ASM stubs when included from entry_32/64.S
0536  *
0537  * This avoids duplicate defines and ensures that everything is consistent.
0538  */
0539 
0540 /*
0541  * Dummy trap number so the low level ASM macro vector number checks do not
0542  * match which results in emitting plain IDTENTRY stubs without bells and
0543  * whistles.
0544  */
0545 #define X86_TRAP_OTHER      0xFFFF
0546 
0547 /* Simple exception entry points. No hardware error code */
0548 DECLARE_IDTENTRY(X86_TRAP_DE,       exc_divide_error);
0549 DECLARE_IDTENTRY(X86_TRAP_OF,       exc_overflow);
0550 DECLARE_IDTENTRY(X86_TRAP_BR,       exc_bounds);
0551 DECLARE_IDTENTRY(X86_TRAP_NM,       exc_device_not_available);
0552 DECLARE_IDTENTRY(X86_TRAP_OLD_MF,   exc_coproc_segment_overrun);
0553 DECLARE_IDTENTRY(X86_TRAP_SPURIOUS, exc_spurious_interrupt_bug);
0554 DECLARE_IDTENTRY(X86_TRAP_MF,       exc_coprocessor_error);
0555 DECLARE_IDTENTRY(X86_TRAP_XF,       exc_simd_coprocessor_error);
0556 
0557 /* 32bit software IRET trap. Do not emit ASM code */
0558 DECLARE_IDTENTRY_SW(X86_TRAP_IRET,  iret_error);
0559 
0560 /* Simple exception entries with error code pushed by hardware */
0561 DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_TS, exc_invalid_tss);
0562 DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_NP, exc_segment_not_present);
0563 DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_SS, exc_stack_segment);
0564 DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_GP, exc_general_protection);
0565 DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_AC, exc_alignment_check);
0566 
0567 /* Raw exception entries which need extra work */
0568 DECLARE_IDTENTRY_RAW(X86_TRAP_UD,       exc_invalid_op);
0569 DECLARE_IDTENTRY_RAW(X86_TRAP_BP,       exc_int3);
0570 DECLARE_IDTENTRY_RAW_ERRORCODE(X86_TRAP_PF, exc_page_fault);
0571 
0572 #ifdef CONFIG_X86_MCE
0573 #ifdef CONFIG_X86_64
0574 DECLARE_IDTENTRY_MCE(X86_TRAP_MC,   exc_machine_check);
0575 #else
0576 DECLARE_IDTENTRY_RAW(X86_TRAP_MC,   exc_machine_check);
0577 #endif
0578 #ifdef CONFIG_XEN_PV
0579 DECLARE_IDTENTRY_RAW(X86_TRAP_MC,   xenpv_exc_machine_check);
0580 #endif
0581 #endif
0582 
0583 /* NMI */
0584 
0585 #if defined(CONFIG_X86_64) && IS_ENABLED(CONFIG_KVM_INTEL)
0586 /*
0587  * Special NOIST entry point for VMX which invokes this on the kernel
0588  * stack. asm_exc_nmi() requires an IST to work correctly vs. the NMI
0589  * 'executing' marker.
0590  *
0591  * On 32bit this just uses the regular NMI entry point because 32-bit does
0592  * not have ISTs.
0593  */
0594 DECLARE_IDTENTRY(X86_TRAP_NMI,      exc_nmi_noist);
0595 #else
0596 #define asm_exc_nmi_noist       asm_exc_nmi
0597 #endif
0598 
0599 DECLARE_IDTENTRY_NMI(X86_TRAP_NMI,  exc_nmi);
0600 #ifdef CONFIG_XEN_PV
0601 DECLARE_IDTENTRY_RAW(X86_TRAP_NMI,  xenpv_exc_nmi);
0602 #endif
0603 
0604 /* #DB */
0605 #ifdef CONFIG_X86_64
0606 DECLARE_IDTENTRY_DEBUG(X86_TRAP_DB, exc_debug);
0607 #else
0608 DECLARE_IDTENTRY_RAW(X86_TRAP_DB,   exc_debug);
0609 #endif
0610 #ifdef CONFIG_XEN_PV
0611 DECLARE_IDTENTRY_RAW(X86_TRAP_DB,   xenpv_exc_debug);
0612 #endif
0613 
0614 /* #DF */
0615 DECLARE_IDTENTRY_DF(X86_TRAP_DF,    exc_double_fault);
0616 #ifdef CONFIG_XEN_PV
0617 DECLARE_IDTENTRY_RAW_ERRORCODE(X86_TRAP_DF, xenpv_exc_double_fault);
0618 #endif
0619 
0620 /* #CP */
0621 #ifdef CONFIG_X86_KERNEL_IBT
0622 DECLARE_IDTENTRY_ERRORCODE(X86_TRAP_CP, exc_control_protection);
0623 #endif
0624 
0625 /* #VC */
0626 #ifdef CONFIG_AMD_MEM_ENCRYPT
0627 DECLARE_IDTENTRY_VC(X86_TRAP_VC,    exc_vmm_communication);
0628 #endif
0629 
0630 #ifdef CONFIG_XEN_PV
0631 DECLARE_IDTENTRY_XENCB(X86_TRAP_OTHER,  exc_xen_hypervisor_callback);
0632 DECLARE_IDTENTRY_RAW(X86_TRAP_OTHER,    exc_xen_unknown_trap);
0633 #endif
0634 
0635 #ifdef CONFIG_INTEL_TDX_GUEST
0636 DECLARE_IDTENTRY(X86_TRAP_VE,       exc_virtualization_exception);
0637 #endif
0638 
0639 /* Device interrupts common/spurious */
0640 DECLARE_IDTENTRY_IRQ(X86_TRAP_OTHER,    common_interrupt);
0641 #ifdef CONFIG_X86_LOCAL_APIC
0642 DECLARE_IDTENTRY_IRQ(X86_TRAP_OTHER,    spurious_interrupt);
0643 #endif
0644 
0645 /* System vector entry points */
0646 #ifdef CONFIG_X86_LOCAL_APIC
0647 DECLARE_IDTENTRY_SYSVEC(ERROR_APIC_VECTOR,      sysvec_error_interrupt);
0648 DECLARE_IDTENTRY_SYSVEC(SPURIOUS_APIC_VECTOR,       sysvec_spurious_apic_interrupt);
0649 DECLARE_IDTENTRY_SYSVEC(LOCAL_TIMER_VECTOR,     sysvec_apic_timer_interrupt);
0650 DECLARE_IDTENTRY_SYSVEC(X86_PLATFORM_IPI_VECTOR,    sysvec_x86_platform_ipi);
0651 #endif
0652 
0653 #ifdef CONFIG_SMP
0654 DECLARE_IDTENTRY(RESCHEDULE_VECTOR,         sysvec_reschedule_ipi);
0655 DECLARE_IDTENTRY_SYSVEC(IRQ_MOVE_CLEANUP_VECTOR,    sysvec_irq_move_cleanup);
0656 DECLARE_IDTENTRY_SYSVEC(REBOOT_VECTOR,          sysvec_reboot);
0657 DECLARE_IDTENTRY_SYSVEC(CALL_FUNCTION_SINGLE_VECTOR,    sysvec_call_function_single);
0658 DECLARE_IDTENTRY_SYSVEC(CALL_FUNCTION_VECTOR,       sysvec_call_function);
0659 #endif
0660 
0661 #ifdef CONFIG_X86_LOCAL_APIC
0662 # ifdef CONFIG_X86_MCE_THRESHOLD
0663 DECLARE_IDTENTRY_SYSVEC(THRESHOLD_APIC_VECTOR,      sysvec_threshold);
0664 # endif
0665 
0666 # ifdef CONFIG_X86_MCE_AMD
0667 DECLARE_IDTENTRY_SYSVEC(DEFERRED_ERROR_VECTOR,      sysvec_deferred_error);
0668 # endif
0669 
0670 # ifdef CONFIG_X86_THERMAL_VECTOR
0671 DECLARE_IDTENTRY_SYSVEC(THERMAL_APIC_VECTOR,        sysvec_thermal);
0672 # endif
0673 
0674 # ifdef CONFIG_IRQ_WORK
0675 DECLARE_IDTENTRY_SYSVEC(IRQ_WORK_VECTOR,        sysvec_irq_work);
0676 # endif
0677 #endif
0678 
0679 #ifdef CONFIG_HAVE_KVM
0680 DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_VECTOR,     sysvec_kvm_posted_intr_ipi);
0681 DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_WAKEUP_VECTOR,  sysvec_kvm_posted_intr_wakeup_ipi);
0682 DECLARE_IDTENTRY_SYSVEC(POSTED_INTR_NESTED_VECTOR,  sysvec_kvm_posted_intr_nested_ipi);
0683 #endif
0684 
0685 #if IS_ENABLED(CONFIG_HYPERV)
0686 DECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR, sysvec_hyperv_callback);
0687 DECLARE_IDTENTRY_SYSVEC(HYPERV_REENLIGHTENMENT_VECTOR,  sysvec_hyperv_reenlightenment);
0688 DECLARE_IDTENTRY_SYSVEC(HYPERV_STIMER0_VECTOR,  sysvec_hyperv_stimer0);
0689 #endif
0690 
0691 #if IS_ENABLED(CONFIG_ACRN_GUEST)
0692 DECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR, sysvec_acrn_hv_callback);
0693 #endif
0694 
0695 #ifdef CONFIG_XEN_PVHVM
0696 DECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR, sysvec_xen_hvm_callback);
0697 #endif
0698 
0699 #ifdef CONFIG_KVM_GUEST
0700 DECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR, sysvec_kvm_asyncpf_interrupt);
0701 #endif
0702 
0703 #undef X86_TRAP_OTHER
0704 
0705 #endif