Skip to content

Commit

Permalink
tdx-tdcall: use interrupt blocked flag for TDVMCALL HLT
Browse files Browse the repository at this point in the history
According to GHCI, interrupt blocked flag should be cleared if `RFLAGS.IF=1` or
the `tdcall` instruction immediately follows an `sti` instruction, otherwise this
flag should be set.

Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 authored and jyao1 committed May 24, 2023
1 parent 10568ba commit 3252047
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions tdx-tdcall/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ lazy_static = { version = "1.0", features = ["spin_no_std"] }
log = "0.4.13"
scroll = { version = "0.10", default-features = false, features = ["derive"] }
spin = "0.9.2"
x86_64 = "0.14.9"

[features]
default = []
Expand Down
4 changes: 4 additions & 0 deletions tdx-tdcall/src/tdx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use core::result::Result;
use core::sync::atomic::{fence, Ordering};
use lazy_static::lazy_static;
use x86_64::registers::rflags::{self, RFlags};

use crate::*;

Expand Down Expand Up @@ -78,8 +79,11 @@ lazy_static! {
///
/// Details can be found in TDX GHCI spec section 'TDG.VP.VMCALL<Instruction.HLT>'
pub fn tdvmcall_halt() {
let interrupt_blocked = !rflags::read().contains(RFlags::INTERRUPT_FLAG);

let mut args = TdVmcallArgs {
r11: TDVMCALL_HALT,
r12: interrupt_blocked as u64,
..Default::default()
};

Expand Down

0 comments on commit 3252047

Please sign in to comment.