#!/bin/bash # vars: # PROGRAM the executable to run # ARGUMENTS the argument we're going to call PROGRAM with DEVICE=/dev/cpu/microcode PROGRAM=/usr/sbin/microcode_ctl ARGUMENTS=-Qu RETVAL=0 # Lets just be sure we have a device file... if [ ! -e $DEVICE ] ; then echo "$0: microcode device $DEVICE doesn't exist" exit 1 elif [ ! -c $DEVICE ] ; then echo "$0: $DEVICE not a character device" exit 1 fi microcode_ctl_start() { echo "Applying Intel IA32 Microcode update: $PROGRAM" $PROGRAM $ARGUMENTS RETVAL=$? if [ $RETVAL -eq 3 ] ; then echo "$0: Cannot find source file \"/etc/microcode.dat\"" fi # trap the most common case, errno 19 = no device if [ $RETVAL -eq 19 ] ; then if [ -e /proc/config.gz ] ; then gzip -dc /proc/config.gz | grep -q CONFIG_MICROCODE= GREPVAL=$? elif [ -e /boot/config ] ; then grep -q CONFIG_MICROCODE= /boot/config GREPVAL=$? elif [ -e /boot/System.map ] ; then grep -q microcode /boot/System.map GREPVAL=$? elif [ -e /usr/src/linux/include/linux/autoconf.h ] ; then grep -q ^#define.*MICROCODE /usr/src/linux/include/linux/autoconf.h GREPVAL=$? fi if [ $GREPVAL -ne 0 ] ; then echo "$0: This kernel doesn't appear to have microcode device support" fi fi exit $RETVAL } case "$1" in 'start') microcode_ctl_start ;; *) echo "usage: $0 start" esac