Skip to content

Commit ffc1858

Browse files
committed
tdcall hypercall changes
1 parent 44c248e commit ffc1858

File tree

2 files changed

+4
-16
lines changed
  • openhcl/openhcl_boot/src/arch/x86_64
  • vm/x86/tdcall/src

2 files changed

+4
-16
lines changed

openhcl/openhcl_boot/src/arch/x86_64/tdx.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use tdx_guest_device::protocol::TdReport;
2424
use x86defs::X64_LARGE_PAGE_SIZE;
2525
use x86defs::tdx::RESET_VECTOR_PAGE;
2626
use x86defs::tdx::TdCallResult;
27-
use x86defs::tdx::TdVmCallR10Result;
2827

2928
/// Writes a synthehtic register to tell the hypervisor the OS ID for the boot shim.
3029
fn report_os_id(guest_os_id: u64) {
@@ -157,14 +156,7 @@ pub fn invoke_tdcall_hypercall(
157156
control: hvdef::hypercall::Control,
158157
io: &TdxHypercallPage,
159158
) -> hvdef::hypercall::HypercallOutput {
160-
let result = tdcall_hypercall(&mut TdcallInstruction, control, io.input(), io.output());
161-
match result {
162-
Ok(()) => 0.into(),
163-
Err(val) => {
164-
let TdVmCallR10Result(return_code) = val;
165-
return_code.into()
166-
}
167-
}
159+
tdcall_hypercall(&mut TdcallInstruction, control, io.input(), io.output())
168160
}
169161

170162
/// Global variable to store tsc frequency.

vm/x86/tdcall/src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#![forbid(unsafe_code)]
88

99
use hvdef::HV_PAGE_SIZE;
10+
use hvdef::hypercall::HypercallOutput;
1011
use memory_range::MemoryRange;
1112
use tdx_guest_device::protocol::TdReport;
1213
use thiserror::Error;
@@ -86,7 +87,7 @@ pub fn tdcall_hypercall(
8687
control: hvdef::hypercall::Control,
8788
input_gpa: u64,
8889
output_gpa: u64,
89-
) -> Result<(), TdVmCallR10Result> {
90+
) -> HypercallOutput {
9091
let input = TdcallInput {
9192
leaf: TdCallLeaf::VP_VMCALL,
9293
rcx: 0x0d04, // pass RDX, R8, R10, R11
@@ -114,12 +115,7 @@ pub fn tdcall_hypercall(
114115
}
115116

116117
// TD.VMCALL for Hypercall passes return code in r11
117-
let result = TdVmCallR10Result(output.r11);
118-
119-
match result {
120-
TdVmCallR10Result::SUCCESS => Ok(()),
121-
val => Err(val),
122-
}
118+
HypercallOutput::from(output.r11)
123119
}
124120

125121
/// Perform a tdcall based MSR read. This is done by issuing a TDG.VP.VMCALL.

0 commit comments

Comments
 (0)