Enable testing of instructions with memory operands in x86_64 simulator #189
+469
−61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes:
This is a PR following what is done in #186 for enabling testing of instructions with memory operands in x86_64 simulator.
Specifically, cosimulation tests with memory operands are added for the following instructions:
They are tested for two addressing modes:
base + scale * index + displacement
andbase + displacement
. The tested operand size is 64 and displacement isdisp8
. One additional test is added whenbase
register isrsp
. They are represented as the following calls in the code:To simplify the problem, the register usage is mostly fixed, however the parameters (
base
,scale
,index
, anddisplacement
) are randomized. ForPUSH
andPOP
, the register usage is also randomized.These instructions and their respective addressing modes are chosen because they appear in existing s2n-bignum assembly.
The
cosimulate_xxx_harness
functions are added in file x86-mem-insns.ml for convenience of adding tests for future x86 instruction modeling.Unlike in Arm, many of the instructions can take memory operands in x86. Therefore I set the cosimulation fraction to be 50% for both non memory-accessing instruction and memory-accessing instruction. The number of tests run in a 40min run is reduced from 2000 to 200, meaning it is now 10 times slower. Reducing the percentage to 10% and around 800 instructions are tested. Some analysis for why this slowdown:
READ_MEMORY_MERGE_CONV
andASM_REWRITE_TAC[]
as inval (word xxx))
appear in expressions causing proofs to fail. To fix this problem, John (@jargh) proposes adding a tacticEPTH_CONV WORD_NUM_RED_CONV THENC
inx86_conv
. This change has an impact on all testscosimulate_mem_full_harness
function takes five instructions to simulate oneOne minor thing, I often find myself having to test if an instruction could be decoded by s2n-bignum, so I wrote this function that currently resides in simulator.ml:
I find it really helpful in times, but I'm not sure where to put it. Let me know if it should be moved to somewhere else.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.