2005-01-08 08:23:02 +00:00
|
|
|
#!/bin/bash
|
2006-10-13 03:26:56 +00:00
|
|
|
# chkconfig: 2345 0 99
|
2005-01-08 08:23:02 +00:00
|
|
|
# description: script to apply cpu microcode
|
|
|
|
|
2005-01-14 07:42:02 +00:00
|
|
|
# Check that we're a priviledged user
|
|
|
|
[ `id -u` = 0 ] || exit 0
|
|
|
|
|
2008-02-22 20:01:12 +00:00
|
|
|
DATAFILE=/lib/firmware/microcode.dat
|
2005-01-08 08:23:02 +00:00
|
|
|
|
|
|
|
. /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
|
|
|
|
|
2009-12-04 17:32:38 +00:00
|
|
|
# Intel 686 and above, AMD family 16 and above
|
|
|
|
vendor=`grep "^vendor_id" /proc/cpuinfo | head -n1 | awk -F ": " '{ print $2 }'`
|
2005-11-15 04:06:33 +00:00
|
|
|
family=`grep "^cpu family" /proc/cpuinfo | head -n1 | awk -F ": " '{ print $2 }'`
|
2009-12-04 17:32:38 +00:00
|
|
|
|
|
|
|
if [ "$vendor" = "GenuineIntel" ] && [ $family -ge 6 ]; then
|
|
|
|
echo -n $"Applying Intel CPU microcode update: "
|
|
|
|
elif [ "$vendor" = "AuthenticAMD" ] && [ $family -ge 16 ]; then
|
|
|
|
echo $"Loading AMD microcode update module"
|
|
|
|
/sbin/modprobe microcode
|
|
|
|
return
|
|
|
|
else
|
|
|
|
return
|
|
|
|
fi
|
2005-01-08 08:23:02 +00:00
|
|
|
|
2005-11-15 04:06:33 +00:00
|
|
|
if [ ! -e $DATAFILE ]; then
|
|
|
|
echo $"$0: CPU microcode data file not present ($DATAFILE)"
|
2005-08-17 17:50:45 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-01-11 17:31:34 +00:00
|
|
|
/sbin/modprobe microcode
|
2005-01-25 09:37:26 +00:00
|
|
|
|
|
|
|
lt=0
|
2009-09-11 18:36:23 +00:00
|
|
|
while [ ! -c /dev/cpu/microcode ]; do
|
2005-01-25 09:37:26 +00:00
|
|
|
lt=$[lt+1];
|
|
|
|
[ $lt -gt 5 ] && break;
|
2009-06-25 23:35:01 +00:00
|
|
|
sleep 0.1;
|
2005-01-25 09:37:26 +00:00
|
|
|
done
|
2005-01-11 18:12:24 +00:00
|
|
|
|
2009-09-11 18:36:23 +00:00
|
|
|
/sbin/microcode_ctl -Qu
|
2005-01-08 08:23:02 +00:00
|
|
|
RETVAL=$?
|
|
|
|
|
2005-01-11 18:40:32 +00:00
|
|
|
/sbin/rmmod microcode
|
2005-01-14 07:42:02 +00:00
|
|
|
|
|
|
|
return $RETVAL
|
2005-01-08 08:23:02 +00:00
|
|
|
}
|
|
|
|
|
2005-01-14 07:42:02 +00:00
|
|
|
stop()
|
|
|
|
{
|
2009-12-04 17:32:38 +00:00
|
|
|
return
|
2005-01-14 07:42:02 +00:00
|
|
|
}
|
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)
|
2009-09-11 18:36:23 +00:00
|
|
|
stop
|
2005-01-14 07:42:02 +00:00
|
|
|
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 $?
|
|
|
|
|