Skip to content

Commit 7e0d035

Browse files
committed
feat(tdx): add UEFI HOB definitions for TDX virtual machines
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
1 parent ca9a64b commit 7e0d035

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

alioth/src/firmware/firmware.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ pub mod acpi;
1919
pub mod dt;
2020
#[path = "ovmf/ovmf.rs"]
2121
pub mod ovmf;
22+
#[path = "uefi/uefi.rs"]
23+
pub mod uefi;
2224

2325
use snafu::Snafu;
2426

alioth/src/firmware/uefi/uefi.rs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Copyright 2026 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
16+
17+
use crate::{bitflags, consts};
18+
19+
consts! {
20+
#[derive(Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
21+
pub struct HobType(u16) {
22+
HANDOFF = 0x0001;
23+
RESOURCE_DESCRIPTOR = 0x0003;
24+
END_OF_HOB_LIST = 0xffff;
25+
}
26+
}
27+
28+
#[repr(C)]
29+
#[derive(Debug, Clone, Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
30+
pub struct HobGenericHeader {
31+
pub r#type: HobType,
32+
pub length: u16,
33+
pub reserved: u32,
34+
}
35+
36+
pub const HOB_HANDOFF_TABLE_VERSION: u32 = 0x9;
37+
38+
#[repr(C)]
39+
#[derive(Debug, Clone, Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
40+
pub struct HobHandoffInfoTable {
41+
pub hdr: HobGenericHeader,
42+
pub version: u32,
43+
pub boot_mode: u32,
44+
pub memory_top: u64,
45+
pub memory_bottom: u64,
46+
pub free_memory_top: u64,
47+
pub free_memory_bottom: u64,
48+
pub end_of_hob_list: u64,
49+
}
50+
51+
consts! {
52+
#[derive(Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
53+
pub struct HobResourceType(u32) {
54+
SYSTEM_MEMORY = 0x00000000;
55+
MEMORY_UNACCEPTED = 0x00000007;
56+
}
57+
}
58+
59+
bitflags! {
60+
#[derive(Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
61+
pub struct ResourceAttr(u32) {
62+
PRESENT = 1 << 0;
63+
INIT = 1 << 1;
64+
TESTED = 1 << 2;
65+
}
66+
}
67+
68+
#[repr(C)]
69+
#[derive(Debug, Clone, Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
70+
pub struct HobResourceDesc {
71+
pub hdr: HobGenericHeader,
72+
pub owner: [u8; 16],
73+
pub r#type: HobResourceType,
74+
pub attr: ResourceAttr,
75+
pub address: u64,
76+
pub len: u64,
77+
}

0 commit comments

Comments
 (0)