-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Measure the Cost of Traps, World Switches, and Misaligned Operat… #372
Conversation
@CharlyCst Let's first merge this pr and then the other. So we can see the cycle gain for the decoder |
e98c201
to
e66ee3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, it's cool to have more stats :)
So turns out tracing_firmware
and tracing_firmware_protect_payload
are basically the same file at the exception of the name of the policy according to diff
:
➜ firmware git:(851f56c5) ✗ diff tracing_firmware/main.rs tracing_firmware_protect_payload/main.rs
36c36
< "Default",
---
> "Protect",
74c74
< "Default",
---
> "Protect",
80c80
< "Default",
---
> "Protect",
But can simply read the policy name from the config, as we do in Miralis:
pub const POLICY_NAME: &str = parse_str_or(option_env!("MIRALIS_POLICY_NAME"), "default_policy");
(if the firmware don't have access to it then we should fix that and expose the environment variables too)
Using this we can simply have a single tracing firmware (and so we don't need the library anymore), which will make things much easier to maintain in the long run :)
crates/tracing/src/lib.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am writing some comments here, but as explained in the main review feedback we can simply get rid of this library by having a single tracing firmware and keeping things simple.
So the comments on this file are simply informational.
crates/tracing/src/lib.rs
Outdated
//! Miralis ABI | ||
//! | ||
//! While miralis forwards standard SBI calls to the virtualized firmware, miralis do expose its own | ||
//! ABI for the firmware to interact with. | ||
//! | ||
//! The Miralis ABI tries to be compatible with the SBI specification as best as it can. | ||
//! See: https://github.com/riscv-non-isa/riscv-sbi-doc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy paste from another library, it doesn't explain what this library is doing nor how it should be used. The current doc comment might cause confusion and make the crate less maintainable.
crates/tracing/src/lib.rs
Outdated
values[i] = $in(); | ||
} | ||
|
||
let stats = get_statistics(values); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This macro uses locally-defined function, so it will fail with a compile error when used by another crate or module. There is a simple way to fix this, which is to use an absolute path for each local function used. There is a magic variable $crate
to do that:
let stats = $crate::get_statistics(values)
With the above version the macro can be used without importing the get_statistics
function. In general macros in libraries should encapsulate all of their import so that they work like standard functions.
crates/tracing/src/lib.rs
Outdated
global_asm!( | ||
r#" | ||
.text | ||
.align 4 | ||
.global _empty_handler | ||
_empty_handler: | ||
// Skip illegal instruction (pc += 4) | ||
csrrw x5, mepc, x5 | ||
addi x5, x5, 4 | ||
csrrw x5, mepc, x5 | ||
// Return back to OS | ||
mret | ||
"#, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In libraries we don't want to insert global assembly, because it can override existing symbols and cause at best linker errors, at worst arbitrarily bad things.
e66ee3a
to
804837d
Compare
@CharlyCst Thank you for all the nice and relevants comments. I did the changes. Feel free to review again ;) |
… with the Protect Payload Policy This commit extends the tracing firmware by introducing three new latency measurements in the Protect Payload policy and ensures that no additional performance losses are incurred.
804837d
to
fa7032b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, looks good to me :)
…ions with the Protect Payload Policy
This commit extends the tracing firmware with three new latency measurements in the Protect Payload policy and ensures that no additional performance losses are introduced.