18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_X86_IDTENTRY_H
38c2ecf20Sopenharmony_ci#define _ASM_X86_IDTENTRY_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/* Interrupts/Exceptions */
68c2ecf20Sopenharmony_ci#include <asm/trapnr.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
98c2ecf20Sopenharmony_ci#include <linux/entry-common.h>
108c2ecf20Sopenharmony_ci#include <linux/hardirq.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <asm/irq_stack.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/**
158c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY - Declare functions for simple IDT entry points
168c2ecf20Sopenharmony_ci *		      No error code pushed by hardware
178c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
188c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * Declares three functions:
218c2ecf20Sopenharmony_ci * - The ASM entry point: asm_##func
228c2ecf20Sopenharmony_ci * - The XEN PV trap entry point: xen_##func (maybe unused)
238c2ecf20Sopenharmony_ci * - The C handler called from the ASM entry point
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * Note: This is the C variant of DECLARE_IDTENTRY(). As the name says it
268c2ecf20Sopenharmony_ci * declares the entry points for usage in C code. There is an ASM variant
278c2ecf20Sopenharmony_ci * as well which is used to emit the entry stubs in entry_32/64.S.
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY(vector, func)					\
308c2ecf20Sopenharmony_ci	asmlinkage void asm_##func(void);				\
318c2ecf20Sopenharmony_ci	asmlinkage void xen_asm_##func(void);				\
328c2ecf20Sopenharmony_ci	__visible void func(struct pt_regs *regs)
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/**
358c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY - Emit code for simple IDT entry points
368c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
378c2ecf20Sopenharmony_ci *
388c2ecf20Sopenharmony_ci * @func is called from ASM entry code with interrupts disabled.
398c2ecf20Sopenharmony_ci *
408c2ecf20Sopenharmony_ci * The macro is written so it acts as function definition. Append the
418c2ecf20Sopenharmony_ci * body with a pair of curly brackets.
428c2ecf20Sopenharmony_ci *
438c2ecf20Sopenharmony_ci * irqentry_enter() contains common code which has to be invoked before
448c2ecf20Sopenharmony_ci * arbitrary code in the body. irqentry_exit() contains common code
458c2ecf20Sopenharmony_ci * which has to run before returning to the low level assembly code.
468c2ecf20Sopenharmony_ci */
478c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY(func)						\
488c2ecf20Sopenharmony_cistatic __always_inline void __##func(struct pt_regs *regs);		\
498c2ecf20Sopenharmony_ci									\
508c2ecf20Sopenharmony_ci__visible noinstr void func(struct pt_regs *regs)			\
518c2ecf20Sopenharmony_ci{									\
528c2ecf20Sopenharmony_ci	irqentry_state_t state = irqentry_enter(regs);			\
538c2ecf20Sopenharmony_ci									\
548c2ecf20Sopenharmony_ci	instrumentation_begin();					\
558c2ecf20Sopenharmony_ci	__##func (regs);						\
568c2ecf20Sopenharmony_ci	instrumentation_end();						\
578c2ecf20Sopenharmony_ci	irqentry_exit(regs, state);					\
588c2ecf20Sopenharmony_ci}									\
598c2ecf20Sopenharmony_ci									\
608c2ecf20Sopenharmony_cistatic __always_inline void __##func(struct pt_regs *regs)
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/* Special case for 32bit IRET 'trap' */
638c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_SW	DECLARE_IDTENTRY
648c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_SW	DEFINE_IDTENTRY
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/**
678c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY_ERRORCODE - Declare functions for simple IDT entry points
688c2ecf20Sopenharmony_ci *				Error code pushed by hardware
698c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
708c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
718c2ecf20Sopenharmony_ci *
728c2ecf20Sopenharmony_ci * Declares three functions:
738c2ecf20Sopenharmony_ci * - The ASM entry point: asm_##func
748c2ecf20Sopenharmony_ci * - The XEN PV trap entry point: xen_##func (maybe unused)
758c2ecf20Sopenharmony_ci * - The C handler called from the ASM entry point
768c2ecf20Sopenharmony_ci *
778c2ecf20Sopenharmony_ci * Same as DECLARE_IDTENTRY, but has an extra error_code argument for the
788c2ecf20Sopenharmony_ci * C-handler.
798c2ecf20Sopenharmony_ci */
808c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_ERRORCODE(vector, func)			\
818c2ecf20Sopenharmony_ci	asmlinkage void asm_##func(void);				\
828c2ecf20Sopenharmony_ci	asmlinkage void xen_asm_##func(void);				\
838c2ecf20Sopenharmony_ci	__visible void func(struct pt_regs *regs, unsigned long error_code)
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci/**
868c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_ERRORCODE - Emit code for simple IDT entry points
878c2ecf20Sopenharmony_ci *			       Error code pushed by hardware
888c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
898c2ecf20Sopenharmony_ci *
908c2ecf20Sopenharmony_ci * Same as DEFINE_IDTENTRY, but has an extra error_code argument
918c2ecf20Sopenharmony_ci */
928c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_ERRORCODE(func)					\
938c2ecf20Sopenharmony_cistatic __always_inline void __##func(struct pt_regs *regs,		\
948c2ecf20Sopenharmony_ci				     unsigned long error_code);		\
958c2ecf20Sopenharmony_ci									\
968c2ecf20Sopenharmony_ci__visible noinstr void func(struct pt_regs *regs,			\
978c2ecf20Sopenharmony_ci			    unsigned long error_code)			\
988c2ecf20Sopenharmony_ci{									\
998c2ecf20Sopenharmony_ci	irqentry_state_t state = irqentry_enter(regs);			\
1008c2ecf20Sopenharmony_ci									\
1018c2ecf20Sopenharmony_ci	instrumentation_begin();					\
1028c2ecf20Sopenharmony_ci	__##func (regs, error_code);					\
1038c2ecf20Sopenharmony_ci	instrumentation_end();						\
1048c2ecf20Sopenharmony_ci	irqentry_exit(regs, state);					\
1058c2ecf20Sopenharmony_ci}									\
1068c2ecf20Sopenharmony_ci									\
1078c2ecf20Sopenharmony_cistatic __always_inline void __##func(struct pt_regs *regs,		\
1088c2ecf20Sopenharmony_ci				     unsigned long error_code)
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci/**
1118c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY_RAW - Declare functions for raw IDT entry points
1128c2ecf20Sopenharmony_ci *		      No error code pushed by hardware
1138c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
1148c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
1158c2ecf20Sopenharmony_ci *
1168c2ecf20Sopenharmony_ci * Maps to DECLARE_IDTENTRY().
1178c2ecf20Sopenharmony_ci */
1188c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_RAW(vector, func)				\
1198c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY(vector, func)
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/**
1228c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_RAW - Emit code for raw IDT entry points
1238c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
1248c2ecf20Sopenharmony_ci *
1258c2ecf20Sopenharmony_ci * @func is called from ASM entry code with interrupts disabled.
1268c2ecf20Sopenharmony_ci *
1278c2ecf20Sopenharmony_ci * The macro is written so it acts as function definition. Append the
1288c2ecf20Sopenharmony_ci * body with a pair of curly brackets.
1298c2ecf20Sopenharmony_ci *
1308c2ecf20Sopenharmony_ci * Contrary to DEFINE_IDTENTRY() this does not invoke the
1318c2ecf20Sopenharmony_ci * idtentry_enter/exit() helpers before and after the body invocation. This
1328c2ecf20Sopenharmony_ci * needs to be done in the body itself if applicable. Use if extra work
1338c2ecf20Sopenharmony_ci * is required before the enter/exit() helpers are invoked.
1348c2ecf20Sopenharmony_ci */
1358c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_RAW(func)					\
1368c2ecf20Sopenharmony_ci__visible noinstr void func(struct pt_regs *regs)
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci/**
1398c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY_RAW_ERRORCODE - Declare functions for raw IDT entry points
1408c2ecf20Sopenharmony_ci *				    Error code pushed by hardware
1418c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
1428c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
1438c2ecf20Sopenharmony_ci *
1448c2ecf20Sopenharmony_ci * Maps to DECLARE_IDTENTRY_ERRORCODE()
1458c2ecf20Sopenharmony_ci */
1468c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func)			\
1478c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY_ERRORCODE(vector, func)
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci/**
1508c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_RAW_ERRORCODE - Emit code for raw IDT entry points
1518c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
1528c2ecf20Sopenharmony_ci *
1538c2ecf20Sopenharmony_ci * @func is called from ASM entry code with interrupts disabled.
1548c2ecf20Sopenharmony_ci *
1558c2ecf20Sopenharmony_ci * The macro is written so it acts as function definition. Append the
1568c2ecf20Sopenharmony_ci * body with a pair of curly brackets.
1578c2ecf20Sopenharmony_ci *
1588c2ecf20Sopenharmony_ci * Contrary to DEFINE_IDTENTRY_ERRORCODE() this does not invoke the
1598c2ecf20Sopenharmony_ci * irqentry_enter/exit() helpers before and after the body invocation. This
1608c2ecf20Sopenharmony_ci * needs to be done in the body itself if applicable. Use if extra work
1618c2ecf20Sopenharmony_ci * is required before the enter/exit() helpers are invoked.
1628c2ecf20Sopenharmony_ci */
1638c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_RAW_ERRORCODE(func)				\
1648c2ecf20Sopenharmony_ci__visible noinstr void func(struct pt_regs *regs, unsigned long error_code)
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci/**
1678c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY_IRQ - Declare functions for device interrupt IDT entry
1688c2ecf20Sopenharmony_ci *			  points (common/spurious)
1698c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
1708c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
1718c2ecf20Sopenharmony_ci *
1728c2ecf20Sopenharmony_ci * Maps to DECLARE_IDTENTRY_ERRORCODE()
1738c2ecf20Sopenharmony_ci */
1748c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_IRQ(vector, func)				\
1758c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY_ERRORCODE(vector, func)
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci/**
1788c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_IRQ - Emit code for device interrupt IDT entry points
1798c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
1808c2ecf20Sopenharmony_ci *
1818c2ecf20Sopenharmony_ci * The vector number is pushed by the low level entry stub and handed
1828c2ecf20Sopenharmony_ci * to the function as error_code argument which needs to be truncated
1838c2ecf20Sopenharmony_ci * to an u8 because the push is sign extending.
1848c2ecf20Sopenharmony_ci *
1858c2ecf20Sopenharmony_ci * irq_enter/exit_rcu() are invoked before the function body and the
1868c2ecf20Sopenharmony_ci * KVM L1D flush request is set. Stack switching to the interrupt stack
1878c2ecf20Sopenharmony_ci * has to be done in the function body if necessary.
1888c2ecf20Sopenharmony_ci */
1898c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_IRQ(func)					\
1908c2ecf20Sopenharmony_cistatic __always_inline void __##func(struct pt_regs *regs, u8 vector);	\
1918c2ecf20Sopenharmony_ci									\
1928c2ecf20Sopenharmony_ci__visible noinstr void func(struct pt_regs *regs,			\
1938c2ecf20Sopenharmony_ci			    unsigned long error_code)			\
1948c2ecf20Sopenharmony_ci{									\
1958c2ecf20Sopenharmony_ci	irqentry_state_t state = irqentry_enter(regs);			\
1968c2ecf20Sopenharmony_ci									\
1978c2ecf20Sopenharmony_ci	instrumentation_begin();					\
1988c2ecf20Sopenharmony_ci	irq_enter_rcu();						\
1998c2ecf20Sopenharmony_ci	kvm_set_cpu_l1tf_flush_l1d();					\
2008c2ecf20Sopenharmony_ci	__##func (regs, (u8)error_code);				\
2018c2ecf20Sopenharmony_ci	irq_exit_rcu();							\
2028c2ecf20Sopenharmony_ci	instrumentation_end();						\
2038c2ecf20Sopenharmony_ci	irqentry_exit(regs, state);					\
2048c2ecf20Sopenharmony_ci}									\
2058c2ecf20Sopenharmony_ci									\
2068c2ecf20Sopenharmony_cistatic __always_inline void __##func(struct pt_regs *regs, u8 vector)
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci/**
2098c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY_SYSVEC - Declare functions for system vector entry points
2108c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
2118c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
2128c2ecf20Sopenharmony_ci *
2138c2ecf20Sopenharmony_ci * Declares three functions:
2148c2ecf20Sopenharmony_ci * - The ASM entry point: asm_##func
2158c2ecf20Sopenharmony_ci * - The XEN PV trap entry point: xen_##func (maybe unused)
2168c2ecf20Sopenharmony_ci * - The C handler called from the ASM entry point
2178c2ecf20Sopenharmony_ci *
2188c2ecf20Sopenharmony_ci * Maps to DECLARE_IDTENTRY().
2198c2ecf20Sopenharmony_ci */
2208c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_SYSVEC(vector, func)				\
2218c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY(vector, func)
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci/**
2248c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_SYSVEC - Emit code for system vector IDT entry points
2258c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
2268c2ecf20Sopenharmony_ci *
2278c2ecf20Sopenharmony_ci * irqentry_enter/exit() and irq_enter/exit_rcu() are invoked before the
2288c2ecf20Sopenharmony_ci * function body. KVM L1D flush request is set.
2298c2ecf20Sopenharmony_ci *
2308c2ecf20Sopenharmony_ci * Runs the function on the interrupt stack if the entry hit kernel mode
2318c2ecf20Sopenharmony_ci */
2328c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_SYSVEC(func)					\
2338c2ecf20Sopenharmony_cistatic void __##func(struct pt_regs *regs);				\
2348c2ecf20Sopenharmony_ci									\
2358c2ecf20Sopenharmony_ci__visible noinstr void func(struct pt_regs *regs)			\
2368c2ecf20Sopenharmony_ci{									\
2378c2ecf20Sopenharmony_ci	irqentry_state_t state = irqentry_enter(regs);			\
2388c2ecf20Sopenharmony_ci									\
2398c2ecf20Sopenharmony_ci	instrumentation_begin();					\
2408c2ecf20Sopenharmony_ci	irq_enter_rcu();						\
2418c2ecf20Sopenharmony_ci	kvm_set_cpu_l1tf_flush_l1d();					\
2428c2ecf20Sopenharmony_ci	run_sysvec_on_irqstack_cond(__##func, regs);			\
2438c2ecf20Sopenharmony_ci	irq_exit_rcu();							\
2448c2ecf20Sopenharmony_ci	instrumentation_end();						\
2458c2ecf20Sopenharmony_ci	irqentry_exit(regs, state);					\
2468c2ecf20Sopenharmony_ci}									\
2478c2ecf20Sopenharmony_ci									\
2488c2ecf20Sopenharmony_cistatic noinline void __##func(struct pt_regs *regs)
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci/**
2518c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_SYSVEC_SIMPLE - Emit code for simple system vector IDT
2528c2ecf20Sopenharmony_ci *				   entry points
2538c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
2548c2ecf20Sopenharmony_ci *
2558c2ecf20Sopenharmony_ci * Runs the function on the interrupted stack. No switch to IRQ stack and
2568c2ecf20Sopenharmony_ci * only the minimal __irq_enter/exit() handling.
2578c2ecf20Sopenharmony_ci *
2588c2ecf20Sopenharmony_ci * Only use for 'empty' vectors like reschedule IPI and KVM posted
2598c2ecf20Sopenharmony_ci * interrupt vectors.
2608c2ecf20Sopenharmony_ci */
2618c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_SYSVEC_SIMPLE(func)				\
2628c2ecf20Sopenharmony_cistatic __always_inline void __##func(struct pt_regs *regs);		\
2638c2ecf20Sopenharmony_ci									\
2648c2ecf20Sopenharmony_ci__visible noinstr void func(struct pt_regs *regs)			\
2658c2ecf20Sopenharmony_ci{									\
2668c2ecf20Sopenharmony_ci	irqentry_state_t state = irqentry_enter(regs);			\
2678c2ecf20Sopenharmony_ci									\
2688c2ecf20Sopenharmony_ci	instrumentation_begin();					\
2698c2ecf20Sopenharmony_ci	__irq_enter_raw();						\
2708c2ecf20Sopenharmony_ci	kvm_set_cpu_l1tf_flush_l1d();					\
2718c2ecf20Sopenharmony_ci	__##func (regs);						\
2728c2ecf20Sopenharmony_ci	__irq_exit_raw();						\
2738c2ecf20Sopenharmony_ci	instrumentation_end();						\
2748c2ecf20Sopenharmony_ci	irqentry_exit(regs, state);					\
2758c2ecf20Sopenharmony_ci}									\
2768c2ecf20Sopenharmony_ci									\
2778c2ecf20Sopenharmony_cistatic __always_inline void __##func(struct pt_regs *regs)
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci/**
2808c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY_XENCB - Declare functions for XEN HV callback entry point
2818c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
2828c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
2838c2ecf20Sopenharmony_ci *
2848c2ecf20Sopenharmony_ci * Declares three functions:
2858c2ecf20Sopenharmony_ci * - The ASM entry point: asm_##func
2868c2ecf20Sopenharmony_ci * - The XEN PV trap entry point: xen_##func (maybe unused)
2878c2ecf20Sopenharmony_ci * - The C handler called from the ASM entry point
2888c2ecf20Sopenharmony_ci *
2898c2ecf20Sopenharmony_ci * Maps to DECLARE_IDTENTRY(). Distinct entry point to handle the 32/64-bit
2908c2ecf20Sopenharmony_ci * difference
2918c2ecf20Sopenharmony_ci */
2928c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_XENCB(vector, func)				\
2938c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY(vector, func)
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_64
2968c2ecf20Sopenharmony_ci/**
2978c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY_IST - Declare functions for IST handling IDT entry points
2988c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
2998c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
3008c2ecf20Sopenharmony_ci *
3018c2ecf20Sopenharmony_ci * Maps to DECLARE_IDTENTRY_RAW, but declares also the NOIST C handler
3028c2ecf20Sopenharmony_ci * which is called from the ASM entry point on user mode entry
3038c2ecf20Sopenharmony_ci */
3048c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_IST(vector, func)				\
3058c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY_RAW(vector, func);				\
3068c2ecf20Sopenharmony_ci	__visible void noist_##func(struct pt_regs *regs)
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci/**
3098c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY_VC - Declare functions for the VC entry point
3108c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
3118c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
3128c2ecf20Sopenharmony_ci *
3138c2ecf20Sopenharmony_ci * Maps to DECLARE_IDTENTRY_RAW_ERRORCODE, but declares also the
3148c2ecf20Sopenharmony_ci * safe_stack C handler.
3158c2ecf20Sopenharmony_ci */
3168c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_VC(vector, func)				\
3178c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func);			\
3188c2ecf20Sopenharmony_ci	__visible noinstr void kernel_##func(struct pt_regs *regs, unsigned long error_code);	\
3198c2ecf20Sopenharmony_ci	__visible noinstr void   user_##func(struct pt_regs *regs, unsigned long error_code)
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ci/**
3228c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_IST - Emit code for IST entry points
3238c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
3248c2ecf20Sopenharmony_ci *
3258c2ecf20Sopenharmony_ci * Maps to DEFINE_IDTENTRY_RAW
3268c2ecf20Sopenharmony_ci */
3278c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_IST(func)					\
3288c2ecf20Sopenharmony_ci	DEFINE_IDTENTRY_RAW(func)
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci/**
3318c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_NOIST - Emit code for NOIST entry points which
3328c2ecf20Sopenharmony_ci *			   belong to a IST entry point (MCE, DB)
3338c2ecf20Sopenharmony_ci * @func:	Function name of the entry point. Must be the same as
3348c2ecf20Sopenharmony_ci *		the function name of the corresponding IST variant
3358c2ecf20Sopenharmony_ci *
3368c2ecf20Sopenharmony_ci * Maps to DEFINE_IDTENTRY_RAW().
3378c2ecf20Sopenharmony_ci */
3388c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_NOIST(func)					\
3398c2ecf20Sopenharmony_ci	DEFINE_IDTENTRY_RAW(noist_##func)
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci/**
3428c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY_DF - Declare functions for double fault
3438c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
3448c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
3458c2ecf20Sopenharmony_ci *
3468c2ecf20Sopenharmony_ci * Maps to DECLARE_IDTENTRY_RAW_ERRORCODE
3478c2ecf20Sopenharmony_ci */
3488c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_DF(vector, func)				\
3498c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func)
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci/**
3528c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_DF - Emit code for double fault
3538c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
3548c2ecf20Sopenharmony_ci *
3558c2ecf20Sopenharmony_ci * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
3568c2ecf20Sopenharmony_ci */
3578c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_DF(func)					\
3588c2ecf20Sopenharmony_ci	DEFINE_IDTENTRY_RAW_ERRORCODE(func)
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci/**
3618c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_VC_KERNEL - Emit code for VMM communication handler
3628c2ecf20Sopenharmony_ci			       when raised from kernel mode
3638c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
3648c2ecf20Sopenharmony_ci *
3658c2ecf20Sopenharmony_ci * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
3668c2ecf20Sopenharmony_ci */
3678c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_VC_KERNEL(func)				\
3688c2ecf20Sopenharmony_ci	DEFINE_IDTENTRY_RAW_ERRORCODE(kernel_##func)
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci/**
3718c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_VC_USER - Emit code for VMM communication handler
3728c2ecf20Sopenharmony_ci			     when raised from user mode
3738c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
3748c2ecf20Sopenharmony_ci *
3758c2ecf20Sopenharmony_ci * Maps to DEFINE_IDTENTRY_RAW_ERRORCODE
3768c2ecf20Sopenharmony_ci */
3778c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_VC_USER(func)				\
3788c2ecf20Sopenharmony_ci	DEFINE_IDTENTRY_RAW_ERRORCODE(user_##func)
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_ci#else	/* CONFIG_X86_64 */
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci/**
3838c2ecf20Sopenharmony_ci * DECLARE_IDTENTRY_DF - Declare functions for double fault 32bit variant
3848c2ecf20Sopenharmony_ci * @vector:	Vector number (ignored for C)
3858c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
3868c2ecf20Sopenharmony_ci *
3878c2ecf20Sopenharmony_ci * Declares two functions:
3888c2ecf20Sopenharmony_ci * - The ASM entry point: asm_##func
3898c2ecf20Sopenharmony_ci * - The C handler called from the C shim
3908c2ecf20Sopenharmony_ci */
3918c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_DF(vector, func)				\
3928c2ecf20Sopenharmony_ci	asmlinkage void asm_##func(void);				\
3938c2ecf20Sopenharmony_ci	__visible void func(struct pt_regs *regs,			\
3948c2ecf20Sopenharmony_ci			    unsigned long error_code,			\
3958c2ecf20Sopenharmony_ci			    unsigned long address)
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci/**
3988c2ecf20Sopenharmony_ci * DEFINE_IDTENTRY_DF - Emit code for double fault on 32bit
3998c2ecf20Sopenharmony_ci * @func:	Function name of the entry point
4008c2ecf20Sopenharmony_ci *
4018c2ecf20Sopenharmony_ci * This is called through the doublefault shim which already provides
4028c2ecf20Sopenharmony_ci * cr2 in the address argument.
4038c2ecf20Sopenharmony_ci */
4048c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_DF(func)					\
4058c2ecf20Sopenharmony_ci__visible noinstr void func(struct pt_regs *regs,			\
4068c2ecf20Sopenharmony_ci			    unsigned long error_code,			\
4078c2ecf20Sopenharmony_ci			    unsigned long address)
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci#endif	/* !CONFIG_X86_64 */
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_ci/* C-Code mapping */
4128c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_NMI		DECLARE_IDTENTRY_RAW
4138c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_NMI		DEFINE_IDTENTRY_RAW
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_64
4168c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_MCE		DECLARE_IDTENTRY_IST
4178c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_MCE		DEFINE_IDTENTRY_IST
4188c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_MCE_USER	DEFINE_IDTENTRY_NOIST
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_DEBUG		DECLARE_IDTENTRY_IST
4218c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_DEBUG		DEFINE_IDTENTRY_IST
4228c2ecf20Sopenharmony_ci#define DEFINE_IDTENTRY_DEBUG_USER	DEFINE_IDTENTRY_NOIST
4238c2ecf20Sopenharmony_ci#endif
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ci#else /* !__ASSEMBLY__ */
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci/*
4288c2ecf20Sopenharmony_ci * The ASM variants for DECLARE_IDTENTRY*() which emit the ASM entry stubs.
4298c2ecf20Sopenharmony_ci */
4308c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY(vector, func)					\
4318c2ecf20Sopenharmony_ci	idtentry vector asm_##func func has_error_code=0
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_ERRORCODE(vector, func)			\
4348c2ecf20Sopenharmony_ci	idtentry vector asm_##func func has_error_code=1
4358c2ecf20Sopenharmony_ci
4368c2ecf20Sopenharmony_ci/* Special case for 32bit IRET 'trap'. Do not emit ASM code */
4378c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_SW(vector, func)
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_RAW(vector, func)				\
4408c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY(vector, func)
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_RAW_ERRORCODE(vector, func)			\
4438c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY_ERRORCODE(vector, func)
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ci/* Entries for common/spurious (device) interrupts */
4468c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_IRQ(vector, func)				\
4478c2ecf20Sopenharmony_ci	idtentry_irq vector func
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci/* System vector entries */
4508c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_SYSVEC(vector, func)				\
4518c2ecf20Sopenharmony_ci	idtentry_sysvec vector func
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_64
4548c2ecf20Sopenharmony_ci# define DECLARE_IDTENTRY_MCE(vector, func)				\
4558c2ecf20Sopenharmony_ci	idtentry_mce_db vector asm_##func func
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_ci# define DECLARE_IDTENTRY_DEBUG(vector, func)				\
4588c2ecf20Sopenharmony_ci	idtentry_mce_db vector asm_##func func
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci# define DECLARE_IDTENTRY_DF(vector, func)				\
4618c2ecf20Sopenharmony_ci	idtentry_df vector asm_##func func
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_ci# define DECLARE_IDTENTRY_XENCB(vector, func)				\
4648c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY(vector, func)
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_ci# define DECLARE_IDTENTRY_VC(vector, func)				\
4678c2ecf20Sopenharmony_ci	idtentry_vc vector asm_##func func
4688c2ecf20Sopenharmony_ci
4698c2ecf20Sopenharmony_ci#else
4708c2ecf20Sopenharmony_ci# define DECLARE_IDTENTRY_MCE(vector, func)				\
4718c2ecf20Sopenharmony_ci	DECLARE_IDTENTRY(vector, func)
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci/* No ASM emitted for DF as this goes through a C shim */
4748c2ecf20Sopenharmony_ci# define DECLARE_IDTENTRY_DF(vector, func)
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci/* No ASM emitted for XEN hypervisor callback */
4778c2ecf20Sopenharmony_ci# define DECLARE_IDTENTRY_XENCB(vector, func)
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ci#endif
4808c2ecf20Sopenharmony_ci
4818c2ecf20Sopenharmony_ci/* No ASM code emitted for NMI */
4828c2ecf20Sopenharmony_ci#define DECLARE_IDTENTRY_NMI(vector, func)
4838c2ecf20Sopenharmony_ci
4848c2ecf20Sopenharmony_ci/*
4858c2ecf20Sopenharmony_ci * ASM code to emit the common vector entry stubs where each stub is
4868c2ecf20Sopenharmony_ci * packed into 8 bytes.
4878c2ecf20Sopenharmony_ci *
4888c2ecf20Sopenharmony_ci * Note, that the 'pushq imm8' is emitted via '.byte 0x6a, vector' because
4898c2ecf20Sopenharmony_ci * GCC treats the local vector variable as unsigned int and would expand
4908c2ecf20Sopenharmony_ci * all vectors above 0x7F to a 5 byte push. The original code did an
4918c2ecf20Sopenharmony_ci * adjustment of the vector number to be in the signed byte range to avoid
4928c2ecf20Sopenharmony_ci * this. While clever it's mindboggling counterintuitive and requires the
4938c2ecf20Sopenharmony_ci * odd conversion back to a real vector number in the C entry points. Using
4948c2ecf20Sopenharmony_ci * .byte achieves the same thing and the only fixup needed in the C entry
4958c2ecf20Sopenharmony_ci * point is to mask off the bits above bit 7 because the push is sign
4968c2ecf20Sopenharmony_ci * extending.
4978c2ecf20Sopenharmony_ci */
4988c2ecf20Sopenharmony_ci	.align 8
4998c2ecf20Sopenharmony_ciSYM_CODE_START(irq_entries_start)
5008c2ecf20Sopenharmony_ci    vector=FIRST_EXTERNAL_VECTOR
5018c2ecf20Sopenharmony_ci    .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
5028c2ecf20Sopenharmony_ci	UNWIND_HINT_IRET_REGS
5038c2ecf20Sopenharmony_ci0 :
5048c2ecf20Sopenharmony_ci	.byte	0x6a, vector
5058c2ecf20Sopenharmony_ci	jmp	asm_common_interrupt
5068c2ecf20Sopenharmony_ci	nop
5078c2ecf20Sopenharmony_ci	/* Ensure that the above is 8 bytes max */
5088c2ecf20Sopenharmony_ci	. = 0b + 8
5098c2ecf20Sopenharmony_ci	vector = vector+1
5108c2ecf20Sopenharmony_ci    .endr
5118c2ecf20Sopenharmony_ciSYM_CODE_END(irq_entries_start)
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_LOCAL_APIC
5148c2ecf20Sopenharmony_ci	.align 8
5158c2ecf20Sopenharmony_ciSYM_CODE_START(spurious_entries_start)
5168c2ecf20Sopenharmony_ci    vector=FIRST_SYSTEM_VECTOR
5178c2ecf20Sopenharmony_ci    .rept (NR_VECTORS - FIRST_SYSTEM_VECTOR)
5188c2ecf20Sopenharmony_ci	UNWIND_HINT_IRET_REGS
5198c2ecf20Sopenharmony_ci0 :
5208c2ecf20Sopenharmony_ci	.byte	0x6a, vector
5218c2ecf20Sopenharmony_ci	jmp	asm_spurious_interrupt
5228c2ecf20Sopenharmony_ci	nop
5238c2ecf20Sopenharmony_ci	/* Ensure that the above is 8 bytes max */
5248c2ecf20Sopenharmony_ci	. = 0b + 8
5258c2ecf20Sopenharmony_ci	vector = vector+1
5268c2ecf20Sopenharmony_ci    .endr
5278c2ecf20Sopenharmony_ciSYM_CODE_END(spurious_entries_start)
5288c2ecf20Sopenharmony_ci#endif
5298c2ecf20Sopenharmony_ci
5308c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
5318c2ecf20Sopenharmony_ci
5328c2ecf20Sopenharmony_ci/*
5338c2ecf20Sopenharmony_ci * The actual entry points. Note that DECLARE_IDTENTRY*() serves two
5348c2ecf20Sopenharmony_ci * purposes:
5358c2ecf20Sopenharmony_ci *  - provide the function declarations when included from C-Code
5368c2ecf20Sopenharmony_ci *  - emit the ASM stubs when included from entry_32/64.S
5378c2ecf20Sopenharmony_ci *
5388c2ecf20Sopenharmony_ci * This avoids duplicate defines and ensures that everything is consistent.
5398c2ecf20Sopenharmony_ci */
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci/*
5428c2ecf20Sopenharmony_ci * Dummy trap number so the low level ASM macro vector number checks do not
5438c2ecf20Sopenharmony_ci * match which results in emitting plain IDTENTRY stubs without bells and
5448c2ecf20Sopenharmony_ci * whistels.
5458c2ecf20Sopenharmony_ci */
5468c2ecf20Sopenharmony_ci#define X86_TRAP_OTHER		0xFFFF
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci/* Simple exception entry points. No hardware error code */
5498c2ecf20Sopenharmony_ciDECLARE_IDTENTRY(X86_TRAP_DE,		exc_divide_error);
5508c2ecf20Sopenharmony_ciDECLARE_IDTENTRY(X86_TRAP_OF,		exc_overflow);
5518c2ecf20Sopenharmony_ciDECLARE_IDTENTRY(X86_TRAP_BR,		exc_bounds);
5528c2ecf20Sopenharmony_ciDECLARE_IDTENTRY(X86_TRAP_NM,		exc_device_not_available);
5538c2ecf20Sopenharmony_ciDECLARE_IDTENTRY(X86_TRAP_OLD_MF,	exc_coproc_segment_overrun);
5548c2ecf20Sopenharmony_ciDECLARE_IDTENTRY(X86_TRAP_SPURIOUS,	exc_spurious_interrupt_bug);
5558c2ecf20Sopenharmony_ciDECLARE_IDTENTRY(X86_TRAP_MF,		exc_coprocessor_error);
5568c2ecf20Sopenharmony_ciDECLARE_IDTENTRY(X86_TRAP_XF,		exc_simd_coprocessor_error);
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ci/* 32bit software IRET trap. Do not emit ASM code */
5598c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SW(X86_TRAP_IRET,	iret_error);
5608c2ecf20Sopenharmony_ci
5618c2ecf20Sopenharmony_ci/* Simple exception entries with error code pushed by hardware */
5628c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_ERRORCODE(X86_TRAP_TS,	exc_invalid_tss);
5638c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_ERRORCODE(X86_TRAP_NP,	exc_segment_not_present);
5648c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_ERRORCODE(X86_TRAP_SS,	exc_stack_segment);
5658c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_ERRORCODE(X86_TRAP_GP,	exc_general_protection);
5668c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_ERRORCODE(X86_TRAP_AC,	exc_alignment_check);
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci/* Raw exception entries which need extra work */
5698c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_RAW(X86_TRAP_UD,		exc_invalid_op);
5708c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_RAW(X86_TRAP_BP,		exc_int3);
5718c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_RAW_ERRORCODE(X86_TRAP_PF,	exc_page_fault);
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_MCE
5748c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_64
5758c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_MCE(X86_TRAP_MC,	exc_machine_check);
5768c2ecf20Sopenharmony_ci#else
5778c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_RAW(X86_TRAP_MC,	exc_machine_check);
5788c2ecf20Sopenharmony_ci#endif
5798c2ecf20Sopenharmony_ci#endif
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_ci/* NMI */
5828c2ecf20Sopenharmony_ci
5838c2ecf20Sopenharmony_ci#if defined(CONFIG_X86_64) && IS_ENABLED(CONFIG_KVM_INTEL)
5848c2ecf20Sopenharmony_ci/*
5858c2ecf20Sopenharmony_ci * Special NOIST entry point for VMX which invokes this on the kernel
5868c2ecf20Sopenharmony_ci * stack. asm_exc_nmi() requires an IST to work correctly vs. the NMI
5878c2ecf20Sopenharmony_ci * 'executing' marker.
5888c2ecf20Sopenharmony_ci *
5898c2ecf20Sopenharmony_ci * On 32bit this just uses the regular NMI entry point because 32-bit does
5908c2ecf20Sopenharmony_ci * not have ISTs.
5918c2ecf20Sopenharmony_ci */
5928c2ecf20Sopenharmony_ciDECLARE_IDTENTRY(X86_TRAP_NMI,		exc_nmi_noist);
5938c2ecf20Sopenharmony_ci#else
5948c2ecf20Sopenharmony_ci#define asm_exc_nmi_noist		asm_exc_nmi
5958c2ecf20Sopenharmony_ci#endif
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_NMI(X86_TRAP_NMI,	exc_nmi);
5988c2ecf20Sopenharmony_ci#ifdef CONFIG_XEN_PV
5998c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_RAW(X86_TRAP_NMI,	xenpv_exc_nmi);
6008c2ecf20Sopenharmony_ci#endif
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci/* #DB */
6038c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_64
6048c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_DEBUG(X86_TRAP_DB,	exc_debug);
6058c2ecf20Sopenharmony_ci#else
6068c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_RAW(X86_TRAP_DB,	exc_debug);
6078c2ecf20Sopenharmony_ci#endif
6088c2ecf20Sopenharmony_ci#ifdef CONFIG_XEN_PV
6098c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_RAW(X86_TRAP_DB,	xenpv_exc_debug);
6108c2ecf20Sopenharmony_ci#endif
6118c2ecf20Sopenharmony_ci
6128c2ecf20Sopenharmony_ci/* #DF */
6138c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_DF(X86_TRAP_DF,	exc_double_fault);
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ci/* #VC */
6168c2ecf20Sopenharmony_ci#ifdef CONFIG_AMD_MEM_ENCRYPT
6178c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_VC(X86_TRAP_VC,	exc_vmm_communication);
6188c2ecf20Sopenharmony_ci#endif
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_ci#ifdef CONFIG_XEN_PV
6218c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_XENCB(X86_TRAP_OTHER,	exc_xen_hypervisor_callback);
6228c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_RAW(X86_TRAP_OTHER,	exc_xen_unknown_trap);
6238c2ecf20Sopenharmony_ci#endif
6248c2ecf20Sopenharmony_ci
6258c2ecf20Sopenharmony_ci/* Device interrupts common/spurious */
6268c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_IRQ(X86_TRAP_OTHER,	common_interrupt);
6278c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_LOCAL_APIC
6288c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_IRQ(X86_TRAP_OTHER,	spurious_interrupt);
6298c2ecf20Sopenharmony_ci#endif
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_ci/* System vector entry points */
6328c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_LOCAL_APIC
6338c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(ERROR_APIC_VECTOR,		sysvec_error_interrupt);
6348c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(SPURIOUS_APIC_VECTOR,		sysvec_spurious_apic_interrupt);
6358c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(LOCAL_TIMER_VECTOR,		sysvec_apic_timer_interrupt);
6368c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(X86_PLATFORM_IPI_VECTOR,	sysvec_x86_platform_ipi);
6378c2ecf20Sopenharmony_ci#endif
6388c2ecf20Sopenharmony_ci
6398c2ecf20Sopenharmony_ci#ifdef CONFIG_SMP
6408c2ecf20Sopenharmony_ciDECLARE_IDTENTRY(RESCHEDULE_VECTOR,			sysvec_reschedule_ipi);
6418c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(IRQ_MOVE_CLEANUP_VECTOR,	sysvec_irq_move_cleanup);
6428c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(REBOOT_VECTOR,			sysvec_reboot);
6438c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(CALL_FUNCTION_SINGLE_VECTOR,	sysvec_call_function_single);
6448c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(CALL_FUNCTION_VECTOR,		sysvec_call_function);
6458c2ecf20Sopenharmony_ci#endif
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_LOCAL_APIC
6488c2ecf20Sopenharmony_ci# ifdef CONFIG_X86_MCE_THRESHOLD
6498c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(THRESHOLD_APIC_VECTOR,		sysvec_threshold);
6508c2ecf20Sopenharmony_ci# endif
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_ci# ifdef CONFIG_X86_MCE_AMD
6538c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(DEFERRED_ERROR_VECTOR,		sysvec_deferred_error);
6548c2ecf20Sopenharmony_ci# endif
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_ci# ifdef CONFIG_X86_THERMAL_VECTOR
6578c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(THERMAL_APIC_VECTOR,		sysvec_thermal);
6588c2ecf20Sopenharmony_ci# endif
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_ci# ifdef CONFIG_IRQ_WORK
6618c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(IRQ_WORK_VECTOR,		sysvec_irq_work);
6628c2ecf20Sopenharmony_ci# endif
6638c2ecf20Sopenharmony_ci#endif
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_ci#ifdef CONFIG_HAVE_KVM
6668c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(POSTED_INTR_VECTOR,		sysvec_kvm_posted_intr_ipi);
6678c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(POSTED_INTR_WAKEUP_VECTOR,	sysvec_kvm_posted_intr_wakeup_ipi);
6688c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(POSTED_INTR_NESTED_VECTOR,	sysvec_kvm_posted_intr_nested_ipi);
6698c2ecf20Sopenharmony_ci#endif
6708c2ecf20Sopenharmony_ci
6718c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_HYPERV)
6728c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR,	sysvec_hyperv_callback);
6738c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(HYPERV_REENLIGHTENMENT_VECTOR,	sysvec_hyperv_reenlightenment);
6748c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(HYPERV_STIMER0_VECTOR,	sysvec_hyperv_stimer0);
6758c2ecf20Sopenharmony_ci#endif
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_ACRN_GUEST)
6788c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR,	sysvec_acrn_hv_callback);
6798c2ecf20Sopenharmony_ci#endif
6808c2ecf20Sopenharmony_ci
6818c2ecf20Sopenharmony_ci#ifdef CONFIG_XEN_PVHVM
6828c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR,	sysvec_xen_hvm_callback);
6838c2ecf20Sopenharmony_ci#endif
6848c2ecf20Sopenharmony_ci
6858c2ecf20Sopenharmony_ci#ifdef CONFIG_KVM_GUEST
6868c2ecf20Sopenharmony_ciDECLARE_IDTENTRY_SYSVEC(HYPERVISOR_CALLBACK_VECTOR,	sysvec_kvm_asyncpf_interrupt);
6878c2ecf20Sopenharmony_ci#endif
6888c2ecf20Sopenharmony_ci
6898c2ecf20Sopenharmony_ci#undef X86_TRAP_OTHER
6908c2ecf20Sopenharmony_ci
6918c2ecf20Sopenharmony_ci#endif
692