TPM2 (Trusted Platform Module) userspace development
 help / color / mirror / Atom feed
From: Tadeusz Struk <tstruk at gmail.com>
To: tpm2@lists.01.org
Subject: [tpm2] Re: Installing on FreeBSD?
Date: Tue, 05 Apr 2022 11:20:31 -0700	[thread overview]
Message-ID: <3454f652-d765-eeea-335b-97a875da6c6a@gmail.com> (raw)
In-Reply-To: 8f99596f-56bd-c34f-d9b2-ce0782c9f11b@skylon.me.uk

[-- Attachment #1: Type: text/plain, Size: 8739 bytes --]

On 4/5/22 10:03, John Connett wrote:
> It's ths one! I added a printf to output the value of "timeout" at:
> https://github.com/freebsd/freebsd-src/blob/main/sys/dev/tpm/tpm_crb.c#L259
> 
> It counts down until timeout <= 0 (in steps of 10000) then ENXIO is returned.
> 
> I've had a quick look at:
> https://trustedcomputinggroup.org/wp-content/uploads/Mobile-Command-Response-Buffer-Interface-v2-r12-Specification_FINAL2.pdf 
> 
> 
> If polling isn't working perhaps interrupt control or some other form of 
> notification is required?

I don't think CRB interface requires irq, in my case no interrupt is registered:
$ vmstat -i
interrupt                          total       rate
irq1: atkbd0                           2          0
cpu0:timer                         17233         28
cpu1:timer                         11371         19
irq25: virtio_pci0                 13987         23
irq26: virtio_pci0                     1          0
irq27: hdac0                          58          0
irq29: virtio_pci2                  5550          9
irq31: virtio_pci1                     1          0
Total                              48203         79


> 
> Is there anything I could dig out of the control structures that would 
> help identify the problem?

Not sure, must be something specific to the windows hyper-V TPM.
I'm running freeBSD13.0 on top of Linux KVM and crb-tpm2.0 and it's working fine.
You may want to compare the ACPI tables to see what's missing. Here what I have:

$ sudo acpidump -dt > dump.txt
$ cat dump.txt
....
/*
   TPM2: Length=76, Revision=4, Checksum=138,
	OEMID=BOCHS, OEM Table ID=BXPC, OEM Revision=0x1,
	Creator ID=BXPC, Creator Revision=0x1
		ControlArea=fed40040
		StartMethod=7
  */
.....
/*
  * Intel ACPI Component Architecture
  * AML/ASL+ Disassembler version 20201113 (64-bit version)
  * Copyright (c) 2000 - 2020 Intel Corporation
  *
  * Disassembling to symbolic ASL+ operators
  *
  * Disassembly of /tmp/acpidump.gpqkvY/acpdump.din, Tue Apr  5 11:02:38 2022
  *
  * Original Table Header:
  *     Signature        "DSDT"
  *     Length           0x0000190A (6410)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
  *     Checksum         0xBC
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPC    "
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)
  */
DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC    ", 0x00000001)
{
     ...
     Scope (\_SB)
     {
     ...
         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
                     0x00001000,         // Address Length
                     )
             })
             Name (_STA, 0x0F)  // _STA: Status
             OperationRegion (TPP2, SystemMemory, 0xFED45100, 0x5A)
             Field (TPP2, AnyAcc, NoLock, Preserve)
             {
                 PPIN,   8,
                 PPIP,   32,
                 PPRP,   32,
                 PPRQ,   32,
                 PPRM,   32,
                 LPPR,   32
             }

             OperationRegion (TPP3, SystemMemory, 0xFED4515A, One)
             Field (TPP3, ByteAcc, NoLock, Preserve)
             {
                 MOVV,   8
             }

             Method (TPFN, 1, Serialized)
             {
                 If ((Arg0 >= 0x0100))
                 {
                     Return (Zero)
                 }

                 OperationRegion (TPP1, SystemMemory, (0xFED45000 + Arg0), One)
                 Field (TPP1, ByteAcc, NoLock, Preserve)
                 {
                     TPPF,   8
                 }

                 Return (TPPF) /* \_SB_.TPM_.TPFN.TPPF */
             }

             Name (TPM2, Package (0x02)
             {
                 Zero,
                 Zero
             })
             Name (TPM3, Package (0x03)
             {
                 Zero,
                 Zero,
                 Zero
             })
             Method (_DSM, 4, Serialized)  // _DSM: Device-Specific Method
             {
                 If ((Arg0 == ToUUID ("3dddfaa6-361b-4eb4-a424-8d10089d1653") /* 
Physical Presence Interface */))
                 {
                     If ((Arg2 == Zero))
                     {
                         Return (Buffer (0x02)
                         {
                              0xFF, 0x01                                       // ..
                         })
                     }

                     If ((Arg2 == One))
                     {
                         Return ("1.3")
                     }

                     If ((Arg2 == 0x02))
                     {
                         Local0 = DerefOf (Arg3 [Zero])
                         Local1 = TPFN (Local0)
                         If (((Local1 & 0x07) == Zero))
                         {
                             Return (One)
                         }

                         PPRQ = Local0
                         PPRM = Zero
                         Return (Zero)
                     }

                     If ((Arg2 == 0x03))
                     {
                         If ((Arg1 == One))
                         {
                             TPM2 [One] = PPRQ /* \_SB_.TPM_.PPRQ */
                             Return (TPM2) /* \_SB_.TPM_.TPM2 */
                         }

                         If ((Arg1 == 0x02))
                         {
                             TPM3 [One] = PPRQ /* \_SB_.TPM_.PPRQ */
                             TPM3 [0x02] = PPRM /* \_SB_.TPM_.PPRM */
                             Return (TPM3) /* \_SB_.TPM_.TPM3 */
                         }
                     }

                     If ((Arg2 == 0x04))
                     {
                         Return (0x02)
                     }

                     If ((Arg2 == 0x05))
                     {
                         TPM3 [One] = LPPR /* \_SB_.TPM_.LPPR */
                         TPM3 [0x02] = PPRP /* \_SB_.TPM_.PPRP */
                         Return (TPM3) /* \_SB_.TPM_.TPM3 */
                     }

                     If ((Arg2 == 0x06))
                     {
                         Return (0x03)
                     }

                     If ((Arg2 == 0x07))
                     {
                         Local0 = DerefOf (Arg3 [Zero])
                         Local1 = TPFN (Local0)
                         If (((Local1 & 0x07) == Zero))
                         {
                             Return (One)
                         }

                         If (((Local1 & 0x07) == 0x02))
                         {
                             Return (0x03)
                         }

                         If ((Arg1 == One))
                         {
                             PPRQ = Local0
                             PPRM = Zero
                         }

                         If ((Arg1 == 0x02))
                         {
                             PPRQ = Local0
                             PPRM = DerefOf (Arg3 [One])
                         }

                         Return (Zero)
                     }

                     If ((Arg2 == 0x08))
                     {
                         Local0 = DerefOf (Arg3 [Zero])
                         Local1 = TPFN (Local0)
                         Return ((Local1 & 0x07))
                     }

                     Return (Buffer (One)
                     {
                          0x00                                             // .
                     })
                 }

                 If ((Arg0 == ToUUID ("376054ed-cc13-4675-901c-4756d7f2d45d") /* 
Unknown UUID */))
                 {
                     If ((Arg2 == Zero))
                     {
                         Return (Buffer (One)
                         {
                              0x03                                             // .
                         })
                     }

                     If ((Arg2 == One))
                     {
                         Local0 = DerefOf (Arg3 [Zero])
                         MOVV = Local0
                         Return (Zero)
                     }
                 }
             }
         }
     }
}



             reply	other threads:[~2022-04-05 18:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05 18:20 Tadeusz Struk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-04-12 23:22 [tpm2] Re: Installing on FreeBSD? jasonadamses
2022-04-05 18:50 John Connett
2022-04-05 17:03 John Connett
2022-04-04 14:42 Tadeusz Struk
2022-04-04 10:50 John Connett
2022-04-01  1:46 Tadeusz Struk
2022-03-31 22:04 John Connett
2022-03-31 19:50 Tadeusz Struk
2022-03-31 19:16 John Connett
2022-03-31 14:05 Tadeusz Struk
2022-03-31 13:24 John Connett
2022-03-31 11:16 Fuchs, Andreas

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=3454f652-d765-eeea-335b-97a875da6c6a@gmail.com \
    --to=tpm2@lists.01.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox