2005-01-08 08:23:02 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# chkconfig: - 0 99
|
|
|
|
# description: script to apply cpu microcode
|
|
|
|
|
|
|
|
# vars:
|
|
|
|
#
|
|
|
|
# START distribution specific way of kicking programs
|
|
|
|
# END distribution specific way of checking return status
|
|
|
|
# PROGRAM the executable to run
|
|
|
|
# ARGUMENTS the argument we're going to call PROGRAM with
|
|
|
|
|
2005-01-14 07:42:02 +00:00
|
|
|
# Check that we're a priviledged user
|
|
|
|
[ `id -u` = 0 ] || exit 0
|
|
|
|
|
2005-01-13 04:23:43 +00:00
|
|
|
DEVICE=/dev/cpu/microcode
|
2005-01-08 08:23:02 +00:00
|
|
|
ARGUMENTS=-Qu
|
|
|
|
RETVAL=0
|
|
|
|
PROGRAM=/sbin/microcode_ctl
|
|
|
|
|
|
|
|
. /etc/init.d/functions
|
|
|
|
|
2005-01-14 07:42:02 +00:00
|
|
|
RETVAL=0
|
|
|
|
|
2005-01-08 08:23:02 +00:00
|
|
|
# perform the update
|
|
|
|
function start ()
|
|
|
|
{
|
|
|
|
RETVAL=1
|
|
|
|
# Make sure we are on an intel machine
|
2005-01-14 07:42:02 +00:00
|
|
|
vendor=`cat /proc/cpuinfo | grep "^vendor_id" | sort -u | awk -F ": " '{ print $2 }'`
|
|
|
|
[ "$vendor" != "GenuineIntel" ] && return
|
2005-01-08 08:23:02 +00:00
|
|
|
|
|
|
|
# Microcode wasn't available until 686's.
|
2005-01-14 07:42:02 +00:00
|
|
|
family=`cat /proc/cpuinfo | grep "^cpu family" | sort -u | awk -F ": " '{ print $2 }'`
|
|
|
|
[ $family -lt 6 ] && return
|
2005-01-08 08:23:02 +00:00
|
|
|
|
|
|
|
echo -n $"Applying Intel Microcode update: "
|
|
|
|
|
2005-08-17 17:50:45 +00:00
|
|
|
if [ ! -e /etc/firmware/microcode.dat ]; then
|
|
|
|
echo $"$0: microcode datafile not present (/etc/firmware/microcode.dat)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-01-11 17:31:34 +00:00
|
|
|
/sbin/modprobe microcode
|
2005-01-25 09:37:26 +00:00
|
|
|
|
|
|
|
lt=0
|
2005-08-17 17:50:45 +00:00
|
|
|
while [ ! -c $DEVICE ]; do
|
2005-01-25 09:37:26 +00:00
|
|
|
lt=$[lt+1];
|
|
|
|
[ $lt -gt 5 ] && break;
|
|
|
|
sleep 1;
|
|
|
|
done
|
2005-01-11 18:12:24 +00:00
|
|
|
|
2005-08-17 17:50:45 +00:00
|
|
|
# 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
|
|
|
|
|
2005-01-08 08:23:02 +00:00
|
|
|
daemon $PROGRAM $ARGUMENTS
|
|
|
|
RETVAL=$?
|
|
|
|
|
|
|
|
# trap the most common case, errno 19 = no device
|
2005-01-14 07:42:02 +00:00
|
|
|
if [ $RETVAL -eq 19 ]; then
|
2005-01-08 08:23:02 +00:00
|
|
|
echo $"$0: kernel does not have microcode device support"
|
|
|
|
fi
|
2005-01-11 18:40:32 +00:00
|
|
|
/sbin/rmmod microcode
|
2005-01-08 08:23:02 +00:00
|
|
|
echo
|
2005-01-14 07:42:02 +00:00
|
|
|
|
|
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/microcode_ctl
|
|
|
|
return $RETVAL
|
2005-01-08 08:23:02 +00:00
|
|
|
}
|
|
|
|
|
2005-01-14 07:42:02 +00:00
|
|
|
stop()
|
|
|
|
{
|
|
|
|
rm -f /var/lock/subsys/microcode_ctl
|
|
|
|
}
|
2005-01-08 08:23:02 +00:00
|
|
|
|
|
|
|
case "$1" in
|
2005-01-14 07:42:02 +00:00
|
|
|
start)
|
2005-01-08 08:23:02 +00:00
|
|
|
start
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
stop)
|
2005-01-14 07:42:02 +00:00
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart|reload|force-reload)
|
|
|
|
stop
|
|
|
|
start
|
2005-01-08 08:23:02 +00:00
|
|
|
;;
|
|
|
|
status)
|
|
|
|
;;
|
|
|
|
*)
|
2005-01-14 07:42:02 +00:00
|
|
|
echo $"Usage: $0 {start|stop|restart}"
|
2005-01-08 08:23:02 +00:00
|
|
|
exit 1
|
|
|
|
esac
|
2005-01-14 07:42:02 +00:00
|
|
|
exit $?
|
|
|
|
|