Lazy page mapping issues
Jon Abbott (1421) 2651 posts |
I’ve been investigating why Wimp_Poll causes odd behaviour under ADFFS and tracked it down to two issues:
I’m assuming Task swapping / Lazy page mapping neither preserves page permissions or flush the TLB, so my dilemma is how to support Wimp apps under ADFFS? Is it sufficient to take a copy of the relevant L2PT entries in a Pre Filter and put them back in a Post Filter, followed by a TLB invalidate? Or will that break the OS as mapped memory will be out of sync with what the OS thinks is mapped in. Is there a way to quickly map all of Appspace in, short of touching every page? And is there a way to turn lazy paging off entirely for Appspace? |
Jeffrey Lee (213) 6048 posts |
The TLB doesn’t cache faulting entries (i.e. pages with no mapping), so no TLB invalidating is required.
True – AMBControl doesn’t make any attempt to preserve the settings. It’s something that should be easy enough to support now that AMBControl is built ontop of the PMP system – I can add it to my todo list. For older OS versions it won’t really be possible since the OS doesn’t have anywhere to store the permissions when the pages are mapped out.
That’ll almost certainly break the OS.
OS_AMBControl 5. Technically it’s for internal use only, but it hasn’t changed in the past 20 years so I doubt we’ll be changing the API any time soon. |
Jon Abbott (1421) 2651 posts |
In that case I’ll hold off trying to preserve page permissions and wait for the OS to handle it. It’s not a total loss, it only affects self-modifying code such as BASIC’s SYS, which I can modify to perform an OS_SyncroniseCodeAreas once it’s written the SWI instruction to memory – the JIT cache is getting out of sync with Appspace. |
Jeffrey Lee (213) 6048 posts |
Actually, that’s a lie, since it could preserve the permissions in the CAM (which is basically what I’m planning on making the current OS do). But it wouldn’t be a trivial thing to try and produce a patch for! |
Jon Abbott (1421) 2651 posts |
I’m only targetting the Pi for 26bit Wimp app support. AFAIK pre-RO5 OS don’t do lazy page mapping, so if I were to consider RO3.71 support, I’d probably just cache the L2PT appspace entries on a per app basis or even take over OS_AMBControl when its swapping to/from a 26bit app. A public interface to switch to a specific task would be useful at some point, so I can look at implementing a Hypervisor with PixieDust™ that can run OS builds targetted at ARM2/3/StrongARM. A lot of the issues ADFFS has to contend with go away if apps are running under a full Hypervisor, virtually all of the hypervised SWI code will no longer be required as it’s no longer translating between the OS and app to present a 26bitish OS. |
Jeffrey Lee (213) 6048 posts |
Lazy task swapping was introduced in RISC OS 4 (or 3.8?). https://stason.org/TULARC/pc/acorn-faq/1-15-What-is-Lazy-Task-Swapping.html |
Steve Pampling (1551) 8170 posts |
Long time ago,but wasn’t there a 3.7 era bug relating to that? |
Steffen Huber (91) 1953 posts |
I think I remember a connection with bugs in the StrongARM, where only Rev.T worked with the original lazy task swapping implementation in RO3.8. Maybe also Rev.S, but most SAs were a lot earlier (Rev.K?). Which would not have mattered for Phoebe of course, but mattered for RO4. I think it was initially disabled in RO4 and only enabled in Select 1, but I could be wrong. |
Jeffrey Lee (213) 6048 posts |
Yes, the OS will automatically disable lazy task swapping for the buggy StrongARM revisions. For 3.7 specifically, there shouldn’t be any lazy task swapping bugs (since it didn’t exist yet), but there are plenty of scary ROM patches (some also relating to StrongARM errata) |