News for hackers. Stuff that matters.

Show HN: Running TempleOS in user space without virtualization

https://github.com/1fishe2fishe/EXODUS

TempleOS is an experimental OS designed to be simple and self-hosted with a JIT compiler. I was mesmerized by it but didn't like the hassle of using virtual machines to boot it up and move files around from the virtual drive.

My project lets you run TempleOS as an app of some sort instead of using a virtual machine to run it - this brings a lot of benefits like speed, seamless filesystem integration (virtual machine development with stock TempleOS is really a pain.), command-line mode where you can code in HolyC on the command line instead of TempleOS' GUI.

Its user-space nature lets it do networking quite easily with the FFI - it even features an IRC server, client and a wiki server!

I've also added a bunch of third-party games and software written for TempleOS on the Community folder, I hope you people take a look and enjoy!

( 37 comments | 5 points | on HN )
Re:Show HN: Running TempleOS in user space without virtualiz... by xmlparser on Friday April 12, 2024 @07:00AM (#40011229)
Oh wow, nice! Just a question, how do you manage memory for the OS? I thought operating systems needed whole control of the MMU.
Re:Show HN: Running TempleOS in user space without virtualiz... by 1fishe2fishe on Friday April 12, 2024 @07:22AM (#40011336)
That was actually a very easy part of EXODUS. Since TempleOS is basically a unikernel, it doesn't need any code for per-process virtual address space.

So I can just map some pages in the host process and the host process' address space becomes the HolyC kernel's entire address space, which is ironic since Terry was always adamant about how he disliked modern isolated per-process address spaces and that turned out to be a key to porting his OS to Ring 3.

I did need some code for "code pages" though - since all function calls in TempleOS use the 32 bit relative call instruction, all compiled HolyC code go in the lower 32 bit address space. Some Linux distros like to map the ELF binary at that address range too, so I have a routine to read /proc/self/maps and avoid mmapping those areas (I was surprised mmap can overlap without any signs).

Re:Show HN: Running TempleOS in user space without virtualiz... by xmlparser on Friday April 12, 2024 @07:37AM (#40011404)
Haha, that's like committing blasphemy to achieve a holy goal. I wonder what Terry or God would say about this.
Re:Show HN: Running TempleOS in user space without virtualiz... by mjgoeke on Friday April 12, 2024 @12:53PM (#40015032)
I'm guessing something along the lines of 1 Samuel 13:13 ;-)

https://www.bible.com/bible/114/1SA.13.13

Re:Show HN: Running TempleOS in user space without virtualiz... by artsi0m on Friday April 12, 2024 @05:03PM (#40017614)
Terry referenced the joke about web browsers, saying that as the most people use internet explorer to download firefox, he used Ubuntu with VMWare to run Temple OS. https://iv.ggtyler.dev/watch?v=IXhmu1aQSOY
Re:Show HN: Running TempleOS in user space without virtualiz... by evmar on Friday April 12, 2024 @04:46PM (#40017471)
Wine has a similar problem around needing to reserve the lower 32 bit address space for 32-bit executables.

I bookmarked their Mac workaround around here: https://github.com/wine-mirror/wine/blob/b2a099b3ceec6fef05c... which involves rearranging the zero page and creating a big WINE_RESERVE section.

On Linux it appears they use a -Ttext linker flag to reposition the code location, but I haven't read it too carefully: https://github.com/wine-mirror/wine/blob/b2a099b3ceec6fef05c...

Re:Show HN: Running TempleOS in user space without virtualiz... by 1fishe2fishe on Friday April 12, 2024 @08:27PM (#40019126)
That's one way to do it, dealing with linkers was really not my thing so I just get the mapped memory list [1] and set it as the start pivot then stack pages on top of it [2]. Thankfully the brk heap isn't intrusive enough to climb up into the pages I allocated :) (this is actually why Linux' MAP_32BIT mmap starts from 0x40000000 [3], but I didn't like how high it was and made it dynamic)

[1]: https://github.com/1fishe2fishe/EXODUS/blob/90f70386b8ac6bd0...

[2]: https://github.com/1fishe2fishe/EXODUS/blob/90f70386b8ac6bd0...

[3]: https://github.com/torvalds/linux/blob/8f2c057754b25075aa3da...

Re:Show HN: Running TempleOS in user space without virtualiz... by xmlparser on Friday April 12, 2024 @11:46PM (#40020316)
> Thankfully the brk heap isn't intrusive enough to climb up into the pages I allocated :)

That seems about right[1], but the MAP_FIXED_NOREPLACE flag has been a thing since Linux 4.17. What about using that?

[1]: https://godbolt.org/z/698dPcvf6

Re:Show HN: Running TempleOS in user space without virtualiz... by 1fishe2fishe on Friday April 12, 2024 @11:53PM (#40020352)
Thanks for the information, I wasn't aware of that! Seems like it's not available on FreeBSD though ;( I want to support as many OS'es as possible, but I'll still add a comment on that for future reference.
Re:Show HN: Running TempleOS in user space without virtualiz... by xyproto on Saturday April 13, 2024 @03:21AM (#40021206)
Could it be enabled with a define or other compile-time mechanism for Linux?
Re:Show HN: Running TempleOS in user space without virtualiz... by 1fishe2fishe on Saturday April 13, 2024 @05:07AM (#40021667)
Yeah, I could just use that flag on Linux and let the kernel do more work but I'm afraid I might have to add more logic for looping for a failed mmap only for linux, and more ifdefs usually mean I'm doing something wrong. I'd rather roll with my current strategy (finding a safe pivot and keep bumping without checking anything)
Re:Show HN: Running TempleOS in user space without virtualiz... by TheAmazingRace on Friday April 12, 2024 @10:43AM (#40013498)
I love how Terry's work continues to inspire developers to this day, even after he has left this mortal plane of existence.
Re:Show HN: Running TempleOS in user space without virtualiz... by gosub100 on Friday April 12, 2024 @03:42PM (#40016869)
You might even say it's "born again".
Re:Show HN: Running TempleOS in user space without virtualiz... by VelesDude on Friday April 12, 2024 @04:54PM (#40017544)
Urrrgh... that is so good and bad it hurts!
Re:Show HN: Running TempleOS in user space without virtualiz... by 1fishe2fishe on Friday April 12, 2024 @11:18PM (#40020203)
It's a great OS to play around with, after all. I know a guy that uses TempleOS to poke around his hypervisor's private internal data that's not exposed in the normal control interface because it's the one of the only "full" OS'es that allows unrestricted access to protected memory and lets you write programs and stuff in it in a relatively familiar language (HolyC).
Re:Show HN: Running TempleOS in user space without virtualiz... by Rendello on Saturday April 13, 2024 @05:03PM (#40026104)
I learned lower level programming through HolyC. I never know what to say when someone else wants to go from high to low as well, as people don't take my TempleOS suggestion too seriously ;)
Re:Show HN: Running TempleOS in user space without virtualiz... by nenadg on Friday April 12, 2024 @11:17AM (#40013896)
is this called a distro or denomination?
Re:Show HN: Running TempleOS in user space without virtualiz... by 1fishe2fishe on Friday April 12, 2024 @11:22AM (#40013954)
Sort of a "distro" I guess. It's basically TempleOS as an app.
Re:Show HN: Running TempleOS in user space without virtualiz... by davidgerard on Friday April 12, 2024 @04:33PM (#40017369)
still a better love story than Urbit
Re:Show HN: Running TempleOS in user space without virtualiz... by dinero_rojo on Friday April 12, 2024 @01:11PM (#40015225)
Was thinking it might just be a new rite if there weren’t any schisms or majors philosophical differences between fishe and TD (pbuh), but I think Mr. God did tell Terry not to bother with networking, so I think it would qualify as a separate denomination.
Re:Show HN: Running TempleOS in user space without virtualiz... by 1fishe2fishe on Friday April 12, 2024 @08:37PM (#40019197)
God actually didn't ban networking, contrary to popular belief [1]. He just didn't add network drivers to his OS because of all the network cards he'd have to support and cause the OS to bloat up. He stated "We need a network connection, possibly implemented as a super-simple high speed serial device." [2] so browsing the Internet isn't a sin after all ;)

[1]: https://old.reddit.com/r/TempleOS_Official/comments/2pzdy6/c...

[2]: https://web.archive.org/web/20170305000952/http://www.temple...

Re:Show HN: Running TempleOS in user space without virtualiz... by blueflow on Friday April 12, 2024 @03:23PM (#40016691)
Its an Operating System.
Re:Show HN: Running TempleOS in user space without virtualiz... by ktm5j on Friday April 12, 2024 @07:12PM (#40018589)
It's a joke..
Re:Show HN: Running TempleOS in user space without virtualiz... by LazarWolf_ on Friday April 12, 2024 @01:52PM (#40015676)
“Exodus”, what a great name for this project. Very cool.
Re:Show HN: Running TempleOS in user space without virtualiz... by 1fishe2fishe on Friday April 12, 2024 @11:12PM (#40020173)
There were a few candidates for this like "GENESIS - Godly Emulation Not Encountered, System Is Sacred", but that sounded way too biblical (you get my point), or "SANCTUM - Sacred Assembly for Navigating Computing Technology with Unity and Majesty" which was too long and felt almost condescending in a way and both didn't feel like it expressed what EXODUS does clearly enough.

After all, it's EXODUS is an "exodus" of the TempleOS kernel from ring 0 to 3, so I rolled with it.

Re:Show HN: Running TempleOS in user space without virtualiz... by valianteffort on Saturday April 13, 2024 @10:11AM (#40023264)
Terry was a devout christian, genesis would have been a good name too!
Re:Show HN: Running TempleOS in user space without virtualiz... by replwoacause on Saturday April 13, 2024 @01:02PM (#40024399)
And a devout racist
Re:Show HN: Running TempleOS in user space without virtualiz... by jazzyjackson on Saturday April 13, 2024 @02:24PM (#40024978)
and a suicidal schizophrenic, race hardly has anything to do with it
Re:Show HN: Running TempleOS in user space without virtualiz... by valianteffort on Saturday April 13, 2024 @05:32PM (#40026345)
Right because blacks are such rabid animals that we're gonna cry racism when it's clear he is mentally unwell. You can keep your reactionary savior bullshit, thanks.
Re:Show HN: Running TempleOS in user space without virtualiz... by replwoacause on Saturday April 13, 2024 @10:34PM (#40028214)
My comment wasn’t for your benefit.
Re:Show HN: Running TempleOS in user space without virtualiz... by keepamovin on Sunday April 14, 2024 @09:26AM (#40030898)
Ha! I doubt you do much for anyone's benefit at all. Hahaha! :)
Re:Show HN: Running TempleOS in user space without virtualiz... by replwoacause on Sunday April 14, 2024 @10:52AM (#40031500)
I'm in awe of your deep insight into my life and work.

Now make like your username and do one.

Re:Show HN: Running TempleOS in user space without virtualiz... by keepamovin on Monday April 15, 2024 @02:09PM (#40043809)
Ooh, ‘keep steppin’ — so threatening! Whaddayagonnado, bud?

You don’t like it or can’t take it? Don’t dish it out, pal. Hahaha! :)

Re:Show HN: Running TempleOS in user space without virtualiz... by Teever on Sunday April 14, 2024 @12:36AM (#40028701)
To me there's only two reasons why people bring this kind of thing up with regards to schizophrenic person's unacceptable behaviour -- either they have no qualms with taking cheap shots on someone they know to have a crippling mental disability, or they're oblivious to the suffering that this kind of mental illness causes.

So which is it? Do you understand that schizophrenia is a serious mental illness that can cripple an individuals ability to process reality and participate in society?

Re:Show HN: Running TempleOS in user space without virtualiz... by 1fishe2fishe on Monday April 15, 2024 @08:41PM (#40047210)
I hate how there's at least one discussion about how a clinically insane man on a disability check that got hit by a train said the n word and did insane things. I know that and his OS is what's best known about him but I really want people to not think about the former when discussing about the latter. Why would that even matter?
Re:Show HN: Running TempleOS in user space without virtualiz... by tjpnz on Saturday April 13, 2024 @08:22AM (#40022669)
If you're interested in learning operating systems or compilers the TempleOS source is surprisingly approachable and clocks in at around 100K LOC. I did a deep dive of HolyC while on a long bus drive and came away with a lot. Terry Davis often talked about the importance of simplicity (albeit using more colorful language) and you can see that throughout his work.
Re:Show HN: Running TempleOS in user space without virtualiz... by AstmmetryAware on Monday April 15, 2024 @12:28PM (#40042684)
Blessed work. Terry would be proud.