Blame SOURCES/kvm-setup

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