usermode linux on BSD?
Antony T Curtis
antony.t.curtis at ntlworld.com
Thu Mar 11 08:11:55 PST 2004
On Wed, 2004-03-10 at 14:13, Robert Watson wrote:
> On Wed, 10 Mar 2004, David Gilbert wrote:
>
> > Has anyone made an attempt to run usermode linux on FreeBSD? Is the
> > issue-list long?
>
> There was a neat paper at BSDCon 2003 discussing running usermode FreeBSD
> on Linux, and it talked about what would be necessary to make usermode
> FreeBSD run on FreeBSD. You can find the paper off the USENIX web site,
> or perhaps via Google. I think it was a relatively small set of changes.
I have been toying with user mode BSD... and maybe even run user-mode
Linux on FreeBSD.... And one of the requirements is to be able to alter
syscalls in flight.
I think something line the following patch would help...
The concept goes something like this...
The User-mode-unix would rfork and set up ptrace,
The parent monitors the child process for syscalls...
child = rfork_thread(RFPROC|RFMEM, stack, child_func, NULL);
waitpid(child, &status, WUNTRACED);
ptrace(PT_TO_SCE, child, (caddr_t)1, 0);
for (;;) {
waitpid(child, &status, WUNTRACED);
if (WSTOPSIG(status) == SIGTRAP) {
struct reg r;
ptrace(PT_GETREGS, child, (caddr_t)&r, 0);
save_syscall= r.r_eax;
r.r_eax = SYS_getpid;
ptrace(PT_SETREGS, child, (caddr_t)&r, 0);
ptrace(PT_TO_SCX, child, (caddr_t)1, 0);
waitpid(child, &status, WUNTRACED);
ptrace(PT_GETREGS, child, (caddr_t)&r, 0);
r.r_eax = save_syscall;
simulate_syscall(&r);
ptrace(PT_SETREGS, child, (caddr_t)&r, 0);
}
ptrace(PT_TO_SCE, child, (caddr_t)1, 0);
}
User mode Linux works with a similar mechanism.
BTW, I haven't yet tested the patch below - just want some wiser, more
experienced eyes to look at it first.
--- trap.c.orig Thu Mar 11 15:22:17 2004
+++ trap.c Thu Mar 11 15:50:06 2004
@@ -936,6 +936,7 @@
cred_update_thread(td);
if (p->p_flag & P_SA)
thread_user_enter(p, td);
+ redo_syscall:
params = (caddr_t)frame.tf_esp + sizeof(int);
code = frame.tf_eax;
orig_tf_eflags = frame.tf_eflags;
@@ -1003,7 +1004,17 @@
STOPEVENT(p, S_SCE, narg);
- PTRACESTOP_SC(p, td, S_PT_SCE);
+
+ if ((p->p_flag & P_TRACED) && (p->p_stops & S_PT_SCE)) {
+ PROC_LOCK(p);
+ ptracestop(td, SIGTRAP);
+ if (!((p->p_flag & P_TRACED) &&
+ (p->p_stops & S_PT_SCE))) {
+ if ((callp->sy_narg & SYF_MPSAFE) == 0)
+ mtx_unlock(&Giant);
+ goto redo_syscall;
+ }
+ }
error = (*callp->sy_call)(td, args);
}
> Robert N M Watson FreeBSD Core Team, TrustedBSD Projects
> robert at fledge.watson.org Senior Research Scientist, McAfee Research
>
>
> >
> > Dave.
> >
> > --
> > ============================================================================
> > |David Gilbert, Independent Contractor. | Two things can only be |
> > |Mail: dave at daveg.ca | equal if and only if they |
> > |http://daveg.ca | are precisely opposite. |
> > =========================================================GLO================
> > _______________________________________________
> > freebsd-hackers at freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
> >
>
> _______________________________________________
> freebsd-current at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe at freebsd.org"
> FLAGS (\Seen))
--
Antony T Curtis BSc Unix Analyst Programmer
http://homepage.ntlworld.com/antony.t.curtis/
More information about the freebsd-current
mailing list