Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Feb 2018 20:08:34 +0100
From:      "Fabian Freyer" <fabian.freyer@physik.tu-berlin.de>
To:        "Peter Grehan" <grehan@freebsd.org>
Cc:        freebsd-virtualization@freebsd.org
Subject:   Re: VMX exit reason=33 and general userboot.so questions
Message-ID:  <5C51D1DD-BD11-40BD-B2EB-185524774D2C@physik.tu-berlin.de>
In-Reply-To: <0142d062-ca13-6917-bb06-28cac727680b@freebsd.org>
References:  <BA57D57B-08B0-45DB-B200-C5C31994AAC7@physik.tu-berlin.de> <0142d062-ca13-6917-bb06-28cac727680b@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 3156 and 4880).

--=_MailMate_0DBF650D-C28C-4718-B4DF-7F6F40194E35_=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Peter,

thanks for your response!

On 21 Feb 2018, at 17:59, Peter Grehan wrote:
>  >        exit_reason     33
>
>  From the Intel SDM, vol 3B Appendix C, this error is "VM-entry failure=
 due to invalid guest state".

Yes, I=E2=80=99m currently going through SDM, vol 3B, section 26.3, and

>  These errors can be difficult to debug given the large amount of guest=
 state involved :(

definitely accurately describes the experience. That said, I=E2=80=99m go=
ing through each check and trying to see what is going wrong.

>  However, looking at the state from your dump:
>
>  > tr desc[0]      0x0000000000000000/0x00000000/0x00000000
>
>  I believe you will have to set this. Here's the comment and relevant c=
ode fragment from grub2-bhyve grub-core/kern/emu/bhyve_hostif.c:grub_emu_=
bhyve_boot32()
>
>   /*
>    * XXX TR is pointing to null selector even though we set the
>    * TSS segment to be usable with a base address and limit of 0.
>    * Has to be 8b or vmenter will fail
>    */
>   desc_access =3D 0x0000008b;
>   assert(vm_set_desc(bhyve_ctx, 0, VM_REG_GUEST_TR, 0x1000, 0x67,
>                      desc_access) =3D=3D 0);
>
>  grub2-bhyve has been able to load/boot multiboot images, so I suspect =
the register settings in grub_emu_bhyve_boot32() are a good place to star=
t from.

Thanks. I=E2=80=99ve tried setting all registers (especially) the segment=
 registers as grub2-bhyve does, but I still don=E2=80=99t seem to be able=
 to boot correctly. Fixing the TR descriptor didn=E2=80=99t do it.

Here=E2=80=99s a list of the descriptors I set up:

ds desc[0]      0x0000000000000000/0xffffffff/0x00000093
es desc[0]      0x0000000000000000/0xffffffff/0x00000093
fs desc[0]      0x0000000000000000/0xffffffff/0x00000093
gs desc[0]      0x0000000000000000/0xffffffff/0x00000093
ss desc[0]      0x0000000000000000/0xffffffff/0x00000093
cs desc[0]      0x0000000000000000/0xffffffff/0x0000009b
tr desc[0]      0x0000000000001000/0x00000067/0x0000008b
ldtr desc[0]    0x0000000000000000/0x0000ffff/0x00010082


gdtr points to a default gdt as set up in grub2-bhyve:

static uint16_t bhyve_gdt[] =3D {
  0x0000, 0x0000, 0x0000, 0x0000,       /* Null */
  0x0000, 0x0000, 0x0000, 0x0000,       /* Null #2 */
  0xffff, 0x0000, 0x9a00, 0x00cf,       /* code */
  0xffff, 0x0000, 0x9200, 0x00cf,       /* data */
  0x0000, 0x0000, 0x8900, 0x0080        /* tss */
};

gdtr[0]         0x0000000000100161/0x00000027
idtr[0]         0x0000000000000000/0x00000000

The rest is set up as by grub2-bhyve:
cs[0]           0x0008
ds[0]           0x0010
es[0]           0x0010
fs[0]           0x0010
gs[0]           0x0010
ss[0]           0x0010
tr[0]           0x0000
ldtr[0]         0x0000

I=E2=80=99m assuming entry_ctls[0] =3D 0x91fb is the VM-entry control, bu=
t is it the value described by Table 24-7 of the SDM Volume 3B? Is this c=
onstant for the first entry after running bhyveload?  That is, when writi=
ng some compliance checks against section 26.3.1, can I just hardcode tha=
t value?

I=E2=80=99m starting to dig through the bhyverun code, but I=E2=80=99m st=
ill pretty new to VMX stuff, so I am ending up with more questions than a=
nswers.

Fabian

--=_MailMate_0DBF650D-C28C-4718-B4DF-7F6F40194E35_=
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename=signature.asc
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQJWBAEBCgBAFiEEX6JoxdmEemcFacQZmealkcs85+YFAlqNw7IiHGZhYmlhbi5m
cmV5ZXJAcGh5c2lrLnR1LWJlcmxpbi5kZQAKCRCZ5qWRyzzn5nLyEACKDA1R/Qg4
ZZyfec5crhrizkog4Wr9T0tTHE1Jc2+wmUoHzKzFoMZdRfF0bWF2GucU70Fbi/Gk
0Hjxqwvoh2U475Nn4x+5Yt6mgHe4xDd38Dwj9pA91r93tAQONGZP4FxtsXGfDrYV
+1Tkif8gIN21rJc1Ga4tj+bD/1ruja5hDdrUK39JJgSM0ZDX1iiM6eba7QH6dl0B
B2Hle707WrZhUUB0odnQvO4oysqL57Hdxjw2LCswumH+CvRGvcz7TRrCsjPZY/3B
n4OUnVdFtAP/ak01jEcjaiLQbyLB3/ARN6RIvNEqn4Ujxh+DEMMbIUTxgYI7zZHx
8z3nOMYtcunXEnfrPH2eLFbQ0vnvwIy5YhWXP93IN6qgufQJFkzvp8fnsseTFcBo
PPqtm/6TDDt9YoaFsHk4+OPk4Hurgj5OXIUIA13qc4pW7X4Yj9eOp9yfJFhBTqC6
L/gdBT5E3OImqBOYLbeo3PjggpUZXii61x1VDSaJ0R1bLgg4ILL5nOH4iaMDYYkb
R4H1azqM3/3d8LlE2gMLoFDjTxBhND1MOwvDVFgPTzLWNRqm0yv2YXqmfsFCAAI7
lVFTlFCriZMyIZSAjDGSMGnaY+BGeZIBNKfnOvN2CQgElo7xBAejOoKHcGGd3IDi
REmfGasV8fZ49Vw3OK5CL/1UsFwlvmRIPA==
=wbGw
-----END PGP SIGNATURE-----

--=_MailMate_0DBF650D-C28C-4718-B4DF-7F6F40194E35_=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5C51D1DD-BD11-40BD-B2EB-185524774D2C>