diff options
28 files changed, 578 insertions, 63 deletions
diff --git a/src/build/debug/Hostboot/Errl.pm b/src/build/debug/Hostboot/Errl.pm index e3484555c..8b248a786 100755 --- a/src/build/debug/Hostboot/Errl.pm +++ b/src/build/debug/Hostboot/Errl.pm @@ -6,7 +6,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2011,2015 +# Contributors Listed Below - COPYRIGHT 2011,2018 # [+] International Business Machines Corp. # # @@ -84,7 +84,8 @@ sub main } } - my ($symAddr, $symSize) = ::findSymbolAddress("ERRORLOG::g_ErrlStorage"); + my ($symAddr, $symSize) = ::findPointer("ERRORLOG", + "ERRORLOG::g_ErrlStorage"); if (not defined $symAddr) { ::userDisplay "Couldn't find symbol ERRORLOG::g_ErrlStorage\n"; diff --git a/src/build/debug/Hostboot/MemStats.pm b/src/build/debug/Hostboot/MemStats.pm index 68fcf15e2..9156d8267 100755 --- a/src/build/debug/Hostboot/MemStats.pm +++ b/src/build/debug/Hostboot/MemStats.pm @@ -5,7 +5,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2011,2014 +# Contributors Listed Below - COPYRIGHT 2011,2018 +# [+] International Business Machines Corp. +# # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -28,6 +30,8 @@ our @EXPORT_OK = ('main'); use constant HEAPMGR_INSTANCE_NAME => "Singleton<HeapManager>::instance()::instance"; +use constant PAGEMGR_INSTANCE_NAME => + "Singleton<PageManager>::instance()::instance"; use constant HEAPMGR_CHUNK_OFFSET => 0; #use constant HEAPMGR_BIGCHUNK_OFFSET => 0; use constant HEAPMGR_NUMBER_OF_BUCKETS => 12; @@ -51,11 +55,11 @@ sub main $showchunks = 1; } - my ($heap_manager_addr, $symSize) = - ::findSymbolAddress(HEAPMGR_INSTANCE_NAME); + my ($heap_manager_addr, $symSize) = ::findPointer("HEAPMGR ", + HEAPMGR_INSTANCE_NAME); - my @page_manager_addr = - ::findSymbolAddress("Singleton<PageManager>::instance()::instance"); + my @page_manager_addr = ::findPointer("PAGEMGR ", + PAGEMGR_INSTANCE_NAME); my $free_pages = ::read64 @page_manager_addr; @@ -63,39 +67,49 @@ sub main my $total_pages = ::read64 ($page_manager_addr[0] + 8, 8); - my $free_min = - ::read64 ::findSymbolAddress("PageManager::cv_low_page_count"); + my $free_min = ::read64 + ::findPointer("PAGEMLPC", + "PageManager::cv_low_page_count"); - my $page_coal = - ::read64 ::findSymbolAddress("PageManager::cv_coalesce_count"); + my $page_coal = ::read64 + ::findPointer("PAGEMCNT", + "PageManager::cv_coalesce_count"); - my $big_heap_pages_used = - ::read32 ::findSymbolAddress("HeapManager::cv_largeheap_page_count"); + my $big_heap_pages_used = ::read32 + ::findPointer("HEAPMLPC", + "HeapManager::cv_largeheap_page_count"); - my $big_heap_max = - ::read32 ::findSymbolAddress("HeapManager::cv_largeheap_page_max"); + my $big_heap_max = ::read32 + ::findPointer("HEAPMLPM", + "HeapManager::cv_largeheap_page_max"); - my $small_heap_pages_used = - ::read32 ::findSymbolAddress("HeapManager::cv_smallheap_page_count"); + my $small_heap_pages_used = ::read32 + ::findPointer("HEAPMSPC", + "HeapManager::cv_smallheap_page_count"); - my $heap_coal = - ::read32 ::findSymbolAddress("HeapManager::cv_coalesce_count"); + my $heap_coal = ::read32 + ::findPointer("HEAPMCNT", + "HeapManager::cv_coalesce_count"); - my $heap_free = - ::read32 ::findSymbolAddress("HeapManager::cv_free_bytes"); + my $heap_free = ::read32 + ::findPointer("HEAPBYTE", + "HeapManager::cv_free_bytes"); - my $heap_free_chunks = - ::read32 ::findSymbolAddress("HeapManager::cv_free_chunks"); + my $heap_free_chunks = ::read32 + ::findPointer("HEAPCHNK", + "HeapManager::cv_free_chunks"); my $heap_total = $big_heap_pages_used + $small_heap_pages_used; my $heap_max = $big_heap_max + $small_heap_pages_used; - my $castout_ro = - ::read32 ::findSymbolAddress("Block::cv_ro_evict_req"); + my $castout_ro = ::read32 + ::findPointer("BLOCKROE", + "Block::cv_ro_evict_req"); - my $castout_rw = - ::read32 ::findSymbolAddress("Block::cv_rw_evict_req"); + my $castout_rw = ::read32 + ::findPointer("BLOCKRWE", + "Block::cv_rw_evict_req"); ::userDisplay "===================================================\n"; diff --git a/src/build/debug/Hostboot/PageMgr.pm b/src/build/debug/Hostboot/PageMgr.pm index d0d73f3d8..faa70253e 100755 --- a/src/build/debug/Hostboot/PageMgr.pm +++ b/src/build/debug/Hostboot/PageMgr.pm @@ -6,7 +6,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2012,2016 +# Contributors Listed Below - COPYRIGHT 2012,2018 # [+] International Business Machines Corp. # # @@ -54,7 +54,8 @@ sub main } # Find the PageManager - my ($symAddr, $symSize) = ::findSymbolAddress(PAGEMGR_INSTANCE_NAME); + my ($symAddr, $symSize) = ::findPointer("PAGEMGR ", + PAGEMGR_INSTANCE_NAME); if (not defined $symAddr) { ::userDisplay "Couldn't find ".PAGEMGR_INSTANCE_NAME; diff --git a/src/build/debug/Hostboot/PrintVMM.pm b/src/build/debug/Hostboot/PrintVMM.pm index 390a9b4b6..476262d93 100644 --- a/src/build/debug/Hostboot/PrintVMM.pm +++ b/src/build/debug/Hostboot/PrintVMM.pm @@ -5,7 +5,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2012,2014 +# Contributors Listed Below - COPYRIGHT 2012,2018 +# [+] International Business Machines Corp. +# # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -68,8 +70,8 @@ sub main } # Get the device segment address - my @segment_manager_addr = - ::findSymbolAddress("Singleton<SegmentManager>::instance()::instance"); + my @segment_manager_addr = ::findPointer("SGMNTMGR", + "Singleton<SegmentManager>::instance()::instance"); if (not defined @segment_manager_addr) { diff --git a/src/build/debug/Hostboot/Printk.pm b/src/build/debug/Hostboot/Printk.pm index 8f933145c..b7dd49546 100755 --- a/src/build/debug/Hostboot/Printk.pm +++ b/src/build/debug/Hostboot/Printk.pm @@ -6,7 +6,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2011,2014 +# Contributors Listed Below - COPYRIGHT 2011,2018 +# [+] International Business Machines Corp. +# # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,7 +32,8 @@ our @EXPORT_OK = ('main'); sub main { - my ($symAddr, $symSize) = ::findSymbolAddress("kernel_printk_buffer"); + my ($symAddr, $symSize) = ::findPointer("PRINTK ", + "kernel_printk_buffer"); if (not defined $symAddr) { ::userDisplay "Cannot find symbol.\n"; die; } my $data = ::readData($symAddr,$symSize); $data =~ s/\0+//g; #strip off nulls diff --git a/src/build/debug/Hostboot/Ps.pm b/src/build/debug/Hostboot/Ps.pm index 134bc6ae8..594f124e0 100755 --- a/src/build/debug/Hostboot/Ps.pm +++ b/src/build/debug/Hostboot/Ps.pm @@ -67,7 +67,8 @@ sub main # Find symbol containing kernel list of task objects. # (Tasks who's parent is the kernel) - my ($symAddr, $symSize) = ::findSymbolAddress(PS_TASKMGR_SYMBOLNAME); + my ($symAddr, $symSize) = ::findPointer("TASKLIST", + PS_TASKMGR_SYMBOLNAME); if (not defined $symAddr) { ::userDisplay "Couldn't find ".PS_TASKMGR_SYMBOLNAME; diff --git a/src/build/debug/Hostboot/Trace.pm b/src/build/debug/Hostboot/Trace.pm index 23286b48c..4756de305 100755 --- a/src/build/debug/Hostboot/Trace.pm +++ b/src/build/debug/Hostboot/Trace.pm @@ -6,7 +6,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2011,2016 +# Contributors Listed Below - COPYRIGHT 2011,2018 # [+] International Business Machines Corp. # # @@ -75,11 +75,11 @@ sub main my $foundBuffer = 0; print $fh "\2"; - my ($daemonAddr, $daemonSize) = - ::findSymbolAddress("Singleton<TRACEDAEMON::Daemon>::instance()::instance"); + my ($daemonAddr, $daemonSize) =::findPointer("TRACEDMN", + "Singleton<TRACEDAEMON::Daemon>::instance()::instance"); - my ($serviceAddr, $serviceSize) = - ::findSymbolAddress("Singleton<TRACE::Service>::instance()::instance"); + my ($serviceAddr, $serviceSize) = ::findPointer("TRACESVC", + "Singleton<TRACE::Service>::instance()::instance"); if ((not defined $daemonAddr) || (not defined $serviceAddr)) { diff --git a/src/build/debug/Hostboot/_DebugFramework.pm b/src/build/debug/Hostboot/_DebugFramework.pm index 8937f4f6d..4977eedeb 100755 --- a/src/build/debug/Hostboot/_DebugFramework.pm +++ b/src/build/debug/Hostboot/_DebugFramework.pm @@ -6,7 +6,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2011,2017 +# Contributors Listed Below - COPYRIGHT 2011,2018 # [+] International Business Machines Corp. # # @@ -56,6 +56,7 @@ our @EXPORT = ( 'setBootloader', 'clearBootloader', 'callToolModule', 'getIstepList', 'findSymbolWithinAddrRange', 'alignUp', + 'findDebugPointer', 'findPointer', ); our ($parsedSymbolFile, %symbolAddress, %symbolTOC, @@ -63,6 +64,11 @@ our ($parsedSymbolFile, %symbolAddress, %symbolTOC, our ($parsedModuleFile, %moduleAddress); our (%toolOpts); our ($bootloaderDebug); +our (%debugPointerAddrs, %debugPointerSizes, $parsedDebugPointers); + +# HOSTBOOT eyecatcher at HRMOR+8K+16 +use constant DEBUG_PTR_ADDR => 8208; + BEGIN { @@ -71,6 +77,9 @@ BEGIN %symbolTOC = (); %addressSymbol = (); %addrRangeHash = (); + %debugPointerAddrs = (); + %debugPointerSizes = (); + $parsedDebugPointers = 0; %symbolSize = (); @@ -365,9 +374,103 @@ sub parseSymbolFile $parsedSymbolFile = 1; } +# @sub parseDebugPointers <INTERNAL ONLY> +# +# Parses the debug pointers area of memory. +# See debugpointers.H for implementation details +# +# @return array of (address, size) or (not-defined, not-defined). +# +sub parseDebugPointers +{ + if ($parsedDebugPointers) { return; } + + # The pointer to the DebugPointers_t sits right behind the + #my $debugptr = translateHRMOR(DEBUG_PTR_ADDR); + #::userDisplay("Reading $debugptr\n"); + my $mainptr = ::read64(DEBUG_PTR_ADDR); + #::userDisplay("mainptr=$mainptr\n"); + if( $mainptr == 0 ) + { + ::userDisplay("No debug pointer set at 0x2010\n"); + } + elsif( $mainptr > 0x4000000 ) + { + ::userDisplay("Debug pointer area appears invalid - $mainptr\n"); + } + else + { + #::userDisplay("Found debug pointer at $mainptr\n"); + #uint64_t eyecatcher; + #uint16_t version; + #uint16_t numEntries; + #uint32_t reserved; + #PointerPair_t pairs[MAX_ENTRIES]; + + # Pull down the metadata + my $eyecatcher = ::read64($mainptr); + #::userDisplay("eyecatcher=$eyecatcher\n"); + my $version = ::read16($mainptr+8); + #::userDisplay("version=$version\n"); + my $numentries = ::read16($mainptr+10); + #::userDisplay("numentries=$numentries\n"); + if( $eyecatcher != 0x4445425547505452 ) #DEBUGPTR + { + ::userDisplay("Invalid debug pointer at $mainptr\n"); + } + + # Walk through all of the pointers + #char label[8]; + #uint32_t size; + #uint32_t pointer; + + my $curentry = $mainptr+16; + for(my $i = 0; $i < $numentries; $i++) + { + #::userDisplay("i=$i, curentry=$curentry\n"); + my $cur_label = ::read64($curentry); + my $cur_label2 = sprintf("%X",$cur_label); + my $cur_size = ::read32($curentry+8); + my $cur_ptr = ::read32($curentry+12); + if( $cur_label != 0 ) + { + #my $cur_ascii = pack( "A*", $cur_label2 ); + #::userDisplay( + # "$cur_label2 / $cur_ascii is at $cur_ptr for $cur_size\n"); + $debugPointerAddrs{$cur_label2} = $cur_ptr; + $debugPointerSizes{$cur_label2} = $cur_size; + } + + $curentry = $curentry+16; + } + } + + $parsedDebugPointers = 1; +} + +# @sub findDebugPointer +# +# Searches a syms file for the address of a particular symbol name. +# +# @param string - Symbol to search for. +# @return array of (address, size) or (not-defined, not-defined). +# +sub findDebugPointer +{ + my $name = shift; + + parseDebugPointers(); + #::userDisplay("name=$name\n"); + # need to turn this string into hex digits + my $name2 = uc(unpack( "H*", $name )); + #::userDisplay("name2=$name2\n"); + + return ($debugPointerAddrs{$name2}, $debugPointerSizes{$name2} ); +} + # @sub findSymbolAddress # -# Searchs a syms file for the address of a particular symbol name. +# Searches a syms file for the address of a particular symbol name. # # @param string - Symbol to search for. # @return array of (address, size) or (not-defined, not-defined). @@ -381,6 +484,39 @@ sub findSymbolAddress return ($symbolAddress{$name}, $symbolSize{$name} ); } +# @sub findPointer +# +# Searches for a pointer wherever it can be found. +# Looks in the debug pointer section of memory first, then +# tries to use the symbols +# +# @param string - Debug pointer to search for. +# @param string - Symbol to search for. +# @return array of (address, size) or (not-defined, not-defined). +# +sub findPointer +{ + my $dbgptrstr = shift; #Debug Pointer + my $sym = shift; #Symbol + my $addr; + my $size; + + my $symsmode = ::getSymsMode(); + if( ($symsmode =~ "") || ($symsmode =~ "usemem") ) + { + ($addr, $size ) = findDebugPointer( $dbgptrstr ); + } + + if( (($symsmode =~ "") && (not defined $addr)) + || ($symsmode =~ "usefile") ) + { + #::userDisplay( "*Using Symbol File*\n" ); + ($addr, $size ) = findSymbolAddress( $sym ); + } + + return ( $addr, $size ); +} + # @sub findSymbolTOCAddress # Searches a syms file for the address of the TOC of a symbol. # diff --git a/src/build/debug/Hostboot/_DebugFrameworkVMM.pm b/src/build/debug/Hostboot/_DebugFrameworkVMM.pm index e51e195a3..128df4ec7 100755 --- a/src/build/debug/Hostboot/_DebugFrameworkVMM.pm +++ b/src/build/debug/Hostboot/_DebugFrameworkVMM.pm @@ -6,7 +6,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2012,2015 +# Contributors Listed Below - COPYRIGHT 2012,2018 # [+] International Business Machines Corp. # # @@ -400,8 +400,8 @@ sub getPhysicalAddr #} # Get the device segment address - my @segment_manager_addr = - ::findSymbolAddress("Singleton<SegmentManager>::instance()::instance"); + my @segment_manager_addr = ::findPointer("SGMNTMGR", + "Singleton<SegmentManager>::instance()::instance"); if (not defined @segment_manager_addr) diff --git a/src/build/debug/ecmd-debug-framework.pl b/src/build/debug/ecmd-debug-framework.pl index 0fadd554b..cbdbbad83 100755 --- a/src/build/debug/ecmd-debug-framework.pl +++ b/src/build/debug/ecmd-debug-framework.pl @@ -67,6 +67,11 @@ if (not $self) $tool = basename $0; } +# "" : Default - Try to use memory, fall-back to symbol files +# "usefile" : Only use the symbol files +# "usemem" : Only use the data from memory +my $useSymsMode = ""; + GetOptions("tool:s" => \$tool, "tool-options:s" => \$toolOptions, "test" => \$testImage, @@ -77,6 +82,7 @@ GetOptions("tool:s" => \$tool, "node:i" => \$node, "proc:i" => \$proc, "memmode:s" => \$memMode, + "symsmode:s" => \$useSymsMode, "man" => \$cfgMan) || pod2usage(-verbose => 0); pod2usage(-verbose => 1) if $cfgHelp; pod2usage(-verbose => 2) if $cfgMan; @@ -125,6 +131,15 @@ sub getImgPath return $imgPath; } +# @sub getSymsMode +# +# Return whether we should use symbol files or pointers from memory. +# +sub getSymsMode +{ + return $useSymsMode; +} + # @sub getIsTest # # Return boolean to determine if tools should look at test debug files or diff --git a/src/build/debug/hb-dump-debug b/src/build/debug/hb-dump-debug index 50972ff45..3aeffe02e 100755 --- a/src/build/debug/hb-dump-debug +++ b/src/build/debug/hb-dump-debug @@ -6,7 +6,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2011,2014 +# Contributors Listed Below - COPYRIGHT 2011,2018 +# [+] International Business Machines Corp. +# # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -50,17 +52,23 @@ if (defined ($hbDir)) } } +# "both" : Try to use memory, fall-back to symbol files +# "usefile" : Only use the symbol files +# "usemem" : Only use the data from memory +my $useSymsMode = "both"; + GetOptions("tool:s" => \$tool, "tool-options:s" => \$toolOptions, "file:s" => \$dumpfile, "test" => \$testImage, "img-path:s" => \$imgPath, + "symsmode:s" => \$useSymsMode, "help" => \$cfgHelp, "toolhelp" => \$toolHelp, "man" => \$cfgMan) || pod2usage(-verbose => 0); pod2usage(-verbose => 1) if $cfgHelp; pod2usage(-verbose => 2) if $cfgMan; -pod2usage(-verbose => 0) if (($tool eq "") || +pod2usage(-verbose => 0) if (($tool eq "") || (($dumpfile eq "") && (!$toolHelp))); if ($toolHelp) @@ -133,6 +141,15 @@ sub getImgPath return $imgPath; } +# @sub getSymsMode +# +# Return whether we should use symbol files or pointers from memory. +# +sub getSymsMode +{ + return $useSymsMode; +} + # @sub getIsTest # # Return boolean to determine if tools should look at test debug files or diff --git a/src/build/debug/simics-debug-framework.pl b/src/build/debug/simics-debug-framework.pl index 932a30f84..1a16db647 100755 --- a/src/build/debug/simics-debug-framework.pl +++ b/src/build/debug/simics-debug-framework.pl @@ -6,7 +6,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2011,2016 +# Contributors Listed Below - COPYRIGHT 2011,2018 # [+] Google Inc. # [+] International Business Machines Corp. # @@ -157,6 +157,17 @@ sub getImgPath return $imgPath; } +# @sub getSymsMode +# +# Return whether we should use symbol files or pointers from memory. +# "usefile" : Only use the symbol files +# +sub getSymsMode +{ + # We're always running from a build of some sort in simics + return "usefile"; +} + # Tool location override. sub getToolOverride { diff --git a/src/include/kernel/block.H b/src/include/kernel/block.H index 80f62b3e0..219c7d3e2 100644 --- a/src/include/kernel/block.H +++ b/src/include/kernel/block.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2014 */ +/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -149,6 +151,11 @@ class Block void updateRefCount( uint64_t i_vaddr, PageTableManager::UsageStats_t i_stats ); + /** + * Add pointers to the global debug area + */ + static void addDebugPointers(); + friend class Segment; friend class BaseSegment; friend class StackSegment; @@ -285,7 +292,6 @@ class Block uint64_t i_size, task_t* i_task); - private: /** Base address of the block */ const uint64_t iv_baseAddr; diff --git a/src/include/kernel/heapmgr.H b/src/include/kernel/heapmgr.H index 9f1d0a7ed..8710e40c7 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,2017 */ +/* Contributors Listed Below - COPYRIGHT 2010,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -116,6 +116,10 @@ class HeapManager */ static void free(void * i_ptr); + /** + * Add pointers to the global debug area + */ + static void addDebugPointers(); protected: @@ -224,6 +228,11 @@ class HeapManager */ void test_pages(); + /** + * Add pointers to the global debug area + */ + void _addDebugPointers(); + private: // data Util::Lockfree::Stack<chunk_t> first_chunk[BUCKETS]; //!< free pool diff --git a/src/include/kernel/pagemgr.H b/src/include/kernel/pagemgr.H index c842a9360..2431c613d 100644 --- a/src/include/kernel/pagemgr.H +++ b/src/include/kernel/pagemgr.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2010,2016 */ +/* Contributors Listed Below - COPYRIGHT 2010,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -181,6 +181,11 @@ class PageManager */ static void addMemory(size_t i_addr, size_t i_pageCount); + /** + * Add pointers to the global debug area + */ + static void addDebugPointers(); + enum { KERNEL_HEAP_RESERVED_PAGES = 4, @@ -208,6 +213,7 @@ class PageManager void _freePage(void*, size_t); //!< see freePage() void _coalesce( void ); //!< see coalesce() void _addMemory(size_t, size_t); //!< see addMemory() + void _addDebugPointers(); //!< see addDebugPointers() /** see queryAvail() */ ALWAYS_INLINE uint64_t _queryAvail() const diff --git a/src/include/kernel/segmentmgr.H b/src/include/kernel/segmentmgr.H index 34bbe8fb6..2534590bc 100644 --- a/src/include/kernel/segmentmgr.H +++ b/src/include/kernel/segmentmgr.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ +/* Contributors Listed Below - COPYRIGHT 2011,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -154,6 +154,10 @@ class SegmentManager */ static int devUnmap(void* ea); + /** + * Add pointers to the global debug area + */ + static void addDebugPointers(); private: @@ -188,6 +192,9 @@ class SegmentManager return i_addr >> SLBE_s; } + /** See addDebugPointers */ + void _addDebugPointers(); + /** Array of segment objects to associated segment IDs. */ Segment* iv_segments[MAX_SEGMENTS]; }; diff --git a/src/include/kernel/taskmgr.H b/src/include/kernel/taskmgr.H index 2b2e17f34..71dc6cfc9 100644 --- a/src/include/kernel/taskmgr.H +++ b/src/include/kernel/taskmgr.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2010,2014 */ +/* Contributors Listed Below - COPYRIGHT 2010,2018 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -144,6 +146,11 @@ class TaskManager static void waitTask(task_t* t, int64_t tid, int* status, void** retval); + /** + * Add pointers to the global debug area + */ + static void addDebugPointers(); + friend class CpuManager; protected: @@ -174,6 +181,11 @@ class TaskManager */ void removeTracker(task_tracking_t* t); + /** + * Add pointers to the global debug area + */ + void _addDebugPointers(); + /** Atomic monotonically increasing counter to use for TIDs. */ Util::Lockfree::Counter<tid_t> iv_nextTid; diff --git a/src/include/usr/debugpointers.H b/src/include/usr/debugpointers.H new file mode 100644 index 000000000..01de1a0d8 --- /dev/null +++ b/src/include/usr/debugpointers.H @@ -0,0 +1,117 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/debugpointers.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2018 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ +#ifndef _DEBUGPOINTERS_H +#define _DEBUGPOINTERS_H + +/** + * This file contains details on a list of pointers that can be used + * by our debug framework without requiring an exact build match. + */ + +// Static space allocated in start.S +// This points to a dynamically allocated instance of a DebugPointers_t +extern void* debug_pointers; + +namespace DEBUG +{ +// Maximum number of entries +constexpr uint16_t MAX_ENTRIES = 20; + +// Eyecatcher to detect levels without this support +// = DEBUGPTR +constexpr uint64_t EYECATCHER = 0x4445425547505452; + +// Only 1 version so far but allow for others +constexpr uint16_t VERSION_LATEST = 0x0001; + +// A pair of pointers +struct PointerPair_t +{ + union { + char label[8]; + uint64_t label_num; //Makes assignments and checking simpler + }; + uint32_t size; // bytes + uint32_t pointer; // we never use all 64-bits of a native pointer +} PACKED; + +// Table of Debug Pointers +struct DebugPointers_t +{ + uint64_t eyecatcher; + uint16_t version; + uint16_t numEntries; + uint32_t reserved; + PointerPair_t pairs[MAX_ENTRIES]; + + DebugPointers_t() + : eyecatcher(EYECATCHER), + version(VERSION_LATEST), + numEntries(MAX_ENTRIES), + reserved(0) + { + memset( pairs, 0, sizeof(pairs) ); + } +} PACKED; + +/* + * List of known debug pointers + * Note: Must keep debug tools in sync if these values change + */ +constexpr uint64_t PRINTK = 0x5052494e544b2020; //'PRINTK ' +constexpr uint64_t TRACESERVICE = 0x5452414345535643; //'TRACESVC' +constexpr uint64_t TRACEDAEMON = 0x5452414345444D4E; //'TRACEDMN' +constexpr uint64_t TASKMANAGER = 0x5441534b4c495354; //'TASKLIST' +constexpr uint64_t ERRORLOGS = 0x4552524f524c4f47; //'ERRORLOG' +constexpr uint64_t HEAPMANAGER = 0x484541504d475220; //'HEAPMGR ' +constexpr uint64_t HEAPMANAGERLARGEPAGECOUNT = 0x484541504d4c5043; //'HEAPMLPC' +constexpr uint64_t HEAPMANAGERLARGEPAGEMAX = 0x484541504d4c504d; //'HEAPMLPM' +constexpr uint64_t HEAPMANAGERSMALLPAGECOUNT = 0x484541504d535043; //'HEAPMSPC' +constexpr uint64_t HEAPMANAGERCOALESCECOUNT = 0x484541504d434e54; //'HEAPMCNT' +constexpr uint64_t HEAPMANAGERFREEBYTES = 0x4845415042595445; //'HEAPBYTE' +constexpr uint64_t HEAPMANAGERFREECHUNKS = 0x4845415043484e4b; //'HEAPCHNK' +constexpr uint64_t PAGEMANAGER = 0x504147454d475220; //'PAGEMGR ' +constexpr uint64_t PAGEMANAGERCOALESCECOUNT = 0x504147454d434e54; //'PAGEMCNT' +constexpr uint64_t PAGEMANAGERLOWPAGECOUNT = 0x504147454d4c5043; //'PAGEMLPC' +constexpr uint64_t SEGMENTMANAGER = 0x53474d4e544d4752; //'SGMNTMGR' +constexpr uint64_t BLOCKREADONLYEVICT = 0x424c4f434b524f45; //'BLOCKROE' +constexpr uint64_t BLOCKREADWRITEEVICT = 0x424c4f434b525745; //'BLOCKRWE' +// Number of values cannot exceed MAX_ENTRIES + + +/* + * @brief Save off a pointer to the master list + * + * @param[in] Pointer Label + * @param[in] Pointer Value + */ +void add_debug_pointer( uint64_t i_label, + void* i_ptr, + size_t i_size ); + +}; //namespace + + +#endif //_DEBUGPOINTERS_H diff --git a/src/kernel/block.C b/src/kernel/block.C index ecb11ff0c..b80db2aac 100644 --- a/src/kernel/block.C +++ b/src/kernel/block.C @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2014 */ +/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* [+] International Business Machines Corp. */ +/* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ @@ -42,6 +44,7 @@ #include <usr/vmmconst.h> #include <new> +#include <usr/debugpointers.H> // Track eviction requests due to aging pages uint32_t Block::cv_ro_evict_req = 0; @@ -708,3 +711,13 @@ void Block::releaseSPTE(ShadowPTE* i_pte) i_pte->setPageAddr(NULL); } + +void Block::addDebugPointers() +{ + DEBUG::add_debug_pointer(DEBUG::BLOCKREADONLYEVICT, + &cv_ro_evict_req, + sizeof(cv_ro_evict_req)); + DEBUG::add_debug_pointer(DEBUG::BLOCKREADWRITEEVICT, + &cv_rw_evict_req, + sizeof(cv_rw_evict_req)); +} diff --git a/src/kernel/heapmgr.C b/src/kernel/heapmgr.C index b473eb05c..643774f52 100644 --- a/src/kernel/heapmgr.C +++ b/src/kernel/heapmgr.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2010,2017 */ +/* Contributors Listed Below - COPYRIGHT 2010,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -30,6 +30,7 @@ #include <kernel/pagemgr.H> #include <util/align.H> #include <arch/ppc.H> +#include <usr/debugpointers.H> #ifdef HOSTBOOT_DEBUG #define SMALL_HEAP_PAGES_TRACKED 64 @@ -75,6 +76,11 @@ void HeapManager::init() Singleton<HeapManager>::instance(); } +void HeapManager::addDebugPointers() +{ + Singleton<HeapManager>::instance()._addDebugPointers(); +} + void * HeapManager::allocate(size_t i_sz) { HeapManager& hmgr = Singleton<HeapManager>::instance(); @@ -622,3 +628,28 @@ bool HeapManager::_freeBig(void* i_ptr) return result; } +void HeapManager::_addDebugPointers() +{ + DEBUG::add_debug_pointer(DEBUG::HEAPMANAGER, + this, + sizeof(HeapManager)); + DEBUG::add_debug_pointer(DEBUG::HEAPMANAGERLARGEPAGECOUNT, + &cv_largeheap_page_count, + sizeof(HeapManager::cv_largeheap_page_count)); + DEBUG::add_debug_pointer(DEBUG::HEAPMANAGERLARGEPAGEMAX, + &cv_largeheap_page_max, + sizeof(HeapManager::cv_largeheap_page_max)); + DEBUG::add_debug_pointer(DEBUG::HEAPMANAGERSMALLPAGECOUNT, + &cv_smallheap_page_count, + sizeof(HeapManager::cv_smallheap_page_count)); + DEBUG::add_debug_pointer(DEBUG::HEAPMANAGERCOALESCECOUNT, + &cv_coalesce_count, + sizeof(HeapManager::cv_coalesce_count)); + DEBUG::add_debug_pointer(DEBUG::HEAPMANAGERFREEBYTES, + &cv_free_bytes, + sizeof(HeapManager::cv_free_bytes)); + DEBUG::add_debug_pointer(DEBUG::HEAPMANAGERFREECHUNKS, + &cv_free_chunks, + sizeof(HeapManager::cv_free_chunks)); +} + diff --git a/src/kernel/kernel.C b/src/kernel/kernel.C index e78dca726..da9470546 100644 --- a/src/kernel/kernel.C +++ b/src/kernel/kernel.C @@ -41,13 +41,16 @@ #include <securerom/sha512.H> #include <kernel/bltohbdatamgr.H> #include <kernel/cpuid.H> +#include <usr/debugpointers.H> +#include <kernel/segmentmgr.H> +#include <kernel/block.H> #include <stdlib.h> extern "C" void kernel_dispatch_task(); extern void* init_main(void* unused); extern uint64_t kernel_other_thread_spinlock; - +extern char hbi_ImageId[]; class Kernel { @@ -101,7 +104,8 @@ const Bootloader::BlToHbData* getBlToHbData() extern "C" int main() { - printk("Booting %s kernel...\n\n", "Hostboot"); + printk("Booting %s kernel...\n", "Hostboot"); + printk("%s\n\n", hbi_ImageId); printk("CPU=%s PIR=%ld\n", ProcessorCoreTypeStrings[CpuID::getCpuType()], static_cast<uint64_t>(getPIR())); @@ -135,6 +139,18 @@ int main() // Let FSP/BMC know that Hostboot is now running KernelMisc::setHbScratchStatus(KernelMisc::HB_RUNNING); + // Initialize the debug pointer area + debug_pointers = new DEBUG::DebugPointers_t(); + DEBUG::add_debug_pointer(DEBUG::PRINTK, + kernel_printk_buffer, + sizeof(kernel_printk_buffer)); + printk("Debug @ %p\n", debug_pointers); + HeapManager::addDebugPointers(); + PageManager::addDebugPointers(); + TaskManager::addDebugPointers(); + SegmentManager::addDebugPointers(); + Block::addDebugPointers(); + kernel.inittaskBootstrap(); // Ready to let the other CPUs go. @@ -193,3 +209,34 @@ void Kernel::inittaskBootstrap() TaskManager::setCurrentTask(t); } + +namespace DEBUG +{ +void add_debug_pointer( uint64_t i_label, + void* i_ptr, + size_t i_size ) +{ + if( debug_pointers != nullptr ) + { + for( auto i = 0; i < MAX_ENTRIES; i++ ) + { + if( 0 == ((DebugPointers_t*)debug_pointers)->pairs[i].label_num ) + { + ((DebugPointers_t*)debug_pointers)->pairs[i].label_num + = i_label; + ((DebugPointers_t*)debug_pointers)->pairs[i].pointer = + (uint32_t)((uint64_t)i_ptr); //using forced cast on purpose + ((DebugPointers_t*)debug_pointers)->pairs[i].size = + static_cast<uint32_t>(i_size); + break; + } + } + } + else + { + printk("No debug pointer set for %.16lX\n",i_label); + MAGIC_INSTRUCTION(MAGIC_BREAK); + } + //NOTE: This is called by kernel code so do not add any traces +} +}; diff --git a/src/kernel/pagemgr.C b/src/kernel/pagemgr.C index 42545470a..bfc1bbf7a 100644 --- a/src/kernel/pagemgr.C +++ b/src/kernel/pagemgr.C @@ -38,6 +38,7 @@ #include <kernel/memstate.H> #include <kernel/bltohbdatamgr.H> #include <kernel/misc.H> +#include <usr/debugpointers.H> size_t PageManager::cv_coalesce_count = 0; @@ -205,6 +206,11 @@ uint64_t PageManager::availPages() return Singleton<PageManager>::instance()._availPages(); } +void PageManager::addDebugPointers() +{ + return Singleton<PageManager>::instance()._addDebugPointers(); +} + PageManager::PageManager() : iv_pagesAvail(0), iv_pagesTotal(0), iv_lock() { @@ -478,3 +484,16 @@ void PageManager::_addMemory(size_t i_addr, size_t i_pageCount) return; } + +void PageManager::_addDebugPointers() +{ + DEBUG::add_debug_pointer(DEBUG::PAGEMANAGER, + this, + sizeof(PageManager)); + DEBUG::add_debug_pointer(DEBUG::PAGEMANAGERLOWPAGECOUNT, + &PageManager::cv_low_page_count, + sizeof(PageManager::cv_low_page_count)); + DEBUG::add_debug_pointer(DEBUG::PAGEMANAGERCOALESCECOUNT, + &PageManager::cv_coalesce_count, + sizeof(PageManager::cv_coalesce_count)); +} diff --git a/src/kernel/segmentmgr.C b/src/kernel/segmentmgr.C index 73caaf76f..9cf88de90 100644 --- a/src/kernel/segmentmgr.C +++ b/src/kernel/segmentmgr.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ +/* Contributors Listed Below - COPYRIGHT 2011,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -31,6 +31,7 @@ #include <kernel/segmentmgr.H> #include <kernel/segment.H> #include <kernel/devicesegment.H> +#include <usr/debugpointers.H> bool SegmentManager::handlePageFault(task_t* i_task, uint64_t i_addr, bool i_store) @@ -77,6 +78,11 @@ int SegmentManager::devUnmap(void* ea) return Singleton<SegmentManager>::instance()._devUnmap(ea); } +void SegmentManager::addDebugPointers() +{ + Singleton<SegmentManager>::instance()._addDebugPointers(); +} + bool SegmentManager::_handlePageFault(task_t* i_task, uint64_t i_addr, bool i_store) { @@ -200,4 +206,9 @@ int SegmentManager::_devUnmap(void* ea) return reinterpret_cast<DeviceSegment*>(iv_segments[segId])->devUnmap(ea); } - +void SegmentManager::_addDebugPointers() +{ + DEBUG::add_debug_pointer(DEBUG::SEGMENTMANAGER, + this, + sizeof(SegmentManager)); +} diff --git a/src/kernel/start.S b/src/kernel/start.S index 979235276..1e2b53cd6 100644 --- a/src/kernel/start.S +++ b/src/kernel/start.S @@ -276,6 +276,14 @@ kernel_descriptor: .byte 'H', 'O', 'S', 'T', 'B', 'O', 'O', 'T' .quad kernel_hbDescriptor +;// Hostboot debug pointers. +;// +;// This points to a table of pointers to be used by the debug tools +;// See debugpointers.H for details +.global debug_pointers +debug_pointers: + .space 8 + ;// _main: ;// Set up stack and TOC and call kernel's main. diff --git a/src/kernel/taskmgr.C b/src/kernel/taskmgr.C index 03b3d0073..274ad42cc 100644 --- a/src/kernel/taskmgr.C +++ b/src/kernel/taskmgr.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2010,2015 */ +/* Contributors Listed Below - COPYRIGHT 2010,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -36,6 +36,7 @@ #include <string.h> #include <limits.h> #include <assert.h> +#include <usr/debugpointers.H> extern "C" void userspace_task_entry(); extern "C" void task_end_stub(); @@ -80,6 +81,11 @@ void TaskManager::waitTask(task_t* t, int64_t tid, int* status, void** retval) Singleton<TaskManager>::instance()._waitTask(t,tid,status,retval); } +void TaskManager::addDebugPointers() +{ + Singleton<TaskManager>::instance()._addDebugPointers(); +} + task_t* TaskManager::_createIdleTask() { return this->_createTask(&TaskManager::idleTaskLoop, NULL, false, true); @@ -373,3 +379,10 @@ void TaskManager::removeTracker(task_tracking_t* t) // Delete tracker object. delete t; } + +void TaskManager::_addDebugPointers() +{ + DEBUG::add_debug_pointer(DEBUG::TASKMANAGER, + this, + sizeof(TaskManager)); +} diff --git a/src/usr/errl/errlmanager.C b/src/usr/errl/errlmanager.C index 4476640f7..d3dd871aa 100644 --- a/src/usr/errl/errlmanager.C +++ b/src/usr/errl/errlmanager.C @@ -54,6 +54,7 @@ #include <functional> #include <hwas/common/deconfigGard.H> #include <kernel/terminate.H> +#include <debugpointers.H> namespace ERRORLOG { @@ -153,6 +154,10 @@ ErrlManager::ErrlManager() : l_pMarker->length = 0; #endif + DEBUG::add_debug_pointer(DEBUG::ERRORLOGS, + &g_ErrlStorage, + 4); + // to determine the starting log ID, we need to do this in 2 steps // first, determine our node // BYTE 0 of the PLID is the ID: 0x9# where # is the node instance. diff --git a/src/usr/trace/daemon/daemon.C b/src/usr/trace/daemon/daemon.C index a7e895b0a..8ebb24e74 100644 --- a/src/usr/trace/daemon/daemon.C +++ b/src/usr/trace/daemon/daemon.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* Contributors Listed Below - COPYRIGHT 2012,2018 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -50,6 +50,7 @@ #include <config.h> #include <console/consoleif.H> #include <util/utilmbox_scratch.H> +#include <debugpointers.H> namespace TRACE { @@ -75,6 +76,10 @@ namespace TRACEDAEMON Daemon::Daemon() : iv_service(NULL), iv_totalPruned(0) { iv_first = iv_last = BufferPage::allocate(true); + + DEBUG::add_debug_pointer(DEBUG::TRACEDAEMON, + this, + sizeof(TRACEDAEMON::Daemon)); } Daemon::~Daemon() diff --git a/src/usr/trace/service.C b/src/usr/trace/service.C index a3445c2ee..260f71e2b 100644 --- a/src/usr/trace/service.C +++ b/src/usr/trace/service.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2016 */ +/* Contributors Listed Below - COPYRIGHT 2012,2018 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -42,6 +42,7 @@ #include <stdio.h> #include <ctype.h> #include <util/sprintf.H> +#include <debugpointers.H> namespace TRACE @@ -55,6 +56,10 @@ namespace TRACE // initialize tracelite setting to off iv_traceLite = 0; + + DEBUG::add_debug_pointer(DEBUG::TRACESERVICE, + this, + sizeof(TRACE::Service)); } Service::~Service() |