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

x86: disallow BT with memory operands #948

Merged
merged 1 commit into from
Nov 7, 2024
Merged

x86: disallow BT with memory operands #948

merged 1 commit into from
Nov 7, 2024

Conversation

vbgl
Copy link
Member

@vbgl vbgl commented Oct 29, 2024

Fixes #931.

@vbgl vbgl added the bug label Oct 29, 2024
@bgregoir
Copy link
Contributor

bgregoir commented Nov 5, 2024

This problem is not in the printing of the instruction ?
"In 64-bit mode, the instruction’s default operation size is 32 bits. Using a REX prefix in the form of REX.R permits access to additional registers (R8-R15). Using a REX prefix in the form of REX.W promotes operation to 64 bit operands. See the summary chart at the beginning of this section for encoding data and limits."
I think the documentation of this instruction with memory operand is anyway hard to understand.

@vbgl
Copy link
Member Author

vbgl commented Nov 5, 2024

No, the problem is not in printing. The problem is in the semantics.

If you run (pseudo-code):

x := 137
cf := BT(p, x)

this will set cf to the value of the bit at position 137 after p. This instruction can read a bit very far away from the given address.

@bgregoir bgregoir merged commit c7b4954 into main Nov 7, 2024
1 check passed
@bgregoir bgregoir deleted the x86-bt branch November 7, 2024 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong semantics of x86 instruction BT when operand is in memory
2 participants