Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Illegal CPU instruction on KVM/QEMU virtual machine #26

Closed
reesericci opened this issue May 10, 2024 · 4 comments
Closed

Illegal CPU instruction on KVM/QEMU virtual machine #26

reesericci opened this issue May 10, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@reesericci
Copy link
Contributor

reesericci commented May 10, 2024

When attempting to use hatsu on my proxmox (kvm/qemu) Ubuntu Server 23.04 virtual machine, I get a Illegal instruction (core dumped) message:

> ./hatsu
Illegal instruction (core dumped)

When building from source (cargo run) I get a more detailed output, but my googling was still unable to resolve:

error: failed to run custom build command for `lock_api v0.4.11`

Caused by:
  process didn't exit successfully: `/srv/hatsu/source/target/debug/build/lock_api-0d32e3dda6c485f1/build-script-build` (signal: 4, SIGILL: illegal instruction)
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `serde v1.0.197`

Caused by:
  process didn't exit successfully: `/srv/hatsu/source/target/debug/build/serde-abaa8383ea65ce48/build-script-build` (signal: 4, SIGILL: illegal instruction)
error: failed to run custom build command for `libc v0.2.153`

Caused by:
  process didn't exit successfully: `/srv/hatsu/source/target/debug/build/libc-8256b98642d05c26/build-script-build` (signal: 4, SIGILL: illegal instruction)
error: failed to run custom build command for `proc-macro2 v1.0.79`

Caused by:
  process didn't exit successfully: `/srv/hatsu/source/target/debug/build/proc-macro2-b4c1ea2d5336d3ae/build-script-build` (signal: 4, SIGILL: illegal instruction)

This is running the latest Rust using the zipped binaries and ./install.sh.

lscpu output
Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         39 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  4
  On-line CPU(s) list:   0-3
Vendor ID:               GenuineIntel
  Model name:            Intel(R) Atom(TM) CPU C3758 @ 2.20GHz
    CPU family:          6
    Model:               95
    Thread(s) per core:  1
    Core(s) per socket:  4
    Socket(s):           1
    Stepping:            1
    BogoMIPS:            4400.00
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rd
                         tscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq pni pclmulqdq vmx ssse3 cx16 pdcm sse4_1 sse4_
                         2 x2apic movbe popcnt tsc_deadline_timer aes xsave rdrand hypervisor lahf_lm 3dnowprefetch cpuid_fault ssbd ibrs ibpb stibp t
                         pr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust smep erms mpx rdseed smap clflushopt sha_ni xsaveopt xsavec x
                         getbv1 xsaves arat umip md_clear arch_capabilities
Virtualization features: 
  Virtualization:        VT-x
  Hypervisor vendor:     KVM
  Virtualization type:   full
Caches (sum of all):     
  L1d:                   128 KiB (4 instances)
  L1i:                   128 KiB (4 instances)
  L2:                    16 MiB (4 instances)
  L3:                    16 MiB (1 instance)
NUMA:                    
  NUMA node(s):          1
  NUMA node0 CPU(s):     0-3
Vulnerabilities:         
  Gather data sampling:  Not affected
  Itlb multihit:         Not affected
  L1tf:                  Not affected
  Mds:                   Not affected
  Meltdown:              Not affected
  Mmio stale data:       Not affected
  Retbleed:              Not affected
  Spec rstack overflow:  Not affected
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
  Srbds:                 Not affected
  Tsx async abort:       Not affected
  

CPU mode was set to host, but I received the same issue when using the default CPU option (either kvm64 or qemu64 I can't remember, but I tried both)

@reesericci reesericci changed the title Hatsu borked on KVM/QEMU Ubuntu 23.04 virtual machine Hatsu illegal CPU instruction on KVM/QEMU Ubuntu 23.04 virtual machine May 10, 2024
@reesericci reesericci changed the title Hatsu illegal CPU instruction on KVM/QEMU Ubuntu 23.04 virtual machine Hatsu illegal CPU instruction on KVM/QEMU virtual machine May 10, 2024
@reesericci reesericci changed the title Hatsu illegal CPU instruction on KVM/QEMU virtual machine Illegal CPU instruction on KVM/QEMU virtual machine May 10, 2024
@kwaa
Copy link
Member

kwaa commented May 10, 2024

Hatsu is using the x86-64-v3 target architecture for optimal performance, and it looks like your Atom processor may not be supported. As a solution, you can either try changing to x86-64-v2 or removing it in your local build:

hatsu/.cargo/config.toml

Lines 13 to 16 in 07a07d0

# x86_64-v3 (Intel Haswell / AMD Excavator and above)
# https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels
[target.'cfg(target_arch = "x86_64")']
rustflags = ["-C", "target-cpu=x86-64-v3"]

@kwaa kwaa added the bug Something isn't working label May 10, 2024
@reesericci
Copy link
Contributor Author

Changing it to v2 worked for me! I think this should be documented somewhere for older CPUs.

@kwaa
Copy link
Member

kwaa commented May 10, 2024

I think this should be documented somewhere for older CPUs.

Yes, I will update the documentation later.

If more users experience this problem, I may consider offering an x86-64-v2 build.

@kwaa
Copy link
Member

kwaa commented Oct 17, 2024

Related: #76

It no longer has the x86-64-v3 build flag by default.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants