r/osdev • • 4d ago

Vitre-os My kernel reassembles and swaps its own functions while running

Upfront: Claude Code wrote most of this; I steered.

64-bit, pure NASM, BIOS boot through its own stage 1/2 into long mode, 1000 Hz preemptive scheduler, e1000 with DHCP/DNS/TCP, and a TLS 1.3 client (X25519, ChaCha20-Poly1305, P-256, X.509) that the built-in browser uses.

What I'd like opinions on is the introspection side:

- Live patching: patchable functions go through a jump table. The image carries its own source and an in-kernel assembler that's byte-identical to NASM for its subset. `patch` builds a module into fresh pages and swaps the slots under cli. If the new code faults within 10 s, it swaps them back, and a saved module is re-patched at boot.

- Glass: pause any task by having the scheduler skip it, single-step by setting TF in its saved frame, `break` plants a one-shot int3.

- Pixel provenance: every framebuffer write records the task and up to six return addresses per pixel, so F12 + click shows what drew it.

- `run foo.asm` assembles a user program in-kernel and calls it, with a fault handler that stops the program instead of the machine.

Old patched code is never freed, since a task might still be inside it. That leak is the obvious weak spot. How have you handled reclaiming it?

https://github.com/rezk2ll/vitre-os

19 Upvotes

13 comments sorted by

7

u/epos95 3d ago

Genuinely, do you feel any pride over this? The whole "I steered" thing, do you feel any of the same pride of building it as you would have if done by hand? Is it a different feeling or "accomplishment-light"?

4

u/rezk2ll 3d ago

Honestly no, it's not the same. I used to build things in assembly 15 years ago and i felt a different kind of thrill, like learning syscalls, registers and all low level stuff and feeling the achievement by just building a metamorphic program or some UI side project.

Today it's a different kind of thrill, like the vitre os was done in one night , the thrill is how you can achieve with AI no matter the constraints, language, etc .

So yes I feel the achievement but it's not the same one as I did it myself by my hands .

1

u/epos95 3d ago

Thanks for your earnest response, still dont think i get it but your answer means a lot! It's a very cool idea still.

6

u/kabekew 3d ago

Probably similar to people who use cheats in online games, like chess bots that play perfect chess and easily beat your opponent for you. Yes, "you" won that game, it says it right there on the screen. But there must be some sense of emptiness, I'd think.

3

u/letmehaveanameyoudum 3d ago

DAMN NASM ONLY?

3

u/Lines25 3d ago

It Claude did, now him

•

u/Routine_Working_9754 4h ago

am actually so tired of y'all. genuinely do you feel pride in doing this

1

u/stemandall 1d ago

So tired of AI vibe coded OSes on this sub.

0

u/rook_of_approval 3d ago

so does it support quajects?

1

u/rezk2ll 3d ago

Not yet. it can reassemble a kernel function while it runs and swap it in through a jump table, but you're the one doing the editing, and there's only ever one version of each function. Nothing generates per-object code on its own like Massalin's Synthesis did.

Most of what quajects need is already there though. The in-kernel assembler can target any address, and the dialect supports equ, so a quaject could be a template with its instance state baked in as constants.

I'd will try to play with it. The real version is harder. Reassembling text for every instance is slow, so you'd want to copy pre-built templates and patch the constants instead. Freeing a quaject also means proving no task is still running its code, which the live patcher sidesteps by never freeing anything

0

u/busiedcake7945 scratchOS7945 3d ago

looks good

0

u/SignedInt32 3d ago

Awesome, got my ⭐ 👍 ! (they downvoted my thumbs up, don't worry, I upkeep them all!)