TPM2 (Trusted Platform Module) userspace development
 help / color / mirror / Atom feed
* [tpm2] Re: Installing on FreeBSD?
@ 2022-03-31 11:16 Fuchs, Andreas
  0 siblings, 0 replies; 13+ messages in thread
From: Fuchs, Andreas @ 2022-03-31 11:16 UTC (permalink / raw)
  To: tpm2

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

Could you give us the complete Error message ?

Typical fault No1 is that the tpm pseudo-file is not accessible by the current user.

Under linux this is /dev/tpm0 I don't know if it's the same on FreeBSD.

Cheers,
Andreas

________________________________________
Von: John Connett <jrc(a)skylon.me.uk>
Gesendet: Donnerstag, 31. März 2022 12:55
An: tpm2(a)lists.01.org
Betreff: [tpm2] Installing on FreeBSD?

Is there a simple, step-by-step guide for installing tpm2 on FreeBSD?

I started with a FreeBSD 13.0-RELEASE-p10 installation on x86_64 and installed the following with "pkg install":

  *   tpm2-abrmd-2.4.0
  *   tpm2-tools-5.2
  *   tpm2-tss-3.1.0

then added tpm2_abrmd_enable="YES" and dbus_enable="YES" to /etc/rc.conf. The user includes "_tss" in its groups.

Attempts to run tpm2_getrandom fail with "Could not initialize TCTI file".

It appears that I have missed some important steps!

The equivalent on Ubuntu just works.

Thanks
--
John

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-03-31 13:24 John Connett
  0 siblings, 0 replies; 13+ messages in thread
From: John Connett @ 2022-03-31 13:24 UTC (permalink / raw)
  To: tpm2

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

On 31/03/2022 12:16, Fuchs, Andreas wrote:

> Could you give us the complete Error message ?
>
> Typical fault No1 is that the tpm pseudo-file is not accessible by the current user.
>
> Under linux this is /dev/tpm0 I don't know if it's the same on FreeBSD.

Looks like that is the problem! It has been a while since I used 
FreeBSD. I think the equivalent of udev in Linux is devd?

Script started on Thu Mar 31 14:16:08 2022
$ ls -l /dev/tpm*
crw-------  1 root  wheel  0x52 Mar 31 10:52 /dev/tpm0
$ tpm2_getrandom 32 | hd

** (process:3209): ^[[1;33mWARNING^[[0m **: ^[[34m14:16:37.199^[[0m: Failed 
to create connection with service: 
GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name 
com.intel.tss2.Tabrmd was not provided by any .service files
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:154:tcti_from_file() Could not 
initialize TCTI file: libtss2-tcti-tabrmd.so.0
ERROR:tcti:src/tss2-tcti/tcti-device.c:443:Tss2_Tcti_Device_Init() 
Failed to open specified TCTI device file /dev/tpmrm0: No such file or 
directory
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:154:tcti_from_file() Could not 
initialize TCTI file: libtss2-tcti-device.so.0
ERROR:tcti:src/tss2-tcti/tcti-device.c:443:Tss2_Tcti_Device_Init() 
Failed to open specified TCTI device file /dev/tpm0: Permission denied
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:154:tcti_from_file() Could not 
initialize TCTI file: libtss2-tcti-device.so.0
WARNING:tcti:src/util/io.c:253:socket_connect() Failed to connect to 
host 127.0.0.1, port 2321: errno 61: Connection refused
ERROR:tcti:src/tss2-tcti/tcti-swtpm.c:591:Tss2_Tcti_Swtpm_Init() Cannot 
connect to swtpm TPM socket
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:154:tcti_from_file() Could not 
initialize TCTI file: libtss2-tcti-swtpm.so.0
WARNING:tcti:src/util/io.c:253:socket_connect() Failed to connect to 
host 127.0.0.1, port 2321: errno 61: Connection refused
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:154:tcti_from_file() Could not 
initialize TCTI file: libtss2-tcti-mssim.so.0
ERROR:tcti:src/tss2-tcti/tctildr-dl.c:254:tctildr_get_default() No 
standard TCTI could be loaded
ERROR:tcti:src/tss2-tcti/tctildr.c:428:Tss2_TctiLdr_Initialize_Ex() 
Failed to instantiate TCTI
ERROR: Could not load tcti, got: "(null)"
$ exit

Script done on Thu Mar 31 14:16:39 2022

> Cheers,
> Andreas
>
> ________________________________________
> Von: John Connett <jrc(a)skylon.me.uk>
> Gesendet: Donnerstag, 31. März 2022 12:55
> An: tpm2(a)lists.01.org
> Betreff: [tpm2] Installing on FreeBSD?
>
> Is there a simple, step-by-step guide for installing tpm2 on FreeBSD?
>
> I started with a FreeBSD 13.0-RELEASE-p10 installation on x86_64 and installed the following with "pkg install":
>
>    *   tpm2-abrmd-2.4.0
>    *   tpm2-tools-5.2
>    *   tpm2-tss-3.1.0
>
> then added tpm2_abrmd_enable="YES" and dbus_enable="YES" to /etc/rc.conf. The user includes "_tss" in its groups.
>
> Attempts to run tpm2_getrandom fail with "Could not initialize TCTI file".
>
> It appears that I have missed some important steps!
>
> The equivalent on Ubuntu just works.
>
> Thanks
> --
> John

[-- Attachment #2: OpenPGP_0x8F3115112EB8DB54.asc --]
[-- Type: application/pgp-keys, Size: 2164 bytes --]

[-- Attachment #3: OpenPGP_signature.sig --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-03-31 14:05 Tadeusz Struk
  0 siblings, 0 replies; 13+ messages in thread
From: Tadeusz Struk @ 2022-03-31 14:05 UTC (permalink / raw)
  To: tpm2

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

On 3/31/22 03:55, John Connett wrote:
> Is there a simple, step-by-step guide for installing tpm2 on FreeBSD?

What about:
$ sudo pkg install tpm2-abrmd tpm2-tools

That should install and configure everything.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-03-31 19:16 John Connett
  0 siblings, 0 replies; 13+ messages in thread
From: John Connett @ 2022-03-31 19:16 UTC (permalink / raw)
  To: tpm2

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

On 31/03/2022 15:05, Tadeusz Struk wrote:

> On 3/31/22 03:55, John Connett wrote:
>> Is there a simple, step-by-step guide for installing tpm2 on FreeBSD?
>
> What about:
> $ sudo pkg install tpm2-abrmd tpm2-tools
>
> That should install and configure everything.

That's what I would have hoped. However, I've found several problems:

 1. /usr/local/etc/rc.d/tpm2-abrmd
    The line starting "desc=" breaks the script because of the un-quoted
    multi-word description text value. Putting quotes around the text
    value fixes it.
 2. /dev/tpm0
    This has owner root. A temporary fix is to change the owner to
    "_tss" which allows tpm2_getrandom to work. Not sure how the
    ownership and permissions are supposed to be set?
 3. Hyper-V Virtual TPM not found
    With FreeBSD installed on a Generation 2 VM on a Windows 11 host the
    Virtual TPM is not found. Ubuntu installed on the same VM does find
    the Virtual TPM.

Not quite as smooth as I anticipated. However, the problems are probably 
with the packaging for FreeBSD rather than tpm2-software issues. I've 
copied this to the maintainer of tpm2-tss for FreeBSD in case they have 
any comments.

Thanks
--
John


[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 1783 bytes --]

[-- Attachment #3: OpenPGP_0x8F3115112EB8DB54.asc --]
[-- Type: application/pgp-keys, Size: 2164 bytes --]

[-- Attachment #4: OpenPGP_signature.sig --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-03-31 19:50 Tadeusz Struk
  0 siblings, 0 replies; 13+ messages in thread
From: Tadeusz Struk @ 2022-03-31 19:50 UTC (permalink / raw)
  To: tpm2

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

On 3/31/22 12:16, John Connett wrote:
> That's what I would have hoped. However, I've found several problems:
> 
>  1. /usr/local/etc/rc.d/tpm2-abrmd
>     The line starting "desc=" breaks the script because of the un-quoted
>     multi-word description text value. Putting quotes around the text value
>     fixes it.

Right, that will be fixed soon.

>  2. /dev/tpm0
>     This has owner root. A temporary fix is to change the owner to "_tss" which
>     allows tpm2_getrandom to work. Not sure how the ownership and permissions
>     are supposed to be set?

Right, we are missing some udev rules here.

>  3. Hyper-V Virtual TPM not found
>     With FreeBSD installed on a Generation 2 VM on a Windows 11 host the Virtual
>     TPM is not found. Ubuntu installed on the same VM does find the Virtual TPM.

did you "sudo kldload tpm" ?

> Not quite as smooth as I anticipated. However, the problems are probably with 
> the packaging for FreeBSD rather than tpm2-software issues. I've copied this to 
> the maintainer of tpm2-tss for FreeBSD in case they have any comments.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-03-31 22:04 John Connett
  0 siblings, 0 replies; 13+ messages in thread
From: John Connett @ 2022-03-31 22:04 UTC (permalink / raw)
  To: tpm2

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


On 31/03/2022 20:50, Tadeusz Struk wrote:
> On 3/31/22 12:16, John Connett wrote:
>> That's what I would have hoped. However, I've found several problems:
>>
>>  1. /usr/local/etc/rc.d/tpm2-abrmd
>>     The line starting "desc=" breaks the script because of the un-quoted
>>     multi-word description text value. Putting quotes around the text 
>> value
>>     fixes it.
>
> Right, that will be fixed soon.
>
>>  2. /dev/tpm0
>>     This has owner root. A temporary fix is to change the owner to 
>> "_tss" which
>>     allows tpm2_getrandom to work. Not sure how the ownership and 
>> permissions
>>     are supposed to be set?
>
> Right, we are missing some udev rules here.
>
>>  3. Hyper-V Virtual TPM not found
>>     With FreeBSD installed on a Generation 2 VM on a Windows 11 host 
>> the Virtual
>>     TPM is not found. Ubuntu installed on the same VM does find the 
>> Virtual TPM.
>
> did you "sudo kldload tpm" ?
I hadn't (on bare hardware the TPM was found automatically). Here's the 
output:

    root(a)atelier2:~ # kldload tpm
    tpmcrb0: <Trusted Platform Module 2.0, CRB mode> iomem
    0xfed40000-0xfed40fff on acpi0
    device_attach: tpmcrb0 attach returned 6
    tpmcrb0: <Trusted Platform Module 2.0, CRB mode> iomem
    0xfed40000-0xfed40fff on acpi0
    device_attach: tpmcrb0 attach returned 6
    root(a)atelier2:~ #

Still no /dev/tpm0
>> Not quite as smooth as I anticipated. However, the problems are 
>> probably with the packaging for FreeBSD rather than tpm2-software 
>> issues. I've copied this to the maintainer of tpm2-tss for FreeBSD in 
>> case they have any comments.
>
Thanks
--
John

[-- Attachment #2: attachment.htm --]
[-- Type: text/html, Size: 2775 bytes --]

[-- Attachment #3: OpenPGP_0x8F3115112EB8DB54.asc --]
[-- Type: application/pgp-keys, Size: 2164 bytes --]

[-- Attachment #4: OpenPGP_signature.sig --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-04-01  1:46 Tadeusz Struk
  0 siblings, 0 replies; 13+ messages in thread
From: Tadeusz Struk @ 2022-04-01  1:46 UTC (permalink / raw)
  To: tpm2

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

On 3/31/22 15:04, John Connett wrote:
>> did you "sudo kldload tpm" ?
> I hadn't (on bare hardware the TPM was found automatically). Here's the output:
> 
>     root(a)atelier2:~ # kldload tpm
>     tpmcrb0: <Trusted Platform Module 2.0, CRB mode> iomem 0xfed40000-0xfed40fff
>     on acpi0
>     device_attach: tpmcrb0 attach returned 6
>     tpmcrb0: <Trusted Platform Module 2.0, CRB mode> iomem 0xfed40000-0xfed40fff
>     on acpi0
>     device_attach: tpmcrb0 attach returned 6
>     root(a)atelier2:~ #
> 
> Still no /dev/tpm0

6 - ENXIO Device not configured. There is something wrong with that device.
You need to debug that first.

https://www.freebsd.org/cgi/man.cgi?query=errno&sektion=2&manpath=freebsd-release-ports

Thanks,
Tadeusz

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-04-04 10:50 John Connett
  0 siblings, 0 replies; 13+ messages in thread
From: John Connett @ 2022-04-04 10:50 UTC (permalink / raw)
  To: tpm2

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

On 01/04/2022 02:46, Tadeusz Struk wrote:

> On 3/31/22 15:04, John Connett wrote:
>>> did you "sudo kldload tpm" ?
>> I hadn't (on bare hardware the TPM was found automatically). Here's 
>> the output:
>>
>>     root(a)atelier2:~ # kldload tpm
>>     tpmcrb0: <Trusted Platform Module 2.0, CRB mode> iomem 
>> 0xfed40000-0xfed40fff
>>     on acpi0
>>     device_attach: tpmcrb0 attach returned 6
>>     tpmcrb0: <Trusted Platform Module 2.0, CRB mode> iomem 
>> 0xfed40000-0xfed40fff
>>     on acpi0
>>     device_attach: tpmcrb0 attach returned 6
>>     root(a)atelier2:~ #
>>
>> Still no /dev/tpm0
>
> 6 - ENXIO Device not configured. There is something wrong with that 
> device.
> You need to debug that first.
>
> https://www.freebsd.org/cgi/man.cgi?query=errno&sektion=2&manpath=freebsd-release-ports 
>
>
> Thanks,
> Tadeusz

I have built a debug kernel and am attempting to debug the tpm module. 
However, the tpm dtrace probes and symbols are not available until 
"kldload tpm" has run by which time the ENXIO error has occurred.

I could pepper the tpm driver code with kernel printf calls but was 
wondering if there is an eaier way?

Thanks
--
John


[-- Attachment #2: OpenPGP_0x8F3115112EB8DB54.asc --]
[-- Type: application/pgp-keys, Size: 2164 bytes --]

[-- Attachment #3: OpenPGP_signature.sig --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-04-04 14:42 Tadeusz Struk
  0 siblings, 0 replies; 13+ messages in thread
From: Tadeusz Struk @ 2022-04-04 14:42 UTC (permalink / raw)
  To: tpm2

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

On 4/4/22 03:50, John Connett wrote:
> I have built a debug kernel and am attempting to debug the tpm module. However, 
> the tpm dtrace probes and symbols are not available until 
> "kldload tpm" has run by which time the ENXIO error has occurred.
> 
> I could pepper the tpm driver code with kernel printf calls but was 
> wondering if there is an eaier way?

There are only two spots where I would suspect it to fail and return ENXIO
from attach. One is on tpmcrb_request_locality():
https://github.com/freebsd/freebsd-src/blob/main/sys/dev/tpm/tpm_crb.c#L171
and the other is AcpiWalkResources():
https://github.com/freebsd/freebsd-src/blob/main/sys/dev/tpm/tpm_crb.c#L203

I would just add some debug printfs there.
Thanks,
Tadeusz

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-04-05 17:03 John Connett
  0 siblings, 0 replies; 13+ messages in thread
From: John Connett @ 2022-04-05 17:03 UTC (permalink / raw)
  To: tpm2

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

On 04/04/2022 15:42, Tadeusz Struk wrote:

> On 4/4/22 03:50, John Connett wrote:
>> I have built a debug kernel and am attempting to debug the tpm 
>> module. However, the tpm dtrace probes and symbols are not available 
>> until "kldload tpm" has run by which time the ENXIO error has occurred.
>>
>> I could pepper the tpm driver code with kernel printf calls but was 
>> wondering if there is an eaier way?
>
> There are only two spots where I would suspect it to fail and return 
> ENXIO
> from attach. One is on tpmcrb_request_locality():
> https://github.com/freebsd/freebsd-src/blob/main/sys/dev/tpm/tpm_crb.c#L171

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?

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

Thanks
--
John


[-- Attachment #2: OpenPGP_0x8F3115112EB8DB54.asc --]
[-- Type: application/pgp-keys, Size: 2164 bytes --]

[-- Attachment #3: OpenPGP_signature.sig --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-04-05 18:20 Tadeusz Struk
  0 siblings, 0 replies; 13+ messages in thread
From: Tadeusz Struk @ 2022-04-05 18:20 UTC (permalink / raw)
  To: tpm2

[-- 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)
                     }
                 }
             }
         }
     }
}



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-04-05 18:50 John Connett
  0 siblings, 0 replies; 13+ messages in thread
From: John Connett @ 2022-04-05 18:50 UTC (permalink / raw)
  To: tpm2

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

On 05/04/2022 19:20, Tadeusz Struk wrote:

> 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: 

Similar here:
# vmstat -i
interrupt                          total       rate
cpu0:timer                        103066         13
cpu1:timer                         72551          9
cpu0:hyperv                        19225          3
cpu1:hyperv                         1850          0
Total                             196692         26

> 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:

I have:
...
/*
   TPM2: Length=52, Revision=3, Checksum=236,
     OEMID=VRTUAL, OEM Table ID=VTPM, OEM Revision=0x1,
     Creator ID=MSFT, Creator Revision=0x1
         ControlArea=fed40000
         StartMethod=7
  */
...
/*
  * Intel ACPI Component Architecture
  * AML/ASL+ Disassembler version 20210930 (64-bit version)
  * Copyright (c) 2000 - 2021 Intel Corporation
  *
  * Disassembling to symbolic ASL+ operators
  *
  * Disassembly of /tmp/acpidump.61CEQi/acpdump.din, Tue Apr  5 19:23:27 
2022
  *
  * Original Table Header:
  *     Signature        "DSDT"
  *     Length           0x0001E184 (123268)
  *     Revision         0x02
  *     Checksum         0x3A
  *     OEM ID           "MSFTVM"
  *     OEM Table ID     "DSDT01"
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "MSFT"
  *     Compiler Version 0x05000000 (83886080)
  */
DefinitionBlock ("", "DSDT", 2, "MSFTVM", "DSDT01", 0x00000001)
{
     OperationRegion (BIOS, SystemMemory, 0xF7FD9000, 0xFF)
     Field (BIOS, ByteAcc, NoLock, Preserve)
     {
         MG2B,   32,
         MG2L,   32,
         HMIB,   32,
         HMIL,   32,
         GCAL,   32,
         GCAH,   32,
         PCNT,   32,
         NVDA,   32,
         SCFG,   8,
         TCFG,   8,
         PCFG,   8,
         HCFG,   8,
         NCFG,   8,
         BCFG,   8,
         SGXE,   8,
         PADE,   8,
         NCNT,   16
     }
...
     If ((TCFG > Zero))
     {
         Device (\_SB.VMOD.TPM2)
         {
             Name (_ADR, Zero)  // _ADR: Address
             Name (_HID, "VTPM0101")  // _HID: Hardware ID
             Name (_CID, "MSFT0101" /* TPM 2.0 Security Device */) // 
_CID: Compatible ID
             Name (_UID, One)  // _UID: Unique ID
             Name (_DDN, "Microsoft Virtual TPM 2.0")  // _DDN: DOS 
Device Name
             Name (_STR, Unicode ("Microsoft Virtual TPM 2.0"))  // 
_STR: Description String
             Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource 
Settings
             {
                 Memory32Fixed (ReadWrite,
                     0xFED40000,         // Address Base
                     0x00001000,         // Address Length
                     )
             })
             Method (_STA, 0, NotSerialized)  // _STA: Status
             {
                 Return (0x0F)
             }

             OperationRegion (GIO, SystemIO, 0x1040, 0x08)
             Field (GIO, DWordAcc, NoLock, Preserve)
             {
                 CTLP,   32,
                 DATP,   32
             }

             Method (TPPI, 2, Serialized)
             {
                 Name (PKG2, Package (0x02)
                 {
                     Zero,
                     Zero
                 })
                 Name (PKG3, Package (0x03)
                 {
                     Zero,
                     Zero,
                     Zero
                 })
                 While (One)
                 {
                     Name (_T_0, 0x00)  // _T_x: Emitted by ASL 
Compiler, x=0-9, A-Z
                     _T_0 = ToInteger (Arg0)
                     If ((_T_0 == Zero))
                     {
                         Return (Buffer (0x02)
                         {
                              0xFF, 
0x01                                       // ..
                         })
                     }
                     ElseIf ((_T_0 == One))
                     {
                         Return ("1.3")
                     }
                     ElseIf ((_T_0 == 0x02))
                     {
                         Return (0x03)
                     }
                     ElseIf ((_T_0 == 0x03))
                     {
                         CTLP = 0x03
                         PKG2 [Zero] = Zero
                         PKG2 [One] = DATP /* \_SB_.VMOD.TPM2.DATP */
                         Return (PKG2) /* \_SB_.VMOD.TPM2.TPPI.PKG2 */
                     }
                     ElseIf ((_T_0 == 0x04))
                     {
                         Return (0x02)
                     }
                     ElseIf ((_T_0 == 0x05))
                     {
                         CTLP = 0x05
                         PKG3 [One] = DATP /* \_SB_.VMOD.TPM2.DATP */
                         CTLP = 0x06
                         PKG3 [0x02] = DATP /* \_SB_.VMOD.TPM2.DATP */
                         PKG3 [Zero] = Zero
                         Return (PKG3) /* \_SB_.VMOD.TPM2.TPPI.PKG3 */
                     }
                     ElseIf ((_T_0 == 0x06))
                     {
                         Return (0x03)
                     }
                     ElseIf ((_T_0 == 0x07))
                     {
                         CTLP = 0x07
                         DATP = DerefOf (Arg1 [Zero])
                         Return (DATP) /* \_SB_.VMOD.TPM2.DATP */
                     }
                     ElseIf ((_T_0 == 0x08))
                     {
                         CTLP = 0x08
                         DATP = DerefOf (Arg1 [Zero])
                         Return (DATP) /* \_SB_.VMOD.TPM2.DATP */
                     }

                     Break
                 }

                 Return (One)
             }

             Method (TMCI, 2, Serialized)
             {
                 While (One)
                 {
                     Name (_T_0, 0x00)  // _T_x: Emitted by ASL 
Compiler, x=0-9, A-Z
                     _T_0 = ToInteger (Arg0)
                     If ((_T_0 == Zero))
                     {
                         Return (Buffer (One)
                         {
0x03                                             // .
                         })
                     }
                     ElseIf ((_T_0 == One))
                     {
                         BADR = 0x31
                         BDAT = DerefOf (Arg1 [Zero])
                         Return (BDAT) /* \_SB_.BDAT */
                     }

                     Break
                 }

                 Return (One)
             }

             Method (_DSM, 4, Serialized)  // _DSM: Device-Specific Method
             {
                 If ((Arg0 == ToUUID 
("3dddfaa6-361b-4eb4-a424-8d10089d1653") /* Physical Presence Interface */))
                 {
                     Return (TPPI (Arg2, Arg3))
                 }

                 If ((Arg0 == ToUUID 
("376054ed-cc13-4675-901c-4756d7f2d45d") /* Unknown UUID */))
                 {
                     Return (TMCI (Arg2, Arg3))
                 }

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


[-- Attachment #2: OpenPGP_0x8F3115112EB8DB54.asc --]
[-- Type: application/pgp-keys, Size: 2164 bytes --]

[-- Attachment #3: OpenPGP_signature.sig --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tpm2] Re: Installing on FreeBSD?
@ 2022-04-12 23:22 jasonadamses
  0 siblings, 0 replies; 13+ messages in thread
From: jasonadamses @ 2022-04-12 23:22 UTC (permalink / raw)
  To: tpm2

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

Antivirus apps for Android do not have a traditional antivirus scanning mechanism, as the Android use an advanced protection mechanism, but it prevents apps from changing the operation of other installed apps, as well as making changes to files and system processes. I was able to find best antivirus iphone apps to protect devices that are available for free or offer long trial periods with premium features in this article: best antivirus apps for phones: https://celltrackingapps.com/free-android-antivirus/

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-04-12 23:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-01  1:46 [tpm2] Re: Installing on FreeBSD? Tadeusz Struk
  -- strict thread matches above, loose matches on Subject: below --
2022-04-12 23:22 jasonadamses
2022-04-05 18:50 John Connett
2022-04-05 18:20 Tadeusz Struk
2022-04-05 17:03 John Connett
2022-04-04 14:42 Tadeusz Struk
2022-04-04 10:50 John Connett
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox