Commit Graph

43 Commits

Author SHA1 Message Date
Kevin Quick
78b45a10c6 Only fix personality to (MS.MacawSimulatorState sym) where required. 2022-02-21 13:27:20 -05:00
Rob Dockins
465a84ee49 Update with changes flowing from GaloicInc/crucible#945.
This mostly deals with the splitting of the old `sym` type into
two: one for dealing with expression creation, and a new simulator
backend type for dealing with control-flow and assertions.
2022-01-24 16:24:07 -08:00
Tristan Ravitch
63a65c3d85 x86: Fix failing proof obligations due to EvenParity
See the writeup in Crucible.hs in this commit for details. In short, the recent
changes to generalize `PtrAdd` triggered a failing proof obligation due to a use
of `llvmPointer_bv`.  The new implementation is as sound as the previous one,
but more general.

Fixes #260
2022-01-21 15:33:10 -08:00
Tristan Ravitch
9ce3d43188
AArch32: Support conditional returns (#243)
Adds support in macaw-aarch32 for conditional returns. These are not supported in core macaw, and are thus architecture-specific block terminators.

This required changes to the type of arch-specific block terminators. Before, `ArchTermStmt` was only parameterized by a state thread (`ids`).  This meant that they could not contain macaw (or crucible) values.  Some work on. AArch32 requires being able to store condition values in arch terminators (to support conditional returns). This change modifies the `ArchTermStmt` to enable this, which requires a bit of plumbing through various definitions and some extra instances.

In support of actually using this, it also became necessary to plumb fallthrough block labels through the architecture-specific terminator translation in macaw-symbolic.

Note that this change was overdue, as the PowerPC backend was storing macaw values in a way that would have rendered them unusable in the macaw-ppc-symbolic translation, had any interpretation been provided.  These new changes will enable a handler to be written for the conditional PowerPC trap instructions.

PowerPC, x86, and ARM have been updated.

Improves the macaw-aarch32 tests. There is now a command line option to save the generated macaw IR for each
discovered function to /tmp. Note that this reuses some infrastructure from the macaw-symbolic tests. This
shared functionality should be extracted into a macaw-testing library.
2021-11-19 16:20:50 -08:00
Brett Boston
a336895da7
Add optional override for MacawArchStmtExtensions to genArchVals (#230)
This change adds an optional argument to `genArchVals` that allows client code to override the backend translation behavior of `MacawArchStmtExtension`s on a statement-by-statement basis.  The new argument has type `Maybe (MacawArchStmtExtensionOverride arch)`, where `MacawArchStmtExtensionOverride` is a function that takes a statement and a crucible state, and returns an optional tuple containing the value produced by the statement, as well as an updated state.  Returning 'Nothing' indicates that the backend should use its default handler for the statement.

Client code that wishes to maintain the existing default behavior in all cases can simply pass `Nothing` for the new argument to `genArchVals`.
2021-09-14 18:24:47 -07:00
Ryan Scott
7f7de2a59b
Adapt to GaloisInc/crucible#794 (#224)
GaloisInc/crucible#794 increases the number of functions that use
implicit `MemOptions`, including a handful of key LLVM memory model–related
functions. As a result, many parts of `macaw` need to add implicit `?memOpts`
parameters to accommodate to this change.
2021-08-23 20:39:08 -04:00
Tristan Ravitch
dbb4c83f08
Add a testing framework for macaw-symbolic (#184)
The new test suites cover x86_64, PowerPC, and ARM. They test that the semantics are actually correct (rather than just seeing if symbolic execution produces any result). The `Data.Macaw.Symbolic.Testing` module in macaw-symbolic provides some common utilities for symbolic execution engine setup, while there are tailored test harnesses for each architecture.

The semantics of the test harnesses are documented in each architecture test suite, but they:
1. Discover all of the test binaries (which are generated from the included makefiles)
2. Treat each function whose name begins with `test_` as a test entry point
3. Symbolically executes each test case with fully symbolic register states
4. Extracts the return value after symbolic execution, which is treated as the predicate to an assertion that must be proved
    - If the test case is in the `pass` subdirectory, it is proved and expected to hold
    - If the test case is in the `fail` subdirectory, it is proved and expected to not hold.

Each test harness supports two options for debugging:
- Dumping generated SMT queries
- Dumping generated Macaw IR for inspection

This testing uncovered a bug in the (previously untested) macaw-aarch32-symbolic code. It required a number of submodule updates to:

- Adapt to some what4 changes
- Fix a bug in the LLVM memory model that lets these tests pass
- Adapt to changes to some crucible APIs

This change also modifies the CI configuration to install SMT solvers earlier (which are now needed for all of the symbolic package tests).
2021-03-01 09:21:44 -08:00
Daniel Matichuk
70d35d44e4 parameterize ArchInfo and ArchVals over mem type 2020-09-02 10:21:39 -07:00
Daniel Matichuk
6109731324 create valid solver symbol for PPC registers 2020-09-01 17:09:49 -07:00
Daniel Matichuk
2da172b3ea generalize ArchInfo over memory model 2020-09-01 17:07:04 -07:00
Tristan Ravitch
02c2fcd96a
Clean up the PowerPC architecture specifications (#130)
This commit reduces duplication in the PowerPC backend.  Instances are now in terms of the generic `AnyPPC` type, rather than having separate instances for 32 and 64 bit.  Shuffling some type parameters also allows us to remove a large number of type equalities that e.g., fix the arch register type to `PPCReg`.
2020-04-19 11:56:42 -07:00
Daniel Wagner
97c9e20089 add memory model as type argument in a few places 2020-03-18 00:21:15 -04:00
Tristan Ravitch
06f64078df
Wip/ppc no block labels (#66)
Update to API changes in macaw-base in macaw-ppc and macaw-arm

The "block label" abstraction (used during arch-specific disassembly) was removed some time ago in the base macaw library.  This change updates macaw-ppc and macaw-arm to remove uses of block labels.  The major change is that the disassembly function only returns a single block at a time instead of a sequence of blocks.

To facilitate this, the handling of the PowerPC conditional trap instruction (trap doubleword) is now an architecture-specific terminator instruction instead of encoding the logic of conditional trapping.  We will now have to encode the conditional trapping logic in macaw-ppc-symbolic.  Note that we have not done so yet.

This commit also updates the expected results of the PowerPC tests; the number of discovered blocks is different, but not significantly so.  It is hard to tell if this is a regression or an improvement.
2019-08-09 16:11:59 -07:00
Kevin Quick
eb93bb4e3a
[ppc-symbolic] updates for crucible nonce change from (ST h) to IO
Changes for compatibility with Crucible pull request
285 (https://github.com/GaloisInc/crucible/pull/285) and the
corresponding changes in macaw symbolic.
2019-07-19 13:19:14 -07:00
Kevin Quick
9c5ebee0bc
Added ArchInfo lookupReg and updateReg for PPC. 2019-02-08 17:28:43 -08:00
Luke Maurer
7d720b74f6 Add new crucGenRegStructType to MacawSymbolicArchFunctions for PPC 2019-01-28 14:48:25 -08:00
Tristan Ravitch
cfcc1fc0d4 Update to the latest macaw-symbolic
There was some API churn, mostly a few renames and new modules.
2019-01-10 18:23:19 -08:00
Luke Maurer
aaa7a6cf85 Add new parameter to CrucGen monad 2019-01-03 12:13:55 -08:00
Luke Maurer
dbce1b1265 Refactor to use AnyPPC 2018-12-21 11:47:40 -08:00
Luke Maurer
b5a75832a3 Adapt to and re-export new AnyPPC arch constructor 2018-12-20 16:43:46 -08:00
Andrei Stefanescu
76ff48eec0 Propagate changes for X86_64 RepMovs and RepStos. 2018-11-27 10:31:03 -08:00
Andrei Stefanescu
1c002f160b Minor fixes. 2018-09-18 21:56:17 -07:00
Andrei Stefanescu
32961d20cb Use name instead of nonce id for uninterpreted functions. 2018-09-14 19:01:27 -07:00
Andrei Stefanescu
85ef5b4f0b Add float le and float round. 2018-09-14 19:01:19 -07:00
Andrei Stefanescu
4b498807fd Handle floating-point rounding. 2018-09-12 11:10:23 -07:00
Andrei Stefanescu
b0c98ccc5c Use op name as argument instead of uninterpreted function name. 2018-09-06 14:47:37 -07:00
Andrei Stefanescu
f448a4ae9f Add symbolic semantics to PPC floats. 2018-09-06 14:47:37 -07:00
Kevin Quick
932b3df9ff
[ppc-symbolic] Update LLVM memory model pointer import for newer crucible. 2018-08-27 15:25:37 -07:00
Tristan Ravitch
981b775c7c Update submodules 2018-07-24 16:57:36 -07:00
Tristan Ravitch
84473060e3 Generalize the lookup/update register assignment utilities
Instead of having them return 'Maybe', use 'MonadThrow'
2018-05-18 17:50:22 -07:00
Kevin Quick
f81f2437ee
Update for crucible reorganization and new what4 module. 2018-05-18 08:33:58 -07:00
Tristan Ravitch
c943d45d21 ppc-symbolic: Export some more helpers 2018-05-15 18:41:04 -07:00
Tristan Ravitch
fd3ab9145a ppc-symbolic: Generate term statements in the translation 2018-05-10 07:58:00 -04:00
Kevin Quick
dc79e6b636
[ppc-symbolic] Update Crucible IsSymInterface and simulator state. 2018-05-07 15:59:05 -07:00
Tristan Ravitch
7bab701643 ppc-symbolic: Implement semantics for the ppc-specific statements
Except for Attn, these are all no-ops since we don't have a concurrency model.
That could change later - we might want to model them as both failing and
succeeding in some cases (esp the transactional memory instructions).
2018-05-07 08:15:05 -07:00
Kevin Quick
1b401bbe94
[ppc-symbolic] Remove extraneous file. 2018-05-04 17:43:10 -07:00
Tristan Ravitch
78af7939b6 ppc-symbolic: Sketch out terminator handling and interpretation 2018-05-04 17:16:06 -07:00
Tristan Ravitch
df607d4044 ppc-symbolic: Translate macaw statements
Still need to translate terminal statements (esp. system call and trap)
2018-05-04 16:48:31 -07:00
Tristan Ravitch
6d7bb6f6e4 ppc-symbolic: Fill out the semantics for the arch-specific functions 2018-05-04 15:46:54 -07:00
Tristan Ravitch
6b3bf072cf ppc-symbolic: Add more descriptive failures 2018-05-04 10:16:46 -07:00
Tristan Ravitch
1c97ca1314 ppc-symbolic: Implement the function evaluators 2018-05-04 10:15:25 -07:00
Tristan Ravitch
05c01beec0 Re-export newSymFuns from the top-level module 2018-05-04 09:32:13 -07:00
Tristan Ravitch
c3ba017fcc Start macaw-ppc-symbolic 2018-05-03 16:41:33 -07:00