How do I know if I changed privilege level on IRQ in X86?
Posted: Tue Aug 05, 2025 4:36 pm
When an IRQ fires, it conditionally pushes an error code. It also pushes RIP, CS, and RFLAGS, and it pushes RSP and SS if a privilege level change occurred. In order to know if a privilege level change occurred, I need the contents of the pushed CS (because it contains the previous CPL), but the pushed CS is in different places in the stack if a privilege change occurred (which pushes RSP and SS as well).
How do I know if I changed privilege level in an IRQ? I need to know so I can properly get the saved registers from the stack and also to know if I need to do a "swapgs" to load my cpu-specific info. I obviously can't do it through the saved CS. The CPU must know this information in order to determine how to handle the stack args on return, but how would I know it?
How do I know if I changed privilege level in an IRQ? I need to know so I can properly get the saved registers from the stack and also to know if I need to do a "swapgs" to load my cpu-specific info. I obviously can't do it through the saved CS. The CPU must know this information in order to determine how to handle the stack args on return, but how would I know it?