Skip to content

Commit 5ab540e

Browse files
eaugermstsirkin
authored andcommitted
arm/acpi: Add the TPM2.0 device under the DSDT
In case it is dynamically instantiated, add the TPM 2.0 device object under the DSDT table in the ACPI namespace. Its HID is MSFT0101 while its current resource settings (CRS) property is initialized with the guest physical address and MMIO size of the device. Signed-off-by: Eric Auger <[email protected]> Reviewed-by: Stefan Berger <[email protected]> Reviewed-by: Igor Mammedov <[email protected]> Message-Id: <[email protected]> Tested-by: Ard Biesheuvel <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent e27e1e6 commit 5ab540e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

hw/arm/virt-acpi-build.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "hw/pci/pci.h"
4747
#include "hw/arm/virt.h"
4848
#include "hw/mem/nvdimm.h"
49+
#include "hw/platform-bus.h"
4950
#include "sysemu/numa.h"
5051
#include "sysemu/reset.h"
5152
#include "sysemu/tpm.h"
@@ -364,6 +365,38 @@ static void acpi_dsdt_add_power_button(Aml *scope)
364365
aml_append(scope, dev);
365366
}
366367

368+
static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms)
369+
{
370+
PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
371+
hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS].base;
372+
SysBusDevice *sbdev = SYS_BUS_DEVICE(tpm_find());
373+
MemoryRegion *sbdev_mr;
374+
hwaddr tpm_base;
375+
376+
if (!sbdev) {
377+
return;
378+
}
379+
380+
tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
381+
assert(tpm_base != -1);
382+
383+
tpm_base += pbus_base;
384+
385+
sbdev_mr = sysbus_mmio_get_region(sbdev, 0);
386+
387+
Aml *dev = aml_device("TPM0");
388+
aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
389+
aml_append(dev, aml_name_decl("_UID", aml_int(0)));
390+
391+
Aml *crs = aml_resource_template();
392+
aml_append(crs,
393+
aml_memory32_fixed(tpm_base,
394+
(uint32_t)memory_region_size(sbdev_mr),
395+
AML_READ_WRITE));
396+
aml_append(dev, aml_name_decl("_CRS", crs));
397+
aml_append(scope, dev);
398+
}
399+
367400
static void
368401
build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
369402
{
@@ -762,6 +795,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
762795
}
763796

764797
acpi_dsdt_add_power_button(scope);
798+
acpi_dsdt_add_tpm(scope, vms);
765799

766800
aml_append(dsdt, scope);
767801

0 commit comments

Comments
 (0)