CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: skrll Date: Wed Feb 5 07:18:16 UTC 2020 Modified Files: src/sys/arch/usermode/dev: if_veth.c Log Message: Adopt To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/usermode/dev/if_veth.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/dev/if_veth.c diff -u src/sys/arch/usermode/dev/if_veth.c:1.13 src/sys/arch/usermode/dev/if_veth.c:1.14 --- src/sys/arch/usermode/dev/if_veth.c:1.13 Wed May 29 10:07:29 2019 +++ src/sys/arch/usermode/dev/if_veth.c Wed Feb 5 07:18:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_veth.c,v 1.13 2019/05/29 10:07:29 msaitoh Exp $ */ +/* $NetBSD: if_veth.c,v 1.14 2020/02/05 07:18:16 skrll Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.13 2019/05/29 10:07:29 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.14 2020/02/05 07:18:16 skrll Exp $"); #include #include @@ -225,14 +225,14 @@ veth_softrx(void *priv) MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { vethprintf("MGETHDR failed (input error)\n"); - ++ifp->if_ierrors; + if_statinc(ifp, if_ierrors); continue; } if (len > MHLEN) { MCLGET(m, M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_freem(m); -++ifp->if_ierrors; +if_statinc(ifp, if_ierrors); vethprintf("M_EXT not set (input error)\n"); continue; } @@ -297,9 +297,9 @@ veth_start(struct ifnet *ifp) m0->m_pkthdr.len); vethprintf("write returned %d\n", len); if (len > 0) - ++ifp->if_opackets; + if_statinc(ifp, if_opackets); else - ++ifp->if_oerrors; + if_statinc(ifp, if_oerrors); m_freem(m0); } } @@ -316,7 +316,7 @@ static void veth_watchdog(struct ifnet *ifp) { vethprintf("%s: %s flags=%x\n", __func__, ifp->if_xname, ifp->if_flags); - ++ifp->if_oerrors; + if_statinc(ifp, if_oerrors); veth_init(ifp); }
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: thorpej Date: Wed Apr 10 04:10:54 UTC 2019 Modified Files: src/sys/arch/usermode/include: types.h src/sys/arch/usermode/usermode: copy.c Log Message: Make the usermode kernel compile again. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/usermode/include/types.h cvs rdiff -u -r1.10 -r1.11 src/sys/arch/usermode/usermode/copy.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/include/types.h diff -u src/sys/arch/usermode/include/types.h:1.15 src/sys/arch/usermode/include/types.h:1.16 --- src/sys/arch/usermode/include/types.h:1.15 Sat Apr 6 03:06:28 2019 +++ src/sys/arch/usermode/include/types.h Wed Apr 10 04:10:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.15 2019/04/06 03:06:28 thorpej Exp $ */ +/* $NetBSD: types.h,v 1.16 2019/04/10 04:10:53 thorpej Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -94,6 +94,5 @@ typedef register_t __register_t; #define __HAVE_CPU_LWP_SETPRIVATE #define __HAVE_MM_MD_KERNACC #define __HAVE_COMPAT_NETBSD32 -#define __HAVE_UCAS_FULL #endif /* !_USERMODE_TYPES_H_ */ Index: src/sys/arch/usermode/usermode/copy.c diff -u src/sys/arch/usermode/usermode/copy.c:1.10 src/sys/arch/usermode/usermode/copy.c:1.11 --- src/sys/arch/usermode/usermode/copy.c:1.10 Wed Apr 10 03:39:34 2019 +++ src/sys/arch/usermode/usermode/copy.c Wed Apr 10 04:10:54 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: copy.c,v 1.10 2019/04/10 03:39:34 msaitoh Exp $ */ +/* $NetBSD: copy.c,v 1.11 2019/04/10 04:10:54 thorpej Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: copy.c,v 1.10 2019/04/10 03:39:34 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: copy.c,v 1.11 2019/04/10 04:10:54 thorpej Exp $"); #define __UFETCHSTORE_PRIVATE #define __UCAS_PRIVATE @@ -97,20 +97,6 @@ kcopy(const void *src, void *dst, size_t } int -_ucas_32(volatile uint32_t *uaddr, uint32_t old, uint32_t new, uint32_t *ret) -{ - *ret = atomic_cas_32(uaddr, old, new); -} - -#ifdef _LP64 -int -_ucas_64(volatile uint64_t *uaddr, uint64_t old, uint64_t new, uint64_t *ret) -{ - *ret = atomic_cas_64(uaddr, old, new); -} -#endif /* _LP64 */ - -int _ufetch_8(const uint8_t *uaddr, uint8_t *valp) { *valp = *uaddr;
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: msaitoh Date: Wed Apr 10 03:39:34 UTC 2019 Modified Files: src/sys/arch/usermode/usermode: copy.c Log Message: Add missing semicolon. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/usermode/copy.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/copy.c diff -u src/sys/arch/usermode/usermode/copy.c:1.9 src/sys/arch/usermode/usermode/copy.c:1.10 --- src/sys/arch/usermode/usermode/copy.c:1.9 Sat Apr 6 03:06:28 2019 +++ src/sys/arch/usermode/usermode/copy.c Wed Apr 10 03:39:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: copy.c,v 1.9 2019/04/06 03:06:28 thorpej Exp $ */ +/* $NetBSD: copy.c,v 1.10 2019/04/10 03:39:34 msaitoh Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: copy.c,v 1.9 2019/04/06 03:06:28 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: copy.c,v 1.10 2019/04/10 03:39:34 msaitoh Exp $"); #define __UFETCHSTORE_PRIVATE #define __UCAS_PRIVATE @@ -114,21 +114,21 @@ int _ufetch_8(const uint8_t *uaddr, uint8_t *valp) { *valp = *uaddr; - return 0 + return 0; } int _ufetch_16(const uint16_t *uaddr, uint16_t *valp) { *valp = *uaddr; - return 0 + return 0; } int _ufetch_32(const uint32_t *uaddr, uint32_t *valp) { *valp = *uaddr; - return 0 + return 0; } #ifdef _LP64 @@ -136,7 +136,7 @@ int _ufetch_64(const uint64_t *uaddr, uint64_t *valp) { *valp = *uaddr; - return 0 + return 0; } #endif /* _LP64 */ @@ -144,21 +144,21 @@ int _ustore_8(uint8_t *uaddr, uint8_t val) { *uaddr = val; - return 0 + return 0; } int _ustore_16(uint16_t *uaddr, uint16_t val) { *uaddr = val; - return 0 + return 0; } int _ustore_32(uint32_t *uaddr, uint32_t val) { *uaddr = val; - return 0 + return 0; } #ifdef _LP64 @@ -166,6 +166,6 @@ int _ustore_64(uint64_t *uaddr, uint64_t val) { *uaddr = val; - return 0 + return 0; } #endif /* _LP64 */
CVS commit: src/sys/arch/usermode/modules/syscallemu
Module Name:src Committed By: rin Date: Sun Feb 17 05:32:35 UTC 2019 Modified Files: src/sys/arch/usermode/modules/syscallemu: Makefile Log Message: Set WARN=3 for sing-compare. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/usermode/modules/syscallemu/Makefile 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/modules/syscallemu/Makefile diff -u src/sys/arch/usermode/modules/syscallemu/Makefile:1.5 src/sys/arch/usermode/modules/syscallemu/Makefile:1.6 --- src/sys/arch/usermode/modules/syscallemu/Makefile:1.5 Sun Nov 10 22:08:58 2013 +++ src/sys/arch/usermode/modules/syscallemu/Makefile Sun Feb 17 05:32:35 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.5 2013/11/10 22:08:58 jmcneill Exp $ +# $NetBSD: Makefile,v 1.6 2019/02/17 05:32:35 rin Exp $ .include @@ -19,4 +19,6 @@ SRCS+= syscallemu_arm.c .error ${MACHINE_CPU} not implemented .endif +WARNS= 3 + .include
CVS commit: src/sys/arch/usermode/conf
Module Name:src Committed By: reinoud Date: Fri Aug 17 20:16:07 UTC 2018 Modified Files: src/sys/arch/usermode/conf: Makefile.usermode kern.ldscript Log Message: Start using the kernel ld script. There are still issues with the .init placement and ./build.sh creating bad images. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/sys/arch/usermode/conf/Makefile.usermode cvs rdiff -u -r1.1 -r1.2 src/sys/arch/usermode/conf/kern.ldscript 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/conf/Makefile.usermode diff -u src/sys/arch/usermode/conf/Makefile.usermode:1.42 src/sys/arch/usermode/conf/Makefile.usermode:1.43 --- src/sys/arch/usermode/conf/Makefile.usermode:1.42 Fri Jun 1 07:22:33 2018 +++ src/sys/arch/usermode/conf/Makefile.usermode Fri Aug 17 20:16:07 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.usermode,v 1.42 2018/06/01 07:22:33 reinoud Exp $ +# $NetBSD: Makefile.usermode,v 1.43 2018/08/17 20:16:07 reinoud Exp $ MKCTF?=no USETOOLS?= no @@ -74,9 +74,9 @@ KERNLDSCRIPT?= ${USERMODE}/conf/kern.lds SYSTEM_LD= @do_system_ld() { \ ${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \ ${_MKSHECHO}\ - ${CC} -static ${COPTS} -Wl,-Map,$${target}.map -o ${.TARGET} ${LINKFORMAT} -Ttext ${TEXTADDR} '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS} $$@; \ + ${CC} -static ${COPTS} -Wl,-Map,$${target}.map -o ${.TARGET} ${LINKFORMAT} -Wl,-Ttext,${TEXTADDR} '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o netbsd.ldscript ${USERMODE_LIBS} $$@; \ ${SYSTEM_LD_FIX} \ - ${CC} -static ${COPTS} -Wl,-Map,$${target}.map -o ${.TARGET} ${LINKFORMAT} -Ttext ${TEXTADDR} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS} $$@; \ + ${CC} -static ${COPTS} -Wl,-Map,$${target}.map -o ${.TARGET} ${LINKFORMAT} -Wl,-Ttext,${TEXTADDR} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o netbsd.ldscript ${USERMODE_LIBS} $$@; \ }; \ do_system_ld NVFLAGS= -n Index: src/sys/arch/usermode/conf/kern.ldscript diff -u src/sys/arch/usermode/conf/kern.ldscript:1.1 src/sys/arch/usermode/conf/kern.ldscript:1.2 --- src/sys/arch/usermode/conf/kern.ldscript:1.1 Fri May 18 19:04:10 2018 +++ src/sys/arch/usermode/conf/kern.ldscript Fri Aug 17 20:16:07 2018 @@ -1,20 +1,28 @@ -/* $NetBSD: kern.ldscript,v 1.1 2018/05/18 19:04:10 reinoud Exp $ */ +/* $NetBSD: kern.ldscript,v 1.2 2018/08/17 20:16:07 reinoud Exp $ */ #include "assym.h" +__PAGE_SIZE = 0x1000 ; + ENTRY(_start) SECTIONS { /* Read-only sections, merged into text segment: */ .text : { + . = ALIGN(__PAGE_SIZE); + *(.text.user) + . = ALIGN(__PAGE_SIZE); *(.text) *(.text.*) *(.stub) - } + . = ALIGN(__PAGE_SIZE); + } =0xCC + _etext = . ; PROVIDE (etext = .) ; + . = ALIGN(__PAGE_SIZE); .rodata : { *(.rodata) @@ -25,7 +33,7 @@ SECTIONS * Adjust the address for the data segment. We want to adjust up to * the same address within the page on the next page up. */ - . = ALIGN(0x10) + (. & (0x10 - 1)); + . = ALIGN(__PAGE_SIZE); __data_start = . ; .data : { @@ -52,22 +60,17 @@ SECTIONS *(.bss) *(.bss.*) *(COMMON) - . = ALIGN(64 / 8); } - . = ALIGN(64 / 8); + + . = ALIGN(__PAGE_SIZE); _end = . ; PROVIDE (end = .) ; - .note.netbsd.ident : - { - KEEP(*(.note.netbsd.ident)); - } -} -SECTIONS -{ - .text : - AT (ADDR(.text) & 0x0fff) - { - *(.text) - } = 0 + /* + * .note.netbsd.ident : + * { + * KEEP(*(.note.netbsd.ident)); + * } + */ } +
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Sun Aug 5 18:57:49 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: db_memrw.c Log Message: Advise to explicitly set flags +agm instead of only clearing them when set To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/usermode/db_memrw.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/db_memrw.c diff -u src/sys/arch/usermode/usermode/db_memrw.c:1.3 src/sys/arch/usermode/usermode/db_memrw.c:1.4 --- src/sys/arch/usermode/usermode/db_memrw.c:1.3 Fri Aug 3 11:18:22 2018 +++ src/sys/arch/usermode/usermode/db_memrw.c Sun Aug 5 18:57:49 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: db_memrw.c,v 1.3 2018/08/03 11:18:22 reinoud Exp $ */ +/* $NetBSD: db_memrw.c,v 1.4 2018/08/05 18:57:49 reinoud Exp $ */ /*- * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.3 2018/08/03 11:18:22 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.4 2018/08/05 18:57:49 reinoud Exp $"); #include #include @@ -226,14 +226,14 @@ db_write_bytes(vaddr_t addr, size_t size /* * if we are in the kernel range, just allow writing by using * mprotect(); Note that this needs an unprotected binary, set with - * `paxctl -agm netbsd` + * `paxctl +agm netbsd` */ if (addr > kmem_k_start) { ret = thunk_mprotect((void *) trunc_page(addr), PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC); if (ret != 0) panic("please unprotect kernel binary with " - "`paxctl -agm netbsd`"); + "`paxctl +agm netbsd`"); assert(ret == 0); }
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Sun Aug 5 18:42:49 UTC 2018 Modified Files: src/sys/arch/usermode/include: db_machdep.h ucontext.h src/sys/arch/usermode/usermode: cpufunc.S kgdb_machdep.c Log Message: Add KGDB definitions for i386 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/db_machdep.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/usermode/include/ucontext.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/usermode/usermode/cpufunc.S cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/usermode/kgdb_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/include/db_machdep.h diff -u src/sys/arch/usermode/include/db_machdep.h:1.3 src/sys/arch/usermode/include/db_machdep.h:1.4 --- src/sys/arch/usermode/include/db_machdep.h:1.3 Wed Aug 1 09:50:57 2018 +++ src/sys/arch/usermode/include/db_machdep.h Sun Aug 5 18:42:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.h,v 1.3 2018/08/01 09:50:57 reinoud Exp $ */ +/* $NetBSD: db_machdep.h,v 1.4 2018/08/05 18:42:48 reinoud Exp $ */ #ifndef _USERMODE_DB_MACHDEP_H #define _USERMODE_DB_MACHDEP_H @@ -27,6 +27,7 @@ extern db_regs_t *ddb_regp; #define ddb_regs (*ddb_regp) #endif +/* copied here in verbatim to remove dependencies */ #if defined(__i386__) #define BKPT_SIZE 1 @@ -34,8 +35,30 @@ extern db_regs_t *ddb_regp; #define BKPT_ADDR(addr) (addr) #define BKPT_SET(inst, addr) (BKPT_INST) -#error append db_machdep.h for i386 +#define db_clear_single_step(regs) _UC_MACHINE_EFLAGS(regs) &= ~PSL_T +#define db_set_single_step(regs) _UC_MACHINE_EFLAGS(regs) |= PSL_T +#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT) +#define IS_WATCHPOINT_TRAP(type, code) ((type) == T_TRCTRAP && (code) & 15) + +#define I_CALL 0xe8 +#define I_CALLI 0xff +#define I_RET 0xc3 +#define I_IRET 0xcf + +#define inst_trap_return(ins) (((ins)&0xff) == I_IRET) +#define inst_return(ins) (((ins)&0xff) == I_RET) +#define inst_call(ins) (((ins)&0xff) == I_CALL || \ + (((ins)&0xff) == I_CALLI && \ + ((ins)&0x3800) == 0x1000)) +#define inst_load(ins) 0 +#define inst_store(ins) 0 + +typedef int kgdb_reg_t; +#define KGDB_NUMREGS 16 +#define KGDB_BUFLEN 512 + +/* copied here in verbatim to remove dependencies */ #elif defined(__x86_64__) #define DDB_EXPR_FMT "l" /* expression is long */ Index: src/sys/arch/usermode/include/ucontext.h diff -u src/sys/arch/usermode/include/ucontext.h:1.1 src/sys/arch/usermode/include/ucontext.h:1.2 --- src/sys/arch/usermode/include/ucontext.h:1.1 Wed Aug 1 09:52:15 2018 +++ src/sys/arch/usermode/include/ucontext.h Sun Aug 5 18:42:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ucontext.h,v 1.1 2018/08/01 09:52:15 reinoud Exp $ */ +/* $NetBSD: ucontext.h,v 1.2 2018/08/05 18:42:48 reinoud Exp $ */ #ifndef _USERMODE_UCONTEXT_H #define _USERMODE_UCONTEXT_H @@ -9,6 +9,8 @@ #if defined(__i386__) +#define _UC_MACHINE_EFLAGS(uc) ((uc)->uc_mcontext.__gregs[_REG_EFL]) + #elif defined(__x86_64__) #define _UC_MACHINE_RFLAGS(uc) ((uc)->uc_mcontext.__gregs[26]) Index: src/sys/arch/usermode/usermode/cpufunc.S diff -u src/sys/arch/usermode/usermode/cpufunc.S:1.1 src/sys/arch/usermode/usermode/cpufunc.S:1.2 --- src/sys/arch/usermode/usermode/cpufunc.S:1.1 Wed Aug 1 10:22:20 2018 +++ src/sys/arch/usermode/usermode/cpufunc.S Sun Aug 5 18:42:48 2018 @@ -5,10 +5,14 @@ #if defined(__i386__) ENTRY(breakpoint) - .byte 0xcc // BKPT_INST + pushl %ebp + movl %esp, %ebp + int $0x03 /* paranoid, not 'int3' */ + popl %ebp ret +END(breakpoint) -#error implement setjmp/longjmp for i386 +//#error TODO implement setjmp/longjmp for i386? #elif defined(__amd64__) ENTRY(breakpoint) Index: src/sys/arch/usermode/usermode/kgdb_machdep.c diff -u src/sys/arch/usermode/usermode/kgdb_machdep.c:1.3 src/sys/arch/usermode/usermode/kgdb_machdep.c:1.4 --- src/sys/arch/usermode/usermode/kgdb_machdep.c:1.3 Wed Aug 1 10:24:41 2018 +++ src/sys/arch/usermode/usermode/kgdb_machdep.c Sun Aug 5 18:42:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kgdb_machdep.c,v 1.3 2018/08/01 10:24:41 reinoud Exp $ */ +/* $NetBSD: kgdb_machdep.c,v 1.4 2018/08/05 18:42:48 reinoud Exp $ */ /* * Copyright (c) 1996 Matthias Pfaller. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.3 2018/08/01 10:24:41 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.4 2018/08/05 18:42:48 reinoud Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -127,34 +127,25 @@ kgdb_getregs(db_regs_t *regs, kgdb_reg_t gdb_regs[19] = gregs[_REG_SS]; #elif defined(__i386) - gdb_regs[ 0] = regs->tf_eax; - gdb_regs[ 1] = regs->tf_ecx; - gdb_regs[ 2] = regs->tf_edx; - gdb_regs[ 3] = regs->tf_ebx; - gdb_regs[ 4] = regs->tf_esp; - gdb_regs[ 5] = regs->tf_ebp; - gdb_regs[ 6] = regs->tf_esi; - gdb_regs[ 7] = regs->tf_edi; - gdb_regs[ 8] = regs->tf_eip; - gdb_regs[ 9] = regs->tf_efla
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Sun Aug 5 16:51:59 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: pmap.c Log Message: To avoid possible collisions between the NetBSD/userland kernel and possible host kernel memory allocation schemes, allocate two dedicated pages for page copying and page zeroing. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/arch/usermode/usermode/pmap.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/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.112 src/sys/arch/usermode/usermode/pmap.c:1.113 --- src/sys/arch/usermode/usermode/pmap.c:1.112 Fri Aug 3 11:18:22 2018 +++ src/sys/arch/usermode/usermode/pmap.c Sun Aug 5 16:51:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.112 2018/08/03 11:18:22 reinoud Exp $ */ +/* $NetBSD: pmap.c,v 1.113 2018/08/05 16:51:59 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.112 2018/08/03 11:18:22 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.113 2018/08/05 16:51:59 reinoud Exp $"); #include "opt_memsize.h" #include "opt_kmempages.h" @@ -101,6 +101,8 @@ static int pm_nentries = 0; static int pm_nl1 = 0; static int pm_l1_size = 0; static uint64_t pm_entries_size = 0; +static void *pm_tmp_p0; +static void *pm_tmp_p1; static struct pool pmap_pool; static struct pool pmap_pventry_pool; @@ -183,6 +185,11 @@ pmap_bootstrap(void) kmem_kvm_end= kmem_k_start - barrier_len; kmem_kvm_start = kmem_kvm_end - KVMSIZE; + /* allow some pmap scratch space */ + pm_tmp_p0 = (void *) (kmem_kvm_start); + pm_tmp_p1 = (void *) (kmem_kvm_start + PAGE_SIZE); + kmem_kvm_start += 2*PAGE_SIZE; + /* claim an area for userland (---/R--/RW-/RWX) */ kmem_user_start = vm_min_addr; kmem_user_end = kmem_kvm_start - barrier_len; @@ -1227,14 +1234,12 @@ pmap_zero_page(paddr_t pa) if (pa & (PAGE_SIZE-1)) panic("%s: unaligned address passed : %p\n", __func__, (void *) pa); - blob = thunk_mmap(NULL, PAGE_SIZE, + blob = thunk_mmap(pm_tmp_p0, PAGE_SIZE, THUNK_PROT_READ | THUNK_PROT_WRITE, - THUNK_MAP_FILE | THUNK_MAP_SHARED, + THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED, mem_fh, pa); - if (!blob) + if (blob != pm_tmp_p0) panic("%s: couldn't get mapping", __func__); - if (blob < (char *) kmem_k_end) - panic("%s: mmap in illegal memory range", __func__); memset(blob, 0, PAGE_SIZE); @@ -1254,25 +1259,21 @@ pmap_copy_page(paddr_t src_pa, paddr_t d thunk_printf_debug("pmap_copy_page: pa src %p, pa dst %p\n", (void *) src_pa, (void *) dst_pa); - /* XXX bug alart: can we allow the kernel to make a decision on this? */ - sblob = thunk_mmap(NULL, PAGE_SIZE, + /* source */ + sblob = thunk_mmap(pm_tmp_p0, PAGE_SIZE, THUNK_PROT_READ, - THUNK_MAP_FILE | THUNK_MAP_SHARED, + THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED, mem_fh, src_pa); - if (!sblob) + if (sblob != pm_tmp_p0) panic("%s: couldn't get src mapping", __func__); - if (sblob < (char *) kmem_k_end) - panic("%s: mmap in illegal memory range", __func__); - /* XXX bug alart: can we allow the kernel to make a decision on this? */ - dblob = thunk_mmap(NULL, PAGE_SIZE, + /* destination */ + dblob = thunk_mmap(pm_tmp_p1, PAGE_SIZE, THUNK_PROT_READ | THUNK_PROT_WRITE, - THUNK_MAP_FILE | THUNK_MAP_SHARED, + THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED, mem_fh, dst_pa); - if (!dblob) + if (dblob != pm_tmp_p1) panic("%s: couldn't get dst mapping", __func__); - if (dblob < (char *) kmem_k_end) - panic("%s: mmap in illegal memory range", __func__); memcpy(dblob, sblob, PAGE_SIZE);
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Fri Aug 3 11:18:22 UTC 2018 Modified Files: src/sys/arch/usermode/include: vmparam.h src/sys/arch/usermode/usermode: db_memrw.c pmap.c Log Message: Allow for setting kernel breakpoints in our remote kgdb To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/usermode/include/vmparam.h cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/usermode/db_memrw.c cvs rdiff -u -r1.111 -r1.112 src/sys/arch/usermode/usermode/pmap.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/include/vmparam.h diff -u src/sys/arch/usermode/include/vmparam.h:1.19 src/sys/arch/usermode/include/vmparam.h:1.20 --- src/sys/arch/usermode/include/vmparam.h:1.19 Wed Aug 1 12:09:02 2018 +++ src/sys/arch/usermode/include/vmparam.h Fri Aug 3 11:18:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.19 2018/08/01 12:09:02 reinoud Exp $ */ +/* $NetBSD: vmparam.h,v 1.20 2018/08/03 11:18:22 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -43,7 +43,7 @@ extern paddr_t kmem_user_start, kmem_use #define VM_MAX_ADDRESS kmem_user_end #define VM_MAXUSER_ADDRESS kmem_user_end #define VM_MIN_KERNEL_ADDRESS kmem_kvm_start -#define VM_MAX_KERNEL_ADDRESS kmem_kvm_end +#define VM_MAX_KERNEL_ADDRESS kmem_k_end #define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST #define VM_PHYSSEG_MAX 1 Index: src/sys/arch/usermode/usermode/db_memrw.c diff -u src/sys/arch/usermode/usermode/db_memrw.c:1.2 src/sys/arch/usermode/usermode/db_memrw.c:1.3 --- src/sys/arch/usermode/usermode/db_memrw.c:1.2 Wed Aug 1 10:27:28 2018 +++ src/sys/arch/usermode/usermode/db_memrw.c Fri Aug 3 11:18:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: db_memrw.c,v 1.2 2018/08/01 10:27:28 reinoud Exp $ */ +/* $NetBSD: db_memrw.c,v 1.3 2018/08/03 11:18:22 reinoud Exp $ */ /*- * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc. @@ -53,11 +53,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.2 2018/08/01 10:27:28 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.3 2018/08/03 11:18:22 reinoud Exp $"); #include #include #include +#include #include #include @@ -211,29 +212,30 @@ db_write_text(vaddr_t addr, size_t size, void db_write_bytes(vaddr_t addr, size_t size, const char *data) { -// extern struct bootspace bootspace; char *dst; -// size_t i; + int ret; dst = (char *)addr; thunk_printf_debug("\n%s : %p + %d\n", __func__, dst, (int) size); -#if 0 - // TODO: check if we in kernel range and if so, do the mmap dance - // ourselves? - /* If any part is in kernel text or rodata, use db_write_text() */ - for (i = 0; i < BTSPACE_NSEGS; i++) { - if (bootspace.segs[i].type != BTSEG_TEXT && - bootspace.segs[i].type != BTSEG_RODATA) { - continue; - } - if (addr >= bootspace.segs[i].va && - addr < (bootspace.segs[i].va + bootspace.segs[i].sz)) { - db_write_text(addr, size, data); - return; - } + if (db_validate_address((vaddr_t)addr)) { + printf("address %p is invalid\n", (void *) addr); + return; + } + + /* + * if we are in the kernel range, just allow writing by using + * mprotect(); Note that this needs an unprotected binary, set with + * `paxctl -agm netbsd` + */ + if (addr > kmem_k_start) { + ret = thunk_mprotect((void *) trunc_page(addr), PAGE_SIZE, + PROT_READ | PROT_WRITE | PROT_EXEC); + if (ret != 0) + panic("please unprotect kernel binary with " + "`paxctl -agm netbsd`"); + assert(ret == 0); } -#endif dst = (char *)addr; Index: src/sys/arch/usermode/usermode/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.111 src/sys/arch/usermode/usermode/pmap.c:1.112 --- src/sys/arch/usermode/usermode/pmap.c:1.111 Fri Aug 3 06:52:50 2018 +++ src/sys/arch/usermode/usermode/pmap.c Fri Aug 3 11:18:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.111 2018/08/03 06:52:50 reinoud Exp $ */ +/* $NetBSD: pmap.c,v 1.112 2018/08/03 11:18:22 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.111 2018/08/03 06:52:50 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.112 2018/08/03 11:18:22 reinoud Exp $"); #include "opt_memsize.h" #include "opt_kmempages.h" @@ -139,7 +139,7 @@ pmap_bootstrap(void) struct pmap *pmap; paddr_t DRAM_cfg; paddr_t fpos, file_len; - paddr_t pv_fpos, tlb_fpos, pm_l1_fpos, pm_fpos; + paddr_t kernel_fpos, pv_fpos, tlb_fpos, pm_l1_fpos, pm_fpos; paddr_t wlen; paddr_t barrier_len; paddr_t pv_table_size; @@ -281,9 +281,11 @@ pmap_bootstrap(void) assert(err == 0); /* map the kernel at the start of the 'memory' file */ - written = thunk_pwrite(mem_fh, (void *) kmem_k_start, kmem_k_length, 0); + kernel_fpos = 0; + written = thunk_pwrite(mem_fh, (void *) kmem_k_start, kmem_k_length, + kernel_fpos); assert(written == kmem_k_length); - fpos = kmem_k_length;
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Fri Aug 3 06:52:50 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: pmap.c Log Message: Fix physical memory size issue. It will now happily run on more than one gb. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/sys/arch/usermode/usermode/pmap.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/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.110 src/sys/arch/usermode/usermode/pmap.c:1.111 --- src/sys/arch/usermode/usermode/pmap.c:1.110 Wed Aug 1 12:09:01 2018 +++ src/sys/arch/usermode/usermode/pmap.c Fri Aug 3 06:52:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.110 2018/08/01 12:09:01 reinoud Exp $ */ +/* $NetBSD: pmap.c,v 1.111 2018/08/03 06:52:50 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.110 2018/08/01 12:09:01 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.111 2018/08/03 06:52:50 reinoud Exp $"); #include "opt_memsize.h" #include "opt_kmempages.h" @@ -76,6 +76,14 @@ struct pmap { struct pmap_l2 **pm_l1; }; +/* + * pv_table is list of pv_entry structs completely spanning the total memory. + * It is indexed on physical page number. Each entry will be daisy chained + * with pv_entry records for each usage in all the pmaps. + * + * kernel_pm_entries contains all kernel L2 pages for its complete map. + * + */ static struct pv_entry **kernel_pm_entries; static struct pv_entry *pv_table; /* physical pages info (direct mapped) */ @@ -95,7 +103,6 @@ static int pm_l1_size = 0; static uint64_t pm_entries_size = 0; static struct pool pmap_pool; -static struct pool pmap_l1_pool; static struct pool pmap_pventry_pool; /* forwards */ @@ -139,6 +146,7 @@ pmap_bootstrap(void) vaddr_t free_start, free_end; paddr_t pa; vaddr_t va; + size_t kmem_k_length, written; uintptr_t pg, l1; void *addr; int err; @@ -165,6 +173,7 @@ pmap_bootstrap(void) /* calculate kernel section (R-X) */ kmem_k_start = (vaddr_t) PAGE_SIZE * (atop(_start)); kmem_k_end = (vaddr_t) PAGE_SIZE * (atop(&etext) + 1); + kmem_k_length = kmem_k_end - kmem_k_start; /* calculate total available memory space & available pages */ DRAM_cfg = (vaddr_t) TEXTADDR; @@ -260,7 +269,7 @@ pmap_bootstrap(void) #endif /* protect the current kernel section */ - err = thunk_mprotect((void *) kmem_k_start, kmem_k_end - kmem_k_start, + err = thunk_mprotect((void *) kmem_k_start, kmem_k_length, THUNK_PROT_READ | THUNK_PROT_EXEC); assert(err == 0); @@ -271,14 +280,18 @@ pmap_bootstrap(void) THUNK_MADV_WILLNEED | THUNK_MADV_RANDOM); assert(err == 0); + /* map the kernel at the start of the 'memory' file */ + written = thunk_pwrite(mem_fh, (void *) kmem_k_start, kmem_k_length, 0); + assert(written == kmem_k_length); + fpos = kmem_k_length; + /* initialize counters */ - fpos = 0; free_start = fpos; /* in physical space ! */ free_end = file_len; /* in physical space ! */ kmem_kvm_cur_start = kmem_kvm_start; /* calculate pv table size */ - phys_npages = (free_end - free_start) / PAGE_SIZE; + phys_npages = file_len / PAGE_SIZE; pv_table_size = round_page(phys_npages * sizeof(struct pv_entry)); thunk_printf_debug("claiming %"PRIu64" KB of pv_table for " "%"PRIdPTR" pages of physical memory\n", @@ -292,7 +305,7 @@ pmap_bootstrap(void) /* calculate how big the l1 tables are going to be */ pm_nl1 = pm_nentries / PMAP_L2_NENTRY; - pm_l1_size = pm_nl1 * sizeof(struct pmap_l1 *); + pm_l1_size = round_page(pm_nl1 * sizeof(struct pmap_l1 *)); /* claim pv table */ pv_fpos = fpos; @@ -449,8 +462,6 @@ pmap_deferred_init(void) /* create pmap pool */ pool_init(&pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappool", NULL, IPL_NONE); - pool_init(&pmap_l1_pool, pm_l1_size, 0, 0, 0, - "pmapl1pool", NULL, IPL_NONE); pool_init(&pmap_pventry_pool, sizeof(struct pv_entry), 0, 0, 0, "pventry", NULL, IPL_HIGH); } @@ -484,8 +495,8 @@ pmap_create(void) pmap->pm_flags = 0; /* claim l1 table */ - pmap->pm_l1 = pool_get(&pmap_l1_pool, PR_WAITOK); - memset(pmap->pm_l1, 0, pm_l1_size); + pmap->pm_l1 = kmem_zalloc(pm_l1_size, KM_SLEEP); + assert(pmap->pm_l1); thunk_printf_debug("\tpmap %p\n", pmap); @@ -527,7 +538,7 @@ pmap_destroy(pmap_t pmap) continue; kmem_free(l2tbl, PMAP_L2_SIZE); } - pool_put(&pmap_l1_pool, pmap->pm_l1); + kmem_free(pmap->pm_l1, pm_l1_size); pool_put(&pmap_pool, pmap); }
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Wed Aug 1 12:09:02 UTC 2018 Modified Files: src/sys/arch/usermode/include: vmparam.h src/sys/arch/usermode/usermode: pmap.c Log Message: Revert to working state To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/usermode/include/vmparam.h cvs rdiff -u -r1.109 -r1.110 src/sys/arch/usermode/usermode/pmap.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/include/vmparam.h diff -u src/sys/arch/usermode/include/vmparam.h:1.18 src/sys/arch/usermode/include/vmparam.h:1.19 --- src/sys/arch/usermode/include/vmparam.h:1.18 Wed Aug 1 09:46:16 2018 +++ src/sys/arch/usermode/include/vmparam.h Wed Aug 1 12:09:02 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.18 2018/08/01 09:46:16 reinoud Exp $ */ +/* $NetBSD: vmparam.h,v 1.19 2018/08/01 12:09:02 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -43,7 +43,7 @@ extern paddr_t kmem_user_start, kmem_use #define VM_MAX_ADDRESS kmem_user_end #define VM_MAXUSER_ADDRESS kmem_user_end #define VM_MIN_KERNEL_ADDRESS kmem_kvm_start -#define VM_MAX_KERNEL_ADDRESS kmem_k_end +#define VM_MAX_KERNEL_ADDRESS kmem_kvm_end #define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST #define VM_PHYSSEG_MAX 1 Index: src/sys/arch/usermode/usermode/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.109 src/sys/arch/usermode/usermode/pmap.c:1.110 --- src/sys/arch/usermode/usermode/pmap.c:1.109 Wed Aug 1 09:44:31 2018 +++ src/sys/arch/usermode/usermode/pmap.c Wed Aug 1 12:09:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.109 2018/08/01 09:44:31 reinoud Exp $ */ +/* $NetBSD: pmap.c,v 1.110 2018/08/01 12:09:01 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.109 2018/08/01 09:44:31 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.110 2018/08/01 12:09:01 reinoud Exp $"); #include "opt_memsize.h" #include "opt_kmempages.h" @@ -285,7 +285,7 @@ pmap_bootstrap(void) (uint64_t) pv_table_size/1024, (uintptr_t) phys_npages); /* calculate number of pmap entries needed for a complete map */ - pm_nentries = (kmem_k_end - VM_MIN_ADDRESS) / PAGE_SIZE; + pm_nentries = (kmem_k_start - VM_MIN_ADDRESS) / PAGE_SIZE; pm_entries_size = round_page(pm_nentries * sizeof(struct pv_entry *)); thunk_printf_debug("tlb va->pa lookup table is %"PRIu64" KB for " "%d logical pages\n", pm_entries_size/1024, pm_nentries); @@ -660,7 +660,8 @@ pmap_fault(pmap_t pmap, vaddr_t va, vm_p /* not known! then it must be UVM's work */ if (pv == NULL) { - thunk_printf_debug("%s: no mapping yet\n", __func__); + //thunk_printf("%s: no mapping yet for %p\n", + // __func__, (void *) va); *atype = VM_PROT_READ; /* assume it was a read */ return false; } @@ -1090,7 +1091,7 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa thunk_printf_debug("pmap_extract: extracting va %p\n", (void *) va); #ifdef DIAGNOSTIC if ((va < VM_MIN_ADDRESS) || (va > VM_MAX_KERNEL_ADDRESS)) { - thunk_printf_debug("pmap_extract: invalid va issued\n"); + thunk_printf_debug("pmap_extract: invalid va isued\n"); thunk_printf("%p not in [%p, %p]\n", (void *) va, (void *) VM_MIN_ADDRESS, (void *) VM_MAX_KERNEL_ADDRESS); return false;
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Wed Aug 1 10:27:28 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: db_memrw.c Log Message: Remove yet another debug printf() To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/usermode/usermode/db_memrw.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/db_memrw.c diff -u src/sys/arch/usermode/usermode/db_memrw.c:1.1 src/sys/arch/usermode/usermode/db_memrw.c:1.2 --- src/sys/arch/usermode/usermode/db_memrw.c:1.1 Wed Aug 1 10:22:20 2018 +++ src/sys/arch/usermode/usermode/db_memrw.c Wed Aug 1 10:27:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: db_memrw.c,v 1.1 2018/08/01 10:22:20 reinoud Exp $ */ +/* $NetBSD: db_memrw.c,v 1.2 2018/08/01 10:27:28 reinoud Exp $ */ /*- * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.1 2018/08/01 10:22:20 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.2 2018/08/01 10:27:28 reinoud Exp $"); #include #include @@ -216,7 +216,7 @@ db_write_bytes(vaddr_t addr, size_t size // size_t i; dst = (char *)addr; -thunk_printf("\n%s : %p + %d\n", __func__, dst, (int) size); + thunk_printf_debug("\n%s : %p + %d\n", __func__, dst, (int) size); #if 0 // TODO: check if we in kernel range and if so, do the mmap dance // ourselves?
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Wed Aug 1 10:24:41 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: kgdb_machdep.c Log Message: Fix too long line To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/usermode/kgdb_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/kgdb_machdep.c diff -u src/sys/arch/usermode/usermode/kgdb_machdep.c:1.2 src/sys/arch/usermode/usermode/kgdb_machdep.c:1.3 --- src/sys/arch/usermode/usermode/kgdb_machdep.c:1.2 Wed Aug 1 10:23:55 2018 +++ src/sys/arch/usermode/usermode/kgdb_machdep.c Wed Aug 1 10:24:41 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kgdb_machdep.c,v 1.2 2018/08/01 10:23:55 reinoud Exp $ */ +/* $NetBSD: kgdb_machdep.c,v 1.3 2018/08/01 10:24:41 reinoud Exp $ */ /* * Copyright (c) 1996 Matthias Pfaller. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.2 2018/08/01 10:23:55 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.3 2018/08/01 10:24:41 reinoud Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -58,7 +58,8 @@ kgdb_acc(vaddr_t va, size_t len) va &= ~PGOFSET; last_va &= ~PGOFSET; - thunk_printf_debug("%s: [%p .. %p]\n", __func__, (void *) va, (void *) last_va); + thunk_printf_debug("%s: [%p .. %p]\n", __func__, + (void *) va, (void *) last_va); do { if (db_validate_address(va)) return (0);
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Wed Aug 1 10:23:55 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: kgdb_machdep.c Log Message: Remove debugging printf() To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/usermode/usermode/kgdb_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/kgdb_machdep.c diff -u src/sys/arch/usermode/usermode/kgdb_machdep.c:1.1 src/sys/arch/usermode/usermode/kgdb_machdep.c:1.2 --- src/sys/arch/usermode/usermode/kgdb_machdep.c:1.1 Wed Aug 1 10:22:20 2018 +++ src/sys/arch/usermode/usermode/kgdb_machdep.c Wed Aug 1 10:23:55 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: kgdb_machdep.c,v 1.1 2018/08/01 10:22:20 reinoud Exp $ */ +/* $NetBSD: kgdb_machdep.c,v 1.2 2018/08/01 10:23:55 reinoud Exp $ */ /* * Copyright (c) 1996 Matthias Pfaller. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.1 2018/08/01 10:22:20 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.2 2018/08/01 10:23:55 reinoud Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -58,7 +58,7 @@ kgdb_acc(vaddr_t va, size_t len) va &= ~PGOFSET; last_va &= ~PGOFSET; -thunk_printf("%s: [%p .. %p]\n", __func__, (void *) va, (void *) last_va); + thunk_printf_debug("%s: [%p .. %p]\n", __func__, (void *) va, (void *) last_va); do { if (db_validate_address(va)) return (0);
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Wed Aug 1 10:22:20 UTC 2018 Added Files: src/sys/arch/usermode/usermode: cpufunc.S db_memrw.c kgdb_machdep.c Log Message: Add the kgdb meat To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/usermode/cpufunc.S \ src/sys/arch/usermode/usermode/db_memrw.c \ src/sys/arch/usermode/usermode/kgdb_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/usermode/usermode/cpufunc.S diff -u /dev/null src/sys/arch/usermode/usermode/cpufunc.S:1.1 --- /dev/null Wed Aug 1 10:22:20 2018 +++ src/sys/arch/usermode/usermode/cpufunc.S Wed Aug 1 10:22:20 2018 @@ -0,0 +1,75 @@ + +#include +#include "assym.h" + +#if defined(__i386__) + +ENTRY(breakpoint) + .byte 0xcc // BKPT_INST + ret + +#error implement setjmp/longjmp for i386 + +#elif defined(__amd64__) +ENTRY(breakpoint) + .byte 0xcc // BKPT_INST, int3 + ret + +/* + * int setjmp(label_t *) + * + * Used primarily by DDB. + */ +ENTRY(setjmp) + /* + * Only save registers that must be preserved across function + * calls according to the ABI (%rbx, %rsp, %rbp, %r12-%r15) + * and %rip. + */ + movq %rdi,%rax + movq %rbx,(%rax) + movq %rsp,8(%rax) + movq %rbp,16(%rax) + movq %r12,24(%rax) + movq %r13,32(%rax) + movq %r14,40(%rax) + movq %r15,48(%rax) + movq (%rsp),%rdx + movq %rdx,56(%rax) + xorl %eax,%eax + ret +END(setjmp) + +/* + * int longjmp(label_t *) + * + * Used primarily by DDB. + */ +ENTRY(longjmp) + movq %rdi,%rax + movq (%rax),%rbx + movq 8(%rax),%rsp + movq 16(%rax),%rbp + movq 24(%rax),%r12 + movq 32(%rax),%r13 + movq 40(%rax),%r14 + movq 48(%rax),%r15 + movq 56(%rax),%rdx + movq %rdx,(%rsp) + movl $1,%eax + ret +END(longjmp) +#elif defined(__arm__) + +ENTRY(breakpoint) + BKPT_ASM + mov pc, lr + +#error implement setjmp/longjmp for arm32 + +#else + +#error port me + +#endif + Index: src/sys/arch/usermode/usermode/db_memrw.c diff -u /dev/null src/sys/arch/usermode/usermode/db_memrw.c:1.1 --- /dev/null Wed Aug 1 10:22:20 2018 +++ src/sys/arch/usermode/usermode/db_memrw.c Wed Aug 1 10:22:20 2018 @@ -0,0 +1,257 @@ +/* $NetBSD: db_memrw.c,v 1.1 2018/08/01 10:22:20 reinoud Exp $ */ + +/*- + * Copyright (c) 1996, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Gordon W. Ross and Jason R. Thorpe. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Interface to the debugger for virtual memory read/write. + * This file is shared by DDB and KGDB, and must work even + * when only KGDB is included (thus no db_printf calls). + * + * To write in the text segment, we have to first make + * the page writable, do the write, then restore the PTE. + * For writes outside the text segment, and all reads, + * just do the access -- if it causes a fault, the debugger + * will recover with a longjmp to an appropriate place. + * + * ALERT! If you want to access device registers with a + * specific size, then the read/write functions have to + * make sure to do the correct sized pointer access. + * + * Modified for i386 from hp300 version by + * Jason R. Thorpe . + * + * Basic copy to amd64 by fvdl. + * + * i386 and amd64 merge by jym. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: db_memrw.c,v 1.1 2018/08/01 10:22:20 reinoud Exp $"); + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +int +db_validate_address(vaddr_t addr) +{ + struct proc *p = curproc; + struct pmap *pmap; + + if (!p || !p->p_vmspace || !p->p_vmspace->vm_map.pmap || + addr >= VM_MIN_KE
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Wed Aug 1 09:52:15 UTC 2018 Added Files: src/sys/arch/usermode/include: cpufunc.h ucontext.h Log Message: Forgot the two header files To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/include/cpufunc.h \ src/sys/arch/usermode/include/ucontext.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/usermode/include/cpufunc.h diff -u /dev/null src/sys/arch/usermode/include/cpufunc.h:1.1 --- /dev/null Wed Aug 1 09:52:15 2018 +++ src/sys/arch/usermode/include/cpufunc.h Wed Aug 1 09:52:15 2018 @@ -0,0 +1,20 @@ +/* $NetBSD: cpufunc.h,v 1.1 2018/08/01 09:52:15 reinoud Exp $ */ + +/* + * Automatically generated by ./genheaders.sh on Wed May 16 14:39:02 CEST 2018 + * Do not modify directly! + */ +#ifndef _USERMODE_INT_LIMITS_H +#define _USERMODE_INT_LIMITS_H + +#if defined(__i386__) +#include "../../i386/include/cpufunc.h" +#elif defined(__x86_64__) +#include "../../amd64/include/cpufunc.h" +#elif defined(__arm__) +#include "../../arm/include/cpufunc.h" +#else +#error port me +#endif + +#endif Index: src/sys/arch/usermode/include/ucontext.h diff -u /dev/null src/sys/arch/usermode/include/ucontext.h:1.1 --- /dev/null Wed Aug 1 09:52:15 2018 +++ src/sys/arch/usermode/include/ucontext.h Wed Aug 1 09:52:15 2018 @@ -0,0 +1,23 @@ +/* $NetBSD: ucontext.h,v 1.1 2018/08/01 09:52:15 reinoud Exp $ */ + +#ifndef _USERMODE_UCONTEXT_H +#define _USERMODE_UCONTEXT_H + +#include +#include +#include + +#if defined(__i386__) + +#elif defined(__x86_64__) + +#define _UC_MACHINE_RFLAGS(uc) ((uc)->uc_mcontext.__gregs[26]) + +#elif defined(__arm__) +#error port me +#else +#error port me +#endif + +#endif /* _USERMODE_UCONTEXT_H */ +
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Wed Aug 1 09:50:57 UTC 2018 Modified Files: src/sys/arch/usermode/conf: files.usermode src/sys/arch/usermode/include: cpu.h db_machdep.h genheaders.sh pmap.h Log Message: Add preliminary KGDB support for NetBSD/usermode, currently only under amd64 To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/usermode/conf/files.usermode cvs rdiff -u -r1.10 -r1.11 src/sys/arch/usermode/include/cpu.h \ src/sys/arch/usermode/include/genheaders.sh cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/include/db_machdep.h cvs rdiff -u -r1.5 -r1.6 src/sys/arch/usermode/include/pmap.h 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/conf/files.usermode diff -u src/sys/arch/usermode/conf/files.usermode:1.17 src/sys/arch/usermode/conf/files.usermode:1.18 --- src/sys/arch/usermode/conf/files.usermode:1.17 Tue Jun 5 20:02:42 2018 +++ src/sys/arch/usermode/conf/files.usermode Wed Aug 1 09:50:57 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.usermode,v 1.17 2018/06/05 20:02:42 reinoud Exp $ +# $NetBSD: files.usermode,v 1.18 2018/08/01 09:50:57 reinoud Exp $ maxpartitions 8 maxusers 8 16 64 @@ -62,6 +62,9 @@ file arch/usermode/usermode/sys_machdep. file arch/usermode/usermode/syscall.c file arch/usermode/usermode/trap.c file arch/usermode/usermode/vm_machdep.c +file arch/usermode/usermode/db_memrw.c ddb | kgdb +file arch/usermode/usermode/kgdb_machdep.c ddb | kgdb +file arch/usermode/usermode/cpufunc.S ddb | kgdb file dev/cons.c file dev/md_root.cmemory_disk_hooks file kern/subr_disk_mbr.c disk Index: src/sys/arch/usermode/include/cpu.h diff -u src/sys/arch/usermode/include/cpu.h:1.10 src/sys/arch/usermode/include/cpu.h:1.11 --- src/sys/arch/usermode/include/cpu.h:1.10 Wed Feb 8 17:55:21 2012 +++ src/sys/arch/usermode/include/cpu.h Wed Aug 1 09:50:57 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.10 2012/02/08 17:55:21 reinoud Exp $ */ +/* $NetBSD: cpu.h,v 1.11 2018/08/01 09:50:57 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -47,7 +47,7 @@ struct cpu_info; extern int astpending; #define aston(ci) (astpending++) extern void cpu_need_resched(struct cpu_info *ci, int flags); - +extern void kgdb_port_init(void); struct cpu_info { struct cpu_data ci_data; /* MI per-cpu data */ Index: src/sys/arch/usermode/include/genheaders.sh diff -u src/sys/arch/usermode/include/genheaders.sh:1.10 src/sys/arch/usermode/include/genheaders.sh:1.11 --- src/sys/arch/usermode/include/genheaders.sh:1.10 Wed May 16 12:40:26 2018 +++ src/sys/arch/usermode/include/genheaders.sh Wed Aug 1 09:50:57 2018 @@ -23,6 +23,7 @@ HDRS="$HDRS wchar_limits.h" HDRS="$HDRS cdefs.h" HDRS="$HDRS mcontext.h" HDRS="$HDRS frame_regs.h" +HDRS="$HDRS cpufunc.h" for hdr in ${HDRS}; do G="_USERMODE_$(echo ${hdr} | sed 's/\./_/g' | tr [a-z] [A-Z])" Index: src/sys/arch/usermode/include/db_machdep.h diff -u src/sys/arch/usermode/include/db_machdep.h:1.2 src/sys/arch/usermode/include/db_machdep.h:1.3 --- src/sys/arch/usermode/include/db_machdep.h:1.2 Wed Oct 21 16:06:59 2009 +++ src/sys/arch/usermode/include/db_machdep.h Wed Aug 1 09:50:57 2018 @@ -1,32 +1,80 @@ -/* $NetBSD: db_machdep.h,v 1.2 2009/10/21 16:06:59 snj Exp $ */ +/* $NetBSD: db_machdep.h,v 1.3 2018/08/01 09:50:57 reinoud Exp $ */ -/*- - * Copyright (c) 2007 Jared D. McNeill - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - *notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - *notice, this list of conditions and the following disclaimer in the - *documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +#ifndef _USERMODE_DB_MACHDEP_H +#define _USERMODE_DB_MACHDEP_H -#ifndef _ARCH_USERMODE_INCLUDE_DB_MACHDEP_H -#define _ARCH_USERMODE_INCLUDE_DB_MACHDEP_H
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Wed Aug 1 09:46:46 UTC 2018 Modified Files: src/sys/arch/usermode/include: thunk.h Log Message: Add headers for support functions for kgdb To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/arch/usermode/include/thunk.h 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/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.65 src/sys/arch/usermode/include/thunk.h:1.66 --- src/sys/arch/usermode/include/thunk.h:1.65 Mon Jun 4 19:53:01 2018 +++ src/sys/arch/usermode/include/thunk.h Wed Aug 1 09:46:46 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.h,v 1.65 2018/06/04 19:53:01 reinoud Exp $ */ +/* $NetBSD: thunk.h,v 1.66 2018/08/01 09:46:46 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -127,6 +127,11 @@ int thunk_mkstemp(char *); int thunk_unlink(const char *); pid_t thunk_getpid(void); +int thunk_gdb_open(void); +int thunk_gdb_accept(int sockfd); +int thunk_kgdb_getc(int fd, char *ch); +int thunk_kgdb_putc(int fd, char ch); + int thunk_sigaction(int, const struct sigaction *, struct sigaction *); int thunk_sigaltstack(const stack_t *, stack_t *); void thunk_signal(int, void (*)(int));
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Wed Aug 1 09:46:16 UTC 2018 Modified Files: src/sys/arch/usermode/include: vmparam.h Log Message: Max kernel address is end of kernel To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/usermode/include/vmparam.h 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/include/vmparam.h diff -u src/sys/arch/usermode/include/vmparam.h:1.17 src/sys/arch/usermode/include/vmparam.h:1.18 --- src/sys/arch/usermode/include/vmparam.h:1.17 Sun Nov 10 19:52:01 2013 +++ src/sys/arch/usermode/include/vmparam.h Wed Aug 1 09:46:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.17 2013/11/10 19:52:01 jmcneill Exp $ */ +/* $NetBSD: vmparam.h,v 1.18 2018/08/01 09:46:16 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -43,7 +43,7 @@ extern paddr_t kmem_user_start, kmem_use #define VM_MAX_ADDRESS kmem_user_end #define VM_MAXUSER_ADDRESS kmem_user_end #define VM_MIN_KERNEL_ADDRESS kmem_kvm_start -#define VM_MAX_KERNEL_ADDRESS kmem_kvm_end +#define VM_MAX_KERNEL_ADDRESS kmem_k_end #define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST #define VM_PHYSSEG_MAX 1
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Wed Aug 1 09:44:32 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: machdep.c pmap.c thunk.c trap.c Log Message: Oops, forgot a debug printf To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/arch/usermode/usermode/machdep.c cvs rdiff -u -r1.108 -r1.109 src/sys/arch/usermode/usermode/pmap.c cvs rdiff -u -r1.90 -r1.91 src/sys/arch/usermode/usermode/thunk.c cvs rdiff -u -r1.69 -r1.70 src/sys/arch/usermode/usermode/trap.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.56 src/sys/arch/usermode/usermode/machdep.c:1.57 --- src/sys/arch/usermode/usermode/machdep.c:1.56 Mon Jun 11 19:35:56 2018 +++ src/sys/arch/usermode/usermode/machdep.c Wed Aug 1 09:44:31 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.56 2018/06/11 19:35:56 reinoud Exp $ */ +/* $NetBSD: machdep.c,v 1.57 2018/08/01 09:44:31 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -37,7 +37,7 @@ #include "opt_memsize.h" #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.56 2018/06/11 19:35:56 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.57 2018/08/01 09:44:31 reinoud Exp $"); #include #include @@ -59,6 +59,11 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include #include #include +#include +#include + +#include "opt_ddb.h" +#include "opt_kgdb.h" #ifndef MAX_DISK_IMAGES #define MAX_DISK_IMAGES 4 @@ -272,6 +277,18 @@ main(int argc, char *argv[]) splinit(); splraise(IPL_HIGH); +#ifdef DDB + if (boothowto & RB_KDB) + Debugger(); +#endif +#ifdef KGDB + if (boothowto & RB_KDB) { + kgdb_port_init(); + kgdb_debug_init = 1; + kgdb_connect(1); + } +#endif + kernmain(); } @@ -297,6 +314,7 @@ setstatclockrate(int arg) void consinit(void) { +// kgdb_connect(0); printf("NetBSD/usermode startup\n"); } Index: src/sys/arch/usermode/usermode/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.108 src/sys/arch/usermode/usermode/pmap.c:1.109 --- src/sys/arch/usermode/usermode/pmap.c:1.108 Wed Aug 1 09:43:17 2018 +++ src/sys/arch/usermode/usermode/pmap.c Wed Aug 1 09:44:31 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.108 2018/08/01 09:43:17 reinoud Exp $ */ +/* $NetBSD: pmap.c,v 1.109 2018/08/01 09:44:31 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.108 2018/08/01 09:43:17 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.109 2018/08/01 09:44:31 reinoud Exp $"); #include "opt_memsize.h" #include "opt_kmempages.h" @@ -660,7 +660,6 @@ pmap_fault(pmap_t pmap, vaddr_t va, vm_p /* not known! then it must be UVM's work */ if (pv == NULL) { -thunk_printf("%s: no mapping yet for %p\n", __func__, (void *) va); thunk_printf_debug("%s: no mapping yet\n", __func__); *atype = VM_PROT_READ; /* assume it was a read */ return false; Index: src/sys/arch/usermode/usermode/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.90 src/sys/arch/usermode/usermode/thunk.c:1.91 --- src/sys/arch/usermode/usermode/thunk.c:1.90 Mon Jun 4 19:53:01 2018 +++ src/sys/arch/usermode/usermode/thunk.c Wed Aug 1 09:44:31 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.90 2018/06/04 19:53:01 reinoud Exp $ */ +/* $NetBSD: thunk.c,v 1.91 2018/08/01 09:44:31 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,7 +28,7 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.90 2018/06/04 19:53:01 reinoud Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.91 2018/08/01 09:44:31 reinoud Exp $"); #endif #define _KMEMUSER @@ -92,6 +92,9 @@ __RCSID("$NetBSD: thunk.c,v 1.90 2018/06 //#define RFB_DEBUG +static ssize_t safe_recv(int s, void *buf, int len); +static ssize_t safe_send(int s, const void *msg, int len); + extern int boothowto; void @@ -1017,6 +1020,78 @@ thunk_rfb_open(thunk_rfb_t *rfb, uint16_ return 0; } +int +thunk_gdb_open(void) +{ + struct sockaddr_in sin; + int sockfd; + int portnr = 5001; /* XXX configurable or random */ + + /* create socket */ + sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + if (sockfd < 0) { + warn("kgdb stub: couldn't create socket"); + return 0; + } + + /* bind to requested port */ + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = htonl(INADDR_ANY); + sin.sin_port= htons(portnr); + + if (bind(sockfd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { + warn("kgdb stub: couldn't bind port %d", portnr); + close(sockfd); + return 0; + } + + /* listen for connections */ + if (listen(sockfd, 1) < 0) { + warn("kgdb stub: couldn't listen on socket"); + close(sockfd); + return 0; + } + printf("kgdb stub: accepting connections on port %d\n", portnr); + + return sockfd; +} + +int +thunk_gdb_accept(int sockfd) +{ + struct
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Wed Aug 1 09:43:17 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: pmap.c Log Message: Allow the usermode pmaps to also contain the kernel itself. This is needed for the kernel pmap. To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 src/sys/arch/usermode/usermode/pmap.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/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.107 src/sys/arch/usermode/usermode/pmap.c:1.108 --- src/sys/arch/usermode/usermode/pmap.c:1.107 Thu May 17 19:06:02 2018 +++ src/sys/arch/usermode/usermode/pmap.c Wed Aug 1 09:43:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.107 2018/05/17 19:06:02 reinoud Exp $ */ +/* $NetBSD: pmap.c,v 1.108 2018/08/01 09:43:17 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.107 2018/05/17 19:06:02 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.108 2018/08/01 09:43:17 reinoud Exp $"); #include "opt_memsize.h" #include "opt_kmempages.h" @@ -285,7 +285,7 @@ pmap_bootstrap(void) (uint64_t) pv_table_size/1024, (uintptr_t) phys_npages); /* calculate number of pmap entries needed for a complete map */ - pm_nentries = (kmem_k_start - VM_MIN_ADDRESS) / PAGE_SIZE; + pm_nentries = (kmem_k_end - VM_MIN_ADDRESS) / PAGE_SIZE; pm_entries_size = round_page(pm_nentries * sizeof(struct pv_entry *)); thunk_printf_debug("tlb va->pa lookup table is %"PRIu64" KB for " "%d logical pages\n", pm_entries_size/1024, pm_nentries); @@ -660,6 +660,7 @@ pmap_fault(pmap_t pmap, vaddr_t va, vm_p /* not known! then it must be UVM's work */ if (pv == NULL) { +thunk_printf("%s: no mapping yet for %p\n", __func__, (void *) va); thunk_printf_debug("%s: no mapping yet\n", __func__); *atype = VM_PROT_READ; /* assume it was a read */ return false; @@ -1089,8 +1090,12 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa thunk_printf_debug("pmap_extract: extracting va %p\n", (void *) va); #ifdef DIAGNOSTIC - if ((va < VM_MIN_ADDRESS) || (va > VM_MAX_KERNEL_ADDRESS)) - panic("pmap_extract: invalid va isued\n"); + if ((va < VM_MIN_ADDRESS) || (va > VM_MAX_KERNEL_ADDRESS)) { + thunk_printf_debug("pmap_extract: invalid va issued\n"); + thunk_printf("%p not in [%p, %p]\n", (void *) va, + (void *) VM_MIN_ADDRESS, (void *) VM_MAX_KERNEL_ADDRESS); + return false; + } #endif lpn = atop(va - VM_MIN_ADDRESS); /* V->L */ pv = pmap_lookup_pv(pmap, lpn);
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Sat Jul 28 20:26:13 UTC 2018 Added Files: src/sys/arch/usermode/include: trap.h Log Message: Provide hand-doctored redirection of trap.h in preparation for ddb/kgdb To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/include/trap.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/usermode/include/trap.h diff -u /dev/null src/sys/arch/usermode/include/trap.h:1.1 --- /dev/null Sat Jul 28 20:26:13 2018 +++ src/sys/arch/usermode/include/trap.h Sat Jul 28 20:26:13 2018 @@ -0,0 +1,19 @@ +/* $NetBSD: trap.h,v 1.1 2018/07/28 20:26:13 reinoud Exp $ */ + +/* + * Handcrafted redirect to prevent problems with i386 and x86_64 sharing x86 + */ +#ifndef _USERMODE_TRAP_H +#define _USERMODE_TRAP_H + +#if defined(__i386__) +#include "../../x86/include/trap.h" +#elif defined(__x86_64__) +#include "../../x86/include/trap.h" +#elif defined(__arm__) +#include "../../arm/include/trap.h" +#else +#error port me +#endif + +#endif
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Sat Jul 28 17:17:38 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: trap.c Log Message: Fix typo To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/arch/usermode/usermode/trap.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/trap.c diff -u src/sys/arch/usermode/usermode/trap.c:1.68 src/sys/arch/usermode/usermode/trap.c:1.69 --- src/sys/arch/usermode/usermode/trap.c:1.68 Mon Jun 11 19:23:21 2018 +++ src/sys/arch/usermode/usermode/trap.c Sat Jul 28 17:17:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.68 2018/06/11 19:23:21 reinoud Exp $ */ +/* $NetBSD: trap.c,v 1.69 2018/07/28 17:17:38 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.68 2018/06/11 19:23:21 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.69 2018/07/28 17:17:38 reinoud Exp $"); #include #include @@ -320,7 +320,7 @@ handle_signal(int sig, siginfo_t *info, l = curlwp; KASSERT(l); pcb = lwp_getpcb(l); KASSERT(pcb); - /* get address of possible faulted memory access and page aligne it */ + /* get address of possible faulted memory access and page align it */ va = (vaddr_t) info->si_addr; va = trunc_page(va);
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Wed Jun 13 19:59:14 UTC 2018 Modified Files: src/sys/arch/usermode/dev: vatapi.c Log Message: Split out error reporting and make it compile without SCSIVERBOSE To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/usermode/dev/vatapi.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/dev/vatapi.c diff -u src/sys/arch/usermode/dev/vatapi.c:1.1 src/sys/arch/usermode/dev/vatapi.c:1.2 --- src/sys/arch/usermode/dev/vatapi.c:1.1 Tue Jun 5 20:02:43 2018 +++ src/sys/arch/usermode/dev/vatapi.c Wed Jun 13 19:59:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vatapi.c,v 1.1 2018/06/05 20:02:43 reinoud Exp $ */ +/* $NetBSD: vatapi.c,v 1.2 2018/06/13 19:59:14 reinoud Exp $ */ /*- * Copyright (c) 2018 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vatapi.c,v 1.1 2018/06/05 20:02:43 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vatapi.c,v 1.2 2018/06/13 19:59:14 reinoud Exp $"); #include #include @@ -48,6 +48,8 @@ __KERNEL_RCSID(0, "$NetBSD: vatapi.c,v 1 #include #include +#include "opt_scsi.h" + /* parameter? */ #define VDEV_ATAPI_DRIVE 0 #define MAX_SIZE ((1<<16)) @@ -68,7 +70,9 @@ static void vatapi_probe_device(struct a static void vatapi_complete(void *arg); /* for debugging */ +#ifdef SCSIVERBOSE void scsipi_print_sense_data_real(struct scsi_sense_data *sense, int verbosity); +#endif /* Note its one vdev, one adapter, one channel for now */ @@ -279,6 +283,21 @@ vatapi_scsipi_request(struct scsipi_chan static void +vatapi_report_problem(scsireq_t *kreq) +{ +#ifdef SCSIVERBOSE + printf("vatapi cmd failed: "); + for (int i = 0; i < kreq->cmdlen; i++) { + printf("%02x ", kreq->cmd[i]); + } + printf("\n"); + scsipi_print_sense_data_real( + (struct scsi_sense_data *) kreq->sense, 1); +#endif +} + + +static void vatapi_complete(void *arg) { struct vatapi_softc *sc = arg; @@ -316,8 +335,7 @@ vatapi_complete(void *arg) xs->error = XS_SHORTSENSE; /* ATAPI */ memcpy(&xs->sense.scsi_sense, kreq.sense, sizeof(struct scsi_sense_data)); -// scsipi_print_sense_data_real( -//(struct scsi_sense_data *) kreq.sense, 1); + vatapi_report_problem(&kreq); break; default: thunk_printf("unhandled/unknown retstst %d\n", kreq.retsts);
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Mon Jun 11 19:35:56 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: machdep.c Log Message: Now we use timestamp info, use direct console output instead of kernel timestamped output for usage() reporting To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 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.55 src/sys/arch/usermode/usermode/machdep.c:1.56 --- src/sys/arch/usermode/usermode/machdep.c:1.55 Tue Jun 5 20:02:43 2018 +++ src/sys/arch/usermode/usermode/machdep.c Mon Jun 11 19:35:56 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.55 2018/06/05 20:02:43 reinoud Exp $ */ +/* $NetBSD: machdep.c,v 1.56 2018/06/11 19:35:56 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -37,7 +37,7 @@ #include "opt_memsize.h" #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.55 2018/06/05 20:02:43 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.56 2018/06/11 19:35:56 reinoud Exp $"); #include #include @@ -99,7 +99,7 @@ void usermode_reboot(void); static void usage(const char *pn) { - printf("usage: %s [-acdqsvxz]" + thunk_printf("usage: %s [-acdqsvxz]" " [net=,]" " [audio=]" " [disk= ...]" @@ -107,7 +107,7 @@ usage(const char *pn) " [vnc=x,]" " [vdev=atapi,device]\n", pn); - printf(" (ex. \"%s" + thunk_printf(" (ex. \"%s" " net=tap0,00:00:be:ef:ca:fe" " audio=audio0" " disk=root.fs" @@ -156,7 +156,7 @@ main(int argc, char *argv[]) char *mac = strchr(tap, ','); char *p = usermode_tap_devicebuf; if (mac == NULL) { - printf("bad net= format\n"); + thunk_printf("bad net= format\n"); return; } memset(usermode_tap_devicebuf, 0, @@ -189,13 +189,13 @@ main(int argc, char *argv[]) w = vnc; h = strchr(w, 'x'); if (h == NULL) { - printf("bad vnc= format\n"); + thunk_printf("bad vnc= format\n"); return; } *h++ = '\0'; p = strchr(h, ','); if (p == NULL) { - printf("bad vnc= format\n"); + thunk_printf("bad vnc= format\n"); return; } *p++ = '\0'; @@ -206,7 +206,7 @@ main(int argc, char *argv[]) strlen("disk=")) == 0) { if (usermode_disk_image_path_count == MAX_DISK_IMAGES) { - printf("too many disk images " + thunk_printf("too many disk images " "(increase MAX_DISK_IMAGES)\n"); usage(argv[0]); return; @@ -220,7 +220,7 @@ main(int argc, char *argv[]) char *t, *p; if (usermode_disk_image_path_count == MAX_VDEVS) { - printf("too many vdevs " + thunk_printf("too many vdevs " "(increase MAX_VDEVS)\n"); usage(argv[0]); return; @@ -228,13 +228,13 @@ main(int argc, char *argv[]) t = vdev; p = strchr(t, ','); if (p == NULL) { - printf("bad vdev= format\n"); + thunk_printf("bad vdev= format\n"); return; } *p++ = '\0'; type = vdev_type(t); if (type < 0) { - printf("unknown vdev device type\n"); + thunk_printf("unknown vdev device type\n"); return; } usermode_vdev_type[usermode_vdev_count] = type; @@ -245,7 +245,7 @@ main(int argc, char *argv[]) usermode_root_device = argv[i] + strlen("root="); } else { -printf("%s: unknown parameter\n", argv[i]); +thunk_printf("%s: unknown parameter\n", argv[i]); usage(argv[0]); return; } @@ -255,7 +255,7 @@ main(int argc, char *argv[]) r = 0; BOOT_FLAG(argv[i][j], r); if (r == 0) { -printf("-%c: unknown flag\n", argv[i][j]); +thunk_printf("unknown kernel boot flag '%c'\n", argv[i][j]); usage(argv[0]); return; }
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Mon Jun 11 19:23:21 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: trap.c Log Message: Prevent nested SIGIOs ruining the system stack To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/arch/usermode/usermode/trap.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/trap.c diff -u src/sys/arch/usermode/usermode/trap.c:1.67 src/sys/arch/usermode/usermode/trap.c:1.68 --- src/sys/arch/usermode/usermode/trap.c:1.67 Fri May 18 20:24:16 2018 +++ src/sys/arch/usermode/usermode/trap.c Mon Jun 11 19:23:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.67 2018/05/18 20:24:16 reinoud Exp $ */ +/* $NetBSD: trap.c,v 1.68 2018/06/11 19:23:21 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.67 2018/05/18 20:24:16 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.68 2018/06/11 19:23:21 reinoud Exp $"); #include #include @@ -335,7 +335,9 @@ handle_signal(int sig, siginfo_t *info, if (sig == SIGILL) print_illegal_instruction_siginfo(sig, info, ctx, pc, va, sp); - /* if we're running on a stack of our own, use the system stack */ + /* currently running on the dedicated signal stack */ + + /* if we're running on a userland stack, switch to the system stack */ from_userland = 0; if ((sp < (vaddr_t) pcb->sys_stack) || (sp > (vaddr_t) pcb->sys_stack_top)) { @@ -361,7 +363,11 @@ handle_signal(int sig, siginfo_t *info, jump_ucp.uc_stack.ss_size = sp - (vaddr_t) pcb->sys_stack; jump_ucp.uc_link = (void *) fp; /* link to old frame on stack */ - thunk_sigemptyset(&jump_ucp.uc_sigmask); + /* prevent multiple nested SIGIOs */ + if (sig == SIGIO) + thunk_sigfillset(&jump_ucp.uc_sigmask); + else + thunk_sigemptyset(&jump_ucp.uc_sigmask); jump_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK; thunk_makecontext(&jump_ucp,
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Tue Jun 5 20:02:43 UTC 2018 Modified Files: src/sys/arch/usermode/conf: GENERIC.common files.usermode src/sys/arch/usermode/dev: mainbus.c src/sys/arch/usermode/include: mainbus.h src/sys/arch/usermode/usermode: machdep.c Added Files: src/sys/arch/usermode/dev: vatapi.c Log Message: Add ATAPI passtrough support giving the NetBSD/usermode kernel full control of an ATAPI device. All ATAPI/SCSI commands are passed trough. Note that ATAPI/SCSI calls are made in the foreground still. Lengthy calls will still hug the CPU until completion. Making it asynchronous is in the pipeline To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/arch/usermode/conf/GENERIC.common cvs rdiff -u -r1.16 -r1.17 src/sys/arch/usermode/conf/files.usermode cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/dev/mainbus.c cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/dev/vatapi.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/include/mainbus.h cvs rdiff -u -r1.54 -r1.55 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/conf/GENERIC.common diff -u src/sys/arch/usermode/conf/GENERIC.common:1.27 src/sys/arch/usermode/conf/GENERIC.common:1.28 --- src/sys/arch/usermode/conf/GENERIC.common:1.27 Sat Jan 13 16:20:33 2018 +++ src/sys/arch/usermode/conf/GENERIC.common Tue Jun 5 20:02:42 2018 @@ -1,9 +1,9 @@ -# $NetBSD: GENERIC.common,v 1.27 2018/01/13 16:20:33 reinoud Exp $ +# $NetBSD: GENERIC.common,v 1.28 2018/06/05 20:02:42 reinoud Exp $ include "arch/usermode/conf/std.usermode" options INCLUDE_CONFIG_FILE -#ident "GENERIC-$Revision: 1.27 $" +#ident "GENERIC-$Revision: 1.28 $" maxusers 32 makeoptions DEBUG="-O1 -g3" @@ -64,7 +64,6 @@ ld* at mainbus? veth0 at mainbus? vaudio0 at mainbus? audio0 at vaudio0 - spkr* at audio? # PC speaker (synthesized) vncfb0 at mainbus? @@ -77,6 +76,17 @@ options WSKBD_DEFAULT_KEYREPEAT_DEL1=10 options WSKBD_DEFAULT_KEYREPEAT_DELN=200 options WSDISPLAY_COMPAT_USL # wsconscfg VT handling +# virtual devices */ +vatapi* at mainbus? +atapibus* at vatapi? + +# cd, sd, and the like +cd* at atapibus? +sd* at atapibus? +st* at atapibus? +uk* at atapibus? + +# pseudo devices pseudo-device loop pseudo-device pty pseudo-device bpfilter Index: src/sys/arch/usermode/conf/files.usermode diff -u src/sys/arch/usermode/conf/files.usermode:1.16 src/sys/arch/usermode/conf/files.usermode:1.17 --- src/sys/arch/usermode/conf/files.usermode:1.16 Fri Dec 30 20:08:36 2011 +++ src/sys/arch/usermode/conf/files.usermode Tue Jun 5 20:02:42 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.usermode,v 1.16 2011/12/30 20:08:36 jmcneill Exp $ +# $NetBSD: files.usermode,v 1.17 2018/06/05 20:02:42 reinoud Exp $ maxpartitions 8 maxusers 8 16 64 @@ -42,6 +42,16 @@ attach vncfb at thunkbus file arch/usermode/dev/vncfb.c vncfb file arch/usermode/dev/vnckbdmap.c vncfb +include "dev/scsipi/files.scsipi" +#device vscsi: scsi +#file arch/usermode/dev/vscsi.c vscsi needs-flag +#attach vscsi at thunkbus with vscsi_thunkbus +#file atch/usermode/dev/vscsi_thunkbus.c vscsi_thunkbus + +device vatapi { } : atapi, atapibus +attach vatapi at thunkbus with vatapi_thunkbus +file arch/usermode/dev/vatapi.c vatapi_thunkbus + file arch/usermode/usermode/copy.c file arch/usermode/usermode/intr.c file arch/usermode/usermode/machdep.c Index: src/sys/arch/usermode/dev/mainbus.c diff -u src/sys/arch/usermode/dev/mainbus.c:1.9 src/sys/arch/usermode/dev/mainbus.c:1.10 --- src/sys/arch/usermode/dev/mainbus.c:1.9 Sat Jan 7 18:10:18 2012 +++ src/sys/arch/usermode/dev/mainbus.c Tue Jun 5 20:02:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.9 2012/01/07 18:10:18 jmcneill Exp $ */ +/* $NetBSD: mainbus.c,v 1.10 2018/06/05 20:02:43 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.9 2012/01/07 18:10:18 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.10 2018/06/05 20:02:43 reinoud Exp $"); #include #include @@ -52,6 +52,9 @@ CFATTACH_DECL_NEW(mainbus, sizeof(mainbu extern char *usermode_disk_image_path[]; extern int usermode_disk_image_path_count; +extern int usermode_vdev_type[]; +extern char *usermode_vdev_path[]; +extern int usermode_vdev_count; extern char *usermode_tap_device; extern char *usermode_tap_eaddr; extern char *usermode_audio_device; @@ -111,6 +114,12 @@ mainbus_attach(device_t parent, device_t taa.u.diskimage.path = usermode_disk_image_path[i]; config_found_ia(self, "thunkbus", &taa, mainbus_print); } + + for (i = 0; i < usermode_vdev_count; i++) { + taa.taa_type = usermode_vdev_type[i]; + taa.u.vdev.path = usermode_vdev_path[i]; + config_found_ia(self, "thunkbus", &taa, mainbus_print); + } } static int Index:
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Mon Jun 4 20:06:52 UTC 2018 Modified Files: src/sys/arch/usermode/dev: ld_thunkbus.c Log Message: Its a hack, but make sure the pages are paged in To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/arch/usermode/dev/ld_thunkbus.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/dev/ld_thunkbus.c diff -u src/sys/arch/usermode/dev/ld_thunkbus.c:1.32 src/sys/arch/usermode/dev/ld_thunkbus.c:1.33 --- src/sys/arch/usermode/dev/ld_thunkbus.c:1.32 Sat Jan 13 10:27:58 2018 +++ src/sys/arch/usermode/dev/ld_thunkbus.c Mon Jun 4 20:06:52 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_thunkbus.c,v 1.32 2018/01/13 10:27:58 reinoud Exp $ */ +/* $NetBSD: ld_thunkbus.c,v 1.33 2018/06/04 20:06:52 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.32 2018/01/13 10:27:58 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.33 2018/06/04 20:06:52 reinoud Exp $"); #include #include @@ -271,6 +271,9 @@ ld_thunkbus_complete(void *arg) //bp->b_flags & B_READ ? "read" : "write", //(unsigned int)bp->b_bcount, (long long)offset, bp->b_data, bp->b_flags); + /* this is silly, but better make sure */ + thunk_assert_presence((vaddr_t) bp->b_data, (size_t) bp->b_bcount); + /* read/write the request */ if (bp->b_flags & B_READ) { ret = thunk_pread(sc->sc_fd, bp->b_data, bp->b_bcount, offset); @@ -285,6 +288,7 @@ ld_thunkbus_complete(void *arg) if ((ret >= 0) && (ret == bp->b_bcount)) { bp->b_resid = 0; } else { + // printf("ret = %d, errno %d?\n",(int) ret, thunk_geterrno()); bp->b_error = thunk_geterrno(); bp->b_resid = bp->b_bcount; }
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Mon Jun 4 19:53:01 UTC 2018 Modified Files: src/sys/arch/usermode/include: thunk.h src/sys/arch/usermode/usermode: thunk.c Log Message: Enhance the NetBSD/usermode thunk interface To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/arch/usermode/include/thunk.h cvs rdiff -u -r1.89 -r1.90 src/sys/arch/usermode/usermode/thunk.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/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.64 src/sys/arch/usermode/include/thunk.h:1.65 --- src/sys/arch/usermode/include/thunk.h:1.64 Fri Jun 1 08:04:57 2018 +++ src/sys/arch/usermode/include/thunk.h Mon Jun 4 19:53:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.h,v 1.64 2018/06/01 08:04:57 reinoud Exp $ */ +/* $NetBSD: thunk.h,v 1.65 2018/06/04 19:53:01 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -92,6 +92,7 @@ timer_t thunk_timer_attach(void); int thunk_timer_start(timer_t, int); int thunk_timer_getoverrun(timer_t); +void thunk_kill(pid_t pid, int sig); void thunk_exit(int); void thunk_abort(void); @@ -136,6 +137,8 @@ int thunk_sigfillset(sigset_t *sa_mask); void thunk_sigaddset(sigset_t *sa_mask, int sig); int thunk_sigprocmask(int how, const sigset_t * set, sigset_t *oset); int thunk_atexit(void (*function)(void)); +pid_t thunk_fork(void); +int thunk_ioctl(int fd, unsigned long request, void *opaque); int thunk_aio_read(struct aiocb *); int thunk_aio_write(struct aiocb *); @@ -166,6 +169,8 @@ int thunk_open_tap(const char *); int thunk_pollin_tap(int, int); int thunk_pollout_tap(int, int); +int thunk_assert_presence(vaddr_t from, size_t size); + typedef struct { unsigned int sample_rate; unsigned int precision; Index: src/sys/arch/usermode/usermode/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.89 src/sys/arch/usermode/usermode/thunk.c:1.90 --- src/sys/arch/usermode/usermode/thunk.c:1.89 Fri Jun 1 08:04:57 2018 +++ src/sys/arch/usermode/usermode/thunk.c Mon Jun 4 19:53:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.89 2018/06/01 08:04:57 reinoud Exp $ */ +/* $NetBSD: thunk.c,v 1.90 2018/06/04 19:53:01 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,7 +28,7 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.89 2018/06/01 08:04:57 reinoud Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.90 2018/06/04 19:53:01 reinoud Exp $"); #endif #define _KMEMUSER @@ -36,6 +36,7 @@ __RCSID("$NetBSD: thunk.c,v 1.89 2018/06 #define _I386_MACHTYPES_H_ #include "../include/types.h" + #include #include #include @@ -344,6 +345,12 @@ thunk_usleep(useconds_t microseconds) } void +thunk_kill(pid_t pid, int sig) +{ + kill(pid, sig); +} + +void thunk_exit(int status) { return exit(status); @@ -646,6 +653,18 @@ thunk_atexit(void (*function)(void)) return atexit(function); } +pid_t +thunk_fork(void) +{ + return fork(); +} + +int +thunk_ioctl(int fd, unsigned long request, void *opaque) +{ + return ioctl(fd, request, opaque); +} + int thunk_aio_read(struct aiocb *aiocbp) { @@ -862,6 +881,21 @@ thunk_pollout_tap(int fd, int timeout) return poll(fds, __arraycount(fds), timeout); } + +/* simply make sure its present... yeah its silly */ +int +thunk_assert_presence(vaddr_t from, size_t size) +{ + vaddr_t va; + int t = 0; + + for (va = from; va < from + (vaddr_t) size; va += PAGE_SIZE) { + t += *(int *) va; + } + return t; +} + + int thunk_audio_open(const char *path) {
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Fri Jun 1 08:04:57 UTC 2018 Modified Files: src/sys/arch/usermode/include: thunk.h src/sys/arch/usermode/usermode: thunk.c Log Message: Pretend we already included the To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sys/arch/usermode/include/thunk.h cvs rdiff -u -r1.88 -r1.89 src/sys/arch/usermode/usermode/thunk.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/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.63 src/sys/arch/usermode/include/thunk.h:1.64 --- src/sys/arch/usermode/include/thunk.h:1.63 Fri May 18 20:24:57 2018 +++ src/sys/arch/usermode/include/thunk.h Fri Jun 1 08:04:57 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.h,v 1.63 2018/05/18 20:24:57 reinoud Exp $ */ +/* $NetBSD: thunk.h,v 1.64 2018/06/01 08:04:57 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -29,7 +29,7 @@ #ifndef _ARCH_USERMODE_INCLUDE_THUNK_H #define _ARCH_USERMODE_INCLUDE_THUNK_H -#include "types.h" +#include #include #include #include Index: src/sys/arch/usermode/usermode/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.88 src/sys/arch/usermode/usermode/thunk.c:1.89 --- src/sys/arch/usermode/usermode/thunk.c:1.88 Fri May 18 05:51:23 2018 +++ src/sys/arch/usermode/usermode/thunk.c Fri Jun 1 08:04:57 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.88 2018/05/18 05:51:23 reinoud Exp $ */ +/* $NetBSD: thunk.c,v 1.89 2018/06/01 08:04:57 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,9 +28,13 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.88 2018/05/18 05:51:23 reinoud Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.89 2018/06/01 08:04:57 reinoud Exp $"); #endif +#define _KMEMUSER +#define _X86_64_MACHTYPES_H_ +#define _I386_MACHTYPES_H_ + #include "../include/types.h" #include #include @@ -42,7 +46,6 @@ __RCSID("$NetBSD: thunk.c,v 1.88 2018/05 #include #include -#define _KMEMUSER #include #include @@ -70,6 +73,7 @@ __RCSID("$NetBSD: thunk.c,v 1.88 2018/05 #include #include #include +#include #include "../include/thunk.h"
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Fri Jun 1 07:26:15 UTC 2018 Modified Files: src/sys/arch/usermode/dev: cpu.c Log Message: Pass the address of the array, this fixes issues with i386 compilation To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/arch/usermode/dev/cpu.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/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.79 src/sys/arch/usermode/dev/cpu.c:1.80 --- src/sys/arch/usermode/dev/cpu.c:1.79 Tue May 29 09:25:01 2018 +++ src/sys/arch/usermode/dev/cpu.c Fri Jun 1 07:26:15 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.79 2018/05/29 09:25:01 reinoud Exp $ */ +/* $NetBSD: cpu.c,v 1.80 2018/06/01 07:26:15 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,7 +30,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.79 2018/05/29 09:25:01 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.80 2018/06/01 07:26:15 reinoud Exp $"); #include #include @@ -353,9 +353,9 @@ cpu_setmcontext(struct lwp *l, const mco thunk_printf_debug("cpu_setmcontext\n"); #endif if ((flags & _UC_CPU) != 0) - memcpy(&ucp->uc_mcontext.__gregs, mcp->__gregs, sizeof(__gregset_t)); + memcpy(&ucp->uc_mcontext.__gregs, &mcp->__gregs, sizeof(__gregset_t)); if ((flags & _UC_FPU) != 0) - memcpy(&ucp->uc_mcontext.__fpregs, mcp->__fpregs, sizeof(__fpregset_t)); + memcpy(&ucp->uc_mcontext.__fpregs, &mcp->__fpregs, sizeof(__fpregset_t)); if ((flags & _UC_TLSBASE) != 0) lwp_setprivate(l, (void *) (uintptr_t) mcp->_mc_tlsbase);
CVS commit: src/sys/arch/usermode/conf
Module Name:src Committed By: reinoud Date: Fri Jun 1 07:22:33 UTC 2018 Modified Files: src/sys/arch/usermode/conf: Makefile.usermode Log Message: Compile NetBSD/userland without CTF for the linker doesn't allow for a single file compiled without CTF To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/arch/usermode/conf/Makefile.usermode 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/conf/Makefile.usermode diff -u src/sys/arch/usermode/conf/Makefile.usermode:1.41 src/sys/arch/usermode/conf/Makefile.usermode:1.42 --- src/sys/arch/usermode/conf/Makefile.usermode:1.41 Sat Jan 13 16:20:33 2018 +++ src/sys/arch/usermode/conf/Makefile.usermode Fri Jun 1 07:22:33 2018 @@ -1,5 +1,6 @@ -# $NetBSD: Makefile.usermode,v 1.41 2018/01/13 16:20:33 reinoud Exp $ +# $NetBSD: Makefile.usermode,v 1.42 2018/06/01 07:22:33 reinoud Exp $ +MKCTF?=no USETOOLS?= no NEED_OWN_INSTALL_TARGET?= no .include
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Fri Jun 1 07:19:50 UTC 2018 Modified Files: src/sys/arch/usermode/include: types.h Log Message: Fix compilation errors so NetBSD/usermode compiles under ./build.sh To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/usermode/include/types.h 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/include/types.h diff -u src/sys/arch/usermode/include/types.h:1.13 src/sys/arch/usermode/include/types.h:1.14 --- src/sys/arch/usermode/include/types.h:1.13 Tue May 29 07:35:39 2018 +++ src/sys/arch/usermode/include/types.h Fri Jun 1 07:19:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.13 2018/05/29 07:35:39 reinoud Exp $ */ +/* $NetBSD: types.h,v 1.14 2018/06/01 07:19:50 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -40,9 +40,31 @@ typedef struct label_t { #endif #if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE) +#if defined(__i386__) || defined(__arm__) typedef unsigned long paddr_t; typedef unsigned long psize_t; -typedef unsigned long vaddr_t; +typedef unsigned long __vaddr_t; +typedef unsigned long vsize_t; +typedef int register_t; + +#ifndef __x86_64__ +// XXX hack to allow for amd64->i386 crosscompile, why? +#define PRIxPADDR "lx" +#define PRIxPSIZE "lx" +#define PRIuPSIZE "lu" +#else +#define PRIxPADDR "llx" +#define PRIxPSIZE "llx" +#define PRIuPSIZE "llu" +#endif +#define PRIxVADDR "lx" +#define PRIxVSIZE "lx" +#define PRIuVSIZE "lu" +#define PRIxREGISTER "lx" +#elif defined(__x86_64__) +typedef unsigned long paddr_t; +typedef unsigned long psize_t; +typedef unsigned long __vaddr_t; typedef unsigned long vsize_t; typedef long int register_t; #define PRIxPADDR "lx" @@ -53,9 +75,11 @@ typedef long int register_t; #define PRIuVSIZE "lu" #define PRIxREGISTER "lx" #endif +#endif +typedef __vaddr_t vaddr_t; typedef unsigned char __cpu_simple_lock_nv_t; -typedef long int __register_t; +typedef register_t __register_t; #define __CPU_SIMPLE_LOCK_PAD
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Tue May 29 09:25:01 UTC 2018 Modified Files: src/sys/arch/usermode/dev: cpu.c Log Message: Only report the things we've passed in the mcontext and leave out flags that are not reported in the mcontext anyway! To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/arch/usermode/dev/cpu.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/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.78 src/sys/arch/usermode/dev/cpu.c:1.79 --- src/sys/arch/usermode/dev/cpu.c:1.78 Tue May 29 07:35:40 2018 +++ src/sys/arch/usermode/dev/cpu.c Tue May 29 09:25:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.78 2018/05/29 07:35:40 reinoud Exp $ */ +/* $NetBSD: cpu.c,v 1.79 2018/05/29 09:25:01 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,7 +30,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.78 2018/05/29 07:35:40 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.79 2018/05/29 09:25:01 reinoud Exp $"); #include #include @@ -322,9 +322,9 @@ cpu_getmcontext(struct lwp *l, mcontext_ #endif memcpy(mcp, &ucp->uc_mcontext, sizeof(mcontext_t)); - /* XXX be overzealous and provide all */ + /* report we have the CPU FPU and TLSBASE registers */ mcp->_mc_tlsbase = (uintptr_t) l->l_private; - *flags = _UC_CPU | _UC_STACK | _UC_SIGMASK | _UC_FPU | _UC_TLSBASE; + *flags = _UC_CPU | _UC_FPU | _UC_TLSBASE; return; } @@ -338,7 +338,7 @@ cpu_mcontext_validate(struct lwp *l, con */ /* XXX NO CHECKING! XXX */ #ifdef CPU_DEBUG - thunk_printf("cpu_mcontext_validate\n"); + thunk_printf_debug("cpu_mcontext_validate\n"); #endif return 0; }
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Tue May 29 07:35:40 UTC 2018 Modified Files: src/sys/arch/usermode/dev: cpu.c src/sys/arch/usermode/include: types.h Log Message: Implement cpu_lwp_setprivate(). This removes the need for the cpu_switch() hack. Programs with TLS work fine now, including gdb! To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/arch/usermode/dev/cpu.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/usermode/include/types.h 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/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.77 src/sys/arch/usermode/dev/cpu.c:1.78 --- src/sys/arch/usermode/dev/cpu.c:1.77 Tue May 29 07:09:21 2018 +++ src/sys/arch/usermode/dev/cpu.c Tue May 29 07:35:40 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.77 2018/05/29 07:09:21 reinoud Exp $ */ +/* $NetBSD: cpu.c,v 1.78 2018/05/29 07:35:40 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,7 +30,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.77 2018/05/29 07:09:21 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.78 2018/05/29 07:35:40 reinoud Exp $"); #include #include @@ -193,6 +193,22 @@ cpu_need_proftick(struct lwp *l) { } +int +cpu_lwp_setprivate(lwp_t *l, void *ptr) +{ + struct pcb *pcb = lwp_getpcb(l); + + /* set both ucontexts up for TLS just in case */ + pcb->pcb_ucp.uc_mcontext._mc_tlsbase = + (uintptr_t) ptr; + pcb->pcb_ucp.uc_flags |= _UC_TLSBASE; + + pcb->pcb_userret_ucp.uc_mcontext._mc_tlsbase = + (uintptr_t) ptr; + pcb->pcb_userret_ucp.uc_flags |= _UC_TLSBASE; + + return 0; +} static void @@ -214,18 +230,8 @@ cpu_switchto_atomic(lwp_t *oldlwp, lwp_t oldpcb->pcb_errno = thunk_geterrno(); thunk_seterrno(newpcb->pcb_errno); - - /* set both ucontexts up for TLS just in case */ - - newpcb->pcb_ucp.uc_mcontext._mc_tlsbase = - (uintptr_t) newlwp->l_private; - newpcb->pcb_ucp.uc_flags |= _UC_TLSBASE; - - newpcb->pcb_userret_ucp.uc_mcontext._mc_tlsbase = - (uintptr_t) newlwp->l_private; - newpcb->pcb_userret_ucp.uc_flags |= _UC_TLSBASE; - curlwp = newlwp; + splx(s); if (thunk_setcontext(&newpcb->pcb_ucp)) Index: src/sys/arch/usermode/include/types.h diff -u src/sys/arch/usermode/include/types.h:1.12 src/sys/arch/usermode/include/types.h:1.13 --- src/sys/arch/usermode/include/types.h:1.12 Thu Jan 26 15:55:10 2017 +++ src/sys/arch/usermode/include/types.h Tue May 29 07:35:39 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.12 2017/01/26 15:55:10 christos Exp $ */ +/* $NetBSD: types.h,v 1.13 2018/05/29 07:35:39 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -67,6 +67,7 @@ typedef long int __register_t; #endif #define __HAVE_CPU_DATA_FIRST +#define __HAVE_CPU_LWP_SETPRIVATE #define __HAVE_MM_MD_KERNACC #define __HAVE_COMPAT_NETBSD32
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Tue May 29 07:09:22 UTC 2018 Modified Files: src/sys/arch/usermode/dev: cpu.c Log Message: Only set requested parts of the mcontext in cpu_setmcontext() Make the atomic switcher `atomic' by using splhigh() To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/sys/arch/usermode/dev/cpu.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/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.76 src/sys/arch/usermode/dev/cpu.c:1.77 --- src/sys/arch/usermode/dev/cpu.c:1.76 Thu May 24 19:39:04 2018 +++ src/sys/arch/usermode/dev/cpu.c Tue May 29 07:09:21 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.76 2018/05/24 19:39:04 reinoud Exp $ */ +/* $NetBSD: cpu.c,v 1.77 2018/05/29 07:09:21 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,7 +30,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.76 2018/05/24 19:39:04 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.77 2018/05/29 07:09:21 reinoud Exp $"); #include #include @@ -194,7 +194,6 @@ cpu_need_proftick(struct lwp *l) } -/* XXX make sure this is atomic? */ static void cpu_switchto_atomic(lwp_t *oldlwp, lwp_t *newlwp) @@ -202,19 +201,22 @@ cpu_switchto_atomic(lwp_t *oldlwp, lwp_t struct pcb *oldpcb; struct pcb *newpcb; struct cpu_info *ci; + int s; oldpcb = oldlwp ? lwp_getpcb(oldlwp) : NULL; newpcb = lwp_getpcb(newlwp); ci = curcpu(); - ci->ci_stash = oldlwp; + s = splhigh(); + ci->ci_stash = oldlwp; if (oldpcb) oldpcb->pcb_errno = thunk_geterrno(); thunk_seterrno(newpcb->pcb_errno); /* set both ucontexts up for TLS just in case */ + newpcb->pcb_ucp.uc_mcontext._mc_tlsbase = (uintptr_t) newlwp->l_private; newpcb->pcb_ucp.uc_flags |= _UC_TLSBASE; @@ -224,8 +226,11 @@ cpu_switchto_atomic(lwp_t *oldlwp, lwp_t newpcb->pcb_userret_ucp.uc_flags |= _UC_TLSBASE; curlwp = newlwp; + splx(s); + if (thunk_setcontext(&newpcb->pcb_ucp)) panic("setcontext failed"); + /* not reached */ } @@ -341,11 +346,28 @@ cpu_setmcontext(struct lwp *l, const mco #ifdef CPU_DEBUG thunk_printf_debug("cpu_setmcontext\n"); #endif - ucp->uc_flags = flags; - memcpy(&ucp->uc_mcontext, mcp, sizeof(mcontext_t)); + if ((flags & _UC_CPU) != 0) + memcpy(&ucp->uc_mcontext.__gregs, mcp->__gregs, sizeof(__gregset_t)); + if ((flags & _UC_FPU) != 0) + memcpy(&ucp->uc_mcontext.__fpregs, mcp->__fpregs, sizeof(__fpregset_t)); + if ((flags & _UC_TLSBASE) != 0) + lwp_setprivate(l, (void *) (uintptr_t) mcp->_mc_tlsbase); - /* update our private, it might be altered in userland */ - l->l_private = (void *) ucp->uc_mcontext._mc_tlsbase; +#if 0 + /* + * XXX we ignore the set and clear stack since signals are done + * slightly differently. + */ +thunk_printf("%s: flags %x\n", __func__, flags); + mutex_enter(l->l_proc->p_lock); + if (flags & _UC_SETSTACK) + l->l_sigstk.ss_flags |= SS_ONSTACK; + if (flags & _UC_CLRSTACK) + l->l_sigstk.ss_flags &= ~SS_ONSTACK; + mutex_exit(l->l_proc->p_lock); +#endif + + ucp->uc_flags |= (flags & (_UC_CPU | _UC_FPU | _UC_TLSBASE)); return 0; } @@ -410,7 +432,6 @@ cpu_lwp_fork(struct lwp *l1, struct lwp l2 ? l2->l_name : "none", l2, stack, (int)stacksize); #endif - if (stack) panic("%s: stack passed, can't handle\n", __func__);
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Thu May 24 19:39:04 UTC 2018 Modified Files: src/sys/arch/usermode/dev: cpu.c Log Message: First try at TLS support and getcontext/setcontext/swapcontext support. To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/arch/usermode/dev/cpu.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/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.75 src/sys/arch/usermode/dev/cpu.c:1.76 --- src/sys/arch/usermode/dev/cpu.c:1.75 Thu May 17 19:00:39 2018 +++ src/sys/arch/usermode/dev/cpu.c Thu May 24 19:39:04 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.75 2018/05/17 19:00:39 reinoud Exp $ */ +/* $NetBSD: cpu.c,v 1.76 2018/05/24 19:39:04 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,7 +30,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.75 2018/05/17 19:00:39 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.76 2018/05/24 19:39:04 reinoud Exp $"); #include #include @@ -66,6 +66,11 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.75 static int cpu_match(device_t, cfdata_t, void *); static void cpu_attach(device_t, device_t, void *); +/* XXX */ +//extern void *_lwp_getprivate(void); +//extern int _lwp_setprivate(void *); + + struct cpu_info cpu_info_primary = { .ci_dev = 0, .ci_self = &cpu_info_primary, @@ -130,7 +135,6 @@ cpu_configure(void) if (config_rootfound("mainbus", NULL) == NULL) panic("configure: mainbus not configured"); - spl0(); } @@ -189,6 +193,8 @@ cpu_need_proftick(struct lwp *l) { } + +/* XXX make sure this is atomic? */ static void cpu_switchto_atomic(lwp_t *oldlwp, lwp_t *newlwp) @@ -208,12 +214,22 @@ cpu_switchto_atomic(lwp_t *oldlwp, lwp_t thunk_seterrno(newpcb->pcb_errno); + /* set both ucontexts up for TLS just in case */ + newpcb->pcb_ucp.uc_mcontext._mc_tlsbase = + (uintptr_t) newlwp->l_private; + newpcb->pcb_ucp.uc_flags |= _UC_TLSBASE; + + newpcb->pcb_userret_ucp.uc_mcontext._mc_tlsbase = + (uintptr_t) newlwp->l_private; + newpcb->pcb_userret_ucp.uc_flags |= _UC_TLSBASE; + curlwp = newlwp; if (thunk_setcontext(&newpcb->pcb_ucp)) panic("setcontext failed"); /* not reached */ } + lwp_t * cpu_switchto(lwp_t *oldlwp, lwp_t *newlwp, bool returning) { @@ -232,17 +248,23 @@ cpu_switchto(lwp_t *oldlwp, lwp_t *newlw newlwp ? newlwp->l_lid : -1); if (oldpcb) { thunk_printf_debug("oldpcb uc_link=%p, uc_stack.ss_sp=%p, " - "uc_stack.ss_size=%d\n", + "uc_stack.ss_size=%d, l_private %p, uc_mcontext._mc_tlsbase=%p(%s)\n", oldpcb->pcb_ucp.uc_link, oldpcb->pcb_ucp.uc_stack.ss_sp, - (int)oldpcb->pcb_ucp.uc_stack.ss_size); + (int)oldpcb->pcb_ucp.uc_stack.ss_size, + (void *) oldlwp->l_private, + (void *) oldpcb->pcb_ucp.uc_mcontext._mc_tlsbase, + oldpcb->pcb_ucp.uc_flags & _UC_TLSBASE? "ON":"off"); } if (newpcb) { - thunk_printf_debug("newpcb uc_link=%p, uc_stack.ss_sp=%p, " - "uc_stack.ss_size=%d\n", + thunk_printf_debug("newpewcb uc_link=%p, uc_stack.ss_sp=%p, " + "uc_stack.ss_size=%d, l_private %p, uc_mcontext._mc_tlsbase=%p(%s)\n", newpcb->pcb_ucp.uc_link, newpcb->pcb_ucp.uc_stack.ss_sp, - (int)newpcb->pcb_ucp.uc_stack.ss_size); + (int)newpcb->pcb_ucp.uc_stack.ss_size, + (void *) newlwp->l_private, + (void *) newpcb->pcb_ucp.uc_mcontext._mc_tlsbase, + newpcb->pcb_ucp.uc_flags & _UC_TLSBASE? "ON":"off"); } #endif /* !CPU_DEBUG */ @@ -250,7 +272,6 @@ cpu_switchto(lwp_t *oldlwp, lwp_t *newlw KASSERT(newlwp); thunk_makecontext(&sc->sc_ucp, (void (*)(void)) cpu_switchto_atomic, 2, oldlwp, newlwp, NULL, NULL); - KASSERT(sc); if (oldpcb) { thunk_swapcontext(&oldpcb->pcb_ucp, &sc->sc_ucp); @@ -284,11 +305,16 @@ cpu_getmcontext(struct lwp *l, mcontext_ { struct pcb *pcb = lwp_getpcb(l); ucontext_t *ucp = &pcb->pcb_userret_ucp; - + #ifdef CPU_DEBUG thunk_printf_debug("cpu_getmcontext\n"); #endif memcpy(mcp, &ucp->uc_mcontext, sizeof(mcontext_t)); + + /* XXX be overzealous and provide all */ + mcp->_mc_tlsbase = (uintptr_t) l->l_private; + *flags = _UC_CPU | _UC_STACK | _UC_SIGMASK | _UC_FPU | _UC_TLSBASE; + return; } @@ -299,6 +325,10 @@ cpu_mcontext_validate(struct lwp *l, con * can we check here? or should that be done in the target * specific places? */ + /* XXX NO CHECKING! XXX */ +#ifdef CPU_DEBUG + thunk_printf("cpu_mcontext_validate\n"); +#endif return 0; } @@ -311,7 +341,12 @@ cpu_setmcontext(struct lwp *l, const mco #ifdef CPU_DEBUG thunk_printf_debug("cpu_setmcontext\n"); #endif + ucp->uc_flags = flags; memcpy(&ucp->uc_mcontext, mcp, sizeof(mcontext_t)); + + /* update our private, it might be altered in userland */ + l->l_private = (void *) ucp->uc_mcontext._mc_tlsbase; + return 0; } @@ -382,10 +417,14 @@ cpu_lwp_fork(str
CVS commit: src/sys/arch/usermode/target
Module Name:src Committed By: reinoud Date: Tue May 22 14:38:10 UTC 2018 Modified Files: src/sys/arch/usermode/target/i386: cpu_i386.c src/sys/arch/usermode/target/x86_64: cpu_x86_64.c Log Message: Include now its available To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/usermode/target/i386/cpu_i386.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/target/x86_64/cpu_x86_64.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/target/i386/cpu_i386.c diff -u src/sys/arch/usermode/target/i386/cpu_i386.c:1.5 src/sys/arch/usermode/target/i386/cpu_i386.c:1.6 --- src/sys/arch/usermode/target/i386/cpu_i386.c:1.5 Fri May 18 20:21:14 2018 +++ src/sys/arch/usermode/target/i386/cpu_i386.c Tue May 22 14:38:10 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_i386.c,v 1.5 2018/05/18 20:21:14 reinoud Exp $ */ +/* $NetBSD: cpu_i386.c,v 1.6 2018/05/22 14:38:10 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -29,7 +29,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.5 2018/05/18 20:21:14 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.6 2018/05/22 14:38:10 reinoud Exp $"); #include #include @@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v #include #include #include +#include #include "opt_exec.h" @@ -89,11 +90,6 @@ struct sigframe_siginfo { /* * mcontext extensions to handle signal delivery. */ -#define _UC_SETSTACK 0x0001 -#define _UC_CLRSTACK 0x0002 -#define _UC_VM 0x0004 -#define _UC_TLSBASE 0x0008 - void sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask) Index: src/sys/arch/usermode/target/x86_64/cpu_x86_64.c diff -u src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.4 src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.5 --- src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.4 Fri May 18 21:05:10 2018 +++ src/sys/arch/usermode/target/x86_64/cpu_x86_64.c Tue May 22 14:38:10 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_x86_64.c,v 1.4 2018/05/18 21:05:10 reinoud Exp $ */ +/* $NetBSD: cpu_x86_64.c,v 1.5 2018/05/22 14:38:10 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -29,7 +29,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c,v 1.4 2018/05/18 21:05:10 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c,v 1.5 2018/05/22 14:38:10 reinoud Exp $"); #include #include @@ -49,7 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c #include #include #include - +#include #if 0 static void dump_regs(register_t *reg);; @@ -84,16 +84,9 @@ struct sigframe_siginfo { }; -/* should be the same as i386 */ /* * mcontext extensions to handle signal delivery. */ -#define _UC_SETSTACK 0x0001 -#define _UC_CLRSTACK 0x0002 -#define _UC_VM 0x0004 -#define _UC_TLSBASE 0x0008 - - void sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask) {
CVS commit: src/sys/arch/usermode/target/x86_64
Module Name:src Committed By: reinoud Date: Fri May 18 21:05:10 UTC 2018 Modified Files: src/sys/arch/usermode/target/x86_64: cpu_x86_64.c Log Message: Remove outdated comment To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/target/x86_64/cpu_x86_64.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/target/x86_64/cpu_x86_64.c diff -u src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.3 src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.4 --- src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.3 Fri May 18 20:11:48 2018 +++ src/sys/arch/usermode/target/x86_64/cpu_x86_64.c Fri May 18 21:05:10 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_x86_64.c,v 1.3 2018/05/18 20:11:48 reinoud Exp $ */ +/* $NetBSD: cpu_x86_64.c,v 1.4 2018/05/18 21:05:10 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,15 +27,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* - * Note that this machdep.c uses the `dummy' mcontext_t defined for usermode. - * This is basicly a blob of PAGE_SIZE big. We might want to switch over to - * non-generic mcontext_t's one day, but will this break non-NetBSD hosts? - */ - #include -__KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c,v 1.3 2018/05/18 20:11:48 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c,v 1.4 2018/05/18 21:05:10 reinoud Exp $"); #include #include
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Fri May 18 20:24:57 UTC 2018 Modified Files: src/sys/arch/usermode/include: thunk.h Log Message: Include OUR types.h and not the machine's. A small step to allow for crosscompilation. To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/usermode/include/thunk.h 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/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.62 src/sys/arch/usermode/include/thunk.h:1.63 --- src/sys/arch/usermode/include/thunk.h:1.62 Fri Feb 6 10:25:13 2015 +++ src/sys/arch/usermode/include/thunk.h Fri May 18 20:24:57 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.h,v 1.62 2015/02/06 10:25:13 prlw1 Exp $ */ +/* $NetBSD: thunk.h,v 1.63 2018/05/18 20:24:57 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -29,7 +29,7 @@ #ifndef _ARCH_USERMODE_INCLUDE_THUNK_H #define _ARCH_USERMODE_INCLUDE_THUNK_H -#include +#include "types.h" #include #include #include
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Fri May 18 20:24:16 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: trap.c Log Message: Replace the dynamically allocated signal stack to a static claimed one and add diagnostic messages that can be enabled. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/arch/usermode/usermode/trap.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/trap.c diff -u src/sys/arch/usermode/usermode/trap.c:1.66 src/sys/arch/usermode/usermode/trap.c:1.67 --- src/sys/arch/usermode/usermode/trap.c:1.66 Sat Aug 4 14:53:32 2012 +++ src/sys/arch/usermode/usermode/trap.c Fri May 18 20:24:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.66 2012/08/04 14:53:32 reinoud Exp $ */ +/* $NetBSD: trap.c,v 1.67 2018/05/18 20:24:16 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.66 2012/08/04 14:53:32 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.67 2018/05/18 20:24:16 reinoud Exp $"); #include #include @@ -62,6 +62,7 @@ static sigfunc_t sigio; static sigfunc_t pass_on; /* raw signal handlers */ +static charsig_stack[SIGSTKSZ]; static stack_t sigstk; ucontext_t jump_ucp; @@ -108,8 +109,7 @@ setup_signal_handlers(void) * effects. Especially ld.so and friends have such tiny stacks that * its not feasable. */ - if ((sigstk.ss_sp = thunk_malloc(SIGSTKSZ)) == NULL) - panic("can't allocate signal stack space\n"); + sigstk.ss_sp= sig_stack; sigstk.ss_size = SIGSTKSZ; sigstk.ss_flags = 0; if (thunk_sigaltstack(&sigstk, 0) < 0) @@ -293,8 +293,8 @@ print_illegal_instruction_siginfo(int si #endif } #else /* DEBUG */ -#define print_mem_access_siginfo(s, i, c, p, v, sp) -#define print_illegal_instruction_siginfo(s, i, c, p, v, sp) +#define print_mem_access_siginfo(s, i, c, p, v, sp) {} +#define print_illegal_instruction_siginfo(s, i, c, p, v, sp) {} #endif /* DEBUG */ @@ -349,7 +349,7 @@ handle_signal(int sig, siginfo_t *info, sp = fp - sizeof(register_t); /* slack */ /* sanity check before copying */ - if (fp - 2*PAGE_SIZE < (vaddr_t) pcb->sys_stack) + if (fp - 4*PAGE_SIZE < (vaddr_t) pcb->sys_stack) panic("%s: out of system stack", __func__); } @@ -431,6 +431,11 @@ pagefault(siginfo_t *info, vaddr_t from_ } /* ask UVM */ +#if 0 +thunk_printf("%s: l %p, pcb %p, ", __func__, l, pcb); +thunk_printf("pc %p, va %p ", (void *) pc, (void *) va); +thunk_printf("derived atype %d\n", atype); +#endif thunk_printf_debug("pmap fault couldn't handle it! : " "derived atype %d\n", atype); @@ -452,10 +457,6 @@ pagefault(siginfo_t *info, vaddr_t from_ goto out; } - /* something got wrong */ - thunk_printf("%s: uvm fault %d, pc %p, va %p, from_kernel %d\n", - __func__, error, (void *) pc, (void *) va, from_kernel); - /* check if its from copyin/copyout */ if (onfault) { panic("%s: can't call onfault yet\n", __func__); @@ -468,11 +469,18 @@ pagefault(siginfo_t *info, vaddr_t from_ goto out; } - if (from_kernel) + if (from_kernel) { + thunk_printf("%s: uvm fault %d, pc %p, va %p, from_kernel %d\n", + __func__, error, (void *) pc, (void *) va, from_kernel); panic("Unhandled page fault in kernel mode"); + } /* send signal */ - thunk_printf("giving signal to userland\n"); + /* something got wrong */ + thunk_printf_debug("%s: uvm fault %d, pc %p, va %p, from_kernel %d\n", + __func__, error, (void *) pc, (void *) va, from_kernel); + + thunk_printf_debug("giving signal to userland\n"); KASSERT(from_userland); KSI_INIT_TRAP(&ksi);
CVS commit: src/sys/arch/usermode/target/i386
Module Name:src Committed By: reinoud Date: Fri May 18 20:21:14 UTC 2018 Modified Files: src/sys/arch/usermode/target/i386: cpu_i386.c Log Message: Use knowledge of mcontext for i386 support To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/target/i386/cpu_i386.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/target/i386/cpu_i386.c diff -u src/sys/arch/usermode/target/i386/cpu_i386.c:1.4 src/sys/arch/usermode/target/i386/cpu_i386.c:1.5 --- src/sys/arch/usermode/target/i386/cpu_i386.c:1.4 Sat Mar 3 21:15:16 2012 +++ src/sys/arch/usermode/target/i386/cpu_i386.c Fri May 18 20:21:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_i386.c,v 1.4 2012/03/03 21:15:16 reinoud Exp $ */ +/* $NetBSD: cpu_i386.c,v 1.5 2018/05/18 20:21:14 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,14 +27,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* - * Note that this machdep.c uses the `dummy' mcontext_t defined for usermode. - * This is basicly a blob of PAGE_SIZE big. We might want to switch over to - * non-generic mcontext_t's one day, but will this break non-NetBSD hosts? - */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.4 2012/03/03 21:15:16 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.5 2018/05/18 20:21:14 reinoud Exp $"); #include #include @@ -117,7 +112,7 @@ sendsig_siginfo(const ksiginfo_t *ksi, c KASSERT(mutex_owned(p->p_lock)); ucp = &pcb->pcb_userret_ucp; - reg = (register_t *) &ucp->uc_mcontext; + reg = (register_t *) &ucp->uc_mcontext.__gregs; #if 0 thunk_printf("%s: ", __func__); thunk_printf("flags %d, ", (int) ksi->ksi_flags); @@ -198,7 +193,7 @@ setregs(struct lwp *l, struct exec_packa /* set up the user context */ ucp = &pcb->pcb_userret_ucp; - reg = (int *) &ucp->uc_mcontext; + reg = (int *) &ucp->uc_mcontext.__gregs; for (i = 4; i < 11; i++) reg[i] = 0; @@ -228,7 +223,7 @@ setregs(struct lwp *l, struct exec_packa void md_syscall_get_syscallnumber(ucontext_t *ucp, uint32_t *code) { - uint *reg = (int *) &ucp->uc_mcontext; + uint *reg = (int *) &ucp->uc_mcontext.__gregs; *code = reg[11]; /* EAX */ } @@ -236,7 +231,7 @@ int md_syscall_getargs(lwp_t *l, ucontext_t *ucp, int nargs, int argsize, register_t *args) { - uint *reg = (int *) &ucp->uc_mcontext; + uint *reg = (int *) &ucp->uc_mcontext.__gregs; register_t *sp = (register_t *) reg[17];/* ESP */ int ret; @@ -250,7 +245,7 @@ void md_syscall_set_returnargs(lwp_t *l, ucontext_t *ucp, int error, register_t *rval) { - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; reg[16] &= ~PSL_C; /* EFL */ if (error > 0) { @@ -270,7 +265,7 @@ register_t md_get_pc(ucontext_t *ucp) { KASSERT(ucp); - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; return reg[14]; /* EIP */ } @@ -279,7 +274,7 @@ register_t md_get_sp(ucontext_t *ucp) { KASSERT(ucp); - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; return reg[17]; /* ESP */ } @@ -307,7 +302,7 @@ void md_syscall_get_opcode(ucontext_t *ucp, uint32_t *opcode) { KASSERT(ucp); - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; // uint8_t *p8 = (uint8_t *) (reg[14]); uint16_t *p16 = (uint16_t*) (reg[14]); /* EIP */ @@ -328,7 +323,7 @@ void md_syscall_inc_pc(ucontext_t *ucp, uint32_t opcode) { KASSERT(ucp); - uint *reg = (int *) &ucp->uc_mcontext; + uint *reg = (int *) &ucp->uc_mcontext.__gregs; /* advance program counter */ switch (opcode) { @@ -349,7 +344,7 @@ void md_syscall_dec_pc(ucontext_t *ucp, uint32_t opcode) { KASSERT(ucp); - uint *reg = (int *) &ucp->uc_mcontext; + uint *reg = (int *) &ucp->uc_mcontext.__gregs; switch (opcode) { case 0xff0f: /* UD1 */
CVS commit: src/sys/arch/usermode/target/x86_64
Module Name:src Committed By: reinoud Date: Fri May 18 20:11:48 UTC 2018 Modified Files: src/sys/arch/usermode/target/x86_64: cpu_x86_64.c Log Message: Use knowledge about the mcontext To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/target/x86_64/cpu_x86_64.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/target/x86_64/cpu_x86_64.c diff -u src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.2 src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.3 --- src/sys/arch/usermode/target/x86_64/cpu_x86_64.c:1.2 Sat Jan 14 17:42:52 2012 +++ src/sys/arch/usermode/target/x86_64/cpu_x86_64.c Fri May 18 20:11:48 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_x86_64.c,v 1.2 2012/01/14 17:42:52 reinoud Exp $ */ +/* $NetBSD: cpu_x86_64.c,v 1.3 2018/05/18 20:11:48 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -35,7 +35,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c,v 1.2 2012/01/14 17:42:52 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_x86_64.c,v 1.3 2018/05/18 20:11:48 reinoud Exp $"); #include #include @@ -118,7 +118,7 @@ sendsig_siginfo(const ksiginfo_t *ksi, c KASSERT(mutex_owned(p->p_lock)); ucp = &pcb->pcb_userret_ucp; - reg = (register_t *) &ucp->uc_mcontext; + reg = (register_t *) &ucp->uc_mcontext.__gregs; #if 0 thunk_printf("%s: ", __func__); thunk_printf("flags %d, ", (int) ksi->ksi_flags); @@ -195,7 +195,7 @@ setregs(struct lwp *l, struct exec_packa /* set up the user context */ ucp = &pcb->pcb_userret_ucp; - reg = (register_t *) &ucp->uc_mcontext; + reg = (register_t *) &ucp->uc_mcontext.__gregs; for (i = 0; i < 15; i++) reg[i] = 0; @@ -213,7 +213,7 @@ setregs(struct lwp *l, struct exec_packa void md_syscall_get_syscallnumber(ucontext_t *ucp, uint32_t *code) { - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; *code = reg[14]; /* RAX */ } @@ -221,7 +221,7 @@ int md_syscall_getargs(lwp_t *l, ucontext_t *ucp, int nargs, int argsize, register_t *args) { - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; register_t *sp = (register_t *) reg[24];/* RSP */ int ret; @@ -251,7 +251,7 @@ void md_syscall_set_returnargs(lwp_t *l, ucontext_t *ucp, int error, register_t *rval) { - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; reg[23] &= ~PSL_C; /* RFLAGS */ if (error > 0) { @@ -270,7 +270,7 @@ md_syscall_set_returnargs(lwp_t *l, ucon register_t md_get_pc(ucontext_t *ucp) { - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; return reg[21]; /* RIP */ } @@ -278,7 +278,7 @@ md_get_pc(ucontext_t *ucp) register_t md_get_sp(ucontext_t *ucp) { - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; return reg[24]; /* RSP */ } @@ -306,7 +306,7 @@ md_syscall_check_opcode(ucontext_t *ucp) void md_syscall_get_opcode(ucontext_t *ucp, uint32_t *opcode) { - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; // uint8_t *p8 = (uint8_t *) (reg[21]); uint16_t *p16 = (uint16_t*) (reg[21]); /* RIP */ @@ -326,7 +326,7 @@ md_syscall_get_opcode(ucontext_t *ucp, u void md_syscall_inc_pc(ucontext_t *ucp, uint32_t opcode) { - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; /* advance program counter */ switch (opcode) { @@ -346,7 +346,7 @@ md_syscall_inc_pc(ucontext_t *ucp, uint3 void md_syscall_dec_pc(ucontext_t *ucp, uint32_t opcode) { - register_t *reg = (register_t *) &ucp->uc_mcontext; + register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs; switch (opcode) { case 0xff0f: /* UD1 */
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Fri May 18 20:10:25 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: process_machdep.c Log Message: Second part for creating sensible coredumps To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/usermode/process_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/process_machdep.c diff -u src/sys/arch/usermode/usermode/process_machdep.c:1.4 src/sys/arch/usermode/usermode/process_machdep.c:1.5 --- src/sys/arch/usermode/usermode/process_machdep.c:1.4 Sat Jan 13 15:15:03 2018 +++ src/sys/arch/usermode/usermode/process_machdep.c Fri May 18 20:10:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: process_machdep.c,v 1.4 2018/01/13 15:15:03 reinoud Exp $ */ +/* $NetBSD: process_machdep.c,v 1.5 2018/05/18 20:10:25 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -26,58 +26,135 @@ * POSSIBILITY OF SUCH DAMAGE. */ + +/* from sys/arch/amd64/amd64/process_machdep.c */ +/* + * This file may seem a bit stylized, but that so that it's easier to port. + * Functions to be implemented here are: + * + * process_read_regs(proc, regs) + * Get the current user-visible register set from the process + * and copy it into the regs structure (). + * The process is stopped at the time read_regs is called. + * + * process_write_regs(proc, regs) + * Update the current register set from the passed in regs + * structure. Take care to avoid clobbering special CPU + * registers or privileged bits in the PSL. + * The process is stopped at the time write_regs is called. + * + * process_read_fpregs(proc, regs, sz) + * Get the current user-visible register set from the process + * and copy it into the regs structure (). + * The process is stopped at the time read_fpregs is called. + * + * process_write_fpregs(proc, regs, sz) + * Update the current register set from the passed in regs + * structure. Take care to avoid clobbering special CPU + * registers or privileged bits in the PSL. + * The process is stopped at the time write_fpregs is called. + * + * process_read_dbregs(proc, regs, sz) + * Get the current user-visible register set from the process + * and copy it into the regs structure (). + * The process is stopped at the time read_dbregs is called. + * + * process_write_dbregs(proc, regs, sz) + * Update the current register set from the passed in regs + * structure. Take care to avoid clobbering special CPU + * registers or privileged bits in the PSL. + * The process is stopped at the time write_dbregs is called. + * + * process_sstep(proc) + * Arrange for the process to trap after executing a single instruction. + * + * process_set_pc(proc) + * Set the process's program counter. + */ + #include -__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.4 2018/01/13 15:15:03 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.5 2018/05/18 20:10:25 reinoud Exp $"); #include #include #include +#include +#include +#include + +#include + int process_read_regs(struct lwp *l, struct reg *regs) { + struct pcb *pcb = lwp_getpcb(l); + ucontext_t *ucp; + register_t *reg; + + ucp = &pcb->pcb_userret_ucp; + reg = (register_t *) &ucp->uc_mcontext.__gregs; + + memcpy(regs, reg, sizeof(__gregset_t)); + return 0; } int process_read_fpregs(struct lwp *l, struct fpreg *regs, size_t *sz) { + struct pcb *pcb = lwp_getpcb(l); + ucontext_t *ucp; + register_t *reg; + + ucp = &pcb->pcb_userret_ucp; + reg = (register_t *) &ucp->uc_mcontext.__fpregs; + + *sz = sizeof(__fpregset_t); + memcpy(regs, reg, *sz); + return 0; } int process_write_regs(struct lwp *l, const struct reg *regs) { +thunk_printf("%s called, not implemented\n", __func__); return 0; } int process_write_fpregs(struct lwp *l, const struct fpreg *regs, size_t sz) { +thunk_printf("%s called, not implemented\n", __func__); return 0; } int process_sstep(struct lwp *l, int sstep) { +thunk_printf("%s called, not implemented\n", __func__); return 0; } int process_set_pc(struct lwp *l, void *addr) { +thunk_printf("%s called, not implemented\n", __func__); return 0; } int process_write_dbregs(struct lwp *l, const struct dbreg *regs, size_t sz) { +thunk_printf("%s called, not implemented\n", __func__); return 0; } int process_read_dbregs(struct lwp *l, struct dbreg *regs, size_t *sz) { +thunk_printf("%s called, not implemented\n", __func__); return 0; }
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Fri May 18 20:09:33 UTC 2018 Modified Files: src/sys/arch/usermode/include: reg.h Log Message: Implement own process register capture from userland. NetBSD/usermode now creates readable and sensible coredumps To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/reg.h 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/include/reg.h diff -u src/sys/arch/usermode/include/reg.h:1.3 src/sys/arch/usermode/include/reg.h:1.4 --- src/sys/arch/usermode/include/reg.h:1.3 Sat Jan 13 14:39:15 2018 +++ src/sys/arch/usermode/include/reg.h Fri May 18 20:09:32 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: reg.h,v 1.3 2018/01/13 14:39:15 reinoud Exp $ */ +/* $NetBSD: reg.h,v 1.4 2018/05/18 20:09:32 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -29,10 +29,16 @@ #ifndef _ARCH_USERMODE_INCLUDE_REG_H #define _ARCH_USERMODE_INCLUDE_REG_H +#include "machine/mcontext.h" + +/* registers are already in the right order since they follow mcontext.h */ struct reg { + __gregset_t regs; }; +/* registers are already in the right order since they follow mcontext.h */ struct fpreg { +__fpregset_t fpregs; }; /* x86_64 only */
CVS commit: src/sys/arch/usermode/conf
Module Name:src Committed By: reinoud Date: Fri May 18 19:04:11 UTC 2018 Added Files: src/sys/arch/usermode/conf: kern.ldscript Log Message: Where did kern.ldscript go? To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/conf/kern.ldscript Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/usermode/conf/kern.ldscript diff -u /dev/null src/sys/arch/usermode/conf/kern.ldscript:1.1 --- /dev/null Fri May 18 19:04:11 2018 +++ src/sys/arch/usermode/conf/kern.ldscript Fri May 18 19:04:10 2018 @@ -0,0 +1,73 @@ +/* $NetBSD: kern.ldscript,v 1.1 2018/05/18 19:04:10 reinoud Exp $ */ + +#include "assym.h" + +ENTRY(_start) +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + .text : + { + *(.text) + *(.text.*) + *(.stub) + } + _etext = . ; + PROVIDE (etext = .) ; + + .rodata : + { + *(.rodata) + *(.rodata.*) + } + + /* + * Adjust the address for the data segment. We want to adjust up to + * the same address within the page on the next page up. + */ + . = ALIGN(0x10) + (. & (0x10 - 1)); + __data_start = . ; + .data : + { + *(.data) + } + + . = ALIGN(COHERENCY_UNIT); + .data.cacheline_aligned : + { + *(.data.cacheline_aligned) + } + . = ALIGN(COHERENCY_UNIT); + .data.read_mostly : + { + *(.data.read_mostly) + } + . = ALIGN(COHERENCY_UNIT); + + _edata = . ; + PROVIDE (edata = .) ; + __bss_start = . ; + .bss : + { + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN(64 / 8); + } + . = ALIGN(64 / 8); + _end = . ; + PROVIDE (end = .) ; + .note.netbsd.ident : + { + KEEP(*(.note.netbsd.ident)); + } +} + +SECTIONS +{ + .text : + AT (ADDR(.text) & 0x0fff) + { + *(.text) + } = 0 +}
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Fri May 18 05:51:24 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: thunk.c Log Message: Include our doctored types.h instead of the default To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/arch/usermode/usermode/thunk.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/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.87 src/sys/arch/usermode/usermode/thunk.c:1.88 --- src/sys/arch/usermode/usermode/thunk.c:1.87 Mon Dec 21 20:44:54 2015 +++ src/sys/arch/usermode/usermode/thunk.c Fri May 18 05:51:23 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.87 2015/12/21 20:44:54 christos Exp $ */ +/* $NetBSD: thunk.c,v 1.88 2018/05/18 05:51:23 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,10 +28,10 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.87 2015/12/21 20:44:54 christos Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.88 2018/05/18 05:51:23 reinoud Exp $"); #endif -#include +#include "../include/types.h" #include #include #include
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Thu May 17 19:06:02 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: pmap.c Log Message: Don't dynamically allocate memory we are only going to use once; so allocate it on the stack. While here, also include some more sanity checks. To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/sys/arch/usermode/usermode/pmap.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/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.106 src/sys/arch/usermode/usermode/pmap.c:1.107 --- src/sys/arch/usermode/usermode/pmap.c:1.106 Thu Jul 7 06:55:39 2016 +++ src/sys/arch/usermode/usermode/pmap.c Thu May 17 19:06:02 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.106 2016/07/07 06:55:39 msaitoh Exp $ */ +/* $NetBSD: pmap.c,v 1.107 2018/05/17 19:06:02 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.106 2016/07/07 06:55:39 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.107 2018/05/17 19:06:02 reinoud Exp $"); #include "opt_memsize.h" #include "opt_kmempages.h" @@ -230,6 +230,7 @@ pmap_bootstrap(void) mem_fh = thunk_mkstemp(mem_name); if (mem_fh < 0) panic("pmap_bootstrap: can't create memory file\n"); + /* unlink the file so space is freed when we quit */ if (thunk_unlink(mem_name) == -1) panic("pmap_bootstrap: can't unlink %s", mem_name); @@ -247,19 +248,14 @@ pmap_bootstrap(void) } #else { - void *block; + char block[PAGE_SIZE]; printf("Creating memory file\r"); - block = thunk_malloc(PAGE_SIZE); - if (!block) - panic("pmap_bootstrap: can't malloc writeout block"); - for (pg = 0; pg < file_len; pg += PAGE_SIZE) { wlen = thunk_pwrite(mem_fh, block, PAGE_SIZE, pg); if (wlen != PAGE_SIZE) panic("pmap_bootstrap: write fails, disc full?"); } - thunk_free(block); } #endif @@ -1204,13 +1200,14 @@ pmap_zero_page(paddr_t pa) if (pa & (PAGE_SIZE-1)) panic("%s: unaligned address passed : %p\n", __func__, (void *) pa); - /* XXX bug alart: can we allow the kernel to make a decision on this? */ blob = thunk_mmap(NULL, PAGE_SIZE, THUNK_PROT_READ | THUNK_PROT_WRITE, THUNK_MAP_FILE | THUNK_MAP_SHARED, mem_fh, pa); if (!blob) panic("%s: couldn't get mapping", __func__); + if (blob < (char *) kmem_k_end) + panic("%s: mmap in illegal memory range", __func__); memset(blob, 0, PAGE_SIZE); @@ -1237,6 +1234,8 @@ pmap_copy_page(paddr_t src_pa, paddr_t d mem_fh, src_pa); if (!sblob) panic("%s: couldn't get src mapping", __func__); + if (sblob < (char *) kmem_k_end) + panic("%s: mmap in illegal memory range", __func__); /* XXX bug alart: can we allow the kernel to make a decision on this? */ dblob = thunk_mmap(NULL, PAGE_SIZE, @@ -1245,6 +1244,8 @@ pmap_copy_page(paddr_t src_pa, paddr_t d mem_fh, dst_pa); if (!dblob) panic("%s: couldn't get dst mapping", __func__); + if (dblob < (char *) kmem_k_end) + panic("%s: mmap in illegal memory range", __func__); memcpy(dblob, sblob, PAGE_SIZE);
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Thu May 17 19:00:39 UTC 2018 Modified Files: src/sys/arch/usermode/dev: cpu.c Log Message: Refactor for easier debugging and while here add some more signals To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/arch/usermode/dev/cpu.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/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.74 src/sys/arch/usermode/dev/cpu.c:1.75 --- src/sys/arch/usermode/dev/cpu.c:1.74 Thu Jun 1 02:45:08 2017 +++ src/sys/arch/usermode/dev/cpu.c Thu May 17 19:00:39 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.74 2017/06/01 02:45:08 chs Exp $ */ +/* $NetBSD: cpu.c,v 1.75 2018/05/17 19:00:39 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,7 +30,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.74 2017/06/01 02:45:08 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.75 2018/05/17 19:00:39 reinoud Exp $"); #include #include @@ -119,6 +119,8 @@ cpu_attach(device_t parent, device_t sel sc->sc_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK; thunk_sigaddset(&sc->sc_ucp.uc_sigmask, SIGALRM); thunk_sigaddset(&sc->sc_ucp.uc_sigmask, SIGIO); + thunk_sigaddset(&sc->sc_ucp.uc_sigmask, SIGINT); + thunk_sigaddset(&sc->sc_ucp.uc_sigmask, SIGTSTP); } void @@ -191,9 +193,13 @@ static void cpu_switchto_atomic(lwp_t *oldlwp, lwp_t *newlwp) { - struct pcb *oldpcb = oldlwp ? lwp_getpcb(oldlwp) : NULL; - struct pcb *newpcb = lwp_getpcb(newlwp); - struct cpu_info *ci = curcpu(); + struct pcb *oldpcb; + struct pcb *newpcb; + struct cpu_info *ci; + + oldpcb = oldlwp ? lwp_getpcb(oldlwp) : NULL; + newpcb = lwp_getpcb(newlwp); + ci = curcpu(); ci->ci_stash = oldlwp; @@ -241,6 +247,7 @@ cpu_switchto(lwp_t *oldlwp, lwp_t *newlw #endif /* !CPU_DEBUG */ /* create atomic switcher */ + KASSERT(newlwp); thunk_makecontext(&sc->sc_ucp, (void (*)(void)) cpu_switchto_atomic, 2, oldlwp, newlwp, NULL, NULL);
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Wed May 16 12:40:43 UTC 2018 Modified Files: src/sys/arch/usermode/include: asm.h bswap.h byte_swap.h cdefs.h disklabel.h elf_machdep.h endian.h endian_machdep.h int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h limits.h mcontext.h netbsd32_machdep.h param.h ptrace.h wchar_limits.h Added Files: src/sys/arch/usermode/include: frame_regs.h Log Message: Regen usermode headers To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/usermode/include/asm.h \ src/sys/arch/usermode/include/bswap.h \ src/sys/arch/usermode/include/byte_swap.h \ src/sys/arch/usermode/include/elf_machdep.h \ src/sys/arch/usermode/include/endian.h \ src/sys/arch/usermode/include/endian_machdep.h \ src/sys/arch/usermode/include/int_const.h \ src/sys/arch/usermode/include/int_fmtio.h \ src/sys/arch/usermode/include/int_limits.h \ src/sys/arch/usermode/include/int_mwgwtypes.h \ src/sys/arch/usermode/include/int_types.h \ src/sys/arch/usermode/include/limits.h \ src/sys/arch/usermode/include/netbsd32_machdep.h \ src/sys/arch/usermode/include/wchar_limits.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/usermode/include/cdefs.h cvs rdiff -u -r1.13 -r1.14 src/sys/arch/usermode/include/disklabel.h \ src/sys/arch/usermode/include/ptrace.h cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/include/frame_regs.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/mcontext.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/usermode/include/param.h 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/include/asm.h diff -u src/sys/arch/usermode/include/asm.h:1.11 src/sys/arch/usermode/include/asm.h:1.12 --- src/sys/arch/usermode/include/asm.h:1.11 Sun Nov 10 19:52:01 2013 +++ src/sys/arch/usermode/include/asm.h Wed May 16 12:40:43 2018 @@ -1,7 +1,7 @@ -/* $NetBSD: asm.h,v 1.11 2013/11/10 19:52:01 jmcneill Exp $ */ +/* $NetBSD: asm.h,v 1.12 2018/05/16 12:40:43 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Nov 10 15:47:57 AST 2013 + * Automatically generated by ./genheaders.sh on Wed May 16 14:39:02 CEST 2018 * Do not modify directly! */ #ifndef _USERMODE_ASM_H Index: src/sys/arch/usermode/include/bswap.h diff -u src/sys/arch/usermode/include/bswap.h:1.11 src/sys/arch/usermode/include/bswap.h:1.12 --- src/sys/arch/usermode/include/bswap.h:1.11 Sun Nov 10 19:52:01 2013 +++ src/sys/arch/usermode/include/bswap.h Wed May 16 12:40:43 2018 @@ -1,7 +1,7 @@ -/* $NetBSD: bswap.h,v 1.11 2013/11/10 19:52:01 jmcneill Exp $ */ +/* $NetBSD: bswap.h,v 1.12 2018/05/16 12:40:43 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Nov 10 15:47:57 AST 2013 + * Automatically generated by ./genheaders.sh on Wed May 16 14:39:02 CEST 2018 * Do not modify directly! */ #ifndef _USERMODE_BSWAP_H Index: src/sys/arch/usermode/include/byte_swap.h diff -u src/sys/arch/usermode/include/byte_swap.h:1.11 src/sys/arch/usermode/include/byte_swap.h:1.12 --- src/sys/arch/usermode/include/byte_swap.h:1.11 Sun Nov 10 19:52:01 2013 +++ src/sys/arch/usermode/include/byte_swap.h Wed May 16 12:40:43 2018 @@ -1,7 +1,7 @@ -/* $NetBSD: byte_swap.h,v 1.11 2013/11/10 19:52:01 jmcneill Exp $ */ +/* $NetBSD: byte_swap.h,v 1.12 2018/05/16 12:40:43 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Nov 10 15:47:57 AST 2013 + * Automatically generated by ./genheaders.sh on Wed May 16 14:39:02 CEST 2018 * Do not modify directly! */ #ifndef _USERMODE_BYTE_SWAP_H Index: src/sys/arch/usermode/include/elf_machdep.h diff -u src/sys/arch/usermode/include/elf_machdep.h:1.11 src/sys/arch/usermode/include/elf_machdep.h:1.12 --- src/sys/arch/usermode/include/elf_machdep.h:1.11 Sun Nov 10 19:52:01 2013 +++ src/sys/arch/usermode/include/elf_machdep.h Wed May 16 12:40:43 2018 @@ -1,7 +1,7 @@ -/* $NetBSD: elf_machdep.h,v 1.11 2013/11/10 19:52:01 jmcneill Exp $ */ +/* $NetBSD: elf_machdep.h,v 1.12 2018/05/16 12:40:43 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Nov 10 15:47:57 AST 2013 + * Automatically generated by ./genheaders.sh on Wed May 16 14:39:02 CEST 2018 * Do not modify directly! */ #ifndef _USERMODE_ELF_MACHDEP_H Index: src/sys/arch/usermode/include/endian.h diff -u src/sys/arch/usermode/include/endian.h:1.11 src/sys/arch/usermode/include/endian.h:1.12 --- src/sys/arch/usermode/include/endian.h:1.11 Sun Nov 10 19:52:01 2013 +++ src/sys/arch/usermode/include/endian.h Wed May 16 12:40:43 2018 @@ -1,7 +1,7 @@ -/* $NetBSD: endian.h,v 1.11 2013/11/10 19:52:01 jmcneill Exp $ */ +/* $NetBSD: endian.h,v 1.12 2018/05/16 12:40:43 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Nov 10 15:47:57 AST 2013 + * Automatically generated by ./genheaders.sh on Wed May 16 14:39:02 CEST 2018 *
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Wed May 16 12:40:26 UTC 2018 Modified Files: src/sys/arch/usermode/include: genheaders.sh Log Message: Add new mcontext and depends to the usermode generated headerfiles To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/include/genheaders.sh 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/include/genheaders.sh diff -u src/sys/arch/usermode/include/genheaders.sh:1.9 src/sys/arch/usermode/include/genheaders.sh:1.10 --- src/sys/arch/usermode/include/genheaders.sh:1.9 Sun Nov 10 19:52:01 2013 +++ src/sys/arch/usermode/include/genheaders.sh Wed May 16 12:40:26 2018 @@ -21,6 +21,8 @@ HDRS="$HDRS param.h" HDRS="$HDRS ptrace.h" HDRS="$HDRS wchar_limits.h" HDRS="$HDRS cdefs.h" +HDRS="$HDRS mcontext.h" +HDRS="$HDRS frame_regs.h" for hdr in ${HDRS}; do G="_USERMODE_$(echo ${hdr} | sed 's/\./_/g' | tr [a-z] [A-Z])"
CVS commit: src/sys/arch/usermode/conf
Module Name:src Committed By: reinoud Date: Sat Jan 13 16:20:33 UTC 2018 Modified Files: src/sys/arch/usermode/conf: GENERIC.common Makefile.usermode Log Message: Make NetBSD/usermode link again! To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/arch/usermode/conf/GENERIC.common cvs rdiff -u -r1.40 -r1.41 src/sys/arch/usermode/conf/Makefile.usermode 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/conf/GENERIC.common diff -u src/sys/arch/usermode/conf/GENERIC.common:1.26 src/sys/arch/usermode/conf/GENERIC.common:1.27 --- src/sys/arch/usermode/conf/GENERIC.common:1.26 Thu Sep 14 07:58:44 2017 +++ src/sys/arch/usermode/conf/GENERIC.common Sat Jan 13 16:20:33 2018 @@ -1,14 +1,14 @@ -# $NetBSD: GENERIC.common,v 1.26 2017/09/14 07:58:44 mrg Exp $ +# $NetBSD: GENERIC.common,v 1.27 2018/01/13 16:20:33 reinoud Exp $ include "arch/usermode/conf/std.usermode" options INCLUDE_CONFIG_FILE -#ident "GENERIC-$Revision: 1.26 $" +#ident "GENERIC-$Revision: 1.27 $" maxusers 32 makeoptions DEBUG="-O1 -g3" -makeoptions COPY_SYMTAB=1 +#makeoptions COPY_SYMTAB=1 options RTC_OFFSET=0 options NTP Index: src/sys/arch/usermode/conf/Makefile.usermode diff -u src/sys/arch/usermode/conf/Makefile.usermode:1.40 src/sys/arch/usermode/conf/Makefile.usermode:1.41 --- src/sys/arch/usermode/conf/Makefile.usermode:1.40 Sun Dec 10 14:29:47 2017 +++ src/sys/arch/usermode/conf/Makefile.usermode Sat Jan 13 16:20:33 2018 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.usermode,v 1.40 2017/12/10 14:29:47 christos Exp $ +# $NetBSD: Makefile.usermode,v 1.41 2018/01/13 16:20:33 reinoud Exp $ USETOOLS?= no NEED_OWN_INSTALL_TARGET?= no @@ -71,12 +71,11 @@ LINKFLAGS_NORMAL= -X KERNLDSCRIPT?= ${USERMODE}/conf/kern.ldscript SYSTEM_LD= @do_system_ld() { \ - target=$$1; shift; \ ${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \ ${_MKSHECHO}\ - ${CC} -static ${COPTS} -Wl,-Map,$${target}.map -o $${target} ${LINKFORMAT} -Ttext ${TEXTADDR} '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS} $$@; \ + ${CC} -static ${COPTS} -Wl,-Map,$${target}.map -o ${.TARGET} ${LINKFORMAT} -Ttext ${TEXTADDR} '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS} $$@; \ ${SYSTEM_LD_FIX} \ - ${CC} -static ${COPTS} -Wl,-Map,$${target}.map -o $${target} ${LINKFORMAT} -Ttext ${TEXTADDR} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS} $$@; \ + ${CC} -static ${COPTS} -Wl,-Map,$${target}.map -o ${.TARGET} ${LINKFORMAT} -Ttext ${TEXTADDR} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS} $$@; \ }; \ do_system_ld NVFLAGS= -n
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Sat Jan 13 15:15:03 UTC 2018 Modified Files: src/sys/arch/usermode/usermode: process_machdep.c Log Message: Implement dummy process_read_dbreg() and process_write_dbreg() used in x86 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/usermode/process_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/process_machdep.c diff -u src/sys/arch/usermode/usermode/process_machdep.c:1.3 src/sys/arch/usermode/usermode/process_machdep.c:1.4 --- src/sys/arch/usermode/usermode/process_machdep.c:1.3 Sat Jan 4 00:10:03 2014 +++ src/sys/arch/usermode/usermode/process_machdep.c Sat Jan 13 15:15:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: process_machdep.c,v 1.3 2014/01/04 00:10:03 dsl Exp $ */ +/* $NetBSD: process_machdep.c,v 1.4 2018/01/13 15:15:03 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.3 2014/01/04 00:10:03 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.4 2018/01/13 15:15:03 reinoud Exp $"); #include #include @@ -68,3 +68,16 @@ process_set_pc(struct lwp *l, void *addr { return 0; } + +int +process_write_dbregs(struct lwp *l, const struct dbreg *regs, size_t sz) +{ + return 0; +} + +int +process_read_dbregs(struct lwp *l, struct dbreg *regs, size_t *sz) +{ + return 0; +} +
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Sat Jan 13 14:39:15 UTC 2018 Modified Files: src/sys/arch/usermode/include: reg.h Log Message: Add dbreg structure prototype needed for x86_64 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/include/reg.h 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/include/reg.h diff -u src/sys/arch/usermode/include/reg.h:1.2 src/sys/arch/usermode/include/reg.h:1.3 --- src/sys/arch/usermode/include/reg.h:1.2 Wed Oct 21 16:06:59 2009 +++ src/sys/arch/usermode/include/reg.h Sat Jan 13 14:39:15 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: reg.h,v 1.2 2009/10/21 16:06:59 snj Exp $ */ +/* $NetBSD: reg.h,v 1.3 2018/01/13 14:39:15 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -35,4 +35,8 @@ struct reg { struct fpreg { }; +/* x86_64 only */ +struct dbreg { +}; + #endif /* !_ARCH_USERMODE_INCLUDE_REG_H */
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Sat Jan 13 10:27:58 UTC 2018 Modified Files: src/sys/arch/usermode/dev: ld_thunkbus.c Log Message: Keep up with changes in ld(4): adding ioctl handling on the ld(4) instead of using the old dedicated ldflush() function. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/arch/usermode/dev/ld_thunkbus.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/dev/ld_thunkbus.c diff -u src/sys/arch/usermode/dev/ld_thunkbus.c:1.31 src/sys/arch/usermode/dev/ld_thunkbus.c:1.32 --- src/sys/arch/usermode/dev/ld_thunkbus.c:1.31 Sat Jan 13 10:08:35 2018 +++ src/sys/arch/usermode/dev/ld_thunkbus.c Sat Jan 13 10:27:58 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_thunkbus.c,v 1.31 2018/01/13 10:08:35 reinoud Exp $ */ +/* $NetBSD: ld_thunkbus.c,v 1.32 2018/01/13 10:27:58 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -27,13 +27,14 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.31 2018/01/13 10:08:35 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.32 2018/01/13 10:27:58 reinoud Exp $"); #include #include #include #include #include +#include #include #include @@ -48,7 +49,7 @@ static void ld_thunkbus_attach(device_t, static int ld_thunkbus_ldstart(struct ld_softc *, struct buf *); static int ld_thunkbus_lddump(struct ld_softc *, void *, int, int); -static int ld_thunkbus_ldflush(struct ld_softc *, int); +static int ld_thunkbus_ioctl(struct ld_softc *, u_long, void *, int32_t, bool); //#define LD_USE_AIO @@ -122,7 +123,7 @@ ld_thunkbus_attach(device_t parent, devi ld->sc_maxqueuecnt = 1; ld->sc_start = ld_thunkbus_ldstart; ld->sc_dump = ld_thunkbus_lddump; - ld->sc_flush = ld_thunkbus_ldflush; + ld->sc_ioctl = ld_thunkbus_ioctl; sc->sc_ih = softint_establish(SOFTINT_BIO, ld_thunkbus_complete, ld); @@ -315,13 +316,19 @@ ld_thunkbus_lddump(struct ld_softc *ld, return 0; } + static int -ld_thunkbus_ldflush(struct ld_softc *ld, int flags) +ld_thunkbus_ioctl(struct ld_softc *ld, u_long cmd, void *addr, int32_t flag, +bool poll) { struct ld_thunkbus_softc *sc = (struct ld_thunkbus_softc *)ld; - if (thunk_fsync(sc->sc_fd) == -1) - return thunk_geterrno(); - - return 0; + switch (cmd) { + case DIOCCACHESYNC: + if (thunk_fsync(sc->sc_fd) == -1) + return thunk_geterrno(); + return 0; + default: + return EPASSTHROUGH; + } }
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Sat Jan 13 10:08:35 UTC 2018 Modified Files: src/sys/arch/usermode/dev: ld_thunkbus.c Log Message: Add the missing strategy argument of ldattach() To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/arch/usermode/dev/ld_thunkbus.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/dev/ld_thunkbus.c diff -u src/sys/arch/usermode/dev/ld_thunkbus.c:1.30 src/sys/arch/usermode/dev/ld_thunkbus.c:1.31 --- src/sys/arch/usermode/dev/ld_thunkbus.c:1.30 Sat Jan 21 22:09:57 2012 +++ src/sys/arch/usermode/dev/ld_thunkbus.c Sat Jan 13 10:08:35 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ld_thunkbus.c,v 1.30 2012/01/21 22:09:57 reinoud Exp $ */ +/* $NetBSD: ld_thunkbus.c,v 1.31 2018/01/13 10:08:35 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.30 2012/01/21 22:09:57 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ld_thunkbus.c,v 1.31 2018/01/13 10:08:35 reinoud Exp $"); #include #include @@ -135,7 +135,7 @@ ld_thunkbus_attach(device_t parent, devi sc->busy = false; - ldattach(ld); + ldattach(ld, BUFQ_DISK_DEFAULT_STRAT); } #ifdef LD_USE_AIO @@ -260,7 +260,7 @@ ld_thunkbus_complete(void *arg) struct ld_thunkbus_softc *sc = (struct ld_thunkbus_softc *)ld; struct ld_thunkbus_transfer *tt = &sc->sc_tt; struct buf *bp = tt->tt_bp; - off_t offset = bp->b_rawblkno * ld->sc_secsize; + off_t offset = (off_t) bp->b_rawblkno * ld->sc_secsize; int64_t ret; if (!sc->busy)
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: msaitoh Date: Mon Oct 23 06:43:00 UTC 2017 Modified Files: src/sys/arch/usermode/include: lock.h Log Message: Fix compile error. Use const correctly. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/include/lock.h 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/include/lock.h diff -u src/sys/arch/usermode/include/lock.h:1.4 src/sys/arch/usermode/include/lock.h:1.5 --- src/sys/arch/usermode/include/lock.h:1.4 Sun Sep 17 00:01:08 2017 +++ src/sys/arch/usermode/include/lock.h Mon Oct 23 06:43:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: lock.h,v 1.4 2017/09/17 00:01:08 christos Exp $ */ +/* $NetBSD: lock.h,v 1.5 2017/10/23 06:43:00 msaitoh Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,13 +30,13 @@ #define _ARCH_USERMODE_INCLUDE_LOCK_H __inline static void -__cpu_simple_lock_init(const __cpu_simple_lock_t *lockp) +__cpu_simple_lock_init(__cpu_simple_lock_t *lockp) { *lockp = __SIMPLELOCK_UNLOCKED; } __inline static int -__cpu_simple_lock_try(const __cpu_simple_lock_t *lockp) +__cpu_simple_lock_try(__cpu_simple_lock_t *lockp) { if (*lockp == __SIMPLELOCK_LOCKED) return 0; @@ -58,13 +58,13 @@ __cpu_simple_unlock(__cpu_simple_lock_t } __inline static int -__SIMPLELOCK_LOCKED_P(__cpu_simple_lock_t *lockp) +__SIMPLELOCK_LOCKED_P(const __cpu_simple_lock_t *lockp) { return *lockp == __SIMPLELOCK_LOCKED; } __inline static int -__SIMPLELOCK_UNLOCKED_P(__cpu_simple_lock_t *lockp) +__SIMPLELOCK_UNLOCKED_P(const __cpu_simple_lock_t *lockp) { return *lockp == __SIMPLELOCK_UNLOCKED; }
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: christos Date: Mon Dec 21 20:44:54 UTC 2015 Modified Files: src/sys/arch/usermode/usermode: thunk.c Log Message: fix label and variable name. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/arch/usermode/usermode/thunk.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/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.86 src/sys/arch/usermode/usermode/thunk.c:1.87 --- src/sys/arch/usermode/usermode/thunk.c:1.86 Mon Dec 21 14:54:35 2015 +++ src/sys/arch/usermode/usermode/thunk.c Mon Dec 21 15:44:54 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.86 2015/12/21 19:54:35 christos Exp $ */ +/* $NetBSD: thunk.c,v 1.87 2015/12/21 20:44:54 christos Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,7 +28,7 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.86 2015/12/21 19:54:35 christos Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.87 2015/12/21 20:44:54 christos Exp $"); #endif #include @@ -768,10 +768,10 @@ thunk_getcpuinfo(char *cp, size_t *len) if (rlen == -1) goto out; - buf[rlen ? rlen - 1 : 0] = '\0'; + cp[rlen ? rlen - 1 : 0] = '\0'; *len = rlen; return 0; -bad: +out: *len = 0; return -1; }
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: christos Date: Mon Dec 21 19:54:35 UTC 2015 Modified Files: src/sys/arch/usermode/usermode: thunk.c Log Message: more checking To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/arch/usermode/usermode/thunk.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/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.85 src/sys/arch/usermode/usermode/thunk.c:1.86 --- src/sys/arch/usermode/usermode/thunk.c:1.85 Fri Feb 6 05:25:13 2015 +++ src/sys/arch/usermode/usermode/thunk.c Mon Dec 21 14:54:35 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.85 2015/02/06 10:25:13 prlw1 Exp $ */ +/* $NetBSD: thunk.c,v 1.86 2015/12/21 19:54:35 christos Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,7 +28,7 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.85 2015/02/06 10:25:13 prlw1 Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.86 2015/12/21 19:54:35 christos Exp $"); #endif #include @@ -761,15 +761,19 @@ thunk_getcpuinfo(char *cp, size_t *len) fd = open("/proc/cpuinfo", O_RDONLY); if (fd == -1) - return -1; - rlen = read(fd, cp, *len - 1); + goto out; + rlen = read(fd, cp, *len); close(fd); if (rlen == -1) - return -1; + goto out; + buf[rlen ? rlen - 1 : 0] = '\0'; *len = rlen; return 0; +bad: + *len = 0; + return -1; } int
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: prlw1 Date: Fri Feb 6 10:25:13 UTC 2015 Modified Files: src/sys/arch/usermode/include: thunk.h src/sys/arch/usermode/usermode: thunk.c Log Message: Take procfs_machdep.c rev 1.4 one step further and adjust signature of thunk_getcpuinfo(). To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sys/arch/usermode/include/thunk.h cvs rdiff -u -r1.84 -r1.85 src/sys/arch/usermode/usermode/thunk.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/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.61 src/sys/arch/usermode/include/thunk.h:1.62 --- src/sys/arch/usermode/include/thunk.h:1.61 Sat Mar 3 21:15:16 2012 +++ src/sys/arch/usermode/include/thunk.h Fri Feb 6 10:25:13 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.h,v 1.61 2012/03/03 21:15:16 reinoud Exp $ */ +/* $NetBSD: thunk.h,v 1.62 2015/02/06 10:25:13 prlw1 Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -156,7 +156,7 @@ int thunk_idle(void); char * thunk_getenv(const char *); vaddr_t thunk_get_vm_min_address(void); -int thunk_getcpuinfo(char *, int *); +int thunk_getcpuinfo(char *, size_t *); int thunk_getmachine(char *, size_t, char *, size_t); Index: src/sys/arch/usermode/usermode/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.84 src/sys/arch/usermode/usermode/thunk.c:1.85 --- src/sys/arch/usermode/usermode/thunk.c:1.84 Sun Nov 10 19:51:00 2013 +++ src/sys/arch/usermode/usermode/thunk.c Fri Feb 6 10:25:13 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.84 2013/11/10 19:51:00 jmcneill Exp $ */ +/* $NetBSD: thunk.c,v 1.85 2015/02/06 10:25:13 prlw1 Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,7 +28,7 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.84 2013/11/10 19:51:00 jmcneill Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.85 2015/02/06 10:25:13 prlw1 Exp $"); #endif #include @@ -754,7 +754,7 @@ thunk_idle(void) } int -thunk_getcpuinfo(char *cp, int *len) +thunk_getcpuinfo(char *cp, size_t *len) { ssize_t rlen; int fd;
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: christos Date: Wed Mar 26 08:29:41 UTC 2014 Modified Files: src/sys/arch/usermode/dev: vaudio.c Log Message: fix sprintf To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/dev/vaudio.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/dev/vaudio.c diff -u src/sys/arch/usermode/dev/vaudio.c:1.3 src/sys/arch/usermode/dev/vaudio.c:1.4 --- src/sys/arch/usermode/dev/vaudio.c:1.3 Sun Jan 15 05:51:12 2012 +++ src/sys/arch/usermode/dev/vaudio.c Wed Mar 26 04:29:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: vaudio.c,v 1.3 2012/01/15 10:51:12 jmcneill Exp $ */ +/* $NetBSD: vaudio.c,v 1.4 2014/03/26 08:29:41 christos Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.3 2012/01/15 10:51:12 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vaudio.c,v 1.4 2014/03/26 08:29:41 christos Exp $"); #include #include @@ -396,8 +396,8 @@ vaudio_getdev(void *opaque, struct audio { struct vaudio_softc *sc = opaque; - sprintf(adev->name, "Virtual Audio"); - sprintf(adev->version, ""); + snprintf(adev->name, sizeof(adev->name), "Virtual Audio"); + adev->version[0] = '\0'; snprintf(adev->config, sizeof(adev->config), "%s", sc->sc_audiopath); return 0;
CVS commit: src/sys/arch/usermode/target/arm
Module Name:src Committed By: jmcneill Date: Mon Nov 11 13:52:04 UTC 2013 Modified Files: src/sys/arch/usermode/target/arm: cpu_arm.c Log Message: implement md_get_pc and md_set_pc To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/usermode/target/arm/cpu_arm.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/target/arm/cpu_arm.c diff -u src/sys/arch/usermode/target/arm/cpu_arm.c:1.1 src/sys/arch/usermode/target/arm/cpu_arm.c:1.2 --- src/sys/arch/usermode/target/arm/cpu_arm.c:1.1 Sun Nov 10 20:03:46 2013 +++ src/sys/arch/usermode/target/arm/cpu_arm.c Mon Nov 11 13:52:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_arm.c,v 1.1 2013/11/10 20:03:46 jmcneill Exp $ */ +/* $NetBSD: cpu_arm.c,v 1.2 2013/11/11 13:52:04 jmcneill Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_arm.c,v 1.1 2013/11/10 20:03:46 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_arm.c,v 1.2 2013/11/11 13:52:04 jmcneill Exp $"); #include #include @@ -99,15 +99,15 @@ md_syscall_set_returnargs(lwp_t *l, ucon register_t md_get_pc(ucontext_t *ucp) { - panic("md_get_pc not implemented"); - return 0; + unsigned int *reg = (unsigned int *)&ucp->uc_mcontext; + return reg[15]; } register_t md_get_sp(ucontext_t *ucp) { - panic("md_get_sp not implemented"); - return 0; + unsigned int *reg = (unsigned int *)&ucp->uc_mcontext; + return reg[13]; } int
CVS commit: src/sys/arch/usermode/modules/syscallemu
Module Name:src Committed By: jmcneill Date: Sun Nov 10 22:08:58 UTC 2013 Modified Files: src/sys/arch/usermode/modules/syscallemu: Makefile Log Message: use MACHINE_CPU instead of MACHINE_ARCH To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/modules/syscallemu/Makefile 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/modules/syscallemu/Makefile diff -u src/sys/arch/usermode/modules/syscallemu/Makefile:1.4 src/sys/arch/usermode/modules/syscallemu/Makefile:1.5 --- src/sys/arch/usermode/modules/syscallemu/Makefile:1.4 Sun Nov 10 19:58:38 2013 +++ src/sys/arch/usermode/modules/syscallemu/Makefile Sun Nov 10 22:08:58 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.4 2013/11/10 19:58:38 jmcneill Exp $ +# $NetBSD: Makefile,v 1.5 2013/11/10 22:08:58 jmcneill Exp $ .include @@ -11,12 +11,12 @@ M?= ${S}/modules KMOD= syscallemu SRCS= syscallemu.c -.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" +.if ${MACHINE_CPU} == "i386" || ${MACHINE_CPU} == "x86_64" SRCS+= syscallemu_x86.c -.elif ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "earm" +.elif ${MACHINE_CPU} == "arm" SRCS+= syscallemu_arm.c .else -.error ${MACHINE_ARCH} not implemented +.error ${MACHINE_CPU} not implemented .endif .include
CVS commit: src/sys/arch/usermode/target/arm
Module Name:src Committed By: jmcneill Date: Sun Nov 10 20:03:46 UTC 2013 Added Files: src/sys/arch/usermode/target/arm: cpu_arm.c Log Message: usermode arm md stub To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/usermode/target/arm/cpu_arm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/usermode/target/arm/cpu_arm.c diff -u /dev/null src/sys/arch/usermode/target/arm/cpu_arm.c:1.1 --- /dev/null Sun Nov 10 20:03:46 2013 +++ src/sys/arch/usermode/target/arm/cpu_arm.c Sun Nov 10 20:03:46 2013 @@ -0,0 +1,137 @@ +/* $NetBSD: cpu_arm.c,v 1.1 2013/11/10 20:03:46 jmcneill Exp $ */ + +/*- + * Copyright (c) 2011 Reinoud Zandijk + * Copyright (c) 2007, 2013 Jared D. McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Note that this machdep.c uses the `dummy' mcontext_t defined for usermode. + * This is basicly a blob of PAGE_SIZE big. We might want to switch over to + * non-generic mcontext_t's one day, but will this break non-NetBSD hosts? + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: cpu_arm.c,v 1.1 2013/11/10 20:03:46 jmcneill Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "opt_exec.h" + +/* from sys/arch/arm/include/frame.h : KEEP IN SYNC */ +struct sigframe_siginfo { + siginfo_t sf_si; /* actual saved siginfo */ + ucontext_t sf_uc; /* actual saved ucontext */ +}; + +void +sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask) +{ + panic("sendsig_siginfo not implemented"); +} + +void +setregs(struct lwp *l, struct exec_package *pack, vaddr_t stack) +{ + panic("sendsig_siginfo not implemented"); +} + +void +md_syscall_get_syscallnumber(ucontext_t *ucp, uint32_t *code) +{ + panic("md_syscall_get_syscallnumber not implemented"); +} + +int +md_syscall_getargs(lwp_t *l, ucontext_t *ucp, int nargs, int argsize, + register_t *args) +{ + panic("md_syscall_getargs not implemented"); + return 0; +} + +void +md_syscall_set_returnargs(lwp_t *l, ucontext_t *ucp, + int error, register_t *rval) +{ + panic("md_syscall_set_returnargs not implemented"); +} + +register_t +md_get_pc(ucontext_t *ucp) +{ + panic("md_get_pc not implemented"); + return 0; +} + +register_t +md_get_sp(ucontext_t *ucp) +{ + panic("md_get_sp not implemented"); + return 0; +} + +int +md_syscall_check_opcode(ucontext_t *ucp) +{ + panic("md_syscall_check_opcode not implemented"); + return 0; +} + +void +md_syscall_get_opcode(ucontext_t *ucp, uint32_t *opcode) +{ + panic("md_syscall_get_opcode not implemented"); +} + +void +md_syscall_inc_pc(ucontext_t *ucp, uint32_t opcode) +{ + panic("md_syscall_inc_pc not implemented"); +} + +void +md_syscall_dec_pc(ucontext_t *ucp, uint32_t opcode) +{ + panic("md_syscall_dec_pc not implemented"); +} +
CVS commit: src/sys/arch/usermode/modules/syscallemu
Module Name:src Committed By: jmcneill Date: Sun Nov 10 19:58:38 UTC 2013 Modified Files: src/sys/arch/usermode/modules/syscallemu: Makefile Added Files: src/sys/arch/usermode/modules/syscallemu: syscallemu_arm.c Log Message: arm support for syscallemu, not tested To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/modules/syscallemu/Makefile cvs rdiff -u -r0 -r1.1 \ src/sys/arch/usermode/modules/syscallemu/syscallemu_arm.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/modules/syscallemu/Makefile diff -u src/sys/arch/usermode/modules/syscallemu/Makefile:1.3 src/sys/arch/usermode/modules/syscallemu/Makefile:1.4 --- src/sys/arch/usermode/modules/syscallemu/Makefile:1.3 Tue Jul 3 21:07:41 2012 +++ src/sys/arch/usermode/modules/syscallemu/Makefile Sun Nov 10 19:58:38 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.3 2012/07/03 21:07:41 christos Exp $ +# $NetBSD: Makefile,v 1.4 2013/11/10 19:58:38 jmcneill Exp $ .include @@ -13,6 +13,8 @@ KMOD= syscallemu SRCS= syscallemu.c .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" SRCS+= syscallemu_x86.c +.elif ${MACHINE_ARCH} == "arm" || ${MACHINE_ARCH} == "earm" +SRCS+= syscallemu_arm.c .else .error ${MACHINE_ARCH} not implemented .endif Added files: Index: src/sys/arch/usermode/modules/syscallemu/syscallemu_arm.c diff -u /dev/null src/sys/arch/usermode/modules/syscallemu/syscallemu_arm.c:1.1 --- /dev/null Sun Nov 10 19:58:38 2013 +++ src/sys/arch/usermode/modules/syscallemu/syscallemu_arm.c Sun Nov 10 19:58:38 2013 @@ -0,0 +1,107 @@ +/* $NetBSD: syscallemu_arm.c,v 1.1 2013/11/10 19:58:38 jmcneill Exp $ */ + +/*- + * Copyright (c) 2011 Reinoud Zandijk + * Copyright (c) 2012-2013 Jared D. McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: syscallemu_arm.c,v 1.1 2013/11/10 19:58:38 jmcneill Exp $"); + +#include +#include +#include + +#include + +#include "syscallemu.h" + +#define ARM_TF_PC(frame) ((frame)->tf_pc) + +/* + * If syscallemu specific data is present for the process, verify that the + * caller is allowed to execute system calls. If not, deliver a SIGILL to + * the process. When syscallemu specific data is not present, simply defer + * to the original syscall handler. + */ +static void +arm_syscall_emu(struct trapframe *frame, struct lwp *l, uint32_t insn) +{ + void (*md_syscall)(struct trapframe *, struct lwp *, uint32_t) = NULL; + struct syscallemu_data *sce; + register_t pc_call; + struct proc *p; + ksiginfo_t ksi; + + p = l->l_proc; + + pc_call = ARM_TF_PC(frame) - INSN_SIZE; + + /* Determine if we need to emulate the system call */ + sce = syscallemu_getsce(p); + if (sce) { + if ((pc_call >= sce->sce_user_start && + pc_call < sce->sce_user_end) || + (pc_call + INSN_SIZE >= sce->sce_user_start && + pc_call + INSN_SIZE < sce->sce_user_end)) { + md_syscall = NULL; + } else { + md_syscall = sce->sce_md_syscall; + } + } else { + md_syscall = p->p_md.md_syscall; + } + + if (md_syscall == NULL) { + /* If emulating, deliver SIGILL to process */ + ARM_TF_PC(frame) = pc_call; + KSI_INIT_TRAP(&ksi); + ksi.ksi_signo = SIGILL; + ksi.ksi_code = ILL_ILLTRP; + ksi.ksi_addr = (void *)ARM_TF_PC(frame); + ksi.ksi_trap = 0; + trapsignal(l, &ksi); + userret(l); + } else { + /* Not emulating, so treat as a normal syscall */ + KASSERT(md_syscall != NULL); + md_syscall(frame, l, insn); + } +} + +/* + * Set p_md.md_syscall to our syscall filter, and return a pointer to the + * original syscall handler.
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: jmcneill Date: Sun Nov 10 19:52:01 UTC 2013 Modified Files: src/sys/arch/usermode/include: ansi.h asm.h bswap.h byte_swap.h cdefs.h disklabel.h elf_machdep.h endian.h endian_machdep.h genheaders.sh int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h limits.h netbsd32_machdep.h param.h psl.h ptrace.h vmparam.h wchar_limits.h Log Message: support building on arm To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/ansi.h cvs rdiff -u -r1.10 -r1.11 src/sys/arch/usermode/include/asm.h \ src/sys/arch/usermode/include/bswap.h \ src/sys/arch/usermode/include/byte_swap.h \ src/sys/arch/usermode/include/elf_machdep.h \ src/sys/arch/usermode/include/endian.h \ src/sys/arch/usermode/include/endian_machdep.h \ src/sys/arch/usermode/include/int_const.h \ src/sys/arch/usermode/include/int_fmtio.h \ src/sys/arch/usermode/include/int_limits.h \ src/sys/arch/usermode/include/int_mwgwtypes.h \ src/sys/arch/usermode/include/int_types.h \ src/sys/arch/usermode/include/limits.h \ src/sys/arch/usermode/include/netbsd32_machdep.h \ src/sys/arch/usermode/include/wchar_limits.h cvs rdiff -u -r1.5 -r1.6 src/sys/arch/usermode/include/cdefs.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/usermode/include/disklabel.h \ src/sys/arch/usermode/include/ptrace.h cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/include/genheaders.sh cvs rdiff -u -r1.11 -r1.12 src/sys/arch/usermode/include/param.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/usermode/include/psl.h cvs rdiff -u -r1.16 -r1.17 src/sys/arch/usermode/include/vmparam.h 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/include/ansi.h diff -u src/sys/arch/usermode/include/ansi.h:1.3 src/sys/arch/usermode/include/ansi.h:1.4 --- src/sys/arch/usermode/include/ansi.h:1.3 Mon Aug 22 21:45:38 2011 +++ src/sys/arch/usermode/include/ansi.h Sun Nov 10 19:52:01 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ansi.h,v 1.3 2011/08/22 21:45:38 jmcneill Exp $ */ +/* $NetBSD: ansi.h,v 1.4 2013/11/10 19:52:01 jmcneill Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -50,6 +50,11 @@ #define _BSD_PTRDIFF_T_ long #define _BSD_SIZE_T_ unsigned long #define _BSD_SSIZE_T_ long +#elif defined(__arm__) +#define _BSD_CLOCK_T_ unsigned int +#define _BSD_PTRDIFF_T_ long int +#define _BSD_SIZE_T_ unsigned long int +#define _BSD_SSIZE_T_ long int #else #error "platform not supported" #endif Index: src/sys/arch/usermode/include/asm.h diff -u src/sys/arch/usermode/include/asm.h:1.10 src/sys/arch/usermode/include/asm.h:1.11 --- src/sys/arch/usermode/include/asm.h:1.10 Sun Feb 5 17:40:08 2012 +++ src/sys/arch/usermode/include/asm.h Sun Nov 10 19:52:01 2013 @@ -1,7 +1,7 @@ -/* $NetBSD: asm.h,v 1.10 2012/02/05 17:40:08 reinoud Exp $ */ +/* $NetBSD: asm.h,v 1.11 2013/11/10 19:52:01 jmcneill Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Feb 5 18:39:33 CET 2012 + * Automatically generated by genheaders.sh on Sun Nov 10 15:47:57 AST 2013 * Do not modify directly! */ #ifndef _USERMODE_ASM_H @@ -11,6 +11,8 @@ #include "../../i386/include/asm.h" #elif defined(__x86_64__) #include "../../amd64/include/asm.h" +#elif defined(__arm__) +#include "../../arm/include/asm.h" #else #error port me #endif Index: src/sys/arch/usermode/include/bswap.h diff -u src/sys/arch/usermode/include/bswap.h:1.10 src/sys/arch/usermode/include/bswap.h:1.11 --- src/sys/arch/usermode/include/bswap.h:1.10 Sun Feb 5 17:40:08 2012 +++ src/sys/arch/usermode/include/bswap.h Sun Nov 10 19:52:01 2013 @@ -1,7 +1,7 @@ -/* $NetBSD: bswap.h,v 1.10 2012/02/05 17:40:08 reinoud Exp $ */ +/* $NetBSD: bswap.h,v 1.11 2013/11/10 19:52:01 jmcneill Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Feb 5 18:39:34 CET 2012 + * Automatically generated by genheaders.sh on Sun Nov 10 15:47:57 AST 2013 * Do not modify directly! */ #ifndef _USERMODE_BSWAP_H @@ -11,6 +11,8 @@ #include "../../i386/include/bswap.h" #elif defined(__x86_64__) #include "../../amd64/include/bswap.h" +#elif defined(__arm__) +#include "../../arm/include/bswap.h" #else #error port me #endif Index: src/sys/arch/usermode/include/byte_swap.h diff -u src/sys/arch/usermode/include/byte_swap.h:1.10 src/sys/arch/usermode/include/byte_swap.h:1.11 --- src/sys/arch/usermode/include/byte_swap.h:1.10 Sun Feb 5 17:40:08 2012 +++ src/sys/arch/usermode/include/byte_swap.h Sun Nov 10 19:52:01 2013 @@ -1,7 +1,7 @@ -/* $NetBSD: byte_swap.h,v 1.10 2012/02/05 17:40:08 reinoud Exp $ */ +/* $NetBSD: byte_swap.h,v 1.11 2013/11/10 19:52:01 jmcneill Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Feb 5 18:39:34 CET 2012 + * Automatically generated by genheaders.sh on Sun Nov 10 15:47:57 AST 2013 * Do not modify directly! */ #ifnde
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: jmcneill Date: Sun Nov 10 19:51:00 UTC 2013 Modified Files: src/sys/arch/usermode/usermode: thunk.c Log Message: define _KMEMUSER before including machine/vmparam.h To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/sys/arch/usermode/usermode/thunk.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/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.83 src/sys/arch/usermode/usermode/thunk.c:1.84 --- src/sys/arch/usermode/usermode/thunk.c:1.83 Wed May 22 13:34:31 2013 +++ src/sys/arch/usermode/usermode/thunk.c Sun Nov 10 19:51:00 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.83 2013/05/22 13:34:31 reinoud Exp $ */ +/* $NetBSD: thunk.c,v 1.84 2013/11/10 19:51:00 jmcneill Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,7 +28,7 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.83 2013/05/22 13:34:31 reinoud Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.84 2013/11/10 19:51:00 jmcneill Exp $"); #endif #include @@ -41,6 +41,8 @@ __RCSID("$NetBSD: thunk.c,v 1.83 2013/05 #include #include #include + +#define _KMEMUSER #include #include
CVS commit: src/sys/arch/usermode/conf
Module Name:src Committed By: jmcneill Date: Sun Nov 10 19:49:49 UTC 2013 Modified Files: src/sys/arch/usermode/conf: Makefile.usermode Log Message: use MACHINE_CPU instead of uname -p; create symlink for arm headers To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/arch/usermode/conf/Makefile.usermode 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/conf/Makefile.usermode diff -u src/sys/arch/usermode/conf/Makefile.usermode:1.33 src/sys/arch/usermode/conf/Makefile.usermode:1.34 --- src/sys/arch/usermode/conf/Makefile.usermode:1.33 Wed Mar 6 11:36:21 2013 +++ src/sys/arch/usermode/conf/Makefile.usermode Sun Nov 10 19:49:49 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.usermode,v 1.33 2013/03/06 11:36:21 yamt Exp $ +# $NetBSD: Makefile.usermode,v 1.34 2013/11/10 19:49:49 jmcneill Exp $ USETOOLS?= no NEED_OWN_INSTALL_TARGET?= no @@ -59,8 +59,8 @@ MD_OBJS= thunk.o MD_CFILES= ${USERMODE}/usermode/thunk.c MD_SFILES= -MD_OBJS+= cpu_${MACHINE_ARCH}.o -MD_CFILES+= ${USERMODE}/target/${MACHINE_ARCH}/cpu_${MACHINE_ARCH}.c +MD_OBJS+= cpu_${MACHINE_CPU}.o +MD_CFILES+= ${USERMODE}/target/${MACHINE_CPU}/cpu_${MACHINE_CPU}.c ## ## (5) link settings @@ -88,6 +88,8 @@ NVFLAGS= -n ln -s $S/arch/i386/include i386 @rm -f amd64 && \ ln -s $S/arch/amd64/include amd64 + @rm -f arm && \ + ln -s $S/arch/arm/include arm .endif thunk.d: ${USERMODE}/usermode/thunk.c @@ -97,7 +99,7 @@ thunk.d: ${USERMODE}/usermode/thunk.c thunk.o: ${USERMODE}/usermode/thunk.c ${CC} ${COPTS} ${CPPFLAGS.thunk.c} -c -o $@ ${USERMODE}/usermode/thunk.c -cpu_${MACHINE_ARCH}.o: ${USERMODE}/target/${MACHINE_ARCH}/cpu_${MACHINE_ARCH}.c +cpu_${MACHINE_CPU}.o: ${USERMODE}/target/${MACHINE_CPU}/cpu_${MACHINE_CPU}.c ## ## (7) misc settings
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: matt Date: Wed Jun 26 15:11:30 UTC 2013 Modified Files: src/sys/arch/usermode/usermode: syscall.c Log Message: Use sy_invoke To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/usermode/usermode/syscall.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/syscall.c diff -u src/sys/arch/usermode/usermode/syscall.c:1.23 src/sys/arch/usermode/usermode/syscall.c:1.24 --- src/sys/arch/usermode/usermode/syscall.c:1.23 Mon Feb 13 19:15:59 2012 +++ src/sys/arch/usermode/usermode/syscall.c Wed Jun 26 15:11:30 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: syscall.c,v 1.23 2012/02/13 19:15:59 reinoud Exp $ */ +/* $NetBSD: syscall.c,v 1.24 2013/06/26 15:11:30 matt Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.23 2012/02/13 19:15:59 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.24 2013/06/26 15:11:30 matt Exp $"); #include #include @@ -131,16 +131,7 @@ syscall(void) md_syscall_inc_pc(ucp, opcode); if (!error) { - if (!__predict_false(p->p_trace_enabled) - || __predict_false(callp->sy_flags & SYCALL_INDIRECT) - || (error = trace_enter(code, args, callp->sy_narg)) == 0) { - error = (*callp->sy_call)(l, args, rval); - } - - if (__predict_false(p->p_trace_enabled) - && !__predict_false(callp->sy_flags & SYCALL_INDIRECT)) { - trace_exit(code, rval, error); - } + error = sy_invoke(callp, l, args, rval, code); } syscall_retvals_print(l, curlwp, code, nargs, args, error, rval);
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Wed May 22 13:34:32 UTC 2013 Modified Files: src/sys/arch/usermode/usermode: thunk.c Log Message: Including missing include file that broke compilation. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sys/arch/usermode/usermode/thunk.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/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.82 src/sys/arch/usermode/usermode/thunk.c:1.83 --- src/sys/arch/usermode/usermode/thunk.c:1.82 Mon Jul 2 12:17:12 2012 +++ src/sys/arch/usermode/usermode/thunk.c Wed May 22 13:34:31 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.82 2012/07/02 12:17:12 reinoud Exp $ */ +/* $NetBSD: thunk.c,v 1.83 2013/05/22 13:34:31 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,7 +28,7 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.82 2012/07/02 12:17:12 reinoud Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.83 2013/05/22 13:34:31 reinoud Exp $"); #endif #include @@ -40,6 +40,7 @@ __RCSID("$NetBSD: thunk.c,v 1.82 2012/07 #include #include #include +#include #include #include
CVS commit: src/sys/arch/usermode/conf
Module Name:src Committed By: yamt Date: Wed Mar 6 11:36:22 UTC 2013 Modified Files: src/sys/arch/usermode/conf: Makefile.usermode Log Message: fix include dir add some dependencies To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/arch/usermode/conf/Makefile.usermode 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/conf/Makefile.usermode diff -u src/sys/arch/usermode/conf/Makefile.usermode:1.32 src/sys/arch/usermode/conf/Makefile.usermode:1.33 --- src/sys/arch/usermode/conf/Makefile.usermode:1.32 Sat Jun 30 15:03:57 2012 +++ src/sys/arch/usermode/conf/Makefile.usermode Wed Mar 6 11:36:21 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.usermode,v 1.32 2012/06/30 15:03:57 reinoud Exp $ +# $NetBSD: Makefile.usermode,v 1.33 2013/03/06 11:36:21 yamt Exp $ USETOOLS?= no NEED_OWN_INSTALL_TARGET?= no @@ -21,7 +21,8 @@ MACHINE_ARCH!=uname -p USERMODE_HOSTOS!=uname -s USERMODE_HOSTMACHINE!=uname -m USERMODE_LIBS= -L${DESTDIR}/usr/lib -lrt -USERMODE_CPPFLAGS=${DEBUG} -U_KERNEL -I/usr/include +USERMODE_CPPFLAGS=${DEBUG} -U_KERNEL +USERMODE_CPPFLAGS+=-I${DESTDIR}/usr/include USERMODE_CPPFLAGS+=${CWARNFLAGS} ${NOGCCERROR:D:U-Werror} ## XXX hack to make it work under build.sh @@ -96,6 +97,8 @@ thunk.d: ${USERMODE}/usermode/thunk.c thunk.o: ${USERMODE}/usermode/thunk.c ${CC} ${COPTS} ${CPPFLAGS.thunk.c} -c -o $@ ${USERMODE}/usermode/thunk.c +cpu_${MACHINE_ARCH}.o: ${USERMODE}/target/${MACHINE_ARCH}/cpu_${MACHINE_ARCH}.c + ## ## (7) misc settings ##
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Sat Aug 4 14:53:32 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: trap.c Log Message: Fix IO lockups in NetBSD/usermode. 1) Don't block IO signals since the return path is not garanteed to enable the signal again. 2) Since signals can get dropped, do a 2nd pass over the routines. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/arch/usermode/usermode/trap.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/trap.c diff -u src/sys/arch/usermode/usermode/trap.c:1.65 src/sys/arch/usermode/usermode/trap.c:1.66 --- src/sys/arch/usermode/usermode/trap.c:1.65 Sat Mar 3 21:29:02 2012 +++ src/sys/arch/usermode/usermode/trap.c Sat Aug 4 14:53:32 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.65 2012/03/03 21:29:02 reinoud Exp $ */ +/* $NetBSD: trap.c,v 1.66 2012/08/04 14:53:32 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.65 2012/03/03 21:29:02 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.66 2012/08/04 14:53:32 reinoud Exp $"); #include #include @@ -364,10 +364,6 @@ handle_signal(int sig, siginfo_t *info, thunk_sigemptyset(&jump_ucp.uc_sigmask); jump_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK; - /* prevent recursive IO signals */ - if (sig == SIGIO) - thunk_sigaddset(&jump_ucp.uc_sigmask, SIGIO); - thunk_makecontext(&jump_ucp, (void (*)(void)) f, 4, info, (void *) from_userland, (void *) pc, (void *) va); @@ -612,13 +608,15 @@ sigio(siginfo_t *info, vaddr_t from_user struct lwp *l = curlwp; struct pcb *pcb = lwp_getpcb(l); KASSERT(pcb); struct intr_handler *sih; - unsigned int n; + unsigned int n, pass; // thunk_printf("%s: l %p, pcb %p\n", __func__, l, pcb); - for (n = 0; n < SIGIO_MAX_HANDLERS; n++) { - sih = &sigio_intr_handler[n]; - if (sih->func) - sih->func(sih->arg); + for (pass = 0; pass < 2; pass++) { + for (n = 0; n < SIGIO_MAX_HANDLERS; n++) { + sih = &sigio_intr_handler[n]; + if (sih->func) +sih->func(sih->arg); + } } KASSERT(l == curlwp);
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Tue Jul 24 13:59:26 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: pmap.c Log Message: Adding an assert that checks for struct pmap_l2 not being bigger than PAGE_SIZE. While here, also add possible bug allerts of temporary mmaps that might screw up memory. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/sys/arch/usermode/usermode/pmap.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/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.103 src/sys/arch/usermode/usermode/pmap.c:1.104 --- src/sys/arch/usermode/usermode/pmap.c:1.103 Fri Mar 2 16:56:32 2012 +++ src/sys/arch/usermode/usermode/pmap.c Tue Jul 24 13:59:26 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.103 2012/03/02 16:56:32 reinoud Exp $ */ +/* $NetBSD: pmap.c,v 1.104 2012/07/24 13:59:26 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.103 2012/03/02 16:56:32 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.104 2012/07/24 13:59:26 reinoud Exp $"); #include "opt_memsize.h" #include "opt_kmempages.h" @@ -204,6 +204,9 @@ pmap_bootstrap(void) if (TRAPSTACKSIZE < 4*PAGE_SIZE) { panic("TRAPSTACKSIZE is too small, please increase UPAGES"); } + if (sizeof(struct pmap_l2) > PAGE_SIZE) { + panic("struct pmap_l2 bigger than one page?\n"); + } /* protect user memory UVM area (---) */ err = thunk_munmap((void *) kmem_user_start, @@ -1202,6 +1205,7 @@ pmap_zero_page(paddr_t pa) if (pa & (PAGE_SIZE-1)) panic("%s: unaligned address passed : %p\n", __func__, (void *) pa); + /* XXX bug alart: can we allow the kernel to make a decision on this? */ blob = thunk_mmap(NULL, PAGE_SIZE, THUNK_PROT_READ | THUNK_PROT_WRITE, THUNK_MAP_FILE | THUNK_MAP_SHARED, @@ -1227,6 +1231,7 @@ pmap_copy_page(paddr_t src_pa, paddr_t d thunk_printf_debug("pmap_copy_page: pa src %p, pa dst %p\n", (void *) src_pa, (void *) dst_pa); + /* XXX bug alart: can we allow the kernel to make a decision on this? */ sblob = thunk_mmap(NULL, PAGE_SIZE, THUNK_PROT_READ, THUNK_MAP_FILE | THUNK_MAP_SHARED, @@ -1234,6 +1239,7 @@ pmap_copy_page(paddr_t src_pa, paddr_t d if (!sblob) panic("%s: couldn't get src mapping", __func__); + /* XXX bug alart: can we allow the kernel to make a decision on this? */ dblob = thunk_mmap(NULL, PAGE_SIZE, THUNK_PROT_READ | THUNK_PROT_WRITE, THUNK_MAP_FILE | THUNK_MAP_SHARED,
CVS commit: src/sys/arch/usermode/modules/syscallemu
Module Name:src Committed By: christos Date: Tue Jul 3 21:07:41 UTC 2012 Modified Files: src/sys/arch/usermode/modules/syscallemu: Makefile Log Message: no home-brewed NETBSDSRCDIR please (fix the build) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/modules/syscallemu/Makefile 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/modules/syscallemu/Makefile diff -u src/sys/arch/usermode/modules/syscallemu/Makefile:1.2 src/sys/arch/usermode/modules/syscallemu/Makefile:1.3 --- src/sys/arch/usermode/modules/syscallemu/Makefile:1.2 Fri Jan 6 08:16:20 2012 +++ src/sys/arch/usermode/modules/syscallemu/Makefile Tue Jul 3 17:07:41 2012 @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.2 2012/01/06 13:16:20 jmcneill Exp $ +# $NetBSD: Makefile,v 1.3 2012/07/03 21:07:41 christos Exp $ -NETBSDSRCDIR?= ../../../../.. +.include S?= ${NETBSDSRCDIR}/sys M?= ${S}/modules
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Mon Jul 2 12:17:12 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: thunk.c Log Message: Fix missing include that breaks the autobuild To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/arch/usermode/usermode/thunk.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/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.81 src/sys/arch/usermode/usermode/thunk.c:1.82 --- src/sys/arch/usermode/usermode/thunk.c:1.81 Sat Mar 3 21:15:16 2012 +++ src/sys/arch/usermode/usermode/thunk.c Mon Jul 2 12:17:12 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.81 2012/03/03 21:15:16 reinoud Exp $ */ +/* $NetBSD: thunk.c,v 1.82 2012/07/02 12:17:12 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,11 +28,12 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.81 2012/03/03 21:15:16 reinoud Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.82 2012/07/02 12:17:12 reinoud Exp $"); #endif #include #include +#include #include #include #include
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Mon Jun 25 14:43:54 UTC 2012 Modified Files: src/sys/arch/usermode/dev: cpu.c Log Message: Implement dummy `cpu_mcontext_validate' to make it compile again. This function needs to be implemented in the target secton one day for extra security. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/sys/arch/usermode/dev/cpu.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/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.70 src/sys/arch/usermode/dev/cpu.c:1.71 --- src/sys/arch/usermode/dev/cpu.c:1.70 Sat Mar 3 21:15:15 2012 +++ src/sys/arch/usermode/dev/cpu.c Mon Jun 25 14:43:54 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.70 2012/03/03 21:15:15 reinoud Exp $ */ +/* $NetBSD: cpu.c,v 1.71 2012/06/25 14:43:54 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,7 +30,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.70 2012/03/03 21:15:15 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.71 2012/06/25 14:43:54 reinoud Exp $"); #include #include @@ -286,6 +286,16 @@ cpu_getmcontext(struct lwp *l, mcontext_ } int +cpu_mcontext_validate(struct lwp *l, const mcontext_t *mcp) +{ + /* + * can we check here? or should that be done in the target + * specific places? + */ + return 0; +} + +int cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags) { struct pcb *pcb = lwp_getpcb(l);
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Sat Mar 3 21:29:02 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: trap.c Log Message: Use the signal's signo instead of just returning SIGSEGV and add a comment To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/arch/usermode/usermode/trap.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/trap.c diff -u src/sys/arch/usermode/usermode/trap.c:1.64 src/sys/arch/usermode/usermode/trap.c:1.65 --- src/sys/arch/usermode/usermode/trap.c:1.64 Sat Mar 3 21:15:16 2012 +++ src/sys/arch/usermode/usermode/trap.c Sat Mar 3 21:29:02 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.64 2012/03/03 21:15:16 reinoud Exp $ */ +/* $NetBSD: trap.c,v 1.65 2012/03/03 21:29:02 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.64 2012/03/03 21:15:16 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.65 2012/03/03 21:29:02 reinoud Exp $"); #include #include @@ -480,7 +480,7 @@ pagefault(siginfo_t *info, vaddr_t from_ KASSERT(from_userland); KSI_INIT_TRAP(&ksi); - ksi.ksi_signo = SIGSEGV; + ksi.ksi_signo = info->si_signo; ksi.ksi_trap = 0; /* XXX */ ksi.ksi_code = (error == EPERM) ? SEGV_ACCERR : SEGV_MAPERR; ksi.ksi_addr = (void *) va; @@ -552,6 +552,11 @@ illegal_instruction(siginfo_t *info, vad } +/* + * handle pass to userland signals + * + * arguments other than the origional siginfo_t are not used + */ static void pass_on(siginfo_t *info, vaddr_t from_userland, vaddr_t pc, vaddr_t va) {
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Sat Mar 3 21:15:16 UTC 2012 Modified Files: src/sys/arch/usermode/dev: cpu.c ttycons.c src/sys/arch/usermode/include: intr.h thunk.h src/sys/arch/usermode/target/i386: cpu_i386.c src/sys/arch/usermode/usermode: thunk.c trap.c Log Message: Implement signal forwarding to userland for usermode kernels. Especially SIGFPE is important since the urkel shouldn't stop when a userland program devides by zero! To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/arch/usermode/dev/cpu.c cvs rdiff -u -r1.18 -r1.19 src/sys/arch/usermode/dev/ttycons.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/include/intr.h cvs rdiff -u -r1.60 -r1.61 src/sys/arch/usermode/include/thunk.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/target/i386/cpu_i386.c cvs rdiff -u -r1.80 -r1.81 src/sys/arch/usermode/usermode/thunk.c cvs rdiff -u -r1.63 -r1.64 src/sys/arch/usermode/usermode/trap.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/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.69 src/sys/arch/usermode/dev/cpu.c:1.70 --- src/sys/arch/usermode/dev/cpu.c:1.69 Sat Jan 21 22:09:56 2012 +++ src/sys/arch/usermode/dev/cpu.c Sat Mar 3 21:15:15 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.69 2012/01/21 22:09:56 reinoud Exp $ */ +/* $NetBSD: cpu.c,v 1.70 2012/03/03 21:15:15 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,7 +30,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.69 2012/01/21 22:09:56 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.70 2012/03/03 21:15:15 reinoud Exp $"); #include #include @@ -242,7 +242,7 @@ cpu_switchto(lwp_t *oldlwp, lwp_t *newlw /* create atomic switcher */ thunk_makecontext(&sc->sc_ucp, (void (*)(void)) cpu_switchto_atomic, - 2, oldlwp, newlwp, NULL); + 2, oldlwp, newlwp, NULL, NULL); KASSERT(sc); if (oldpcb) { @@ -341,7 +341,7 @@ cpu_lwp_trampoline(ucontext_t *ucp, void lwp_startup(curcpu()->ci_stash, curlwp); /* actual jump */ - thunk_makecontext(ucp, (void (*)(void)) func, 1, arg, NULL, NULL); + thunk_makecontext(ucp, (void (*)(void)) func, 1, arg, NULL, NULL, NULL); thunk_setcontext(ucp); } @@ -381,7 +381,7 @@ cpu_lwp_fork(struct lwp *l1, struct lwp pcb2->pcb_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK; thunk_makecontext(&pcb2->pcb_ucp, (void (*)(void)) cpu_lwp_trampoline, - 3, &pcb2->pcb_ucp, func, arg); + 3, &pcb2->pcb_ucp, func, arg, NULL); } void Index: src/sys/arch/usermode/dev/ttycons.c diff -u src/sys/arch/usermode/dev/ttycons.c:1.18 src/sys/arch/usermode/dev/ttycons.c:1.19 --- src/sys/arch/usermode/dev/ttycons.c:1.18 Sat Jan 21 22:09:57 2012 +++ src/sys/arch/usermode/dev/ttycons.c Sat Mar 3 21:15:15 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ttycons.c,v 1.18 2012/01/21 22:09:57 reinoud Exp $ */ +/* $NetBSD: ttycons.c,v 1.19 2012/03/03 21:15:15 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ttycons.c,v 1.18 2012/01/21 22:09:57 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ttycons.c,v 1.19 2012/03/03 21:15:15 reinoud Exp $"); #include #include @@ -389,7 +389,7 @@ ttycons_softintr(void *priv) * argument 'pc' and 'va' are not used. */ static void -ttycons_ctrlc(vaddr_t from_userland, vaddr_t pc, vaddr_t va) +ttycons_ctrlc(siginfo_t *info, vaddr_t from_userland, vaddr_t pc, vaddr_t va) { struct ttycons_softc *sc; @@ -416,7 +416,7 @@ ttycons_softctrlc(void *priv) * argument 'pc' and 'va' are not used. */ static void -ttycons_ctrlz(vaddr_t from_userland, vaddr_t pc, vaddr_t va) +ttycons_ctrlz(siginfo_t *info, vaddr_t from_userland, vaddr_t pc, vaddr_t va) { struct ttycons_softc *sc; Index: src/sys/arch/usermode/include/intr.h diff -u src/sys/arch/usermode/include/intr.h:1.8 src/sys/arch/usermode/include/intr.h:1.9 --- src/sys/arch/usermode/include/intr.h:1.8 Thu Feb 2 11:13:41 2012 +++ src/sys/arch/usermode/include/intr.h Sat Mar 3 21:15:16 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.8 2012/02/02 11:13:41 reinoud Exp $ */ +/* $NetBSD: intr.h,v 1.9 2012/03/03 21:15:16 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -41,7 +41,7 @@ void spllower(int); #define splx(x) spllower(x) /* traps */ -typedef void (sigfunc_t)(vaddr_t from_userland, vaddr_t pc, vaddr_t va); +typedef void (sigfunc_t)(siginfo_t *info, vaddr_t from_userland, vaddr_t pc, vaddr_t va); extern void setup_signal_handlers(void); extern void signal_intr_establish(int sig, sigfunc_t f); extern void *sigio_intr_establish(int (*)(void *), void *); Index: src/sys/arch/usermode/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.60 src/sys/arch/usermode/include/thunk.h:1.61 --- src/sys/arch/usermode/include/thunk.h:1.60 Sat Jan 21 19:17:33 2012 +++ src/sys/a
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Fri Mar 2 16:56:33 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: pmap.c Log Message: Move from pool(9) to kmem_zalloc(9) for L2 page tables. A pool with PAGE_SIZE elements is accepted but seems to panic now and then claiming it can't find the header info. XXX should this be PR'd? To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/arch/usermode/usermode/pmap.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/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.102 src/sys/arch/usermode/usermode/pmap.c:1.103 --- src/sys/arch/usermode/usermode/pmap.c:1.102 Sat Jan 14 17:42:52 2012 +++ src/sys/arch/usermode/usermode/pmap.c Fri Mar 2 16:56:32 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.102 2012/01/14 17:42:52 reinoud Exp $ */ +/* $NetBSD: pmap.c,v 1.103 2012/03/02 16:56:32 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.102 2012/01/14 17:42:52 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.103 2012/03/02 16:56:32 reinoud Exp $"); #include "opt_memsize.h" #include "opt_kmempages.h" @@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.1 #include #include #include +#include #include #include #include @@ -95,7 +96,6 @@ static uint64_t pm_entries_size = 0; static struct pool pmap_pool; static struct pool pmap_l1_pool; -static struct pool pmap_l2_pool; static struct pool pmap_pventry_pool; /* forwards */ @@ -451,8 +451,6 @@ pmap_deferred_init(void) /* create pmap pool */ pool_init(&pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappool", NULL, IPL_NONE); - pool_init(&pmap_l2_pool, PMAP_L2_SIZE, 0, 0, 0, - "pmapl2pool", NULL, IPL_HIGH); pool_init(&pmap_l1_pool, pm_l1_size, 0, 0, 0, "pmapl1pool", NULL, IPL_NONE); pool_init(&pmap_pventry_pool, sizeof(struct pv_entry), 0, 0, 0, @@ -529,7 +527,7 @@ pmap_destroy(pmap_t pmap) l2tbl = pmap->pm_l1[l1]; if (!l2tbl) continue; - pool_put(&pmap_l2_pool, l2tbl); + kmem_free(l2tbl, PMAP_L2_SIZE); } pool_put(&pmap_l1_pool, pmap->pm_l1); pool_put(&pmap_pool, pmap); @@ -623,8 +621,8 @@ pmap_set_pv(pmap_t pmap, uintptr_t lpn, l2tbl = pmap->pm_l1[l1]; if (!l2tbl) { - l2tbl = pmap->pm_l1[l1] = pool_get(&pmap_l2_pool, PR_WAITOK); - memset(l2tbl, 0, PMAP_L2_SIZE); + l2tbl = pmap->pm_l1[l1] = kmem_zalloc(PMAP_L2_SIZE, KM_SLEEP); + /* should be zero filled */ } l2tbl->pm_l2[l2] = pv; }
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Wed Feb 15 15:20:53 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: trap.c Log Message: Prevent recursive IO signals. This prevents crashes when pieces of text are pasted in say an Xterm. Each char might create a SIGIO running out of stackspace very quickly! To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/arch/usermode/usermode/trap.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/trap.c diff -u src/sys/arch/usermode/usermode/trap.c:1.62 src/sys/arch/usermode/usermode/trap.c:1.63 --- src/sys/arch/usermode/usermode/trap.c:1.62 Sun Jan 22 17:51:39 2012 +++ src/sys/arch/usermode/usermode/trap.c Wed Feb 15 15:20:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.62 2012/01/22 17:51:39 reinoud Exp $ */ +/* $NetBSD: trap.c,v 1.63 2012/02/15 15:20:53 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.62 2012/01/22 17:51:39 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.63 2012/02/15 15:20:53 reinoud Exp $"); #include #include @@ -362,6 +362,11 @@ handle_signal(int sig, siginfo_t *info, thunk_sigemptyset(&jump_ucp.uc_sigmask); jump_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK; + + /* prevent recursive IO signals */ + if (sig == SIGIO) + thunk_sigaddset(&jump_ucp.uc_sigmask, SIGIO); + thunk_makecontext(&jump_ucp, (void (*)(void)) f, 3, (void *) from_userland, (void *) pc, (void *) va);
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Mon Feb 13 19:15:59 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: syscall.c Log Message: Add cpu_spawn_return() as per other archs to make it compile. No tests done yet. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/usermode/usermode/syscall.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/syscall.c diff -u src/sys/arch/usermode/usermode/syscall.c:1.22 src/sys/arch/usermode/usermode/syscall.c:1.23 --- src/sys/arch/usermode/usermode/syscall.c:1.22 Sat Jan 14 21:45:28 2012 +++ src/sys/arch/usermode/usermode/syscall.c Mon Feb 13 19:15:59 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: syscall.c,v 1.22 2012/01/14 21:45:28 reinoud Exp $ */ +/* $NetBSD: syscall.c,v 1.23 2012/02/13 19:15:59 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.22 2012/01/14 21:45:28 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.23 2012/02/13 19:15:59 reinoud Exp $"); #include #include @@ -63,6 +63,16 @@ child_return(void *arg) ktrsysret(SYS_fork, 0, 0); } +/* + * Process the tail end of a posix_spawn() for the child. + */ +void +cpu_spawn_return(struct lwp *l) +{ + + userret(l); +} + extern const char *const syscallnames[]; static void syscall_args_print(lwp_t *l, int code, int nargs, int argsize,
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Wed Feb 8 17:55:21 UTC 2012 Modified Files: src/sys/arch/usermode/include: cpu.h types.h vmparam.h src/sys/arch/usermode/usermode: machdep.c Log Message: Fix /dev/kmem access and make vmstat(1) `work'. Not sure all the results are indeed valid or correct but at least it shows them without coredumping or coredumping the kernel. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/include/cpu.h cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/include/types.h cvs rdiff -u -r1.15 -r1.16 src/sys/arch/usermode/include/vmparam.h cvs rdiff -u -r1.52 -r1.53 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/include/cpu.h diff -u src/sys/arch/usermode/include/cpu.h:1.9 src/sys/arch/usermode/include/cpu.h:1.10 --- src/sys/arch/usermode/include/cpu.h:1.9 Thu Jan 19 12:14:49 2012 +++ src/sys/arch/usermode/include/cpu.h Wed Feb 8 17:55:21 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.9 2012/01/19 12:14:49 reinoud Exp $ */ +/* $NetBSD: cpu.h,v 1.10 2012/02/08 17:55:21 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -50,10 +50,10 @@ extern void cpu_need_resched(struct cpu_ struct cpu_info { - device_t ci_dev; + struct cpu_data ci_data; /* MI per-cpu data */ + device_t ci_dev; /* pointer to our device */ struct cpu_info *ci_self; struct cpu_info *ci_next; - struct cpu_data ci_data; u_int ci_cpuid; int ci_want_resched; int ci_idepth; Index: src/sys/arch/usermode/include/types.h diff -u src/sys/arch/usermode/include/types.h:1.7 src/sys/arch/usermode/include/types.h:1.8 --- src/sys/arch/usermode/include/types.h:1.7 Sun Jan 8 18:06:00 2012 +++ src/sys/arch/usermode/include/types.h Wed Feb 8 17:55:21 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.7 2012/01/08 18:06:00 jmcneill Exp $ */ +/* $NetBSD: types.h,v 1.8 2012/02/08 17:55:21 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -62,4 +62,7 @@ typedef volatile unsigned char __cpu_sim #define __HAVE_OLD_DISKLABEL #endif +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_MM_MD_KERNACC + #endif /* !_ARCH_USERMODE_INCLUDE_TYPES_H */ Index: src/sys/arch/usermode/include/vmparam.h diff -u src/sys/arch/usermode/include/vmparam.h:1.15 src/sys/arch/usermode/include/vmparam.h:1.16 --- src/sys/arch/usermode/include/vmparam.h:1.15 Tue Jan 10 10:19:38 2012 +++ src/sys/arch/usermode/include/vmparam.h Wed Feb 8 17:55:21 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.15 2012/01/10 10:19:38 reinoud Exp $ */ +/* $NetBSD: vmparam.h,v 1.16 2012/02/08 17:55:21 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -36,6 +36,7 @@ extern paddr_t kmem_k_start, kmem_k_end; extern paddr_t kmem_kvm_start, kmem_kvm_end; +extern paddr_t kmem_kvm_cur_end; extern paddr_t kmem_user_start, kmem_user_end; #define VM_MIN_ADDRESS kmem_user_start Index: src/sys/arch/usermode/usermode/machdep.c diff -u src/sys/arch/usermode/usermode/machdep.c:1.52 src/sys/arch/usermode/usermode/machdep.c:1.53 --- src/sys/arch/usermode/usermode/machdep.c:1.52 Sun Jan 15 10:30:21 2012 +++ src/sys/arch/usermode/usermode/machdep.c Wed Feb 8 17:55:21 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.52 2012/01/15 10:30:21 jmcneill Exp $ */ +/* $NetBSD: machdep.c,v 1.53 2012/02/08 17:55:21 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -37,7 +37,7 @@ #include "opt_memsize.h" #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.52 2012/01/15 10:30:21 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.53 2012/02/08 17:55:21 reinoud Exp $"); #include #include @@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include #include +#include #include #include @@ -249,8 +250,30 @@ consinit(void) } int -mm_md_physacc(paddr_t pa, vm_prot_t prog) +mm_md_physacc(paddr_t pa, vm_prot_t prot) { + // printf("%s: pa = %p, acc %d\n", __func__, (void *) pa, prot); + if (pa >= physmem * PAGE_SIZE) + return EFAULT; + return 0; +} + + +int +mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled) +{ + const vaddr_t va = (vaddr_t)ptr; + extern void *end; + + // printf("%s: ptr %p, acc %d\n", __func__, ptr, prot); + if (va < kmem_kvm_start) + return EFAULT; + if ((va >= kmem_kvm_cur_end) && (va < kmem_k_start)) + return EFAULT; + if (va > (vaddr_t) end) + return EFAULT; + + *handled = true; return 0; }
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Sun Feb 5 17:40:08 UTC 2012 Modified Files: src/sys/arch/usermode/include: asm.h bswap.h byte_swap.h cdefs.h disklabel.h elf_machdep.h endian.h endian_machdep.h int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h limits.h netbsd32_machdep.h param.h ptrace.h wchar_limits.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/include/asm.h \ src/sys/arch/usermode/include/bswap.h \ src/sys/arch/usermode/include/byte_swap.h \ src/sys/arch/usermode/include/elf_machdep.h \ src/sys/arch/usermode/include/endian.h \ src/sys/arch/usermode/include/endian_machdep.h \ src/sys/arch/usermode/include/int_const.h \ src/sys/arch/usermode/include/int_fmtio.h \ src/sys/arch/usermode/include/int_limits.h \ src/sys/arch/usermode/include/int_mwgwtypes.h \ src/sys/arch/usermode/include/int_types.h \ src/sys/arch/usermode/include/limits.h \ src/sys/arch/usermode/include/netbsd32_machdep.h \ src/sys/arch/usermode/include/wchar_limits.h cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/include/cdefs.h cvs rdiff -u -r1.11 -r1.12 src/sys/arch/usermode/include/disklabel.h \ src/sys/arch/usermode/include/ptrace.h cvs rdiff -u -r1.10 -r1.11 src/sys/arch/usermode/include/param.h 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/include/asm.h diff -u src/sys/arch/usermode/include/asm.h:1.9 src/sys/arch/usermode/include/asm.h:1.10 --- src/sys/arch/usermode/include/asm.h:1.9 Sun Feb 5 14:27:08 2012 +++ src/sys/arch/usermode/include/asm.h Sun Feb 5 17:40:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: asm.h,v 1.9 2012/02/05 14:27:08 reinoud Exp $ */ +/* $NetBSD: asm.h,v 1.10 2012/02/05 17:40:08 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Feb 5 15:25:56 CET 2012 + * Automatically generated by genheaders.sh on Sun Feb 5 18:39:33 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_ASM_H Index: src/sys/arch/usermode/include/bswap.h diff -u src/sys/arch/usermode/include/bswap.h:1.9 src/sys/arch/usermode/include/bswap.h:1.10 --- src/sys/arch/usermode/include/bswap.h:1.9 Sun Feb 5 14:27:08 2012 +++ src/sys/arch/usermode/include/bswap.h Sun Feb 5 17:40:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: bswap.h,v 1.9 2012/02/05 14:27:08 reinoud Exp $ */ +/* $NetBSD: bswap.h,v 1.10 2012/02/05 17:40:08 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Feb 5 15:25:56 CET 2012 + * Automatically generated by genheaders.sh on Sun Feb 5 18:39:34 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_BSWAP_H Index: src/sys/arch/usermode/include/byte_swap.h diff -u src/sys/arch/usermode/include/byte_swap.h:1.9 src/sys/arch/usermode/include/byte_swap.h:1.10 --- src/sys/arch/usermode/include/byte_swap.h:1.9 Sun Feb 5 14:27:08 2012 +++ src/sys/arch/usermode/include/byte_swap.h Sun Feb 5 17:40:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: byte_swap.h,v 1.9 2012/02/05 14:27:08 reinoud Exp $ */ +/* $NetBSD: byte_swap.h,v 1.10 2012/02/05 17:40:08 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Feb 5 15:25:56 CET 2012 + * Automatically generated by genheaders.sh on Sun Feb 5 18:39:34 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_BYTE_SWAP_H Index: src/sys/arch/usermode/include/elf_machdep.h diff -u src/sys/arch/usermode/include/elf_machdep.h:1.9 src/sys/arch/usermode/include/elf_machdep.h:1.10 --- src/sys/arch/usermode/include/elf_machdep.h:1.9 Sun Feb 5 14:27:08 2012 +++ src/sys/arch/usermode/include/elf_machdep.h Sun Feb 5 17:40:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: elf_machdep.h,v 1.9 2012/02/05 14:27:08 reinoud Exp $ */ +/* $NetBSD: elf_machdep.h,v 1.10 2012/02/05 17:40:08 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Feb 5 15:25:56 CET 2012 + * Automatically generated by genheaders.sh on Sun Feb 5 18:39:34 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_ELF_MACHDEP_H Index: src/sys/arch/usermode/include/endian.h diff -u src/sys/arch/usermode/include/endian.h:1.9 src/sys/arch/usermode/include/endian.h:1.10 --- src/sys/arch/usermode/include/endian.h:1.9 Sun Feb 5 14:27:08 2012 +++ src/sys/arch/usermode/include/endian.h Sun Feb 5 17:40:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: endian.h,v 1.9 2012/02/05 14:27:08 reinoud Exp $ */ +/* $NetBSD: endian.h,v 1.10 2012/02/05 17:40:08 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Sun Feb 5 15:25:57 CET 2012 + * Automatically generated by genheaders.sh on Sun Feb 5 18:39:34 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_ENDIAN_H Index: src/sys/arch/usermode/include/endian_machdep.h diff -u src/sys/arch/usermode/include/endian_machdep.h:1.9 src/sys/arch/usermode/include/endian_machdep.h:1.10 --- src/sys/arch/usermode/include/endi
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Sun Feb 5 17:39:18 UTC 2012 Modified Files: src/sys/arch/usermode/include: genheaders.sh Log Message: With the recent kmem changes, remove the `unlimited' maximum setting of NKMEMPAGES from amd64 since it gets us into trouble. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/include/genheaders.sh 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/include/genheaders.sh diff -u src/sys/arch/usermode/include/genheaders.sh:1.7 src/sys/arch/usermode/include/genheaders.sh:1.8 --- src/sys/arch/usermode/include/genheaders.sh:1.7 Sat Feb 4 23:04:15 2012 +++ src/sys/arch/usermode/include/genheaders.sh Sun Feb 5 17:39:18 2012 @@ -60,6 +60,9 @@ EOF echo "#define UPAGES 12" >> ${hdr} echo "#undef USPACE" >> ${hdr} echo "#define USPACE (PAGE_SIZE*UPAGES)" >> ${hdr} + echo "" >> ${hdr} + echo "#undef NKMEMPAGES_MAX_UNLIMITED" >> ${hdr} + echo "#include \"opt_kmempages.h\"" >> ${hdr} fi echo >>${hdr}
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Sun Feb 5 14:27:09 UTC 2012 Modified Files: src/sys/arch/usermode/include: asm.h bswap.h byte_swap.h cdefs.h disklabel.h elf_machdep.h endian.h endian_machdep.h int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h limits.h netbsd32_machdep.h param.h ptrace.h wchar_limits.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/include/asm.h \ src/sys/arch/usermode/include/bswap.h \ src/sys/arch/usermode/include/byte_swap.h \ src/sys/arch/usermode/include/elf_machdep.h \ src/sys/arch/usermode/include/endian.h \ src/sys/arch/usermode/include/endian_machdep.h \ src/sys/arch/usermode/include/int_const.h \ src/sys/arch/usermode/include/int_fmtio.h \ src/sys/arch/usermode/include/int_limits.h \ src/sys/arch/usermode/include/int_mwgwtypes.h \ src/sys/arch/usermode/include/int_types.h \ src/sys/arch/usermode/include/limits.h \ src/sys/arch/usermode/include/netbsd32_machdep.h \ src/sys/arch/usermode/include/wchar_limits.h cvs rdiff -u -r1.3 -r1.4 src/sys/arch/usermode/include/cdefs.h cvs rdiff -u -r1.10 -r1.11 src/sys/arch/usermode/include/disklabel.h \ src/sys/arch/usermode/include/ptrace.h cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/include/param.h 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/include/asm.h diff -u src/sys/arch/usermode/include/asm.h:1.8 src/sys/arch/usermode/include/asm.h:1.9 --- src/sys/arch/usermode/include/asm.h:1.8 Thu Feb 2 11:12:40 2012 +++ src/sys/arch/usermode/include/asm.h Sun Feb 5 14:27:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: asm.h,v 1.8 2012/02/02 11:12:40 reinoud Exp $ */ +/* $NetBSD: asm.h,v 1.9 2012/02/05 14:27:08 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Fri Jan 27 08:34:26 CET 2012 + * Automatically generated by genheaders.sh on Sun Feb 5 15:25:56 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_ASM_H Index: src/sys/arch/usermode/include/bswap.h diff -u src/sys/arch/usermode/include/bswap.h:1.8 src/sys/arch/usermode/include/bswap.h:1.9 --- src/sys/arch/usermode/include/bswap.h:1.8 Thu Feb 2 11:12:40 2012 +++ src/sys/arch/usermode/include/bswap.h Sun Feb 5 14:27:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: bswap.h,v 1.8 2012/02/02 11:12:40 reinoud Exp $ */ +/* $NetBSD: bswap.h,v 1.9 2012/02/05 14:27:08 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Fri Jan 27 08:34:26 CET 2012 + * Automatically generated by genheaders.sh on Sun Feb 5 15:25:56 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_BSWAP_H Index: src/sys/arch/usermode/include/byte_swap.h diff -u src/sys/arch/usermode/include/byte_swap.h:1.8 src/sys/arch/usermode/include/byte_swap.h:1.9 --- src/sys/arch/usermode/include/byte_swap.h:1.8 Thu Feb 2 11:12:40 2012 +++ src/sys/arch/usermode/include/byte_swap.h Sun Feb 5 14:27:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: byte_swap.h,v 1.8 2012/02/02 11:12:40 reinoud Exp $ */ +/* $NetBSD: byte_swap.h,v 1.9 2012/02/05 14:27:08 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Fri Jan 27 08:34:26 CET 2012 + * Automatically generated by genheaders.sh on Sun Feb 5 15:25:56 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_BYTE_SWAP_H Index: src/sys/arch/usermode/include/elf_machdep.h diff -u src/sys/arch/usermode/include/elf_machdep.h:1.8 src/sys/arch/usermode/include/elf_machdep.h:1.9 --- src/sys/arch/usermode/include/elf_machdep.h:1.8 Thu Feb 2 11:12:40 2012 +++ src/sys/arch/usermode/include/elf_machdep.h Sun Feb 5 14:27:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: elf_machdep.h,v 1.8 2012/02/02 11:12:40 reinoud Exp $ */ +/* $NetBSD: elf_machdep.h,v 1.9 2012/02/05 14:27:08 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Fri Jan 27 08:34:26 CET 2012 + * Automatically generated by genheaders.sh on Sun Feb 5 15:25:56 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_ELF_MACHDEP_H Index: src/sys/arch/usermode/include/endian.h diff -u src/sys/arch/usermode/include/endian.h:1.8 src/sys/arch/usermode/include/endian.h:1.9 --- src/sys/arch/usermode/include/endian.h:1.8 Thu Feb 2 11:12:40 2012 +++ src/sys/arch/usermode/include/endian.h Sun Feb 5 14:27:08 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: endian.h,v 1.8 2012/02/02 11:12:40 reinoud Exp $ */ +/* $NetBSD: endian.h,v 1.9 2012/02/05 14:27:08 reinoud Exp $ */ /* - * Automatically generated by genheaders.sh on Fri Jan 27 08:34:26 CET 2012 + * Automatically generated by genheaders.sh on Sun Feb 5 15:25:57 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_ENDIAN_H Index: src/sys/arch/usermode/include/endian_machdep.h diff -u src/sys/arch/usermode/include/endian_machdep.h:1.8 src/sys/arch/usermode/include/endian_machdep.h:1.9 --- src/sys/arch/usermode/include/endian_machdep.h:
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Sat Feb 4 23:04:15 UTC 2012 Modified Files: src/sys/arch/usermode/include: genheaders.sh Log Message: Bump UPAGES effectively bumping per-process (system) stack i.e. the stack on which traps are taken. When it was 8 it could run out of space on big NFS stack traces in combination with timer and memory paging. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/usermode/include/genheaders.sh 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/include/genheaders.sh diff -u src/sys/arch/usermode/include/genheaders.sh:1.6 src/sys/arch/usermode/include/genheaders.sh:1.7 --- src/sys/arch/usermode/include/genheaders.sh:1.6 Thu Feb 2 11:10:24 2012 +++ src/sys/arch/usermode/include/genheaders.sh Sat Feb 4 23:04:15 2012 @@ -57,7 +57,7 @@ EOF echo "#undef __HAVE_PROCFS_MACHDEP" >> ${hdr} elif [ "$hdr" = "param.h" ]; then echo "#undef UPAGES" >> ${hdr} - echo "#define UPAGES 8" >> ${hdr} + echo "#define UPAGES 12" >> ${hdr} echo "#undef USPACE" >> ${hdr} echo "#define USPACE (PAGE_SIZE*UPAGES)" >> ${hdr} fi
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Thu Feb 2 11:13:41 UTC 2012 Modified Files: src/sys/arch/usermode/include: intr.h Log Message: spl_intr() is not defined anymore so remove from the header file To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/include/intr.h 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/include/intr.h diff -u src/sys/arch/usermode/include/intr.h:1.7 src/sys/arch/usermode/include/intr.h:1.8 --- src/sys/arch/usermode/include/intr.h:1.7 Sat Jan 21 22:09:57 2012 +++ src/sys/arch/usermode/include/intr.h Thu Feb 2 11:13:41 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.h,v 1.7 2012/01/21 22:09:57 reinoud Exp $ */ +/* $NetBSD: intr.h,v 1.8 2012/02/02 11:13:41 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -36,7 +36,6 @@ void splinit(void); int splraise(int); void spllower(int); -void spl_intr(int x, void (*func)(void *), void *arg); #define spl0() spllower(IPL_NONE) #define splx(x) spllower(x)
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Thu Feb 2 11:12:40 UTC 2012 Modified Files: src/sys/arch/usermode/include: asm.h bswap.h byte_swap.h cdefs.h disklabel.h elf_machdep.h endian.h endian_machdep.h int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h limits.h netbsd32_machdep.h param.h ptrace.h wchar_limits.h Log Message: Regen To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/include/asm.h \ src/sys/arch/usermode/include/bswap.h \ src/sys/arch/usermode/include/byte_swap.h \ src/sys/arch/usermode/include/elf_machdep.h \ src/sys/arch/usermode/include/endian.h \ src/sys/arch/usermode/include/endian_machdep.h \ src/sys/arch/usermode/include/int_const.h \ src/sys/arch/usermode/include/int_fmtio.h \ src/sys/arch/usermode/include/int_limits.h \ src/sys/arch/usermode/include/int_mwgwtypes.h \ src/sys/arch/usermode/include/int_types.h \ src/sys/arch/usermode/include/limits.h \ src/sys/arch/usermode/include/netbsd32_machdep.h \ src/sys/arch/usermode/include/wchar_limits.h cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/include/cdefs.h cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/include/disklabel.h \ src/sys/arch/usermode/include/ptrace.h cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/include/param.h 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/include/asm.h diff -u src/sys/arch/usermode/include/asm.h:1.7 src/sys/arch/usermode/include/asm.h:1.8 --- src/sys/arch/usermode/include/asm.h:1.7 Sat Jan 14 21:21:48 2012 +++ src/sys/arch/usermode/include/asm.h Thu Feb 2 11:12:40 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: asm.h,v 1.7 2012/01/14 21:21:48 reinoud Exp $ */ +/* $NetBSD: asm.h,v 1.8 2012/02/02 11:12:40 reinoud Exp $ */ /* - * Automatically generated by ./genheaders.sh on Sat Jan 14 22:20:59 CET 2012 + * Automatically generated by genheaders.sh on Fri Jan 27 08:34:26 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_ASM_H Index: src/sys/arch/usermode/include/bswap.h diff -u src/sys/arch/usermode/include/bswap.h:1.7 src/sys/arch/usermode/include/bswap.h:1.8 --- src/sys/arch/usermode/include/bswap.h:1.7 Sat Jan 14 21:21:48 2012 +++ src/sys/arch/usermode/include/bswap.h Thu Feb 2 11:12:40 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: bswap.h,v 1.7 2012/01/14 21:21:48 reinoud Exp $ */ +/* $NetBSD: bswap.h,v 1.8 2012/02/02 11:12:40 reinoud Exp $ */ /* - * Automatically generated by ./genheaders.sh on Sat Jan 14 22:20:59 CET 2012 + * Automatically generated by genheaders.sh on Fri Jan 27 08:34:26 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_BSWAP_H Index: src/sys/arch/usermode/include/byte_swap.h diff -u src/sys/arch/usermode/include/byte_swap.h:1.7 src/sys/arch/usermode/include/byte_swap.h:1.8 --- src/sys/arch/usermode/include/byte_swap.h:1.7 Sat Jan 14 21:21:48 2012 +++ src/sys/arch/usermode/include/byte_swap.h Thu Feb 2 11:12:40 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: byte_swap.h,v 1.7 2012/01/14 21:21:48 reinoud Exp $ */ +/* $NetBSD: byte_swap.h,v 1.8 2012/02/02 11:12:40 reinoud Exp $ */ /* - * Automatically generated by ./genheaders.sh on Sat Jan 14 22:20:59 CET 2012 + * Automatically generated by genheaders.sh on Fri Jan 27 08:34:26 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_BYTE_SWAP_H Index: src/sys/arch/usermode/include/elf_machdep.h diff -u src/sys/arch/usermode/include/elf_machdep.h:1.7 src/sys/arch/usermode/include/elf_machdep.h:1.8 --- src/sys/arch/usermode/include/elf_machdep.h:1.7 Sat Jan 14 21:21:48 2012 +++ src/sys/arch/usermode/include/elf_machdep.h Thu Feb 2 11:12:40 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: elf_machdep.h,v 1.7 2012/01/14 21:21:48 reinoud Exp $ */ +/* $NetBSD: elf_machdep.h,v 1.8 2012/02/02 11:12:40 reinoud Exp $ */ /* - * Automatically generated by ./genheaders.sh on Sat Jan 14 22:20:59 CET 2012 + * Automatically generated by genheaders.sh on Fri Jan 27 08:34:26 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_ELF_MACHDEP_H Index: src/sys/arch/usermode/include/endian.h diff -u src/sys/arch/usermode/include/endian.h:1.7 src/sys/arch/usermode/include/endian.h:1.8 --- src/sys/arch/usermode/include/endian.h:1.7 Sat Jan 14 21:21:48 2012 +++ src/sys/arch/usermode/include/endian.h Thu Feb 2 11:12:40 2012 @@ -1,7 +1,7 @@ -/* $NetBSD: endian.h,v 1.7 2012/01/14 21:21:48 reinoud Exp $ */ +/* $NetBSD: endian.h,v 1.8 2012/02/02 11:12:40 reinoud Exp $ */ /* - * Automatically generated by ./genheaders.sh on Sat Jan 14 22:20:59 CET 2012 + * Automatically generated by genheaders.sh on Fri Jan 27 08:34:26 CET 2012 * Do not modify directly! */ #ifndef _USERMODE_ENDIAN_H Index: src/sys/arch/usermode/include/endian_machdep.h diff -u src/sys/arch/usermode/include/endian_machdep.h:1.7 src/sys/arch/usermode/include/endian_machdep.h:1.8 --- src/sys/arch/usermode/include/endian_ma
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Thu Feb 2 11:10:24 UTC 2012 Modified Files: src/sys/arch/usermode/include: genheaders.sh Log Message: Add cdefs.h to usermode's genheaders.sh To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/usermode/include/genheaders.sh 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/include/genheaders.sh diff -u src/sys/arch/usermode/include/genheaders.sh:1.5 src/sys/arch/usermode/include/genheaders.sh:1.6 --- src/sys/arch/usermode/include/genheaders.sh:1.5 Sat Jan 14 21:20:56 2012 +++ src/sys/arch/usermode/include/genheaders.sh Thu Feb 2 11:10:24 2012 @@ -20,6 +20,7 @@ HDRS="$HDRS netbsd32_machdep.h" HDRS="$HDRS param.h" HDRS="$HDRS ptrace.h" HDRS="$HDRS wchar_limits.h" +HDRS="$HDRS cdefs.h" for hdr in ${HDRS}; do G="_USERMODE_$(echo ${hdr} | sed 's/\./_/g' | tr [a-z] [A-Z])"
CVS commit: src/sys/arch/usermode/conf
Module Name:src Committed By: reinoud Date: Mon Jan 23 12:08:31 UTC 2012 Modified Files: src/sys/arch/usermode/conf: GENERIC.common Log Message: No need to explicitly use thunkbus at this place. thunkbus == mainbus on NetBSD/usermode To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/usermode/conf/GENERIC.common 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/conf/GENERIC.common diff -u src/sys/arch/usermode/conf/GENERIC.common:1.16 src/sys/arch/usermode/conf/GENERIC.common:1.17 --- src/sys/arch/usermode/conf/GENERIC.common:1.16 Sun Jan 15 00:15:23 2012 +++ src/sys/arch/usermode/conf/GENERIC.common Mon Jan 23 12:08:31 2012 @@ -1,9 +1,9 @@ -# $NetBSD: GENERIC.common,v 1.16 2012/01/15 00:15:23 jmcneill Exp $ +# $NetBSD: GENERIC.common,v 1.17 2012/01/23 12:08:31 reinoud Exp $ include "arch/usermode/conf/std.usermode" options INCLUDE_CONFIG_FILE -#ident "GENERIC-$Revision: 1.16 $" +#ident "GENERIC-$Revision: 1.17 $" maxusers 32 makeoptions DEBUG="-O1 -g3" @@ -63,7 +63,7 @@ veth0 at mainbus? vaudio0 at mainbus? audio0 at vaudio0 -vncfb0 at thunkbus? +vncfb0 at mainbus? wsdisplay0 at vncfb? wskbd0 at vncfb? wsmouse0 at vncfb? mux 0
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Sun Jan 22 17:51:39 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: trap.c Log Message: Fix compilation issue for target amd64. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sys/arch/usermode/usermode/trap.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/trap.c diff -u src/sys/arch/usermode/usermode/trap.c:1.61 src/sys/arch/usermode/usermode/trap.c:1.62 --- src/sys/arch/usermode/usermode/trap.c:1.61 Sat Jan 21 22:09:57 2012 +++ src/sys/arch/usermode/usermode/trap.c Sun Jan 22 17:51:39 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.61 2012/01/21 22:09:57 reinoud Exp $ */ +/* $NetBSD: trap.c,v 1.62 2012/01/22 17:51:39 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.61 2012/01/21 22:09:57 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.62 2012/01/22 17:51:39 reinoud Exp $"); #include #include @@ -305,7 +305,7 @@ handle_signal(int sig, siginfo_t *info, struct lwp *l; struct pcb *pcb; vaddr_t va, sp, pc, fp; - int from_userland; + long from_userland; if (sig == SIGBUS || sig == SIGSEGV || sig == SIGILL) { if (info->si_code == SI_NOINFO)
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Sat Jan 21 22:09:57 UTC 2012 Modified Files: src/sys/arch/usermode/dev: clock.c cpu.c if_veth.c ld_thunkbus.c ttycons.c src/sys/arch/usermode/include: intr.h src/sys/arch/usermode/usermode: intr.c trap.c Log Message: Complete rewrite of the signal and spl framework for NetBSD/usermode Signals are now moved from the sigaltstack ASAP and stacked on a replacement stack for each processes. Preemption now works though could be enhanced a bit more To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/arch/usermode/dev/clock.c cvs rdiff -u -r1.68 -r1.69 src/sys/arch/usermode/dev/cpu.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/usermode/dev/if_veth.c cvs rdiff -u -r1.29 -r1.30 src/sys/arch/usermode/dev/ld_thunkbus.c cvs rdiff -u -r1.17 -r1.18 src/sys/arch/usermode/dev/ttycons.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/usermode/include/intr.h cvs rdiff -u -r1.14 -r1.15 src/sys/arch/usermode/usermode/intr.c cvs rdiff -u -r1.60 -r1.61 src/sys/arch/usermode/usermode/trap.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/dev/clock.c diff -u src/sys/arch/usermode/dev/clock.c:1.25 src/sys/arch/usermode/dev/clock.c:1.26 --- src/sys/arch/usermode/dev/clock.c:1.25 Sat Jan 14 21:42:51 2012 +++ src/sys/arch/usermode/dev/clock.c Sat Jan 21 22:09:56 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.25 2012/01/14 21:42:51 reinoud Exp $ */ +/* $NetBSD: clock.c,v 1.26 2012/01/21 22:09:56 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -29,7 +29,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.25 2012/01/14 21:42:51 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.26 2012/01/21 22:09:56 reinoud Exp $"); #include #include @@ -50,11 +50,14 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1. static int clock_match(device_t, cfdata_t, void *); static void clock_attach(device_t, device_t, void *); -static void clock_signal(int sig, siginfo_t *info, void *ctx); static unsigned int clock_getcounter(struct timecounter *); static int clock_todr_gettime(struct todr_chip_handle *, struct timeval *); +extern void setup_clock_intr(void); +void clock_intr(void *priv); + + struct clock_softc { device_t sc_dev; struct todr_chip_handle sc_todr; @@ -72,6 +75,7 @@ static struct timecounter clock_timecoun }; timer_t clock_timerid; +int clock_running = 0; CFATTACH_DECL_NEW(clock, sizeof(struct clock_softc), clock_match, clock_attach, NULL, NULL); @@ -90,7 +94,6 @@ clock_match(device_t parent, cfdata_t ma static void clock_attach(device_t parent, device_t self, void *opaque) { - static struct sigaction sa; struct clock_softc *sc = device_private(self); aprint_naive("\n"); @@ -101,21 +104,15 @@ clock_attach(device_t parent, device_t s sc->sc_todr.todr_gettime = clock_todr_gettime; todr_attach(&sc->sc_todr); - memset(&sa, 0, sizeof(sa)); - thunk_sigemptyset(&sa.sa_mask); - sa.sa_sigaction = clock_signal; - sa.sa_flags = SA_RESTART | SA_ONSTACK; - if (thunk_sigaction(SIGALRM, &sa, NULL) == -1) - panic("couldn't register SIGALRM handler : %d", - thunk_geterrno()); - clock_timerid = thunk_timer_attach(); - clock_timecounter.tc_quality = 1000; tc_init(&clock_timecounter); + + setup_clock_intr(); + clock_running = 1; } -static void +void clock_intr(void *priv) { struct clockframe cf; @@ -126,13 +123,6 @@ clock_intr(void *priv) } } -static void -clock_signal(int sig, siginfo_t *info, void *ctx) -{ - curcpu()->ci_idepth++; - spl_intr(IPL_SOFTCLOCK, clock_intr, NULL); - curcpu()->ci_idepth--; -} static unsigned int clock_getcounter(struct timecounter *tc) Index: src/sys/arch/usermode/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.68 src/sys/arch/usermode/dev/cpu.c:1.69 --- src/sys/arch/usermode/dev/cpu.c:1.68 Wed Jan 18 19:17:02 2012 +++ src/sys/arch/usermode/dev/cpu.c Sat Jan 21 22:09:56 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.68 2012/01/18 19:17:02 reinoud Exp $ */ +/* $NetBSD: cpu.c,v 1.69 2012/01/21 22:09:56 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,7 +30,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.68 2012/01/18 19:17:02 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.69 2012/01/21 22:09:56 reinoud Exp $"); #include #include @@ -244,12 +244,13 @@ cpu_switchto(lwp_t *oldlwp, lwp_t *newlw thunk_makecontext(&sc->sc_ucp, (void (*)(void)) cpu_switchto_atomic, 2, oldlwp, newlwp, NULL); - if (!oldpcb) { - thunk_setcontext(&sc->sc_ucp); - /* never returns */ - } else { + KASSERT(sc); + if (oldpcb) { thunk_swapcontext(&oldpcb->pcb_ucp, &sc->sc_ucp); /* returns here */ + } else { + thunk_setcontext(&sc->sc_ucp); + /* never returns */ } #ifdef CPU_DEBUG @@ -374,8 +375,10 @@ cpu_lwp_fork(struct lwp *l1, struct lwp /* ge
CVS commit: src/sys/arch/usermode/target/i386
Module Name:src Committed By: reinoud Date: Sat Jan 21 22:05:06 UTC 2012 Modified Files: src/sys/arch/usermode/target/i386: cpu_i386.c Log Message: Add extra kasserts to make sure we dont derive paramters from zero ucp's To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/target/i386/cpu_i386.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/target/i386/cpu_i386.c diff -u src/sys/arch/usermode/target/i386/cpu_i386.c:1.2 src/sys/arch/usermode/target/i386/cpu_i386.c:1.3 --- src/sys/arch/usermode/target/i386/cpu_i386.c:1.2 Sat Jan 14 17:42:52 2012 +++ src/sys/arch/usermode/target/i386/cpu_i386.c Sat Jan 21 22:05:06 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_i386.c,v 1.2 2012/01/14 17:42:52 reinoud Exp $ */ +/* $NetBSD: cpu_i386.c,v 1.3 2012/01/21 22:05:06 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.2 2012/01/14 17:42:52 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.3 2012/01/21 22:05:06 reinoud Exp $"); #include #include @@ -268,6 +268,7 @@ md_syscall_set_returnargs(lwp_t *l, ucon register_t md_get_pc(ucontext_t *ucp) { + KASSERT(ucp); register_t *reg = (register_t *) &ucp->uc_mcontext; return reg[14]; /* EIP */ @@ -276,6 +277,7 @@ md_get_pc(ucontext_t *ucp) register_t md_get_sp(ucontext_t *ucp) { + KASSERT(ucp); register_t *reg = (register_t *) &ucp->uc_mcontext; return reg[17]; /* ESP */ @@ -303,6 +305,7 @@ md_syscall_check_opcode(ucontext_t *ucp) void md_syscall_get_opcode(ucontext_t *ucp, uint32_t *opcode) { + KASSERT(ucp); register_t *reg = (register_t *) &ucp->uc_mcontext; // uint8_t *p8 = (uint8_t *) (reg[14]); uint16_t *p16 = (uint16_t*) (reg[14]); /* EIP */ @@ -323,6 +326,7 @@ md_syscall_get_opcode(ucontext_t *ucp, u void md_syscall_inc_pc(ucontext_t *ucp, uint32_t opcode) { + KASSERT(ucp); uint *reg = (int *) &ucp->uc_mcontext; /* advance program counter */ @@ -343,6 +347,7 @@ md_syscall_inc_pc(ucontext_t *ucp, uint3 void md_syscall_dec_pc(ucontext_t *ucp, uint32_t opcode) { + KASSERT(ucp); uint *reg = (int *) &ucp->uc_mcontext; switch (opcode) {
CVS commit: src/sys/arch/usermode
Module Name:src Committed By: reinoud Date: Sat Jan 21 19:17:33 UTC 2012 Modified Files: src/sys/arch/usermode/include: thunk.h src/sys/arch/usermode/usermode: thunk.c Log Message: Add the complement to sigemptyset(), sigfillset()! To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/arch/usermode/include/thunk.h cvs rdiff -u -r1.79 -r1.80 src/sys/arch/usermode/usermode/thunk.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/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.59 src/sys/arch/usermode/include/thunk.h:1.60 --- src/sys/arch/usermode/include/thunk.h:1.59 Wed Jan 11 12:37:50 2012 +++ src/sys/arch/usermode/include/thunk.h Sat Jan 21 19:17:33 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.h,v 1.59 2012/01/11 12:37:50 reinoud Exp $ */ +/* $NetBSD: thunk.h,v 1.60 2012/01/21 19:17:33 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -132,6 +132,7 @@ void thunk_signal(int, void (*)(int)); int thunk_sigblock(int); int thunk_sigunblock(int); int thunk_sigemptyset(sigset_t *sa_mask); +int thunk_sigfillset(sigset_t *sa_mask); void thunk_sigaddset(sigset_t *sa_mask, int sig); int thunk_sigprocmask(int how, const sigset_t * set, sigset_t *oset); int thunk_atexit(void (*function)(void)); Index: src/sys/arch/usermode/usermode/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.79 src/sys/arch/usermode/usermode/thunk.c:1.80 --- src/sys/arch/usermode/usermode/thunk.c:1.79 Sun Jan 15 10:35:08 2012 +++ src/sys/arch/usermode/usermode/thunk.c Sat Jan 21 19:17:33 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.79 2012/01/15 10:35:08 jmcneill Exp $ */ +/* $NetBSD: thunk.c,v 1.80 2012/01/21 19:17:33 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill @@ -28,7 +28,7 @@ #include #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.79 2012/01/15 10:35:08 jmcneill Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.80 2012/01/21 19:17:33 reinoud Exp $"); #endif #include @@ -605,6 +605,13 @@ thunk_sigemptyset(sigset_t *sa_mask) } +int +thunk_sigfillset(sigset_t *sa_mask) +{ + return sigfillset(sa_mask); +} + + void thunk_sigaddset(sigset_t *sa_mask, int sig) {
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Thu Jan 19 12:14:49 UTC 2012 Modified Files: src/sys/arch/usermode/include: cpu.h Log Message: My fault, forgot that cpu_need_resched() is indeed already declared as a function To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/include/cpu.h 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/include/cpu.h diff -u src/sys/arch/usermode/include/cpu.h:1.8 src/sys/arch/usermode/include/cpu.h:1.9 --- src/sys/arch/usermode/include/cpu.h:1.8 Thu Jan 19 12:10:00 2012 +++ src/sys/arch/usermode/include/cpu.h Thu Jan 19 12:14:49 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.8 2012/01/19 12:10:00 reinoud Exp $ */ +/* $NetBSD: cpu.h,v 1.9 2012/01/19 12:14:49 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -43,9 +43,10 @@ extern void userret(struct lwp *); #define cpu_proc_fork(p1, p2) +struct cpu_info; extern int astpending; #define aston(ci) (astpending++) -#define cpu_need_resched(ci, flags) { ci->ci_want_resched = 1; aston(); } +extern void cpu_need_resched(struct cpu_info *ci, int flags); struct cpu_info {
CVS commit: src/sys/arch/usermode/include
Module Name:src Committed By: reinoud Date: Thu Jan 19 12:10:00 UTC 2012 Modified Files: src/sys/arch/usermode/include: cpu.h Log Message: Add macro cpu_need_resched To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/include/cpu.h 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/include/cpu.h diff -u src/sys/arch/usermode/include/cpu.h:1.7 src/sys/arch/usermode/include/cpu.h:1.8 --- src/sys/arch/usermode/include/cpu.h:1.7 Sat Jan 14 21:23:24 2012 +++ src/sys/arch/usermode/include/cpu.h Thu Jan 19 12:10:00 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.7 2012/01/14 21:23:24 reinoud Exp $ */ +/* $NetBSD: cpu.h,v 1.8 2012/01/19 12:10:00 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -45,6 +45,7 @@ extern void userret(struct lwp *); extern int astpending; #define aston(ci) (astpending++) +#define cpu_need_resched(ci, flags) { ci->ci_want_resched = 1; aston(); } struct cpu_info {
CVS commit: src/sys/arch/usermode/dev
Module Name:src Committed By: reinoud Date: Wed Jan 18 19:17:02 UTC 2012 Modified Files: src/sys/arch/usermode/dev: cpu.c Log Message: Create an atomic switchto() that has SIGALRM and SIGIO signals blocked that might otherwise disrupt the setting of curlwp to match the lwp context. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/arch/usermode/dev/cpu.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/dev/cpu.c diff -u src/sys/arch/usermode/dev/cpu.c:1.67 src/sys/arch/usermode/dev/cpu.c:1.68 --- src/sys/arch/usermode/dev/cpu.c:1.67 Sun Jan 15 10:45:03 2012 +++ src/sys/arch/usermode/dev/cpu.c Wed Jan 18 19:17:02 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.67 2012/01/15 10:45:03 jmcneill Exp $ */ +/* $NetBSD: cpu.c,v 1.68 2012/01/18 19:17:02 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill @@ -30,7 +30,7 @@ #include "opt_hz.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.67 2012/01/15 10:45:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.68 2012/01/18 19:17:02 reinoud Exp $"); #include #include @@ -78,6 +78,9 @@ char cpu_model[48] = "virtual processor" typedef struct cpu_softc { device_t sc_dev; struct cpu_info *sc_ci; + + ucontext_t sc_ucp; + uint8_t sc_ucp_stack[PAGE_SIZE]; } cpu_softc_t; @@ -108,8 +111,16 @@ cpu_attach(device_t parent, device_t sel aprint_naive("\n"); aprint_normal("\n"); + cpu_info_primary.ci_dev = self; sc->sc_dev = self; sc->sc_ci = &cpu_info_primary; + + thunk_getcontext(&sc->sc_ucp); + sc->sc_ucp.uc_stack.ss_sp = sc->sc_ucp_stack; + sc->sc_ucp.uc_stack.ss_size = PAGE_SIZE - sizeof(register_t); + sc->sc_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK; + thunk_sigaddset(&sc->sc_ucp.uc_sigmask, SIGALRM); + thunk_sigaddset(&sc->sc_ucp.uc_sigmask, SIGIO); } void @@ -176,12 +187,34 @@ cpu_need_proftick(struct lwp *l) { } +static +void +cpu_switchto_atomic(lwp_t *oldlwp, lwp_t *newlwp) +{ + struct pcb *oldpcb = oldlwp ? lwp_getpcb(oldlwp) : NULL; + struct pcb *newpcb = lwp_getpcb(newlwp); + struct cpu_info *ci = curcpu(); + + ci->ci_stash = oldlwp; + + if (oldpcb) + oldpcb->pcb_errno = thunk_geterrno(); + + thunk_seterrno(newpcb->pcb_errno); + + curlwp = newlwp; + if (thunk_setcontext(&newpcb->pcb_ucp)) + panic("setcontext failed"); + /* not reached */ +} + lwp_t * cpu_switchto(lwp_t *oldlwp, lwp_t *newlwp, bool returning) { struct pcb *oldpcb = oldlwp ? lwp_getpcb(oldlwp) : NULL; struct pcb *newpcb = lwp_getpcb(newlwp); struct cpu_info *ci = curcpu(); + cpu_softc_t *sc = device_private(ci->ci_dev); #ifdef CPU_DEBUG thunk_printf_debug("cpu_switchto [%s,pid=%d,lid=%d] -> [%s,pid=%d,lid=%d]\n", @@ -207,19 +240,16 @@ cpu_switchto(lwp_t *oldlwp, lwp_t *newlw } #endif /* !CPU_DEBUG */ - ci->ci_stash = oldlwp; - - if (oldpcb) { - oldpcb->pcb_errno = thunk_geterrno(); - thunk_seterrno(newpcb->pcb_errno); - curlwp = newlwp; - if (thunk_swapcontext(&oldpcb->pcb_ucp, &newpcb->pcb_ucp)) - panic("swapcontext failed"); + /* create atomic switcher */ + thunk_makecontext(&sc->sc_ucp, (void (*)(void)) cpu_switchto_atomic, + 2, oldlwp, newlwp, NULL); + + if (!oldpcb) { + thunk_setcontext(&sc->sc_ucp); + /* never returns */ } else { - thunk_seterrno(newpcb->pcb_errno); - curlwp = newlwp; - if (thunk_setcontext(&newpcb->pcb_ucp)) - panic("setcontext failed"); + thunk_swapcontext(&oldpcb->pcb_ucp, &sc->sc_ucp); + /* returns here */ } #ifdef CPU_DEBUG @@ -344,7 +374,7 @@ cpu_lwp_fork(struct lwp *l1, struct lwp /* get l2 its own stack */ pcb2->pcb_ucp.uc_stack.ss_sp = pcb2->sys_stack; pcb2->pcb_ucp.uc_stack.ss_size = pcb2->sys_stack_top - pcb2->sys_stack; - pcb2->pcb_ucp.uc_flags = _UC_STACK | _UC_CPU; + pcb2->pcb_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK; pcb2->pcb_ucp.uc_link = &pcb2->pcb_userret_ucp; thunk_makecontext(&pcb2->pcb_ucp, (void (*)(void)) cpu_lwp_trampoline, @@ -382,6 +412,7 @@ cpu_startup(void) /* init lwp0 */ memset(&lwp0pcb, 0, sizeof(lwp0pcb)); thunk_getcontext(&lwp0pcb.pcb_ucp); + lwp0pcb.pcb_ucp.uc_flags = _UC_STACK | _UC_CPU | _UC_SIGMASK; uvm_lwp_setuarea(&lwp0, (vaddr_t) &lwp0pcb); memcpy(&lwp0pcb.pcb_userret_ucp, &lwp0pcb.pcb_ucp, sizeof(ucontext_t));
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Wed Jan 18 12:39:45 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: trap.c Log Message: Another step towards unification of the signal handers: separate the printing of details usefull for debugging / porting from the main code. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/arch/usermode/usermode/trap.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/trap.c diff -u src/sys/arch/usermode/usermode/trap.c:1.59 src/sys/arch/usermode/usermode/trap.c:1.60 --- src/sys/arch/usermode/usermode/trap.c:1.59 Tue Jan 17 20:50:38 2012 +++ src/sys/arch/usermode/usermode/trap.c Wed Jan 18 12:39:45 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.59 2012/01/17 20:50:38 reinoud Exp $ */ +/* $NetBSD: trap.c,v 1.60 2012/01/18 12:39:45 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.59 2012/01/17 20:50:38 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.60 2012/01/18 12:39:45 reinoud Exp $"); #include #include @@ -146,22 +146,15 @@ userret(struct lwp *l) } -/* signal handler switching to a pagefault context */ +#ifdef DEBUG +/* + * Uncomment the following if you want to receive information about what + * triggered the fault. Mainly for debugging and porting purposes + */ static void -mem_access_handler(int sig, siginfo_t *info, void *ctx) +print_mem_access_siginfo(int sig, siginfo_t *info, void *ctx, + vaddr_t pc, vaddr_t va, vaddr_t sp) { - ucontext_t *ucp = ctx; - struct lwp *l; - struct pcb *pcb; - vaddr_t va, sp, pc, fp; - int from_userland; - - assert((info->si_signo == SIGSEGV) || (info->si_signo == SIGBUS)); - - if (info->si_code == SI_NOINFO) - panic("received signal %d with no info", - info->si_signo); - #if 0 thunk_printf_debug("SIGSEGV or SIGBUS!\n"); thunk_printf_debug("\tsi_signo = %d\n", info->si_signo); @@ -181,6 +174,75 @@ mem_access_handler(int sig, siginfo_t *i thunk_printf_debug("\tsi_trap = %d\n", info->si_trap); #endif +#if 0 + printf("memaccess error, pc %p, va %p, " + "sys_stack %p, sp %p, stack top %p\n", + (void *) pc, (void *) va, + (void *) pcb->sys_stack, (void *) sp, + (void *) pcb->sys_stack_top); +#endif +} + +/* + * Uncomment the following if you want to receive information about what + * triggered the fault. Mainly for debugging and porting purposes + */ +static void +print_illegal_instruction_siginfo(int sig, siginfo_t *info, void *ctx, + vaddr_t pc, vaddr_t va, vaddr_t sp) +{ +#if 0 + thunk_printf("SIGILL!\n"); + thunk_printf("\tsi_signo = %d\n", info->si_signo); + thunk_printf("\tsi_errno = %d\n", info->si_errno); + thunk_printf("\tsi_code = %d\n", info->si_code); + if (info->si_code == ILL_ILLOPC) + thunk_printf("\t\tIllegal opcode"); + if (info->si_code == ILL_ILLOPN) + thunk_printf("\t\tIllegal operand"); + if (info->si_code == ILL_ILLADR) + thunk_printf("\t\tIllegal addressing mode"); + if (info->si_code == ILL_ILLTRP) + thunk_printf("\t\tIllegal trap"); + if (info->si_code == ILL_PRVOPC) + thunk_printf("\t\tPrivileged opcode"); + if (info->si_code == ILL_PRVREG) + thunk_printf("\t\tPrivileged register"); + if (info->si_code == ILL_COPROC) + thunk_printf("\t\tCoprocessor error"); + if (info->si_code == ILL_BADSTK) + thunk_printf("\t\tInternal stack error"); + thunk_printf("\tsi_addr = %p\n", info->si_addr); + thunk_printf("\tsi_trap = %d\n", info->si_trap); + + thunk_printf("%p : ", info->si_addr); + for (int i = 0; i < 10; i++) + thunk_printf("%02x ", *((uint8_t *) info->si_addr + i)); + thunk_printf("\n"); +#endif +} +#else /* DEBUG */ +#define print_mem_access_siginfo(s, i, c, p, v, sp) +#define print_illegal_instruction_siginfo(s, i, c, p, v, sp) +#endif /* DEBUG */ + + +/* signal handler switching to a pagefault context */ +static void +mem_access_handler(int sig, siginfo_t *info, void *ctx) +{ + ucontext_t *ucp = ctx; + struct lwp *l; + struct pcb *pcb; + vaddr_t va, sp, pc, fp; + int from_userland; + + assert((info->si_signo == SIGSEGV) || (info->si_signo == SIGBUS)); + + if (info->si_code == SI_NOINFO) + panic("received signal %d with no info", + info->si_signo); + l = curlwp; pcb = lwp_getpcb(l); @@ -194,13 +256,7 @@ mem_access_handler(int sig, siginfo_t *i /* setup for pagefault context */ sp = md_get_sp(ctx); -#if 0 - printf("memaccess error, pc %p, va %p, " - "sys_stack %p, sp %p, stack top %p\n", - (void *) pc, (void *) va, - (void *) pcb->sys_stack, (void *) sp, - (void *) pcb->sys_stack_top); -#endif + print_mem_access_siginfo(sig, info, ctx, pc, va, sp); /* if we're running on a stack of our own, use the system stack */ from_userland = 0; @@ -246,35 +302,6 @@ illegal_instruction_handler(int sig, sig int from_userland; assert(info->si_signo == SIGILL); -#if 0 - thunk_printf("SIGILL!\
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Tue Jan 17 20:50:39 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: trap.c Log Message: Do init the astpending variable. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/arch/usermode/usermode/trap.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/trap.c diff -u src/sys/arch/usermode/usermode/trap.c:1.58 src/sys/arch/usermode/usermode/trap.c:1.59 --- src/sys/arch/usermode/usermode/trap.c:1.58 Tue Jan 17 19:46:55 2012 +++ src/sys/arch/usermode/usermode/trap.c Tue Jan 17 20:50:38 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.58 2012/01/17 19:46:55 reinoud Exp $ */ +/* $NetBSD: trap.c,v 1.59 2012/01/17 20:50:38 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.58 2012/01/17 19:46:55 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.59 2012/01/17 20:50:38 reinoud Exp $"); #include #include @@ -62,7 +62,7 @@ bool pmap_fault(pmap_t pmap, vaddr_t va, static stack_t sigstk; -int astpending; +int astpending = 0; void startlwp(void *arg)
CVS commit: src/sys/arch/usermode/usermode
Module Name:src Committed By: reinoud Date: Tue Jan 17 19:46:55 UTC 2012 Modified Files: src/sys/arch/usermode/usermode: trap.c Log Message: Clean up userret/ast handling. Now called ONLY when its 100% clear that it is returning to userland. To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/arch/usermode/usermode/trap.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/trap.c diff -u src/sys/arch/usermode/usermode/trap.c:1.57 src/sys/arch/usermode/usermode/trap.c:1.58 --- src/sys/arch/usermode/usermode/trap.c:1.57 Sat Jan 14 21:45:28 2012 +++ src/sys/arch/usermode/usermode/trap.c Tue Jan 17 19:46:55 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.57 2012/01/14 21:45:28 reinoud Exp $ */ +/* $NetBSD: trap.c,v 1.58 2012/01/17 19:46:55 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.57 2012/01/14 21:45:28 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.58 2012/01/17 19:46:55 reinoud Exp $"); #include #include @@ -50,14 +50,13 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.5 /* forwards and externals */ void setup_signal_handlers(void); void stop_all_signal_handlers(void); -void userret(struct lwp *l); static void mem_access_handler(int sig, siginfo_t *info, void *ctx); static void illegal_instruction_handler(int sig, siginfo_t *info, void *ctx); extern int errno; -static void pagefault(vaddr_t pc, vaddr_t va); -static void illegal_instruction(void); +static void pagefault(vaddr_t from_userland, vaddr_t pc, vaddr_t va); +static void illegal_instruction(vaddr_t from_userland); bool pmap_fault(pmap_t pmap, vaddr_t va, vm_prot_t *atype); @@ -120,6 +119,33 @@ stop_all_signal_handlers(void) } +/* ast and userret */ +void +userret(struct lwp *l) +{ + /* invoke MI userret code */ + mi_userret(l); + + while (astpending) { + astpending = 0; + + curcpu()->ci_data.cpu_ntrap++; +#if 0 + /* profiling */ + if (l->l_pflag & LP_OWEUPC) { + l->l_pflag &= ~LP_OWEUPC; + ADDUPROF(l); + } +#endif + /* allow a forced task switch */ + if (l->l_cpu->ci_want_resched) + preempt(); + + mi_userret(l); + } +} + + /* signal handler switching to a pagefault context */ static void mem_access_handler(int sig, siginfo_t *info, void *ctx) @@ -128,6 +154,7 @@ mem_access_handler(int sig, siginfo_t *i struct lwp *l; struct pcb *pcb; vaddr_t va, sp, pc, fp; + int from_userland; assert((info->si_signo == SIGSEGV) || (info->si_signo == SIGBUS)); @@ -176,9 +203,12 @@ mem_access_handler(int sig, siginfo_t *i #endif /* if we're running on a stack of our own, use the system stack */ + from_userland = 0; if ((sp < (vaddr_t) pcb->sys_stack) || (sp > (vaddr_t) pcb->sys_stack_top)) { sp = (vaddr_t) pcb->sys_stack_top - sizeof(register_t); fp = (vaddr_t) &pcb->pcb_userret_ucp; + if (pc < kmem_user_end) + from_userland = 1; } else { /* stack grows down */ fp = sp - sizeof(ucontext_t) - sizeof(register_t); /* slack */ @@ -198,56 +228,13 @@ mem_access_handler(int sig, siginfo_t *i pcb->pcb_ucp.uc_flags = _UC_STACK | _UC_CPU; thunk_makecontext(&pcb->pcb_ucp, (void (*)(void)) pagefault, - 2, (void *) pc, (void *) va, NULL); + 3, (void *) from_userland, (void *) pc, (void *) va); /* switch to the new pagefault entry on return from signal */ memcpy(ctx, &pcb->pcb_ucp, sizeof(ucontext_t)); } -/* ast and userret */ -void -userret(struct lwp *l) -{ - struct pcb *pcb; - ucontext_t ucp, *nucp; - vaddr_t pc; - - KASSERT(l); - - /* are we going back to userland? */ - pcb = lwp_getpcb(l); - KASSERT(pcb); - - /* where are we going back to ? */ - thunk_getcontext(&ucp); - nucp = (ucontext_t *) ucp.uc_link; - pc = md_get_pc(nucp); - - if (pc >= kmem_k_start) - return; - - /* ok, going to userland, proceed! */ - if (astpending) { - astpending = 0; - - curcpu()->ci_data.cpu_ntrap++; -#if 0 - /* profiling */ - if (l->l_pflag & LP_OWEUPC) { - l->l_pflag &= ~LP_OWEUPC; - ADDUPROF(l); - } -#endif - /* allow a forced task switch */ - if (l->l_cpu->ci_want_resched) - preempt(); - } - - /* invoke MI userret code */ - mi_userret(l); -} - /* signal handler switching to a illegal instruction context */ static void illegal_instruction_handler(int sig, siginfo_t *info, void *ctx) @@ -255,7 +242,8 @@ illegal_instruction_handler(int sig, sig ucontext_t *ucp = ctx; struct lwp *l; struct pcb *pcb; - vaddr_t sp, fp; + vaddr_t sp, pc, fp; + int from_userland; assert(info->si_signo == SIGILL); #if 0 @@ -291,14 +279,21 @@ illegal_instruction_handler(int sig, sig l = curlwp; pcb = lwp_getpcb(l); + /* get PC address of faulted instruction */ + pc = md_get_pc(ctx); + /* setup for illegal_instruction context */ sp = md_get_sp(ctx); /* if we're running on a stack of our own, use the system stack */ + from_userla