intel / haxm

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

HAXM build fails on Linux #322

Open Ioozer opened 4 years ago

Ioozer commented 4 years ago

System information:

inxi -F
System:    Host: giahung-ms7817 Kernel: 5.8.0-1-amd64 x86_64 bits: 64 Desktop: Xfce 4.14.2 Distro: SparkyLinux 6 (Po-Tolo) 
Machine:   Type: Desktop Mobo: MSI model: H81M-P33 (MS-7817) v: 1.0 serial: <superuser/root required> 
           UEFI: American Megatrends v: 1.7 date: 07/18/2014 
CPU:       Info: Quad Core model: Intel Core i5-4460 bits: 64 type: MCP L2 cache: 6144 KiB 
           Speed: 900 MHz min/max: 800/3400 MHz Core speeds (MHz): 1: 900 2: 900 3: 900 4: 900 
Graphics:  Device-1: Intel Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics driver: i915 v: kernel 
           Display: x11 server: X.Org 1.20.8 driver: modesetting unloaded: fbdev,vesa resolution: 1680x1050~60Hz 
           OpenGL: renderer: Mesa DRI Intel HD Graphics 4600 (HSW GT2) v: 4.5 Mesa 20.1.7 
Audio:     Device-1: Intel 8 Series/C220 Series High Definition Audio driver: snd_hda_intel 
           Sound Server: ALSA v: k5.8.0-1-amd64 
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet driver: r8169 
           IF: eth0 state: up speed: 100 Mbps duplex: full mac: d8:cb:8a:37:0b:18 
Drives:    Local Storage: total: 231.03 GiB used: 20.90 GiB (9.0%) 
           ID-1: /dev/sda vendor: TeamGroup model: T253LE120G size: 111.79 GiB 
           ID-2: /dev/sdb vendor: Netac model: SSD 128GB size: 119.24 GiB 
Partition: ID-1: / size: 100.58 GiB used: 20.83 GiB (20.7%) fs: ext4 dev: /dev/sda2 
Swap:      ID-1: swap-1 type: partition size: 8.80 GiB used: 0 KiB (0.0%) dev: /dev/sda3 
Sensors:   System Temperatures: cpu: 29.8 C mobo: 27.8 C 
           Fan Speeds (RPM): N/A 
Info:      Processes: 170 Uptime: 13m Memory: 7.66 GiB used: 1.42 GiB (18.6%) Shell: Bash inxi: 3.1.06

Packages installed: linux-header-amd64 nasm to allow it to started to build

The error message:

make
make -C /lib/modules/5.8.0-1-amd64/build M=$PWD modules
make[1]: Entering directory '/usr/src/linux-headers-5.8.0-1-amd64'
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/chunk.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/cpu.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/cpuid.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/dump.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/emulate.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/ept.o
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/ept.c: In function ‘invept’:
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/ept.c:117:18: warning: this statement may fall through [-Wimplicit-fallthrough=]
  117 |             type = EPT_INVEPT_ALL_CONTEXT;
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/ept.c:120:9: note: here
  120 |         case EPT_INVEPT_ALL_CONTEXT: {
      |         ^~~~
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/ept.c:121:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
  121 |             if (ept_has_cap(ept_cap_invept_ac))
      |                ^
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/ept.c:125:9: note: here
  125 |         default: {
      |         ^~~~~~~
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/ept2.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/ept_tree.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/gpa_space.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/hax.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/ia32.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/intr_exc.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/memory.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/memslot.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/name.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/page_walker.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/ramblock.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/vcpu.o
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/vcpu.c: In function ‘is_mmio_address’:
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/vcpu.c:2143:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
 2143 |     hax_memslot *slot = memslot_find(&vcpu->vm->gpa_space, gpa >> PG_ORDER_4K);
      |     ^~~~~~~~~~~
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/vm.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/vmx.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/../../core/vtlb.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/components.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_entry.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_event.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_host_mem.o
  CC [M]  /home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_mem_alloc.o
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_mem_alloc.c: In function ‘hax_vunmap’:
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_mem_alloc.c:71:12: error: implicit declaration of function ‘iounmap’; did you mean ‘do_munmap’? [-Werror=implicit-function-declaration]
   71 |     return iounmap(addr);
      |            ^~~~~~~
      |            do_munmap
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_mem_alloc.c:71:12: warning: ‘return’ with a value, in function returning void [-Wreturn-type]
   71 |     return iounmap(addr);
      |            ^~~~~~~~~~~~~
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_mem_alloc.c:69:6: note: declared here
   69 | void hax_vunmap(void *addr, uint32_t size)
      |      ^~~~~~~~~~
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_mem_alloc.c: In function ‘hax_pa’:
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_mem_alloc.c:76:12: error: implicit declaration of function ‘virt_to_phys’; did you mean ‘virt_to_page’? [-Werror=implicit-function-declaration]
   76 |     return virt_to_phys(va);
      |            ^~~~~~~~~~~~
      |            virt_to_page
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_mem_alloc.c: In function ‘hax_alloc_pages’:
/home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_mem_alloc.c:102:17: error: implicit declaration of function ‘page_to_phys’; did you mean ‘page_to_pfn’? [-Werror=implicit-function-declaration]
  102 |     ppage->pa = page_to_phys(page);
      |                 ^~~~~~~~~~~~
      |                 page_to_pfn
cc1: some warnings being treated as errors
make[3]: *** [/usr/src/linux-headers-5.8.0-1-common/scripts/Makefile.build:286: /home/giahung/Downloads/haxm-7.6.5/platforms/linux/hax_mem_alloc.o] Error 1
make[2]: *** [/usr/src/linux-headers-5.8.0-1-common/Makefile:1768: /home/giahung/Downloads/haxm-7.6.5/platforms/linux] Error 2
make[1]: *** [/usr/src/linux-headers-5.8.0-1-common/Makefile:185: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.8.0-1-amd64'
make: *** [Makefile:29: modules] Error 2
maronz commented 4 years ago

@Ioozer: Silly me, I'd asked earlier in #321 about the Linux distribution without realising, that you are the same user that had opened both issues. So now I believe to know the answer to my question.

I've downloaded sparkylinux-2020.09-x86_64-xfce.iso, but when I run it as a live session the result of uname -r is '5.7.0-3-amd64'. BUT, after an apt update the apt install -y linux-headers-amd64 command wants to download headers for v5.8.0 (and the correct ones for linux-headers-$( uname -r ) could not be found). So this "(Semi)-Rolling" distribution can't be used in a live environment for this test (and I'm not gone waste more of my time installing such a …).

It is highly likely that in one of the newer Linux kernels (after v5.4) a change occurred, that lead to the build issue you've run into. For the moment you could use the "stable" release of SparkyLinux (with a v4.19 kernel). Or if you fancy something newer, one of the many distributions derived from Ubuntu 20.04 (that are using a v5.4 kernel). I say this because that is what I've successfully tested HAXM v7.6.5 with on 'Linux Mint 20'.

maronz commented 4 years ago

Well, I now believe that the problem might not be a big deal.

After a bit of an analysis I've just added the header file that seems to be required (i.e. 'asm/io.h') into 'hax_mem_alloc.c' (see HAXM-issue_322.patch.gz )

I've only done some fairly limited testing with a Linux kernel v5.0 (using: Mint v19.3), and v5.8 (using: Manjaro v20.1). So I think the original author @AlexAltea should take a look at it.

AlexAltea commented 4 years ago

@maronz Patch looks good to me!

BeatScherrer commented 3 years ago

patch also worked for me on arch 5.9.14. builds successfully

iadegesso commented 3 years ago

The patch doesn't work with the 7.7.0 version, but the bug is still present...