Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src Pull up following revision(s) (requested by maxv in ticke...
details: https://anonhg.NetBSD.org/src/rev/d1f84a1ff79d
branches: netbsd-9
changeset: 1001005:d1f84a1ff79d
user: martin <martin%NetBSD.org@localhost>
date: Wed Oct 16 09:52:38 2019 +0000
description:
Pull up following revision(s) (requested by maxv in ticket #336):
sys/dev/isa/tpm_isa.c: revision 1.6
sys/dev/ic/tpm.c: revision 1.16
sys/dev/isa/tpm_isa.c: revision 1.7
sys/dev/acpi/tpm_acpi.c: revision 1.10
sys/dev/acpi/tpm_acpi.c: revision 1.11
sys/dev/ic/tpmreg.h: revision 1.5
sys/dev/ic/tpmreg.h: revision 1.6
sys/dev/acpi/tpm_acpi.c: revision 1.9
sys/dev/ic/tpmvar.h: revision 1.5
sys/dev/ic/tpmvar.h: revision 1.6
sys/dev/ic/tpmvar.h: revision 1.7
sys/dev/ic/tpm.c: revision 1.14
share/man/man4/tpm.4: revision 1.5
sys/dev/isa/tpm_isa.c: revision 1.5
sys/dev/ic/tpm.c: revision 1.15
Improvements in tpm(4):
- Remove interrupt support, do polling only, avoids unnecessary trouble.
- Simplify a few things.
- Fix the suspend function, the SaveState command is 0x98, not 0x9C.
- Make the driver MP-safe.
- Sync the man page with reality.
-
Add suspend support for TPM 2.0 chips. Check the TPM response also for 1.2
chips. Unfortunately I cannot really test this change since ACPI suspend
does not work on any of my laptops.
-
Provide a better abstraction for the TPM interface. Report it in the ioctl.
diffstat:
share/man/man4/tpm.4 | 68 ++---
sys/dev/acpi/tpm_acpi.c | 61 +---
sys/dev/ic/tpm.c | 562 +++++++++++++++++------------------------------
sys/dev/ic/tpmreg.h | 19 +-
sys/dev/ic/tpmvar.h | 75 ++---
sys/dev/isa/tpm_isa.c | 94 ++++---
6 files changed, 354 insertions(+), 525 deletions(-)
diffs (truncated from 1398 to 300 lines):
diff -r 03c8c9d64040 -r d1f84a1ff79d share/man/man4/tpm.4
--- a/share/man/man4/tpm.4 Wed Oct 16 09:46:55 2019 +0000
+++ b/share/man/man4/tpm.4 Wed Oct 16 09:52:38 2019 +0000
@@ -1,20 +1,33 @@
-.\" $NetBSD: tpm.4,v 1.4 2018/02/22 01:40:49 pgoyette Exp $
-.\"
-.\" Copyright (c) 2010 Hans-Jörg Höxer, <Hans-Joerg.Hoexer%genua.de@localhost>
+.\" $NetBSD: tpm.4,v 1.4.6.1 2019/10/16 09:52:38 martin Exp $
.\"
-.\" Permission to use, copy, modify, and distribute this software for any
-.\" purpose with or without fee is hereby granted, provided that the above
-.\" copyright notice and this permission notice appear in all copies.
+.\" Copyright (c) 2019 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Maxime Villard.
.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
.\"
-.Dd February 22, 2018
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd October 6, 2019
.Dt TPM 4
.Os
.Sh NAME
@@ -22,40 +35,22 @@
.Nd Trusted Platform Module
.Sh SYNOPSIS
.Cd "tpm* at isa? iomem 0xfed40000"
-.Cd "tpm* at isa? iomem 0xfed40000 irq 7"
.Cd "tpm* at acpi?"
.Sh DESCRIPTION
The
.Nm
-driver provides support for various trusted platform modules (TPM) that can
-store cryptographic keys.
+driver provides support for various Trusted Platform Module (TPM) chips.
.Pp
Supported modules:
.Pp
.Bl -bullet -compact -offset indent
.It
-Atmel 97SC3203
-.It
-Broadcom BCM0102
-.It
-Infineon IFX SLD 9630 TT 1.1 and IFX SLB 9635 TT 1.2
+TPM 2.0 chips over ACPI
.It
-Intel INTC0102
-.It
-Sinosun SNS SSX35
-.It
-STM ST19WP18
-.It
-Winbond WEC WPCT200
+TPM 1.2 chips over ISA
.El
.Pp
-The driver can be configured to use an IRQ by providing a free ISA
-interrupt vector using the keyword
-.Em irq
-in the kernel configuration file or using
-.Xr config 1 .
-If not IRQ is specified, the driver uses polling.
-This is the default configuration.
+Note that the supported interface version is TIS1.2 in each case.
.Sh SEE ALSO
.Xr config 1 ,
.Xr intro 4
@@ -64,6 +59,7 @@
The
.Nm
driver was written by
+.An Maxime Villard ,
.An Michael Shalayeff
and
.An Hans-Joerg Hoexer .
diff -r 03c8c9d64040 -r d1f84a1ff79d sys/dev/acpi/tpm_acpi.c
--- a/sys/dev/acpi/tpm_acpi.c Wed Oct 16 09:46:55 2019 +0000
+++ b/sys/dev/acpi/tpm_acpi.c Wed Oct 16 09:52:38 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tpm_acpi.c,v 1.8 2019/06/22 12:57:40 maxv Exp $ */
+/* $NetBSD: tpm_acpi.c,v 1.8.2.1 2019/10/16 09:52:38 martin Exp $ */
/*
* Copyright (c) 2012, 2019 The NetBSD Foundation, Inc.
@@ -30,10 +30,9 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tpm_acpi.c,v 1.8 2019/06/22 12:57:40 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tpm_acpi.c,v 1.8.2.1 2019/10/16 09:52:38 martin Exp $");
#include <sys/param.h>
-#include <sys/device.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/bus.h>
@@ -45,8 +44,6 @@
#include <dev/acpi/acpireg.h>
#include <dev/acpi/acpivar.h>
-#include <dev/isa/isavar.h>
-
#include "ioconf.h"
#define _COMPONENT ACPI_RESOURCE_COMPONENT
@@ -100,70 +97,52 @@
struct acpi_attach_args *aa = aux;
struct acpi_resources res;
struct acpi_mem *mem;
- struct acpi_irq *irq;
bus_addr_t base;
bus_addr_t size;
- int rv, inum;
-
- sc->sc_dev = self;
- sc->sc_ver = TPM_2_0;
+ int rv;
rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS", &res,
&acpi_resource_parse_ops_default);
if (ACPI_FAILURE(rv)) {
- aprint_error_dev(sc->sc_dev, "cannot parse resources %d\n", rv);
+ aprint_error_dev(self, "cannot parse resources %d\n", rv);
return;
}
mem = acpi_res_mem(&res, 0);
if (mem == NULL) {
- aprint_error_dev(sc->sc_dev, "cannot find mem\n");
+ aprint_error_dev(self, "cannot find mem\n");
goto out;
}
if (mem->ar_length != TPM_SPACE_SIZE) {
- aprint_error_dev(sc->sc_dev,
- "wrong size mem %"PRIu64" != %u\n",
+ aprint_error_dev(self, "wrong size mem %"PRIu64" != %u\n",
(uint64_t)mem->ar_length, TPM_SPACE_SIZE);
goto out;
}
-
base = mem->ar_base;
size = mem->ar_length;
+
+ sc->sc_dev = self;
+ sc->sc_ver = TPM_2_0;
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+ sc->sc_busy = false;
+ sc->sc_intf = &tpm_intf_tis12;
sc->sc_bt = aa->aa_memt;
- sc->sc_init = tpm_tis12_init;
- sc->sc_start = tpm_tis12_start;
- sc->sc_read = tpm_tis12_read;
- sc->sc_write = tpm_tis12_write;
- sc->sc_end = tpm_tis12_end;
-
if (bus_space_map(sc->sc_bt, base, size, 0, &sc->sc_bh)) {
aprint_error_dev(sc->sc_dev, "cannot map registers\n");
goto out;
}
- if (!tpm_tis12_probe(sc->sc_bt, sc->sc_bh)) {
- aprint_error_dev(sc->sc_dev, "TIS1.2 probe failed\n");
+ if ((rv = (*sc->sc_intf->probe)(sc->sc_bt, sc->sc_bh)) != 0) {
+ aprint_error_dev(sc->sc_dev, "probe failed, rv=%d\n", rv);
+ goto out1;
+ }
+ if ((rv = (*sc->sc_intf->init)(sc)) != 0) {
+ aprint_error_dev(sc->sc_dev, "cannot init device, rv=%d\n", rv);
goto out1;
}
- irq = acpi_res_irq(&res, 0);
- if (irq == NULL)
- inum = -1;
- else
- inum = irq->ar_irq;
-
- if ((rv = (*sc->sc_init)(sc, inum)) != 0) {
- aprint_error_dev(sc->sc_dev, "cannot init device %d\n", rv);
- goto out1;
- }
-
- if (inum != -1 &&
- (sc->sc_ih = isa_intr_establish(aa->aa_ic, irq->ar_irq,
- IST_EDGE, IPL_TTY, tpm_intr, sc)) == NULL) {
- aprint_error_dev(sc->sc_dev, "cannot establish interrupt\n");
- goto out1;
- }
-
+ if (!pmf_device_register(self, tpm_suspend, tpm_resume))
+ aprint_error_dev(self, "couldn't establish power handler\n");
acpi_resource_cleanup(&res);
return;
diff -r 03c8c9d64040 -r d1f84a1ff79d sys/dev/ic/tpm.c
--- a/sys/dev/ic/tpm.c Wed Oct 16 09:46:55 2019 +0000
+++ b/sys/dev/ic/tpm.c Wed Oct 16 09:52:38 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tpm.c,v 1.13 2019/06/22 12:57:41 maxv Exp $ */
+/* $NetBSD: tpm.c,v 1.13.2.1 2019/10/16 09:52:38 martin Exp $ */
/*
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.13 2019/06/22 12:57:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.13.2.1 2019/10/16 09:52:38 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -65,8 +65,10 @@
#include "ioconf.h"
+CTASSERT(sizeof(struct tpm_header) == 10);
+
#define TPM_BUFSIZ 1024
-#define TPM_HDRSIZE 10
+
#define TPM_PARAM_SIZE 0x0001 /* that's a flag */
/* Timeouts. */
@@ -79,23 +81,6 @@
(TPM_INTF_DATA_AVAIL_INT|TPM_INTF_LOCALITY_CHANGE_INT| \
TPM_INTF_INT_LEVEL_LOW)
-static const struct {
- uint32_t devid;
- const char *name;
- int flags;
-#define TPM_DEV_NOINTS 0x0001
-} tpm_devs[] = {
- { 0x000615d1, "IFX SLD 9630 TT 1.1", 0 },
- { 0x000b15d1, "IFX SLB 9635 TT 1.2", 0 },
- { 0x100214e4, "Broadcom BCM0102", TPM_DEV_NOINTS },
- { 0x00fe1050, "WEC WPCT200", 0 },
- { 0x687119fa, "SNS SSX35", 0 },
- { 0x2e4d5453, "STM ST19WP18", 0 },
- { 0x32021114, "ATML 97SC3203", TPM_DEV_NOINTS },
- { 0x10408086, "INTEL INTC0102", 0 },
- { 0, "", TPM_DEV_NOINTS },
-};
-
static inline int
tpm_tmotohz(int tmo)
{
@@ -108,42 +93,6 @@
}
static int
-tpm_request_locality(struct tpm_softc *sc, int l)
-{
- uint32_t r;
- int to, rv;
-
- if (l != 0)
- return EINVAL;
-
- if ((bus_space_read_1(sc->sc_bt, sc->sc_bh, TPM_ACCESS) &
- (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY)) ==
- (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY))
- return 0;
-
- bus_space_write_1(sc->sc_bt, sc->sc_bh, TPM_ACCESS,
- TPM_ACCESS_REQUEST_USE);
-
- to = tpm_tmotohz(TPM_ACCESS_TMO);
-
- while ((r = bus_space_read_1(sc->sc_bt, sc->sc_bh, TPM_ACCESS) &
Home |
Main Index |
Thread Index |
Old Index