-
Notifications
You must be signed in to change notification settings - Fork 274
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
Fixes lifting disassembler bug for Pcmp #1222
Conversation
(Am I correct in thinking bil wants both sides of shifts to have the same type? If that has changed, it could just be that I'm working with older code that wants to make that assumption. Either way, the pcmp decoder error fixed here is definitely a problem.) |
09273fe
to
2340acc
Compare
Nope, they can have different types, no problem here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please remove the .merlin files and provide some references that identify what "some bugs" you're fixing? E.g., what is the expected behavior and how the current behavior differs from it, and how it is reflected in the ISA manual.
@@ -999,9 +999,9 @@ let parse_instr mode mem addr = | |||
(Punpck(prefix.mopsize, elemt, order, r, rm, rv), na) | |||
| 0x64 | 0x65 | 0x66 | 0x74 | 0x75 | 0x76 as o -> | |||
let r, rm, rv, na = parse_modrm_vec None na in | |||
let elet = match o land 0x6 with | 0x4 -> reg8_t | 0x5 -> reg16_t | 0x6 -> reg32_t | _ -> | |||
let elet = match o land 0x0F with | 0x4 -> reg8_t | 0x5 -> reg16_t | 0x6 -> reg32_t | _ -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any references or explanations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was a typo, this is what the author meant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(you can check the behavior against http://ref.x86asm.net/coder64.html ; pretty clearly the case that leaves elet=reg16_t isn't supposed to be dead code :P )
Ah, ok. I'll note that I think this type difference is causing primus to send our code stuff like |
There's a typo in the disassembler.
2340acc
to
183e9e7
Compare
Thanks! |
Yes, since 2.1.0 we relaxed the type system of the Primus interpreter and it now permits binary operations, including the arithmetic operations, on operands with different sizes. To enable this, the interpreter coerces operands to the same bitwidth. We apply this coercion to all operations, even those that permit operands of different sizes, which is probably too conservative and results in unnecessary operations such as
Yes, if the resulting width is larger than the original it is the same as zero-padding, e.g.,
|
👍 Thanks for the info. In our particular case, removing the "bogus" coercions would actually just cause errors elsewhere in our code, because our expressions use traditional width-strictness in bitvec operands (and the code assumes that Primus is as strict as it was previously). So what I'd suggest, is that Primus be updated to send the "correct" coercion (cast or extract), rather than omitting them. An approach like that would allow Primus to avoid breaking the API, even if operator definitions are relaxed/otherwise expanded in the future. |
I am not saying about removing all coercions, just removing coercions for shifts, which are not necessary from the perspective of the BIL type system, but indeed are necessary from the perspective of SMTLIB, where shifts are having sort
In other words, instead of the swiss-knife I can do this, but here is the caveat. Even if Primus will begin to emit more precise coercions it doesn't guarantee that someone else will not be using
See also our symbolic executor formula module that maps Primus observations to Z3 formulae, which we should probably make public. And sorry for the late reply, I missed somehow the notification :( |
There's a decoding error in some Pcmp instructions, and the same type error in Pcmp & Ppackedbinop semantics (left-shift of a vector-register-sized operand by an 8-bit shift value).