NetBSD Problem Report #59730

From he@smistad.uninett.no  Mon Oct 27 10:49:15 2025
Return-Path: <he@smistad.uninett.no>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 4019F1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 27 Oct 2025 10:49:15 +0000 (UTC)
Message-Id: <20251027104909.C8C7443F099@smistad.uninett.no>
Date: Mon, 27 Oct 2025 11:49:09 +0100 (CET)
From: he@NetBSD.org
Reply-To: he@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: tpm entropy source disabled on Lenovo x200
X-Send-Pr-Version: 3.95

>Number:         59730
>Category:       port-amd64
>Synopsis:       tpm entropy source disabled on Lenovo x200
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-amd64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 27 10:50:00 +0000 2025
>Originator:     he@NetBSD.org
>Release:        NetBSD 11.99.3
>Organization:
I Try...
>Environment:
System: NetBSD 11.99.3 (GENERIC) #5: Sun Oct 26 10:13:39 CET 2025
Architecture: x86_64
Machine: amd64
>Description:
	Installing NetBSD on a "left-over" Lenovo x200 leaves
	the following messages in the kernel message log:

[     1.034955] tpm0 at acpi0 (TPM, INTC0102-1): mem 0xfed40000-0xfed44fff
[     1.034955] tpm0: device 0x10208086 rev 0x6

	and a little later:

[     1.034955] tpm0: write failed, error=5
[     1.034955] tpm0: deactivating entropy source

	On advice from riastradh@, I tried to collect the
	output from 'acpidump -dt', identifying the TPM module,
	and the part which mentions TPM is rather longish, but
	starts out with:

                Device (TPM)
                {
                    Method (_HID, 0, NotSerialized)  // _HID: Hardware ID
                    {
                        TPHY (0x00)
                        If ((TPMV == 0x01))
                        {
                            Return (0x0201D824)
                        }

                        If ((TPMV == 0x02))
                        {
                            Return (0x0435CF4D)
                        }

                        If ((TPMV == 0x03))
                        {
                            Return (0x02016D08)
                        }

                        If ((TPMV == 0x04))
                        {
                            Return (0x01016D08)
                        }

                        If (((TPMV == 0x05) || (TPMV == 0x06)))
                        {
                            Return (0x0010A35C)
                        }

                        If ((TPMV == 0x08))
                        {
                            Return (0x00128D06)
                        }

                        If ((TPMV == 0x09))
                        {
                            Return ("INTC0102")
                        }

                        Return (0x310CD041)
                    }

                    Name (_CID, EisaId ("PNP0C31"))  // _CID: Compatible ID
                    Name (_UID, 0x01)  // _UID: Unique ID

	The full 540KB of that file can be made available.

	(While running the 10.1 kernel, the 'acpidump -dt' output
	was truncated and an error message about "could not read
	acpi table" was produced.  With the 11.99.3 kernel that
	error is gone, and the output appears to be complete.)

	Also looking at where the "write failed" error might come
	from, Taylor pointed at sys/dev/ic/tpm.c, and based on
	suggestions I built a kernel with this diff:

Index: sys/dev/ic/tpm.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/tpm.c,v
retrieving revision 1.29
diff -u -r1.29 tpm.c
--- sys/dev/ic/tpm.c    14 May 2024 13:41:15 -0000      1.29
+++ sys/dev/ic/tpm.c    27 Oct 2025 10:45:13 -0000
@@ -919,8 +919,10 @@

        if (len == 0)
                return 0;
-       if ((rv = tpm12_request_locality(sc, 0)) != 0)
+       if ((rv = tpm12_request_locality(sc, 0)) != 0) {
+               printf("tpm12_request_locality failed\n");
                return rv;
+       }

        cnt = 0;
        while (cnt < len - 1) {
@@ -929,10 +931,12 @@
                        cnt++;
                }
                if ((rv = tpm_waitfor(sc, TPM_STS_VALID, TPM_READ_TMO, sc))) {
+                       printf("tpm_tis12_write / tpm_waitfor failed\n");
                        return rv;
                }
                sc->sc_status = tpm_status(sc);
                if (!(sc->sc_status & TPM_STS_DATA_EXPECT)) {
+                       printf("tpm_tis12_write / no TPM_STS_DATA_EXPECT\n");
                        return EIO;
                }
        }
@@ -941,9 +945,11 @@
        cnt++;

        if ((rv = tpm_waitfor(sc, TPM_STS_VALID, TPM_READ_TMO, sc))) {
+               printf("tpm_tis12_write / tpm_waitfor(2) failed\n");
                return rv;
        }
        if ((sc->sc_status & TPM_STS_DATA_EXPECT) != 0) {
+               printf("tpm_tis12_write / no TPM_STS_DATA_EXPECT(2)\n");
                return EIO;
        }


	And booting with this kernel reveals a bit more:

[     1.035529] tpm0 at acpi0 (TPM, INTC0102-1): mem 0xfed40000-0xfed44fff
[     1.035529] tpm0: device 0x10208086 rev 0x6

	followed later by

[     1.035529] tpm_tis12_write / no TPM_STS_DATA_EXPECT
[     1.035529] tpm0: write failed, error=5
[     1.035529] tpm0: deactivating entropy source

>How-To-Repeat:
	Try to install either 10.1 or 11.99.3 kernel on
	a Lenovo x200.

>Fix:
	Would be nice...

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.