New kernel post! This time: /proc/*/mem and how it writes to unwritable mem.
Key takeaway: By walking page tables in software, the kernel can access userspace mem without directly dereferencing pointers it gets from userspace. (No WP/SMAP bits involved). https://t.co/U9IOeyHIc5
it would be cool if binary ninja had a kernel mode
in userspace it's correct that `hlt` would end execution
but contrary to popular belief, `hlt` in the kernel does not turn the computer off or something
it just sleeps the core until the next interrupt. and then continues!
this is why it's so fun to have a hobby os! you can do ring zero experiments and play with the cpu directly =)
and the end result:
a fully working integration test for preemption
which opts into having the timer interrupt
and existing tests are undisturbed :)
thx. follow for weekly systems programming content from the trenches 🫡
week 142, streaming OS dev (c++)
topic: preemption integration tests
one of my key principles is strong kernel test infrastructure
this week i continued exploring tests for preemptive multitasking
i found a good solution for per-test kernel configs!
here's how it works:
so that's how it works
i use Snitch tags to annotate each test with strings
This can inform the early test code how to config the kernel
which leads to the holy grail:
- kernel init'd exactly once, no reinit
- test can run, do arbitrary kernel stuff, ret back to framework
@ariccio Ok, then i don't actually understand your original comment in this thread. The brace init for Kernel is intentional. The placement new is intentional. The c style cast for the buffers arg is not intentional and just an artifact of the current prototype, not very important
week 141, streaming OS dev (c++)
topic: preemption tests
one of my key principles is strong kernel test infrastructure
this week i explored integration tests for preempt multitasking
few hobby OSes do this. and I can see why! it's hard
here's my problem solving process:
@ariccio start lifetime as is not correct here. i don't want to simply start a lifetime without running ctor, i want to start a lifetime at an address and run ctor