All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] question about syscall
@ 2009-02-07 13:15 Antonio Ricci
  2009-02-07 13:27 ` Lionel Landwerlin
  2009-02-07 17:33 ` Mulyadi Santosa
  0 siblings, 2 replies; 5+ messages in thread
From: Antonio Ricci @ 2009-02-07 13:15 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 295 bytes --]

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


Best regards,

Antonio Ricci

[-- Attachment #2: Type: text/html, Size: 449 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] question about syscall
  2009-02-07 13:15 [Qemu-devel] question about syscall Antonio Ricci
@ 2009-02-07 13:27 ` Lionel Landwerlin
  2009-02-07 17:33 ` Mulyadi Santosa
  1 sibling, 0 replies; 5+ messages in thread
From: Lionel Landwerlin @ 2009-02-07 13:27 UTC (permalink / raw)
  To: qemu-devel

Le samedi 07 février 2009 à 14:15 +0100, Antonio Ricci a écrit :
> Hi all, 
> 
> 
> i'd want to understand how Qemu handles system calls while executing
> both Linux and Windows operating system.

A syscall is usually done by generating a cpu exception. In Qemu, when a
such exception is catched by a virtual cpu, Qemu executes the related
syscall (syscall number is usually put in a register). All of this
depends on the ABI.


-- 
Lione Landwerlin                                         

O p e n W i d e                    14, rue Gaillon 75002 Paris

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] question about syscall
  2009-02-07 13:15 [Qemu-devel] question about syscall Antonio Ricci
  2009-02-07 13:27 ` Lionel Landwerlin
@ 2009-02-07 17:33 ` Mulyadi Santosa
  2009-02-09 19:23   ` Antonio Ricci
  1 sibling, 1 reply; 5+ messages in thread
From: Mulyadi Santosa @ 2009-02-07 17:33 UTC (permalink / raw)
  To: qemu-devel

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 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] question about syscall
  2009-02-07 17:33 ` Mulyadi Santosa
@ 2009-02-09 19:23   ` Antonio Ricci
  2009-02-11  6:25     ` Mulyadi Santosa
  0 siblings, 1 reply; 5+ messages in thread
From: Antonio Ricci @ 2009-02-09 19:23 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2084 bytes --]

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 <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 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.
>
>
>

[-- Attachment #2: Type: text/html, Size: 2805 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] question about syscall
  2009-02-09 19:23   ` Antonio Ricci
@ 2009-02-11  6:25     ` Mulyadi Santosa
  0 siblings, 0 replies; 5+ messages in thread
From: Mulyadi Santosa @ 2009-02-11  6:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: ricciantonio

Hi

On Tue, Feb 10, 2009 at 2:23 AM, Antonio Ricci <ricciantonio@gmail.com> wrote:
> 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?

My guess is, 0xcd is the opcode of "int" instruction. Try to check
Intel instruction manual....

regards,

Mulyadi.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-02-11  6:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-07 13:15 [Qemu-devel] question about syscall Antonio Ricci
2009-02-07 13:27 ` Lionel Landwerlin
2009-02-07 17:33 ` Mulyadi Santosa
2009-02-09 19:23   ` Antonio Ricci
2009-02-11  6:25     ` Mulyadi Santosa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.