Blame SOURCES/kvm-setup

9bac43
#! /bin/bash
9bac43
9bac43
kvm_setup_powerpc () {
9bac43
    if grep '^platform[[:space:]]*:[[:space:]]*PowerNV' /proc/cpuinfo > /dev/null; then
9bac43
	# PowerNV platform, which is KVM HV capable
9bac43
9bac43
	if [ -z "$SUBCORES" ]; then
9bac43
	    SUBCORES=1
9bac43
	fi
9bac43
9bac43
	# Step 1. Load the KVM HVmodule
9bac43
	if ! modprobe -b kvm_hv; then
9bac43
	    return
9bac43
	fi
9bac43
9bac43
	# On POWER8 a host core can only run threads of a single
9bac43
	# guest, meaning that SMT must be disabled on the host in
9bac43
	# order to run KVM guests. (Also applieds to POWER7, but we
9bac43
	# don't support that).
9bac43
	#
9bac43
	# POWER9 doesn't have this limitation (though it will for hash
9bac43
	# guests on radix host when that's implemented).  So, only set
9bac43
	# up subcores and disable SMT for POWER*.
9bac43
	if grep '^cpu[[:space:]]*:[[:space:]]*POWER8' /proc/cpuinfo > /dev/null; then
9bac43
	    # Step 2. Configure subcore mode
9bac43
	    /usr/sbin/ppc64_cpu --subcores-per-core=$SUBCORES
9bac43
9bac43
	    # Step 3. Disable SMT (multithreading)
9bac43
	    /usr/sbin/ppc64_cpu --smt=off
9bac43
	fi
9bac43
    fi
9bac43
}
9bac43
9bac43
case $(uname -m) in
9bac43
    ppc64|ppc64le)
9bac43
	kvm_setup_powerpc
9bac43
	;;
9bac43
esac
9bac43
9bac43
exit 0