From: Blaisorblade <blaisorblade@yahoo.it>
To: user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] Question about system call trap in UML
Date: Wed, 7 Mar 2007 00:52:55 +0100 [thread overview]
Message-ID: <200703070052.56034.blaisorblade@yahoo.it> (raw)
In-Reply-To: <3aab51dc0703061532g4b5e763co8927b5abeabcc2d@mail.gmail.com>
On Wednesday 07 March 2007 00:32, Haifeng He wrote:
> Hi,
>
> I am beginner of UML. I have a question about how the system call
> trap happens in UML in skas0 mode. Suppose a user application
> within UML initialed a system call. How does UML track the
> system call and is the host OS the one to actually handle the system
> call?
The base tool is ptrace (see man 2 ptrace).
Basically ptrace(PTRACE_SYSCALL) (also used by the strace tool - look at man
strace) is used to intercept the syscalls to the host. Registers are modified
so that getpid() is executed (it is a syscall doing no harm), and the syscall
is then executed by the UML kernel.
arch/um/os-Linux/skas/process.c contains the core code: the main loop in
userspace() runs for the process lifetime, once for each process.
handle_trap() does the above trick with getpid and ptrace and calls
handle_syscall(), which performs the actual syscall.
Assume local_using_sysemu == 0; that does not change the core, it's just a
faster API to tell the host "don't execute this syscall" than changing the
syscall to getpid().
No difference about this exists in SKAS0 and SKAS3, that I remember (I think
it's also valid for TT mode, with a few differences).
> Particularly, I found a file: arch/um/sys-i386/stub.S. Is the file used
> for handling syscalls in user application?
No. That code is injected in all user applications within UML.
When we need that the user process does a certain syscall, we change EIP to
point to that piece of code, write the syscalls to perform and their
arguments in a fixed location, and resume the process with ptrace().
The 'virtual RAM' of a UML instance is represented by a file, which is mapped
with MAP_SHARED.
So, memory mappings for userspace processes are installed by making that stub
call mmap() with certain arguments decided by UML; munmap() and mprotect()
are also used.
Since demand paging is used, when mmap is called no mapping is installed; when
a page is allocated and page tables are modified, we can call mmap() to
install the mapping.
> Can somebody explain the
> process to me?
The above is just a little start, to let you explore more and ask more
specific questions.
Bye
--
Inform me of my mistakes, so I can add them to my list!
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale!
http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
prev parent reply other threads:[~2007-03-06 23:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-06 23:32 [uml-devel] Question about system call trap in UML Haifeng He
2007-03-06 23:52 ` Blaisorblade [this message]
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=200703070052.56034.blaisorblade@yahoo.it \
--to=blaisorblade@yahoo.it \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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