Hacker News new | ask | show | jobs
by vsupalov 1183 days ago
I wondered about an adjacent topic recently ("what IS the kernel actually") and found out that a great way to understand it, would be to start with the boot process. Once I felt less lost, I tried to capture my learnings [1]

The text is not edited yet, but as I had the benefit of learning about it with fresh eyes, it should be very approachable (and hopefully accurate enough)

[1] https://vsupalov.com/demystifying-kernel/

1 comments

> It’s firmware time. Your machine has a motherboard, there is a chip on it which has had BIOS (Basic Input/Output System) flashed on it.

I wonder if it's worth it to call out the "processor microcode" firmware? Any cool startup things happen at that low level as well?

The microcode is mostly irrelevant, and is also opaque. It might be doing something but Intel won't give you more details beyond the programmer's reference model.

"Microcode" generally looks more like expanding a CISC instruction into other instructions, rather than something that looks like a program.

Extremely low level paper: https://www.researchgate.net/publication/295010710_Booting_a... ; good to confirm that Intel systems still boot at 0xFFFFFF0 in real (16-bit!) mode. It also points out that microcode updates are applied after execution has started.

There is also the fun of "cache as RAM"; it's usually quite a time consuming operation to get the DRAM controller up and running and "trained" to the particular signal properties of the motherboard, so the early boot phase has no RAM.

I knew it would boot at 16bit mode, I need to make an article.
There's indeed a lot of firmware (not just microcode). A bunch of code is signature-checked and executed from the boot ROM and firmware flash in order to bring up the CPU and its various auxiliary cores (starting with the security processor/management engine nowadays), the PCH and the DRAM controller - all before the CPU can start executing any bootloader code from RAM.
Way out of my depth! However, the stuff I saw the folks from Oxide [1] talk about comes to mind. Hardware stuff with Rust. If you want to look at a specific project, Hubris [2] is a kernel for "deeply-embedded" systems.

[1] https://oxide.computer/blog/building-big-systems-with-remote...

[2] https://github.com/oxidecomputer/hubris

Hubris is a part of booting on our systems in that it executes on both our root of trust and on our service processor -- but both of these execute long before the host CPU. To understand how we boot our host CPU (AMD Milan) on an Oxide compute sled, see my OSFC 2022 talk[0][1], as well as the episode of our Oxide and Friends podcast on holistic boot.[2]

[0] https://speakerdeck.com/bcantrill/i-have-come-to-bury-the-bi...

[1] https://www.osfc.io/2022/talks/i-have-come-to-bury-the-bios-...

[2] https://share.transistor.fm/s/24beb248

Thanks a lot for sharing! I ended up watching the referenced "It's Time for Operating Systems to Rediscover Hardware" talk as well. Fascinating stuff.