From: Mark Williamson Subject: Re: Hypercalls in Intel-VT Date: Wed, 31 Oct 2007 04:13:48 +0000 Message-ID: <200710310413.49383.mark.williamson@cl.cam.ac.uk> References: Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Ashish Bijlani List-Id: xen-devel@lists.xenproject.org > so is xen currently mapped in the first 64MB of every guest hvm? No, it's not. Only for PV guests, not HVM. > also,=20 > does xen use different GDT for itself or it uses some slots in the GDT of > every guest hvm? Root mode, where Xen runs has a separate GDT to non-root mode where guests= =20 run. > if you could you guide me to some pointers which mention=20 > xen's implementation for intel-vt, that will be really helpful. thanks. Basically, I think we're getting confused about how VT fundamentally works. Normal x86 has just 4 protection rings and a bunch of special purpose=20 datastructures and registers. Xen runs in ring 0, guests run in rings 1-3= =20 (usually they run their kernel in 1, userland in 3). Xen borrows some GDT= =20 slots from the guest, and also maps itself into the top of the guest addres= s=20 space. That's how PV works today. HVM works very differently from the level of the hardware up to the level o= f=20 Xen. Intel's VT adds two new modes that are orthogonal to protection rings: "roo= t=20 mode" and "non-root mode". A more descriptive way of thinking about these = is=20 to think of "root mode" as "host mode" and "non-root mode" as "guest mode".= =20 I'm going to use these terms in the explanation, but they're not the offici= al=20 terms for those modes. Xen runs in "host (root) mode" and is aware of the host processor. Guests = run=20 in "guest (non-root) mode". In guest (non-root) mode there is a separate s= et=20 of control registers that are private to the guest. The guest isn't allowe= d=20 to touch the privileged control registers of the host, because you can only= =20 do that if you run in host (root) mode. The guest doesn't know that it's=20 running in non-root mode. When Xen wants to run an HVM guest on VT it does a VMEnter. This instructs= =20 the processor to start using the guest's private registers (EIP, CR3, EAX,= =20 EBX, etc etc) so that the guest starts running as if it had control over th= e=20 hardware. The virtual memory space currently in operation is that of the=20 guest only. Xen isn't mapped in there anywhere, because Xen isn't mapped i= n=20 guest (non-root) mode. If an event happens that Xen needs to attend to, the CPU will jump back out= of=20 guest (non-root) mode and into host (root) mode where Xen is mapped. This= =20 event is a VMExit. The VMExit swaps back the register state that Xen had=20 before the guest was entered, so that Xen can continue running as it was=20 before. Xen can run and do whatever it needs to do. So, in answer to your original question: 1) Xen isn't mapped into the HVM guest because Xen is not mapped in non-roo= t=20 mode. The guest has the entire virtual address space to itself. 2) Because Xen runs in host (root) mode it uses a completely separate GDT t= o=20 the guest running in non-root mode. The switch between the two GDTs will=20 happen automatically as a consequence of mode switches via VMEnter and=20 VMExit. Does that help? Cheers, Mark > On 10/29/07, Keir Fraser wrote: > > The way that PV and HVM guests work is very different. Many of the > > tricks necessary for hosting PV guests, such as stealing address space > > for the hypervisor, are not necessary for HVM guests. > > > > -- Keir > > > > On 29/10/07 07:59, "Ashish Bijlani" wrote: > > > > if a VM's context is saved to and xen's context is loaded from VMCS upon > > every VMexit call in VT, the why is xen mapped in the first 64MB region > > of every guest VM? As far as I know, TLB will also be flushed when xen's > > context is loaded from VMCS host area. > > > > On 10/26/07, *Mark Williamson* > > > > > > wrote: > > > thanks for your answers. really appreciate your help. however, i've > > > some > > > > > > more doubts and would appreciate if you could answer the following: > > > > We're now getting a bit outside my understanding of VMX, but the other > > guys > > may know more. > > > > > how > > > does transition happen from root VMX mode to non-root VMX mode? I mean > > > > does > > > > > it load Xen's CS, DS from the GDT or does it switch GDT to load Xen's > > > > GDT? > > > > > Also, does it do TLB flush, provided Xen is mapped in the first 64MB = of > > > > the > > > > > guest VM? thanks. > > > > Well, the hardware probably does something equivalent to this. But (as > > far as > > I know) that's not how it looks to software: from the software's point = of > > view you are just doing a VMEXIT from non-root mode to root mode. Root > > mode > > effectively has a different set of control registers / datastructures to > > non-root mode. So software doesn't have to worry so much about the data > > structures involved. I don't *think* the software even has to save / > > restore > > the guest registers (unless it wants to modify them). > > > > Regarding the TLB flush, again, the hardware quite possibly does that. > > But > > I'm not aware of anything in the VMX spec that exposes this detail, so > > Intel > > could easily tag the TLB entries as root / non-root to avoid flushing on > > a > > > > VMEXIT / VMENTER. For all I know, they may do this already! > > > > Eddie, did I get that about right? :-) > > > > Cheers, > > Mark > > > > > On 10/26/07, Mark Williamson < mark.williamson@cl.cam.ac.uk > > > > > > > > > wrote: > > > > > that means dom0 doesn't make trap to ring 0 root VMX mode for > > > > > privileged operations like updating cr3? > > > > > > > > Dom0 always runs paravirtualised, it can't be an HVM domain. So it > > > > just > > > > > > uses > > > > the normal paravirtualised interface, regardless of whether VMX is > > > > available > > > > in the hardware. > > > > > > > > Cheers, > > > > Mark > > > > > > > > > On 10/26/07, Dong, Eddie < eddie.dong@intel.com> wrote: > > > > > > DOm0 works in ring 1 root VMX mode. Anyway can switch from ring > > > > > > 1 > > > > to > > > > > > > > ring 0 can be used for accessing privileged resource such as INT > > > > xx, > > > > > > or > > > > > > > > > > thru exception like I/O. > > > > > > > > > > > > But HVM works in non root VMX mode though ring=3D0, so you need= to > > > > > > > > switch > > > > > > > > > > from non root VMX mode to root VMX mode to access privileged > > > > > > resource. > > > > > > > > VM > > > > > > > > > > Exit is the only way to do this. > > > > > > > > > > > > ------------------------------ > > > > > > *From:* xen-devel-bounces@lists.xensource.com [mailto: > > > > > > xen-devel-bounces@lists.xensource.com] *On Behalf Of *Ashish > > > > Bijlani > > > > > > > > *Sent:* 2007=E5=B9=B410=E6=9C=8826=E6=97=A5 9:14 > > > > > > *To:* xen-devel@lists.xensource.com > > > > > > *Subject:* Re: [Xen-devel] Hypercalls in Intel-VT > > > > > > > > > > > > how does dom0 on intel-vt gets privileges to access the hardware > > > > > > > > devices? > > > > > > > > > > i mean does it get these privileges through superpages? > > > > > > > > > > > > On 10/25/07, Cui, Dexuan < dexuan.cui@intel.com > > > > > wrote: > > > > > > > > From: xen-devel-bounces@lists.xensource.com > > > > > > > > [mailto: xen-devel-bounces@lists.xensource.com > > > xen-devel-bounces@lists.xensource.com> ] > > > > > > > > > On Behalf Of Ashish Bijlani > > > > > > > > > > > > > > > Sent: 2007=E5=B9=B410=E6=9C=8826=E6=97=A5 8:20 > > > > > > > > To: xen-devel@lists.xensource.com > > > > > > > > Subject: Re: [Xen-devel] Hypercalls in Intel-VT > > > > > > > > > > > > > > > > > > > > > > > > could there be a way to make a transition into xen without a > > > > > > > > vmexit > > > > > > > > > > > upon executing an iret inside a guest os krnl? > > > > > > > I think we are talking about VMX guest -- the answer it NO... > > > > For > > > > > > an > > > > > > > > > > > VMX guest to return to Xen, a VMexit is a must. You can refert > > > > to > > > > > > Intel > > > > > > > > > > > Software Developer Manual 3B for details. > > > > > > > > > > > > > > -- Dexuan > > > > > > > > -- > > > > Dave: Just a question. What use is a unicyle with no seat? And no > > > > pedals! Mark: To answer a question with a question: What use is a > > > > skateboard? Dave: Skateboards have wheels. > > > > Mark: My wheel has a wheel! > > > > -- > > Dave: Just a question. What use is a unicyle with no seat? And no > > pedals! Mark: To answer a question with a question: What use is a > > skateboard? Dave: Skateboards have wheels. > > Mark: My wheel has a wheel! > > > > > > ------------------------------ > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xensource.com > > http://lists.xensource.com/xen-devel =2D-=20 Dave: Just a question. What use is a unicyle with no seat? And no pedals! Mark: To answer a question with a question: What use is a skateboard? Dave: Skateboards have wheels. Mark: My wheel has a wheel!