From 38131c8a611344b2461f05ae765e2447aaf46f8d Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Fri, 19 Aug 2022 10:08:23 +0800 Subject: [PATCH] configs: Add option to override cpu vendor string Glibc requires x86-64-v2 ISA level on newer Linux distributions (e.g. Debian Bookworm), and running applications in GEM5 will fail with "CPU ISA level is lower than required" error. It is due to glibc not detecting CPU features when the vendor string is unknown yet requiring them to run. For glibc to detect correct CPU features, this commit adds a command line option to allow user to override x86 cpu vendor string to well-known ones, e.g. GenuineIntel. It allows glibc to detect more cpu features and fixes the issue. Jira Issue: https://gem5.atlassian.net/browse/GEM5-1117 Change-Id: I22907e7b983e9aa6122543042af207e35b09badb Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62555 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- configs/common/Options.py | 7 +++++++ configs/common/Simulation.py | 26 ++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/configs/common/Options.py b/configs/common/Options.py index 46bf4f3a99..f325e9be96 100644 --- a/configs/common/Options.py +++ b/configs/common/Options.py @@ -670,6 +670,13 @@ def addCommonOptions(parser): "that are present under any of the roots. If not given, dump all " "stats. ", ) + parser.add_argument( + "--override-vendor-string", + action="store", + type=str, + default=None, + help="Override vendor string returned by CPUID instruction in X86.", + ) def addSEOptions(parser): diff --git a/configs/common/Simulation.py b/configs/common/Simulation.py index a51fb33987..e558055f16 100644 --- a/configs/common/Simulation.py +++ b/configs/common/Simulation.py @@ -61,11 +61,11 @@ def getCPUClass(cpu_type): def setCPUClass(options): """Returns two cpu classes and the initial mode of operation. - Restoring from a checkpoint or fast forwarding through a benchmark - can be done using one type of cpu, and then the actual - simulation can be carried out using another type. This function - returns these two types of cpus and the initial mode of operation - depending on the options provided. + Restoring from a checkpoint or fast forwarding through a benchmark + can be done using one type of cpu, and then the actual + simulation can be carried out using another type. This function + returns these two types of cpus and the initial mode of operation + depending on the options provided. """ TmpClass, test_mem_mode = getCPUClass(options.cpu_type) @@ -300,9 +300,12 @@ def benchCheckpoints(options, maxtick, cptdir): def parseSimpointAnalysisFile(options, testsys): import re - simpoint_filename, weight_filename, interval_length, warmup_length = options.take_simpoint_checkpoints.split( - ",", 3 - ) + ( + simpoint_filename, + weight_filename, + interval_length, + warmup_length, + ) = options.take_simpoint_checkpoints.split(",", 3) print("simpoint analysis file:", simpoint_filename) print("simpoint weight file:", weight_filename) print("interval length:", interval_length) @@ -497,6 +500,13 @@ def run(options, root, testsys, cpu_class): for i in range(np): testsys.cpu[i].max_insts_any_thread = options.maxinsts + if options.override_vendor_string is not None: + for i in range(len(testsys.cpu)): + for j in range(len(testsys.cpu[i].isa)): + testsys.cpu[i].isa[ + j + ].vendor_string = options.override_vendor_string + if cpu_class: switch_cpus = [ cpu_class(switched_out=True, cpu_id=(i)) for i in range(np)