Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit 00a2f86

Browse files
liuw1jyao1
authored andcommitted
Remove unsafe crate paste
Signed-off-by: Wei Liu <[email protected]>
1 parent 217a635 commit 00a2f86

File tree

5 files changed

+32
-62
lines changed

5 files changed

+32
-62
lines changed

Cargo.lock

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

src/spdm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition = "2021"
88
[dependencies]
99
global = { path = "../global" }
1010
log = "0.4.13"
11-
paste = "1.0"
1211

1312
ring = { version = "0.17.6" }
1413
spin = "0.9.2"

src/tdtunnel/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition = "2021"
88
[dependencies]
99
global = { path = "../global" }
1010
log = "0.4.13"
11-
paste = "1.0"
1211
x86 = "0.47.0"
1312
x86_64 = "0.14.9"
1413

src/tdtunnel/src/interrupt.rs

Lines changed: 32 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,46 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
use paste::paste;
6-
75
use core::sync::atomic::{AtomicU8, Ordering};
86
pub use td_exception::*;
97
use td_payload::arch::apic::{disable, enable_and_hlt};
108
use td_payload::interrupt_handler_template;
9+
1110
pub const NOTIFY_VALUE_CLEAR: u8 = 0;
1211
pub const NOTIFY_VALUE_SET: u8 = 1;
1312

14-
#[macro_export]
15-
macro_rules! register_interrupt {
16-
($name:ident, $notifiy_vector:expr) => {
17-
18-
paste! {
19-
const [<NOTIFY_VECTOR_ $name:upper>]: u8 = $notifiy_vector;
20-
static [<NOTIFY_ $name:upper>]: AtomicU8 = AtomicU8::new(NOTIFY_VALUE_CLEAR);
21-
interrupt_handler_template!([<vmm_notification_ $name:lower>], _stack, {
22-
[<NOTIFY_ $name:upper>].store(NOTIFY_VALUE_SET, Ordering::SeqCst);
23-
});
24-
25-
pub fn [<register_vmm_notification_ $name:lower>]() {
26-
// log::info!("Calling {:?}", stringify!([<register_vmm_notification_ $name:lower>]));
27-
// #[cfg(test)]
28-
// return;
29-
30-
// Setup interrupt handler
31-
unsafe {
32-
idt::register_handler([<NOTIFY_VECTOR_ $name:upper>], [<vmm_notification_ $name:lower>]);
33-
}
34-
}
35-
36-
pub fn [<wait_for_vmm_notification_ $name:lower>]() {
37-
// #[cfg(test)]
38-
// return;
39-
40-
// log::info!("Calling {:?}", stringify!([<wait_for_vmm_notification_ $name:lower>]));
13+
// 32~255 are available
14+
pub const INTERRUPT_VECTOR_WAIT_FOR_REQUEST: u8 = 32;
4115

42-
while([<NOTIFY_ $name:upper>].load(Ordering::SeqCst) != NOTIFY_VALUE_SET){
43-
enable_and_hlt();
44-
if ([<NOTIFY_ $name:upper>].load(Ordering::SeqCst) == NOTIFY_VALUE_SET){
45-
break;
46-
}
47-
}
48-
disable();
16+
// Define a static atomic variable to store the notification state.
17+
static NOTIFY_WAIT_FOR_REQUEST: AtomicU8 = AtomicU8::new(NOTIFY_VALUE_CLEAR);
18+
const NOTIFY_VECTOR_WAIT_FOR_REQUEST: u8 = INTERRUPT_VECTOR_WAIT_FOR_REQUEST;
19+
20+
// Define the interrupt handler via the provided interrupt_handler_template macro.
21+
interrupt_handler_template!(vmm_notification_wait_for_request, _stack, {
22+
NOTIFY_WAIT_FOR_REQUEST.store(NOTIFY_VALUE_SET, Ordering::SeqCst);
23+
});
24+
25+
// Function to register the VMM notification interrupt.
26+
pub fn register_vmm_notification_wait_for_request() {
27+
// Setup interrupt handler.
28+
unsafe {
29+
idt::register_handler(
30+
NOTIFY_VECTOR_WAIT_FOR_REQUEST,
31+
vmm_notification_wait_for_request,
32+
);
33+
}
34+
}
4935

50-
// log::debug!("============== WOKE UP ============\n");
51-
// log::debug!("NOTIFY_WAIT_FOR_REQUEST:{:?}\n", NOTIFY_WAIT_FOR_REQUEST);
52-
// log::debug!("NOTIFY_REPORT_STATUS:{:?}\n", NOTIFY_REPORT_STATUS);
53-
// log::debug!("NOTIFY_SPDM_PCI_DOE:{:?}\n", NOTIFY_SPDM_PCI_DOE);
54-
// log::debug!("NOTIFY_SHUTDOWN:{:?}\n", NOTIFY_SHUTDOWN);
55-
// log::debug!("NOTIFY_SERVICE_QUERY:{:?}\n", NOTIFY_SERVICE_QUERY);
56-
[<NOTIFY_ $name:upper>].store(NOTIFY_VALUE_CLEAR, Ordering::SeqCst);
57-
}
36+
// Function to wait for the VMM notification interrupt.
37+
pub fn wait_for_vmm_notification_wait_for_request() {
38+
while NOTIFY_WAIT_FOR_REQUEST.load(Ordering::SeqCst) != NOTIFY_VALUE_SET {
39+
enable_and_hlt();
40+
if NOTIFY_WAIT_FOR_REQUEST.load(Ordering::SeqCst) == NOTIFY_VALUE_SET {
41+
break;
5842
}
59-
};
43+
}
44+
disable();
45+
// Reset notification state.
46+
NOTIFY_WAIT_FOR_REQUEST.store(NOTIFY_VALUE_CLEAR, Ordering::SeqCst);
6047
}
61-
62-
// 32~255 are available
63-
pub const INTERRUPT_VECTOR_WAIT_FOR_REQUEST: u8 = 32;
64-
65-
register_interrupt!(wait_for_request, INTERRUPT_VECTOR_WAIT_FOR_REQUEST);

src/vtpmtd/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ x86_64 = "0.14.9"
1616
zerocopy = { version = "0.7.31", features = ["derive"] }
1717
anyhow = { version = "1.0.68", default-features = false }
1818
sha2 = { version = "0.10.6", default-features = false, features = ["force-soft"]}
19-
paste = "1.0"
2019
bytes = { version="1", default-features=false }
2120
der = {version = "0.7.9", features = ["oid", "alloc", "derive"]}
2221

0 commit comments

Comments
 (0)