Hacker News new | ask | show | jobs
by alehyze 1840 days ago
Thanks :-)

The article that got me started is the pdf taken from a conference called "OpenBSD Kernel Internals: The Hitchhiker's Guide" mentioned here: https://www.openbsd.org/events.html

I just checked the link and the site seems to be down for me now, so I refer you to that page. Hopefully it will come back up or the link will be updated.

In that article it describes how to add a syscall to openbsd. So you start by writing a very simple one just to see that it works and get comfortable rebuilding the kernel and testing your syscall with a userspace program.

Then, since I roughly knew what I wanted to achieve, I started looking at kernel code and finding the parts relevant to what I wanted to do.

Then take baby steps with your changes, try and fail until you succeed with a small bit before moving on to the next. Especially value failures, as they give you hints about what is going on. Think why it could have failed and try a different approach that should not fail in the same way. Very tedious and time consuming, but a very good way to learn when you don't have the books.

Then looked for hints on the web and talked to the awesome people on the mailing lists and on the reddit OpenBSD channel.

I did not talk too much to people though, I asked a few questions at the beginning and then had a short conversation about allocating contiguous physical memory to a userspace task, which is something that OpenBSD does not do. I figured out how to do that by myself, by trial and error. Same with other details.

My mindset was: I know how to do this with bare metal, there must be a way to connect to the kernel code and do the same in a way that does not break things too much if I keep it limited in scope.

I hope this helps :-)

1 comments

Yep, this is quite nice and helpful, many thanks!
:-)