From 687ce1a7faaeaa8175adbcf164f19dcec5f97e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lesimple?= Date: Sat, 8 Sep 2018 23:15:21 +0200 Subject: [PATCH] fix: load cpuid module if absent even when /dev/cpu/0/cpuid is there --- spectre-meltdown-checker.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spectre-meltdown-checker.sh b/spectre-meltdown-checker.sh index 229a414..d822f86 100755 --- a/spectre-meltdown-checker.sh +++ b/spectre-meltdown-checker.sh @@ -959,11 +959,14 @@ read_cpuid() if [ -e /dev/cpu/0/cpuid ]; then # Linux + # on some kernel versions, /dev/cpu/0/cpuid doesn't imply that the cpuid module is loaded, in that case dd returns an error + dd if=/dev/cpu/0/cpuid bs=16 count=1 >/dev/null 2>&1 || load_cpuid # we need _leaf to be converted to decimal for dd _leaf=$(( _leaf )) # to avoid using iflag=skip_bytes, which doesn't exist on old versions of dd, seek to the closer multiple-of-16 _ddskip=$(( _leaf / 16 )) _odskip=$(( _leaf - _ddskip * 16 )) + # now read the value _cpuid=$(dd if=/dev/cpu/0/cpuid bs=16 skip=$_ddskip count=$((_odskip + 1)) 2>/dev/null | od -j $((_odskip * 16)) -A n -t u4) elif [ -e /dev/cpuctl0 ]; then # BSD