Date: Mon, 1 Apr 1996 13:40:34 -0500 (EST) From: Andrew Gallatin <gallatin@isds.Duke.EDU> To: Colman Reilly <creilly@maths.tcd.ie> Cc: hackers@freebsd.org Subject: Re: Linux emulator and Mathematica Message-ID: <199604011840.NAA19545@davinci.isds.duke.edu> In-Reply-To: <9604011003.aa25264@salmon.maths.tcd.ie> References: <9604011003.aa25264@salmon.maths.tcd.ie>
next in thread | previous in thread | raw e-mail | index | archive | help
Colman Reilly writes: > The network. To make the network run, you have to emulate the SIOCHWADDR call > from linux. This returns the ethernet address of your machine. > > Um. Horrible code segment follows. > > Insert into linux_ioctl, in linux_ioctl.c, inside the first switch. > > case 0x8927: > hwaddr[0]=0x00; > hwaddr[1]=0x00; > hwaddr[2]=0xc0; > hwaddr[3]=0x27; > hwaddr[4]=0xe5; > hwaddr[5]=0x66; > return copyout((caddr_t)hwaddr, (caddr_t)args->arg,6); > > > The 6 numbers need to be your ethernet address in hex. I'm sorry, this is a > disgusting hack, but I still haven't had time to fix it > > Colman Thanks... Actually, I consider being able to hardcode the HW address a feature ;-) We have a university wide site-license for mathematica, but I still hate having to deal with the key givers.. Anyway, I've slapped the above into linux_ioctl, in linux_ioctl.c (btw, what type is hwaddr supposed to be?, I've got it declared as int hwaddr[6]) I've appended what I've put into the 2.1R linux_dummy.c. Its taken nearly verbatum from the the 3/23 snap. At this point, I've attemped to use both a network & standalone license. I'd really rather get the standalone license working.. The network license sort of works, but strange goblety-gook is printed to the screen, it looses connections to the server, and mathclients are spawned which go into a cpu-bound infinate loop. The standalone (which is what I really want) stops on the error: General::codespace: Code space corrupted a ktrace shows it reading from a file (/usr/local/math/Install/Preload/msgthin.m), closing it then dying: 213 mathexe RET read 2833/0xb11 213 mathexe CALL close(3) 213 mathexe RET close 0 213 mathexe CALL write(1,4149248,1) 213 mathexe GIO fd 1 wrote 1 bytes " " 213 mathexe RET write 1 213 mathexe CALL write(1,4149248,41) 213 mathexe GIO fd 1 wrote 41 bytes "General::codespace: Code space corrupted." 213 mathexe RET write 41/0x29 213 mathexe CALL write(1,4149248,1) 213 mathexe GIO fd 1 wrote 1 bytes " " 213 mathexe RET write 1 213 mathexe PSIG SIGBUS SIG_DFL Where do I go from here? Thanks, Drew ############################################################################## # Andrew Gallatin, Computer Project Manager # # Institute of Statistics and Decision Sciences # # Box 90251, Duke University, Durham, NC 27708-0251 # ############################################################################## #include <sys/signal.h> #include <sys/sysctl.h> #include <sys/proc.h> #include <sys/user.h> #include <machine/proc.h> #include <machine/cpu.h> #include <machine/reg.h> #include <machine/psl.h> struct linux_sigcontext { int sc_gs; int sc_fs; int sc_es; int sc_ds; int sc_edi; int sc_esi; int sc_ebp; int sc_esp; int sc_ebx; int sc_edx; int sc_ecx; int sc_eax; int sc_trapno; int sc_err; int sc_eip; int sc_cs; int sc_eflags; int sc_esp_at_signal; int sc_ss; int sc_387; int sc_mask; int sc_cr2; }; struct linux_sigreturn_args { struct linux_sigcontext * scp; }; /* * System call to cleanup state after a signal * has been taken. Reset signal mask and * stack state from context left by sendsig (above). * Return to previous pc and psl as specified by * context left by sendsig. Check carefully to * make sure that the user has not modified the * psl to gain improper privileges or to cause * a machine fault. */ int linux_sigreturn(struct proc *p, struct linux_sigreturn_args *args, int *retval) /* struct proc *p; struct linux_sigreturn_args *args; int *retval; */ { struct linux_sigcontext *scp, context; register int *regs; int eflags; regs = p->p_md.md_regs; #ifdef DEBUG printf("Linux-emul(%d): linux_sigreturn(%8x)\n", p->p_pid, args->scp); #endif /* * The trampoline code hands us the context. * It is unsafe to keep track of it ourselves, in the event that a * program jumps out of a signal handler. */ scp = args->scp; if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0) return (EFAULT); /* * Check for security violations. */ #define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) eflags = context.sc_eflags; /* * XXX do allow users to change the privileged flag PSL_RF. The * cpu sets PSL_RF in tf_eflags for faults. Debuggers should * sometimes set it there too. tf_eflags is kept in the signal * context during signal handling and there is no other place * to remember it, so the PSL_RF bit may be corrupted by the * signal handler without us knowing. Corruption of the PSL_RF * bit at worst causes one more or one less debugger trap, so * allowing it is fairly harmless. */ if (!EFLAGS_SECURE(eflags & ~PSL_RF, regs[tEFLAGS] & ~PSL_RF)) { return(EINVAL); } /* * Don't allow users to load a valid privileged %cs. Let the * hardware check for invalid selectors, excess privilege in * other selectors, invalid %eip's and invalid %esp's. */ #define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) if (!CS_SECURE(context.sc_cs)) { trapsignal(p, SIGBUS, T_PROTFLT); return(EINVAL); } p->p_sigacts->ps_sigstk.ss_flags &= ~SA_ONSTACK; p->p_sigmask = context.sc_mask &~ (sigmask(SIGKILL)|sigmask(SIGCONT)|sigmask(SIGSTOP)); /* * Restore signal context. */ /* %fs and %gs were restored by the trampoline. */ regs[tES] = context.sc_es; regs[tDS] = context.sc_ds; regs[tEDI] = context.sc_edi; regs[tESI] = context.sc_esi; regs[tEBP] = context.sc_ebp; regs[tEBX] = context.sc_ebx; regs[tEDX] = context.sc_edx; regs[tECX] = context.sc_ecx; regs[tEAX] = context.sc_eax; regs[tEIP] = context.sc_eip; regs[tCS] = context.sc_cs; regs[tEFLAGS] = eflags; regs[tESP] = context.sc_esp_at_signal; regs[tSS] = context.sc_ss; return (EJUSTRETURN); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604011840.NAA19545>