VOGONS


First post, by superfury

User metadata
Rank l33t
Rank
l33t

Is the #GP/#SS fault used in any case with modern operating systems, but for other effects than terminating the offending program/driver/OS?

I can imagine handing #NP/#SS for dynamically loading segments into memory(when swapped out), but modern operating systems might not use them anymore? Do operating systems like Windows 10 still support it(for 3.x programs)?

UniPCemu Git repository
UniPCemu for Android, Windows and PSP on itch.io
Older UniPCemu PC/Android/PSP releases

Reply 1 of 8, by Stenzek

User metadata
Rank Newbie
Rank
Newbie

As far as I'm aware, not really, modern OS's just use a flat address space. Even things like stack overflows are checked via the paging unit. The FS/GS segments can be used for thread-local or process-local storage (basically a base pointer which is indexed).

Swapping in/out is also done via paging. Considering there's WRGSBASE/WRFSBASE instructions in x86_64, I would be surprised if they had more than a handful of segment descriptors (CS for user/kernel-mode, DS, probably shared with SS, user/kernel, and that's about it).

Reply 2 of 8, by canthearu

User metadata
Rank Oldbie
Rank
Oldbie
superfury wrote:

Is the #GP/#SS fault used in any case with modern operating systems, but for other effects than terminating the offending program/driver/OS?

Absolutely used in paging and memory allocation. A #GP is raised if the program tries to access memory that isn't currently allocated/loading in. The OS will then check if the #GP was raised because the application is trying to access valid memory that the paging system has to make available. If so, it is loaded into working memory and application execution continues. If the application is trying to access memory it shouldn't, or memory that doesn't exist, the application is terminated and your program has crashed window shows.

Reply 3 of 8, by Stenzek

User metadata
Rank Newbie
Rank
Newbie
canthearu wrote:
superfury wrote:

Is the #GP/#SS fault used in any case with modern operating systems, but for other effects than terminating the offending program/driver/OS?

Absolutely used in paging and memory allocation. A #GP is raised if the program tries to access memory that isn't currently allocated/loading in. The OS will then check if the #GP was raised because the application is trying to access valid memory that the paging system has to make available. If so, it is loaded into working memory and application execution continues. If the application is trying to access memory it shouldn't, or memory that doesn't exist, the application is terminated and your program has crashed window shows.

Wouldn't this be #PF? As far as I understand it, reserved memory is allocated in the page table but not marked valid until it's committed. Same for memory-mapped files which aren't resident in physical memory.

edit: linux at least has the complex stuff in the page fault handler, #GP from a user-mode process just kills it with SIGSEGV: https://elixir.bootlin.com/linux/latest/sourc … el/traps.c#L522. #SS or #NP raise SIGBUS.

Reply 4 of 8, by superfury

User metadata
Rank l33t
Rank
l33t

What about Windows software executing reserved system instructions? Like LIDT etc., which throw #GP(0) when not privileged? Or protected-mode software throwing #GP(selector)? Do they always terminate the application/driver, or do they support some special actions with them(like simulating it's effects, like DPMI and MS-DOS extenders did(like EMM386/DOS4/G(W)))?

UniPCemu Git repository
UniPCemu for Android, Windows and PSP on itch.io
Older UniPCemu PC/Android/PSP releases

Reply 6 of 8, by superfury

User metadata
Rank l33t
Rank
l33t

What about software running inside the NTVDM? That still exists inside 32-bit Windows flavours?

UniPCemu Git repository
UniPCemu for Android, Windows and PSP on itch.io
Older UniPCemu PC/Android/PSP releases

Reply 7 of 8, by canthearu

User metadata
Rank Oldbie
Rank
Oldbie
Stenzek wrote:
canthearu wrote:
superfury wrote:

Is the #GP/#SS fault used in any case with modern operating systems, but for other effects than terminating the offending program/driver/OS?

Absolutely used in paging and memory allocation. A #GP is raised if the program tries to access memory that isn't currently allocated/loading in. The OS will then check if the #GP was raised because the application is trying to access valid memory that the paging system has to make available. If so, it is loaded into working memory and application execution continues. If the application is trying to access memory it shouldn't, or memory that doesn't exist, the application is terminated and your program has crashed window shows.

Wouldn't this be #PF? As far as I understand it, reserved memory is allocated in the page table but not marked valid until it's committed. Same for memory-mapped files which aren't resident in physical memory.

edit: linux at least has the complex stuff in the page fault handler, #GP from a user-mode process just kills it with SIGSEGV: https://elixir.bootlin.com/linux/latest/sourc … el/traps.c#L522. #SS or #NP raise SIGBUS.

True, and very interesting. As a non-kernel programmer, I don't get to see too much of what exactly happens inside the kernel, only know the general way operating systems work.

Reply 8 of 8, by superfury

User metadata
Rank l33t
Rank
l33t

Also, besides NTVDM, what about 16-bit Windows applications(on 32-bit Windows flavours)? Also, Although Microsoft doesn't support it anymore on 64-bit versions of Windows, the x86-64 CPUs still theoretically support those in 64-bit long mode?

UniPCemu Git repository
UniPCemu for Android, Windows and PSP on itch.io
Older UniPCemu PC/Android/PSP releases