Skip to content

Commit c6eb8e1

Browse files
committed
Change guest tracing to use flatbuffers serialization
Signed-off-by: Doru Blânzeanu <[email protected]>
1 parent 2e3ff78 commit c6eb8e1

File tree

13 files changed

+280
-490
lines changed

13 files changed

+280
-490
lines changed

Cargo.lock

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hyperlight_guest/src/exit.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ pub fn halt() {
3434
unsafe {
3535
asm!("hlt",
3636
in("r8") OutBAction::TraceBatch as u64,
37-
in("r9") tbi.guest_start_tsc,
38-
in("r10") tbi.spans_ptr,
39-
in("r11") tbi.events_ptr,
37+
in("r9") tbi.serialized_data.as_ptr() as u64,
38+
in("r10") tbi.serialized_data.len() as u64,
4039
options(nostack)
4140
)
4241
};
@@ -134,9 +133,8 @@ pub(crate) unsafe fn out32(port: u16, val: u32) {
134133
in("dx") port,
135134
in("eax") val,
136135
in("r8") OutBAction::TraceBatch as u64,
137-
in("r9") tbi.guest_start_tsc,
138-
in("r10") tbi.spans_ptr,
139-
in("r11") tbi.events_ptr,
136+
in("r9") tbi.serialized_data.as_ptr() as u64,
137+
in("r10") tbi.serialized_data.len() as u64,
140138
options(preserves_flags, nomem, nostack)
141139
)
142140
};

src/hyperlight_guest_tracing/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ readme.workspace = true
1010
description = """Provides the tracing functionality for the hyperlight guest."""
1111

1212
[dependencies]
13-
heapless = { version = "0.9.1", features = ["serde"] }
1413
hyperlight-common = { workspace = true, default-features = false }
1514
spin = "0.10.0"
1615
tracing = { version = "0.1.41", default-features = false, features = ["attributes"] }

src/hyperlight_guest_tracing/src/lib.rs

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ limitations under the License.
1515
*/
1616

1717
#![no_std]
18-
use heapless as hl;
1918

2019
/// Expose invariant TSC module
2120
pub mod invariant_tsc;
@@ -42,102 +41,6 @@ pub use trace::{
4241
set_start_tsc,
4342
};
4443

45-
/// Maximum number of spans that the guest can store
46-
const MAX_NO_OF_SPANS: usize = 10;
47-
/// Maximum number of events that the guest can store
48-
const MAX_NO_OF_EVENTS: usize = 10;
49-
/// Maximum length a name can have in a span/event
50-
const MAX_NAME_LENGTH: usize = 64;
51-
/// Maximum length the target can have in a span/event
52-
const MAX_TARGET_LENGTH: usize = 64;
53-
/// Maximum length key of a Field can have
54-
const MAX_FIELD_KEY_LENGTH: usize = 32;
55-
/// Maximum length value of a Field can have
56-
const MAX_FIELD_VALUE_LENGTH: usize = 96;
57-
/// Maximum number of fields a span/event can have
58-
const MAX_NO_OF_FIELDS: usize = 8;
59-
60-
/// Alias for the complicated heapless::Vec type for Spans
61-
pub type Spans = hl::Vec<
62-
GuestSpan<
63-
MAX_NAME_LENGTH,
64-
MAX_TARGET_LENGTH,
65-
MAX_FIELD_KEY_LENGTH,
66-
MAX_FIELD_VALUE_LENGTH,
67-
MAX_NO_OF_FIELDS,
68-
>,
69-
MAX_NO_OF_SPANS,
70-
>;
71-
72-
/// Alias for the complicated heapless::Vec type for Events
73-
pub type Events = hl::Vec<
74-
GuestEvent<MAX_NAME_LENGTH, MAX_FIELD_KEY_LENGTH, MAX_FIELD_VALUE_LENGTH, MAX_NO_OF_FIELDS>,
75-
MAX_NO_OF_EVENTS,
76-
>;
77-
78-
/// The trace level assigned to a span/event
79-
#[derive(Debug, Copy, Clone)]
80-
pub enum TraceLevel {
81-
Error,
82-
Warn,
83-
Info,
84-
Debug,
85-
Trace,
86-
}
87-
88-
impl From<tracing::Level> for TraceLevel {
89-
fn from(value: tracing::Level) -> Self {
90-
match value {
91-
tracing::Level::ERROR => Self::Error,
92-
tracing::Level::WARN => Self::Warn,
93-
tracing::Level::INFO => Self::Info,
94-
tracing::Level::DEBUG => Self::Debug,
95-
tracing::Level::TRACE => Self::Trace,
96-
}
97-
}
98-
}
99-
impl From<TraceLevel> for tracing::Level {
100-
fn from(value: TraceLevel) -> Self {
101-
match value {
102-
TraceLevel::Error => Self::ERROR,
103-
TraceLevel::Warn => Self::WARN,
104-
TraceLevel::Info => Self::INFO,
105-
TraceLevel::Debug => Self::DEBUG,
106-
TraceLevel::Trace => Self::TRACE,
107-
}
108-
}
109-
}
110-
111-
/// The structure in which a guest stores Span information
112-
pub struct GuestSpan<
113-
const N: usize,
114-
const T: usize,
115-
const FK: usize,
116-
const FV: usize,
117-
const F: usize,
118-
> {
119-
pub id: u64,
120-
pub parent_id: Option<u64>,
121-
pub level: TraceLevel,
122-
/// Span name
123-
pub name: hl::String<N>,
124-
/// Filename
125-
pub target: hl::String<T>,
126-
pub start_tsc: u64,
127-
pub end_tsc: Option<u64>,
128-
pub fields: hl::Vec<(hl::String<FK>, hl::String<FV>), F>,
129-
}
130-
131-
/// The structure in which a guest stores Event information
132-
pub struct GuestEvent<const N: usize, const FK: usize, const FV: usize, const F: usize> {
133-
pub parent_id: u64,
134-
pub level: TraceLevel,
135-
pub name: hl::String<N>,
136-
/// Event name
137-
pub tsc: u64,
138-
pub fields: hl::Vec<(hl::String<FK>, hl::String<FV>), F>,
139-
}
140-
14144
/// This module is gated because some of these types are also used on the host, but we want
14245
/// only the guest to allocate and allow the functionality intended for the guest.
14346
#[cfg(feature = "trace")]

0 commit comments

Comments
 (0)