Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow specifying privilege modes for simulation #984

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,14 @@ def get_generator_cmd(simulator, simulator_yaml, cov, exp, debug_cmd):
sys.exit(RET_FAIL)


def parse_iss_yaml(iss, iss_yaml, isa, setting_dir, debug_cmd):
def parse_iss_yaml(iss, iss_yaml, isa, priv, setting_dir, debug_cmd):
"""Parse ISS YAML to get the simulation command

Args:
iss : target ISS used to look up in ISS YAML
iss_yaml : ISS configuration file in YAML format
isa : ISA variant passed to the ISS
priv: : privilege modes
setting_dir : Generator setting directory
debug_cmd : Produce the debug cmd log without running

Expand Down Expand Up @@ -169,6 +170,7 @@ def parse_iss_yaml(iss, iss_yaml, isa, setting_dir, debug_cmd):
cmd = re.sub("\<variant\>", variant, cmd)
else:
cmd = re.sub("\<variant\>", isa, cmd)
cmd = re.sub("\<priv\>", priv, cmd)
cmd = re.sub("\<scripts_path\>", scripts_dir, cmd)
cmd = re.sub("\<config_path\>", yaml_dir, cmd)
return cmd
Expand Down Expand Up @@ -645,7 +647,7 @@ def run_c_from_dir(c_test_dir, iss_yaml, isa, mabi, gcc_opts, iss,


def iss_sim(test_list, output_dir, iss_list, iss_yaml, iss_opts,
isa, setting_dir, timeout_s, debug_cmd):
isa, priv, setting_dir, timeout_s, debug_cmd):
"""Run ISS simulation with the generated test program

Args:
Expand All @@ -655,13 +657,14 @@ def iss_sim(test_list, output_dir, iss_list, iss_yaml, iss_opts,
iss_yaml : ISS configuration file in YAML format
iss_opts : ISS command line options
isa : ISA variant passed to the ISS
priv : privilege modes
setting_dir : Generator setting directory
timeout_s : Timeout limit in seconds
debug_cmd : Produce the debug cmd log without running
"""
for iss in iss_list.split(","):
log_dir = ("{}/{}_sim".format(output_dir, iss))
base_cmd = parse_iss_yaml(iss, iss_yaml, isa, setting_dir, debug_cmd)
base_cmd = parse_iss_yaml(iss, iss_yaml, isa, priv, setting_dir, debug_cmd)
logging.info("{} sim log dir: {}".format(iss, log_dir))
run_cmd_output(["mkdir", "-p", log_dir])
for test in test_list:
Expand Down Expand Up @@ -818,6 +821,8 @@ def parse_args(cwd):
command is not specified")
parser.add_argument("--isa", type=str, default="",
help="RISC-V ISA subset")
parser.add_argument("--priv", type=str, default="",
help="RISC-V privilege modes enabled in simulation [su]")
parser.add_argument("-m", "--mabi", type=str, default="",
help="mabi used for compilation", dest="mabi")
parser.add_argument("--gen_timeout", type=int, default=360,
Expand Down Expand Up @@ -1151,7 +1156,7 @@ def main():
if args.steps == "all" or re.match(".*iss_sim.*", args.steps):
iss_sim(matched_list, output_dir, args.iss, args.iss_yaml,
args.iss_opts,
args.isa, args.core_setting_dir, args.iss_timeout,
args.isa, args.priv, args.core_setting_dir, args.iss_timeout,
args.debug)

# Compare ISS simulation result
Expand Down
4 changes: 2 additions & 2 deletions yaml/iss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- iss: spike
path_var: SPIKE_PATH
cmd: >
<path_var>/spike --log-commits --isa=<variant> --misaligned -l <elf>
<path_var>/spike --log-commits --isa=<variant> --priv=m<priv> --misaligned -l <elf>

- iss: ovpsim
path_var: OVPSIM_PATH
Expand All @@ -35,7 +35,7 @@
- iss: whisper
path_var: WHISPER_ISS
cmd: >
<path_var> <elf> --log --xlen <xlen> --isa <variant> --configfile <config_path>/whisper.json --iccmrw
<path_var> <elf> --log --xlen <xlen> --isa <variant><priv> --configfile <config_path>/whisper.json --iccmrw

- iss: renode
path_var: RENODE_PATH
Expand Down
Loading