mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Don't pass dummy disk images to gem5
After https://gem5.atlassian.net/browse/GEM5-337: - gem5 baremetal can run without any disk images, just like QEMU - gem5 X86 can run with a single disk image and no horrendous dummy vmlinux and second disk image
This commit is contained in:
13
build-gem5
13
build-gem5
@@ -61,18 +61,7 @@ https://github.com/cirosantilli/linux-kernel-module-cheat-regression#gem5-unit-t
|
|||||||
verbose = ['--verbose', LF]
|
verbose = ['--verbose', LF]
|
||||||
else:
|
else:
|
||||||
verbose = []
|
verbose = []
|
||||||
if self.env['arch'] == 'x86_64':
|
if self.env['is_arm']:
|
||||||
dummy_img_path = os.path.join(disks_dir, 'linux-bigswap2.img')
|
|
||||||
with open(dummy_img_path, 'wb') as dummy_img_file:
|
|
||||||
zeroes = b'\x00' * (2 ** 16)
|
|
||||||
for i in range(2 ** 10):
|
|
||||||
dummy_img_file.write(zeroes)
|
|
||||||
self.sh.run_cmd(['mkswap', dummy_img_path, LF])
|
|
||||||
with open(os.path.join(binaries_dir, 'x86_64-vmlinux-2.6.22.9'), 'w'):
|
|
||||||
# This file must always be present, despite --kernel overriding that default and selecting the kernel.
|
|
||||||
# I'm not even joking. No one has ever built x86 gem5 without the magic dist dir present.
|
|
||||||
pass
|
|
||||||
elif self.env['arch'] == 'arm' or self.env['arch'] == 'aarch64':
|
|
||||||
gem5_system_source_dir = os.path.join(self.env['gem5_source_dir'], 'system')
|
gem5_system_source_dir = os.path.join(self.env['gem5_source_dir'], 'system')
|
||||||
|
|
||||||
# dtb
|
# dtb
|
||||||
|
|||||||
@@ -844,7 +844,6 @@ Incompatible archs are skipped.
|
|||||||
# gem5
|
# gem5
|
||||||
if not env['_args_given']['gem5_build_dir']:
|
if not env['_args_given']['gem5_build_dir']:
|
||||||
env['gem5_build_dir'] = join(env['gem5_out_dir'], env['gem5_build_id'])
|
env['gem5_build_dir'] = join(env['gem5_out_dir'], env['gem5_build_id'])
|
||||||
env['gem5_fake_iso'] = join(env['gem5_out_dir'], 'fake.iso')
|
|
||||||
env['gem5_m5term'] = join(env['gem5_build_dir'], 'm5term')
|
env['gem5_m5term'] = join(env['gem5_build_dir'], 'm5term')
|
||||||
env['gem5_build_build_dir'] = join(env['gem5_build_dir'], 'build')
|
env['gem5_build_build_dir'] = join(env['gem5_build_dir'], 'build')
|
||||||
env['gem5_executable_dir'] = join(env['gem5_build_build_dir'], env['gem5_arch'])
|
env['gem5_executable_dir'] = join(env['gem5_build_build_dir'], env['gem5_arch'])
|
||||||
@@ -1065,7 +1064,7 @@ Incompatible archs are skipped.
|
|||||||
|
|
||||||
# Image
|
# Image
|
||||||
if env['baremetal'] is not None:
|
if env['baremetal'] is not None:
|
||||||
env['disk_image'] = env['gem5_fake_iso']
|
env['disk_image'] = None
|
||||||
env['image'] = self.resolve_baremetal_executable(env['baremetal'])
|
env['image'] = self.resolve_baremetal_executable(env['baremetal'])
|
||||||
source_path_noext = os.path.splitext(join(
|
source_path_noext = os.path.splitext(join(
|
||||||
env['root_dir'],
|
env['root_dir'],
|
||||||
@@ -1094,7 +1093,7 @@ Incompatible archs are skipped.
|
|||||||
if not env['_args_given']['linux_exec']:
|
if not env['_args_given']['linux_exec']:
|
||||||
env['image'] = env['vmlinux']
|
env['image'] = env['vmlinux']
|
||||||
if env['ramfs']:
|
if env['ramfs']:
|
||||||
env['disk_image'] = env['gem5_fake_iso']
|
env['disk_image'] = None
|
||||||
else:
|
else:
|
||||||
env['disk_image'] = env['rootfs_raw_file']
|
env['disk_image'] = env['rootfs_raw_file']
|
||||||
else:
|
else:
|
||||||
|
|||||||
23
run
23
run
@@ -471,11 +471,7 @@ Extra options to append at the end of the emulator command line.
|
|||||||
if self.env['emulator'] == 'gem5':
|
if self.env['emulator'] == 'gem5':
|
||||||
if self.env['quiet']:
|
if self.env['quiet']:
|
||||||
show_stdout = False
|
show_stdout = False
|
||||||
if not self.env['baremetal'] is None:
|
if self.env['baremetal'] is None and self.env['userland'] is None:
|
||||||
if not os.path.exists(self.env['gem5_fake_iso']):
|
|
||||||
os.makedirs(os.path.dirname(self.env['gem5_fake_iso']), exist_ok=True)
|
|
||||||
self.sh.write_string_to_file(self.env['gem5_fake_iso'], 'a' * 512)
|
|
||||||
elif self.env['userland'] is None:
|
|
||||||
if not os.path.exists(self.env['rootfs_raw_file']):
|
if not os.path.exists(self.env['rootfs_raw_file']):
|
||||||
if not os.path.exists(self.env['qcow2_file']):
|
if not os.path.exists(self.env['qcow2_file']):
|
||||||
raise_rootfs_not_found()
|
raise_rootfs_not_found()
|
||||||
@@ -536,11 +532,12 @@ Extra options to append at the end of the emulator command line.
|
|||||||
extra_emulator_args.extend(['-r', str(cpt_dirs_sorted_by_tick.index(cpt_dir) + 1)])
|
extra_emulator_args.extend(['-r', str(cpt_dirs_sorted_by_tick.index(cpt_dir) + 1)])
|
||||||
cmd.extend([
|
cmd.extend([
|
||||||
self.env['gem5_fs_file'], LF,
|
self.env['gem5_fs_file'], LF,
|
||||||
'--disk-image', self.env['disk_image'], LF,
|
|
||||||
'--kernel', self.env['image'], LF,
|
'--kernel', self.env['image'], LF,
|
||||||
'--num-cpus', str(self.env['cpus']), LF,
|
'--num-cpus', str(self.env['cpus']), LF,
|
||||||
'--script', self.env['gem5_readfile_file'], LF,
|
'--script', self.env['gem5_readfile_file'], LF,
|
||||||
])
|
])
|
||||||
|
if self.env['disk_image'] is not None:
|
||||||
|
cmd.extend(['--disk-image', self.env['disk_image'], LF])
|
||||||
if self.env['arch'] == 'x86_64':
|
if self.env['arch'] == 'x86_64':
|
||||||
if self.env['kvm']:
|
if self.env['kvm']:
|
||||||
cmd.extend(['--cpu-type', 'X86KvmCPU', LF])
|
cmd.extend(['--cpu-type', 'X86KvmCPU', LF])
|
||||||
@@ -608,11 +605,12 @@ Extra options to append at the end of the emulator command line.
|
|||||||
'--bootscript', self.env['gem5_readfile_file'], LF,
|
'--bootscript', self.env['gem5_readfile_file'], LF,
|
||||||
'--big-cpus', str((self.env['cpus'] + 1) // 2), LF,
|
'--big-cpus', str((self.env['cpus'] + 1) // 2), LF,
|
||||||
'--cpu-type', cpu_type, LF,
|
'--cpu-type', cpu_type, LF,
|
||||||
'--disk', self.env['disk_image'], LF,
|
|
||||||
'--kernel', self.env['image'], LF,
|
'--kernel', self.env['image'], LF,
|
||||||
'--little-cpus', str(self.env['cpus'] // 2), LF,
|
'--little-cpus', str(self.env['cpus'] // 2), LF,
|
||||||
'--root', '/dev/vda', LF,
|
'--root', '/dev/vda', LF,
|
||||||
])
|
])
|
||||||
|
if self.env['disk_image'] is not None:
|
||||||
|
cmd.extend(['--disk', self.env['disk_image'], LF])
|
||||||
if self.env['dtb']:
|
if self.env['dtb']:
|
||||||
cmd.extend([
|
cmd.extend([
|
||||||
'--dtb',
|
'--dtb',
|
||||||
@@ -749,6 +747,12 @@ Extra options to append at the end of the emulator command line.
|
|||||||
if not os.path.exists(self.env['rootfs_raw_file']):
|
if not os.path.exists(self.env['rootfs_raw_file']):
|
||||||
raise_rootfs_not_found()
|
raise_rootfs_not_found()
|
||||||
self.raw_to_qcow2(qemu_which=self.env['qemu_which'])
|
self.raw_to_qcow2(qemu_which=self.env['qemu_which'])
|
||||||
|
if rr:
|
||||||
|
extra_emulator_args.extend([
|
||||||
|
'-drive', 'driver=blkreplay,if=none,image=img-direct,id=img-blkreplay', LF,
|
||||||
|
'-device', 'ide-hd,drive=img-blkreplay', LF,
|
||||||
|
])
|
||||||
|
if self.env['disk_image'] is not None:
|
||||||
extra_emulator_args.extend([
|
extra_emulator_args.extend([
|
||||||
'-drive',
|
'-drive',
|
||||||
'file={},format=qcow2,if={}{}{}'.format(
|
'file={},format=qcow2,if={}{}{}'.format(
|
||||||
@@ -759,11 +763,6 @@ Extra options to append at the end of the emulator command line.
|
|||||||
),
|
),
|
||||||
LF,
|
LF,
|
||||||
])
|
])
|
||||||
if rr:
|
|
||||||
extra_emulator_args.extend([
|
|
||||||
'-drive', 'driver=blkreplay,if=none,image=img-direct,id=img-blkreplay', LF,
|
|
||||||
'-device', 'ide-hd,drive=img-blkreplay', LF,
|
|
||||||
])
|
|
||||||
if rr:
|
if rr:
|
||||||
extra_emulator_args.extend([
|
extra_emulator_args.extend([
|
||||||
'-object', 'filter-replay,id=replay,netdev=net0', LF,
|
'-object', 'filter-replay,id=replay,netdev=net0', LF,
|
||||||
|
|||||||
Reference in New Issue
Block a user