From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LWbj8-0002Gh-CT for qemu-devel@nongnu.org; Mon, 09 Feb 2009 14:23:30 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LWbj6-0002GD-0b for qemu-devel@nongnu.org; Mon, 09 Feb 2009 14:23:28 -0500 Received: from [199.232.76.173] (port=38596 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LWbj3-0002Fw-DJ for qemu-devel@nongnu.org; Mon, 09 Feb 2009 14:23:25 -0500 Received: from fg-out-1718.google.com ([72.14.220.156]:17265) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LWbj2-0005qT-Ll for qemu-devel@nongnu.org; Mon, 09 Feb 2009 14:23:25 -0500 Received: by fg-out-1718.google.com with SMTP id e21so1187759fga.8 for ; Mon, 09 Feb 2009 11:23:22 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 9 Feb 2009 20:23:22 +0100 Message-ID: Subject: Re: [Qemu-devel] question about syscall From: Antonio Ricci Content-Type: multipart/alternative; boundary=000e0cd28956ca566c0462814da3 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --000e0cd28956ca566c0462814da3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Muladi, some times ago someone said me to do something like this: /****************************************************/ a piece of code handling interrupt in translate.c: case 0xcd: /* int N */ val = ldub_code(s->pc++); /* asia: start */ if (val == 0x80){ gen_op_handle_syscall(); break; } if (s->vm86 && s->iopl != 3) { gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base); } else { gen_interrupt(s, val, pc_start - s->cs_base, s->pc - s->cs_base); } break; /*********************************************************/ I can't understand why I have to intercept the case 0xcd. Can you explain me? I've tried to intercept sysenter (0x134) and sysexit (0x135) events, but I had no information about syscall from it. Thanks for help, Antonio 2009/2/7 Mulyadi Santosa > Hi > > On Sat, Feb 7, 2009 at 8:15 PM, Antonio Ricci > wrote: > > Hi all, > > i'd want to understand how Qemu handles system calls while executing both > > Linux and Windows operating system. I've searched on the web with no > > results. > > Do you know if there is some documentation about syscall handling in > Qemu? > > Thanks in advance for help > > I assume you ask about full system emulation. Try to check how Qemu > intercept int 80h or SYSENTER/SYSCALL instruction (if the guest OS is > Linux). Not sure what Windows does when doing system call, maybe by > executing int instruction toward certain vectors too. > > As usual, related interrupt handler will be executed (and translated). > So from Qemu point of view, it's strictly a matter of intercepting > code and translating it. It's the guest OS that does the real work on > syscall handling. > > In user space emulation only, system call is intercepted by the normal > dynamic code translation, but syscall is handled by syscall() C > function. The complication could arise if the guest OS is not the same > type as the host OS. Some "interpretations" are needed here. > > regards, > > Mulyadi. > > > --000e0cd28956ca566c0462814da3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Muladi,

some times ago someone said me to do something like this:=

/****************************************************/
a p= iece of code handling interrupt in translate.c:
case 0xcd: /* int N */ val =3D ldub_code(s->pc++);
/* asia: start */
if= (val =3D=3D 0x80){
gen_op_handle_syscall();
break; }

if (s->vm86 && s->iopl !=3D 3) {
= gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
} else {
gen_interrupt(s, val, pc_start - s->cs_base,= s->pc - s->cs_base);
}
break;

/************= *********************************************/


I can't= understand why I have to intercept the case 0xcd. Can you explain me?

I've tried to intercept sysenter (0x134) and  sysexit (0x135) = events, but I had no information about syscall from it.


Thanks = for help,


Antonio
2009/2/7 Mulyadi= Santosa <mulyadi.santosa@gmail.com>
Hi

On Sat, Feb 7, 2009 at 8:15 PM, Antonio Ricci <ricciantonio@gmail.com> wrote: > Hi all,
> i'd want to understand how Qemu handles system calls while executi= ng both
> Linux and Windows operating system. I've searched on the web with = no
> results.
> Do you know if there is some documentation about syscall handling in Q= emu?
> Thanks in advance for help

I assume you ask about full system emulation. Try to check how = Qemu
intercept int 80h or SYSENTER/SYSCALL instruction (if the guest OS is
Linux). Not sure what Windows does when doing system call, maybe by
executing int instruction toward certain vectors too.

As usual, related interrupt handler will be executed (and translated).
So from Qemu point of view, it's strictly a matter of intercepting
code and translating it. It's the guest OS that does the real work on syscall handling.

In user space emulation only, system call is intercepted by the normal
dynamic code translation, but syscall is handled by syscall() C
function. The complication could arise if the guest OS is not the same
type as the host OS. Some "interpretations" are needed here.

regards,

Mulyadi.





--000e0cd28956ca566c0462814da3--