Commit Graph

33 Commits

Author SHA1 Message Date
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
Tristan Ravitch
380d732d0e
Implement system call support for x86 (#226)
Implement support for symbolically executing system calls in macaw-symbolic. **To update code that does not need to symbolically execute system calls (i.e., most clients of macaw-symbolic), just pass the new `unsupportedSyscalls` default handler as the fifth argument of `macawExtensions`.**

The primary interface is via the new `LookupSyscallHandle` callback passed to `macawExtensions`. This callback inspects the environment and returns a Crucible `FunctionHandle` that models the behavior of the requested system call. Note that this mechanism only supports concrete system calls (i.e., system calls where the system call number is concrete). The x86 backend has been updated to support this new functionality.

The representation of system calls in macaw is still architecture-specific (because there are interesting differences between system call instructions across architectures). The idea is that system calls are now treated in two steps:
1. A macaw-symbolic extension statement that looks up the override to invoke for the given syscall (returned as a Crucible FunctionHandle)
2. A call to that handle

We need this two step approach because the handlers that interpret syntax extension statements cannot symbolically branch (and thus cannot call overrides). The extension interpreter just looks up the necessary handle and uses the standard call/override machinery to handle any branching required to support the system call model functionality.

The major complication to this approach is that system calls need to update values in registers when they return. To capture these updates, the architecture-specific syntax extension needs to explicitly update any machine registers that could possibly be affected. The explicit updates are necessary because machine registers do not exist anymore at the macaw-symbolic level (at least within a block). To handle all of these constraints:
1. System calls are represented as extension functions at the macaw level when lifted from machine code.
2. During translation into crucible (via macaw-symbolic), the extension functions are translated into two statements: a function handle lookup and then a function call (with the return values being explicitly threaded through the Crucible function).
3. During symbolic execution, the lookup statement examines the environment to return the necessary function handle, while the handle is called via the normal machinery.

Note that the feature is entirely controlled by the `LookupSyscallHandle` function, which determines the system call dispatch policy. No system call models are included with this change.

Co-authored-by: Brett Boston <boston@galois.com>
2021-08-27 15:47:40 -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
robdockins
a58f1e25dd
Update to follow changes in What4. Nat is no longer a base type (#190)
Nat is no longer a what4 base type, so we have to adapt various APIs to accommodate that. The template haskell in macaw-semmc is updated to remove Nat cases. Changes to the `SymFn` type required removing a type parameter.

This commit also adds macaw-refinement to CI (which requires installing SMT solvers); that code had to be updated due to the what4 changes.


Co-authored-by: Tristan Ravitch <tristan@galois.com>
2021-02-19 15:44:56 -08:00
Rob Dockins
99f8cb0bdf Update to use new HasLLVMAnn API, which requires an action for
recording (or discarding) annotations rather than a map.
2020-09-11 14:40:02 -07:00
Kevin Quick
fc419e4c18
[refinement] update for badBehaviorMap implicit parameter. 2020-08-10 13:47:44 -07:00
Andrei Stefanescu
0be59e5815
Update Macaw to use HasLLVMAnn. (#122) 2020-04-02 17:58:47 -07:00
Tristan Ravitch
e024646860
macaw-refinement (#114)
This commit updates macaw-refinement to work with the latest macaw/crucible and makes a few improvements along the way.

The major changes involved in this are:
* Block labels were removed from macaw, so we had to come up with an alternative approach to making synthetic blocks to represent dispatch resolved by macaw-refinement that is not really a jump table. We considered adding a new terminator that encoded "computed IP-based dispatch", but there was concern about the impact on client code. Instead, we added a field to the `DiscoveryFunInfo` that records "external" resolutions to indirect control flow (e.g., as by an SMT solver in macaw-refinement). The hook by which we feed SMT-based resolutions back into macaw was modified accordingly (`addDiscoveredFunctionBlockTargets`).
* Solver invocation changed to allow solver selection and parallel solver application.
* Logging is now done via the `lumberjack` library.
* macaw-symbolic now uses the "external" resolutions in `DiscoveryFunInfo` while building crucible CFGs.
* The path creation code in macaw-refinement was simplified significantly and the approach to path creation has been documented.
* The run-refinement tool is now more featureful.
* The test suite is a bit more structured and no longer depends on the printed output of the discovery process.
2020-03-12 17:15:08 -07:00
Kevin Quick
898e7bdb95
[refinement] Added newline to end of expected output file. 2019-02-26 14:51:49 -08:00
Kevin Quick
3fe6fdf949
Sort refinement results for test stability and visual convenience. 2019-02-23 21:33:40 -08:00
Kevin Quick
3e7bd01560
[refinement] Disabled PPC switching test.
Attempting to refine the switching test for PPC executables ends up
with a non-terminating Z3 process, so this test is disabled until this
is diagnosed.
2019-02-08 17:32:21 -08:00
Kevin Quick
d3228847f7
[refinement] add PPC tests expected results. 2019-02-08 14:26:17 -08:00
Kevin Quick
290e33279a
[refinement] Enable PPC testing. 2019-02-08 14:10:08 -08:00
Kevin Quick
33540121f5 Merge branch 'master' of github.com:GaloisInc/macaw 2019-02-07 17:15:24 -08:00
Andrei Stefanescu
ec9acfc1e1 [refinement] Add llvm compiled ppc64 binary files. 2019-02-07 17:00:10 -08:00
Kevin Quick
e47887a9f1
[refinement] add note to sample input for refinement tests. 2019-02-07 16:43:11 -08:00
Kevin Quick
3c6492b6fb
[refinement] add additional comment and showsearch info to RefinementTests. 2019-02-07 16:41:34 -08:00
Andrei Stefanescu
9121f0a439 [refinement] Add llvm compiled binary files. 2019-02-07 16:20:24 -08:00
Kevin Quick
59b55dd10a
[refinement] Update README for tests/samples. 2019-02-07 16:15:49 -08:00
Kevin Quick
35ff0c18ab
[refinement] Added nested switch/case test source. 2019-02-07 16:14:12 -08:00
Kevin Quick
7bb72b4b19
[refinement] Update expected refined test results for switching.x86.
The tests/samples/switching.c example now gets refined successfully so
this updates the expected file for that output.
2019-02-07 16:09:23 -08:00
Andrei Stefanescu
3aae34297f [refinement][first version] Get successor candidates for classification failure blocks. 2019-02-05 21:08:13 -08:00
Kevin Quick
9ba5473302
[refinement] only run refined tests if specified.
This prevents refined validation tests from causing problems with base
tests when only the latter is being run.
2019-01-30 09:14:22 -08:00
Kevin Quick
375dd1d656
[refinement] disable PPC testing temporarily 2019-01-30 09:13:52 -08:00
Kevin Quick
1b99c43518
[refinement] run tests only over specified architectures. 2019-01-30 09:13:38 -08:00
Kevin Quick
ebde669a24
[refinement] group tests by name. 2019-01-30 09:12:02 -08:00
Andrei Stefanescu
2efd7bc0e6 Fixes. 2019-01-29 16:29:54 -08:00
Kevin Quick
16dfcaab0d
[refinement] Add initial refinement framework. 2019-01-24 14:49:47 -08:00
Kevin Quick
fb605a41d0
[refinement] update test generation and add refinement tests. 2019-01-23 12:04:41 -08:00
Kevin Quick
1d9c6d7ae0
[refinement] Add 32-bit PPC support to tests. 2019-01-23 00:02:49 -08:00
Kevin Quick
63d24be712
[refinement] add binary versions of test samples. 2019-01-22 23:36:48 -08:00
Kevin Quick
fb869eedf7
[refinement] add some test sources to the test/samples. 2019-01-22 23:35:01 -08:00
Kevin Quick
08d4dcd832
[refinement] Add test framework to compare output to expected output. 2019-01-22 20:04:26 -08:00