Oxide and Friends

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
thewrongchristian
Member
Member
Posts: 471
Joined: Tue Apr 03, 2018 2:44 am

Oxide and Friends

Post by thewrongchristian »

Interesting Oxide and Friends podcast:

https://oxide-and-friends.transistor.fm ... corruption

It's a slow burn to get to the ultimate root cause, but worth a listen.

In summary, the episode is about tracking down an issue causing data corruption in their firmware bootstrap system, but seemingly at random. A cautionary tail for budding OS developers, but I won't add spoilers right now.
thewrongchristian
Member
Member
Posts: 471
Joined: Tue Apr 03, 2018 2:44 am

Re: Oxide and Friends

Post by thewrongchristian »

thewrongchristian wrote: Sat Jul 12, 2025 4:09 am Interesting Oxide and Friends podcast:

https://oxide-and-friends.transistor.fm ... corruption

It's a slow burn to get to the ultimate root cause, but worth a listen.

In summary, the episode is about tracking down an issue causing data corruption in their firmware bootstrap system, but seemingly at random. A cautionary tail for budding OS developers, but I won't add spoilers right now.
Spoiler:

The code in question was invalidating a kernel level TLB mapping for a page, but doing so before the corresponding page table entry was cleared. They did it in this order on the assumption that they wouldn't be referencing the page again in their code.

But, before they got to clearing the PTE, they were getting an interrupt, the ISR contained code that speculatively was referencing the page being invalidated, and that speculative reference was reloading the TLB from the still valid PTE.

The TLB entry remained, because it wasn't being further invalidated, even though the page table had no valid entry for the page. So any references to that page were referring to some now phantom PTE, until some other mechanism invalidated it.

TL; DR

Remove your PTE from the page table, then invalidate the TLB.
User avatar
eekee
Member
Member
Posts: 960
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Oxide and Friends

Post by eekee »

Interesting, thanks. I saw speculative execution was involved. Every time I hear of a spec exec bug, I get more interested in embedded and ancient hardware! ;) But I'm making a note about it anyway.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
Post Reply