deliverable/linux.git
8 years agoMerge branch 'stable-4.8' of git://git.infradead.org/users/pcmoore/selinux into next
James Morris [Thu, 7 Jul 2016 00:15:34 +0000 (10:15 +1000)] 
Merge branch 'stable-4.8' of git://git.infradead.org/users/pcmoore/selinux into next

8 years agoima: extend the measurement entry specific pcr
Eric Richter [Wed, 1 Jun 2016 18:14:07 +0000 (13:14 -0500)] 
ima: extend the measurement entry specific pcr

Extend the PCR supplied as a parameter, instead of assuming that the
measurement entry uses the default configured PCR.

Signed-off-by: Eric Richter <erichte@linux.vnet.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
8 years agoima: change integrity cache to store measured pcr
Eric Richter [Wed, 1 Jun 2016 18:14:06 +0000 (13:14 -0500)] 
ima: change integrity cache to store measured pcr

IMA avoids re-measuring files by storing the current state as a flag in
the integrity cache. It will then skip adding a new measurement log entry
if the cache reports the file as already measured.

If a policy measures an already measured file to a new PCR, the measurement
will not be added to the list. This patch implements a new bitfield for
specifying which PCR the file was measured into, rather than if it was
measured.

Signed-off-by: Eric Richter <erichte@linux.vnet.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
8 years agoima: redefine duplicate template entries
Eric Richter [Wed, 1 Jun 2016 18:14:05 +0000 (13:14 -0500)] 
ima: redefine duplicate template entries

Template entry duplicates are prevented from being added to the
measurement list by checking a hash table that contains the template
entry digests. However, the PCR value is not included in this comparison,
so duplicate template entry digests with differing PCRs may be dropped.

This patch redefines duplicate template entries as template entries with
the same digest and same PCR values.

Reported-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: Eric Richter <erichte@linux.vnet.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
8 years agoima: change ima_measurements_show() to display the entry specific pcr
Eric Richter [Wed, 1 Jun 2016 18:14:04 +0000 (13:14 -0500)] 
ima: change ima_measurements_show() to display the entry specific pcr

IMA assumes that the same default Kconfig PCR is extended for each
entry. This patch replaces the default configured PCR with the policy
defined PCR.

Signed-off-by: Eric Richter <erichte@linux.vnet.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
8 years agoima: include pcr for each measurement log entry
Eric Richter [Wed, 1 Jun 2016 18:14:03 +0000 (13:14 -0500)] 
ima: include pcr for each measurement log entry

The IMA measurement list entries include the Kconfig defined PCR value.
This patch defines a new ima_template_entry field for including the PCR
as specified in the policy rule.

Signed-off-by: Eric Richter <erichte@linux.vnet.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
8 years agoima: extend ima_get_action() to return the policy pcr
Eric Richter [Wed, 1 Jun 2016 18:14:02 +0000 (13:14 -0500)] 
ima: extend ima_get_action() to return the policy pcr

Different policy rules may extend different PCRs. This patch retrieves
the specific PCR for the matched rule.  Subsequent patches will include
the rule specific PCR in the measurement list and extend the appropriate
PCR.

Signed-off-by: Eric Richter <erichte@linux.vnet.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
8 years agoima: add policy support for extending different pcrs
Eric Richter [Wed, 1 Jun 2016 18:14:01 +0000 (13:14 -0500)] 
ima: add policy support for extending different pcrs

This patch defines a new IMA measurement policy rule option "pcr=",
which allows extending different PCRs on a per rule basis. For example,
the system independent files could extend the default IMA Kconfig
specified PCR, while the system dependent files could extend a different
PCR.

The following is an example of this usage with an SELinux policy; the
rule would extend PCR 11 with system configuration files:

  measure func=FILE_CHECK mask=MAY_READ obj_type=system_conf_t pcr=11

Changelog v3:
- FIELD_SIZEOF returns bytes, not bits. Fixed INVALID_PCR

Signed-off-by: Eric Richter <erichte@linux.vnet.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
8 years agointegrity: add measured_pcrs field to integrity cache
Eric Richter [Wed, 1 Jun 2016 18:14:00 +0000 (13:14 -0500)] 
integrity: add measured_pcrs field to integrity cache

To keep track of which measurements have been extended to which PCRs, this
patch defines a new integrity_iint_cache field named measured_pcrs. This
field is a bitmask of the PCRs measured. Each bit corresponds to a PCR
index. For example, bit 10 corresponds to PCR 10.

Signed-off-by: Eric Richter <erichte@linux.vnet.ibm.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
8 years agonetlabel: Implement CALIPSO config functions for SMACK.
Huw Davies [Mon, 27 Jun 2016 19:06:18 +0000 (15:06 -0400)] 
netlabel: Implement CALIPSO config functions for SMACK.

SMACK uses similar functions to control CIPSO, these are
the equivalent functions for CALIPSO and follow exactly
the same semantics.

int netlbl_cfg_calipso_add(struct calipso_doi *doi_def,
                           struct netlbl_audit *audit_info)
    Adds a CALIPSO doi.

void netlbl_cfg_calipso_del(u32 doi, struct netlbl_audit *audit_info)
    Removes a CALIPSO doi.

int netlbl_cfg_calipso_map_add(u32 doi, const char *domain,
                               const struct in6_addr *addr,
                               const struct in6_addr *mask,
                               struct netlbl_audit *audit_info)
    Creates a mapping between a domain and a CALIPSO doi.  If
    addr and mask are non-NULL this creates an address-selector
    type mapping.

This also extends netlbl_cfg_map_del() to remove IPv6 address-selector
mappings.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agocalipso: Add a label cache.
Huw Davies [Mon, 27 Jun 2016 19:06:17 +0000 (15:06 -0400)] 
calipso: Add a label cache.

This works in exactly the same way as the CIPSO label cache.
The idea is to allow the lsm to cache the result of a secattr
lookup so that it doesn't need to perform the lookup for
every skbuff.

It introduces two sysctl controls:
 calipso_cache_enable - enables/disables the cache.
 calipso_cache_bucket_size - sets the size of a cache bucket.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agocalipso: Add validation of CALIPSO option.
Huw Davies [Mon, 27 Jun 2016 19:06:17 +0000 (15:06 -0400)] 
calipso: Add validation of CALIPSO option.

Lengths, checksum and the DOI are checked.  Checking of the
level and categories are left for the socket layer.

CRC validation is performed in the calipso module to avoid
unconditionally linking crc_ccitt() into ipv6.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agonetlabel: Pass a family parameter to netlbl_skbuff_err().
Huw Davies [Mon, 27 Jun 2016 19:06:16 +0000 (15:06 -0400)] 
netlabel: Pass a family parameter to netlbl_skbuff_err().

This makes it possible to route the error to the appropriate
labelling engine.  CALIPSO is far less verbose than CIPSO
when encountering a bogus packet, so there is no need for a
CALIPSO error handler.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agocalipso: Allow the lsm to label the skbuff directly.
Huw Davies [Mon, 27 Jun 2016 19:06:15 +0000 (15:06 -0400)] 
calipso: Allow the lsm to label the skbuff directly.

In some cases, the lsm needs to add the label to the skbuff directly.
A NF_INET_LOCAL_OUT IPv6 hook is added to selinux to match the IPv4
behaviour.  This allows selinux to label the skbuffs that it requires.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agoipv6: constify the skb pointer of ipv6_find_tlv().
Huw Davies [Mon, 27 Jun 2016 19:06:15 +0000 (15:06 -0400)] 
ipv6: constify the skb pointer of ipv6_find_tlv().

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agocalipso: Allow request sockets to be relabelled by the lsm.
Huw Davies [Mon, 27 Jun 2016 19:05:29 +0000 (15:05 -0400)] 
calipso: Allow request sockets to be relabelled by the lsm.

Request sockets need to have a label that takes into account the
incoming connection as well as their parent's label.  This is used
for the outgoing SYN-ACK and for their child full-socket.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agoipv6: Allow request socks to contain IPv6 options.
Huw Davies [Mon, 27 Jun 2016 19:05:28 +0000 (15:05 -0400)] 
ipv6: Allow request socks to contain IPv6 options.

If set, these will take precedence over the parent's options during
both sending and child creation.  If they're not set, the parent's
options (if any) will be used.

This is to allow the security_inet_conn_request() hook to modify the
IPv6 options in just the same way that it already may do for IPv4.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agonetlabel: Prevent setsockopt() from changing the hop-by-hop option.
Huw Davies [Mon, 27 Jun 2016 19:05:27 +0000 (15:05 -0400)] 
netlabel: Prevent setsockopt() from changing the hop-by-hop option.

If a socket has a netlabel in place then don't let setsockopt() alter
the socket's IPv6 hop-by-hop option.  This is in the same spirit as
the existing check for IPv4.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agocalipso: Set the calipso socket label to match the secattr.
Huw Davies [Mon, 27 Jun 2016 19:02:51 +0000 (15:02 -0400)] 
calipso: Set the calipso socket label to match the secattr.

CALIPSO is a hop-by-hop IPv6 option.  A lot of this patch is based on
the equivalent CISPO code.  The main difference is due to manipulating
the options in the hop-by-hop header.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agonetlabel: Move bitmap manipulation functions to the NetLabel core.
Huw Davies [Mon, 27 Jun 2016 19:02:51 +0000 (15:02 -0400)] 
netlabel: Move bitmap manipulation functions to the NetLabel core.

This is to allow the CALIPSO labelling engine to use these.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agoipv6: Add ipv6_renew_options_kern() that accepts a kernel mem pointer.
Huw Davies [Mon, 27 Jun 2016 19:02:50 +0000 (15:02 -0400)] 
ipv6: Add ipv6_renew_options_kern() that accepts a kernel mem pointer.

The functionality is equivalent to ipv6_renew_options() except
that the newopt pointer is in kernel, not user, memory

The kernel memory implementation will be used by the CALIPSO network
labelling engine, which needs to be able to set IPv6 hop-by-hop
options.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agonetlabel: Add support for removing a CALIPSO DOI.
Huw Davies [Mon, 27 Jun 2016 19:02:49 +0000 (15:02 -0400)] 
netlabel: Add support for removing a CALIPSO DOI.

Remove a specified DOI through the NLBL_CALIPSO_C_REMOVE command.
It requires the attribute:
 NLBL_CALIPSO_A_DOI.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agonetlabel: Add support for creating a CALIPSO protocol domain mapping.
Huw Davies [Mon, 27 Jun 2016 19:02:49 +0000 (15:02 -0400)] 
netlabel: Add support for creating a CALIPSO protocol domain mapping.

This extends the NLBL_MGMT_C_ADD and NLBL_MGMT_C_ADDDEF commands
to accept CALIPSO protocol DOIs.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agonetlabel: Add support for enumerating the CALIPSO DOI list.
Huw Davies [Mon, 27 Jun 2016 19:02:48 +0000 (15:02 -0400)] 
netlabel: Add support for enumerating the CALIPSO DOI list.

Enumerate the DOI list through the NLBL_CALIPSO_C_LISTALL command.
It takes no attributes.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agonetlabel: Add support for querying a CALIPSO DOI.
Huw Davies [Mon, 27 Jun 2016 19:02:47 +0000 (15:02 -0400)] 
netlabel: Add support for querying a CALIPSO DOI.

Query a specified DOI through the NLBL_CALIPSO_C_LIST command.
It requires the attribute:
 NLBL_CALIPSO_A_DOI.

The reply will contain:
 NLBL_CALIPSO_A_MTYPE

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agonetlabel: Initial support for the CALIPSO netlink protocol.
Huw Davies [Mon, 27 Jun 2016 19:02:46 +0000 (15:02 -0400)] 
netlabel: Initial support for the CALIPSO netlink protocol.

CALIPSO is a packet labelling protocol for IPv6 which is very similar
to CIPSO.  It is specified in RFC 5570.  Much of the code is based on
the current CIPSO code.

This adds support for adding passthrough-type CALIPSO DOIs through the
NLBL_CALIPSO_C_ADD command.  It requires attributes:

 NLBL_CALIPSO_A_TYPE which must be CALIPSO_MAP_PASS.
 NLBL_CALIPSO_A_DOI.

In passthrough mode the CALIPSO engine will map MLS secattr levels
and categories directly to the packet label.

At this stage, the major difference between this and the CIPSO
code is that IPv6 may be compiled as a module.  To allow for
this the CALIPSO functions are registered at module init time.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agonetlabel: Add an address family to domain hash entries.
Huw Davies [Mon, 27 Jun 2016 19:02:46 +0000 (15:02 -0400)] 
netlabel: Add an address family to domain hash entries.

The reason is to allow different labelling protocols for
different address families with the same domain.

This requires the addition of an address family attribute
in the netlink communication protocol.  It is used in several
messages:

NLBL_MGMT_C_ADD and NLBL_MGMT_C_ADDDEF take it as an optional
attribute for the unlabelled protocol.  It may be one of AF_INET,
AF_INET6 or AF_UNSPEC (to specify both address families).  If it
is missing, it defaults to AF_UNSPEC.

NLBL_MGMT_C_LISTALL and NLBL_MGMT_C_LISTDEF return it as part of
the enumeration of each item.  Addtionally, it may be sent to
LISTDEF to specify which address family to return.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agonetlabel: Mark rcu pointers with __rcu.
Huw Davies [Mon, 27 Jun 2016 19:02:45 +0000 (15:02 -0400)] 
netlabel: Mark rcu pointers with __rcu.

This fixes sparse errors of the form:
  incompatible types in comparison expression (different address spaces)

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agotpm_crb: fix address space of the return pointer in crb_map_res()
Jarkko Sakkinen [Fri, 17 Jun 2016 14:39:29 +0000 (16:39 +0200)] 
tpm_crb: fix address space of the return pointer in crb_map_res()

When running make C=2 M=drivers/char/tpm/

  CHECK   drivers/char/tpm//tpm_crb.c
drivers/char/tpm//tpm_crb.c:248:31: warning: incorrect type in return expression (different address spaces)
drivers/char/tpm//tpm_crb.c:248:31:    expected void [noderef] <asn:2>*
drivers/char/tpm//tpm_crb.c:248:31:    got void *

CC: stable@vger.kernel.org
Fixes: 1bd047be37d9 ("tpm_crb: Use devm_ioremap_resource")
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
8 years agotpm_vtpm_proxy: fix address space of a user pointer in vtpmx_fops_ioctl()
Jarkko Sakkinen [Fri, 17 Jun 2016 14:39:28 +0000 (16:39 +0200)] 
tpm_vtpm_proxy: fix address space of a user pointer in vtpmx_fops_ioctl()

When running make C=2 M=drivers/char/tpm/

  CC [M]  drivers/char/tpm//tpm_crb.o
  CHECK   drivers/char/tpm//tpm_vtpm_proxy.c
drivers/char/tpm//tpm_vtpm_proxy.c:552:32: warning: incorrect type in assignment (different address spaces)
drivers/char/tpm//tpm_vtpm_proxy.c:552:32:    expected struct vtpm_proxy_new_dev *vtpm_new_dev_p
drivers/char/tpm//tpm_vtpm_proxy.c:552:32:    got void [noderef] <asn:1>*argp
drivers/char/tpm//tpm_vtpm_proxy.c:553:51: warning: incorrect type in argument 2 (different address spaces)
drivers/char/tpm//tpm_vtpm_proxy.c:553:51:    expected void const [noderef] <asn:1>*from
drivers/char/tpm//tpm_vtpm_proxy.c:553:51:    got struct vtpm_proxy_new_dev *vtpm_new_dev_p
drivers/char/tpm//tpm_vtpm_proxy.c:559:34: warning: incorrect type in argument 1 (different address spaces)
drivers/char/tpm//tpm_vtpm_proxy.c:559:34:    expected void [noderef] <asn:1>*to
drivers/char/tpm//tpm_vtpm_proxy.c:559:34:    got struct vtpm_proxy_new_dev *vtpm_new_dev_p

The __user annotation was missing from the corresponding variable.

Fixes: 794c38e01358 ("tpm: Proxy driver for supporting multiple emulated TPMs")
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
8 years agotpm/tpm_tis_spi: Add support for spi phy
Christophe Ricard [Wed, 18 May 2016 22:35:53 +0000 (00:35 +0200)] 
tpm/tpm_tis_spi: Add support for spi phy

Spi protocol standardized by the TCG is now supported by most of TPM
vendors.

It supports SPI Bit Protocol as describe in the TCG PTP
specification (chapter 6.4.6 SPI Bit Protocol).

Irq mode is not supported.

This commit is based on the initial work by Peter Huewe.

Signed-off-by: Peter Huewe <peter.huewe@infineon.com>
Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/tpm_tis: Split tpm_tis driver into a core and TCG TIS compliant phy
Christophe Ricard [Wed, 18 May 2016 22:35:52 +0000 (00:35 +0200)] 
tpm/tpm_tis: Split tpm_tis driver into a core and TCG TIS compliant phy

To avoid code duplication between the old tpm_tis and the new and future
native tcg tis driver(ie: spi, i2c...), the tpm_tis driver was reworked,
so that all common logic is extracted and can be reused from all drivers.

The core methods can also be used from other TIS like drivers.

itpm workaround is now managed with a specific tis flag
TPM_TIS_ITPM_POSSIBLE.

This commit is based on the initial work by Peter Huewe.

Signed-off-by: Peter Huewe <peter.huewe@infineon.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agodevicetree: Add Trusted Computing Group to vendor-prefix.txt
Christophe Ricard [Wed, 18 May 2016 22:35:51 +0000 (00:35 +0200)] 
devicetree: Add Trusted Computing Group to vendor-prefix.txt

Add missing vendor to vendor-prefix.txt.

Trusted Computing Group design common specifications for
TPM (Trusted Platform Module) vendors.
TCG designates a TPM answering to a public specification.

This commit is based on the initial work by Peter Huewe.

Cc: devicetree@vger.kernel.org
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agodevicetree: Add infineon to vendor-prefix.txt
Christophe Ricard [Wed, 18 May 2016 22:35:50 +0000 (00:35 +0200)] 
devicetree: Add infineon to vendor-prefix.txt

Add missing vendor to vendor-prefix.txt

This commit is based on the initial work by Peter Huewe.

Cc: devicetree@vger.kernel.org
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm_tis: Introduce intermediate layer for TPM access
Christophe Ricard [Wed, 18 May 2016 22:35:49 +0000 (00:35 +0200)] 
tpm_tis: Introduce intermediate layer for TPM access

This splits tpm_tis in a high-level protocol part and a low-level interface
for the actual TPM communication. The low-level interface can then be
implemented by additional drivers to provide access to TPMs using other
mechanisms, for example native I2C or SPI transfers, while still reusing
the same TIS protocol implementation.

Though the ioread/iowrite calls cannot fail, other implementations of this
interface might want to return error codes if their communication fails.

This follows the usual pattern of negative values representing errors and
zero representing success. Positive values are not used (yet).

Errors are passed back to the caller if possible. If the interface of a
function does not allow that, it tries to do the most sensible thing it
can, but this might also mean ignoring the error in this instance.

This commit is based on the initial work by Peter Huewe.

Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: tpm_tis: Share common data between phys
Christophe Ricard [Wed, 18 May 2016 22:35:48 +0000 (00:35 +0200)] 
tpm: tpm_tis: Share common data between phys

Split priv_data structure in common and phy specific structures. This will
allow in future patches to reuse the same tis logic on top of new phy such
as spi and i2c. Ultimately, other drivers may reuse this tis logic.
(e.g: st33zp24...)

iobase field is specific to TPM addressed on 0xFED4xxxx on LPC/SPI bus.

This commit is based on the initial work by Peter Huewe.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Add include guards in tpm.h
Christophe Ricard [Wed, 4 May 2016 19:06:22 +0000 (21:06 +0200)] 
tpm: Add include guards in tpm.h

Add missing include guards in tpm.h

Signed-off-by: Peter Huewe <peter.huewe@infineon.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Fix suspend regression
Stefan Berger [Wed, 11 May 2016 15:28:27 +0000 (11:28 -0400)] 
tpm: Fix suspend regression

Fix the suspend regression due to the wrong way of retrieving the
chip structure. The suspend functions are attached to the hardware
device, not the chip and thus must rely on drvdata.

Fixes: e89f8b1ade9cc1a ("tpm: Remove all uses of drvdata from the TPM Core")
Reported-by: Jeremiah Mahler <jmmahler@gmail.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tested-by: Jeremiah Mahler <jmmahler@gmail.com>
Acked-by: Jarkko Sakkinen <jarkko.sakkine@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkine@linux.intel.com>
8 years agotpm: fix for typo in tpm/tpm_ibmvtpm.c
Stephen Rothwell [Thu, 28 Apr 2016 05:27:17 +0000 (15:27 +1000)] 
tpm: fix for typo in tpm/tpm_ibmvtpm.c

Fixes: 28157164b056 ("tpm: Remove useless priv field in struct tpm_vendor_specific")
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: select ANON_INODES for proxy driver
Arnd Bergmann [Thu, 28 Apr 2016 10:46:13 +0000 (12:46 +0200)] 
tpm: select ANON_INODES for proxy driver

The newly added vtpmx driver fails to build if CONFIG_ANON_INODES
is disabled:

drivers/char/built-in.o: In function `vtpmx_fops_ioctl':
(.text+0x97f8): undefined reference to `anon_inode_getfile'

This adds a Kconfig 'select' statement to ensure it's always there
when we need it.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 794c38e01358 ("tpm: Proxy driver for supporting multiple emulated TPMs")
Acked-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Acked-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Fix IRQ unwind ordering in TIS
Jason Gunthorpe [Wed, 27 Apr 2016 16:58:46 +0000 (10:58 -0600)] 
tpm: Fix IRQ unwind ordering in TIS

The devm for the IRQ was placed on the chip, not the pdev. This can
cause the irq to be still callable after the pdev has been cleaned up
(eg priv kfree'd).

Found by CONFIG_DEBUG_SHIRQ=y

Reported-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Fixes: 233a065e0cd0 ("tpm: Get rid of chip->pdev")
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Add documentation for the tpm_vtpm_proxy device driver
Stefan Berger [Mon, 18 Apr 2016 17:26:16 +0000 (13:26 -0400)] 
tpm: Add documentation for the tpm_vtpm_proxy device driver

Add documentation for the tpm_vtpm device driver that implements
support for providing TPM functionality to Linux containers.

Parts of this documentation were recycled from the Xen vTPM
device driver documentation.

Update the documentation for the ioctl numbers.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
CC: linux-kernel@vger.kernel.org
CC: linux-doc@vger.kernel.org
CC: linux-api@vger.kernel.org
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Proxy driver for supporting multiple emulated TPMs
Stefan Berger [Mon, 18 Apr 2016 17:26:15 +0000 (13:26 -0400)] 
tpm: Proxy driver for supporting multiple emulated TPMs

This patch implements a proxy driver for supporting multiple emulated TPMs
in a system.

The driver implements a device /dev/vtpmx that is used to created
a client device pair /dev/tpmX (e.g., /dev/tpm10) and a server side that
is accessed using a file descriptor returned by an ioctl.
The device /dev/tpmX is the usual TPM device created by the core TPM
driver. Applications or kernel subsystems can send TPM commands to it
and the corresponding server-side file descriptor receives these
commands and delivers them to an emulated TPM.

The driver retrievs the TPM 1.2 durations and timeouts. Since this requires
the startup of the TPM, we send a startup for TPM 1.2 as well as TPM 2.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
CC: linux-kernel@vger.kernel.org
CC: linux-doc@vger.kernel.org
CC: linux-api@vger.kernel.org
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Introduce TPM_CHIP_FLAG_VIRTUAL
Stefan Berger [Mon, 18 Apr 2016 17:26:14 +0000 (13:26 -0400)] 
tpm: Introduce TPM_CHIP_FLAG_VIRTUAL

Introduce TPM_CHIP_FLAG_VIRTUAL to be used when the chip device has no
parent device.

Prevent sysfs entries requiring a parent device from being created.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Remove all uses of drvdata from the TPM Core
Jason Gunthorpe [Mon, 18 Apr 2016 17:26:13 +0000 (13:26 -0400)] 
tpm: Remove all uses of drvdata from the TPM Core

The final thing preventing this was the way the sysfs files were
attached to the pdev. Follow the approach developed for ppi and move
the sysfs files to the chip->dev with symlinks from the pdev
for compatibility. Everything in the core now sanely uses container_of
to get the chip.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Remove useless priv field in struct tpm_vendor_specific
Christophe Ricard [Thu, 31 Mar 2016 20:57:00 +0000 (22:57 +0200)] 
tpm: Remove useless priv field in struct tpm_vendor_specific

Remove useless priv field in struct tpm_vendor_specific and take benefit
of chip->dev.driver_data.  As priv is the latest field available in
struct tpm_vendor_specific, remove any reference to that structure.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Move tpm_vendor_specific data related with PTP specification to tpm_chip
Christophe Ricard [Thu, 31 Mar 2016 20:56:59 +0000 (22:56 +0200)] 
tpm: Move tpm_vendor_specific data related with PTP specification to tpm_chip

Move tpm_vendor_specific data related to TCG PTP specification to tpm_chip.

Move all fields directly linked with well known TCG concepts and used in
TPM drivers (tpm_i2c_atmel, tpm_i2c_infineon, tpm_i2c_nuvoton, tpm_tis
and xen-tpmfront) as well as in TPM core files (tpm-sysfs, tpm-interface
and tpm2-cmd) in tpm_chip.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: drop 'locality' from struct tpm_vendor_specific
Christophe Ricard [Thu, 31 Mar 2016 20:56:58 +0000 (22:56 +0200)] 
tpm: drop 'locality' from struct tpm_vendor_specific

Dropped the field 'locality' from struct tpm_vendor_specific migrated it to
the private structures of st33zp24, tpm_i2c_infineon and tpm_tis.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: drop 'read_queue' from struct tpm_vendor_specific
Christophe Ricard [Thu, 31 Mar 2016 20:56:57 +0000 (22:56 +0200)] 
tpm: drop 'read_queue' from struct tpm_vendor_specific

Dropped the field 'read_queue' from struct tpm_vendor_specific and make it
available to the various private structures in the drivers.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: drop 'irq' from struct tpm_vendor_specific
Christophe Ricard [Thu, 31 Mar 2016 20:56:56 +0000 (22:56 +0200)] 
tpm: drop 'irq' from struct tpm_vendor_specific

Dropped the field 'irq' from struct tpm_vendor_specific and make it
available to the various private structures in the drivers using irqs.

A dedicated flag TPM_CHIP_FLAG_IRQ is added for the upper layers.

In st33zp24, struct st33zp24_dev declaration is moved to st33zp24.h in
order to make accessible irq from other phy's(i2c, spi).

In tpm_i2c_nuvoton, chip->vendor.priv is not directly allocated. We can
access irq field from priv_data in a cleaner way.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: drop 'iobase' from struct tpm_vendor_specific
Christophe Ricard [Thu, 31 Mar 2016 20:56:55 +0000 (22:56 +0200)] 
tpm: drop 'iobase' from struct tpm_vendor_specific

Dropped the field 'iobase' from struct tpm_vendor_specific and migrated
it to the private structures of tpm_atmel and tpm_tis.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: drop list from struct tpm_vendor_specific
Christophe Ricard [Wed, 23 Mar 2016 20:17:17 +0000 (21:17 +0100)] 
tpm: drop list from struct tpm_vendor_specific

Dropped list from struct tpm_vendor_specific as it is not used in any
place.

It is initialized in tpm_i2c_infineon but not used at all in the code.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: drop the field 'time_expired' from struct tpm_chip
Jarkko Sakkinen [Wed, 23 Mar 2016 06:23:39 +0000 (08:23 +0200)] 
tpm: drop the field 'time_expired' from struct tpm_chip

Removed the field because it is not used for anything.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
8 years agotpm: drop 'base' from struct tpm_vendor_specific
Jarkko Sakkinen [Wed, 23 Mar 2016 06:16:09 +0000 (08:16 +0200)] 
tpm: drop 'base' from struct tpm_vendor_specific

Dropped the field 'base' from struct tpm_vendor_specific and migrated
it to the private structures of tpm_atmel and tpm_nsc.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
8 years agotpm: drop manufacturer_id from struct tpm_vendor_specific
Jarkko Sakkinen [Wed, 23 Mar 2016 05:31:56 +0000 (07:31 +0200)] 
tpm: drop manufacturer_id from struct tpm_vendor_specific

Dropped manufacturer_id from struct tpm_vendor_specific and redeclared
it in the private struct priv_data that tpm_tis uses because the field
is only used tpm_tis.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
8 years agotpm: drop tpm_atmel specific fields from tpm_vendor_specific
Jarkko Sakkinen [Wed, 23 Mar 2016 05:10:22 +0000 (07:10 +0200)] 
tpm: drop tpm_atmel specific fields from tpm_vendor_specific

Introduced a private struct tpm_atmel_priv that contains the variables
have_region and region_size that were previously located in struct
tpm_vendor_specific. These fields were only used by tpm_atmel.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
8 years agotpm: drop int_queue from tpm_vendor_specific
Jarkko Sakkinen [Tue, 22 Mar 2016 04:20:09 +0000 (06:20 +0200)] 
tpm: drop int_queue from tpm_vendor_specific

Drop field int_queue from tpm_vendor_specific as it is used only by
tpm_tis. Probably all of the fields should be eventually dropped and
moved to the private structures of different drivers but it is better to
do this one step at a time in order not to break anything.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
8 years agotpm: check for TPM_CHIP_FLAG_TPM2 before calling tpm2_shutdown()
Jarkko Sakkinen [Mon, 25 Apr 2016 09:20:07 +0000 (12:20 +0300)] 
tpm: check for TPM_CHIP_FLAG_TPM2 before calling tpm2_shutdown()

Fixes: 20e0152393b41 ("tpm: fix crash in tpm_tis deinitialization")
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reported-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-By: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
8 years agotpm_crb: fix mapping of the buffers
Jarkko Sakkinen [Tue, 19 Apr 2016 09:54:18 +0000 (12:54 +0300)] 
tpm_crb: fix mapping of the buffers

On my Lenovo x250 the following situation occurs:

[18697.813871] tpm_crb MSFT0101:00: can't request region for resource
[mem 0xacdff080-0xacdfffff]

The mapping of the control area overlaps the mapping of the command
buffer. The control area is mapped over page, which is not right. It
should mapped over sizeof(struct crb_control_area).

Fixing this issue unmasks another issue. Command and response buffers
can overlap and they do interleave on this machine. According to the PTP
specification the overlapping means that they are mapped to the same
buffer.

The commit has been also on a Haswell NUC where things worked before
applying this fix so that the both code paths for response buffer
initialization are tested.

Cc: stable@vger.kernel.org
Fixes: 1bd047be37d9 ("tpm_crb: Use devm_ioremap_resource")
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
8 years agotpm/st33zp24: Remove unneeded tpm_reg in get_burstcount
Christophe Ricard [Wed, 23 Mar 2016 07:55:34 +0000 (08:55 +0100)] 
tpm/st33zp24: Remove unneeded tpm_reg in get_burstcount

We can get rid of tpm_reg variable in get_burstcount.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Drop two useless checks in ACPI probe path
Christophe Ricard [Wed, 23 Mar 2016 07:55:33 +0000 (08:55 +0100)] 
tpm/st33zp24/spi: Drop two useless checks in ACPI probe path

When st33zp24_spi_acpi_request_resources() gets called we
already know that the entries in ->acpi_match_table have matched ACPI ID
of the device.
In addition spi_device pointer cannot be NULL in any case (otherwise I2C
core would not call ->probe() for the driver in the first place).

Drop the two useless checks from the driver.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/i2c: Drop two useless checks in ACPI probe path
Christophe Ricard [Wed, 23 Mar 2016 07:55:32 +0000 (08:55 +0100)] 
tpm/st33zp24/i2c: Drop two useless checks in ACPI probe path

When st33zp24_i2c_acpi_request_resources() gets called we
already know that the entries in ->acpi_match_table have matched ACPI ID
of the device.
In addition I2C client pointer cannot be NULL in any case (otherwise I2C
core would not call ->probe() for the driver in the first place).

Drop the two useless checks from the driver.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm_crb: drop struct resource res from struct crb_priv
Jarkko Sakkinen [Tue, 15 Mar 2016 19:41:40 +0000 (21:41 +0200)] 
tpm_crb: drop struct resource res from struct crb_priv

The iomem resource is needed only temporarily so it is better to pass
it on instead of storing it permanently. Named the variable as io_res
so that the code better documents itself.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
8 years agotpm: fix crash in tpm_tis deinitialization
Jarkko Sakkinen [Mon, 11 Apr 2016 11:20:57 +0000 (14:20 +0300)] 
tpm: fix crash in tpm_tis deinitialization

rmmod crashes the driver because tpm_chip_unregister() already sets ops
to NULL. This commit fixes the issue by moving tpm2_shutdown() to
tpm_chip_unregister(). This commit is also cleanup because it removes
duplicate code from tpm_crb and tpm_tis to the core.

Fixes: 4d3eac5e156a ("tpm: Provide strong locking for device removal")
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
8 years agotpm: cleanup tpm_tis_remove()
Jarkko Sakkinen [Thu, 31 Mar 2016 10:05:36 +0000 (13:05 +0300)] 
tpm: cleanup tpm_tis_remove()

Created a local variable pointing to the INT_ENABLE_x register. The
expression clearing INT_ENABLE_x.globalIntEnable is unreadable and
hard to modify without surpassing the 80 char boundary.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Christophe Ricard <christophe-h.ricard@st.com>
8 years agotpm: fix tpm_bios_log_setup stub prototype
Arnd Bergmann [Wed, 16 Mar 2016 08:19:48 +0000 (09:19 +0100)] 
tpm: fix tpm_bios_log_setup stub prototype

A cleanup patch changed the prototype of the regular tpm_bios_log_setup
function, but not that of the stub that is used when the TPM is disabled,
causing a harmless build warning:

drivers/char/tpm/tpm-chip.c: In function 'tpm1_chip_register':
drivers/char/tpm/tpm-chip.c:287:38: error: passing argument 1 of 'tpm_bios_log_setup' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
  chip->bios_dir = tpm_bios_log_setup(dev_name(&chip->dev));
In file included from ../drivers/char/tpm/tpm-chip.c:30:0:
../drivers/char/tpm/tpm_eventlog.h:83:31: note: expected 'char *' but argument is of type 'const char *'
 static inline struct dentry **tpm_bios_log_setup(char *name)

This changes the stub function to match the normal prototype,
avoiding that warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: aca8db8088c3 ("tpm: Get rid of devname")
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Replace device number bitmap with IDR
Stefan Berger [Mon, 29 Feb 2016 13:53:02 +0000 (08:53 -0500)] 
tpm: Replace device number bitmap with IDR

Replace the device number bitmap with IDR. Extend the number of devices we
can create to 64k.
Since an IDR allows us to associate a pointer with an ID, we use this now
to rewrite tpm_chip_find_get() to simply look up the chip pointer by the
given device ID.

Protect the IDR calls with a mutex.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Split out the devm stuff from tpmm_chip_alloc
Jason Gunthorpe [Thu, 11 Feb 2016 19:45:48 +0000 (12:45 -0700)] 
tpm: Split out the devm stuff from tpmm_chip_alloc

tpm_chip_alloc becomes a typical subsystem allocate call.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Get rid of module locking
Stefan Berger [Mon, 29 Feb 2016 13:53:01 +0000 (08:53 -0500)] 
tpm: Get rid of module locking

Now that the tpm core has strong locking around 'ops' it is possible
to remove a TPM driver, module and all, even while user space still
has things like /dev/tpmX open. For consistency and simplicity, drop
the module locking entirely.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Provide strong locking for device removal
Jason Gunthorpe [Sat, 13 Feb 2016 03:29:53 +0000 (20:29 -0700)] 
tpm: Provide strong locking for device removal

Add a read/write semaphore around the ops function pointers so
ops can be set to null when the driver un-registers.

Previously the tpm core expected module locking to be enough to
ensure that tpm_unregister could not be called during certain times,
however that hasn't been sufficient for a long time.

Introduce a read/write semaphore around 'ops' so the core can set
it to null when unregistering. This provides a strong fence around
the driver callbacks, guaranteeing to the driver that no callbacks
are running or will run again.

For now the ops_lock is placed very high in the call stack, it could
be pushed down and made more granular in future if necessary.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Get rid of devname
Jason Gunthorpe [Mon, 29 Feb 2016 17:29:48 +0000 (12:29 -0500)] 
tpm: Get rid of devname

Now that we have a proper struct device just use dev_name() to
access this value instead of keeping two copies.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: Get rid of chip->pdev
Jason Gunthorpe [Mon, 29 Feb 2016 17:29:47 +0000 (12:29 -0500)] 
tpm: Get rid of chip->pdev

This is a hold over from before the struct device conversion.

- All prints should be using &chip->dev, which is the Linux
  standard. This changes prints to use tpm0 as the device name,
  not the PnP/etc ID.
- The few places involving sysfs/modules that really do need the
  parent just use chip->dev.parent instead
- We no longer need to get_device(pdev) in any places since it is no
  longer used by any of the code. The kref on the parent is held
  by the device core during device_add and dropped in device_del

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Tested-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Change xxx_request_resources header
Christophe RICARD [Tue, 23 Feb 2016 21:25:51 +0000 (22:25 +0100)] 
tpm/st33zp24/spi: Change xxx_request_resources header

Simplify st33zp24_spi_acpi_request_resources, st33zp24_spi_of_request_resources
and st33zp24_spi_request_resources to have the same prototype and using
spi_get_drvdata.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/i2c: Change xxx_request_resources header
Christophe RICARD [Tue, 23 Feb 2016 21:25:50 +0000 (22:25 +0100)] 
tpm/st33zp24/i2c: Change xxx_request_resources header

Simplify st33zp24_i2c_acpi_request_resources, st33zp24_i2c_of_request_resources
and st33zp24_i2c_request_resources to have the same prototype and using
i2c_get_clientdata.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: st33zp24: Add support for acpi probing for spi device.
Christophe RICARD [Tue, 23 Feb 2016 21:25:49 +0000 (22:25 +0100)] 
tpm: st33zp24: Add support for acpi probing for spi device.

Add support for acpi probing. SMO3324 is used for st33zp24.
It has been tested with the following acpi node on Minnowboard:

Device (TPM1)
{
Name (_ADR, Zero)  // _ADR: Address
Name (_HID, "SMO3324")  // _HID: Hardware ID
Name (_CID, "SMO3324")  // _CID: Compatible ID
Name (_DDN, "SMO TPM")  // _DDN: DOS Device Name
Name (_UID, One)  // _UID: Unique ID
Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
{
Name (SBUF, ResourceTemplate ()
{
SpiSerialBus (0, PolarityLow, FourWireMode, 8,
      ControllerInitiated, 4000000, ClockPolarityLow,
      ClockPhaseFirst, "\\_SB.SPI1",
      0x00, ResourceConsumer, ,)
GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
 "\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{       // Pin list
0x0001
}
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{       // Pin list
0x0002,
}
})
Return (SBUF) /* \_SB_.SPI1.TPM1._CRS.SBUF */
}
Method (_STA, 0, NotSerialized)  // _STA: Status
{
Return (0x0F)
}
}

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24: Add support for acpi probing for i2c device.
Christophe RICARD [Sat, 13 Feb 2016 15:15:32 +0000 (16:15 +0100)] 
tpm/st33zp24: Add support for acpi probing for i2c device.

Add support for acpi probing. SMO3324 is used for st33zp24.
It has been tested with the following acpi node on Minnowboard:

Device (TPM1)
{
Name (_ADR, Zero)  // _ADR: Address
Name (_HID, "SMO3324")  // _HID: Hardware ID
Name (_CID, "SMO3324")  // _CID: Compatible ID
Name (_DDN, "SMO TPM")  // _DDN: DOS Device Name
Name (_UID, One)  // _UID: Unique ID
Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
{
Name (SBUF, ResourceTemplate ()
{
I2cSerialBus (0x0013, ControllerInitiated, 400000,
      AddressingMode7Bit, "\\_SB.I2C7",
      0x00, ResourceConsumer, ,)
GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
 "\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{    // Pin list
0x0001
}
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{ // Pin list
0x0002,
}
})
Return (SBUF) /* \_SB_.I2C7.TPM1._CRS.SBUF */
}

Method (_STA, 0, NotSerialized)  // _STA: Status
{
Return (0x0F)
}
}

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24: Extend Copyright headers
Christophe RICARD [Sat, 13 Feb 2016 15:15:31 +0000 (16:15 +0100)] 
tpm/st33zp24: Extend Copyright headers

Extend copyright header to 2016

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency
Christophe RICARD [Sat, 13 Feb 2016 15:15:30 +0000 (16:15 +0100)] 
tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency

Add check in st33zp24_spi_evaluate_latency helping to diagnose if the chip
is present or in a bad state.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24: Remove unneeded CONFIG_OF switches
Christophe RICARD [Sat, 13 Feb 2016 15:15:28 +0000 (16:15 +0100)] 
tpm/st33zp24: Remove unneeded CONFIG_OF switches

DT headers already define NOOP routines when CONFIG_OF is not defined.

[jarkko.sakkinen@linux.intel.com: I tested that the driver compiles
 without warnings and errors with and without CONFIG_OF flag.]

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy structure
Christophe RICARD [Sat, 13 Feb 2016 15:15:27 +0000 (16:15 +0100)] 
tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy structure

Remove spi_xfer from st33zp24_spi_phy structure and declare local spi_xfer
when needed instead.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Remove useless use of memcpy.
Christophe RICARD [Sat, 13 Feb 2016 15:15:26 +0000 (16:15 +0100)] 
tpm/st33zp24/spi: Remove useless use of memcpy.

An affectation is enough when copying 1 byte. Remove memcpy usage where
possible.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix
Christophe RICARD [Sat, 13 Feb 2016 15:15:25 +0000 (16:15 +0100)] 
tpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix

Make sure every function name use st33zp24_spi_ prefix.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage
Christophe RICARD [Sat, 13 Feb 2016 15:15:24 +0000 (16:15 +0100)] 
tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage

nbr_dummy_bytes variable could be easily replaced by phy->latency in
st33zp24_spi_send and st33zp24_spi_recv.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Change xxx_request_resources header
Christophe RICARD [Tue, 23 Feb 2016 21:25:51 +0000 (22:25 +0100)] 
tpm/st33zp24/spi: Change xxx_request_resources header

Simplify st33zp24_spi_acpi_request_resources, st33zp24_spi_of_request_resources
and st33zp24_spi_request_resources to have the same prototype and using
spi_get_drvdata.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/i2c: Change xxx_request_resources header
Christophe RICARD [Tue, 23 Feb 2016 21:25:50 +0000 (22:25 +0100)] 
tpm/st33zp24/i2c: Change xxx_request_resources header

Simplify st33zp24_i2c_acpi_request_resources, st33zp24_i2c_of_request_resources
and st33zp24_i2c_request_resources to have the same prototype and using
i2c_get_clientdata.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm: st33zp24: Add support for acpi probing for spi device.
Christophe RICARD [Tue, 23 Feb 2016 21:25:49 +0000 (22:25 +0100)] 
tpm: st33zp24: Add support for acpi probing for spi device.

Add support for acpi probing. SMO3324 is used for st33zp24.
It has been tested with the following acpi node on Minnowboard:

Device (TPM1)
{
Name (_ADR, Zero)  // _ADR: Address
Name (_HID, "SMO3324")  // _HID: Hardware ID
Name (_CID, "SMO3324")  // _CID: Compatible ID
Name (_DDN, "SMO TPM")  // _DDN: DOS Device Name
Name (_UID, One)  // _UID: Unique ID
Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
{
Name (SBUF, ResourceTemplate ()
{
SpiSerialBus (0, PolarityLow, FourWireMode, 8,
      ControllerInitiated, 4000000, ClockPolarityLow,
      ClockPhaseFirst, "\\_SB.SPI1",
      0x00, ResourceConsumer, ,)
GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
 "\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{       // Pin list
0x0001
}
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{       // Pin list
0x0002,
}
})
Return (SBUF) /* \_SB_.SPI1.TPM1._CRS.SBUF */
}
Method (_STA, 0, NotSerialized)  // _STA: Status
{
Return (0x0F)
}
}

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24: Add support for acpi probing for i2c device.
Christophe RICARD [Sat, 13 Feb 2016 15:15:32 +0000 (16:15 +0100)] 
tpm/st33zp24: Add support for acpi probing for i2c device.

Add support for acpi probing. SMO3324 is used for st33zp24.
It has been tested with the following acpi node on Minnowboard:

Device (TPM1)
{
Name (_ADR, Zero)  // _ADR: Address
Name (_HID, "SMO3324")  // _HID: Hardware ID
Name (_CID, "SMO3324")  // _CID: Compatible ID
Name (_DDN, "SMO TPM")  // _DDN: DOS Device Name
Name (_UID, One)  // _UID: Unique ID
Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
{
Name (SBUF, ResourceTemplate ()
{
I2cSerialBus (0x0013, ControllerInitiated, 400000,
      AddressingMode7Bit, "\\_SB.I2C7",
      0x00, ResourceConsumer, ,)
GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
 "\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{    // Pin list
0x0001
}
GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
"\\_SB.GPO2", 0x00, ResourceConsumer, ,)
{ // Pin list
0x0002,
}
})
Return (SBUF) /* \_SB_.I2C7.TPM1._CRS.SBUF */
}

Method (_STA, 0, NotSerialized)  // _STA: Status
{
Return (0x0F)
}
}

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24: Extend Copyright headers
Christophe RICARD [Sat, 13 Feb 2016 15:15:31 +0000 (16:15 +0100)] 
tpm/st33zp24: Extend Copyright headers

Extend copyright header to 2016

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency
Christophe RICARD [Sat, 13 Feb 2016 15:15:30 +0000 (16:15 +0100)] 
tpm/st33zp24/spi: Improve st33zp24_spi_evaluate_latency

Add check in st33zp24_spi_evaluate_latency helping to diagnose if the chip
is present or in a bad state.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24: Auto-select core module
Christophe RICARD [Sat, 13 Feb 2016 15:15:29 +0000 (16:15 +0100)] 
tpm/st33zp24: Auto-select core module

The core st33zp24 module is useless without either the I2C or the
SPI access module. So hide NFC_ST_NCI and select it automatically
if either TCG_TIS_ST33ZP24_I2C or TCG_TIS_ST33ZP24_SPI is selected.

This avoids presenting TCG_TIS_ST33ZP24 when neither TCG_TIS_ST33ZP24_I2C
nor TCG_TIS_ST33ZP24_SPI can be selected.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24: Remove unneeded CONFIG_OF switches
Christophe RICARD [Sat, 13 Feb 2016 15:15:28 +0000 (16:15 +0100)] 
tpm/st33zp24: Remove unneeded CONFIG_OF switches

DT headers already define NOOP routines when CONFIG_OF is not defined.

[jarkko.sakkinen@linux.intel.com: I tested that the driver compiles
 without warnings and errors with and without CONFIG_OF flag.]

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy structure
Christophe RICARD [Sat, 13 Feb 2016 15:15:27 +0000 (16:15 +0100)] 
tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy structure

Remove spi_xfer from st33zp24_spi_phy structure and declare local spi_xfer
when needed instead.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Remove useless use of memcpy.
Christophe RICARD [Sat, 13 Feb 2016 15:15:26 +0000 (16:15 +0100)] 
tpm/st33zp24/spi: Remove useless use of memcpy.

An affectation is enough when copying 1 byte. Remove memcpy usage where
possible.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix
Christophe RICARD [Sat, 13 Feb 2016 15:15:25 +0000 (16:15 +0100)] 
tpm/st33zp24/spi: Use functions name with st33zp24_spi_ prefix

Make sure every function name use st33zp24_spi_ prefix.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agotpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage
Christophe RICARD [Sat, 13 Feb 2016 15:15:24 +0000 (16:15 +0100)] 
tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage

nbr_dummy_bytes variable could be easily replaced by phy->latency in
st33zp24_spi_send and st33zp24_spi_recv.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
8 years agoselinux: fix type mismatch
Heinrich Schuchardt [Fri, 10 Jun 2016 21:14:26 +0000 (23:14 +0200)] 
selinux: fix type mismatch

avc_cache_threshold is of type unsigned int.  Do not use a signed
new_value in sscanf(page, "%u", &new_value).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
[PM: subject prefix fix, description cleanup]
Signed-off-by: Paul Moore <paul@paul-moore.com>
8 years agoum/ptrace: run seccomp after ptrace
Kees Cook [Fri, 3 Jun 2016 02:59:42 +0000 (19:59 -0700)] 
um/ptrace: run seccomp after ptrace

Close the hole where ptrace can change a syscall out from under seccomp.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: user-mode-linux-devel@lists.sourceforge.net
8 years agotile/ptrace: run seccomp after ptrace
Kees Cook [Fri, 3 Jun 2016 02:56:43 +0000 (19:56 -0700)] 
tile/ptrace: run seccomp after ptrace

Close the hole where ptrace can change a syscall out from under seccomp.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
8 years agopowerpc/ptrace: run seccomp after ptrace
Kees Cook [Fri, 3 Jun 2016 02:55:09 +0000 (19:55 -0700)] 
powerpc/ptrace: run seccomp after ptrace

Close the hole where ptrace can change a syscall out from under seccomp.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
8 years agos390/ptrace: run seccomp after ptrace
Kees Cook [Thu, 2 Jun 2016 20:19:36 +0000 (13:19 -0700)] 
s390/ptrace: run seccomp after ptrace

Close the hole where ptrace can change a syscall out from under seccomp.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: linux-s390@vger.kernel.org
This page took 0.055614 seconds and 5 git commands to generate.