[Pdbg] [PATCH v2 07/10] libpdbg/p9chip.c: correct thread start for inactive and stopped threads

Nicholas Piggin npiggin at gmail.com
Wed May 2 02:33:36 AEST 2018


Quiesced threads which are inactive or in stop state (idle stop) must
not be started with direct control core start operation otherwise they
will start executing past the stop instruction for example, which will
crash the host.

They are started from quiesce state by clearing maintainence mode.

Signed-off-by: Nicholas Piggin <npiggin at mgail.com>
---
 libpdbg/p9chip.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c
index 46ec0d9..3cc3dcb 100644
--- a/libpdbg/p9chip.c
+++ b/libpdbg/p9chip.c
@@ -115,7 +115,17 @@ static int p9_thread_probe(struct pdbg_target *target)
 
 static int p9_thread_start(struct thread *thread)
 {
-	thread_write(thread, P9_DIRECT_CONTROL, PPC_BIT(6 + 8*thread->id));
+	if (!(thread->status & THREAD_STATUS_QUIESCE))
+		return 1;
+
+	if ((!(thread->status & THREAD_STATUS_ACTIVE)) ||
+	    (thread->status & THREAD_STATUS_STOP)) {
+		/* Inactive or active ad stopped: Clear Maint */
+		thread_write(thread, P9_DIRECT_CONTROL, PPC_BIT(3 + 8*thread->id));
+	} else {
+		/* Active and not stopped: Start */
+		thread_write(thread, P9_DIRECT_CONTROL, PPC_BIT(6 + 8*thread->id));
+	}
 
 	return 0;
 }
-- 
2.17.0



More information about the Pdbg mailing list