|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 1/4] libacpi: Build TPM2 tables for the TIS interface
On 07.11.2026 00:15, Jason Andryuk wrote:
> --- a/tools/libacpi/Makefile
> +++ b/tools/libacpi/Makefile
> @@ -16,7 +16,7 @@ C_SRC-$(CONFIG_ARM_64) = dsdt_anycpu_arm.c
> DSDT_FILES ?= $(C_SRC-y)
> C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, $(DSDT_FILES))
> H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h)
> -H_SRC += $(addprefix $(ACPI_BUILD_DIR)/, ssdt_tpm.h ssdt_tpm2.h
> ssdt_laptop_slate.h)
> +H_SRC += $(addprefix $(ACPI_BUILD_DIR)/, ssdt_tpm.h ssdt_tpm2.h
> ssdt_tpm2_tis.h ssdt_laptop_slate.h)
I think it's time to wrap this line.
> --- a/tools/libacpi/build.c
> +++ b/tools/libacpi/build.c
> @@ -11,6 +11,7 @@
> #include "ssdt_s4.h"
> #include "ssdt_tpm.h"
> #include "ssdt_tpm2.h"
> +#include "ssdt_tpm2_tis.h"
> #include "ssdt_pm.h"
> #include "ssdt_laptop_slate.h"
> #include <xen/hvm/hvm_info_table.h>
> @@ -444,17 +445,30 @@ static int construct_secondary_tables(struct acpi_ctxt
> *ctxt,
> break;
>
> case 2:
> - /*
> - * Check VID stored in bits 37:32 (3rd 16 bit word) of CRB
> - * identifier register. See table 16 of TCG PC client platform
> - * TPM profile specification for TPM 2.0.
> - */
> - if ( config->crb_id[2] == 0 || config->crb_id[2] == 0xffff )
> - break;
> + if ( config->tpm_interface == ACPI_TPM_INTERFACE_TIS )
Better use switch() right away?
> + {
> + if ( config->tis_hdr[0] == 0 || config->tis_hdr[0] == 0xffff
> ||
> + config->tis_hdr[1] == 0 || config->tis_hdr[1] == 0xffff
> )
> + break;
>
> - ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_tpm2), 16);
> - if (!ssdt) return -1;
> - memcpy(ssdt, ssdt_tpm2, sizeof(ssdt_tpm2));
> + ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_tpm2_tis), 16);
> + if (!ssdt) return -1;
Please can we not gain further instances of this style-violating code? It
would be nice if ...
> + memcpy(ssdt, ssdt_tpm2_tis, sizeof(ssdt_tpm2_tis));
> + }
> + else
> + {
> + /*
> + * Check VID stored in bits 37:32 (3rd 16 bit word) of CRB
> + * identifier register. See table 16 of TCG PC client
> + * platform TPM profile specification for TPM 2.0.
> + */
> + if ( config->crb_id[2] == 0 || config->crb_id[2] == 0xffff )
> + break;
> +
> + ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_tpm2), 16);
> + if (!ssdt) return -1;
... the one you re-indent could be corrected as well. Actually, can't
we consolidate both allocation and ...
> + memcpy(ssdt, ssdt_tpm2, sizeof(ssdt_tpm2));
... copying paths by way of having another pair of local variables
(pointer and size)?
> @@ -471,8 +485,17 @@ static int construct_secondary_tables(struct acpi_ctxt
> *ctxt,
> tpm2->header.creator_id = ACPI_CREATOR_ID;
> tpm2->header.creator_revision = ACPI_CREATOR_REVISION;
> tpm2->platform_class = TPM2_ACPI_CLASS_CLIENT;
> - tpm2->control_area_address = TPM_CRB_CTRL_REQ;
> - tpm2->start_method = TPM2_START_METHOD_CRB;
> + if ( config->tpm_interface == ACPI_TPM_INTERFACE_TIS )
> + {
> + /* The FIFO interface has no control area. */
> + tpm2->control_area_address = 0;
There is a memset() earlier on, so only the comment looks to be needed
here.
> --- /dev/null
> +++ b/tools/libacpi/ssdt_tpm2_tis.asl
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: LGPL-2.1-only */
> +/*
> + * ssdt_tpm2_tis.asl
> + */
> +
> +/* SSDT for TPM 2.0 TIS Interface for Xen with Qemu device model. */
> +
> +DefinitionBlock ("SSDT_TPM2_TIS.aml", "SSDT", 2, "Xen", "HVM", 0)
> +{
> + Device (TPM)
> + {
> + Name (_HID, "MSFT0101" /* TPM 2.0 Security Device */) // _HID:
> Hardware ID
> + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
> + {
> + Memory32Fixed (ReadWrite,
> + 0xFED40000, // Address Base
> + 0x00005000, // Address Length
> + )
I know you're only following what we do elsewhere (i.e. this isn't a
request for you to change anything), but I wonder how we could make sure
that such seemingly arbitrary address range allocations won't ever
conflict. (I assume the base address is dictated by qemu?)
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |