All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Andryuk <jason.andryuk@amd.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Anthony PERARD <anthony.perard@vates.tech>,
	<xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 1/4] libacpi: Build TPM2 tables for the TIS interface
Date: Tue, 17 Nov 2026 20:15:57 -0500	[thread overview]
Message-ID: <f4fd77a4-bdf2-4d29-bc3b-c8ce314f7385@amd.com> (raw)
In-Reply-To: <6213ab52-73ad-46d8-83eb-0ab7161b2a8f@suse.com>

On 2026-11-16 08:30, Jan Beulich wrote:
> On 07.11.2026 00:15, Jason Andryuk wrote:

>> @@ -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?

Well, I don't expect there to be more than these two on x86.

>> +            {
>> +                if ( config->tis_hdr[0] == 0 || config->tis_hdr[0] == 0xffff ||
>> +                     config->tis_hdr[1] == 0 || config->tis_hdr[1] == 0xffff )

I'm going to add a prerequisite patch that moves this probing into 
hvmloader.

> 
>> +                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)?

Yes, sounds good.

>> @@ -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.

More local variables streamlines this away.

>> --- /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?)

Yes, it is a hardcoded address in QEMU for TPM-TIS.  More generally, 
0xfed4xxxx is standardized by the Trusted Computing Group for TPM TIS on 
x86.

ARM defines assorted GUEST_* values for ram and mmio.  Something like 
that could be done for x86.  Though using them in an .asl file isn't 
friendly.  TPM_REGISTER_BASE is already a define.  That could be placed 
in the comment at least?

Thanks,
Jason


  reply	other threads:[~2026-11-18  1:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 23:15 [PATCH 0/4] libxl TPM emulator support Jason Andryuk
2026-11-06 23:15 ` [PATCH 1/4] libacpi: Build TPM2 tables for the TIS interface Jason Andryuk
2026-11-16 13:30   ` Jan Beulich
2026-11-18  1:15     ` Jason Andryuk [this message]
2026-11-18  7:34       ` Jan Beulich
2026-11-06 23:15 ` [PATCH 2/4] hvmloader: Support the TIS interface for TPM 2.0 Jason Andryuk
2026-11-16 13:36   ` Jan Beulich
2026-11-06 23:15 ` [PATCH 3/4] tools/libxl: add emulated TPM support backed by swtpm Jason Andryuk
2026-11-09 19:54   ` Nick Rosbrook
2026-11-06 23:15 ` [PATCH 4/4] libxl: Add emulated TPM support on ARM Jason Andryuk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f4fd77a4-bdf2-4d29-bc3b-c8ce314f7385@amd.com \
    --to=jason.andryuk@amd.com \
    --cc=anthony.perard@vates.tech \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.