2019-07-16 04:18:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Intel Corporation
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <kernel.h>
|
|
|
|
#include <ksched.h>
|
|
|
|
#include <kernel_structs.h>
|
|
|
|
#include <kernel_internal.h>
|
|
|
|
#include <logging/log.h>
|
2020-11-27 02:32:34 +08:00
|
|
|
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
|
2019-07-16 04:18:36 +08:00
|
|
|
|
2020-10-14 21:45:06 +08:00
|
|
|
/* NMI handlers should override weak implementation
|
|
|
|
* return true if NMI is handled, false otherwise
|
|
|
|
*/
|
|
|
|
__weak bool z_x86_do_kernel_nmi(const z_arch_esf_t *esf)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-11-07 04:26:59 +08:00
|
|
|
void z_x86_exception(z_arch_esf_t *esf)
|
2019-07-16 04:18:36 +08:00
|
|
|
{
|
2019-11-07 04:26:59 +08:00
|
|
|
switch (esf->vector) {
|
2019-12-19 06:12:54 +08:00
|
|
|
case Z_X86_OOPS_VECTOR:
|
|
|
|
z_x86_do_kernel_oops(esf);
|
|
|
|
break;
|
2019-11-07 04:26:59 +08:00
|
|
|
case IV_PAGE_FAULT:
|
|
|
|
z_x86_page_fault_handler(esf);
|
|
|
|
break;
|
2020-10-14 21:45:06 +08:00
|
|
|
case IV_NON_MASKABLE_INTERRUPT:
|
|
|
|
if (!z_x86_do_kernel_nmi(esf)) {
|
|
|
|
z_x86_unhandled_cpu_exception(esf->vector, esf);
|
|
|
|
CODE_UNREACHABLE;
|
|
|
|
}
|
|
|
|
break;
|
2019-11-07 04:26:59 +08:00
|
|
|
default:
|
2019-11-19 04:07:58 +08:00
|
|
|
z_x86_unhandled_cpu_exception(esf->vector, esf);
|
2019-11-07 04:26:59 +08:00
|
|
|
CODE_UNREACHABLE;
|
2019-11-06 06:00:30 +08:00
|
|
|
}
|
2019-07-16 04:18:36 +08:00
|
|
|
}
|
2019-12-19 06:30:41 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_USERSPACE
|
|
|
|
void arch_syscall_oops(void *ssf_ptr)
|
|
|
|
{
|
|
|
|
struct x86_ssf *ssf = ssf_ptr;
|
|
|
|
|
|
|
|
LOG_ERR("Bad system call from RIP 0x%lx", ssf->rip);
|
|
|
|
|
|
|
|
z_x86_fatal_error(K_ERR_KERNEL_OOPS, NULL);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_USERSPACE */
|