From: Keir Fraser Subject: Re: how page faults are handled in paravirtualized xenguests? Date: Sun, 09 Mar 2008 17:00:53 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0379390114==" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: weiming , Daniel Stodden Cc: xen-devel , fanghaifeng@ncic.ac.cn List-Id: xen-devel@lists.xenproject.org > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --===============0379390114== Content-type: multipart/alternative; boundary="B_3287926866_3861739" > This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3287926866_3861739 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: quoted-printable Hypercalls and syscalls are both performed using the SYSCALL instruction fo= r 64-bit guests. SYSCALL from 64-bit guest kernel triggers the hypercall path= ; SYSCALL from 64-bit guest application causes entry to 64-bit guest kernel. -- Keir On 9/3/08 16:37, "weiming" wrote: > Hi Daniel & Haifeng, >=20 > Thanks for your elaboration. > Now I'm almost clear on this problem. >=20 > Daniel, Could you please explain why "not the case for 64-bit systems." > For system calls, a regular OS will issure INT 0x80 to do system calls. I= n > Xen, this interrupt will be handled by the guest directly. In guest OS ca= n use > 0x82 interrupt to call hypercalls. >=20 > So how is x86_64 different? I'm more interested in 64-bit system because = I'll > work on it. >=20 > Thanks a lot! > Weiming >=20 >=20 >=20 > On Sun, Mar 9, 2008 at 10:33 AM, Daniel Stodden wrot= e: >> On Sun, 2008-03-09 at 10:27 +0800, =E6=88=BF=E6=B5=B7=E5=B3=B0 wrote: >>> > hello, my friend: >>> > >>> > According to my research with source code of xen, i think the process >>> > is that: >>> > >>> > first, when Guest OS is created by Xen/Domian0, it install it's IDT >>> > through "set_trap_table" hypercall. >>> > second, during Xen/GuestOS running, all interrupt/trap will result a >>> > trap into Ring0, that is the layer of Xen. >>> > for some trap, such as system-call, they will be dealt with directly >>> > through interrupt hardware. >>> > For the most of other traps, they will be dealt by xen, and then >>> > dispatched to corresponding Guest OS. >>> > >>> > in addition, there are other details to study in-depth. >>=20 >> Generally, the IDT entry may either point to xen or directly to the >> trap handler installed by the guest. >>=20 >> For system calls, it presently depends on the architecture: x86_32 has >> separate trap instructions for hypercalls and system calls, which can be >> forwarded directly. But is not the case for 64-bit systems. >>=20 >> In fault handling, it depends on the type of fault. It may be either due >> to the virtualization layer, then transparently fixed by Xen (e.g. >> instruction emulation). Or the guest may be responsible (e.g. a process >> page fault). In that case the fault will be forwarded. >>=20 >> Some faults (e.g. division by zero) are indeed never Xen's business. >> Still, you'll find the idt entry to point to xen, instead of directly to >> the ring1 kernel. =EF=BB=BFSee the use of DO_ERROR_*() in x86/traps.c. The >> reason is simply that bugs in Xen (of course, that's impossible :), but >> you never know) would not be caught otherwise. >>=20 >> So, the bottom line is that all goes through Xen, except for 32-on-32 >> bit system calls. >>=20 >> hth, >> daniel >>=20 >> -- >> Daniel Stodden >> LRR - Lehrstuhl f=C3=BCr Rechnertechnik und Rechnerorganisation >> Institut f=C3=BCr Informatik der TU M=C3=BCnchen D-85748 Garching >> http://www.lrr.in.tum.de/~stodden >> mailto:stodden@cs.tum.edu >> PGP Fingerprint: F5A4 1575 4C56 E26A 0B33 3D80 457E 82AE B0D8 735B >>=20 >>=20 >=20 >=20 >=20 > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel --B_3287926866_3861739 Content-type: text/html; charset="UTF-8" Content-transfer-encoding: quoted-printable Re: [Xen-devel] how page faults are handled in paravirtualized xengu= ests? Hyper= calls and syscalls are both performed using the SYSCALL instruction for 64-b= it guests. SYSCALL from 64-bit guest kernel triggers the hypercall path; SYS= CALL from 64-bit guest application causes entry to 64-bit guest kernel.

 -- Keir

On 9/3/08 16:37, "weiming" <zephyr.zhao@gmail.com> wrote:
Hi Daniel & Haifeng,

Thanks for your elaboration.
Now I'm almost clear on this problem.

Daniel, Could you please explain why "not the case for 64-bit systems.= "
For system calls, a regular OS will issure INT 0x80 to do system calls. In = Xen, this interrupt will be handled by the guest directly. In guest OS can u= se 0x82 interrupt to call hypercalls.

So how is x86_64 different? I'm more interested in 64-bit system because I'= ll work on it.

Thanks a lot!
Weiming



On Sun, Mar 9, 2008 at 10:33 AM, Daniel Stodden <stodden@cs.tum.edu> = wrote:
On Sun, 2008-03-09 at 10:27 +0800, =E6=88=BF=E6=B5=B7=E5=B3=B0 wrote:
> hello, my friend:
>
> According to my research with source code of xen, i think the process<= BR> > is that:
>
> first, when Guest OS is created by Xen/Domian0, it install it's IDT > through "set_trap_table" hypercall.
> second, during Xen/GuestOS running, all interrupt/trap will result a > trap into Ring0, that is the layer of Xen.
> for some trap, such as system-call, they will be dealt with directly > through interrupt hardware.
> For the most of other traps, they will be dealt by xen, and then
> dispatched to corresponding Guest OS.
>
> in addition, there are other details to study in-depth.

Generally, the IDT entry may either point to xen or directly to the
trap handler installed by the guest.

For system calls, it presently depends on the architecture: x86_32 has
separate trap instructions for hypercalls and system calls, which can be forwarded directly. But is not the case for 64-bit systems.

In fault handling, it depends on the type of fault. It may be either due to the virtualization layer, then transparently fixed by Xen (e.g.
instruction emulation). Or the guest may be responsible (e.g. a process
page fault). In that case the fault will be forwarded.

Some faults (e.g. division by zero) are indeed never Xen's business.
Still, you'll find the idt entry to point to xen, instead of directly to the ring1 kernel. =EF=BB=BFSee the use of DO_ERROR_*() in x86/traps.c. The
reason is simply that bugs in Xen (of course, that's impossible :), but
you never know) would not be caught otherwise.

So, the bottom line is that all goes through Xen, except for 32-on-32
bit system calls.

hth,
daniel

--
Daniel Stodden
LRR     -      Lehrstuhl f&uum= l;r Rechnertechnik und Rechnerorganisation
Institut für Informatik der TU München     &n= bsp;       D-85748 Garching
http://www.lrr.in.tum.de/~stodd= en <http://www.lrr.in.t= um.de/%7Estodden>         &nb= sp;mailto:stodden@cs.tum.edu
PGP Fingerprint: F5A4 1575 4C56 E26A 0B33  3D80 457E 82AE B0D8 735B




____________________= ___________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/x= en-devel

--B_3287926866_3861739-- --===============0379390114== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============0379390114==--