Unverified Commit 130fff55 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Disable arch_capabilities on AMD cpu's (#813)

parent 497e86e8
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ if [[ "${ARCH,,}" != "amd64" ]]; then
  warn "your CPU architecture is ${ARCH^^} and cannot provide KVM acceleration for x64 instructions, this will cause a major loss of performance."
fi

[[ "${ARGUMENTS,,}" == "-cpu host" ]] && KVM="Y" && ARGUMENTS=""

if [[ "$KVM" != [Nn]* ]]; then

  KVM_ERR=""
@@ -67,7 +69,9 @@ if [[ "$KVM" != [Nn]* ]]; then
    CPU_FEATURES+=",-vmx"
  fi

  if grep -qw "svm" <<< "$flags"; then
  vendor=$(lscpu | awk '/Vendor ID/{print $3}')

  if [[ "$vendor" == "AuthenticAMD" ]]; then

    # AMD processor

@@ -75,6 +79,10 @@ if [[ "$KVM" != [Nn]* ]]; then
      CPU_FEATURES+=",+invtsc"
    fi

    if [[ "${BOOT_MODE,,}" == "windows"* ]]; then
      CPU_FEATURES+=",-arch_capabilities"      
    fi

  else

    # Intel processor
@@ -91,7 +99,7 @@ if [[ "$KVM" != [Nn]* ]]; then

    HV_FEATURES="hv_passthrough"

    if grep -qw "svm" <<< "$flags"; then
    if [[ "$vendor" == "AuthenticAMD" ]]; then

      # AMD processor

@@ -143,6 +151,18 @@ else

fi

if [[ "${ARGUMENTS,,}" == "-cpu host,"* ]]; then
  args="${ARGUMENTS:10}"
  if [[ "$args" != *" "* ]]; then
    ARGUMENTS=""
    if [ -z "$CPU_FLAGS" ]; then
      CPU_FLAGS="$args"
    else
      CPU_FLAGS+=",$args"
    fi
  fi
fi

if [ -z "$CPU_FLAGS" ]; then
  if [ -z "$CPU_FEATURES" ]; then
    CPU_FLAGS="$CPU_MODEL"