mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-21 01:54:51 +08:00
14442a159c
Add support for generating VMX feature names in capflags.c and use the resulting x86_vmx_flags to print the VMX flags in /proc/cpuinfo. Don't print VMX flags if no bits are set in word 0, which holds Pin Controls. Pin Control's INTR and NMI exiting are fundamental pillars of VMX, if they are not supported then the CPU is broken, it does not actually support VMX, or the kernel wasn't built with support for the target CPU. Print the features in a dedicated "vmx flags" line to avoid polluting the common "flags" and to avoid having to prefix all flags with "vmx_", which results in horrendously long names. Keep synthetic VMX flags in cpufeatures to preserve /proc/cpuinfo's ABI for those flags. This means that "flags" and "vmx flags" will have duplicate entries for tpr_shadow (virtual_tpr), vnmi, ept, flexpriority, vpid and ept_ad, but caps the pollution of "flags" at those six VMX features. The vendor-specific code that populates the synthetic flags will be consolidated in a future patch to further minimize the lasting damage. Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20191221044513.21680-12-sean.j.christopherson@intel.com
75 lines
1.8 KiB
Bash
75 lines
1.8 KiB
Bash
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Generate the x86_cap/bug_flags[] arrays from include/asm/cpufeatures.h
|
|
#
|
|
|
|
set -e
|
|
|
|
OUT=$1
|
|
|
|
dump_array()
|
|
{
|
|
ARRAY=$1
|
|
SIZE=$2
|
|
PFX=$3
|
|
POSTFIX=$4
|
|
IN=$5
|
|
|
|
PFX_SZ=$(echo $PFX | wc -c)
|
|
TABS="$(printf '\t\t\t\t\t')"
|
|
|
|
echo "const char * const $ARRAY[$SIZE] = {"
|
|
|
|
# Iterate through any input lines starting with #define $PFX
|
|
sed -n -e 's/\t/ /g' -e "s/^ *# *define *$PFX//p" $IN |
|
|
while read i
|
|
do
|
|
# Name is everything up to the first whitespace
|
|
NAME="$(echo "$i" | sed 's/ .*//')"
|
|
|
|
# If the /* comment */ starts with a quote string, grab that.
|
|
VALUE="$(echo "$i" | sed -n 's@.*/\* *\("[^"]*"\).*\*/@\1@p')"
|
|
[ -z "$VALUE" ] && VALUE="\"$NAME\""
|
|
[ "$VALUE" = '""' ] && continue
|
|
|
|
# Name is uppercase, VALUE is all lowercase
|
|
VALUE="$(echo "$VALUE" | tr A-Z a-z)"
|
|
|
|
if [ -n "$POSTFIX" ]; then
|
|
T=$(( $PFX_SZ + $(echo $POSTFIX | wc -c) + 2 ))
|
|
TABS="$(printf '\t\t\t\t\t\t')"
|
|
TABCOUNT=$(( ( 6*8 - ($T + 1) - $(echo "$NAME" | wc -c) ) / 8 ))
|
|
printf "\t[%s - %s]%.*s = %s,\n" "$PFX$NAME" "$POSTFIX" "$TABCOUNT" "$TABS" "$VALUE"
|
|
else
|
|
TABCOUNT=$(( ( 5*8 - ($PFX_SZ + 1) - $(echo "$NAME" | wc -c) ) / 8 ))
|
|
printf "\t[%s]%.*s = %s,\n" "$PFX$NAME" "$TABCOUNT" "$TABS" "$VALUE"
|
|
fi
|
|
done
|
|
echo "};"
|
|
}
|
|
|
|
trap 'rm "$OUT"' EXIT
|
|
|
|
(
|
|
echo "#ifndef _ASM_X86_CPUFEATURES_H"
|
|
echo "#include <asm/cpufeatures.h>"
|
|
echo "#endif"
|
|
echo ""
|
|
|
|
dump_array "x86_cap_flags" "NCAPINTS*32" "X86_FEATURE_" "" $2
|
|
echo ""
|
|
|
|
dump_array "x86_bug_flags" "NBUGINTS*32" "X86_BUG_" "NCAPINTS*32" $2
|
|
echo ""
|
|
|
|
echo "#ifdef CONFIG_X86_VMX_FEATURE_NAMES"
|
|
echo "#ifndef _ASM_X86_VMXFEATURES_H"
|
|
echo "#include <asm/vmxfeatures.h>"
|
|
echo "#endif"
|
|
dump_array "x86_vmx_flags" "NVMXINTS*32" "VMX_FEATURE_" "" $3
|
|
echo "#endif /* CONFIG_X86_VMX_FEATURE_NAMES */"
|
|
) > $OUT
|
|
|
|
trap - EXIT
|