ghaststeam/MagicEMX

Virtualization VS. Emulation differences in approach?

Closed this issue · 9 comments

I notice people have suggested that virtualization is better since the PS4 OS could run on the same processor architecture as PCs. But wouldn't that not work because the GPU and other hardware will still need to be emulated? And would emulating the CPU in software not be very slow? If you combine that with the emulated GPU wouldn't it require too many resources to function even on the best processors?
I have also heard that virtualizing is harder to implement than emulation ... I tried reading comparisons but the difference between "process virtual machine" and "emulation" in general seems tricky to fully understand, specifically because process virtual machines are also emulators of some sort as well.

In short, what are these differences and how can PS4EMX utilize them?

We were going to implement emulation first as to enable a wider-range of portability among various platforms/architectures. With x86 virtualization concerns, we're initially tied to x86. While that method will certainly work better, it'll be harder to get right at this time, and full software-emulation will replace the entire construct of the hardware without needing to be concerned as much about the underlying hardware. Not to mention that with emulation we'd have more freedom to experiment with emulation of the CPU and its intricacies, functions, etc., and with virtualization we can't do that and may have various problems since we don't know exactly what the limitations are of the customization done to the PS4's processor. And with emulation to start with it will make better inter-compatibility and operability between the emulated hardware more feasible than virtualization methods, which will be harder to get right and have everyone focus on one platform too strictly. When emulation matures very much and makes its way for cross-platform functionality, then tailoring virtualization access will greatly improve speeds and performance capabilities one day for x86-64.

Yeah, the MediaCon is (according to my own research and some top-notch hackers) the main CPU that boots and initializes the system. There is a good chance that hardware-assisted security could be present there, along with the main AMD chip. Still, though, generic emulation of them will prove worthwhile and when I get some time I'll try and improve on the MediaCon's ARM emulation, the AMD/x86-64 counterparts, and the memory and such.

Could you run the OS without virtualization using emulation only?

Yes, you could.

You could use dynamic recompilation with an interpreter fallback for better performance on supported platforms with no portability loss.

Dynamic recompilation will work with the MediaCon eventually (on x86), and a similar method can be implemented by the GPU later on as well, but for PSSL and shading to OpenGL/DirectX; however, neither of these are of importance now. Interpretation of everything is the (slow) but efficient way all processing cores will be emulated initially, and cross-platform functionality will hopefully be (generally) faultless.

Yeah, I do agree that a complete interpreter should be made before starting on a dynarec, though I might try to make the interpreter simpler by converting the x86 instruction set to a simpler form before interpretation. This will most likely make the interpreter easier to maintain, but the real hard part of this will come to finding patterns in the x86 opcode encoding. I'll see what I can do.

Dolphin has a JIT dynarec for PowerPC (Gamecube/Wii/Triforce/etc. emulator) that has a core mode for intermediate language translation, which is pretty much what you're describing. The success of it won't be easy to determine, as, in some cases, it can be more trouble than not. The same thing would be applicable to an interpreter, I suppose. But go ahead if you want to try and begin implementing something like that; might prove very effective in the long run. Note that I am having Git issues now so I won't be able to merge any pull requests until I resolve the issue and get some time (probably tomorrow).

Couldn't figure out ... my computer's dead. Need a new one. Anyways, this issue seems to be done with.