1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
From 356b7e781c815c70c992d58360caa42f1776d06b Mon Sep 17 00:00:00 2001
From: Alex Busenius <s9albuse@stud.uni-saarland.de>
Date: Mon, 27 Apr 2009 17:09:27 +0200
Subject: bochs-2.3.7 triple fault
---
cpu/cpu.h | 4 ++++
cpu/exception.cc | 7 +++++++
gdbstub.cc | 11 ++++++++---
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/cpu/cpu.h b/cpu/cpu.h
index 7c7b11b..c47133a 100644
--- a/cpu/cpu.h
+++ b/cpu/cpu.h
@@ -903,6 +903,10 @@ public: // for now...
#endif
Bit8u trace;
+#if BX_GDBSTUB
+ Bit8u ispanic;
+#endif
+
// for paging
struct {
bx_TLB_entry entry[BX_TLB_SIZE] BX_CPP_AlignN(16);
diff --git a/cpu/exception.cc b/cpu/exception.cc
index c3e3777..fb3abfc 100644
--- a/cpu/exception.cc
+++ b/cpu/exception.cc
@@ -856,6 +856,13 @@ void BX_CPU_C::exception(unsigned vector, Bit16u error_code, bx_bool trap)
// trap into debugger (similar as done when PANIC occured)
bx_debug_break();
#endif
+#if BX_GDBSTUB
+ if (bx_dbg.gdbstub_enabled) {
+ fprintf(stderr, "Triple fault: stopping for gdb\n");
+ BX_CPU_THIS_PTR ispanic = 1;
+ longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1);
+ }
+#endif
if (SIM->get_param_bool(BXPN_RESET_ON_TRIPLE_FAULT)->get()) {
BX_ERROR(("exception(): 3rd (%d) exception with no resolution, shutdown status is %02xh, resetting", vector, DEV_cmos_get_reg(0x0f)));
bx_pc_system.Reset(BX_RESET_SOFTWARE);
diff --git a/gdbstub.cc b/gdbstub.cc
index f58f866..bc5ed61 100644
--- a/gdbstub.cc
+++ b/gdbstub.cc
@@ -471,7 +471,12 @@ static void debug_loop(void)
}
stub_trace_flag = 0;
+ bx_cpu.ispanic = 0;
bx_cpu.cpu_loop(0);
+ if (bx_cpu.ispanic)
+ {
+ last_stop_reason = GDBSTUB_EXECUTION_BREAKPOINT;
+ }
DEV_vga_refresh();
@@ -502,19 +507,19 @@ static void debug_loop(void)
BX_INFO(("stepping"));
stub_trace_flag = 1;
+ bx_cpu.ispanic = 0;
bx_cpu.cpu_loop(0);
DEV_vga_refresh();
stub_trace_flag = 0;
BX_INFO(("stopped with %x", last_stop_reason));
buf[0] = 'S';
- if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT ||
- last_stop_reason == GDBSTUB_TRACE)
+ if (last_stop_reason == GDBSTUB_TRACE && !bx_cpu.ispanic)
{
write_signal(&buf[1], SIGTRAP);
}
else
{
- write_signal(&buf[1], SIGTRAP);
+ write_signal(&buf[1], SIGSEGV);
}
put_reply(buf);
break;
--
1.6.2.3
|