intel / haxm

Intel® Hardware Accelerated Execution Manager (Intel® HAXM)
BSD 3-Clause "New" or "Revised" License
3.24k stars 880 forks source link

Darwin guest kernel panics #181

Open yjftsjthsd-g opened 5 years ago

yjftsjthsd-g commented 5 years ago

TLDR: Darwin guest "panic(cpu 0 caller 0xC017DF16): timeRDTSC() calibation failed with 2 attempts"

Host Environment

Host is NetBSD 8.0, HAXM built from latest cvs checkout of /usr/pkgsrc/emulators/haxm (3bdfd1a39021df9b4dfe69e05a277e4e6456494anb2) and using wip/qemu-haxm 3.0.0 with sdl and gtk3 enabled.

Hardware is Dell Latitude E6510 with cpu0: "Intel(R) Core(TM) i7 CPU M 640 @ 2.80GHz" and 8 GB RAM.

To Reproduce

What I ran: qemu-system-x86_64 --accel hax -cdrom darwinx86-801.iso

What I expected:

What actually happened:

I reproduced this in 7 of 7 attempts. Notably, if I remove the --accel hax option, then it works. The only message from qemu is "HAX is working and emulator runs in fast virt mode."

Note: that ISO is from https://sourceforge.net/projects/darwinsource/ - https://sourceforge.net/projects/darwinsource/files/Darwin/8.0.1/darwinx86-801.iso.gz/download

HAXM log: Only line that's added to dmesg when I rerun is this:

haxm_warning: hax_alloc_pages: HAX_MEM_LOW_4G is ignored
raphaelning commented 5 years ago

Thanks for the report. Darwin is an untested/unsupported guest for HAXM. If you are familiar with its code and want to see it boot on HAXM (which will also benefit #149), maybe you can look into timeRDTSC() and figure out why the calibration fails.

yjftsjthsd-g commented 5 years ago

Unfortunately, I am not qualified; I'm a mediocre programmer and certainly no kernel dev. I completely understand if you prefer to view this as out of scope for the project.

krytarowski commented 5 years ago

I can boot this Darwin image... http://netbsd.org/~kamil/haxm/darwinx86-801-in-haxm-2019-02-18.png

But indeed this timeRDTSC() sometimes breaks on boot. It seems to be related to timing issues with apic in some guests.

krytarowski commented 5 years ago

OK, this is hardware issue. No hypervisor can precisely emulate TSC.

This bug has to be handled in the darwin guest kernel. Please close this report.

sskras commented 5 years ago

@krytarowski ,

No hypervisor can precisely emulate TSC.

Do you mean it impossible at fundmental level (such as stretching from Popek-Goldberg theorem) or that it is just very hard to implement?

Judging by the opposing comments about faking the TSC: http://theinvisiblethings.blogspot.com/2006/06/introducing-blue-pill.html ... and two "Simple Anti-VMM detection" measures mentioned by Joanna a year later: https://web.archive.org/web/20100109031241/http://bluepillproject.org/

... I guess it's possible to do so with a reasonable precission (only if complex, challenging, yes).

krytarowski commented 5 years ago

My source of this statement is from @m00nbsd.