From 1fad0c77e53eb42d3dc7d85bb01788109bb70944 Mon Sep 17 00:00:00 2001 From: Anton Arapov Date: Tue, 23 Mar 2010 09:26:52 +0000 Subject: [PATCH] - Make microcode_ctl event driven (Bill Nottingham ) Resolves rhbz#479898 --- microcode_ctl.init | 79 --------------------------------------------- microcode_ctl.rules | 3 ++ microcode_ctl.spec | 56 +++++++++----------------------- 3 files changed, 18 insertions(+), 120 deletions(-) delete mode 100755 microcode_ctl.init create mode 100644 microcode_ctl.rules diff --git a/microcode_ctl.init b/microcode_ctl.init deleted file mode 100755 index eddecd2..0000000 --- a/microcode_ctl.init +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/bash -# chkconfig: 2345 0 99 -# description: script to apply cpu microcode - -# Check that we're a priviledged user -[ `id -u` = 0 ] || exit 0 - -DATAFILE=/lib/firmware/microcode.dat - -. /etc/init.d/functions - -RETVAL=0 - -# perform the update -function start () -{ - RETVAL=1 - - # 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 - echo $"Loading AMD microcode update module" - /sbin/modprobe microcode - return - else - return - fi - - if [ ! -e $DATAFILE ]; then - echo $"$0: CPU microcode data file not present ($DATAFILE)" - 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 - - /sbin/microcode_ctl -Qu - RETVAL=$? - - /sbin/rmmod microcode - - return $RETVAL -} - -stop() -{ - return -} - -case "$1" in - start) - start - exit 0 - ;; - stop) - stop - ;; - restart|reload|force-reload) - stop - start - ;; - status) - ;; - *) - echo $"Usage: $0 {start|stop|restart}" - exit 1 -esac -exit $? - diff --git a/microcode_ctl.rules b/microcode_ctl.rules new file mode 100644 index 0000000..4a76528 --- /dev/null +++ b/microcode_ctl.rules @@ -0,0 +1,3 @@ +KERNEL=="cpu[0-9]*", RUN+="/sbin/modprobe microcode" +KERNEL=="microcode", RUN+="/sbin/microcode_ctl -Qu" + diff --git a/microcode_ctl.spec b/microcode_ctl.spec index 55096e2..78daee1 100644 --- a/microcode_ctl.spec +++ b/microcode_ctl.spec @@ -1,22 +1,22 @@ Summary: Tool to update x86/x86-64 CPU microcode. Name: microcode_ctl Version: 1.17 -Release: %(R="$Revision$"; RR="${R##: }"; echo ${RR%%?})%{?dist} +Release: 2%{?dist} Epoch: 1 Group: System Environment/Base License: GPLv2+ URL: http://www.urbanmyth.org/microcode/ Source0: http://www.urbanmyth.org/microcode/microcode_ctl-%{version}.tar.gz -Source1: microcode_ctl.init +Source1: microcode_ctl.rules # Microcode now distributed directly by Intel, at # http://downloadcenter.intel.com (just search for microcode) Source2: microcode-20100209.dat # http://www.amd64.org/support/microcode.html -Source3: amd-ucode-2009-10-09.tar +Source3: amd-ucode-2009-10-09.tar Buildroot: %{_tmppath}/%{name}-%{version}-root +Requires: udev Requires(pre): /sbin/chkconfig /sbin/service Requires(pre): grep gawk coreutils -Obsoletes: kernel-utils ExclusiveArch: %{ix86} x86_64 Patch1: microcode_ctl.patch @@ -42,7 +42,10 @@ mkdir -p %{buildroot}/lib/firmware/amd-ucode/ make DESTDIR=%{buildroot} PREFIX=%{_prefix} \ INSDIR=/sbin MANDIR=%{_mandir}/man8 RCDIR=%{_sysconfdir} install clean -install %{SOURCE1} %{buildroot}%{_sysconfdir}/init.d/microcode_ctl +rm -rf %{buildroot}/etc/* + +mkdir -p %{buildroot}/lib/udev/rules.d +install -m 644 %{SOURCE1} %{buildroot}/lib/udev/rules.d/89-microcode.rules install -m 644 %{SOURCE2} %{buildroot}/lib/firmware/microcode.dat install -m 644 amd-ucode-2009-10-09/microcode_amd.bin %{buildroot}/lib/firmware/amd-ucode/microcode_amd.bin @@ -57,51 +60,22 @@ rm -rf %{buildroot} %files %defattr(-,root,root) -%{_sysconfdir}/init.d/microcode_ctl /lib/firmware/* +/lib/udev/rules.d/* /sbin/microcode_ctl %doc LICENSE.microcode_amd README.microcode_amd INSTALL.microcode_amd %attr(0644,root,root) %{_mandir}/*/* - - -%preun -if [ "$1" = "0" ] ; then - /sbin/chkconfig --del microcode_ctl -fi - -%post -# Only enable on Intel 686's and above or AMD family 0x10 and above -vendor=`cat /proc/cpuinfo | grep "^vendor_id" | sort -u | awk -F ": " '{ print $2 }'` -family=`cat /proc/cpuinfo | grep "^cpu family" | sort -u | awk -F ": " '{ print $2 }'` -if [ "$vendor" = "GenuineIntel" ]; then - [ $family -lt 6 ] && exit 0 -elif [ "$vendor" = "AuthenticAMD" ]; then - [ $family -lt 16 ] && exit 0 -else - exit 0 -fi - -/sbin/chkconfig --add microcode_ctl +%triggerun -- microcode_ctl < 1:1.17-2 +/sbin/chkconfig --del microcode_ctl exit 0 -%triggerpostun -- kernel-utils -# Only enable on Intel 686's and above or AMD family 0x10 and above -vendor=`cat /proc/cpuinfo | grep "^vendor_id" | sort -u | awk -F ": " '{ print $2 }'` -family=`cat /proc/cpuinfo | grep "^cpu family" | sort -u | awk -F ": " '{ print $2 }'` -if [ "$vendor" = "GenuineIntel" ]; then - [ $family -lt 6 ] && exit 0 -elif [ "$vendor" = "AuthenticAMD" ]; then - [ $family -lt 16 ] && exit 0 -else - exit 0 -fi - -/sbin/chkconfig --add microcode_ctl -exit 0 %changelog -* Thu Feb 11 2010 Dave Jones +* Mon Mar 22 2010 Anton Arapov 1.17-2 +- Make microcode_ctl event driven (Bill Nottingham ) Resolves rhbz#479898 + +* Thu Feb 11 2010 Dave Jones 1.17-1.58 - Update to microcode-20100209.dat * Fri Dec 04 2009 Kyle McMartin 1.17-1.57