mirror of
https://github.com/speed47/spectre-meltdown-checker.git
synced 2026-06-04 13:43:05 +02:00
fix: arm64: collapse per-core CPU info lists to a single line (#576)
Store the per-core implementer/part/arch/variant/revision lists space-separated (no embedded newlines, which also cleans up JSON and prometheus output) and dedup them for the human-readable display, so homogeneous systems show e.g. "0x41" instead of repeating it per core.
This commit is contained in:
committed by
GitHub
parent
645a79846b
commit
7d9345a32f
@@ -29,11 +29,18 @@ parse_cpu_details() {
|
|||||||
# cpu_variant_list and cpu_revision_list are consumed by ARM64 errata affection checks
|
# cpu_variant_list and cpu_revision_list are consumed by ARM64 errata affection checks
|
||||||
# that need to match a specific revision range.
|
# that need to match a specific revision range.
|
||||||
if grep -q 'CPU implementer' "$g_procfs/cpuinfo"; then
|
if grep -q 'CPU implementer' "$g_procfs/cpuinfo"; then
|
||||||
cpu_impl_list=$(awk '/CPU implementer/ {print $4}' "$g_procfs/cpuinfo")
|
# keep these single-line (space-separated) so consumers and outputs (JSON, prometheus)
|
||||||
cpu_part_list=$(awk '/CPU part/ {print $4}' "$g_procfs/cpuinfo")
|
# don't end up with embedded newlines; per-core order is preserved for the errata checks
|
||||||
cpu_arch_list=$(awk '/CPU architecture/ {print $3}' "$g_procfs/cpuinfo")
|
cpu_impl_list=$(awk '/CPU implementer/ {print $4}' "$g_procfs/cpuinfo" | tr '\n' ' ')
|
||||||
cpu_variant_list=$(awk '/CPU variant/ {print $4}' "$g_procfs/cpuinfo")
|
cpu_impl_list=${cpu_impl_list% }
|
||||||
cpu_revision_list=$(awk '/CPU revision/ {print $4}' "$g_procfs/cpuinfo")
|
cpu_part_list=$(awk '/CPU part/ {print $4}' "$g_procfs/cpuinfo" | tr '\n' ' ')
|
||||||
|
cpu_part_list=${cpu_part_list% }
|
||||||
|
cpu_arch_list=$(awk '/CPU architecture/ {print $3}' "$g_procfs/cpuinfo" | tr '\n' ' ')
|
||||||
|
cpu_arch_list=${cpu_arch_list% }
|
||||||
|
cpu_variant_list=$(awk '/CPU variant/ {print $4}' "$g_procfs/cpuinfo" | tr '\n' ' ')
|
||||||
|
cpu_variant_list=${cpu_variant_list% }
|
||||||
|
cpu_revision_list=$(awk '/CPU revision/ {print $4}' "$g_procfs/cpuinfo" | tr '\n' ' ')
|
||||||
|
cpu_revision_list=${cpu_revision_list% }
|
||||||
fi
|
fi
|
||||||
# Map first-seen implementer to cpu_vendor; note that heterogeneous systems
|
# Map first-seen implementer to cpu_vendor; note that heterogeneous systems
|
||||||
# (e.g. DynamIQ with ARM+Kryo cores) would all map to one vendor here, but
|
# (e.g. DynamIQ with ARM+Kryo cores) would all map to one vendor here, but
|
||||||
|
|||||||
@@ -384,6 +384,12 @@ check_kernel_info() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Collapse a whitespace-separated list to its unique values, preserving first-seen order.
|
||||||
|
# Used to prettify the per-core ARM lists for display (e.g. "0x41 0x41 0x41 0x41" -> "0x41").
|
||||||
|
_uniq_list() {
|
||||||
|
echo "$1" | awk '{ for (i = 1; i <= NF; i++) if (!seen[$i]++) printf "%s%s", (n++ ? " " : ""), $i }'
|
||||||
|
}
|
||||||
|
|
||||||
# Display hardware-level CPU mitigation support (microcode features, ARCH_CAPABILITIES, etc.)
|
# Display hardware-level CPU mitigation support (microcode features, ARCH_CAPABILITIES, etc.)
|
||||||
check_cpu() {
|
check_cpu() {
|
||||||
local capabilities ret spec_ctrl_msr codename ucode_str
|
local capabilities ret spec_ctrl_msr codename ucode_str
|
||||||
@@ -393,13 +399,13 @@ check_cpu() {
|
|||||||
pr_info " * Vendor: $cpu_vendor"
|
pr_info " * Vendor: $cpu_vendor"
|
||||||
pr_info " * Model name: $cpu_friendly_name"
|
pr_info " * Model name: $cpu_friendly_name"
|
||||||
if [ -n "${cpu_impl_list:-}" ]; then
|
if [ -n "${cpu_impl_list:-}" ]; then
|
||||||
pr_info " * Implementer(s): $cpu_impl_list"
|
pr_info " * Implementer(s): $(_uniq_list "$cpu_impl_list")"
|
||||||
fi
|
fi
|
||||||
if [ -n "${cpu_part_list:-}" ]; then
|
if [ -n "${cpu_part_list:-}" ]; then
|
||||||
pr_info " * Part(s): $cpu_part_list"
|
pr_info " * Part(s): $(_uniq_list "$cpu_part_list")"
|
||||||
fi
|
fi
|
||||||
if [ -n "${cpu_arch_list:-}" ]; then
|
if [ -n "${cpu_arch_list:-}" ]; then
|
||||||
pr_info " * Architecture(s): $cpu_arch_list"
|
pr_info " * Architecture(s): $(_uniq_list "$cpu_arch_list")"
|
||||||
fi
|
fi
|
||||||
if has_runtime; then
|
if has_runtime; then
|
||||||
pr_info_nol " * Running as VM guest: "
|
pr_info_nol " * Running as VM guest: "
|
||||||
|
|||||||
Reference in New Issue
Block a user