Module Name:    src
Committed By:   reinoud
Date:           Thu Sep  8 15:10:59 UTC 2011

Modified Files:
        src/sys/arch/usermode/usermode: machdep.c

Log Message:
Implement md_check_syscall_opcode() to check if the instruction at the pointer
`ptr' is indeed a syscall entry.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/usermode/usermode/machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/usermode/usermode/machdep.c
diff -u src/sys/arch/usermode/usermode/machdep.c:1.25 src/sys/arch/usermode/usermode/machdep.c:1.26
--- src/sys/arch/usermode/usermode/machdep.c:1.25	Wed Sep  7 10:10:10 2011
+++ src/sys/arch/usermode/usermode/machdep.c	Thu Sep  8 15:10:59 2011
@@ -1,6 +1,7 @@
-/* $NetBSD: machdep.c,v 1.25 2011/09/07 10:10:10 reinoud Exp $ */
+/* $NetBSD: machdep.c,v 1.26 2011/09/08 15:10:59 reinoud Exp $ */
 
 /*-
+ * Copyright (c) 2011 Reinoud Zandijk <[email protected]>
  * Copyright (c) 2007 Jared D. McNeill <[email protected]>
  * All rights reserved.
  *
@@ -31,7 +32,7 @@
 #include "opt_urkelvisor.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.25 2011/09/07 10:10:10 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.26 2011/09/08 15:10:59 reinoud Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -46,7 +47,7 @@
 #include <uvm/uvm_page.h>
 
 #include <dev/mm.h>
-
+#include <machine/machdep.h>
 #include <machine/thunk.h>
 
 #if defined(URKELVISOR)
@@ -57,7 +58,7 @@
 char machine_arch[] = "usermode";
 
 /* XXX */
-int		physmem = MEMSIZE * 1024 / PAGE_SIZE;
+int	physmem = MEMSIZE * 1024 / PAGE_SIZE;
 
 static char **saved_argv;
 char *usermode_root_image_path = NULL;
@@ -214,6 +215,25 @@
 }
 
 
+int
+md_check_syscall_opcode(void *ptr)
+{
+//	uint8_t  *p8;
+	uint16_t *p16;
+//	uint32_t *p32;
+
+	/* undefined instruction */
+	p16 = (uint16_t *) ptr;
+	if (*p16 == 0xff0f)
+		return 1;
+	if (*p16 == 0xff0b)
+		return 1;
+
+	/* TODO int $80 and sysenter */
+	return 0;
+}
+
+
 #else
 #	error setregs() not yet ported to this architecture
 #endif

Reply via email to