Add tests for tasks.
This commit is contained in:
parent
8bbd292e9a
commit
033efd7a02
6
Makefile
6
Makefile
@ -98,8 +98,10 @@ debug-nox: image.bin
|
|||||||
-ex "break _start" \
|
-ex "break _start" \
|
||||||
-ex "continue"
|
-ex "continue"
|
||||||
|
|
||||||
fs.img: ./kernel.bin ./tools/mkfs ./user/false ./user/greet ./user/div0 ./user/shout
|
USERPROGS=./user/false ./user/greet ./user/div0 ./user/shout ./user/badputs ./user/bss
|
||||||
./tools/mkfs $@ $< ./user/false ./user/greet ./user/div0 ./user/shout
|
|
||||||
|
fs.img: ./kernel.bin ./tools/mkfs $(USERPROGS)
|
||||||
|
./tools/mkfs $@ $< $(USERPROGS)
|
||||||
|
|
||||||
LDFLAGS=-m elf_i386
|
LDFLAGS=-m elf_i386
|
||||||
|
|
||||||
|
|||||||
7
tasks.md
7
tasks.md
@ -62,7 +62,8 @@ Yabloko does not honor the size of `.bss` that your program requests.
|
|||||||
Instead, it [reads your program file](https://gitlab.myltsev.ru/caos/hw/yabloko/-/blob/main/proc.c#L53)
|
Instead, it [reads your program file](https://gitlab.myltsev.ru/caos/hw/yabloko/-/blob/main/proc.c#L53)
|
||||||
into memory, reserving just enough pages that it fits. If you create a large
|
into memory, reserving just enough pages that it fits. If you create a large
|
||||||
`.bss` with (for example) `static char zeroes[8000]`, then accessing `zeroes[7000]` will
|
`.bss` with (for example) `static char zeroes[8000]`, then accessing `zeroes[7000]` will
|
||||||
cause a page fault (try this out).
|
cause a page fault (try running the program in `user/bss.c` by typing `run bss` at
|
||||||
|
the Yabloko prompt).
|
||||||
|
|
||||||
Fix this by parsing the header of the executable file and mapping the required amount
|
Fix this by parsing the header of the executable file and mapping the required amount
|
||||||
of pages. We already have the header structure `hdr` in [proc.c](https://gitlab.myltsev.ru/caos/hw/yabloko/-/blob/main/proc.c#L58).
|
of pages. We already have the header structure `hdr` in [proc.c](https://gitlab.myltsev.ru/caos/hw/yabloko/-/blob/main/proc.c#L58).
|
||||||
@ -83,7 +84,7 @@ This task requires understanding of virtual memory mappings and the memory
|
|||||||
layout of Yabloko. Contact [@myltsev](https://t.me/myltsev) if you attempt
|
layout of Yabloko. Contact [@myltsev](https://t.me/myltsev) if you attempt
|
||||||
this and get stuck.
|
this and get stuck.
|
||||||
|
|
||||||
The `shout` executable [demonstrates](https://gitlab.myltsev.ru/caos/hw/yabloko/-/blob/main/user/shout.c#L14)
|
The `badputs` executable [demonstrates](https://gitlab.myltsev.ru/caos/hw/yabloko/-/blob/main/user/badputs.c#L14)
|
||||||
the use of the `SYS_puts` system call. It supplies the string pointer as an argument
|
the use of the `SYS_puts` system call. It supplies the string pointer as an argument
|
||||||
of the system call, and the string is printed to the screen.
|
of the system call, and the string is printed to the screen.
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ It is easy to cause a panic by supplying a random value:
|
|||||||
|
|
||||||
Your task is to check if the pointer actually points to a valid zero-terminated string,
|
Your task is to check if the pointer actually points to a valid zero-terminated string,
|
||||||
completing a [FIXME](https://gitlab.myltsev.ru/caos/hw/yabloko/-/blob/main/cpu/idt.c#L124)
|
completing a [FIXME](https://gitlab.myltsev.ru/caos/hw/yabloko/-/blob/main/cpu/idt.c#L124)
|
||||||
in the code.
|
in the code. As a result, `run badputs` should no longer cause a kernel panic.
|
||||||
|
|
||||||
### Figuring out the size of mapped memory after the pointer
|
### Figuring out the size of mapped memory after the pointer
|
||||||
During the handling of this system call, the page table of the calling process
|
During the handling of this system call, the page table of the calling process
|
||||||
|
|||||||
9
user/badputs.c
Normal file
9
user/badputs.c
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include "../syscall.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
const char* message = "I hope the kernel does not panic...\n";
|
||||||
|
syscall(SYS_puts, (uint32_t)message);
|
||||||
|
syscall(SYS_puts, 0x1bad1dea);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
8
user/bss.c
Normal file
8
user/bss.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "../syscall.h"
|
||||||
|
|
||||||
|
static char zeroes[8000];
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
zeroes[7999] = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user