#! /bin/sh # # microcode Update the Intel/AMD CPU microcode. # # chkconfig: 2345 95 95 # description: microcode_ctl is a program that uses the kernel # to update the microcode of Intel P6 familly (ie # PPro, PII, Celeron, PIII, Celeron2). # processname: microcode_ctl # config: /lib/firmware/intel-microcode/intel-microcode.dat # ### BEGIN INIT INFO # Provides: microcode # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Required-Start: $local_fs # Required-Stop: $local_fs # Short-Description: Update the Intel / AMD CPU microcode # Description: microcode_ctl is a program that uses the kernel # to update the microcode of Intel P6 familly (ie # PPro, PII, Celeron, PIII, Celeron2). ### END INIT INFO # source function library . /etc/rc.d/init.d/functions RETVAL=0 DATAFILE=/lib/firmware/intel-microcode/intel-microcode.dat case "$1" in start|reload|restart|force-reload) # Intel 686 and above, AMD family 16 and above vendor=`grep "^vendor_id" /proc/cpuinfo | head -n1 | awk -F ": " '{ print $2 }'` family=`grep "^cpu family" /proc/cpuinfo | head -n1 | awk -F ": " '{ print $2 }'` if [ "$vendor" = "GenuineIntel" ] && [ $family -ge 6 ]; then echo -n $"Applying Intel CPU microcode update: " elif [ "$vendor" = "AuthenticAMD" ] && [ $family -ge 16 ]; then minor=`uname -r | cut -d . -f 3 | cut -d - -f 1` if [ $minor -ge 29 ]; then echo $"Loading AMD microcode update module" /sbin/modprobe microcode action "" /bin/true touch /var/lock/subsys/microcode_ctl /sbin/rmmod microcode exit 0 fi else action "" /bin/true touch /var/lock/subsys/microcode_ctl exit 0 fi if [ ! -e $DATAFILE ]; then action "CPU microcode data file not present ($DATAFILE)" /bin/false exit 1 fi /sbin/modprobe microcode lt=0 while [ ! -c /dev/cpu/microcode ]; do lt=$[lt+1]; [ $lt -gt 5 ] && break; sleep 0.1; done /usr/sbin/microcode_ctl -Qu -f "$DATAFILE" RETVAL=$? /sbin/rmmod microcode if [ $RETVAL -eq 0 ]; then action "" /bin/true touch /var/lock/subsys/microcode_ctl else action "" /bin/false fi ;; stop) rm -f /var/lock/subsys/microcode_ctl ;; status) ;; *) echo "Usage: $0 {start|stop|reload|force-reload}" exit 1 esac exit $RETVAL