frno7 / linux

Linux 2.2, 2.6, 3.x, 4.x and 5.x kernels for the PlayStation 2.
Other
86 stars 5 forks source link

uLaunchELF unexpected CP0 Status user mode #7

Open frno7 opened 5 years ago

frno7 commented 5 years ago

The PlayStation 2 uLaunchELF starts the ELF Linux kernel in user mode with CP0 access enabled (CP0 Status 0x70030c11), which is unexpected. Commit b2159cbf965b12f09f30a853efb0ad9f2ddbb01b is a provisional workaround. Can this be fixed in uLaunchELF without breaking other ELF applications? Booting the Linux kernel without the workaround results in an early boot freeze, which is very difficult to debug.

See also #4.

sp193 commented 5 years ago

While homebrew software are free to change the operating mode of the EE, I am pretty sure that LaunchELF does not. This value you have, is likely set by the PlayStation 2 EE kernel. If PS2Linux requires something else, then you should change it during the bootup of the new kernel.

But what's wrong with having access to COP0?

frno7 commented 5 years ago

A MIPS Linux kernel developer thought that this CP0.Status combination was weird, and the Linux kernel will not boot with it, and if uLaunchELF acts as a boot loader it should be fixed if possible. If uLaunchELF cannot be fixed then having a small workaround in the Linux kernel (similar to commit b2159cbf965b12f09f30a853efb0ad9f2ddbb01b discussed above) is an obvious alternative, in my opinion, since having a new separate intermediate boot loader sitting between uLaunchELF and the Linux kernel just to correct CP0.Status would complicate the boot process.

sp193 commented 5 years ago

Yes, that would complicate the process. But I don't understand why the Linux kernel loader cannot change this value itself (how does it deal with undefined power-on defaults?) or why such a configuration would be a problem. There could be different options set for CP0 because the EE kernel is not Linux and Sony had their own standards.

I don't think it should be a change to be incorporated into LaunchELF because it only serves PS2Linux and has zero benefit for other software. It would have to be skipped if PS2Linux is not booted because it may cause the Sony EE kernel's behaviour to change, which could change the way other software work.

frno7 commented 5 years ago

Well, then it seems the best we can hope for is that the MIPS Linux kernel maintainers will accept a suitable CP0.Status workaround. Having #4 would be even better, because then uLaunchELF isn't needed at all.

uyjulian commented 1 year ago

I don't believe CP0 is set in rom0:EELOAD (program used by LoadExecPS2 to load ELF executables) or the loader.elf used by ps2sdk and wLE.

If CP0 is set somewhere in the EE kernel, then it might be possible to either patch that out or replicate the behavior.