From 4198ffbc2ae5404b05baff55be8e6f39578389cc Mon Sep 17 00:00:00 2001 From: Dan Crowell Date: Wed, 18 Dec 2019 08:33:09 -0600 Subject: Force a Hostboot dump on any TI in Simics Execute a magic instruction in the TI path to force a hostboot dump to be collected on any TI while running in Simics. Change-Id: I8aeffb2b646bbe8480568e8af33a658400fa01a5 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/88831 Reviewed-by: Nicholas E Bofferding Reviewed-by: Matt Derksen Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: William G Hoffa --- src/build/debug/Hostboot/Dump.pm | 14 +++++++++++--- src/build/debug/simics-debug-framework.py | 18 +++++++++++++++++- src/include/arch/ppc.H | 1 + src/kernel/terminate.C | 4 ++++ 4 files changed, 33 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/build/debug/Hostboot/Dump.pm b/src/build/debug/Hostboot/Dump.pm index 705638aa2..90b445df9 100755 --- a/src/build/debug/Hostboot/Dump.pm +++ b/src/build/debug/Hostboot/Dump.pm @@ -6,7 +6,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2012,2018 +# Contributors Listed Below - COPYRIGHT 2012,2019 # [+] International Business Machines Corp. # # @@ -106,6 +106,13 @@ sub main $debug = 1; } + # Parse 'quiet' option. + my $quiet = 0; + if (defined $args->{"quiet"}) + { + $quiet = 1; + } + # Check for a different output directory my $outdir = "./"; if (defined $args->{"outdir"}) @@ -128,7 +135,7 @@ sub main open( OUTFH, ">$hbDumpFile" ) or die "can't open $hbDumpFile: $!\n"; binmode(OUTFH); - ::userDisplay "Using HRMOR=". ::getHRMOR() . "\n"; + ::userDisplay "Using HRMOR=". sprintf("0x%X",::getHRMOR()) . "\n"; # Read memory regions and output to file. foreach my $state (@{$memory_states{int $memstate}}) @@ -152,7 +159,7 @@ sub main $curlength = $length_remaining; } - ::userDisplay (sprintf "...%x@%x\n", $curlength, $curstart); + ::userDisplay (sprintf "...%x@%x\n", $curlength, $curstart) if !$quiet; my $data = ::readData($curstart, $curlength); seek OUTFH, $curstart, SEEK_SET; @@ -187,6 +194,7 @@ sub helpInfo options => { "outdir=" => ["Output directory for dump file"], "debug" => ["More debug output."], + "quiet" => ["Less output."], }, ); } diff --git a/src/build/debug/simics-debug-framework.py b/src/build/debug/simics-debug-framework.py index 69465da3f..fd90806bb 100644 --- a/src/build/debug/simics-debug-framework.py +++ b/src/build/debug/simics-debug-framework.py @@ -516,7 +516,7 @@ def magic_instruction_callback(user_arg, cpu, arg): # Stop the simulation, much like a hard-coded breakpoint SIM_break_simulation( "Simulation stopped. (hap 7007)" ) - if arg == 7008: + if arg == 7008: # MAGIC_RANDOM cpu.r3 = random.randint(1, 0xffffffffffffffffL) if arg == 7009: # MAGIC_MEMORYLEAK_FUNCTION @@ -525,6 +525,10 @@ def magic_instruction_callback(user_arg, cpu, arg): if arg == 7011: #MAGIC_SIMICS_CHECK cpu.r3 = 1 print "TimeManager::cv_isSimicsRunning = true" + # Clear the dump flag in case it was still set from a previous boot + # (this call happens only 1 time and it is very early in the boot) + if( os.environ.has_key('HB_DUMP_COMPLETE') ): + del os.environ['HB_DUMP_COMPLETE'] if arg == 7012: # MAGIC_LOAD_PAYLOAD #For P9 the Payload load is much faster due to PNOR @@ -537,6 +541,17 @@ def magic_instruction_callback(user_arg, cpu, arg): #SIM_run_alone( run_command, cmd ) print "MAGIC_LOAD_PAYLOAD not implemented\n"; + if arg == 7014: # MAGIC_HB_DUMP + # Collect a hostboot dump + # (no args) + + # Make sure we only do 1 dump even though every thread will TI + if( not os.environ.has_key('HB_DUMP_COMPLETE') ): + print "Generating Hostboot Dump for TI" + os.environ['HB_DUMP_COMPLETE']="1" + cmd1 = "hb-Dump quiet" + SIM_run_alone(run_command, cmd1 ) + if arg == 7018: # MAGIC_BREAK_ON_ERROR # Stop the simulation if an env var is set if( os.environ.has_key('HB_BREAK_ON_ERROR') ): @@ -573,6 +588,7 @@ def magic_instruction_callback(user_arg, cpu, arg): percent_s = "%s" dateCommand = "shell \" date +'%s > TRACE REGS: %d %d' \""%(percent_s,first_num,second_num) SIM_run_alone(run_command, dateCommand ) + if arg == 7022: # MAGIC_SET_LOG_LEVEL if( not os.environ.has_key('ENABLE_HB_SIMICS_LOGS') ): #print("Skipping Hostboot Simics Logging because ENABLE_HB_SIMICS_LOGS is not set") diff --git a/src/include/arch/ppc.H b/src/include/arch/ppc.H index a6c60be9e..b9b8df7ee 100644 --- a/src/include/arch/ppc.H +++ b/src/include/arch/ppc.H @@ -523,6 +523,7 @@ enum MAGIC_FAKEPAYLOAD_ENTER = 7010, // Entered the fake payload. MAGIC_SIMICS_CHECK = 7011, // Check if system is running on simics MAGIC_LOAD_PAYLOAD = 7012, // load payload from flash + MAGIC_HB_DUMP = 7014, // Create a hostboot dump MAGIC_BREAK_ON_ERROR = 7018, // Breakpoint in error cases if // env var HB_BREAK_ON_ERROR MAGIC_GET_SBE_TRACES = 7019, // Collect SBE traces diff --git a/src/kernel/terminate.C b/src/kernel/terminate.C index fb3e1d069..308e52b2e 100644 --- a/src/kernel/terminate.C +++ b/src/kernel/terminate.C @@ -27,6 +27,7 @@ #include #include #include +#include #ifndef BOOTLOADER #include #include @@ -56,6 +57,9 @@ HB_Descriptor kernel_hbDescriptor = void terminateExecuteTI() { + // Trigger a hostboot dump in Simics + MAGIC_INSTRUCTION(MAGIC_HB_DUMP); + // Call the function that actually executes the TI code. p9_force_attn(); } -- cgit v1.2.1