All of lore.kernel.org
 help / color / mirror / Atom feed
* System Calls in x86_32
@ 2008-06-17 22:56 Ahmed Moneeb Azab
  2008-06-19 13:42 ` Grzegorz Miłoś
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmed Moneeb Azab @ 2008-06-17 22:56 UTC (permalink / raw)
  To: xen-devel

Hi All,

I need help understanding how the direct system calls work on the x86_32 
architecture.

What I understand is that when a guest is initialized, it uses the 
hypercall do_set_trap_table to initialize the trap table which calls 
init_int80_direct_trap for system call interrupts. The later updates the 
int80_desc structure in the VCPU of the guest so that the new address 
gets the callback directly.

What I do not understand is where does the call back occur. Int80 is not 
handles in the x86_32's entry.S?!!!! So, where is the code that issues 
the callback?

Why is architecture is different on x86_64. The entry.S contains an 
entry for int80. Does this affect the performance of the guests?

Ahmed

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

* Re: System Calls in x86_32
  2008-06-17 22:56 System Calls in x86_32 Ahmed Moneeb Azab
@ 2008-06-19 13:42 ` Grzegorz Miłoś
  2008-06-19 14:42   ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Grzegorz Miłoś @ 2008-06-19 13:42 UTC (permalink / raw)
  To: Ahmed Moneeb Azab; +Cc: xen-devel

>  I need help understanding how the direct system calls work on the x86_32
> architecture.
>
>  What I understand is that when a guest is initialized, it uses the
> hypercall do_set_trap_table to initialize the trap table which calls
> init_int80_direct_trap for system call interrupts.

Correct.

>  The later updates the
> int80_desc structure in the VCPU of the guest so that the new address gets
> the callback directly.

Yes, on 32 bit arch (arch/x86/x86_32/traps.c). The definition is
different on 64 bit arch (arch/x86/x86_64/traps.c), int80_desc is not
used.

>  What I do not understand is where does the call back occur. Int80 is not
> handles in the x86_32's entry.S?!!!! So, where is the code that issues the
> callback?

Here is an explanation how things work on 32 bit arch:

During boot Interrupt Descriptor Table (IDT) is constructed and loaded
onto the CPU(s) (construct_percpu_idt() in arch/x86/smpboot.c). This
table contains description of various interrupt vectors.

When do_set_trap_table() hypercall is issued, vector 0x80 is reset to
point to the guest provided interrupt handler (by
init_int80_direct_trap() in include/asm-x86/processor.h).

Thanks to that, whenever INT 0x80 instruction is executed, the guest
provided handler will be invoked directly, without involving Xen.
That's how the callback happens: CPU encounters INT 0x80 intruction,
looks up the relevant, guest provided, interrupt handler in the IDT
and invokes it.

>
>  Why is architecture is different on x86_64. The entry.S contains an entry
> for int80. Does this affect the performance of the guests?

64 bit architecture is more complicated, because Xen will intercept
interrupt 0x80 (it therefore loads it's own interrupt handler into
IDT, specifically int80_direct_trap defined in
arch/x86/x86_64/entry.S). The reason why Xen wants to intercept the
interrupts is that we could be executing 32bit guest, or an HVM guest
etc (look through the definition of int80_direct_trap for details).

Hope this helps
Gr(z)egor(z)

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

* Re: System Calls in x86_32
  2008-06-19 13:42 ` Grzegorz Miłoś
@ 2008-06-19 14:42   ` Jan Beulich
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2008-06-19 14:42 UTC (permalink / raw)
  To: Grzegorz Milos, Ahmed Moneeb Azab; +Cc: xen-devel

>The reason why Xen wants to intercept the
>interrupts is that we could be executing 32bit guest, or an HVM guest
>etc (look through the definition of int80_direct_trap for details).

Not exactly. First of all, HVM guests are don't-care here - they handle
int 0x80 with their own IDT. 64-bit guests must go through Xen because
guest and kernel run in ring 3, and the kernel mode flag must be set
correctly, which can only be donein Xen. 32-bit guest must go through
Xen because x84-64 doesn't know 32-bit gates (i.e. the target code
selector of any gate must be a 64-bit code segment).

Jan

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

end of thread, other threads:[~2008-06-19 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-17 22:56 System Calls in x86_32 Ahmed Moneeb Azab
2008-06-19 13:42 ` Grzegorz Miłoś
2008-06-19 14:42   ` Jan Beulich

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.