wiremod / wire-cpu

Legacy CPU/GPU/SPU as a separate addon.
Apache License 2.0
8 stars 6 forks source link

Precompile now checks using physical addresses rather than XEIP #60

Closed DerelictDrone closed 1 month ago

DerelictDrone commented 1 month ago

As the title implies, this switches use of XEIP(CS + IP) out for the Physical Address of the memory, which makes addresses consistent when running with paging enabled and remapping.

This fixes an issue where the CPU would "hallucinate" that it was still capable of running code that, according to the page remapping, shouldn't be there (if you were to try and make a different program run at address 0 by switching page tables, it would think it was running the cpu code at physical address 0 because it was already precompiled and didn't understand the difference between the virtual CS:IP and the physical address)

Added additional checks to try and invalidate an address if a function/precompile straddles a page border and the user tries to execute it after remapping a portion of the function to a different page. Forcing it to precompile again starting at the straddled page border(and the previous section that lead us here if we were to run that again)

Adds a check to trigger interrupt 15(bad address) if you try to execute from a page that's not a whole integer (Check is performed at precompile, error is triggered at execution time)

DerelictDrone commented 1 month ago

I forgot that 0 is truthy in lua for some reason, every other page remap check does Remapped == 1