ntvdmx64 icon indicating copy to clipboard operation
ntvdmx64 copied to clipboard

Why not using Hyper to enable fast 16bit switch?

Open vaualbus opened this issue 4 years ago • 1 comments

This is not an issue per Se but a suggestion on what this thing can become. I read all your docs and I'm wondering why we not use an hypervisor "driver" now that Windows have documented that to be able to use the CPU fast 16bit emulation. According to Wiki, V86 is not support, as you said, in long mode but can be enable by an hypervisor. I cite wiki "The addition of VT-x has added back the ability to run virtual 8086 mode from x86-64 long mode, but it has to be done by transitioning the (physical) processor to VMX root mode and launching a logical (virtual) processor itself running in virtual 8086 mode. Westmere and later Intel processors usually[14] can start the virtual processor directly in real mode using the "unrestricted guest" feature (which itself requires Extended Page Tables); this method removes the need to resort to the nested virtual 8086 mode simply to run the legacy BIOS for booting." Probably this is not possible to do in windows but if so it would a cool work around. All the other problems would still remain of course

Alberto

vaualbus avatar Oct 01 '21 12:10 vaualbus

I think last time I looked at Hyper-V, its API didn't support the specialities we require for DOS emulation, that's why I adapted HAXM driver for VT-x emulation instead (which of course uses unrestricted guest mode, it wouldn't work otherwise). Some of the stuff that needed to be patched into the Hypervisor can be found in the Commit history of the HAXM-driver, if you are interested: https://github.com/leecher1337/haxm/commits/ntvdm

Unfortunately, using VT-x isn't such a huge performance gain as I had expected, HAXM build still cannot beat V86 NTVDM. It works quite nicely for commandline tools, but as soon as you are requiring VGA graphics, the performance (obviously) sucks compared to the emulated CPU due to the amount of switches necessary. But you are invited to experiment with the HAXM build and make performance improvements to it. Maybe they can be ported to Hyper-V some day, when Hyper-V gets more flexible.

For VT-x implementation details, have a look at: https://github.com/leecher1337/ntvdmx64/tree/master/ntvdmpatch/experimental/haxm/v86/haxm/i386

leecher1337 avatar Oct 01 '21 15:10 leecher1337