Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing hidden operands for far call/ret #239

Open
mappzor opened this issue Sep 20, 2021 · 1 comment
Open

Missing hidden operands for far call/ret #239

mappzor opened this issue Sep 20, 2021 · 1 comment
Assignees
Labels
A-decoder Area: Decoder C-enhancement Category: Enhancement of existing features P-medium Priority: Medium

Comments

@mappzor
Copy link
Contributor

mappzor commented Sep 20, 2021

For far call (currently only esp, eip and [esp] operands are supported just as in near call):

The new code segment selector and its descriptor are loaded into CS register; the offset from the instruction is loaded into the EIP register.

Depending on call type stack switch can occurr (ss/esp read/write).

For far ret (currently only rsp, rip and [rsp] operands are supported just as in near ret):

When executing a far return, the processor pops the return instruction pointer from the top of the stack into the EIP
register, then pops the segment selector from the top of the stack into the CS register. The processor then begins
program execution in the new code segment at the new instruction pointer.
The mechanics of an inter-privilege-level far return are similar to an intersegment return, except that the
processor examines the privilege levels and access rights of the code and stack segments being returned to determine if the control transfer is allowed to be made. The DS, ES, FS, and GS segment registers are cleared by the RET
instruction during an inter-privilege-level return if they refer to segments that are not allowed to be accessed at the
new privilege level. Since a stack switch also occurs on an inter-privilege level return, the ESP and SS registers are
loaded from the stack.

@flobernd flobernd self-assigned this Sep 20, 2021
@flobernd flobernd added A-decoder Area: Decoder C-enhancement Category: Enhancement of existing features P-medium Priority: Medium labels Sep 20, 2021
@tremalrik
Copy link

This looks like it should also apply to int, iret, sysenter and sysexit, as all of these modify cs and might modify ss as well. (syscall and sysret correctly list cs and ss as hidden operands already.)

Also, since call far, int and syscall will read ip/eip/rip, they should probably have the operand action on ip/eip/rip set to RW rather than W, much like the near variants of call already do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-decoder Area: Decoder C-enhancement Category: Enhancement of existing features P-medium Priority: Medium
Projects
None yet
Development

No branches or pull requests

3 participants