-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tutorials for edk2/uefi application and risc-v kernel
- Loading branch information
1 parent
d6a9eac
commit 067469f
Showing
84 changed files
with
8,177 additions
and
530 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,8 @@ linux64/ | |
win64/ | ||
packageinfo/ | ||
target/ | ||
documentation | ||
simics | ||
simics-eclipse | ||
simics-gui | ||
compiler.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rsrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
PUBLIC_SIMICS_PKGS_URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/881ee76a-c24d-41c0-af13-5d89b2a857ff/simics-6-packages-2023-31-linux64.ispm" | ||
PUBLIC_SIMICS_ISPM_URL="https://registrationcenter-download.intel.com/akdlm/IRC_NAS/881ee76a-c24d-41c0-af13-5d89b2a857ff/intel-simics-package-manager-1.7.5-linux64.tar.gz" | ||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
IMAGE_NAME="tsffs-builder" | ||
CONTAINER_UID=$(echo "${RANDOM}" | sha256sum | head -c 8) | ||
CONTAINER_NAME="${IMAGE_NAME}-tmp-${CONTAINER_UID}" | ||
|
||
mkdir -p "${SCRIPT_DIR}/rsrc" | ||
if [ ! -f "${SCRIPT_DIR}/rsrc/ispm.tar.gz" ]; then | ||
curl --noproxy '*.intel.com' -o "${SCRIPT_DIR}/rsrc/ispm.tar.gz" \ | ||
"${PUBLIC_SIMICS_ISPM_URL}" | ||
fi | ||
if [ ! -f "${SCRIPT_DIR}/rsrc/simics.ispm" ]; then | ||
curl --noproxy '*.intel.com' -o "${SCRIPT_DIR}/rsrc/simics.ispm" \ | ||
"${PUBLIC_SIMICS_PKGS_URL}" | ||
fi | ||
|
||
docker build -t "${IMAGE_NAME}" -f "${SCRIPT_DIR}/Dockerfile" "${SCRIPT_DIR}/../../" | ||
docker create --name "${CONTAINER_NAME}" "${IMAGE_NAME}" bash | ||
docker cp "${CONTAINER_NAME}:/tsffs/linux64/packages/" "${SCRIPT_DIR}/../../" | ||
docker rm -f "${CONTAINER_NAME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
6fff107aa30d12a9e7c1bb0ae12d0892cf8267e1:docs/src/tutorials/edk2-uefi/writing-the-application.md:generic-api-key:160 | ||
6e7bfe7256ea34323926bdbc2f7c157126782c87:docs/src/tutorials/edk2-uefi.md:generic-api-key:167 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
crates/ | ||
simics/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Documenation | ||
|
||
Documentation for the public distribution of SIMICS and all the crates which make up | ||
TSFFS are provided here. | ||
|
||
- [SIMICS Documentation](https://intel.github.io/tsffs/simics/) | ||
- [Crate Documentation](https://intel.github.io/tsffs/crates/) | ||
- [tsffs](https://intel.github.io/tsffs/crates/tsffs/) | ||
- [simics](https://intel.github.io/tsffs/crates/simics) | ||
- [simics-macro](https://intel.github.io/tsffs/crates/simics-macro) | ||
- [simics-codegen](https://intel.github.io/tsffs/crates/simics-codegen) | ||
- [simics-api-sys](https://intel.github.io/tsffs/crates/simics-api-sys) | ||
- [ispm-wrapper](https://intel.github.io/tsffs/crates/ispm-wrapper) | ||
- [command-ext](https://intel.github.io/tsffs/crates/command-ext) | ||
- [ffi-macro](https://intel.github.io/tsffs/crates/ffi-macro) | ||
- [getters](https://intel.github.io/tsffs/crates/getters) | ||
- [raw-cstr](https://intel.github.io/tsffs/crates/raw-cstr) | ||
- [version-tools](https://intel.github.io/tsffs/crates/version-tools) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Choosing a Harnessing Method | ||
|
||
As covered in the [harnessing](../harnessing/) section, there are three options for | ||
harnessing a given target software: | ||
|
||
- Open-box, or compiled-in harnesses using provided macros | ||
- Closed-box harnessing that injects testcases into some target software memory | ||
- Fully manual harnessing that returns the testcase to the harnessing script | ||
|
||
The method that should be used depends on your target software and, more importantly, | ||
your build system. | ||
|
||
## Compiled-In/Open-Box Harnessing | ||
|
||
If you control the build system and are able to modify the code, you | ||
should almost always prefer the compiled-in harnesses. When you control the compilation, | ||
some examples of when compiled-in harnesses should be used are: | ||
|
||
- Your UEFI application has a function (or code flow) that takes external input | ||
- Uses files from the filesystem, SRAM, or other persistent storage | ||
- Takes input from the operating system | ||
- Your Kernel module takes external input | ||
- Receives input from user-space via IOCTL or system call | ||
- Uses DMA or MMIO to take input from an external source | ||
- Your user space application takes user input | ||
- From command line | ||
- From a file | ||
|
||
## Closed-Box Harnessing | ||
|
||
The closed-box harnessing methods covered in | ||
[the closed-box section](../harnessing/closed-box.md) work in the same way as the | ||
open-box harnessing approach. They should be used when the software takes input in the | ||
same way as software that would be harnessed using the open-box approach, but whose | ||
code or build system cannot be changed to add compiled-in harnessing. | ||
|
||
## Fully Manual Harnessing | ||
|
||
Fully manual harnessing should be used in cases where neither other approach is | ||
possible or in extremely complex cases. For example, when significant code is required | ||
to preprocess and send an input via an external interface, for harnessing code such as | ||
a UEFI update mechanism. This approach (when used correctly) can save time that would | ||
have been spent writing a harness in the target software, but you should take care that | ||
in-target harnessing is not the best option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Optimizing for Fuzzing | ||
|
||
There are a few techniques that can be used to optimize the fuzzer for performance while | ||
fuzzing. | ||
|
||
## Reduce Output | ||
|
||
The most effective (and, helpfully, often the easiest) way to improve performance of the | ||
fuzzer is to eliminate as much output as possible from the target software. You can use | ||
the preprocessor definition `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` to do this: | ||
|
||
Before: | ||
|
||
```c | ||
log_info("Some info about what's happening"); | ||
log_debug("Some even more info about what's happening, the value is %d", some_value); | ||
``` | ||
After: | ||
```c | ||
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION | ||
log_info("Some info about what's happening"); | ||
log_debug("Some even more info about what's happening, the value is %d", some_value); | ||
#endif | ||
``` | ||
|
||
This will reduce the logging output, which is important in SIMICS as it reduces the running | ||
of the console output model, which is much slower than the CPU model. | ||
|
||
## Run as little as possible | ||
|
||
In general, the harnesses for fuzzing should be placed as close around the code you | ||
actually wish to fuzz as possible. For example, if you only want to fuzz a specific function, | ||
like `YourSpecialDecoder`, place your harnesses immediately around the function call you | ||
want to fuzz: | ||
|
||
```c | ||
HARNESS_START(buf, buf_size_ptr); | ||
int retval = YourSpecialDecoder(certbuf, certbuf_size_ptr); | ||
|
||
if (!retval) { | ||
/// An error occurred | ||
HARNESS_ASSERT(); | ||
} else { | ||
HARNESS_STOP(); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.