2012-06-13 01:29:32 +02:00
|
|
|
/*
|
|
|
|
This software and ancillary information (herein called SOFTWARE )
|
|
|
|
called LinuxBIOS is made available under the terms described
|
|
|
|
here. The SOFTWARE has been approved for release with associated
|
|
|
|
LA-CC Number 00-34 . Unless otherwise indicated, this SOFTWARE has
|
|
|
|
been authored by an employee or employees of the University of
|
|
|
|
California, operator of the Los Alamos National Laboratory under
|
|
|
|
Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The
|
|
|
|
U.S. Government has rights to use, reproduce, and distribute this
|
|
|
|
SOFTWARE. The public may copy, distribute, prepare derivative works
|
|
|
|
and publicly display this SOFTWARE without charge, provided that this
|
|
|
|
Notice and any statement of authorship are reproduced on all copies.
|
|
|
|
Neither the Government nor the University makes any warranty, express
|
|
|
|
or implied, or assumes any liability or responsibility for the use of
|
|
|
|
this SOFTWARE. If SOFTWARE is modified to produce derivative works,
|
|
|
|
such modified SOFTWARE should be clearly marked, so as not to confuse
|
|
|
|
it with the version available from LANL.
|
|
|
|
*/
|
|
|
|
/* Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
|
|
|
|
* rminnich@lanl.gov
|
2017-03-11 00:23:24 +01:00
|
|
|
* Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>,
|
|
|
|
* Raptor Engineering
|
2012-06-13 01:29:32 +02:00
|
|
|
*/
|
|
|
|
|
2014-12-16 03:19:03 +01:00
|
|
|
#include <assert.h>
|
2012-06-13 01:29:32 +02:00
|
|
|
#include <lib.h>
|
|
|
|
#include <console/console.h>
|
2014-12-16 03:19:03 +01:00
|
|
|
#include <symbols.h>
|
2012-06-13 01:29:32 +02:00
|
|
|
|
|
|
|
int checkstack(void *top_of_stack, int core)
|
|
|
|
{
|
2014-12-16 03:19:03 +01:00
|
|
|
/* Not all archs use CONFIG_STACK_SIZE, those who don't set it to 0. */
|
|
|
|
size_t stack_size = CONFIG_STACK_SIZE ? CONFIG_STACK_SIZE : _stack_size;
|
2012-06-13 01:29:32 +02:00
|
|
|
int i;
|
2014-12-16 03:19:03 +01:00
|
|
|
u32 *stack = (u32 *) (top_of_stack - stack_size);
|
2012-06-13 01:29:32 +02:00
|
|
|
|
2017-03-10 02:35:28 +01:00
|
|
|
if (stack[0] != 0xDEADBEEF) {
|
2017-03-11 00:23:24 +01:00
|
|
|
printk(BIOS_ERR,
|
|
|
|
"Stack overrun on CPU%d (address %p overwritten). "
|
2014-12-16 03:19:03 +01:00
|
|
|
"Increase stack from current %zu bytes\n",
|
2015-09-06 02:31:03 +02:00
|
|
|
core, stack, stack_size);
|
2014-12-16 03:19:03 +01:00
|
|
|
BUG();
|
2012-06-13 01:29:32 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-03-10 02:35:28 +01:00
|
|
|
for (i = 1; i < stack_size/sizeof(stack[0]); i++) {
|
2012-06-13 01:29:32 +02:00
|
|
|
if (stack[i] == 0xDEADBEEF)
|
|
|
|
continue;
|
2012-10-16 00:19:43 +02:00
|
|
|
printk(BIOS_SPEW, "CPU%d: stack: %p - %p, ",
|
2014-12-16 03:19:03 +01:00
|
|
|
core, stack, &stack[stack_size/sizeof(stack[0])]);
|
2012-10-16 00:19:43 +02:00
|
|
|
printk(BIOS_SPEW, "lowest used address %p, ", &stack[i]);
|
|
|
|
printk(BIOS_SPEW, "stack used: %ld bytes\n",
|
2014-12-16 03:19:03 +01:00
|
|
|
(unsigned long)&stack[stack_size / sizeof(stack[0])]
|
|
|
|
- (unsigned long)&stack[i]);
|
2012-10-16 00:19:43 +02:00
|
|
|
return 0;
|
2012-06-13 01:29:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|