intel / haxm

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

QEMU/HAXM does not work with -cpu max #38

Open mifritscher opened 6 years ago

mifritscher commented 6 years ago

While a qemu-system-x86_64.exe -cpu max works (until the BIOS boot loop, which is fine), a qemu-system-x86_64.exe -cpu max -accel hax hangs way before. The guest doesn't even initialize the GPU.

Output: C:\temp\preseed_installation\qemu_windows_x64>qemu-system-x86_64.exe -cpu max -accel hax HAX is working and emulator runs in fast virt mode. VCPU shutdown request VCPU shutdown request ... VCPU shutdown request

until I kill it.

Using qemu 2.11 and haxm 7.1.0 on a Windows 64 bit machine on a Intel Core i7 6820 HQ machine.

raphaelning commented 6 years ago

Thanks for the bug report. According to QEMU -cpu help:

x86 max Enables all features supported by the accelerator in the current host

So does this replace the old -cpu host switch supported by KVM? HAXM currently ignores the vCPU model specified by the QEMU user (i.e. anything that goes after -cpu) and uses its own model, which only supports a basic feature set. For example, like you pointed out in #43, AES-NI is missing from the HAXM vCPU model.

This is indeed a problem we need to address. The plan is to provide new APIs for vCPU model customization, so HAXM guest can be launched with -cpu Haswell, -cpu max, etc.

mifritscher commented 6 years ago

Yes, your summary is right. My main point was that haxm should not crash / hang using -cpu max.

Yes, the vCPU is static for now. So my question is: Why makes specifing -cpu max any difference? Does qemu expect some other behavior then?

necros2k7 commented 6 years ago

+1 I confirm issue, thou -cpu Haswell, SandyBridge is OK on my i7 system

Tasiobg commented 6 years ago

Same issue here Host windows 10 QEMU 3.0.0 CPU i7-5820K

krytarowski commented 5 years ago

It would be handy to support custom vCPU model with aid of PINTOOL, especially future one (can we please open-source Pin? we need NetBSD port).

raphaelning commented 5 years ago

@krytarowski I'm not familiar with Pin, which is developed by a separate team at Intel. How can it help implement custom vCPU model support?

krytarowski commented 5 years ago

https://software.intel.com/en-us/articles/intel-software-development-emulator SDE can emulate custom Intel CPUs... not sure if it's really combinable with HAXM (it might be difficult as pin is userland and hax kernel).

raphaelning commented 5 years ago

I see what you mean now. I don't think we really need to emulate a custom CPU to test this feature. A simple test that dumps the CPUID feature flags as seen by the guest for both -accel hax and -accel tcg should be good enough.

JesseRMeyer commented 4 years ago

Continues with QEMU 4.2 on Win10 x64.

Astrosynthesist commented 4 years ago

This has been a problem for me for weeks and I could not determine why I cannot get cpu models to work under HAXM. I do not see any documentation about this limitation with HAXM so I am relieved to finally find this issue. Additionally, though I can pass multiple vCPUs to a Windows guest OS, it only ever uses one vCPU (even though device manager lists multiple CPUs). I have tried many permutations of smp settings of cores, threads, dies, and sockets, and none seem to make any difference to Windows' behaviour in this regard. It makes me wonder if that is being ignored as well, though I am too inexperienced to do anything beyond speculate on this. QEMU 4.2 HAXM 7.6.1 Windows 10 1909 x64

wcwang commented 4 years ago

@Astrosynthesist, thanks for your report. We have studied this issue and considered that it should be a regression of HAXM v7.6.1. You may try to uninstall HAXM and download HAXM v7.5.6.

@nevilad, after reverting the patch 5c4b6cb merged in PR #204, the issue of no multiple vCPUs could be resolved. Could you help to reproduce this issue by following approach after launching an AVD (Android Virtual Device) of Android R image? Thanks.

> adb shell
$ cat /proc/cpuinfo
nevilad commented 4 years ago

@Astrosynthesist Windows 10 1909 x64 is your host OS?

@wcwang

after reverting the patch 5c4b6cb merged in PR #204, the issue of no multiple vCPUs could be resolved

  • Are you sure about patch number, did you mean CR8 support patch?
  • You tested hax with multiple vcpus and it did not work only on darwin?
  • When I upload new changes, they are compiled in jenkins. Is it possible to download the built binary? If yes, I can try to test it without setting up a darwin build machine.

Could you help to reproduce this issue by following approach after launching an AVD (Android Virtual Device) of Android R image? Thanks.

This issue is with Android Studio too?

wcwang commented 4 years ago

Are you sure about patch number, did you mean CR8 support patch?

Yes, the patch number is exact. It added support for CPUID 4. According to SDM, the CPUID leaf 04H also reports data that can be used to derive the topology of processor cores in a physical package. Software can query the raw data reported by executing CPUID with EAX=04H and ECX=0.

You tested hax with multiple vcpus and it did not work only on darwin?

I tested HAXM with 4 vCPUs but it only showed 1 vCPU. The issue also exists on Windows and can be reproduced on the latest Android R image.

When I upload new changes, they are compiled in jenkins. Is it possible to download the built binary? If yes, I can try to test it without setting up a darwin build machine.

No, it is impossible to download the built binary from Jenkins. But you can try the latest release on Windows and launch an AVD in Android Studio. You don't need to set up a Darwin build machine. Thanks.

nevilad commented 4 years ago

This issue was solved by https://github.com/intel/haxm/pull/272, but it was not merged, because it does not run multicore guests on Mac. The source of the problem was cr8 support patch. I'm not able to debug it, because I need to make modifications to the code and test it. I don't have a darwin build and test machine. I have some ideas what can be wrong with cr8 support on Mac, I can make these changes, jenkins can build these, but somebody must test it on Mac.

wcwang commented 4 years ago

Thanks for your reply. I understand the current situation of the CR8 support problem. Sorry for not having time to collaborate with you to debug the macOS issue because of the performance issue of HAXM.

We would like to spend time to resolve the CR8 support related issues in future, including both macOS and Windows. If there is some times before the next release, we will work with you to fix the current issues and merge related pull requests. Thanks for understanding.

ethindp commented 3 years ago

I'm suffering this issue as well. I'm writing a custom OS that requires RDRAND and it appears that HAXM is not exposing RDRAND to my guest, which requires it because it uses it to initialize RNGs and such.