vmm: Add required acpi entries for vtpm device

Add an TPM2 entry to DSDT ACPI table. Add a TPM2 table to guest's ACPI.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
Co-authored-by: Sean Yoo <t-seanyoo@microsoft.com>
This commit is contained in:
Praveen K Paladugu
2022-08-12 20:28:04 +00:00
committed by Rob Bradford
parent 7122e2989c
commit af261f231c
3 changed files with 57 additions and 2 deletions

View File

@@ -4167,6 +4167,29 @@ fn numa_node_id_from_memory_zone_id(numa_nodes: &NumaNodes, memory_zone_id: &str
None
}
struct TpmDevice {}
impl Aml for TpmDevice {
fn to_aml_bytes(&self) -> Vec<u8> {
aml::Device::new(
"TPM2".into(),
vec![
&aml::Name::new("_HID".into(), &"MSFT0101"),
&aml::Name::new("_STA".into(), &(0xF_usize)),
&aml::Name::new(
"_CRS".into(),
&aml::ResourceTemplate::new(vec![&aml::Memory32Fixed::new(
true,
layout::TPM_START.0 as u32,
layout::TPM_SIZE as u32,
)]),
),
],
)
.to_aml_bytes()
}
}
impl Aml for DeviceManager {
fn append_aml_bytes(&self, bytes: &mut Vec<u8>) {
#[cfg(target_arch = "aarch64")]
@@ -4328,6 +4351,13 @@ impl Aml for DeviceManager {
)
.append_aml_bytes(bytes);
if self.config.lock().unwrap().tpm.is_some() {
// Add tpm device
let tpm_acpi = TpmDevice {};
let tpm_dsdt_data = tpm_acpi.to_aml_bytes();
bytes.extend_from_slice(tpm_dsdt_data.as_slice());
}
self.ged_notification_device
.as_ref()
.unwrap()