diff options
author | Dan Crowell <dcrowell@us.ibm.com> | 2016-05-16 11:22:18 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2016-05-24 17:09:33 -0400 |
commit | 39c834621810eac50a7b34a94a90a840dcdb58d9 (patch) | |
tree | f215055b8565eebee4944aa5646925ad85336863 | |
parent | c518fff3c3a71c3a9944a4b2e8ca7ac776cd8eb1 (diff) | |
download | talos-hostboot-39c834621810eac50a7b34a94a90a840dcdb58d9.tar.gz talos-hostboot-39c834621810eac50a7b34a94a90a840dcdb58d9.zip |
Add simics breakpoint for exceptions
Created a new magic instruction handler that can be enabled via
environment variable to stop the simulation for Hostboot
exceptions. This is useful when we want to get a backtrace at
the failing spot without recompiling code or having to manually
insert breakpoints in simics directly.
Enable the function by setting HB_BREAK_ON_ERROR
The trigger call is MAGIC_BREAK_ON_ERROR
Change-Id: I17e008281d010e3f8c5e5817e5f30fd0ccb624d0
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/24600
Tested-by: Jenkins Server
Tested-by: FSP CI Jenkins
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Reviewed-by: Marshall J. Wilks <mjwilks@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
-rwxr-xr-x | src/build/debug/simics-debug-framework.py | 11 | ||||
-rw-r--r-- | src/include/arch/ppc.H | 4 | ||||
-rw-r--r-- | src/kernel/exception.C | 10 |
3 files changed, 21 insertions, 4 deletions
diff --git a/src/build/debug/simics-debug-framework.py b/src/build/debug/simics-debug-framework.py index 48a8d4818..cae13c134 100755 --- a/src/build/debug/simics-debug-framework.py +++ b/src/build/debug/simics-debug-framework.py @@ -485,9 +485,6 @@ except: # See src/include/arch/ppc.H for the definitions of the magic args. # Hostboot magic args should range 7000..7999. def magic_instruction_callback(user_arg, cpu, arg): - if arg == 7008: - cpu.r3 = random.randint(1, 0xffffffffffffffffL) - if arg == 7006: # MAGIC_SHUTDOWN # KernelMisc::shutdown() print "KernelMisc::shutdown() called." @@ -499,6 +496,9 @@ 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: + cpu.r3 = random.randint(1, 0xffffffffffffffffL) + if arg == 7009: # MAGIC_MEMORYLEAK_FUNCTION magic_memoryleak_function(cpu) @@ -552,6 +552,11 @@ def magic_instruction_callback(user_arg, cpu, arg): enableCore1 = "%s; %s; %s; %s"%(enable4,enable5,enable6,enable7) SIM_run_alone(run_command, enableCore1 ) + 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') ): + SIM_break_simulation( "Stopping sim on HB error. (hap 7018)" ) + if arg == 7055: # MAGIC_CONTINUOUS_TRACE hb_tracBinaryBuffer = cpu.r4 hb_tracBinaryBufferSz = cpu.r5 diff --git a/src/include/arch/ppc.H b/src/include/arch/ppc.H index 455728500..7e8b768c2 100644 --- a/src/include/arch/ppc.H +++ b/src/include/arch/ppc.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ +/* Contributors Listed Below - COPYRIGHT 2011,2016 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -466,6 +466,8 @@ enum MAGIC_WAKE_MASTER_THREAD = 7015, // Wake master thread MAGIC_WAKE_OTHER_THREADS = 7016, // Wake other threads on initial CORE MAGIC_WAKE_FUSED_THREADS = 7017, // Wake up fused core threads + MAGIC_BREAK_ON_ERROR = 7018, // Breakpoint in error cases if + // env var HB_BREAK_ON_ERROR MAGIC_CONTINUOUS_TRACE = 7055, // extract mixed trace buffer }; diff --git a/src/kernel/exception.C b/src/kernel/exception.C index 686d3012c..5b891ff63 100644 --- a/src/kernel/exception.C +++ b/src/kernel/exception.C @@ -63,6 +63,7 @@ void kernel_execute_prog_ex() if (!handled) { printk("Program exception, killing task %d\n", t->tid); + MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR); TaskManager::endTask(t, NULL, TASK_STATUS_CRASHED); } } @@ -102,6 +103,7 @@ void kernel_execute_data_storage() { printk("Data Storage exception on %d: %lx, %lx @ %p\n", t->tid, getDAR(), getDSISR(), t->context.nip); + MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR); TaskManager::endTask(t, NULL, TASK_STATUS_CRASHED); } } @@ -112,6 +114,7 @@ void kernel_execute_data_segment() task_t* t = TaskManager::getCurrentTask(); printk("Data Segment exception on %d: %lx @ %p\n", t->tid, getDAR(), t->context.nip); + MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR); TaskManager::endTask(t, NULL, TASK_STATUS_CRASHED); } @@ -135,6 +138,7 @@ void kernel_execute_inst_storage() { printk("Inst Storage exception on %d: %lx, %lx\n", t->tid, getSRR0(), getSRR1()); + MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR); TaskManager::endTask(t, NULL, TASK_STATUS_CRASHED); } } @@ -144,6 +148,7 @@ void kernel_execute_inst_segment() { task_t* t = TaskManager::getCurrentTask(); printk("Inst Segment exception on %d: %p\n", t->tid, t->context.nip); + MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR); TaskManager::endTask(t, NULL, TASK_STATUS_CRASHED); } @@ -152,6 +157,7 @@ void kernel_execute_alignment() { task_t* t = TaskManager::getCurrentTask(); printk("Alignment exception, killing task %d\n", t->tid); + MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR); TaskManager::endTask(t, NULL, TASK_STATUS_CRASHED); } @@ -161,6 +167,7 @@ void kernel_execute_hype_emu_assist() task_t* t = TaskManager::getCurrentTask(); printk("HypeEmu: Illegal instruction in task %d\n" "\tHSSR0 = %lx, HEIR = %lx\n", t->tid, getHSRR0(), getHEIR()); + MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR); TaskManager::endTask(t, NULL, TASK_STATUS_CRASHED); } @@ -311,6 +318,7 @@ void kernel_execute_machine_check() "\tDSISR = %lx, DAR = %lx\n", t->tid, getPIR(), getSRR0(), getSRR1(), getDSISR(), getDAR()); + MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR); kassert(false); } @@ -366,6 +374,7 @@ void kernel_execute_machine_check() "\tDSISR = %lx, DAR = %lx\n", t->tid, getPIR(), getSRR0(), getSRR1(), getDSISR(), getDAR()); + MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR); TaskManager::endTask(t, NULL, TASK_STATUS_CRASHED); } } @@ -388,6 +397,7 @@ void kernel_execute_unhandled_exception() printk("Unhandled exception %lx by task %d @ %p\n", exception, t->tid, t->context.nip); + MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR); termWriteSRC(TI_UNHANDLED_EX, RC_UNHANDLED_EX, exception); terminateExecuteTI(); |