From: "Kamble, Nitin A" Subject: Re: [PATCH][RFC] Emulating real mode with x86_emulate Date: Mon, 2 Apr 2007 16:52:25 -0700 Message-ID: <1175557945.3593.16.camel@lnitindesktop.sc.intel.com> References: <4607074E.1030807@us.ibm.com> <1175203075.27076.17.camel@lnitindesktop.sc.intel.com> <460C4AAE.5020707@us.ibm.com> <1175212362.27076.32.camel@lnitindesktop.sc.intel.com> <460C55BD.5050202@us.ibm.com> <1175216381.27076.39.camel@lnitindesktop.sc.intel.com> <1175221214.27076.43.camel@lnitindesktop.sc.intel.com> <460C8207.8000604@us.ibm.com> <1175280781.32115.13.camel@lnitindesktop.sc.intel.com> <460D5E34.2080803@us.ibm.com> <1175288913.32115.20.camel@lnitindesktop.sc.intel.com> <1175289886.32115.26.camel@lnitindesktop.sc.intel.com> <460D8B1B.6020308@us.ibm.com> <1175539525.9276.5.camel@lnitindesktop.sc.intel.com> <4611514D.4090404@us.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1236507992==" Return-path: Content-class: urn:content-classes:message In-Reply-To: <4611514D.4090404@us.ibm.com> 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: Anthony Liguori Cc: "Yu, Wilfred" , xen-devel@lists.xensource.com, Keir Fraser , "Nakajima, Jun" List-Id: xen-devel@lists.xenproject.org --===============1236507992== Content-Type: multipart/signed; boundary="=-ulCrGXctB1HDKJEc7EyP"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-class: urn:content-classes:message --=-ulCrGXctB1HDKJEc7EyP Content-Type: multipart/alternative; boundary="=-7YFftK5h5sRA2Q11Ape4" --=-7YFftK5h5sRA2Q11Ape4 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Mon, 2007-04-02 at 11:54 -0700, Anthony Liguori wrote: > Before calling x86_emulate, we use hvm_store_cpu_guest_regs() to copy > the guest state into a regs struct (which happens to be the vcpu's reg > struct). This reads directly from the VMCS via vmread() so it should > be > okay. I don't think a vmx_world_save/restore is actually needed > although perhaps I'm missing something? It may be ok to use hvm_store_cpu_guest_regs() for 1st few instructions, but I think it is not complete enough for emulator use. >=20 > > Also the function arch_vmx_do_resume() is called at the time of > vcpu > > schedule, so it is not right to call the vmx_do_emulate() from > there. >=20 > Right, the idea was to have x86_emulate() be called instead of > vmentry(). I thought that being in the set_cr0 path would ensure that > we go through do_resume() again. Is this assumption incorrect? Yes, This assumption is not right. arch_vmx_do_resume() is assigned to schedule tail, so that the vcpu context is saved/restored when another vcpu is scheduled on the physical cpu. >=20 > I didn't want to just stick it in the set_cr0 path because we ought to > be able to pull the emulation loop into common code for SVM/VT and the > do_resume path seems like the only place where there's common place to > hook right now. I thought the emulator will be needed only for VMX; why is it needed for SVM? Also calling the x86_emulate() to emulate multiple instructions from vmx_do_resume() will block the physical cpu from other vcpus.=20 I think we discussed the approach of using the non-root context for for emulator within the Xen. Or did I misunderstanding it? > Regards, >=20 > Anthony Liguori >=20 Thanks & Regards, Nitin=20 Open Source Technology Center, Intel Corporation. ------------------------------------------------------------------------- The mind is like a parachute; it works much better when it's open.=20 --=-7YFftK5h5sRA2Q11Ape4 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Re: [PATCH][RFC] Emulating real mode with x86_emulate On Mon, 2007-04-02 at 11:54 -0700, Anthony Liguori wrote:
Before calling x86_emulate, we= use hvm_store_cpu_guest_regs() to copy
the guest state into a regs st= ruct (which happens to be the vcpu's reg
struct).  This reads dire= ctly from the VMCS via vmread() so it should be
okay.  I don't think a vm= x_world_save/restore is actually needed
although perhaps I'm missing s= omething?
It may be ok to use hvm_store_cpu_= guest_regs() for 1st few instructions, but I think it is not = complete enough for emulator use.

> Also the function  a= rch_vmx_do_resume() is called at the time of vcpu
> schedule, so it is not ri= ght to call the  vmx_do_emulate() from there.

Right, the idea was to have x8= 6_emulate() be called instead of
vmentry().  I thought tha= t being in the set_cr0 path would ensure that
we go through do_resume() agai= n.  Is this assumption incorrect?
Yes, This assumption is not right. arch_vmx_do_resume() is assigned to schedule tail, so that t= he vcpu context is saved/restored when another vcpu is scheduled on the phy= sical cpu.

I didn't want to just stick it= in the set_cr0 path because we ought to
be able to pull the emulation = loop into common code for SVM/VT and the
do_resume path seems like the = only place where there's common place to
hook right now.<= BR>
I thought the emulator will be needed only for VMX; why is it needed for SV= M?

Also calling the x86_emulate() to emulate multiple instructions from vmx_do= _resume() will block the physical cpu from other vcpus.
I think we discussed the approach of using the non-root context for for emu= lator within the Xen. Or did I misunderstanding it?

Regards,

Anthony Liguori<= BR>

Thanks & Regards,
Nitin
Open Source Technology Center, Int= el Corporation.
----------------------------------= ---------------------------------------
The mind is like a parachute; it w= orks much better when it's open.=20
--=-7YFftK5h5sRA2Q11Ape4-- --=-ulCrGXctB1HDKJEc7EyP Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBGEZc1Z1sfU7kTCR8RAv61AJ92R7GKEx1byaMQ/H+WiJ7Cfnar8wCcCWo/ AcXOiImkt2rcr1wRrIoKHfw= =fb4f -----END PGP SIGNATURE----- --=-ulCrGXctB1HDKJEc7EyP-- --===============1236507992== 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 --===============1236507992==--