x86: report when thread re-use is detected
x86_64's __resume path 'poisons' the incoming thread's saved RIP value with a special 0xB9 value, to catch re-use of thread objects across CPUs in SMP. Add a check and printout for this when handling fatal errors, and treat as a kernel panic. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
3dd3c6a393
commit
bed6b6891d
1 changed files with 12 additions and 2 deletions
|
@ -305,11 +305,21 @@ static void dump_page_fault(z_arch_esf_t *esf)
|
|||
FUNC_NORETURN void z_x86_fatal_error(unsigned int reason,
|
||||
const z_arch_esf_t *esf)
|
||||
{
|
||||
#ifdef CONFIG_EXCEPTION_DEBUG
|
||||
if (esf != NULL) {
|
||||
#ifdef CONFIG_EXCEPTION_DEBUG
|
||||
dump_regs(esf);
|
||||
#endif
|
||||
#if defined(CONFIG_ASSERT) && defined(CONFIG_X86_64)
|
||||
if (esf->rip == 0xb9) {
|
||||
/* See implementation of __resume in locore.S. This is
|
||||
* never a valid RIP value. Treat this as a kernel
|
||||
* panic.
|
||||
*/
|
||||
LOG_ERR("Attempt to resume un-suspended thread object");
|
||||
reason = K_ERR_KERNEL_PANIC;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
z_fatal_error(reason, esf);
|
||||
CODE_UNREACHABLE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue