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 <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Jiajie Chen
2022-08-19 10:08:23 +08:00
parent 608b930ba6
commit 38131c8a61
2 changed files with 25 additions and 8 deletions

View File

@@ -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):

View File

@@ -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)