-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ArthurHeymans/Authorize_Stash_test
- Loading branch information
Showing
99 changed files
with
1,210 additions
and
583 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Versioned Build Test | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
hw-version: | ||
default: "latest" | ||
type: string | ||
rom-ref: | ||
default: "main" | ||
type: string | ||
firmware-version: | ||
default: "main" | ||
type: string | ||
|
||
pull_request: | ||
inputs: | ||
todo-remove-before-merging: | ||
default: "" | ||
type: string | ||
hw-version: | ||
default: "latest" | ||
type: string | ||
rom-ref: | ||
default: "main" | ||
type: string | ||
firmware-version: | ||
default: "main" | ||
type: string | ||
|
||
jobs: | ||
fpga-full-suite-etrng-log: | ||
name: FPGA Suite (etrng, log) | ||
|
||
fpga-full-suite-etrng-nolog: | ||
name: FPGA Suite (etrng, nolog) | ||
|
||
fpga-full-suite-itrng-log: | ||
name: FPGA Suite (itrng, log) | ||
|
||
fpga-full-suite-itrng-nolog: | ||
name: FPGA Suite (itrng, nolog) | ||
|
||
sw-emulator-full-suite-etrng-log: | ||
name: sw-emulator Suite (etrng, log) | ||
|
||
sw-emulator-full-suite-etrng-nolog: | ||
name: sw-emulator Suite (etrng, nolog) | ||
|
||
sw-emulator-full-suite-itrng-log: | ||
name: sw-emulator Suite (itrng, log) | ||
|
||
sw-emulator-full-suite-itrng-nolog: | ||
name: sw-emulator Suite (itrng, nolog) | ||
|
||
build-release: | ||
runs-on: ubuntu-22.04 | ||
permissions: | ||
contents: write |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# WARNING: Do not update this file without the approval of the Caliptra TAC | ||
91b951fbe655919a1e123b86add18ab604d049f6d2b2bbefac4cd554a4411eaf22247973c47490e243b9a5b1d197feb3 caliptra-rom-no-log.bin | ||
105cda4bbc0f2f0096d058eda9090670da0d90c8e3066cb44027843e9a490db61933b524ca78fe78351a7fd26a124c03 caliptra-rom-with-log.bin | ||
133bf3969893178e041b61001d75bfb504be3b3676cac608a40877f1e4b46b4855f86c1859cfc3e22745327102fba4b0 caliptra-rom-no-log.bin | ||
44f5bbbc4b71d7f0926f85b7d81ef7e17f721557b38379b650497eb8dd19d0a74ab5a1e2177c7e99653a878d2daed3b3 caliptra-rom-with-log.bin |
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,78 @@ | ||
// Licensed under the Apache-2.0 license | ||
|
||
// These tests are here so that they are excluded in FPGA tests. | ||
|
||
// These tests don't directly import the CFI code. If they fail, | ||
// this likely indicates that the CFI laundering code may not | ||
// be doing what we want, and we need to investigate. | ||
|
||
#[cfg(test)] | ||
mod test { | ||
|
||
const START: &str = " | ||
#![no_std] | ||
pub fn add(mut a: u32, mut b: u32) -> u32 { | ||
launder(a) + launder(a) + launder(b) + launder(b) | ||
} | ||
"; | ||
|
||
const LAUNDER: &str = " | ||
#[inline(always)] | ||
fn launder(mut val: u32) -> u32 { | ||
// Safety: this is a no-op, since we don't modify the input. | ||
unsafe { | ||
core::arch::asm!( | ||
\"/* {t} */\", | ||
t = inout(reg) val, | ||
); | ||
} | ||
val | ||
}"; | ||
|
||
const NO_LAUNDER: &str = " | ||
#[inline(always)] | ||
fn launder(mut val: u32) -> u32 { | ||
val | ||
} | ||
"; | ||
|
||
fn compile_to_riscv32_asm(src: String) -> String { | ||
let dir = std::env::temp_dir(); | ||
let src_path = dir.join("asm.rs"); | ||
let dst_path = dir.join("asm.s"); | ||
|
||
std::fs::write(src_path.clone(), src).expect("could not write asm file"); | ||
|
||
let p = std::process::Command::new("rustc") | ||
.args([ | ||
"--crate-type=lib", | ||
"--target", | ||
"riscv32imc-unknown-none-elf", | ||
"-C", | ||
"opt-level=s", | ||
"--emit", | ||
"asm", | ||
src_path.to_str().expect("could not convert path"), | ||
"-o", | ||
dst_path.to_str().expect("could not convert path"), | ||
]) | ||
.output() | ||
.expect("failed to compile"); | ||
assert!(p.status.success()); | ||
std::fs::read_to_string(dst_path).expect("could not read asm file") | ||
} | ||
|
||
#[test] | ||
fn test_launder() { | ||
// With no laundering, LLVM can simplify the double add to a shift left. | ||
let src = format!("{}{}", START, NO_LAUNDER); | ||
let asm = compile_to_riscv32_asm(src); | ||
assert!(asm.contains("sll")); | ||
|
||
// With laundering, LLVM cannot simplify the double add and has to use the register twice. | ||
let src = format!("{}{}", START, LAUNDER); | ||
let asm = compile_to_riscv32_asm(src); | ||
assert!(!asm.contains("sll")); | ||
} | ||
} |
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.