oriansj / stage0-posix-x86

GNU General Public License v3.0
8 stars 3 forks source link

Undocumented encoding of sal_eax,cl breaks Virtual Box #5

Closed rick-masters closed 7 months ago

rick-masters commented 7 months ago

Live-bootstrap (which uses this repo) freezes when run on VirtualBox.

The root cause is that VirtualBox does not support the encoding of sal_eax,cl as D3F0.

sal_eax,cl should be D3E0 which works with VirtualBox.

The D3F0 encoding can be described as D3 /6 which is not documented in the Intel documentation: http://web.archive.org/web/20190606075330/https://software.intel.com/sites/default/files/managed/a4/60/325383-sdm-vol-2abcd.pdf

SHL and SAL are two different mnemomics for the same instruction. The both should be encoded using D3 /4, which is D3 E0 for sal_eax,cl.

Also see: https://www.felixcloutier.com/x86/sal:sar:shl:shr https://stackoverflow.com/questions/8373415/difference-between-shl-and-sal-in-80x86

Also, running nasm on both sal eax, cl and shl eax, cl produces D3 E0.

Technically real processors probably work with D3 F0 but it is probably easier and definitely faster to fix this here than to get Oracle to support an undocumented opcode in VirtualBox.