mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
baremetal: exit at the end of main instead of infinite loop
run: interpret lkmc_test_fail as the last line of test as an error
This commit is contained in:
25
baremetal/arch/aarch64/floating_point.S
Normal file
25
baremetal/arch/aarch64/floating_point.S
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/* https://github.com/cirosantilli/arm-assembly-cheat/blob/c19e187e98e99f2f4a042783ca238aa4eb2292ab/v8/floating_point.S */
|
||||||
|
|
||||||
|
.global main
|
||||||
|
main:
|
||||||
|
/* 1.5 + 2.5 == 4.0 */
|
||||||
|
fmov d0, #1.5
|
||||||
|
fmov d1, #2.5
|
||||||
|
fadd d2, d0, d1
|
||||||
|
fmov d3, #4.0
|
||||||
|
fcmp d2, d3
|
||||||
|
beq 1f
|
||||||
|
bl assert_fail
|
||||||
|
1:
|
||||||
|
|
||||||
|
/* Now in 32-bit. */
|
||||||
|
fmov s0, #1.5
|
||||||
|
fmov s1, #2.5
|
||||||
|
fadd s2, s0, s1
|
||||||
|
fmov s3, #4.0
|
||||||
|
fcmp s2, s3
|
||||||
|
beq 1f
|
||||||
|
bl assert_fail
|
||||||
|
1:
|
||||||
|
|
||||||
|
ret
|
||||||
4
baremetal/arch/aarch64/return.S
Normal file
4
baremetal/arch/aarch64/return.S
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/* Return to ensure that the post main works. */
|
||||||
|
.global main
|
||||||
|
main:
|
||||||
|
ret
|
||||||
6
baremetal/interactive/hello.c
Normal file
6
baremetal/interactive/hello.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
puts("hello");
|
||||||
|
return;
|
||||||
|
}
|
||||||
@@ -8,4 +8,5 @@ mystart:
|
|||||||
ldr x0, =stack_top
|
ldr x0, =stack_top
|
||||||
mov sp, x0
|
mov sp, x0
|
||||||
bl main
|
bl main
|
||||||
b .
|
mov x0, #0
|
||||||
|
bl exit
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
mystart:
|
mystart:
|
||||||
ldr sp, =stack_top
|
ldr sp, =stack_top
|
||||||
bl main
|
bl main
|
||||||
b .
|
mov r0, #0
|
||||||
|
bl exit
|
||||||
|
|||||||
3
baremetal/return.c
Normal file
3
baremetal/return.c
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
void main(void) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
@@ -72,6 +72,7 @@ kernel_module_ext = '.ko'
|
|||||||
obj_ext = '.o'
|
obj_ext = '.o'
|
||||||
config_file = os.path.join(data_dir, 'config')
|
config_file = os.path.join(data_dir, 'config')
|
||||||
command_prefix = '+ '
|
command_prefix = '+ '
|
||||||
|
magic_fail_string = b'lkmc_test_fail'
|
||||||
if os.path.exists(config_file):
|
if os.path.exists(config_file):
|
||||||
config = imp.load_source('config', config_file)
|
config = imp.load_source('config', config_file)
|
||||||
configs = {x:getattr(config, x) for x in dir(config) if not x.startswith('__')}
|
configs = {x:getattr(config, x) for x in dir(config) if not x.startswith('__')}
|
||||||
@@ -774,6 +775,7 @@ def setup(parser):
|
|||||||
this_module.m5out_dir = os.path.join(this_module.gem5_run_dir, 'm5out')
|
this_module.m5out_dir = os.path.join(this_module.gem5_run_dir, 'm5out')
|
||||||
this_module.stats_file = os.path.join(this_module.m5out_dir, 'stats.txt')
|
this_module.stats_file = os.path.join(this_module.m5out_dir, 'stats.txt')
|
||||||
this_module.trace_txt_file = os.path.join(this_module.m5out_dir, 'trace.txt')
|
this_module.trace_txt_file = os.path.join(this_module.m5out_dir, 'trace.txt')
|
||||||
|
this_module.gem5_guest_terminal_file = os.path.join(this_module.m5out_dir, 'system.terminal')
|
||||||
this_module.gem5_readfile = os.path.join(this_module.gem5_run_dir, 'readfile')
|
this_module.gem5_readfile = os.path.join(this_module.gem5_run_dir, 'readfile')
|
||||||
this_module.gem5_termout_file = os.path.join(this_module.gem5_run_dir, 'termout.txt')
|
this_module.gem5_termout_file = os.path.join(this_module.gem5_run_dir, 'termout.txt')
|
||||||
this_module.qemu_run_dir = os.path.join(this_module.run_dir_base, 'qemu', args.arch, str(args.run_id))
|
this_module.qemu_run_dir = os.path.join(this_module.run_dir_base, 'qemu', args.arch, str(args.run_id))
|
||||||
@@ -782,6 +784,7 @@ def setup(parser):
|
|||||||
this_module.qemu_trace_txt_file = os.path.join(this_module.qemu_run_dir, 'trace.txt')
|
this_module.qemu_trace_txt_file = os.path.join(this_module.qemu_run_dir, 'trace.txt')
|
||||||
this_module.qemu_termout_file = os.path.join(this_module.qemu_run_dir, 'termout.txt')
|
this_module.qemu_termout_file = os.path.join(this_module.qemu_run_dir, 'termout.txt')
|
||||||
this_module.qemu_rrfile = os.path.join(this_module.qemu_run_dir, 'rrfile')
|
this_module.qemu_rrfile = os.path.join(this_module.qemu_run_dir, 'rrfile')
|
||||||
|
this_module.qemu_guest_terminal_file = os.path.join(this_module.m5out_dir, qemu_termout_file)
|
||||||
this_module.gem5_out_dir = os.path.join(this_module.out_dir, 'gem5')
|
this_module.gem5_out_dir = os.path.join(this_module.out_dir, 'gem5')
|
||||||
if args.gem5_build_dir is None:
|
if args.gem5_build_dir is None:
|
||||||
this_module.gem5_build_dir = os.path.join(this_module.gem5_out_dir, args.gem5_build_id, args.gem5_build_type)
|
this_module.gem5_build_dir = os.path.join(this_module.gem5_out_dir, args.gem5_build_id, args.gem5_build_type)
|
||||||
@@ -817,10 +820,12 @@ def setup(parser):
|
|||||||
this_module.executable = this_module.gem5_executable
|
this_module.executable = this_module.gem5_executable
|
||||||
this_module.run_dir = this_module.gem5_run_dir
|
this_module.run_dir = this_module.gem5_run_dir
|
||||||
this_module.termout_file = this_module.gem5_termout_file
|
this_module.termout_file = this_module.gem5_termout_file
|
||||||
|
this_module.guest_terminal_file = gem5_guest_terminal_file
|
||||||
else:
|
else:
|
||||||
this_module.executable = this_module.qemu_executable
|
this_module.executable = this_module.qemu_executable
|
||||||
this_module.run_dir = this_module.qemu_run_dir
|
this_module.run_dir = this_module.qemu_run_dir
|
||||||
this_module.termout_file = this_module.qemu_termout_file
|
this_module.termout_file = this_module.qemu_termout_file
|
||||||
|
this_module.guest_terminal_file = qemu_guest_terminal_file
|
||||||
this_module.gem5_config_dir = os.path.join(this_module.gem5_src_dir, 'configs')
|
this_module.gem5_config_dir = os.path.join(this_module.gem5_src_dir, 'configs')
|
||||||
this_module.gem5_se_file = os.path.join(this_module.gem5_config_dir, 'example', 'se.py')
|
this_module.gem5_se_file = os.path.join(this_module.gem5_config_dir, 'example', 'se.py')
|
||||||
this_module.gem5_fs_file = os.path.join(this_module.gem5_config_dir, 'example', 'fs.py')
|
this_module.gem5_fs_file = os.path.join(this_module.gem5_config_dir, 'example', 'fs.py')
|
||||||
|
|||||||
13
run
13
run
@@ -392,11 +392,20 @@ def main(args, extra_args=None):
|
|||||||
else:
|
else:
|
||||||
panic_msg = b'Kernel panic - not syncing'
|
panic_msg = b'Kernel panic - not syncing'
|
||||||
panic_re = re.compile(panic_msg)
|
panic_re = re.compile(panic_msg)
|
||||||
|
error_string_found = False
|
||||||
with open(common.termout_file, 'br') as logfile:
|
with open(common.termout_file, 'br') as logfile:
|
||||||
for line in logfile:
|
for line in logfile:
|
||||||
if panic_re.search(line):
|
if panic_re.search(line):
|
||||||
common.log_error('simulation error detected by parsing logs')
|
error_string_found = True
|
||||||
return 1
|
with open(common.guest_terminal_file, 'br') as logfile:
|
||||||
|
lines = logfile.readlines()
|
||||||
|
if lines:
|
||||||
|
last_line = lines[-1]
|
||||||
|
if last_line.rstrip() == common.magic_fail_string:
|
||||||
|
error_string_found = True
|
||||||
|
if error_string_found:
|
||||||
|
common.log_error('simulation error detected by parsing logs')
|
||||||
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def get_argparse():
|
def get_argparse():
|
||||||
|
|||||||
Reference in New Issue
Block a user