Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode/usermode Implement md_check_syscall_opcode...



details:   https://anonhg.NetBSD.org/src/rev/53f28fa45b7d
branches:  trunk
changeset: 769400:53f28fa45b7d
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Thu Sep 08 15:10:59 2011 +0000

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

diffstat:

 sys/arch/usermode/usermode/machdep.c |  28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)

diffs (65 lines):

diff -r 217f0c8c74eb -r 53f28fa45b7d sys/arch/usermode/usermode/machdep.c
--- a/sys/arch/usermode/usermode/machdep.c      Thu Sep 08 14:49:42 2011 +0000
+++ b/sys/arch/usermode/usermode/machdep.c      Thu Sep 08 15:10:59 2011 +0000
@@ -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 <reinoud%netbsd.org@localhost>
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
  * 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



Home | Main Index | Thread Index | Old Index