[Cbe-oss-dev] [PATCH 1/2] libspe2: specific error reporting for isolated loader status

Jeremy Kerr jk at ozlabs.org
Fri Jul 6 17:21:44 EST 2007


LWG_RFC00025 defines a new set of stop-and-signal codes for errors.
This change implements LWG_RFC00025 by catching these stop-and-signal
codes, and populates the spe_stop_info structure appropriately.

Also, LWGRFC00025 defines ENODEV as a valid error code for spe_create,
so enable that here too.

Signed-off-by: Jeremy Kerr <jk at ozlabs.org>

---

 libspe2-types.h   |    2 ++
 spebase/create.c  |    4 +++-
 spebase/run.c     |   15 ++++++++++++++-
 spebase/spebase.h |    4 ++++
 4 files changed, 23 insertions(+), 2 deletions(-)

Index: libspe2/spebase/run.c
===================================================================
--- libspe2.orig/spebase/run.c
+++ libspe2/spebase/run.c
@@ -230,7 +230,14 @@ do_run:
 			/* Other fatal runtime error */
 			stopinfo->stop_reason = SPE_RUNTIME_FATAL;
 			stopinfo->result.spe_runtime_fatal = errno;
-			errno = EFAULT;
+
+			/* For isolated contexts, pass EPERM up to the
+			 * caller.
+			 */
+			if (!(spe->base_private->flags & SPE_ISOLATE
+					&& errno == EPERM))
+				errno = EFAULT;
+
 		}
 
 		freespeinfo();
@@ -301,6 +308,12 @@ do_run:
 				retval = -1;
 			}
 
+		} else if ((stopcode & 0xfff0) == SPE_PROGRAM_ISOLATED_STOP) {
+
+			stopinfo->stop_reason = SPE_ISOLATION_ERROR;
+			stopinfo->result.spe_isolation_error = stopcode & 0xf;
+			retval = -1;
+
 		} else if (spe->base_private->flags & SPE_ISOLATE &&
 				!(run_rc & 0x80)) {
 			/* We've successfully exited isolated mode */
Index: libspe2/spebase/spebase.h
===================================================================
--- libspe2.orig/spebase/spebase.h
+++ libspe2/spebase/spebase.h
@@ -125,6 +125,10 @@ struct spe_context_base_priv {
 #define SPE_PROGRAM_NORMAL_END		0x2000
 #define SPE_PROGRAM_LIBRARY_CALL	0x2100
 
+/**
+ * Isolated exit codes: 0x220x
+ */
+#define SPE_PROGRAM_ISOLATED_STOP	0x2200
 
 /**
  * spe_context: This holds the persistant information of a SPU instance
Index: libspe2/libspe2-types.h
===================================================================
--- libspe2.orig/libspe2-types.h
+++ libspe2/libspe2-types.h
@@ -124,6 +124,7 @@ typedef struct spe_stop_info {
 		int spe_runtime_exception; 
 		int spe_runtime_fatal;
 		int spe_callback_error;
+		int spe_isolation_error;
 		/* Reserved fields */
 		void *__reserved_ptr;
 		unsigned long long __reserved_u64;
@@ -191,6 +192,7 @@ enum ps_area { SPE_MSSYNC_AREA, SPE_MFC_
 #define SPE_RUNTIME_EXCEPTION	4
 #define SPE_RUNTIME_FATAL		5
 #define SPE_CALLBACK_ERROR		6
+#define SPE_ISOLATION_ERROR		7
 
 /**
  * Runtime errors
Index: libspe2/spebase/create.c
===================================================================
--- libspe2.orig/spebase/create.c
+++ libspe2/spebase/create.c
@@ -263,7 +263,9 @@ spe_context_ptr_t _base_spe_context_crea
 		DEBUG_PRINTF("ERROR: Could not create SPE %s\n", pathname);
 		perror("spu_create()");
 		free_spe_context(spe);
-		errno = EFAULT;
+		/* we mask most errors, but leave ENODEV */
+		if (errno != ENODEV)
+			errno = EFAULT;
 		return NULL;
 	}
 



More information about the cbe-oss-dev mailing list