12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007 |
- #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
- #include <linux/context_tracking.h>
- #include <linux/interrupt.h>
- #include <linux/kallsyms.h>
- #include <linux/spinlock.h>
- #include <linux/kprobes.h>
- #include <linux/uaccess.h>
- #include <linux/kdebug.h>
- #include <linux/kgdb.h>
- #include <linux/kernel.h>
- #include <linux/export.h>
- #include <linux/ptrace.h>
- #include <linux/uprobes.h>
- #include <linux/string.h>
- #include <linux/delay.h>
- #include <linux/errno.h>
- #include <linux/kexec.h>
- #include <linux/sched.h>
- #include <linux/timer.h>
- #include <linux/init.h>
- #include <linux/bug.h>
- #include <linux/nmi.h>
- #include <linux/mm.h>
- #include <linux/smp.h>
- #include <linux/io.h>
- #ifdef CONFIG_EISA
- #include <linux/ioport.h>
- #include <linux/eisa.h>
- #endif
- #if defined(CONFIG_EDAC)
- #include <linux/edac.h>
- #endif
- #include <asm/kmemcheck.h>
- #include <asm/stacktrace.h>
- #include <asm/processor.h>
- #include <asm/debugreg.h>
- #include <linux/atomic.h>
- #include <asm/text-patching.h>
- #include <asm/ftrace.h>
- #include <asm/traps.h>
- #include <asm/desc.h>
- #include <asm/fpu/internal.h>
- #include <asm/mce.h>
- #include <asm/fixmap.h>
- #include <asm/mach_traps.h>
- #include <asm/alternative.h>
- #include <asm/fpu/xstate.h>
- #include <asm/trace/mpx.h>
- #include <asm/mpx.h>
- #include <asm/vm86.h>
- #ifdef CONFIG_X86_64
- #include <asm/x86_init.h>
- #include <asm/pgalloc.h>
- #include <asm/proto.h>
- gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
- #else
- #include <asm/processor-flags.h>
- #include <asm/setup.h>
- #include <asm/proto.h>
- #endif
- gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
- DECLARE_BITMAP(used_vectors, NR_VECTORS);
- EXPORT_SYMBOL_GPL(used_vectors);
- static inline void cond_local_irq_enable(struct pt_regs *regs)
- {
- if (regs->flags & X86_EFLAGS_IF)
- local_irq_enable();
- }
- static inline void cond_local_irq_disable(struct pt_regs *regs)
- {
- if (regs->flags & X86_EFLAGS_IF)
- local_irq_disable();
- }
- void ist_enter(struct pt_regs *regs)
- {
- if (user_mode(regs)) {
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
- } else {
-
- rcu_nmi_enter();
- }
- preempt_disable();
-
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "ist_enter didn't work");
- }
- void ist_exit(struct pt_regs *regs)
- {
- preempt_enable_no_resched();
- if (!user_mode(regs))
- rcu_nmi_exit();
- }
- void ist_begin_non_atomic(struct pt_regs *regs)
- {
- BUG_ON(!user_mode(regs));
-
- BUG_ON((unsigned long)(current_top_of_stack() -
- current_stack_pointer()) >= THREAD_SIZE);
- preempt_enable_no_resched();
- }
- void ist_end_non_atomic(void)
- {
- preempt_disable();
- }
- static nokprobe_inline int
- do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
- struct pt_regs *regs, long error_code)
- {
- if (v8086_mode(regs)) {
-
- if (trapnr < X86_TRAP_UD) {
- if (!handle_vm86_trap((struct kernel_vm86_regs *) regs,
- error_code, trapnr))
- return 0;
- }
- return -1;
- }
- if (!user_mode(regs)) {
- if (!fixup_exception(regs, trapnr)) {
- tsk->thread.error_code = error_code;
- tsk->thread.trap_nr = trapnr;
- die(str, regs, error_code);
- }
- return 0;
- }
- return -1;
- }
- static siginfo_t *fill_trap_info(struct pt_regs *regs, int signr, int trapnr,
- siginfo_t *info)
- {
- unsigned long siaddr;
- int sicode;
- switch (trapnr) {
- default:
- return SEND_SIG_PRIV;
- case X86_TRAP_DE:
- sicode = FPE_INTDIV;
- siaddr = uprobe_get_trap_addr(regs);
- break;
- case X86_TRAP_UD:
- sicode = ILL_ILLOPN;
- siaddr = uprobe_get_trap_addr(regs);
- break;
- case X86_TRAP_AC:
- sicode = BUS_ADRALN;
- siaddr = 0;
- break;
- }
- info->si_signo = signr;
- info->si_errno = 0;
- info->si_code = sicode;
- info->si_addr = (void __user *)siaddr;
- return info;
- }
- static void
- do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
- long error_code, siginfo_t *info)
- {
- struct task_struct *tsk = current;
- if (!do_trap_no_signal(tsk, trapnr, str, regs, error_code))
- return;
-
- tsk->thread.error_code = error_code;
- tsk->thread.trap_nr = trapnr;
- if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
- printk_ratelimit()) {
- pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
- tsk->comm, tsk->pid, str,
- regs->ip, regs->sp, error_code);
- print_vma_addr(" in ", regs->ip);
- pr_cont("\n");
- }
- force_sig_info(signr, info ?: SEND_SIG_PRIV, tsk);
- }
- NOKPROBE_SYMBOL(do_trap);
- static void do_error_trap(struct pt_regs *regs, long error_code, char *str,
- unsigned long trapnr, int signr)
- {
- siginfo_t info;
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
- if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) !=
- NOTIFY_STOP) {
- cond_local_irq_enable(regs);
- do_trap(trapnr, signr, str, regs, error_code,
- fill_trap_info(regs, signr, trapnr, &info));
- }
- }
- #define DO_ERROR(trapnr, signr, str, name) \
- dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
- { \
- do_error_trap(regs, error_code, str, trapnr, signr); \
- }
- DO_ERROR(X86_TRAP_DE, SIGFPE, "divide error", divide_error)
- DO_ERROR(X86_TRAP_OF, SIGSEGV, "overflow", overflow)
- DO_ERROR(X86_TRAP_UD, SIGILL, "invalid opcode", invalid_op)
- DO_ERROR(X86_TRAP_OLD_MF, SIGFPE, "coprocessor segment overrun",coprocessor_segment_overrun)
- DO_ERROR(X86_TRAP_TS, SIGSEGV, "invalid TSS", invalid_TSS)
- DO_ERROR(X86_TRAP_NP, SIGBUS, "segment not present", segment_not_present)
- DO_ERROR(X86_TRAP_SS, SIGBUS, "stack segment", stack_segment)
- DO_ERROR(X86_TRAP_AC, SIGBUS, "alignment check", alignment_check)
- #ifdef CONFIG_VMAP_STACK
- __visible void __noreturn handle_stack_overflow(const char *message,
- struct pt_regs *regs,
- unsigned long fault_address)
- {
- printk(KERN_EMERG "BUG: stack guard page was hit at %p (stack is %p..%p)\n",
- (void *)fault_address, current->stack,
- (char *)current->stack + THREAD_SIZE - 1);
- die(message, regs, 0);
-
- panic(message);
- }
- #endif
- #ifdef CONFIG_X86_64
- dotraplinkage void do_double_fault(struct pt_regs *regs, long error_code)
- {
- static const char str[] = "double fault";
- struct task_struct *tsk = current;
- #ifdef CONFIG_VMAP_STACK
- unsigned long cr2;
- #endif
- #ifdef CONFIG_X86_ESPFIX64
- extern unsigned char native_irq_return_iret[];
-
- if (((long)regs->sp >> PGDIR_SHIFT) == ESPFIX_PGD_ENTRY &&
- regs->cs == __KERNEL_CS &&
- regs->ip == (unsigned long)native_irq_return_iret)
- {
- struct pt_regs *normal_regs = task_pt_regs(current);
-
- memmove(&normal_regs->ip, (void *)regs->sp, 5*8);
- normal_regs->orig_ax = 0;
- regs->ip = (unsigned long)general_protection;
- regs->sp = (unsigned long)&normal_regs->orig_ax;
- return;
- }
- #endif
- ist_enter(regs);
- notify_die(DIE_TRAP, str, regs, error_code, X86_TRAP_DF, SIGSEGV);
- tsk->thread.error_code = error_code;
- tsk->thread.trap_nr = X86_TRAP_DF;
- #ifdef CONFIG_VMAP_STACK
-
- cr2 = read_cr2();
- if ((unsigned long)task_stack_page(tsk) - 1 - cr2 < PAGE_SIZE)
- handle_stack_overflow("kernel stack overflow (double-fault)", regs, cr2);
- #endif
- #ifdef CONFIG_DOUBLEFAULT
- df_debug(regs, error_code);
- #endif
-
- for (;;)
- die(str, regs, error_code);
- }
- #endif
- dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
- {
- const struct mpx_bndcsr *bndcsr;
- siginfo_t *info;
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
- if (notify_die(DIE_TRAP, "bounds", regs, error_code,
- X86_TRAP_BR, SIGSEGV) == NOTIFY_STOP)
- return;
- cond_local_irq_enable(regs);
- if (!user_mode(regs))
- die("bounds", regs, error_code);
- if (!cpu_feature_enabled(X86_FEATURE_MPX)) {
-
- goto exit_trap;
- }
-
- bndcsr = get_xsave_field_ptr(XFEATURE_MASK_BNDCSR);
- if (!bndcsr)
- goto exit_trap;
- trace_bounds_exception_mpx(bndcsr);
-
- switch (bndcsr->bndstatus & MPX_BNDSTA_ERROR_CODE) {
- case 2:
- if (mpx_handle_bd_fault())
- goto exit_trap;
- break;
- case 1:
- info = mpx_generate_siginfo(regs);
- if (IS_ERR(info)) {
-
- goto exit_trap;
- }
-
- do_trap(X86_TRAP_BR, SIGSEGV, "bounds", regs, error_code, info);
- kfree(info);
- break;
- case 0:
- goto exit_trap;
- default:
- die("bounds", regs, error_code);
- }
- return;
- exit_trap:
-
- do_trap(X86_TRAP_BR, SIGSEGV, "bounds", regs, error_code, NULL);
- }
- dotraplinkage void
- do_general_protection(struct pt_regs *regs, long error_code)
- {
- struct task_struct *tsk;
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
- cond_local_irq_enable(regs);
- if (v8086_mode(regs)) {
- local_irq_enable();
- handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
- return;
- }
- tsk = current;
- if (!user_mode(regs)) {
- if (fixup_exception(regs, X86_TRAP_GP))
- return;
- tsk->thread.error_code = error_code;
- tsk->thread.trap_nr = X86_TRAP_GP;
- if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
- X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
- die("general protection fault", regs, error_code);
- return;
- }
- tsk->thread.error_code = error_code;
- tsk->thread.trap_nr = X86_TRAP_GP;
- if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
- printk_ratelimit()) {
- pr_info("%s[%d] general protection ip:%lx sp:%lx error:%lx",
- tsk->comm, task_pid_nr(tsk),
- regs->ip, regs->sp, error_code);
- print_vma_addr(" in ", regs->ip);
- pr_cont("\n");
- }
- force_sig_info(SIGSEGV, SEND_SIG_PRIV, tsk);
- }
- NOKPROBE_SYMBOL(do_general_protection);
- dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
- {
- #ifdef CONFIG_DYNAMIC_FTRACE
-
- if (unlikely(atomic_read(&modifying_ftrace_code)) &&
- ftrace_int3_handler(regs))
- return;
- #endif
- if (poke_int3_handler(regs))
- return;
- ist_enter(regs);
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
- #ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
- if (kgdb_ll_trap(DIE_INT3, "int3", regs, error_code, X86_TRAP_BP,
- SIGTRAP) == NOTIFY_STOP)
- goto exit;
- #endif
- #ifdef CONFIG_KPROBES
- if (kprobe_int3_handler(regs))
- goto exit;
- #endif
- if (notify_die(DIE_INT3, "int3", regs, error_code, X86_TRAP_BP,
- SIGTRAP) == NOTIFY_STOP)
- goto exit;
-
- debug_stack_usage_inc();
- preempt_disable();
- cond_local_irq_enable(regs);
- do_trap(X86_TRAP_BP, SIGTRAP, "int3", regs, error_code, NULL);
- cond_local_irq_disable(regs);
- preempt_enable_no_resched();
- debug_stack_usage_dec();
- exit:
- ist_exit(regs);
- }
- NOKPROBE_SYMBOL(do_int3);
- #ifdef CONFIG_X86_64
- asmlinkage __visible notrace struct pt_regs *sync_regs(struct pt_regs *eregs)
- {
- struct pt_regs *regs = task_pt_regs(current);
- *regs = *eregs;
- return regs;
- }
- NOKPROBE_SYMBOL(sync_regs);
- struct bad_iret_stack {
- void *error_entry_ret;
- struct pt_regs regs;
- };
- asmlinkage __visible notrace
- struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s)
- {
-
- struct bad_iret_stack *new_stack =
- container_of(task_pt_regs(current),
- struct bad_iret_stack, regs);
-
- memmove(&new_stack->regs.ip, (void *)s->regs.sp, 5*8);
-
- memmove(new_stack, s, offsetof(struct bad_iret_stack, regs.ip));
- BUG_ON(!user_mode(&new_stack->regs));
- return new_stack;
- }
- NOKPROBE_SYMBOL(fixup_bad_iret);
- #endif
- static bool is_sysenter_singlestep(struct pt_regs *regs)
- {
-
- #ifdef CONFIG_X86_32
- return (regs->ip - (unsigned long)__begin_SYSENTER_singlestep_region) <
- (unsigned long)__end_SYSENTER_singlestep_region -
- (unsigned long)__begin_SYSENTER_singlestep_region;
- #elif defined(CONFIG_IA32_EMULATION)
- return (regs->ip - (unsigned long)entry_SYSENTER_compat) <
- (unsigned long)__end_entry_SYSENTER_compat -
- (unsigned long)entry_SYSENTER_compat;
- #else
- return false;
- #endif
- }
- dotraplinkage void do_debug(struct pt_regs *regs, long error_code)
- {
- struct task_struct *tsk = current;
- int user_icebp = 0;
- unsigned long dr6;
- int si_code;
- ist_enter(regs);
- get_debugreg(dr6, 6);
-
- set_debugreg(0, 6);
-
- dr6 &= ~DR6_RESERVED;
-
- clear_tsk_thread_flag(tsk, TIF_BLOCKSTEP);
- if (unlikely(!user_mode(regs) && (dr6 & DR_STEP) &&
- is_sysenter_singlestep(regs))) {
- dr6 &= ~DR_STEP;
- if (!dr6)
- goto exit;
-
- }
-
- if (!dr6 && user_mode(regs))
- user_icebp = 1;
-
- if ((dr6 & DR_STEP) && kmemcheck_trap(regs))
- goto exit;
-
- tsk->thread.debugreg6 = dr6;
- #ifdef CONFIG_KPROBES
- if (kprobe_debug_handler(regs))
- goto exit;
- #endif
- if (notify_die(DIE_DEBUG, "debug", regs, (long)&dr6, error_code,
- SIGTRAP) == NOTIFY_STOP)
- goto exit;
-
- debug_stack_usage_inc();
-
- preempt_disable();
- cond_local_irq_enable(regs);
- if (v8086_mode(regs)) {
- handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
- X86_TRAP_DB);
- cond_local_irq_disable(regs);
- preempt_enable_no_resched();
- debug_stack_usage_dec();
- goto exit;
- }
- if (WARN_ON_ONCE((dr6 & DR_STEP) && !user_mode(regs))) {
-
- tsk->thread.debugreg6 &= ~DR_STEP;
- set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
- regs->flags &= ~X86_EFLAGS_TF;
- }
- si_code = get_si_code(tsk->thread.debugreg6);
- if (tsk->thread.debugreg6 & (DR_STEP | DR_TRAP_BITS) || user_icebp)
- send_sigtrap(tsk, regs, error_code, si_code);
- cond_local_irq_disable(regs);
- preempt_enable_no_resched();
- debug_stack_usage_dec();
- exit:
- #if defined(CONFIG_X86_32)
-
- WARN(this_cpu_read(cpu_tss.SYSENTER_stack_canary) != STACK_END_MAGIC,
- "Overran or corrupted SYSENTER stack\n");
- #endif
- ist_exit(regs);
- }
- NOKPROBE_SYMBOL(do_debug);
- static void math_error(struct pt_regs *regs, int error_code, int trapnr)
- {
- struct task_struct *task = current;
- struct fpu *fpu = &task->thread.fpu;
- siginfo_t info;
- char *str = (trapnr == X86_TRAP_MF) ? "fpu exception" :
- "simd exception";
- if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, SIGFPE) == NOTIFY_STOP)
- return;
- cond_local_irq_enable(regs);
- if (!user_mode(regs)) {
- if (!fixup_exception(regs, trapnr)) {
- task->thread.error_code = error_code;
- task->thread.trap_nr = trapnr;
- die(str, regs, error_code);
- }
- return;
- }
-
- fpu__save(fpu);
- task->thread.trap_nr = trapnr;
- task->thread.error_code = error_code;
- info.si_signo = SIGFPE;
- info.si_errno = 0;
- info.si_addr = (void __user *)uprobe_get_trap_addr(regs);
- info.si_code = fpu__exception_code(fpu, trapnr);
-
- if (!info.si_code)
- return;
- force_sig_info(SIGFPE, &info, task);
- }
- dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
- {
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
- math_error(regs, error_code, X86_TRAP_MF);
- }
- dotraplinkage void
- do_simd_coprocessor_error(struct pt_regs *regs, long error_code)
- {
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
- math_error(regs, error_code, X86_TRAP_XF);
- }
- dotraplinkage void
- do_spurious_interrupt_bug(struct pt_regs *regs, long error_code)
- {
- cond_local_irq_enable(regs);
- }
- dotraplinkage void
- do_device_not_available(struct pt_regs *regs, long error_code)
- {
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
- #ifdef CONFIG_MATH_EMULATION
- if (!boot_cpu_has(X86_FEATURE_FPU) && (read_cr0() & X86_CR0_EM)) {
- struct math_emu_info info = { };
- cond_local_irq_enable(regs);
- info.regs = regs;
- math_emulate(&info);
- return;
- }
- #endif
- fpu__restore(¤t->thread.fpu);
- #ifdef CONFIG_X86_32
- cond_local_irq_enable(regs);
- #endif
- }
- NOKPROBE_SYMBOL(do_device_not_available);
- #ifdef CONFIG_X86_32
- dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code)
- {
- siginfo_t info;
- RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
- local_irq_enable();
- info.si_signo = SIGILL;
- info.si_errno = 0;
- info.si_code = ILL_BADSTK;
- info.si_addr = NULL;
- if (notify_die(DIE_TRAP, "iret exception", regs, error_code,
- X86_TRAP_IRET, SIGILL) != NOTIFY_STOP) {
- do_trap(X86_TRAP_IRET, SIGILL, "iret exception", regs, error_code,
- &info);
- }
- }
- #endif
- void __init early_trap_init(void)
- {
-
- set_intr_gate_notrace(X86_TRAP_DB, debug);
-
- set_system_intr_gate(X86_TRAP_BP, &int3);
- #ifdef CONFIG_X86_32
- set_intr_gate(X86_TRAP_PF, page_fault);
- #endif
- load_idt(&idt_descr);
- }
- void __init early_trap_pf_init(void)
- {
- #ifdef CONFIG_X86_64
- set_intr_gate(X86_TRAP_PF, page_fault);
- #endif
- }
- void __init trap_init(void)
- {
- int i;
- #ifdef CONFIG_EISA
- void __iomem *p = early_ioremap(0x0FFFD9, 4);
- if (readl(p) == 'E' + ('I'<<8) + ('S'<<16) + ('A'<<24))
- EISA_bus = 1;
- early_iounmap(p, 4);
- #endif
- set_intr_gate(X86_TRAP_DE, divide_error);
- set_intr_gate_ist(X86_TRAP_NMI, &nmi, NMI_STACK);
-
- set_system_intr_gate(X86_TRAP_OF, &overflow);
- set_intr_gate(X86_TRAP_BR, bounds);
- set_intr_gate(X86_TRAP_UD, invalid_op);
- set_intr_gate(X86_TRAP_NM, device_not_available);
- #ifdef CONFIG_X86_32
- set_task_gate(X86_TRAP_DF, GDT_ENTRY_DOUBLEFAULT_TSS);
- #else
- set_intr_gate_ist(X86_TRAP_DF, &double_fault, DOUBLEFAULT_STACK);
- #endif
- set_intr_gate(X86_TRAP_OLD_MF, coprocessor_segment_overrun);
- set_intr_gate(X86_TRAP_TS, invalid_TSS);
- set_intr_gate(X86_TRAP_NP, segment_not_present);
- set_intr_gate(X86_TRAP_SS, stack_segment);
- set_intr_gate(X86_TRAP_GP, general_protection);
- set_intr_gate(X86_TRAP_SPURIOUS, spurious_interrupt_bug);
- set_intr_gate(X86_TRAP_MF, coprocessor_error);
- set_intr_gate(X86_TRAP_AC, alignment_check);
- #ifdef CONFIG_X86_MCE
- set_intr_gate_ist(X86_TRAP_MC, &machine_check, MCE_STACK);
- #endif
- set_intr_gate(X86_TRAP_XF, simd_coprocessor_error);
-
- for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++)
- set_bit(i, used_vectors);
- #ifdef CONFIG_IA32_EMULATION
- set_system_intr_gate(IA32_SYSCALL_VECTOR, entry_INT80_compat);
- set_bit(IA32_SYSCALL_VECTOR, used_vectors);
- #endif
- #ifdef CONFIG_X86_32
- set_system_intr_gate(IA32_SYSCALL_VECTOR, entry_INT80_32);
- set_bit(IA32_SYSCALL_VECTOR, used_vectors);
- #endif
-
- __set_fixmap(FIX_RO_IDT, __pa_symbol(idt_table), PAGE_KERNEL_RO);
- idt_descr.address = fix_to_virt(FIX_RO_IDT);
-
- cpu_init();
-
- set_intr_gate_ist(X86_TRAP_DB, &debug, DEBUG_STACK);
-
- set_system_intr_gate_ist(X86_TRAP_BP, &int3, DEBUG_STACK);
- x86_init.irqs.trap_init();
- #ifdef CONFIG_X86_64
- memcpy(&debug_idt_table, &idt_table, IDT_ENTRIES * 16);
- set_nmi_gate(X86_TRAP_DB, &debug);
- set_nmi_gate(X86_TRAP_BP, &int3);
- #endif
- }
|