Commit Graph

193 Commits

Author SHA1 Message Date
Tristan Ravitch
52dc736c08 ppc: Add more support for CR and FPSCR instructions 2017-11-29 16:30:46 -08:00
Ben Selfridge
45a898cf5d added double precision load/store 2017-11-29 15:11:12 -08:00
Ben Selfridge
11affb8848 Tests for all single-precision floating point load and store ops 2017-11-29 15:02:07 -08:00
Ben Selfridge
a25a477944 added first actual floating point test instruction (stfs) 2017-11-29 13:08:11 -08:00
Tristan Ravitch
5cea5a8a42 ppc: Fix the expected results of the fp test case 2017-11-29 10:14:20 -08:00
Tristan Ravitch
b033f3788c ppc: Change how we translate instructions represented by arch-specific statements
The old method involved providing the TH code a list of match expressions.  This
made it very difficult to inspect arguments of instructions.  The new approach
has the architecture backend provide a function that gets the first opportunity
to process instructions, which is much more flexible.  This commit also includes
support for a number of cache hint instructions that use the new features.
2017-11-28 21:36:49 -08:00
Ben Selfridge
3d1eb18289 Added support for floating point LT uf 2017-11-28 14:47:28 -08:00
Tristan Ravitch
ef5150e2e1 ppc: Remove an unused module 2017-11-27 22:53:55 -08:00
Tristan Ravitch
df03ddf439 Use more qualified names in the TH-generated SimpleBuilder->Macaw translation
This gives us better name capture properties, allowing us to use more
restrictive imports in the PPC64 and PPC32 modules.
2017-11-27 22:40:18 -08:00
Tristan Ravitch
289e1f33be [ppc] Updates to support some vector instructions
The semantics for many of the vector instructions are incomplete and just set
the target register to undefined.  This is enough for code discovery (for now).
2017-11-27 18:16:19 -08:00
Tristan Ravitch
c7af261d66 Marginally improve compile times
Disable a few optimizations in the TH-generated modules and add a fallthrough
case to prevent the coverage checker from firing.
2017-11-27 08:33:48 -08:00
Tristan Ravitch
7256fd597f Generalize the generator monad, the TH helper monad, and the simplifier
This code was mostly architecture independent already, so this commit moves it
to the macaw-semmc module so that it can be shared with the ARM backend.  I
still plan to move the main TH module with the SimpleBuilder to macaw
translation, but that requires a few other changes first.
2017-11-26 23:31:04 -08:00
Ben Selfridge
221e5b3407 Merge branch 'master' of gitlab-ext.galois.com:macaw/macaw-semmc 2017-11-22 16:31:51 -08:00
Ben Selfridge
e1ffa245c2 added support for is_snan uninterpreted functions 2017-11-22 16:31:36 -08:00
Tristan Ravitch
18d5ac3fe4 Add a translation for the undefined value from semmc 2017-11-21 23:37:17 -08:00
Tristan Ravitch
3b763bf347 Export useful helpers from macaw-ppc
This includes another ELF helper to find function entry points and the
type-level tags to choose between the 32 and 64 bit architectures.
2017-11-21 14:21:37 -08:00
Tristan Ravitch
d49dbc679c [ppc] Make the PPC ELF helpers easier to use
The TOC parser now doesn't require a Memory object, making it easier to actually
instantiate this in derived tools (where the TOC parser needs to be used before
a memory is available).  To do this, we use MemAddr as the base type for the TOC
instead of MemSegmentOff
2017-11-21 14:10:47 -08:00
Tristan Ravitch
80145a0161 Fix a bad exponential behavior bug
The recursive simplifier could exhibit exponential behavior in cases where a
nested tree of irreducable terms were accumulated.  The recursive calls quickly
exploded execution times.

The fix was to remove the recursive calls from the simplifier, but to
incrementally simplify expressions to constants as they are added (via the
addExpr function).  This simplifies as much as the recursive case, but more
efficiently.  This change required exporting the simplifyApp function.
2017-11-16 21:42:30 -05:00
Ben Selfridge
9ce1ffa0c5 Added test case for floating point store. Not really functional yet. 2017-11-16 16:08:25 -08:00
Tristan Ravitch
dbbb0bd947 Add TOC entries to the macaw list of entry points in the test harness
This code now pulls all of the function addresses from the TOC as entry points
for the code discovery search.  This lets us trivially find code reachable via
indirect calls, as the function pointer discovery heuristic doesn't seem to be
well-suited to PowerPC.  I'd like to push on that, but it seems like a good
start for now.
2017-11-16 10:16:22 -05:00
Ben Selfridge
399cd4ab6c Merge branch 'master' of gitlab-ext.galois.com:macaw/macaw-semmc 2017-11-15 18:00:39 -08:00
Ben Selfridge
e1963bcbf2 Added single_to_double for floating point operations 2017-11-15 18:00:19 -08:00
Tristan Ravitch
2092a0fd01 Add a (currently failing) test for indirect call handling
The code pointer discovery in macaw can't handle this case because we never
write the code pointers into memory - we only read them.  We really need a way
to tell macaw about code pointers.

The easy workaround is to pull all of the function entry points out of the TOC
and just seed the macaw search with them, but it would be nice to be able to
identify them from first principles.
2017-11-14 19:00:01 -08:00
Tristan Ravitch
94b72b2c73 Improvements for the generated semantics transformers
This change now memoizes translations of SimpleBuilder expression fragments,
which allows us to restore the sharing in semantics formulas.  The generator
re-uses shared sub-expressions automatically now.  This generates less Haskell
code, yielding better code density and fewer terms constructed at run time.  It
also reduces compile times.

It seems to cut the size of the generated TH code by about half.  It also
generates less deeply-nested Haskell code, making the resulting TH splices human
readable.
2017-11-13 10:46:33 -08:00
Tristan Ravitch
2002afa246 [ppc] Add preliminary support for popcount
It isn't supported in SimpleBuilder, so we use an uninterpreted function in the
formula language for now.
2017-11-10 16:52:38 -08:00
Tristan Ravitch
bbd00f7ef2 [ppc] Add division and a few arch-specific statements
The arch-specific statements are for memory synchronization
2017-11-10 14:48:35 -08:00
Tristan Ravitch
48dfa4d192 Remove an accidentally-committed binary file 2017-11-10 08:18:16 -08:00
Tristan Ravitch
9d750c944a Add a new type of test to PowerPC
It runs code discovery over a large-ish binary to test coverage.  We currently
fail due to unsupported instructions (expected).  This test will guide
priorities on implementing new semantics.
2017-11-09 17:18:20 -08:00
Tristan Ravitch
fc1bd8b077 Add support for more instructions
semmc has semantics for many new instructions.  We also added support for
translating the count leading zero functions.
2017-11-09 17:17:51 -08:00
Tristan Ravitch
d5d1d87fd5 Split some shared helpers out of a test module 2017-11-09 10:43:41 -08:00
Tristan Ravitch
e307c9a82a Add a comment in the test suite 2017-11-08 15:46:40 -08:00
Tristan Ravitch
e5d20c6acf Fix an expected test output
It looks like I counted the bytes wrong the first time
2017-11-08 10:56:13 -08:00
Tristan Ravitch
b9835b9767 Cleanup and documentation pass 2017-11-07 22:46:06 -08:00
Tristan Ravitch
599a357515 Don't export curPPCState 2017-11-07 21:45:04 -08:00
Tristan Ravitch
a03953ecdc Delete some obsolete comments 2017-11-07 21:36:25 -08:00
Tristan Ravitch
6308df3a8f Add a helper to set register values
This helper additionally simplifies constants.  This is very useful for dealing
with simplifying the instruction pointer.  That is required by the rest of
macaw, which expects IP values it wants to explore to be fully reduced.
2017-11-07 21:16:00 -08:00
Tristan Ravitch
71a432ed18 Improve the test suite
Don't just ensure that found blocks are expected: also ensure that all expected
blocks are found.
2017-11-07 20:50:33 -08:00
Tristan Ravitch
c3d0ede125 Import alignment 2017-11-07 20:29:41 -08:00
Tristan Ravitch
65bc1231fb Implement 'identifyCall' for PowerPC
The current heuristic isn't great, but is probably okay for now.  It just checks
to see if the LNK register is an address plus four.  Something more precise
would require knowing the address of the next instruction, but we can't get that
from the IP, which has already been changed due to the call.
2017-11-07 20:23:11 -08:00
Tristan Ravitch
a648a4c50b Improve the formatting for test failures
Now print addresses as hex values
2017-11-07 20:22:49 -08:00
Tristan Ravitch
fed8e00482 [ppc] Fix the offsets in the call test 2017-11-07 20:22:32 -08:00
Tristan Ravitch
f126dbf5fa Add a (currently failing) test for calls 2017-11-07 17:49:53 -08:00
Tristan Ravitch
48ba00870d Add some extra tracing to 'identifyFunction' 2017-11-07 17:49:36 -08:00
Tristan Ravitch
65c940e334 Remove an unused function 2017-11-07 17:49:28 -08:00
Tristan Ravitch
fdcbbeae39 Fix a bug in register value handling
The semantics of each instruction are atomic updates over the register state.
Prior to this commit, changes were not atomic and updates to register values
were visible to later register definitions, which causes a huge number of
problems.  Now, we take a snapshot of the register state at the beginning of the
instruction and read all values we need from that snapshot.  This way, updates
are isolated from one another.
2017-11-07 17:45:00 -08:00
Tristan Ravitch
fc48993507 Update an expected test result
My understanding of how macaw splits up blocks was incorrect when I wrote the
test initially.  Macaw doesn't split blocks just because a jump happens to land
in the middle of the block, so the middle block in this example is actually a
few instructions longer.
2017-11-07 14:32:51 -08:00
Tristan Ravitch
81fbec6bb9 Improve the layout of the frontier calculation 2017-11-07 13:45:40 -08:00
Tristan Ravitch
a4cbd3a9d0 Make the simplifier more powerful
It now recursively traverses its arguments.  This isn't great from an efficiency
perspective, but we need it to be able to simplify instruction pointers computed
from relative jumps (which involve some sign extensions and shifts).
2017-11-07 13:44:41 -08:00
Tristan Ravitch
0b43f5672e Have 'matchConditionalBranch' simplify the values it returns
These values are new values of the IP to explore, and the code consuming these
values expects them to be BV literals (i.e., simplified from expressions to
values).

The simplifier isn't currently powerful enough to simplify everything we throw
at it, but this is at least the right place to apply it.  If we don't simplify
here, the core of macaw won't know how to follow the IP changes and will miss
blocks.
2017-11-07 11:36:50 -08:00
Tristan Ravitch
32d37e1a31 Delete an obsolete comment 2017-11-07 11:36:36 -08:00