summaryrefslogtreecommitdiffstats
path: root/src/include/kernel
diff options
context:
space:
mode:
authorRichard J. Knight <rjknight@us.ibm.com>2017-03-07 15:51:36 -0600
committerDaniel M. Crowell <dcrowell@us.ibm.com>2017-04-10 17:44:40 -0400
commitca1e3f7df35276b213a4453df289f376c2cbc618 (patch)
treee54dabbffee07677364edb6d6d08f79d197a8c73 /src/include/kernel
parentc703612bd907523a11169a7d30aca138a84ed673 (diff)
downloadtalos-hostboot-ca1e3f7df35276b213a4453df289f376c2cbc618.tar.gz
talos-hostboot-ca1e3f7df35276b213a4453df289f376c2cbc618.zip
Enhance heap consistency checking
-Add validation to heap allocations, marker used to detect buffer overruns to generate exception when memory segment is freed -Add additional debug to the heap bookkeeping data - owner tid, reserved size and an indicator to say it is an allocated chunk Change-Id: Iae522fc4c6157a32f5689ee1ec5fd9d552123eb4 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/37829 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Martin Gloff <mgloff@us.ibm.com> Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/include/kernel')
-rw-r--r--src/include/kernel/heapmgr.H21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/include/kernel/heapmgr.H b/src/include/kernel/heapmgr.H
index 6db70569b..bf4fe1cc7 100644
--- a/src/include/kernel/heapmgr.H
+++ b/src/include/kernel/heapmgr.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2010,2015 */
+/* Contributors Listed Below - COPYRIGHT 2010,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -28,6 +28,7 @@
#include <stdint.h>
#include <util/lockfree/stack.H>
#include <builtins.h>
+#include <kernel/types.h>
extern "C"
void kernel_execute_decrementer();
@@ -53,6 +54,11 @@ class HeapManager
public:
enum
{
+ CHUNK_HEADER_PLUS_RESERVED = 9, //!< 8 Bytes header + 1 byte valid
+ };
+
+ enum
+ {
BUCKETS = 12, //!< number of buckets
MIN_BUCKET_SIZE = 16, //!< Smallest bucket size
FIB_START_INCR = 16, //!< Seed for the Fibonacci series
@@ -69,7 +75,10 @@ class HeapManager
BUCKET_SIZE10 = BUCKET_SIZE9 + BUCKET_SIZE8,
BUCKET_SIZE11 = BUCKET_SIZE10 + BUCKET_SIZE9,
- MAX_SMALL_ALLOC_SIZE = BUCKET_SIZE11 - 8,// last bucket size-8
+ // last bucket size, 8 byte chunk header + 1 byte for consistency
+ // checking
+ MAX_SMALL_ALLOC_SIZE = BUCKET_SIZE11 - CHUNK_HEADER_PLUS_RESERVED,
+
};
friend class CpuManager;
@@ -136,9 +145,11 @@ class HeapManager
{
struct
{
- char free:8; //!< Is chunk free
- char coalesce:8; //!< Is chunk being coalesced
- uint64_t bucket:48; //!< Which bucket this chunk belongs to
+ uint8_t free; //!< F=free, A=allocated
+ uint8_t coalesce; //!< C=chunk being coalesced
+ uint16_t size; //!< size of the data area
+ tid_t allocator; //!< task_id of allocating thread
+ uint16_t bucket; //!< Which bucket this chunk belongs to
} PACKED;
chunk_t* next; //!< Next chunk (for unallocated chunks only)
OpenPOWER on IntegriCloud