Misc Horizon Linux - Running Switch Games Natively on ARM64 Linux

Joom

 ❤❤❤
OP
Member
Joined
Jan 8, 2016
Messages
6,067
Trophies
1
Location
US
Website
mogbox.net
XP
6,077
Country
United States
Kinda surprised this hasn't made its round here yet. Over at Reddit, u/kentjhall has announced a rather ambitious project. They're patching the ARM64 Linux kernel in order to be able to play Switch games natively. So far, the first commercial game they've got running is Puyo Puyo Tetris. If this project gets further traction, this is going to be huge.

From their post:
What?
Over the past while, I’ve worked on-and-off in my free time patching the arm64 Linux kernel to run Nintendo Switch games natively, i.e. by taking many of the Switch’s “Horizon” OS system calls and implementing their behavior using Linux’s existing facilities for memory management, scheduling, synchronization, etc.

Why?
Well my original thought was merely that I wanted to run Switch games on my MacBook—given that they’re powered by the same arm64 architecture, you should be able to run a Switch game’s machine code right on the CPU, no x86 translation layer needed. I was hoping to be able to achieve this entirely in user-space by attaching (via ptrace) to a process executing the Switch game’s code, and trapping any system calls to the tracer process. But if I recall, this quickly proved infeasible without OS support for various reasons to do with a Switch program’s use of system registers. If I’d have to poke around the OS anyway, I figured I might as well just handle everything within the kernel—then I’d just virtualize said OS under macOS.

Patching arm64 Linux means that you get Linux’s vast hardware driver support for free, so not only can it be virtualized on Apple silicon Macs, but it can run bare-metal on any arm64 hardware which supports Linux—even on lower-end hardware, given that there’s no need to emulate the CPU. This should offer a good deal of flexibility in the future for running Switch games, and hopefully will prove a useful option for game preservation.

Note that this is not an attempt to accurately recreate the Horizon OS, nor is it particularly intended to run on an actual Switch, as (I believe) is the case is for the Mesosphere project (though you probably could, I’m aware that the Switch can run Android at least). Rather, Horizon Linux is my attempt to enable Switch games to run on any arm64 hardware.

How?
In addition to OS support in handling Horizon system calls, a Switch program needs to be able to communicate with a number of system services that handle things like input, audio, graphics, etc. Rather than reinvent the wheel, I figured the easiest approach would be to take the open-source yuzu emulator and gut out the things I didn’t need (namely, kernel / CPU emulation), essentially keeping only the system services, GPU emulation, and app loader. This necessitated a custom system call interface to interface with kernel, and a custom Linux binary format for the loader to work with. I also decided (perhaps unnecessarily) to deviate from yuzu’s model and have each system service run persistently in it’s own thread, which made my reorganization considerably more involved.

The custom Linux kernel is called “Horizon Linux”, and the yuzu hack-job is called “mizu”. Mizu is intended to run as a systemd service under Horizon Linux.

Source
Horizon Linux on GitHub
 

Jayro

MediCat USB Dev
Developer
Joined
Jul 23, 2012
Messages
13,046
Trophies
4
Location
WA State
Website
ko-fi.com
XP
17,229
Country
United States
Wow, this is really cool. I'd love to see this come along and eventually see switch games on more ARM64 devices. Especially ARM-based SBCs.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • Quincy @ Quincy:
    Usually when such a big title leaks the Temp will be the first to report about it (going off of historical reports here, Pokemon SV being the latest one I can recall seeing pop up here)
  • K3Nv2 @ K3Nv2:
    I still like how a freaking mp3 file hacks webos all that security defeated by text yet again
  • BigOnYa @ BigOnYa:
    They have simulators for everything nowdays, cray cray. How about a sim that shows you playing the Switch.
  • K3Nv2 @ K3Nv2:
    That's called yuzu
    +1
  • BigOnYa @ BigOnYa:
    I want a 120hz 4k tv but crazy how more expensive the 120hz over the 60hz are. Or even more crazy is the price of 8k's.
  • K3Nv2 @ K3Nv2:
    No real point since movies are 30fps
  • BigOnYa @ BigOnYa:
    Not a big movie buff, more of a gamer tbh. And Series X is 120hz 8k ready, but yea only 120hz 4k games out right now, but thinking of in the future.
  • K3Nv2 @ K3Nv2:
    Mostly why you never see TV manufacturers going post 60hz
  • BigOnYa @ BigOnYa:
    I only watch tv when i goto bed, it puts me to sleep, and I have a nas drive filled w my fav shows so i can watch them in order, commercial free. I usually watch Married w Children, or South Park
  • K3Nv2 @ K3Nv2:
    Stremio ruined my need for nas
  • BigOnYa @ BigOnYa:
    I stream from Nas to firestick, one on every tv, and use Kodi. I'm happy w it, plays everything. (I pirate/torrent shows/movies on pc, and put on nas)
  • K3Nv2 @ K3Nv2:
    Kodi repost are still pretty popular
  • BigOnYa @ BigOnYa:
    What the hell is Kodi reposts? what do you mean, or "Wut?" -xdqwerty
  • K3Nv2 @ K3Nv2:
    Google them basically web crawlers to movie sites
  • BigOnYa @ BigOnYa:
    oh you mean the 3rd party apps on Kodi, yea i know what you mean, yea there are still a few cool ones, in fact watched the new planet of the apes movie other night w wifey thru one, was good pic surprisingly, not a cam
  • BigOnYa @ BigOnYa:
    Damn, only $2.06 and free shipping. Gotta cost more for them to ship than $2.06
    +1
  • BigOnYa @ BigOnYa:
    I got my Dad a firestick for Xmas and showed him those 3rd party sites on Kodi, he loves it, all he watches anymore. He said he has got 3 letters from AT&T already about pirating, but he says f them, let them shut my internet off (He wants out of his AT&T contract anyways)
  • K3Nv2 @ K3Nv2:
    That's where stremio comes to play never got a letter about it
  • BigOnYa @ BigOnYa:
    I just use a VPN, even give him my login and password so can use it also, and he refuses, he's funny.
  • BigOnYa @ BigOnYa:
    I had to find and get him an old style flip phone even without text, cause thats what he wanted. No text, no internet, only phone calls. Old, old school.
  • Psionic Roshambo @ Psionic Roshambo:
    @BigOnYa, Lol I bought a new USB card reader thing on AliExpress last month for I think like 87 cents. Free shipping from China... It arrived it works and honestly I don't understand how it was so cheap.
    +1
    Psionic Roshambo @ Psionic Roshambo: @BigOnYa, Lol I bought a new USB card reader thing on AliExpress last month for I think like 87... +1