diff --git a/README.adoc b/README.adoc index 4c45b7c..61f87b6 100644 --- a/README.adoc +++ b/README.adoc @@ -7781,9 +7781,9 @@ Works and prints `hello`: ./run-toolchain --arch x86_64 gcc -- -static -o x86_64.out "$(./getvar kernel_modules_src_dir)/user/hello.c" ./run-toolchain --arch arm gcc -- -static -o arm.out "$(./getvar kernel_modules_src_dir)/user/hello.c" ./run-toolchain --arch aarch64 gcc -- -static -o aarch64.out "$(./getvar kernel_modules_src_dir)/user/hello.c" -./run-gem5-se --arch x86_64 ./x86_64.out -./run-gem5-se --arch arm ./arm.out -./run-gem5-se --arch aarch64 ./aarch64.out +./run --arch x86_64 --gem5 --gem5-script se --exec-image ./x86_64.out +./run --arch arm --gem5 --gem5-script se --exec-image ./arm.out +./run --arch aarch64 --gem5 --gem5-script se --exec-image ./aarch64.out .... But I think this is unreliable, and only works because we are using uclibc which does not check the kernel version as glibc does: https://stackoverflow.com/questions/48959349/how-to-solve-fatal-kernel-too-old-when-running-gem5-in-syscall-emulation-se-m/50542301#50542301 @@ -7791,9 +7791,9 @@ But I think this is unreliable, and only works because we are using uclibc which Ignoring that insanity, we then try it with dynamically linked executables: .... -./run-gem5-se --arch x86_64 "$(./getvar --arch x86_64 --gem5 target_dir)/hello.out" -./run-gem5-se --arch arm "$(./getvar --arch arm --gem5 target_dir)/hello.out" -./run-gem5-se --arch aarch64 "$(./getvar --arch aarch64 --gem5 target_dir)/hello.out" +./run --arch x86_64 --gem5 --gem5-script se --exec-image "$(./getvar --arch x86_64 --gem5 target_dir)/hello.out" +./run --arch arm --gem5 --gem5-script se --exec-image "$(./getvar --arch arm --gem5 target_dir)/hello.out" +./run --arch aarch64 --gem5 --gem5-script se --exec-image "$(./getvar --arch aarch64 --gem5 target_dir)/hello.out" .... But at 185c2730cc78d5adda683d76c0e3b35e7cb534f0 they fail with: @@ -9706,7 +9706,7 @@ The out of build tree is required, because otherwise Buildroot would copy the ou By default, we use `configs/example/fs.py` script. -The `--gem5-biglittle` option enables the alternative `configs/example/arm/fs_bigLITTLE.py` script instead. +The `--gem5-script biglittle` option enables the alternative `configs/example/arm/fs_bigLITTLE.py` script instead. First apply: @@ -9717,7 +9717,7 @@ patch -d "$(./getvar gem5_src_dir)" -p 1 < patches/manual/gem5-biglittle.patch then: .... -./run --arch aarch64 --gem5 --gem5-biglittle +./run --arch aarch64 --gem5 --gem5-script biglittle .... Advantages over `fs.py`: diff --git a/bench-boot b/bench-boot index 0c60f8a..11df9c7 100755 --- a/bench-boot +++ b/bench-boot @@ -71,7 +71,7 @@ fi if [ "$test_size" -ge 3 ]; then #bench "$arch --eval 'm5 exit' --gem5 -- --cpu-type=HPI ${caches}" #gem5_insts "$arch" - bench "$arch --eval 'm5 exit' --gem5 --gem5-biglittle" + bench "$arch --eval 'm5 exit' --gem5 --gem5-script biglittle" gem5_insts "$arch" fi diff --git a/run b/run index de06c73..2dcc118 100755 --- a/run +++ b/run @@ -16,10 +16,11 @@ defaults = { 'debug_vm': False, 'eval': None, 'extra_emulator_args': [], - 'gem5_biglittle': False, + 'exec_image': None, 'gem5_exe_args': '', 'gem5_readfile': '', 'gem5_restore': None, + 'gem5_script': 'fs', 'graphic': False, 'initramfs': False, 'initrd': False, @@ -138,20 +139,7 @@ def main(args, extra_args=None): '-d', common.m5out_dir ] ) - if args.gem5_biglittle: - if args.gem5_restore is not None: - cpt_dir = common.gem_list_checkpoint_dirs()[-args.gem5_restore] - extra_emulator_args.extend(['--restore-from', os.path.join(common.m5out_dir, cpt_dir)]) - cmd += [ - os.path.join(common.gem5_src_dir, 'configs', 'example', 'arm', 'fs_bigLITTLE.py'), - '--big-cpus', '2', - '--cpu-type', 'atomic', - '--disk', common.disk_image, - '--dtb', os.path.join(common.gem5_system_dir, 'arm', 'dt', 'armv8_gem5_v1_big_little_2_2.dtb'), - '--kernel', common.image, - '--little-cpus', '2' - ] - else: + if args.gem5_script == 'fs': # TODO port if args.gem5_restore is not None: cpt_dirs = common.gem_list_checkpoint_dirs() @@ -179,6 +167,22 @@ def main(args, extra_args=None): ] if not args.baremetal is None: cmd.append('--bare-metal') + elif args.gem5_script == 'biglittle': + if args.gem5_restore is not None: + cpt_dir = common.gem_list_checkpoint_dirs()[-args.gem5_restore] + extra_emulator_args.extend(['--restore-from', os.path.join(common.m5out_dir, cpt_dir)]) + cmd += [ + os.path.join(common.gem5_src_dir, 'configs', 'example', 'arm', 'fs_bigLITTLE.py'), + '--big-cpus', '2', + '--cpu-type', 'atomic', + '--disk', common.disk_image, + '--dtb', os.path.join(common.gem5_system_dir, 'arm', 'dt', 'armv8_gem5_v1_big_little_2_2.dtb'), + '--kernel', common.image, + '--little-cpus', '2' + ] + elif args.gem5_script == 'se': + assert(args.exec_image is not None) + cmd += [common.gem5_se_file, '-c', args.exec_image] else: if not os.path.exists(common.image): raise_image_not_found() @@ -348,6 +352,15 @@ def get_argparse(): help='''\ Replace the normal init with a minimal init that just evals the given string. See: https://github.com/cirosantilli/linux-kernel-module-cheat#replace-init +''' + ) + parser.add_argument( + '--exec-image', default=defaults['gem5_script'], + help='''\ +Set which executable image to use. Currently only used for gem5 se.py +which has no sensible default. Maybe we could also select the --baremetal +executable with this, might be a nicer interface. We could definitely use +this to override the default Linux kernel image. ''' ) parser.add_argument( @@ -389,8 +402,8 @@ gem.op5 --debug-flags=Exec fs.py --cpu-type=HPI --caches ''' ) parser.add_argument( - '--gem5-biglittle', default=defaults['gem5_biglittle'], action='store_true', - help='Use fs_bigLITTLE.py instead of fs.py' + '--gem5-script', default=defaults['gem5_script'], choices=['fs', 'se', 'biglittle'], + help='Which gem5 script to use' ) parser.add_argument( '--gem5-readfile', default=defaults['gem5_readfile'], diff --git a/run-gem5-se b/run-gem5-se deleted file mode 100755 index e961305..0000000 --- a/run-gem5-se +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python3 - -import common - -parser = common.get_argparse( - default_args={'gem5':True}, - argparse_args={'description':'Run executable in gem5 se.py syscall emulation mode'} -) -parser.add_argument( - 'executable', -) -args = common.setup(parser) -common.run_cmd([common.executable, common.gem5_se_file, '-c', args.executable])