Live data from Hacker News

Interview with Andreas Kling of Serenity OS (2022)

corecursive.com

51–60 of 181 posts

Re: Interview with Andreas Kling of Serenity OS (2022)

#51
post #46

Earlier quoted context omitted.

To be fair there is a lot you can do in userland. Graphics protocols, package management, isolation, security etc. And even more can be done by incrementally patching the kernel where needed. It's just that Linux is kind of usable out of the box with just the kernel and /bin/sh. But for other OSes this isn't true, the kernel can expose a vastly different interface than the actual os which users interact with.

I've done every bit of the kernely/cgroupy/bpf/vfio/syscall stuff for a long time and I honestly don't think I could tell you pretty much anything about building an OS. I actually came into this thread thinking, "damn, I have no idea specifically WHAT I would do/not do if I made an OS, or where to even start" not that I could at all. But I mean feature-wise, etc. Like, it's obviously a ton of apis that you call to in…

Don’t look at c specifically, look at syscalls. This is the real api of the operating system. It will also be confusing probably, since it is in some senses like thinking about how functions are implemented in assembly, but you don’t have to focus on the mechanics of how they work if that confuses you. One interesting exercise might be thinking about how syscalls are used to make up the standard library functions you are more familiar with.

Re: Interview with Andreas Kling of Serenity OS (2022)

#53
post #46

Earlier quoted context omitted.

I've done every bit of the kernely/cgroupy/bpf/vfio/syscall stuff for a long time and I honestly don't think I could tell you pretty much anything about building an OS. I actually came into this thread thinking, "damn, I have no idea specifically WHAT I would do/not do if I made an OS, or where to even start" not that I could at all. But I mean feature-wise, etc. Like, it's obviously a ton of apis that you call to in…

I have always found it interesting how people who come from the top down (software -> hardware) get confused by the low level stuff, and myself who came from the bottom up (hardware -> software) gets so confused by non-low-level code. I.e. I have no idea how to write a program for windows, it's totally alien to me and I cannot make sense of the code.

Perfect! I've worked with a lot of C kernel security devs and I don't think I've ever seen one of them write something not Cish, like python/ruby/go/etc.

So, what exactly happens here - you need to write a kernel in some super fast low level language like C. I THINK The kernel that you write is probably talking to, for instance an Intel/AMD CPU, Motherboard, GPU, etc API to access the hardware.

Is this close/wrong?

If I made a completely new kernel how do I boot it? Does the kernel have its own API that the BIOS calls? Does the BIOS have anything to do with the kernel but instead something starts Windows and that loads the kernel? I think the kernel mounts/becomes aware of all of the hardware (apis?) potentially by the motherboard telling it what's on it. Does the BIOS just start any C app you point it at and they're just C apps that start the kernel?

Maybe it goes through the motherboard for most of it.. Maybe it accesses every piece of hardware directly without an API somehow?

This may be stupid questions but hopefully they make sense.. And thanks if you or anyone has input!

edit: There's a Boot processing of linux Wiki [1] thats pretty good

> After being loaded into RAM, bootloader (also called first-stage bootloader or primary bootloader) will execute to load the second-stage bootloader[2] (also called secondary bootloader).[6] The second-stage bootloader will load the kernel image into memory, decompress and initialize it then pass control to this kernel image.[2] Second-stage bootloader also performs several operation on the system such as system hardware check, mounting the root device, loading the necessary kernel modules,...[2] Finally, the very first user-space process (init process) starts, and other high-level system initializations are performed (which involve with startup scripts).[2]

> For each of these stages and components, there are different variations and approaches; for example, GRUB, coreboot or Das U-Boot can be used as bootloaders (historical examples are LILO, SYSLINUX or Loadlin), while the startup scripts can be either traditional init-style, or the system configuration can be performed through modern alternatives such as systemd or Upstart.

> The intermediate stage loader (stage1.5, usually core.img) is loaded and executed by the stage1 loader. The second-stage loader (stage2, the /boot/grub/ files) is loaded by the stage1.5 and displays the GRUB startup menu that allows the user to choose an operating system or examine and edit startup parameters. After a menu entry is chosen and optional parameters are given, GRUB loads the linux kernel into memory and passes control to it. GRUB 2 is also capable of chain-loading of another bootloader. In UEFI systems, the stage1 and stage1.5 usually are the same UEFI application file (such as grubx64.efi for x64 UEFI systems).

[1] - https://en.wikipedia.org/wiki/Booting_process_of_Linux#:~:te....

[2] - https://www.gnu.org/software/grub/manual/grub/html_node/Imag...

[3] - Potentially how systemd starts installing the kernel https://github.com/ivandavidov/systemd-boot/blob/master/proj...

[4] - This looks like it's a TPM authentication shim that sits between the EFI and Kernel - https://github.com/ivandavidov/systemd-boot/blob/5521e37e77a...

[5] - Ok this is super helpful, a project on writing a minimal kernel - https://www.codeproject.com/Articles/1225196/Create-Your-Own...

[6] - And wow the GNU bootloader spec is rough - https://www.gnu.org/software/grub/manual/multiboot/multiboot...

Re: Interview with Andreas Kling of Serenity OS (2022)

#55
post #53

Earlier quoted context omitted.

I have always found it interesting how people who come from the top down (software -> hardware) get confused by the low level stuff, and myself who came from the bottom up (hardware -> software) gets so confused by non-low-level code. I.e. I have no idea how to write a program for windows, it's totally alien to me and I cannot make sense of the code.

Perfect! I've worked with a lot of C kernel security devs and I don't think I've ever seen one of them write something not Cish, like python/ruby/go/etc. So, what exactly happens here - you need to write a kernel in some super fast low level language like C. I THINK The kernel that you write is probably talking to, for instance an Intel/AMD CPU, Motherboard, GPU, etc API to access the hardware. Is this close/wrong? I…

Unfortunately I have never written low level code for a CPU. I have a background in electronics and mainly work with microcontrollers, where everything is C or assembly and you work directly with all the registers in binary/hex.

I know fundamentally it's all the same in regular computers, but I am unfamiliar with the structure of it.

Re: Interview with Andreas Kling of Serenity OS (2022)

#56

> But at least in my case, whenever I tell people about some idea, I kind of tend to lose interest in the idea. So I just went to work on it instead. I think that's great advice.

I agree. I've learned that it's best if I don't tell people my ideas until I've at least started to work on them unless I need to pick someone's brain.

Re: Interview with Andreas Kling of Serenity OS (2022)

#57
post #53

Earlier quoted context omitted.

Perfect! I've worked with a lot of C kernel security devs and I don't think I've ever seen one of them write something not Cish, like python/ruby/go/etc. So, what exactly happens here - you need to write a kernel in some super fast low level language like C. I THINK The kernel that you write is probably talking to, for instance an Intel/AMD CPU, Motherboard, GPU, etc API to access the hardware. Is this close/wrong? I…

Unfortunately I have never written low level code for a CPU. I have a background in electronics and mainly work with microcontrollers, where everything is C or assembly and you work directly with all the registers in binary/hex. I know fundamentally it's all the same in regular computers, but I am unfamiliar with the structure of it.

Cool no worries. Embedded stuff is really cool I've always been curious about that stuff on like, assembly lines, etc. I updated my comment you're replying to with a bunch of details if you're interested.

Re: Interview with Andreas Kling of Serenity OS (2022)

#58
I'd focus on high level APIs, managed code and JIT, and stuff like that, and everything would be written in Rust plus a scripting language for everything that isn't performance critical.

More realistically, I just wouldn't build an OS either. That would be a nightmarishly large project!

Re: Interview with Andreas Kling of Serenity OS (2022)

#59
post #50

Figured I would write this here, but I would scratch the concept of a file system and replace it with a database.

I would like to scrap the idea of a file and replace it with an object. If it's a "file" it just regurgitates it's contents, but it could also return aspects of itself, decrypt itself, stream from an offscreen resource. Just let them be smart, and what we know as sending "files" would just become object serialisation.

Re: Interview with Andreas Kling of Serenity OS (2022)

#60
post #41

Earlier quoted context omitted.

One problem with 2. is that subscribing to changes isn't always good enough, since if you go to act on the changes things may update out from under you regardless. Like, if you react to filesystem events, if a new file is created you might have it get deleted before you even register that it was added and do whatever you wanted with it.

I feel like it should be possible to say "I want to reserve access to this resource when something important happens on it". Or just "I want to reserve access to this resource". Hopefully eliminates TOCTOU races. I guess then there have to be different modes to balance scalability/flexibility.

When people complain about antivirus and endpoint security applications slowing their computer down, this is what they're talking about. This leads to user-visible delays (which, to them, seem to be random) as the reserver does what it wants right after the user has done something to the file. Many (most? ALL?) apparent Explorer stalls are really Windows Defender locking and scanning the file right after you did something to it.
Post reply on HN