importantimport / hatsu

🩵 Self-hosted & Fully-automated ActivityPub Bridge for Static Sites.
https://hatsu.cli.rs
GNU Affero General Public License v3.0
107 stars 2 forks source link

Illegal CPU instruction on KVM/QEMU virtual machine #26

Closed reesericci closed 1 month ago

reesericci commented 1 month ago

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)

kwaa commented 1 month ago

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:

https://github.com/importantimport/hatsu/blob/07a07d0bbbdeaab78a25d3acdc7d5e0108af4ade/.cargo/config.toml#L13-L16

reesericci commented 1 month ago

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

kwaa commented 1 month ago

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.