From 3f2ca67051d4f343da46eb2ed2bc98e12c5d727b Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 16 Dec 2023 04:22:21 +0100 Subject: [PATCH] feat: Emulate SSE4.2 on ARM64 --- src/config.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/config.sh b/src/config.sh index 9725628..6a09009 100644 --- a/src/config.sh +++ b/src/config.sh @@ -3,6 +3,7 @@ set -Eeuo pipefail KVM_ERR="" KVM_OPTS="" +QEMU_CPU="qemu64,+ssse3,+sse4,+sse4.1,+sse4.2" if [ "$ARCH" == "amd64" ]; then @@ -15,23 +16,27 @@ if [ "$ARCH" == "amd64" ]; then fi if [ -n "$KVM_ERR" ]; then - error "KVM acceleration not detected $KVM_ERR, see the FAQ about this." - [[ "$DEBUG" != [Yy1]* ]] && exit 88 + error "KVM acceleration not detected $KVM_ERR, this will cause a major loss of performance." + error "See the FAQ on how to enable it, or skip this error by setting KVM=N (not recommended)." + [[ "$KVM" != [Nn]* ]] && [[ "$DEBUG" != [Yy1]* ]] && exit 88 + [ "$CPU_MODEL" == "host" ] && CPU_MODEL="$QEMU_CPU" else - if [ "$CPU_MODEL" == "host" ]; then - if ! grep -qE '^flags.* (sse4_2)' /proc/cpuinfo; then - error "Your CPU does not have the SSE4.2 instruction set, which is required by DSM." - [[ "$DEBUG" != [Yy1]* ]] && exit 89 - fi - fi - KVM_OPTS=",accel=kvm -enable-kvm -cpu $CPU_MODEL" + KVM_OPTS=",accel=kvm -enable-kvm" fi + if [ "$CPU_MODEL" == "host" ]; then + if ! grep -qE '^flags.* (sse4_2)' /proc/cpuinfo; then + info "Your CPU does not have the SSE4.2 instruction set, it will be emulated.." + CPU_MODEL="host,+ssse3,+sse4,+sse4.1,+sse4.2" + fi + fi +else + [ "$CPU_MODEL" == "host" ] && CPU_MODEL="$QEMU_CPU" fi DEF_OPTS="-nographic -nodefaults -boot strict=on -display none" RAM_OPTS=$(echo "-m $RAM_SIZE" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g') -CPU_OPTS="-smp $CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1" +CPU_OPTS="-cpu $CPU_MODEL -smp $CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1" MAC_OPTS="-machine type=q35,usb=off,dump-guest-core=off,hpet=off${KVM_OPTS}" EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4" EXTRA_OPTS="$EXTRA_OPTS -object rng-random,id=objrng0,filename=/dev/urandom"