From 5c39a8d8902028c15fbf6b21b7462dbfb0322146 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Fri, 14 Jan 2005 07:42:02 +0000 Subject: [PATCH] - Only enable microcode_ctl service if the CPU is capable. - Prevent microcode_ctl getting restarted multiple times on initlevel change (#141581) - Make restart/reload work properly - Do nothing if not started by root. --- microcode_ctl.init | 52 ++++++++++++++++++++++++++-------------------- microcode_ctl.spec | 25 ++++++++-------------- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/microcode_ctl.init b/microcode_ctl.init index 08414f5..b490dc7 100755 --- a/microcode_ctl.init +++ b/microcode_ctl.init @@ -9,50 +9,43 @@ # PROGRAM the executable to run # ARGUMENTS the argument we're going to call PROGRAM with +# Check that we're a priviledged user +[ `id -u` = 0 ] || exit 0 + DEVICE=/dev/cpu/microcode ARGUMENTS=-Qu RETVAL=0 PROGRAM=/sbin/microcode_ctl # Lets just be sure we have a device file... -if [ ! -e $DEVICE ]; -then +if [ ! -e $DEVICE ]; then echo $"$0: microcode device $DEVICE doesn't exist?" exit 1 -elif [ ! -c $DEVICE ]; -then +elif [ ! -c $DEVICE ]; then echo $"$0: $DEVICE not a character device?" exit 1 fi -if [ ! -e /etc/firmware/microcode.dat ]; -then +if [ ! -e /etc/firmware/microcode.dat ]; then echo $"$0: microcode datafile not present (/etc/firmware/microcode.dat)" exit 1 fi - . /etc/init.d/functions +RETVAL=0 + # perform the update function start () { RETVAL=1 # Make sure we are on an intel machine - vendor=`cat /proc/cpuinfo | \ - grep "^vendor_id" | sort -u | \ - awk -F ": " '{ print $2 }'` - if [ "$vendor" != "GenuineIntel" ]; then - return - fi + vendor=`cat /proc/cpuinfo | grep "^vendor_id" | sort -u | awk -F ": " '{ print $2 }'` + [ "$vendor" != "GenuineIntel" ] && return # Microcode wasn't available until 686's. - family=`cat /proc/cpuinfo | \ - grep "^cpu family" | sort -u | \ - awk -F ": " '{ print $2 }'` - if [ $family -lt 6 ]; then - return - fi + family=`cat /proc/cpuinfo | grep "^cpu family" | sort -u | awk -F ": " '{ print $2 }'` + [ $family -lt 6 ] && return echo -n $"Applying Intel Microcode update: " @@ -69,25 +62,38 @@ function start () RETVAL=$? # trap the most common case, errno 19 = no device - if [ $RETVAL -eq 19 ]; - then + if [ $RETVAL -eq 19 ]; then echo $"$0: kernel does not have microcode device support" fi /sbin/rmmod microcode echo + + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/microcode_ctl + return $RETVAL } +stop() +{ + rm -f /var/lock/subsys/microcode_ctl +} case "$1" in - start|reload|force-reload|restart) + start) start exit 0 ;; stop) + stop + ;; + restart|reload|force-reload) + stop + start ;; status) ;; *) - echo $"Usage: $0 {start|restart}" + echo $"Usage: $0 {start|stop|restart}" exit 1 esac +exit $? + diff --git a/microcode_ctl.spec b/microcode_ctl.spec index e58680b..99c3b36 100644 --- a/microcode_ctl.spec +++ b/microcode_ctl.spec @@ -65,35 +65,28 @@ if [ "$1" = "0" ] ; then fi %post -# Only enable on Intel machines. +# Only enable on Intel 686's and above. vendor=`cat /proc/cpuinfo | grep "^vendor_id" | sort -u | awk -F ": " '{ print $2 }'` -if [ "$vendor" != "GenuineIntel" ]; then - exit 0; -fi -# Microcode wasn't available until 686's. +[ "$vendor" != "GenuineIntel" ] && exit 0 family=`cat /proc/cpuinfo | grep "^cpu family" | sort -u | awk -F ": " '{ print $2 }'` -if [ $family -lt 6 ]; then - exit 0; -fi +[ $family -lt 6 ] && exit 0 /sbin/chkconfig --add microcode_ctl %triggerpostun -- kernel-utils -# Only enable on Intel machines. +# Only enable on Intel 686's and above. vendor=`cat /proc/cpuinfo | grep "^vendor_id" | sort -u | awk -F ": " '{ print $2 }'` -if [ "$vendor" != "GenuineIntel" ]; then - exit 0; -fi -# Microcode wasn't available until 686's. +[ "$vendor" != "GenuineIntel" ] && exit 0 family=`cat /proc/cpuinfo | grep "^cpu family" | sort -u | awk -F ": " '{ print $2 }'` -if [ $family -lt 6 ]; then - exit 0; -fi +[ $family -lt 6 ] && exit 0 /sbin/chkconfig --add microcode_ctl exit 0 %changelog * Fri Jan 14 2005 Dave Jones - Only enable microcode_ctl service if the CPU is capable. +- Prevent microcode_ctl getting restarted multiple times on initlevel change (#141581) +- Make restart/reload work properly +- Do nothing if not started by root. * Wed Jan 12 2005 Dave Jones - Adjust dev node location. (#144963)