From: "Kamble, Nitin A" Subject: Re: [PATCH][RFC] Emulating real mode with x86_emulate Date: Fri, 30 Mar 2007 14:24:46 -0700 Message-ID: <1175289886.32115.26.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> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0537366310==" Return-path: Content-class: urn:content-classes:message In-Reply-To: <1175288913.32115.20.camel@lnitindesktop.sc.intel.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 --===============0537366310== Content-Type: multipart/signed; boundary="=-+ytRGW3NwQ8RM8HFFBcy"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-class: urn:content-classes:message --=-+ytRGW3NwQ8RM8HFFBcy Content-Type: multipart/alternative; boundary="=-uhYQ2q3+QGooJRTeY3Nk" --=-uhYQ2q3+QGooJRTeY3Nk Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Anthony, eip of 0x0 is the right address. Because the trampoline_Start code is relocated to address 0. /* Relocate real-mode trampoline to 0x0. */ " mov $trampoline_start,%esi \n" " xor %edi,%edi \n" " mov $trampoline_end,%ecx \n" " sub %esi,%ecx \n" " rep movsb \n" Still there is no progress in the emulation. The guest is dying with triple-fault just like before. 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 On Fri, 2007-03-30 at 14:08 -0700, Nitin A Kamble wrote: > Hi Anthony, >=20 > On Fri, 2007-03-30 at 14:00 -0500, Anthony Liguori wrote:=20 >=20 > > /* Enter real mode, reload all segment registers and IDT. */ > > " ljmp $0x8,$0x0 \n" > > "trampoline_start: .code16 \n" > > " mov %eax,%cr0 \n" > >=20 > > That change was pretty recent so unless it was reverted it should Just = Work. > >=20 > > Regards, > >=20 > > Anthony Liguori >=20 > Now I see cr0 is updated after returning from main.=20 > I enabled the debug log in the xen code now. >=20 > (XEN) HVM2: Creating MP > tables ... =20 > (XEN) HVM2: Loading Cirrus > VGABIOS ... =20 > (XEN) HVM2: Loading > ACPI ... =20 > (XEN) HVM2: Loading VMXAssist ... > deadbeef =20 > (XEN) HVM2: > foo =20 > (XEN) > hvmop_emulate_realmode = =20 > (XEN) guest requests real mode > emulation =20 > (XEN) foo > 221 =20 > (XEN) HVM2: Invoking > ROMBIOS ... =20 > (XEN) vmx_vmexit_handler called. eip =3D > 0x0 =20 > (XEN) vmx_cr_access called > eip=3D0x0 =20 > (XEN) mov_to_cr 0 called > eip=3D0x0 =20 > (XEN) vmx_set_cr0 called > eip=3D0x0 =20 > (XEN) Transfering -- control to x86_emulate eip > 0x0 =20 > (XEN) hvm.c:446:d2 Triple fault on VCPU0 - invoking HVM system > reset. =20 >=20 > It shows cr0 is getting modified. But the eip is still 0x0.=20 >=20 >=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 --=-uhYQ2q3+QGooJRTeY3Nk Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Anthony,
eip of 0x0 is the right address.

Because the trampoline_Start code is relocated to address 0.

    /* Relocate real-mode trampoline to 0x0. */
    "    mov  $trampoline_start,%es= i \n"
    "    xor  %edi,%edi  =             \n"=
    "    mov  $trampoline_end,%ecx&= nbsp;  \n"
    "    sub  %esi,%ecx  =             \n"=
    "    rep  movsb  &nbs= p;            &= nbsp;  \n"

Still there is no progress in the emulation. The guest is dying with triple= -fault just like before.

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

On Fri, 2007-03-30 at 14:08 -0700, Nitin A Kamble wrote:
Hi Anthony,

On Fri, 2007-03-30 at 14:00 -0500, Anthony Ligu= ori wrote:
    /* Enter real mode, reload all segment register=
s and IDT. */
    "    ljmp $0x8,$0x0              \n"<=
/FONT>
    "trampoline_start: .code16       \n"<=
/FONT>
    "    mov  %eax,%cr0              \n"<=
/FONT>

That change was pretty recent so unless it was reve=
rted it should Just Work.

Regards,

Anthony Liguori
Now I see cr0 is updated after returning from m= ain.
   I enabled the debug log in the xen= code now.

(XEN) HVM2: Creating MP tables ...  &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;     
(XEN) HVM2: Loading Cirrus VGABIOS ... &nb= sp;            =             &nb= sp;            =   
(XEN) HVM2: Loading ACPI ...   &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;          
(XEN) HVM2: Loading VMXAssist ... deadbeef = ;            &n= bsp;            = ;            =
(XEN) HVM2: foo     &n= bsp;            = ;            &n= bsp;            = ;            &n= bsp;        
(XEN) hvmop_emulate_realmode   &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;          
(XEN) guest requests real mode emulation &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;
(XEN) foo 221     &nbs= p;            &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;          
(XEN) HVM2: Invoking ROMBIOS ...  &nb= sp;            =             &nb= sp;            =        
(XEN) vmx_vmexit_handler called. eip =3D 0x0&nb= sp;            =             &nb= sp;           
(XEN) vmx_cr_access called eip=3D0x0  = ;            &n= bsp;            = ;            &n= bsp;     
(XEN) mov_to_cr 0 called eip=3D0x0  &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;       
(XEN) vmx_set_cr0 called eip=3D0x0  &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;       
(XEN) Transfering -- control to x86_emulate eip= 0x0            = ;            &n= bsp;   
(XEN) hvm.c:446:d2 Triple fault on VCPU0 - invo= king HVM system reset. 

It shows cr0 is getting modified. But the eip i= s still 0x0.


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

--=-uhYQ2q3+QGooJRTeY3Nk-- --=-+ytRGW3NwQ8RM8HFFBcy 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) iD8DBQBGDYAeZ1sfU7kTCR8RAsgmAJ9bi/bZ65Pq4Fde0m3PA3AgeNvbzACfVEZX lq5bEUfokynNs1IXxlnrAq8= =BTF+ -----END PGP SIGNATURE----- --=-+ytRGW3NwQ8RM8HFFBcy-- --===============0537366310== 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 --===============0537366310==--