Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ make boot

You may need to install the following (unless you already have it):
* GRUB2 bootloader tools - `grub2-common` package (e.g. `apt install grub2-common`)
* ISO generation tools - `xorriso` package (e.g. `apt install xorriso`)
* ISO generation tools - `xorriso` and `mtools` package (e.g. `apt install xorriso mtools`)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mtools is needed for creating the ISO via grub-mkrescue? If so, you should mention that in the commit log, at least. However, it should already had been installed via the grub2-common package, as that depends on grub-common which "suggests" mtools. But yeah, it's not a strong dependency, so we may want to make it explicit.

#### Kernel image build (for example to be used with QEMU)

Expand Down
9 changes: 7 additions & 2 deletions common/usermode.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ static inline void syscall_restore(void) {
}

static inline long syscall_return(long return_code) {
register long ret asm(STR(_ASM_AX)) = return_code;
return ret;
/* clang-format off */
asm volatile(
"mov %[ret], %%" STR(_ASM_AX) "\n"
::[ret] "r"(return_code)
);
/* clang-format on */
return return_code;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WTF is this?! Why isn't this a simple return return_code?.... Oh, I see. syscall_handler(), what a bummer! It does the right thing only by chance. We'd better rewrite that think with a ASM thunk instead of this fragile register pinning code (gcc is free to reuse these registers, you know ;)).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right of course, the current implementation of syscall handling is indeed quite fragile. I plan to improve it all at some point.


static inline void stack_switch(void) {
Expand Down