Skip to content

Commit

Permalink
usermode: set return code correctly
Browse files Browse the repository at this point in the history
The return code in from user tasks was assigned the wrong register since
the refactor of syscalls.

Signed-off-by: Johannes Wikner <[email protected]>
  • Loading branch information
sktt authored and wipawel committed Aug 31, 2023
1 parent 5707bd6 commit 55e64e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/x86/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ ENTRY(usermode_stub)
call *%_ASM_SI

/* sys_exit */
mov %_ASM_AX, %_ASM_DI
mov %_ASM_AX, %_ASM_SI
mov $SYSCALL_EXIT, %_ASM_AX
syscall
END_FUNC(usermode_stub)
Expand Down
9 changes: 8 additions & 1 deletion tests/unittests.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ static unsigned long __user_text test_user_task_func2(void *arg) {
return 0;
}

static unsigned long __user_text test_user_task_func3(void *arg) {
/* ensure tasks return code is correct */
return -16;
}

int unit_tests(void *_unused) {
printk("\nLet the UNITTESTs begin\n");
printk("Commandline parsing: %s\n", kernel_cmdline);
Expand Down Expand Up @@ -160,18 +165,20 @@ int unit_tests(void *_unused) {
cpu_freq_expect("Prototyp Amazing Foo One @ 1GHz", 1000000000);
cpu_freq_expect("Prototyp Amazing Foo Two @ 1.00GHz", 1000000000);

task_t *task1, *task2, *task_user1, *task_user2;
task_t *task1, *task2, *task_user1, *task_user2, *task_user3;

task1 = new_kernel_task("test1", test_kernel_task_func, _ptr(98));
task2 = new_kernel_task("test2", test_kernel_task_func, _ptr(-99));
task_user1 = new_user_task("test1 user", test_user_task_func1, NULL);
task_user2 = new_user_task("test2 user", test_user_task_func2, NULL);
task_user3 = new_user_task("test3 user", test_user_task_func3, NULL);

set_task_repeat(task1, 10);
schedule_task(task1, get_bsp_cpu());
schedule_task(task2, get_cpu(1));
schedule_task(task_user1, get_bsp_cpu());
schedule_task(task_user2, get_cpu(1));
schedule_task(task_user3, get_bsp_cpu());

printk("Long mode to real mode transition:\n");
long_to_real();
Expand Down

0 comments on commit 55e64e7

Please sign in to comment.