c59b13
#! /bin/bash -efu
c59b13
c59b13
# Trigger microcode reload with additional check for BDW-EP that can have
c59b13
# microcode reloaded only in case kernel has specific patches.
c59b13
#
c59b13
# SPDX-License-Identifier: CC0-1.0
c59b13
c59b13
CHECK_CAVEATS=/usr/libexec/microcode_ctl/check_caveats
c59b13
IGNORE_HYPERVISOR="/etc/microcode_ctl/ignore-hypervisor-flag"
c59b13
c59b13
[ -e "$IGNORE_HYPERVISOR" ] || {
c59b13
	if grep -q '^flags[[:space:]]*:.* hypervisor\( .*\)\?$' /proc/cpuinfo
c59b13
	then
c59b13
		exit 0
c59b13
	fi
c59b13
}
c59b13
c59b13
"$CHECK_CAVEATS" -m > /dev/null || exit 0
c59b13
c59b13
echo 2>/dev/null 1 > /sys/devices/system/cpu/microcode/reload || :
c59b13
c59b13
exit 0