From: Jeff Dike <jdike@karaya.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] Allow UML kernel to run in a separate host address space
Date: Sat, 28 Dec 2002 18:37:46 -0500 [thread overview]
Message-ID: <200212282337.SAA04085@ccure.karaya.com> (raw)
In-Reply-To: Your message of "Sat, 28 Dec 2002 12:50:53 PST." <Pine.LNX.4.44.0212281227510.25566-100000@home.transmeta.com>
torvalds@transmeta.com said:
> On Sat, 28 Dec 2002, Jeff Dike wrote:
>
> > 3 - Ability to manipulate a child's address space (i.e. mmap, munmap,
> > mprotect on an address space which is not current->mm)
>
> Well, #3 falls under "ptrace()" as far as I'm concerned,
Not exactly. UML needs to be able to fiddle an address space that has no
process in it (swapout, COWing, maybe a few other things).
UML has two relevant processes, one which runs userspace, and one which runs
the kernel and ptraces the userspace process. The kernel process creates
an address space per UML process, and makes the userspace process switch
between them during a UML context switch. So, when there's swapping going
on, pages need to be unmapped from UML processes, and thus from the
corresponding host address spaces.
> Which really means that I _think_ the right approach would be to
> literally have a "indirect-system-call-using-this-mm" system call,
> which does something like
>
> asmlinkage sys_mm_indirect(int fd, struct syscall_descriptor_block
> *user_args)
> {
> struct mm_struct *old_mm;
> struct syscall_descriptor_block args;
>
> if (memcpy_from_user(&args, user_args, sizeof(args)))
> return -EFAULT;
>
> mm = get_fd_mm(fd);
> old_mm = current->mm;
> current->mm = mm;
> switch_mm(mm);
>
> arch_do_syscall(&args);
>
> current->mm = old_mm;
> switch_mm(old_mm);
> put_mm(mm);
> }
Hmmm, I wasn't planning on going that far, but this certainly works for UML,
as long as there is also PTRACE_SWITCH_MM to make a child jump from one mm
to another.
The calls to switch_mm() are needed when the system call is going to modify
data within the address space, but not if it's going to change mappings,
correct?
If those will cause a noticable performance hit, would it be OK to special-case
syscalls which don't need it?
if(!dont_need_no_stinkin_switch_mm[args.syscall])
switch_mm(mm);
arch_do_syscall(&args);
current->mm = old_mm;
if(!dont_need_no_stinkin_switch_mm[args.syscall])
switch_mm(old_mm);
Sorry about the double negative, but it seems easiest to sparsely populate
an array with system calls that really don't want the switch_mm().
Jeff
next prev parent reply other threads:[~2002-12-28 23:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-28 15:47 [PATCH] Allow UML kernel to run in a separate host address space Jeff Dike
2002-12-28 19:34 ` Linus Torvalds
2002-12-28 20:24 ` Jeff Dike
2002-12-28 20:50 ` Linus Torvalds
2002-12-28 23:37 ` Jeff Dike [this message]
2002-12-29 4:13 ` Linus Torvalds
2002-12-29 5:12 ` Jeff Dike
2002-12-29 0:59 ` Daniel Jacobowitz
2002-12-29 4:03 ` Jeremy Fitzhardinge
2002-12-29 5:12 ` Jeff Dike
-- strict thread matches above, loose matches on Subject: below --
2002-12-17 23:24 Jeff Dike
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200212282337.SAA04085@ccure.karaya.com \
--to=jdike@karaya.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox