Re: [PATCH 1/5] w83627ehf: Use hwmon_device_register_with_info and sensor groups

2017-03-23 Thread Peter Hüwe
This is of course v2 of the series
Forgot to add it to git-send-email, sorry.
Shall I resend with v2 in subject?

Peter


Re: [PATCH 1/5] w83627ehf: Use hwmon_device_register_with_info and sensor groups

2017-03-23 Thread Peter Hüwe
This is of course v2 of the series
Forgot to add it to git-send-email, sorry.
Shall I resend with v2 in subject?

Peter


Re: Conversion of w83627ehf to hwmon_device_register_with_info ?

2017-03-22 Thread Peter Hüwe
> > It saves about 20k in compiled size, so the savings from reduced
> > boilerplate are huge. (and I think it's more readable)
> > 
> >> I would suggest to drop nct6775/nct6776 support to simplify the
> >> code when you do that. Maybe as separate commit, though.
> > 
> > Hehe - I'm testing on a nct6776 :)
> > I'll look into it once the first conversion has been accepted.
> 
> Wondering - why don't you use the nct6775 driver ?

Probably because it got matched by sensors-detect before the nct6775 driver 
(?) or because I hadn't had it turned on in my kernel config.

Both drivers work, but interestingly, they show different values for 
intrusion1 (and fan alarm).


nct6776.c:

nct6776-isa-0290
Adapter: ISA adapter
Vcore:  +1.16 V  (min =  +0.00 V, max =  +1.74 V)
in1:+1.85 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:   +3.36 V  (min =  +2.98 V, max =  +3.63 V)
+3.3V:  +3.36 V  (min =  +2.98 V, max =  +3.63 V)
in4:+0.26 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:+1.67 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in6:+0.79 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:   +3.44 V  (min =  +2.98 V, max =  +3.63 V)
Vbat:   +3.26 V  (min =  +2.70 V, max =  +3.63 V)
fan1: 0 RPM  (min =0 RPM)
fan2:  2106 RPM  (min =0 RPM)
fan3: 0 RPM  (min =0 RPM)
fan4: 0 RPM  (min =0 RPM)
fan5: 0 RPM  (min =0 RPM)
SYSTIN: +35.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = 
thermistor
CPUTIN: +44.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
AUXTIN: +43.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
PECI Agent 0:   +59.0°C  (high = +80.0°C, hyst = +75.0°C)
 (crit = +105.0°C)
PCH_CHIP_TEMP:   +0.0°C  
PCH_CPU_TEMP:+0.0°C  
PCH_MCH_TEMP:+0.0°C  
intrusion0:ALARM
intrusion1:OK
beep_enable:   disabled



w83627ehf.c:
nct6776-isa-0290
Adapter: ISA adapter
Vcore: +1.14 V  (min =  +0.00 V, max =  +1.74 V)
in1:   +1.85 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:  +3.36 V  (min =  +2.98 V, max =  +3.63 V)
+3.3V: +3.36 V  (min =  +2.98 V, max =  +3.63 V)
in4:   +0.24 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:   +1.68 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:  +3.44 V  (min =  +2.98 V, max =  +3.63 V)
Vbat:  +3.26 V  (min =  +2.70 V, max =  +3.63 V)
fan1:0 RPM  (min =0 RPM)  ALARM
fan2: 2142 RPM  (min =0 RPM)  ALARM
fan3:0 RPM  (min =0 RPM)  ALARM
fan4:0 RPM  (min =0 RPM)  ALARM
fan5:0 RPM  (min =0 RPM)  ALARM
SYSTIN:+35.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = 
thermistor
CPUTIN:+46.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
AUXTIN:+44.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
PECI Agent 0:  +64.0°C  
cpu0_vid: +0.000 V
intrusion0:   ALARM
intrusion1:   ALARM



Once the other patches have been accepted I'll work on that conversion/removal 
of the nct6775 code from the w83627ehf.


Peter





Re: Conversion of w83627ehf to hwmon_device_register_with_info ?

2017-03-22 Thread Peter Hüwe
> > It saves about 20k in compiled size, so the savings from reduced
> > boilerplate are huge. (and I think it's more readable)
> > 
> >> I would suggest to drop nct6775/nct6776 support to simplify the
> >> code when you do that. Maybe as separate commit, though.
> > 
> > Hehe - I'm testing on a nct6776 :)
> > I'll look into it once the first conversion has been accepted.
> 
> Wondering - why don't you use the nct6775 driver ?

Probably because it got matched by sensors-detect before the nct6775 driver 
(?) or because I hadn't had it turned on in my kernel config.

Both drivers work, but interestingly, they show different values for 
intrusion1 (and fan alarm).


nct6776.c:

nct6776-isa-0290
Adapter: ISA adapter
Vcore:  +1.16 V  (min =  +0.00 V, max =  +1.74 V)
in1:+1.85 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:   +3.36 V  (min =  +2.98 V, max =  +3.63 V)
+3.3V:  +3.36 V  (min =  +2.98 V, max =  +3.63 V)
in4:+0.26 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:+1.67 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in6:+0.79 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:   +3.44 V  (min =  +2.98 V, max =  +3.63 V)
Vbat:   +3.26 V  (min =  +2.70 V, max =  +3.63 V)
fan1: 0 RPM  (min =0 RPM)
fan2:  2106 RPM  (min =0 RPM)
fan3: 0 RPM  (min =0 RPM)
fan4: 0 RPM  (min =0 RPM)
fan5: 0 RPM  (min =0 RPM)
SYSTIN: +35.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = 
thermistor
CPUTIN: +44.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
AUXTIN: +43.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
PECI Agent 0:   +59.0°C  (high = +80.0°C, hyst = +75.0°C)
 (crit = +105.0°C)
PCH_CHIP_TEMP:   +0.0°C  
PCH_CPU_TEMP:+0.0°C  
PCH_MCH_TEMP:+0.0°C  
intrusion0:ALARM
intrusion1:OK
beep_enable:   disabled



w83627ehf.c:
nct6776-isa-0290
Adapter: ISA adapter
Vcore: +1.14 V  (min =  +0.00 V, max =  +1.74 V)
in1:   +1.85 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
AVCC:  +3.36 V  (min =  +2.98 V, max =  +3.63 V)
+3.3V: +3.36 V  (min =  +2.98 V, max =  +3.63 V)
in4:   +0.24 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
in5:   +1.68 V  (min =  +0.00 V, max =  +0.00 V)  ALARM
3VSB:  +3.44 V  (min =  +2.98 V, max =  +3.63 V)
Vbat:  +3.26 V  (min =  +2.70 V, max =  +3.63 V)
fan1:0 RPM  (min =0 RPM)  ALARM
fan2: 2142 RPM  (min =0 RPM)  ALARM
fan3:0 RPM  (min =0 RPM)  ALARM
fan4:0 RPM  (min =0 RPM)  ALARM
fan5:0 RPM  (min =0 RPM)  ALARM
SYSTIN:+35.0°C  (high =  +0.0°C, hyst =  +0.0°C)  ALARM  sensor = 
thermistor
CPUTIN:+46.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
AUXTIN:+44.0°C  (high = +80.0°C, hyst = +75.0°C)  sensor = thermistor
PECI Agent 0:  +64.0°C  
cpu0_vid: +0.000 V
intrusion0:   ALARM
intrusion1:   ALARM



Once the other patches have been accepted I'll work on that conversion/removal 
of the nct6775 code from the w83627ehf.


Peter





Re: Conversion of w83627ehf to hwmon_device_register_with_info ?

2017-03-21 Thread Peter Hüwe
Hi

On Friday 03 March 2017 03:56:01 Guenter Roeck wrote:
> Hi Peter,
> 
> On 03/02/2017 04:33 PM, Peter Hüwe wrote:
> > Hi,
> > 
> > is anybody else working on the conversion of the w83627ehf to the new
> > hwmon_device_register_with_info interface?
> 
> I don't think so.
> 
> > Otherwise I will probably update the driver to this interface within the
> > next days - but since it's a lot of work I wanted to check for
> > duplication first.
> 
> Go ahead.

So I'm close to have to conversion done,
the current diff stat is about
647 insertions(+), 787 deletions(-)
for the whole conversion.

Should I try to break it down into smaller chunks for easier review?

Although this would mean to convert stuff from A to B and then from B to C -
otherwise the intermediate steps would be not fully functional. 
(since the sysfs nodes partially would exist under hwmon1/ and partially under 
hwmon1/device/ (as they currently are)).

or just submit it?

It saves about 20k in compiled size, so the savings from reduced boilerplate 
are huge. (and I think it's more readable)



> I would suggest to drop nct6775/nct6776 support to simplify the
> code when you do that. Maybe as separate commit, though.
Hehe - I'm testing on a nct6776 :)
I'll look into it once the first conversion has been accepted.





Thanks,
Peter


Re: Conversion of w83627ehf to hwmon_device_register_with_info ?

2017-03-21 Thread Peter Hüwe
Hi

On Friday 03 March 2017 03:56:01 Guenter Roeck wrote:
> Hi Peter,
> 
> On 03/02/2017 04:33 PM, Peter Hüwe wrote:
> > Hi,
> > 
> > is anybody else working on the conversion of the w83627ehf to the new
> > hwmon_device_register_with_info interface?
> 
> I don't think so.
> 
> > Otherwise I will probably update the driver to this interface within the
> > next days - but since it's a lot of work I wanted to check for
> > duplication first.
> 
> Go ahead.

So I'm close to have to conversion done,
the current diff stat is about
647 insertions(+), 787 deletions(-)
for the whole conversion.

Should I try to break it down into smaller chunks for easier review?

Although this would mean to convert stuff from A to B and then from B to C -
otherwise the intermediate steps would be not fully functional. 
(since the sysfs nodes partially would exist under hwmon1/ and partially under 
hwmon1/device/ (as they currently are)).

or just submit it?

It saves about 20k in compiled size, so the savings from reduced boilerplate 
are huge. (and I think it's more readable)



> I would suggest to drop nct6775/nct6776 support to simplify the
> code when you do that. Maybe as separate commit, though.
Hehe - I'm testing on a nct6776 :)
I'll look into it once the first conversion has been accepted.





Thanks,
Peter


Question about hwmon_attr_show_string

2017-03-06 Thread Peter Hüwe
Hi Guenter,

I was wondering whether there was a particular reason why 
hwmon_attr_show_string passes only an "empty" pointer(pointer) to the ops-
>read_string function rather than the buffer itself?

Wouldn't this mean that in ops->read_string I'd have to reserve some space for 
the value on the heap (and taking care to free it somewhere, since returning 
an address on the stack is bad idea), instead of calling sprintf(buf, "%s\n", 
s) directly?

With the current implementation I have to sprintf it into my local buffer and 
you sprintf it again into the final buffer.


Unfortunately there are no other callers, where you show the intended usage.



Thanks,
Peter


Question about hwmon_attr_show_string

2017-03-06 Thread Peter Hüwe
Hi Guenter,

I was wondering whether there was a particular reason why 
hwmon_attr_show_string passes only an "empty" pointer(pointer) to the ops-
>read_string function rather than the buffer itself?

Wouldn't this mean that in ops->read_string I'd have to reserve some space for 
the value on the heap (and taking care to free it somewhere, since returning 
an address on the stack is bad idea), instead of calling sprintf(buf, "%s\n", 
s) directly?

With the current implementation I have to sprintf it into my local buffer and 
you sprintf it again into the final buffer.


Unfortunately there are no other callers, where you show the intended usage.



Thanks,
Peter


Conversion of w83627ehf to hwmon_device_register_with_info ?

2017-03-02 Thread Peter Hüwe
Hi,

is anybody else working on the conversion of the w83627ehf to the new 
hwmon_device_register_with_info interface? 

Otherwise I will probably update the driver to this interface within the next 
days - but since it's a lot of work I wanted to check for duplication first.

Do you think it makes sense to introduce a hwmon_sensor_types for "intrusion" 
as well? - there are currently 8 drivers who offer that interface.

Thanks,
Peter


Conversion of w83627ehf to hwmon_device_register_with_info ?

2017-03-02 Thread Peter Hüwe
Hi,

is anybody else working on the conversion of the w83627ehf to the new 
hwmon_device_register_with_info interface? 

Otherwise I will probably update the driver to this interface within the next 
days - but since it's a lot of work I wanted to check for duplication first.

Do you think it makes sense to introduce a hwmon_sensor_types for "intrusion" 
as well? - there are currently 8 drivers who offer that interface.

Thanks,
Peter


Re: [PATCH 06/10] tpm: introduce tpm_buf

2015-10-17 Thread Peter Hüwe
Am Freitag, 16. Oktober 2015, 20:40:25 schrieb Jarkko Sakkinen:
> This patch introduces struct tpm_buf that provides a string buffer for
> constructing TPM commands. This allows to construct variable sized TPM
> commands. For the buffer a page is allocated and mapped, which limits
> maximum size to PAGE_SIZE.
> 
> Variable sized TPM commands are needed in order to add algorithmic
> agility.
> 
> Signed-off-by: Jarkko Sakkinen 
> ---
>  drivers/char/tpm/tpm.h | 97
> ++ 1 file changed, 97
> insertions(+)
> 
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index 36ceb71..cb46f62 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -1,5 +1,6 @@
>  /*
>   * Copyright (C) 2004 IBM Corporation
> + * Copyright (C) 2015 Intel Corporation
>   *
>   * Authors:
>   * Leendert van Doorn 
> @@ -28,6 +29,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  enum tpm_const {
>   TPM_MINOR = 224,/* officially assigned */
> @@ -390,6 +392,101 @@ struct tpm_cmd_t {
>   tpm_cmd_params  params;
>  } __packed;
> 
> +/* A string buffer type for constructing TPM commands. This is based on
> the + * ideas of string buffer code in security/keys/trusted.h but is heap
> based + * in order to keep the stack usage minimal.
> + */
> +
> +enum tpm_buf_flags {
> + TPM_BUF_OVERFLOW= BIT(0),
> +};
> +
> +struct tpm_buf {
> + struct page *data_page;
> + unsigned int flags;
> + u8 *data;
> +};
> +
> +static inline void tpm_buf_init(struct tpm_buf *buf, u16 tag, u32 ordinal)
> +{
> + struct tpm_input_header *head;
> +
> + buf->data_page = alloc_page(GFP_HIGHUSER);
> + if (!buf->data_page)
> + return -ENOMEM;
> +
> + buf->flags = 0;
> + buf->data = kmap(buf->data_page);
> +
> + head = (struct tpm_input_header *) buf->data;
> +
> + head->tag = cpu_to_be16(tag);
> + head->length = cpu_to_be32(sizeof(*head));
> + head->ordinal = cpu_to_be32(ordinal);
> +
> + return 0;
> +}
> +
> +static inline void tpm_buf_destroy(struct tpm_buf *buf)
> +{
> + kunmap(buf->data_page);
> + __free_page(buf->data_page);
> +}
> +
> +static inline u32 tpm_buf_length(struct tpm_buf *buf)
> +{
> + struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
> +
> + return be32_to_cpu(head->length);
> +}
> +
> +static inline u16 tpm_buf_tag(struct tpm_buf *buf)
> +{
> + struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
> +
> + return be16_to_cpu(head->tag);
> +}
> +
> +static inline void tpm_buf_append(struct tpm_buf *buf,
> +   const unsigned char *new_data,
> +   unsigned int new_len)
> +{
> + struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
> + u32 len = tpm_buf_length(buf);


> +
> + /* Return silently if overflow has already happened. */
> + if (buf->flags & TPM_BUF_OVERFLOW)
> + return;
> +
> + if ((len + new_len) > PAGE_SIZE) {
> + WARN(1, "tpm_buf: overflow\n");
> + buf->flags |= TPM_BUF_OVERFLOW;
> + return;
> + }
Why not use WARN_ONCE?

> +
> + memcpy(>data[len], new_data, new_len);
> + head->length = cpu_to_be32(len + new_len);
> +}
> +
> +static inline void tpm_buf_append_u8(struct tpm_buf *buf, const u8 value)
> +{
> + tpm_buf_append(buf, , 1);
> +}
> +
> +static inline void tpm_buf_append_u16(struct tpm_buf *buf, const u16
> value) +{
> + __be16 value2 = cpu_to_be16(value);
> +
> + tpm_buf_append(buf, (u8 *) , 2);
> +}
> +
> +static inline void tpm_buf_append_u32(struct tpm_buf *buf, const u32
> value) +{
> + __be32 value2 = cpu_to_be32(value);
> +
> + tpm_buf_append(buf, (u8 *) , 4);
> +}
> +
>  extern struct class *tpm_class;
>  extern dev_t tpm_devt;
>  extern const struct file_operations tpm_fops;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 01/10] tpm, tpm_crb: fix unaligned read of the command buffer address

2015-10-17 Thread Peter Hüwe
Am Freitag, 16. Oktober 2015, 20:40:20 schrieb Jarkko Sakkinen:
> +   pa = ((u64) le32_to_cpu(ioread32(>cca->cmd_pa_high)) << 32) +
> +   (u64) le32_to_cpu(ioread32(>cca->cmd_pa_low));

The canonical form would be 
> +   pa = ((u64) le32_to_cpu(ioread32(>cca->cmd_pa_high)) << 32) |
> +   (u64) le32_to_cpu(ioread32(>cca->cmd_pa_low));
?
Or am I missing something?
Shall I fix-up?

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 03/10] sysfs: added __compat_only_sysfs_link_entry_to_kobj()

2015-10-17 Thread Peter Hüwe
Am Freitag, 16. Oktober 2015, 20:40:22 schrieb Jarkko Sakkinen:
> Added a new function __compat_only_sysfs_link_group_to_kobj() that adds
> a symlink from attribute or group to a kobject. This needed for
> maintaining backwards compatibility with PPI attributes in the TPM
> driver.
> 
> Signed-off-by: Jarkko Sakkinen 
@Greg: Can I get an acked-by or something from you as the sysfs maintainer?

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 03/10] sysfs: added __compat_only_sysfs_link_entry_to_kobj()

2015-10-17 Thread Peter Hüwe
Am Freitag, 16. Oktober 2015, 20:40:22 schrieb Jarkko Sakkinen:
> Added a new function __compat_only_sysfs_link_group_to_kobj() that adds
> a symlink from attribute or group to a kobject. This needed for
> maintaining backwards compatibility with PPI attributes in the TPM
> driver.
> 
> Signed-off-by: Jarkko Sakkinen 
@Greg: Can I get an acked-by or something from you as the sysfs maintainer?

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 01/10] tpm, tpm_crb: fix unaligned read of the command buffer address

2015-10-17 Thread Peter Hüwe
Am Freitag, 16. Oktober 2015, 20:40:20 schrieb Jarkko Sakkinen:
> +   pa = ((u64) le32_to_cpu(ioread32(>cca->cmd_pa_high)) << 32) +
> +   (u64) le32_to_cpu(ioread32(>cca->cmd_pa_low));

The canonical form would be 
> +   pa = ((u64) le32_to_cpu(ioread32(>cca->cmd_pa_high)) << 32) |
> +   (u64) le32_to_cpu(ioread32(>cca->cmd_pa_low));
?
Or am I missing something?
Shall I fix-up?

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 06/10] tpm: introduce tpm_buf

2015-10-17 Thread Peter Hüwe
Am Freitag, 16. Oktober 2015, 20:40:25 schrieb Jarkko Sakkinen:
> This patch introduces struct tpm_buf that provides a string buffer for
> constructing TPM commands. This allows to construct variable sized TPM
> commands. For the buffer a page is allocated and mapped, which limits
> maximum size to PAGE_SIZE.
> 
> Variable sized TPM commands are needed in order to add algorithmic
> agility.
> 
> Signed-off-by: Jarkko Sakkinen 
> ---
>  drivers/char/tpm/tpm.h | 97
> ++ 1 file changed, 97
> insertions(+)
> 
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index 36ceb71..cb46f62 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -1,5 +1,6 @@
>  /*
>   * Copyright (C) 2004 IBM Corporation
> + * Copyright (C) 2015 Intel Corporation
>   *
>   * Authors:
>   * Leendert van Doorn 
> @@ -28,6 +29,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  enum tpm_const {
>   TPM_MINOR = 224,/* officially assigned */
> @@ -390,6 +392,101 @@ struct tpm_cmd_t {
>   tpm_cmd_params  params;
>  } __packed;
> 
> +/* A string buffer type for constructing TPM commands. This is based on
> the + * ideas of string buffer code in security/keys/trusted.h but is heap
> based + * in order to keep the stack usage minimal.
> + */
> +
> +enum tpm_buf_flags {
> + TPM_BUF_OVERFLOW= BIT(0),
> +};
> +
> +struct tpm_buf {
> + struct page *data_page;
> + unsigned int flags;
> + u8 *data;
> +};
> +
> +static inline void tpm_buf_init(struct tpm_buf *buf, u16 tag, u32 ordinal)
> +{
> + struct tpm_input_header *head;
> +
> + buf->data_page = alloc_page(GFP_HIGHUSER);
> + if (!buf->data_page)
> + return -ENOMEM;
> +
> + buf->flags = 0;
> + buf->data = kmap(buf->data_page);
> +
> + head = (struct tpm_input_header *) buf->data;
> +
> + head->tag = cpu_to_be16(tag);
> + head->length = cpu_to_be32(sizeof(*head));
> + head->ordinal = cpu_to_be32(ordinal);
> +
> + return 0;
> +}
> +
> +static inline void tpm_buf_destroy(struct tpm_buf *buf)
> +{
> + kunmap(buf->data_page);
> + __free_page(buf->data_page);
> +}
> +
> +static inline u32 tpm_buf_length(struct tpm_buf *buf)
> +{
> + struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
> +
> + return be32_to_cpu(head->length);
> +}
> +
> +static inline u16 tpm_buf_tag(struct tpm_buf *buf)
> +{
> + struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
> +
> + return be16_to_cpu(head->tag);
> +}
> +
> +static inline void tpm_buf_append(struct tpm_buf *buf,
> +   const unsigned char *new_data,
> +   unsigned int new_len)
> +{
> + struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
> + u32 len = tpm_buf_length(buf);


> +
> + /* Return silently if overflow has already happened. */
> + if (buf->flags & TPM_BUF_OVERFLOW)
> + return;
> +
> + if ((len + new_len) > PAGE_SIZE) {
> + WARN(1, "tpm_buf: overflow\n");
> + buf->flags |= TPM_BUF_OVERFLOW;
> + return;
> + }
Why not use WARN_ONCE?

> +
> + memcpy(>data[len], new_data, new_len);
> + head->length = cpu_to_be32(len + new_len);
> +}
> +
> +static inline void tpm_buf_append_u8(struct tpm_buf *buf, const u8 value)
> +{
> + tpm_buf_append(buf, , 1);
> +}
> +
> +static inline void tpm_buf_append_u16(struct tpm_buf *buf, const u16
> value) +{
> + __be16 value2 = cpu_to_be16(value);
> +
> + tpm_buf_append(buf, (u8 *) , 2);
> +}
> +
> +static inline void tpm_buf_append_u32(struct tpm_buf *buf, const u32
> value) +{
> + __be32 value2 = cpu_to_be32(value);
> +
> + tpm_buf_append(buf, (u8 *) , 4);
> +}
> +
>  extern struct class *tpm_class;
>  extern dev_t tpm_devt;
>  extern const struct file_operations tpm_fops;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Fwd: Re: [PATCH v4 1/2] vTPM: support little endian guests]

2015-08-24 Thread Peter Hüwe
Am Montag, 24. August 2015, 21:07:32 schrieb Hon Ching(Vicky) Lo:
> Hi Peter,
> 
> 
> Did you the explanations in the following reply make sense to you?
> If you needed more clarifications, please advice.  Thanks!

I trust your explanations - I just haven't gotten around to apply them.
Sorry about that - will apply them for the next cycle.

Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Fwd: Re: [PATCH v4 1/2] vTPM: support little endian guests]

2015-08-24 Thread Peter Hüwe
Am Montag, 24. August 2015, 21:07:32 schrieb Hon Ching(Vicky) Lo:
 Hi Peter,
 
 
 Did you the explanations in the following reply make sense to you?
 If you needed more clarifications, please advice.  Thanks!

I trust your explanations - I just haven't gotten around to apply them.
Sorry about that - will apply them for the next cycle.

Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/2] vTPM: support little endian guests

2015-07-16 Thread Peter Hüwe
Hi Vicky,
Am Donnerstag, 16. Juli 2015, 19:54:15 schrieb Hon Ching(Vicky) Lo:
> Hi Peter,
> 
> On Mon, 2015-07-13 at 23:08 +0200, Peter Hüwe wrote:
> > Hi Vicky,
> > 
> > sorry for the late reply
> > 
> > > This patch makes the code endianness independent. We defined a
> > > macro do_endian_conversion to apply endianness to raw integers
> > > in the event entries so that they will be displayed properly.
> > > tpm_binary_bios_measurements_show() is modified for the display.
> > > 
> > > Signed-off-by: Hon Ching(Vicky) Lo 
> > > Signed-off-by: Joy Latten 
> > > 
> > > b/drivers/char/tpm/tpm_eventlog.h index e7da086..267bfbd 100644
> > > --- a/drivers/char/tpm/tpm_eventlog.h
> > > +++ b/drivers/char/tpm/tpm_eventlog.h
> > > @@ -6,6 +6,12 @@
> > > 
> > >  #define MAX_TEXT_EVENT   1000/* Max event string length */
> > >  #define ACPI_TCPA_SIG"TCPA"  /* 0x41504354 /'TCPA' */
> > > 
> > > +#ifdef CONFIG_PPC64
> > > +#define do_endian_conversion(x) be32_to_cpu(x)
> > > +#else
> > > +#define do_endian_conversion(x) x
> > > +#endif
> > 
> > Why is this macro needed?
> > shouldn't the be32_to_cpu macro already do correct thing?
> > Or am I missing something here?
> > 
> > 
> > Thanks,
> > Peter
> 
> The macro is defined to not do the conversion in the architecture
> that does not need it.

Unfortunately I'm still not convinced this is needed?
 be32_to_cpu(x)
should already do the right thing if no conversion is needed ? (being defined 
as (x)) 
Or is it not?



Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/2] vTPM: support little endian guests

2015-07-16 Thread Peter Hüwe
Hi Vicky,
Am Donnerstag, 16. Juli 2015, 19:54:15 schrieb Hon Ching(Vicky) Lo:
 Hi Peter,
 
 On Mon, 2015-07-13 at 23:08 +0200, Peter Hüwe wrote:
  Hi Vicky,
  
  sorry for the late reply
  
   This patch makes the code endianness independent. We defined a
   macro do_endian_conversion to apply endianness to raw integers
   in the event entries so that they will be displayed properly.
   tpm_binary_bios_measurements_show() is modified for the display.
   
   Signed-off-by: Hon Ching(Vicky) Lo hon...@linux.vnet.ibm.com
   Signed-off-by: Joy Latten jmlat...@linux.vnet.ibm.com
   
   b/drivers/char/tpm/tpm_eventlog.h index e7da086..267bfbd 100644
   --- a/drivers/char/tpm/tpm_eventlog.h
   +++ b/drivers/char/tpm/tpm_eventlog.h
   @@ -6,6 +6,12 @@
   
#define MAX_TEXT_EVENT   1000/* Max event string length */
#define ACPI_TCPA_SIGTCPA  /* 0x41504354 /'TCPA' */
   
   +#ifdef CONFIG_PPC64
   +#define do_endian_conversion(x) be32_to_cpu(x)
   +#else
   +#define do_endian_conversion(x) x
   +#endif
  
  Why is this macro needed?
  shouldn't the be32_to_cpu macro already do correct thing?
  Or am I missing something here?
  
  
  Thanks,
  Peter
 
 The macro is defined to not do the conversion in the architecture
 that does not need it.

Unfortunately I'm still not convinced this is needed?
 be32_to_cpu(x)
should already do the right thing if no conversion is needed ? (being defined 
as (x)) 
Or is it not?



Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Drop owner assignment from i2c_driver (and platform left-overs)

2015-07-13 Thread Peter Hüwe
Am Freitag, 10. Juli 2015, 07:32:28 schrieb Krzysztof Kozlowski:
> Hi,
> 
> 
> The i2c drivers also do not have to set 'owner' field because
> i2c_register_driver() will do it instead.
> 
> 'owner' is removed from i2c drivers, which I was able to compile
> with allyesconfig (arm, arm64, i386, x86_64, ppc64).
> Only compile-tested.
> 
> The coccinelle script which generated the patch was sent here:
> http://www.spinics.net/lists/kernel/msg2029903.html
> 
> 
> Best regards,
> Krzysztof
> 
> Krzysztof Kozlowski (1):
>   char: Drop owner assignment from i2c_driver
> 
>  drivers/char/ipmi/ipmi_ssif.c   | 1 -
>  drivers/char/tpm/st33zp24/i2c.c | 1 -
>  drivers/char/tpm/tpm_i2c_atmel.c| 1 -
>  drivers/char/tpm/tpm_i2c_infineon.c | 1 -
>  drivers/char/tpm/tpm_i2c_nuvoton.c  | 1 -
>  5 files changed, 5 deletions(-)


Applied - thanks.
Will be included in the pull-request for 4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm, tpm_crb: fail when TPM2 ACPI table contents look corrupted

2015-07-13 Thread Peter Hüwe
Am Mittwoch, 24. Juni 2015, 16:14:55 schrieb Jarkko Sakkinen:
> At least some versions of AMI BIOS have corrupted contents in the TPM2
> ACPI table and namely the physical address of the control area is set to
> zero.
> 
> This patch changes the driver to fail gracefully  when we observe a zero
> address instead of continuing to ioremap.

Reviewed-by: Peter Huewe 

Thanks for fixing this.
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/2] vTPM: support little endian guests

2015-07-13 Thread Peter Hüwe
Hi Vicky,

sorry for the late reply


> This patch makes the code endianness independent. We defined a
> macro do_endian_conversion to apply endianness to raw integers
> in the event entries so that they will be displayed properly.
> tpm_binary_bios_measurements_show() is modified for the display.
> 
> Signed-off-by: Hon Ching(Vicky) Lo 
> Signed-off-by: Joy Latten 

> b/drivers/char/tpm/tpm_eventlog.h index e7da086..267bfbd 100644
> --- a/drivers/char/tpm/tpm_eventlog.h
> +++ b/drivers/char/tpm/tpm_eventlog.h
> @@ -6,6 +6,12 @@
>  #define MAX_TEXT_EVENT   1000/* Max event string length */
>  #define ACPI_TCPA_SIG"TCPA"  /* 0x41504354 /'TCPA' */
> 
> +#ifdef CONFIG_PPC64
> +#define do_endian_conversion(x) be32_to_cpu(x)
> +#else
> +#define do_endian_conversion(x) x
> +#endif


Why is this macro needed?
shouldn't the be32_to_cpu macro already do correct thing?
Or am I missing something here?


Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm, tpm_crb: fail when TPM2 ACPI table contents look corrupted

2015-07-13 Thread Peter Hüwe
Am Mittwoch, 24. Juni 2015, 16:14:55 schrieb Jarkko Sakkinen:
 At least some versions of AMI BIOS have corrupted contents in the TPM2
 ACPI table and namely the physical address of the control area is set to
 zero.
 
 This patch changes the driver to fail gracefully  when we observe a zero
 address instead of continuing to ioremap.

Reviewed-by: Peter Huewe peterhu...@gmx.de

Thanks for fixing this.
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/2] vTPM: support little endian guests

2015-07-13 Thread Peter Hüwe
Hi Vicky,

sorry for the late reply


 This patch makes the code endianness independent. We defined a
 macro do_endian_conversion to apply endianness to raw integers
 in the event entries so that they will be displayed properly.
 tpm_binary_bios_measurements_show() is modified for the display.
 
 Signed-off-by: Hon Ching(Vicky) Lo hon...@linux.vnet.ibm.com
 Signed-off-by: Joy Latten jmlat...@linux.vnet.ibm.com

 b/drivers/char/tpm/tpm_eventlog.h index e7da086..267bfbd 100644
 --- a/drivers/char/tpm/tpm_eventlog.h
 +++ b/drivers/char/tpm/tpm_eventlog.h
 @@ -6,6 +6,12 @@
  #define MAX_TEXT_EVENT   1000/* Max event string length */
  #define ACPI_TCPA_SIGTCPA  /* 0x41504354 /'TCPA' */
 
 +#ifdef CONFIG_PPC64
 +#define do_endian_conversion(x) be32_to_cpu(x)
 +#else
 +#define do_endian_conversion(x) x
 +#endif


Why is this macro needed?
shouldn't the be32_to_cpu macro already do correct thing?
Or am I missing something here?


Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Drop owner assignment from i2c_driver (and platform left-overs)

2015-07-13 Thread Peter Hüwe
Am Freitag, 10. Juli 2015, 07:32:28 schrieb Krzysztof Kozlowski:
 Hi,
 
 
 The i2c drivers also do not have to set 'owner' field because
 i2c_register_driver() will do it instead.
 
 'owner' is removed from i2c drivers, which I was able to compile
 with allyesconfig (arm, arm64, i386, x86_64, ppc64).
 Only compile-tested.
 
 The coccinelle script which generated the patch was sent here:
 http://www.spinics.net/lists/kernel/msg2029903.html
 
 
 Best regards,
 Krzysztof
 
 Krzysztof Kozlowski (1):
   char: Drop owner assignment from i2c_driver
 
  drivers/char/ipmi/ipmi_ssif.c   | 1 -
  drivers/char/tpm/st33zp24/i2c.c | 1 -
  drivers/char/tpm/tpm_i2c_atmel.c| 1 -
  drivers/char/tpm/tpm_i2c_infineon.c | 1 -
  drivers/char/tpm/tpm_i2c_nuvoton.c  | 1 -
  5 files changed, 5 deletions(-)


Applied - thanks.
Will be included in the pull-request for 4.3
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tpmdd-devel] [PATCH] tpm, tpm_crb: migrate to struct acpi_table_tpm2 and acpi_tpm2_control

2015-06-16 Thread Peter Hüwe
Hi Jarkko

> > > >Betreff: [PATCH] tpm, tpm_crb: migrate to struct acpi_table_tpm2 and
> > > >acpi_tpm2_control
> > > but are the names there still correct? Isn't this information outdated?
> > > The acpi spec refers to the MS spec which is not present anymore, and
> > > MS refers to the TCG -- and in the PTP your names are used.
> > > 
> > > ---> We should update the ACPI header?
> > > At least the naming for reserved and error.
> > > What do you think?
> > 
> > I think you are right. It does not make sense to degrade here. 

so I'm waiting on the new version depending on the updated acpi header?

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] vTPM: set virtual device before passing to ibmvtpm_reset_crq

2015-06-16 Thread Peter Hüwe
Hey,

Am Freitag, 22. Mai 2015, 19:23:02 schrieb Hon Ching(Vicky) Lo:
> tpm_ibmvtpm_probe() calls ibmvtpm_reset_crq(ibmvtpm) without having yet
> set the virtual device in the ibmvtpm structure. So in ibmvtpm_reset_crq,
> the phype call contains empty unit addresses, ibmvtpm->vdev->unit_address.
> 
> Signed-off-by: Hon Ching(Vicky) Lo 
> Signed-off-by: Joy Latten 
> ---
>  drivers/char/tpm/tpm_ibmvtpm.c |5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_ibmvtpm.c
> b/drivers/char/tpm/tpm_ibmvtpm.c index 42ffa5e..27ebf95 100644
> --- a/drivers/char/tpm/tpm_ibmvtpm.c
> +++ b/drivers/char/tpm/tpm_ibmvtpm.c
> @@ -578,6 +578,9 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
>   goto cleanup;
>   }
> 
> + ibmvtpm->dev = dev;
> + ibmvtpm->vdev = vio_dev;
> +
>   crq_q = >crq_queue;
>   crq_q->crq_addr = (struct ibmvtpm_crq *)get_zeroed_page(GFP_KERNEL);
>   if (!crq_q->crq_addr) {
> @@ -622,8 +625,6 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
> 
>   crq_q->index = 0;
> 
> - ibmvtpm->dev = dev;
> - ibmvtpm->vdev = vio_dev;
>   TPM_VPRIV(chip) = (void *)ibmvtpm;
> 
>   spin_lock_init(>rtce_lock);

Is this a fix for something?
does it need to go through stable?

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] vTPM: set virtual device before passing to ibmvtpm_reset_crq

2015-06-16 Thread Peter Hüwe
Hey,

Am Freitag, 22. Mai 2015, 19:23:02 schrieb Hon Ching(Vicky) Lo:
 tpm_ibmvtpm_probe() calls ibmvtpm_reset_crq(ibmvtpm) without having yet
 set the virtual device in the ibmvtpm structure. So in ibmvtpm_reset_crq,
 the phype call contains empty unit addresses, ibmvtpm-vdev-unit_address.
 
 Signed-off-by: Hon Ching(Vicky) Lo hon...@linux.vnet.ibm.com
 Signed-off-by: Joy Latten jmlat...@linux.vnet.ibm.com
 ---
  drivers/char/tpm/tpm_ibmvtpm.c |5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/char/tpm/tpm_ibmvtpm.c
 b/drivers/char/tpm/tpm_ibmvtpm.c index 42ffa5e..27ebf95 100644
 --- a/drivers/char/tpm/tpm_ibmvtpm.c
 +++ b/drivers/char/tpm/tpm_ibmvtpm.c
 @@ -578,6 +578,9 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
   goto cleanup;
   }
 
 + ibmvtpm-dev = dev;
 + ibmvtpm-vdev = vio_dev;
 +
   crq_q = ibmvtpm-crq_queue;
   crq_q-crq_addr = (struct ibmvtpm_crq *)get_zeroed_page(GFP_KERNEL);
   if (!crq_q-crq_addr) {
 @@ -622,8 +625,6 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
 
   crq_q-index = 0;
 
 - ibmvtpm-dev = dev;
 - ibmvtpm-vdev = vio_dev;
   TPM_VPRIV(chip) = (void *)ibmvtpm;
 
   spin_lock_init(ibmvtpm-rtce_lock);

Is this a fix for something?
does it need to go through stable?

Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tpmdd-devel] [PATCH] tpm, tpm_crb: migrate to struct acpi_table_tpm2 and acpi_tpm2_control

2015-06-16 Thread Peter Hüwe
Hi Jarkko

   Betreff: [PATCH] tpm, tpm_crb: migrate to struct acpi_table_tpm2 and
   acpi_tpm2_control
   but are the names there still correct? Isn't this information outdated?
   The acpi spec refers to the MS spec which is not present anymore, and
   MS refers to the TCG -- and in the PTP your names are used.
   
   --- We should update the ACPI header?
   At least the naming for reserved and error.
   What do you think?
  
  I think you are right. It does not make sense to degrade here. 

so I'm waiting on the new version depending on the updated acpi header?

Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] tpm: introduce struct tpm_buf

2015-06-08 Thread Peter Hüwe
Hi,


Am Mittwoch, 3. Juni 2015, 18:39:14 schrieb Jarkko Sakkinen:
> This patch introduces struct tpm_buf that provides a string buffer for
> constructing TPM commands. This allows to construct variable sized TPM
> commands. This feature is needed for TPM 2.0 commands in order to allow
> policy authentication and algorithmic agility.
> 
> The commands in the tpm2-cmd.c have been updated to use struct tpm_buf.
> Lots of awkward length calculations could be dropped because the buffer
> knows its length.
> 
> The code is is along the lines of the string buffer code in
> security/trusted/trusted.h.
> 
> Changes since v1:
> 
> - Fixed potential alignment issues in tpm_buf_tag().
> 
> Signed-off-by: Jarkko Sakkinen 

> +static inline void tpm_buf_append(struct tpm_buf *buf,
> +   const unsigned char *data,
> +   unsigned int len)
> +{
> + struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
> +
> + BUG_ON((len + tpm_buf_length(buf)) > TPM_BUF_SIZE);
> +
> + memcpy(>data[tpm_buf_length(buf)], data, len);
> + head->length = cpu_to_be32(tpm_buf_length(buf) + len);
> +}
> +
> +static inline void tpm_buf_store(struct tpm_buf *buf,
> +  unsigned int pos,
> +  const unsigned char *data,
> +  unsigned int len)
> +{
> + BUG_ON((pos + len) > TPM_BUF_SIZE);
> +
> + memcpy(>data[pos], data, len);
> +}

Don't you have to update the ->length here?


Thanks,
Peter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] tpm: introduce struct tpm_buf

2015-06-08 Thread Peter Hüwe
Hi,


Am Mittwoch, 3. Juni 2015, 18:39:14 schrieb Jarkko Sakkinen:
 This patch introduces struct tpm_buf that provides a string buffer for
 constructing TPM commands. This allows to construct variable sized TPM
 commands. This feature is needed for TPM 2.0 commands in order to allow
 policy authentication and algorithmic agility.
 
 The commands in the tpm2-cmd.c have been updated to use struct tpm_buf.
 Lots of awkward length calculations could be dropped because the buffer
 knows its length.
 
 The code is is along the lines of the string buffer code in
 security/trusted/trusted.h.
 
 Changes since v1:
 
 - Fixed potential alignment issues in tpm_buf_tag().
 
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com

 +static inline void tpm_buf_append(struct tpm_buf *buf,
 +   const unsigned char *data,
 +   unsigned int len)
 +{
 + struct tpm_input_header *head = (struct tpm_input_header *) buf-data;
 +
 + BUG_ON((len + tpm_buf_length(buf))  TPM_BUF_SIZE);
 +
 + memcpy(buf-data[tpm_buf_length(buf)], data, len);
 + head-length = cpu_to_be32(tpm_buf_length(buf) + len);
 +}
 +
 +static inline void tpm_buf_store(struct tpm_buf *buf,
 +  unsigned int pos,
 +  const unsigned char *data,
 +  unsigned int len)
 +{
 + BUG_ON((pos + len)  TPM_BUF_SIZE);
 +
 + memcpy(buf-data[pos], data, len);
 +}

Don't you have to update the -length here?


Thanks,
Peter

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 03/27] tpm: Allow compile test of GPIO consumers if !GPIOLIB

2015-05-05 Thread Peter Hüwe
Am Dienstag, 5. Mai 2015, 18:32:19 schrieb Geert Uytterhoeven:
> The GPIO subsystem provides dummy GPIO consumer functions if GPIOLIB is
> not enabled. Hence drivers that depend on GPIOLIB, but use GPIO consumer
> functionality only, can still be compiled if GPIOLIB is not enabled.
> 
> Relax the dependency on GPIOLIB if COMPILE_TEST is enabled, where
> appropriate.
> 
> Signed-off-by: Geert Uytterhoeven 
> Cc: Peter Huewe 
> Cc: Marcel Selhorst 
> Cc: tpmdd-de...@lists.sourceforge.net
Acked-by: Peter Huewe 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 03/27] tpm: Allow compile test of GPIO consumers if !GPIOLIB

2015-05-05 Thread Peter Hüwe
Am Dienstag, 5. Mai 2015, 18:32:19 schrieb Geert Uytterhoeven:
 The GPIO subsystem provides dummy GPIO consumer functions if GPIOLIB is
 not enabled. Hence drivers that depend on GPIOLIB, but use GPIO consumer
 functionality only, can still be compiled if GPIOLIB is not enabled.
 
 Relax the dependency on GPIOLIB if COMPILE_TEST is enabled, where
 appropriate.
 
 Signed-off-by: Geert Uytterhoeven ge...@linux-m68k.org
 Cc: Peter Huewe peterhu...@gmx.de
 Cc: Marcel Selhorst tp...@selhorst.net
 Cc: tpmdd-de...@lists.sourceforge.net
Acked-by: Peter Huewe peterhu...@gmx.de
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/5 linux-next] tpm_ibmvtpm: remove unneccessary message level.

2015-03-30 Thread Peter Hüwe
Am Montag, 30. März 2015, 22:06:08 schrieb Fabian Frederick:
> KERN_ERR is implicitely declared in pr_err()
> 
> Signed-off-by: Fabian Frederick 
Good catch.
Acked-by: Peter Huewe 

If nobody else pulls this one through his tree, I'll apply it probably for 
4._2_ (so it might take a while)

Peter

> ---
>  drivers/char/tpm/tpm_of.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c
> index c002d1b..eebe625 100644
> --- a/drivers/char/tpm/tpm_of.c
> +++ b/drivers/char/tpm/tpm_of.c
> @@ -49,7 +49,7 @@ int read_log(struct tpm_bios_log *log)
> 
>   basep = of_get_property(np, "linux,sml-base", NULL);
>   if (basep == NULL) {
> - pr_err(KERN_ERR "%s: ERROR - SML not found\n", __func__);
> + pr_err("%s: ERROR - SML not found\n", __func__);
>   goto cleanup_eio;
>   }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/5 linux-next] tpm_ibmvtpm: remove unneccessary message level.

2015-03-30 Thread Peter Hüwe
Am Montag, 30. März 2015, 22:06:08 schrieb Fabian Frederick:
 KERN_ERR is implicitely declared in pr_err()
 
 Signed-off-by: Fabian Frederick f...@skynet.be
Good catch.
Acked-by: Peter Huewe peterhu...@gmx.de

If nobody else pulls this one through his tree, I'll apply it probably for 
4._2_ (so it might take a while)

Peter

 ---
  drivers/char/tpm/tpm_of.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c
 index c002d1b..eebe625 100644
 --- a/drivers/char/tpm/tpm_of.c
 +++ b/drivers/char/tpm/tpm_of.c
 @@ -49,7 +49,7 @@ int read_log(struct tpm_bios_log *log)
 
   basep = of_get_property(np, linux,sml-base, NULL);
   if (basep == NULL) {
 - pr_err(KERN_ERR %s: ERROR - SML not found\n, __func__);
 + pr_err(%s: ERROR - SML not found\n, __func__);
   goto cleanup_eio;
   }

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm: fix call order in tpm-chip.c

2015-03-01 Thread Peter Hüwe
Am Sonntag, 1. März 2015, 22:55:47 schrieb Jarkko Sakkinen:
> - tpm_dev_add_device(): cdev_add() must be done before uevent is
>   propagated in order to avoid races.
> - tpm_chip_register(): tpm_dev_add_device() must be done as the
>   last step before exposing device to the user space in order to
>   avoid races.
> 
> In addition clarified description in tpm_chip_register().
> 
> Signed-off-by: Jarkko Sakkinen 
Looks good to me.
Staged it and I'll send out the pull request in the next few days.

(have to catch up mails from traveling)

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm: fix call order in tpm-chip.c

2015-03-01 Thread Peter Hüwe
Am Sonntag, 1. März 2015, 22:55:47 schrieb Jarkko Sakkinen:
 - tpm_dev_add_device(): cdev_add() must be done before uevent is
   propagated in order to avoid races.
 - tpm_chip_register(): tpm_dev_add_device() must be done as the
   last step before exposing device to the user space in order to
   avoid races.
 
 In addition clarified description in tpm_chip_register().
 
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com
Looks good to me.
Staged it and I'll send out the pull request in the next few days.

(have to catch up mails from traveling)

Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm, tpm_tis: fix TPM 2.0 probing

2015-02-08 Thread Peter Hüwe
Am Mittwoch, 4. Februar 2015, 15:21:09 schrieb Jarkko Sakkinen:
> If during transmission system error was returned, the logic was to
> incorrectly deduce that chip is a TPM 1.x chip. This patch fixes this
> issue. Also, this patch changes probing so that message tag is used as the
> measure for TPM 2.x, which should be much more stable.
Is it aware that some TPMs may respond with 0x00C1 as TAG for TPM1.2 commands?


> A separate function
> called tpm2_probe() is encapsulated because it can be used with any
> chipset.

> 
> Signed-off-by: Jarkko Sakkinen 
> ---
>  drivers/char/tpm/tpm.h  |  3 ++-
>  drivers/char/tpm/tpm2-cmd.c | 40 +---
>  drivers/char/tpm/tpm_tis.c  | 11 ---
>  3 files changed, 39 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index 7b0727c..a4b0f5e 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -435,4 +435,5 @@ extern int tpm2_startup(struct tpm_chip *chip, u16
> startup_type); extern int tpm2_shutdown(struct tpm_chip *chip, u16
> shutdown_type); extern unsigned long tpm2_calc_ordinal_duration(struct
> tpm_chip *, u32); extern int tpm2_do_selftest(struct tpm_chip *chip);
> -extern int tpm2_gen_interrupt(struct tpm_chip *chip, bool quiet);
> +extern int tpm2_gen_interrupt(struct tpm_chip *chip);
> +extern int tpm2_probe(struct tpm_chip *chip);
> diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
> index 1abe650..49cd354 100644
> --- a/drivers/char/tpm/tpm2-cmd.c
> +++ b/drivers/char/tpm/tpm2-cmd.c
> @@ -598,20 +598,46 @@ EXPORT_SYMBOL_GPL(tpm2_do_selftest);
>  /**
>   * tpm2_gen_interrupt() - generate an interrupt
>   * @chip: TPM chip to use
> - * @quiet: surpress the error message
>   *
>   * 0 is returned when the operation is successful. If a negative number is
>   * returned it remarks a POSIX error code. If a positive number is
> returned * it remarks a TPM error.
>   */
> -int tpm2_gen_interrupt(struct tpm_chip *chip, bool quiet)
> +int tpm2_gen_interrupt(struct tpm_chip *chip)
>  {
> - const char *desc = NULL;
>   u32 dummy;
> 
> - if (!quiet)
> - desc = "attempting to generate an interrupt";
> -
> - return tpm2_get_tpm_pt(chip, TPM2_CAP_TPM_PROPERTIES, , desc);
> + return tpm2_get_tpm_pt(chip, 0x100, ,
> +"attempting to generate an interrupt");
Why the change from TPM2_CAP_TPM_PROPERTIES = 6 to 0x100 and what does 0x100 
stand for?


>  }
>  EXPORT_SYMBOL_GPL(tpm2_gen_interrupt);
> +
> +/**
> + * tpm2_probe() - probe TPM 2.0
> + * @chip: TPM chip to use
> + *
> + * Send idempotent TPM 2.0 command and see whether TPM 2.0 chip replied
> based on + * the reply tag.
> + */
> +int tpm2_probe(struct tpm_chip *chip)
> +{
> + struct tpm2_cmd cmd;
> + int rc;
> +
> + cmd.header.in = tpm2_get_tpm_pt_header;
> + cmd.params.get_tpm_pt_in.cap_id = cpu_to_be32(TPM2_CAP_TPM_PROPERTIES);
> + cmd.params.get_tpm_pt_in.property_id = cpu_to_be32(0x100);
> + cmd.params.get_tpm_pt_in.property_cnt = cpu_to_be32(1);
> +
> + rc = tpm_transmit(chip, (const char *) , sizeof(cmd));
> + if (rc <  0)
> + return rc;
> + else if (rc < TPM_HEADER_SIZE)
> + return -EFAULT;
> +
> + if (be16_to_cpu(cmd.header.out.tag) == TPM2_ST_NO_SESSIONS)
> + chip->flags |= TPM_CHIP_FLAG_TPM2;
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(tpm2_probe);
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 6725bef..ee6e0bd 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -639,12 +639,9 @@ static int tpm_tis_init(struct device *dev,
> acpi_handle acpi_dev_handle, goto out_err;
>   }
> 
> - /* Every TPM 2.x command has a higher ordinal than TPM 1.x commands.
> -  * Therefore, we can use an idempotent TPM 2.x command to probe TPM 2.x.
> -  */
> - rc = tpm2_gen_interrupt(chip, true);
> - if (rc == 0 || rc == TPM2_RC_INITIALIZE)
> - chip->flags |= TPM_CHIP_FLAG_TPM2;
> + rc = tpm2_probe(chip);
> + if (rc)
> + goto out_err;
> 
>   vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
>   chip->vendor.manufacturer_id = vendor;
> @@ -747,7 +744,7 @@ static int tpm_tis_init(struct device *dev, acpi_handle
> acpi_dev_handle,
> 
>   /* Generate Interrupts */
>   if (chip->flags & TPM_CHIP_FLAG_TPM2)
> - tpm2_gen_interrupt(chip, false);
> + tpm2_gen_interrupt(chip);
>   else
>   tpm_gen_interrupt(chip);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm, tpm_tis: fix TPM 2.0 probing

2015-02-08 Thread Peter Hüwe
Am Mittwoch, 4. Februar 2015, 15:21:09 schrieb Jarkko Sakkinen:
 If during transmission system error was returned, the logic was to
 incorrectly deduce that chip is a TPM 1.x chip. This patch fixes this
 issue. Also, this patch changes probing so that message tag is used as the
 measure for TPM 2.x, which should be much more stable.
Is it aware that some TPMs may respond with 0x00C1 as TAG for TPM1.2 commands?


 A separate function
 called tpm2_probe() is encapsulated because it can be used with any
 chipset.

 
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com
 ---
  drivers/char/tpm/tpm.h  |  3 ++-
  drivers/char/tpm/tpm2-cmd.c | 40 +---
  drivers/char/tpm/tpm_tis.c  | 11 ---
  3 files changed, 39 insertions(+), 15 deletions(-)
 
 diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
 index 7b0727c..a4b0f5e 100644
 --- a/drivers/char/tpm/tpm.h
 +++ b/drivers/char/tpm/tpm.h
 @@ -435,4 +435,5 @@ extern int tpm2_startup(struct tpm_chip *chip, u16
 startup_type); extern int tpm2_shutdown(struct tpm_chip *chip, u16
 shutdown_type); extern unsigned long tpm2_calc_ordinal_duration(struct
 tpm_chip *, u32); extern int tpm2_do_selftest(struct tpm_chip *chip);
 -extern int tpm2_gen_interrupt(struct tpm_chip *chip, bool quiet);
 +extern int tpm2_gen_interrupt(struct tpm_chip *chip);
 +extern int tpm2_probe(struct tpm_chip *chip);
 diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
 index 1abe650..49cd354 100644
 --- a/drivers/char/tpm/tpm2-cmd.c
 +++ b/drivers/char/tpm/tpm2-cmd.c
 @@ -598,20 +598,46 @@ EXPORT_SYMBOL_GPL(tpm2_do_selftest);
  /**
   * tpm2_gen_interrupt() - generate an interrupt
   * @chip: TPM chip to use
 - * @quiet: surpress the error message
   *
   * 0 is returned when the operation is successful. If a negative number is
   * returned it remarks a POSIX error code. If a positive number is
 returned * it remarks a TPM error.
   */
 -int tpm2_gen_interrupt(struct tpm_chip *chip, bool quiet)
 +int tpm2_gen_interrupt(struct tpm_chip *chip)
  {
 - const char *desc = NULL;
   u32 dummy;
 
 - if (!quiet)
 - desc = attempting to generate an interrupt;
 -
 - return tpm2_get_tpm_pt(chip, TPM2_CAP_TPM_PROPERTIES, dummy, desc);
 + return tpm2_get_tpm_pt(chip, 0x100, dummy,
 +attempting to generate an interrupt);
Why the change from TPM2_CAP_TPM_PROPERTIES = 6 to 0x100 and what does 0x100 
stand for?


  }
  EXPORT_SYMBOL_GPL(tpm2_gen_interrupt);
 +
 +/**
 + * tpm2_probe() - probe TPM 2.0
 + * @chip: TPM chip to use
 + *
 + * Send idempotent TPM 2.0 command and see whether TPM 2.0 chip replied
 based on + * the reply tag.
 + */
 +int tpm2_probe(struct tpm_chip *chip)
 +{
 + struct tpm2_cmd cmd;
 + int rc;
 +
 + cmd.header.in = tpm2_get_tpm_pt_header;
 + cmd.params.get_tpm_pt_in.cap_id = cpu_to_be32(TPM2_CAP_TPM_PROPERTIES);
 + cmd.params.get_tpm_pt_in.property_id = cpu_to_be32(0x100);
 + cmd.params.get_tpm_pt_in.property_cnt = cpu_to_be32(1);
 +
 + rc = tpm_transmit(chip, (const char *) cmd, sizeof(cmd));
 + if (rc   0)
 + return rc;
 + else if (rc  TPM_HEADER_SIZE)
 + return -EFAULT;
 +
 + if (be16_to_cpu(cmd.header.out.tag) == TPM2_ST_NO_SESSIONS)
 + chip-flags |= TPM_CHIP_FLAG_TPM2;
 +
 + return 0;
 +}
 +EXPORT_SYMBOL_GPL(tpm2_probe);
 diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
 index 6725bef..ee6e0bd 100644
 --- a/drivers/char/tpm/tpm_tis.c
 +++ b/drivers/char/tpm/tpm_tis.c
 @@ -639,12 +639,9 @@ static int tpm_tis_init(struct device *dev,
 acpi_handle acpi_dev_handle, goto out_err;
   }
 
 - /* Every TPM 2.x command has a higher ordinal than TPM 1.x commands.
 -  * Therefore, we can use an idempotent TPM 2.x command to probe TPM 2.x.
 -  */
 - rc = tpm2_gen_interrupt(chip, true);
 - if (rc == 0 || rc == TPM2_RC_INITIALIZE)
 - chip-flags |= TPM_CHIP_FLAG_TPM2;
 + rc = tpm2_probe(chip);
 + if (rc)
 + goto out_err;
 
   vendor = ioread32(chip-vendor.iobase + TPM_DID_VID(0));
   chip-vendor.manufacturer_id = vendor;
 @@ -747,7 +744,7 @@ static int tpm_tis_init(struct device *dev, acpi_handle
 acpi_dev_handle,
 
   /* Generate Interrupts */
   if (chip-flags  TPM_CHIP_FLAG_TPM2)
 - tpm2_gen_interrupt(chip, false);
 + tpm2_gen_interrupt(chip);
   else
   tpm_gen_interrupt(chip);

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Char: tpm: fixed white spaces and braces coding style issues

2015-01-18 Thread Peter Hüwe
Hi Bruno,

thanks for your patch!
The patch is fine, 
but unfortunately not against the latest version of the tpm subsytem code.

You can find the latest version of the tpm subsystem at   
https://github.com/PeterHuewe/linux-tpmdd 
the for-james branch is usually the best choice here.

Nevertheless, I quickly ported it to the latest code (see below)
--> applied.



> Fixed some coding style issues.
Usually it is quite good if you include the reports by checkpatch.

Thanks,
Peter


So this is what got merged, the rest does not apply anymore due to recent code 
changes:



From: Bruno E O Meneguele 
Date: Sat, 17 Jan 2015 17:03:30 +0100
Subject: [PATCH] char/tpm: fixed white spaces coding style issues

Fixed some coding style issues reported by checkpatch.

Signed-off-by: Bruno E O Meneguele 
[phuewe: ported to latest code]
Signed-off-by: Peter Huewe 
---
 drivers/char/tpm/tpm.h  | 6 +++---
 drivers/char/tpm/tpm_i2c_stm_st33.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index cc421cf..7b0727c 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -10,13 +10,13 @@
  * Maintained by: 
  *
  * Device driver for TCG/TCPA TPM (trusted platform module).
- * Specifications at www.trustedcomputinggroup.org  
+ * Specifications at www.trustedcomputinggroup.org
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation, version 2 of the
  * License.
- * 
+ *
  */
 #include 
 #include 
@@ -141,7 +141,7 @@ struct tpm_vendor_specific {
u16 manufacturer_id;
 };
 
-#define TPM_VPRIV(c)   (c)->vendor.priv
+#define TPM_VPRIV(c) ((c)->vendor.priv)
 
 #define TPM_VID_INTEL0x8086
 #define TPM_VID_WINBOND  0x1050
diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c 
b/drivers/char/tpm/tpm_i2c_stm_st33.c
index dbab8d0..612845b 100644
--- a/drivers/char/tpm/tpm_i2c_stm_st33.c
+++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
@@ -777,7 +777,7 @@ tpm_stm_i2c_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
IRQF_TRIGGER_HIGH,
"TPM SERIRQ management", chip);
if (ret < 0) {
-   dev_err(chip->pdev , "TPM SERIRQ signals %d not 
available\n",
+   dev_err(chip->pdev, "TPM SERIRQ signals %d not 
available\n",
client->irq);
goto _tpm_clean_answer;
}
-- 
2.0.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Char: tpm: fixed white spaces and braces coding style issues

2015-01-18 Thread Peter Hüwe
Hi Bruno,

thanks for your patch!
The patch is fine, 
but unfortunately not against the latest version of the tpm subsytem code.

You can find the latest version of the tpm subsystem at   
https://github.com/PeterHuewe/linux-tpmdd 
the for-james branch is usually the best choice here.

Nevertheless, I quickly ported it to the latest code (see below)
-- applied.



 Fixed some coding style issues.
Usually it is quite good if you include the reports by checkpatch.

Thanks,
Peter


So this is what got merged, the rest does not apply anymore due to recent code 
changes:



From: Bruno E O Meneguele bmenegu...@gmail.com
Date: Sat, 17 Jan 2015 17:03:30 +0100
Subject: [PATCH] char/tpm: fixed white spaces coding style issues

Fixed some coding style issues reported by checkpatch.

Signed-off-by: Bruno E O Meneguele bmenegu...@gmail.com
[phuewe: ported to latest code]
Signed-off-by: Peter Huewe peterhu...@gmx.de
---
 drivers/char/tpm/tpm.h  | 6 +++---
 drivers/char/tpm/tpm_i2c_stm_st33.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index cc421cf..7b0727c 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -10,13 +10,13 @@
  * Maintained by: tpmdd-de...@lists.sourceforge.net
  *
  * Device driver for TCG/TCPA TPM (trusted platform module).
- * Specifications at www.trustedcomputinggroup.org  
+ * Specifications at www.trustedcomputinggroup.org
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation, version 2 of the
  * License.
- * 
+ *
  */
 #include linux/module.h
 #include linux/delay.h
@@ -141,7 +141,7 @@ struct tpm_vendor_specific {
u16 manufacturer_id;
 };
 
-#define TPM_VPRIV(c)   (c)-vendor.priv
+#define TPM_VPRIV(c) ((c)-vendor.priv)
 
 #define TPM_VID_INTEL0x8086
 #define TPM_VID_WINBOND  0x1050
diff --git a/drivers/char/tpm/tpm_i2c_stm_st33.c 
b/drivers/char/tpm/tpm_i2c_stm_st33.c
index dbab8d0..612845b 100644
--- a/drivers/char/tpm/tpm_i2c_stm_st33.c
+++ b/drivers/char/tpm/tpm_i2c_stm_st33.c
@@ -777,7 +777,7 @@ tpm_stm_i2c_probe(struct i2c_client *client, const struct 
i2c_device_id *id)
IRQF_TRIGGER_HIGH,
TPM SERIRQ management, chip);
if (ret  0) {
-   dev_err(chip-pdev , TPM SERIRQ signals %d not 
available\n,
+   dev_err(chip-pdev, TPM SERIRQ signals %d not 
available\n,
client-irq);
goto _tpm_clean_answer;
}
-- 
2.0.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 6/8] tpm: TPM 2.0 baseline support

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:16 schrieb Jarkko Sakkinen:
> TPM 2.0 devices are separated by adding a field 'flags' to struct
> tpm_chip and defining a flag TPM_CHIP_FLAG_TPM2 for tagging them.
> 
> This patch adds the following internal functions:
> 
> - tpm2_get_random()
> - tpm2_get_tpm_pt()
> - tpm2_pcr_extend()
> - tpm2_pcr_read()
> - tpm2_startup()
> 
> Additionally, the following exported functions are implemented for
> implementing TPM 2.0 device drivers:
> 
> - tpm2_do_selftest()
> - tpm2_calc_ordinal_durations()
> - tpm2_gen_interrupt()
> 
> The existing functions that are exported for the use for existing
> subsystems have been changed to check the flags field in struct
> tpm_chip and use appropriate TPM 2.0 counterpart if
> TPM_CHIP_FLAG_TPM2 is est.
> 
> The code for tpm2_calc_ordinal_duration() and tpm2_startup() were
> originally written by Will Arthur.
> 
> Signed-off-by: Jarkko Sakkinen 
> Signed-off-by: Will Arthur 
> ---
>  drivers/char/tpm/Makefile|   2 +-
>  drivers/char/tpm/tpm-chip.c  |  27 +-
>  drivers/char/tpm/tpm-interface.c |  24 +-
>  drivers/char/tpm/tpm.h   |  61 +
>  drivers/char/tpm/tpm2-cmd.c  | 542
> +++ 5 files changed, 641
> insertions(+), 15 deletions(-)
>  create mode 100644 drivers/char/tpm/tpm2-cmd.c
> 
> diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
> index c715596..88848ed 100644
> --- a/drivers/char/tpm/Makefile
> +++ b/drivers/char/tpm/Makefile
> @@ -2,7 +2,7 @@
>  # Makefile for the kernel tpm device drivers.
>  #
>  obj-$(CONFIG_TCG_TPM) += tpm.o
> -tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o tpm-chip.o
> +tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o tpm-chip.o tpm2-cmd.o
>  tpm-$(CONFIG_ACPI) += tpm_ppi.o
> 
>  ifdef CONFIG_ACPI
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> index 7741e28..3f3f2de 100644
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -195,15 +195,18 @@ int tpm_chip_register(struct tpm_chip *chip)
>   if (rc)
>   return rc;
> 
> - rc = tpm_sysfs_add_device(chip);
> - if (rc)
> - goto del_misc;
> + /* Populate sysfs for TPM1 devices. */
> + if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
> + rc = tpm_sysfs_add_device(chip);
> + if (rc)
> + goto del_misc;
> 
> - rc = tpm_add_ppi(chip);
> - if (rc)
> - goto del_sysfs;
> + rc = tpm_add_ppi(chip);
> + if (rc)
> + goto del_sysfs;
> 
> - chip->bios_dir = tpm_bios_log_setup(chip->devname);
> + chip->bios_dir = tpm_bios_log_setup(chip->devname);
> + }
> 
>   /* Make the chip available. */
>   spin_lock(_lock);
> @@ -236,10 +239,12 @@ void tpm_chip_unregister(struct tpm_chip *chip)
>   spin_unlock(_lock);
>   synchronize_rcu();
> 
> - if (chip->bios_dir)
> - tpm_bios_log_teardown(chip->bios_dir);
> - tpm_remove_ppi(chip);
> - tpm_sysfs_del_device(chip);
> + if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) {
> + if (chip->bios_dir)
> + tpm_bios_log_teardown(chip->bios_dir);
> + tpm_remove_ppi(chip);
> + tpm_sysfs_del_device(chip);
> + }
> 
>   tpm_dev_del_device(chip);
>  }
> diff --git a/drivers/char/tpm/tpm-interface.c
> b/drivers/char/tpm/tpm-interface.c index b6f6b17..8a14887 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -360,7 +360,10 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char
> *buf, if (chip->vendor.irq)
>   goto out_recv;
> 
> - stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
> + if (chip->flags & TPM_CHIP_FLAG_TPM2)
> + stop = jiffies + tpm2_calc_ordinal_duration(chip, ordinal);
> + else
> + stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
>   do {
>   u8 status = chip->ops->status(chip);
>   if ((status & chip->ops->req_complete_mask) ==
> @@ -483,7 +486,7 @@ static const struct tpm_input_header tpm_startup_header
> = { static int tpm_startup(struct tpm_chip *chip, __be16 startup_type) {
>   struct tpm_cmd_t start_cmd;
> - start_cmd.header.in = tpm_startup_header;
> +
WHY?!? This renders tpm_startup useless.

So NACK for this part.
>   start_cmd.params.startup_in.startup_type = startup_type;
>   return tpm_transmit_cmd(chip, _cmd, TPM_INTERNAL_RESULT_SIZE,
>   "attempting to start the TPM");

I'll get you an TPM1.2 :)

Thanks
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tpmdd-devel] [PATCH v8 6/8] tpm: TPM 2.0 baseline support

2014-12-04 Thread Peter Hüwe
Am Mittwoch, 3. Dezember 2014, 03:28:35 schrieb Stefan Berger:
> On 12/02/2014 05:31 PM, Jarkko Sakkinen wrote:
> > +
> > +/**
> > + * tpm2_startup() - send startup command to the TPM chip
> > + * @chip:  TPM chip to use.
> > + * @startup_type   startup type. The value is either
> > + * TPM_SU_CLEAR or TPM_SU_STATE.
> > + *
> > + * 0 is returned when the operation is successful. If a negative number
> > is + * returned it remarks a POSIX error code. If a positive number is
> > returned + * it remarks a TPM error.
> > + */
> > +int tpm2_startup(struct tpm_chip *chip, __be16 startup_type)
> > +{
> > +   struct tpm2_cmd cmd;
> > +
> > +   cmd.header.in = tpm2_startup_header;
> > +
> > +   cmd.params.startup_in.startup_type = startup_type;
> > +   return tpm_transmit_cmd(chip, , sizeof(cmd),
> > +   "attempting to start the TPM");
> > +}
> 
> I suppose you need to send this command because your firmware does not
> do it ?Following TPM1.2 I guess the BIOS / UEFI should send this instead
> and sending it later would actually be wrong. Hm, I don't find from
> where you are calling this... do you need it ? Can you remove it?
> 
> Stefan

Hi,

I think it would be good to send a TPM2_Startup if the TPM sends a 
TPM_RC_INITIALIZE (0x100) - so it becomes atleast usable.
Of course the BIOS/UEFI/Firmware should send the TPM2_Startup, but if there is 
no such thing, I would prefer Linux to do it, rather than nobody.
(analog: This was done for embedded platforms with TPM1.2).

In the current situation (v9) it is not possible to use the TPM2 on a machine 
without bios integration. :( (so I cannot test here :( )




Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 7/8] tpm: TPM 2.0 CRB Interface

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:17 schrieb Jarkko Sakkinen:
> tpm_crb is a driver for TPM 2.0 Command Response Buffer (CRB) Interface
> as defined in PC Client Platform TPM Profile (PTP) Specification.
> 
> Only polling and single locality is supported as these are the limitations
> of the available hardware, Platform Trust Techonlogy (PTT) in Haswell
> CPUs.
> 
> The driver always applies CRB with ACPI start because PTT reports using
> only ACPI start as start method but as a result of my testing it requires
> also CRB start.
> 
> Signed-off-by: Jarkko Sakkinen 
> ---
>  drivers/char/tpm/Kconfig   |   9 ++
>  drivers/char/tpm/Makefile  |   1 +
>  drivers/char/tpm/tpm_crb.c | 356
> + 3 files changed, 366
> insertions(+)
>  create mode 100644 drivers/char/tpm/tpm_crb.c
> 
> diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
> index 3d0873b..9d4e375 100644
> --- a/drivers/char/tpm/Kconfig
> +++ b/drivers/char/tpm/Kconfig
> @@ -122,4 +122,13 @@ config TCG_XEN
> To compile this driver as a module, choose M here; the module
> will be called xen-tpmfront.
> 
> +config TCG_CRB
> + tristate "TPM 2.0 CRB Interface"
> + depends on X86 && ACPI
> + ---help---
> +   If you have a TPM security chip that is compliant with the
> +   TCG CRB 2.0 TPM specification say Yes and it will be accessible
> +   from within Linux.  To compile this driver as a module, choose
> +   M here; the module will be called tpm_crb.
> +
>  endif # TCG_TPM
> diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
> index 88848ed..990cf18 100644
> --- a/drivers/char/tpm/Makefile
> +++ b/drivers/char/tpm/Makefile
> @@ -22,3 +22,4 @@ obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
>  obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o
>  obj-$(CONFIG_TCG_TIS_I2C_ST33) += tpm_i2c_stm_st33.o
>  obj-$(CONFIG_TCG_XEN) += xen-tpmfront.o
> +obj-$(CONFIG_TCG_CRB) += tpm_crb.o
> diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
> new file mode 100644
> index 000..eb78f93
> --- /dev/null
> +++ b/drivers/char/tpm/tpm_crb.c
> @@ -0,0 +1,356 @@
> +/*
> + * Copyright (C) 2014 Intel Corporation
> + *
> + * Authors:
> + * Jarkko Sakkinen 
> + *
> + * Maintained by: 
> + *
> + * This device driver implements the TPM interface as defined in
> + * the TCG CRB 2.0 TPM specification.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; version 2
> + * of the License.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include "tpm.h"
> +
> +#define ACPI_SIG_TPM2 "TPM2"
> +
> +static const u8 CRB_ACPI_START_UUID[] = {
> + /*  */ 0xAB, 0x6C, 0xBF, 0x6B, 0x63, 0x54, 0x14, 0x47,
> + /* 0008 */ 0xB7, 0xCD, 0xF0, 0x20, 0x3C, 0x03, 0x68, 0xD4
> +};
> +
> +enum crb_defaults {
> + CRB_ACPI_START_REVISION_ID = 1,
> + CRB_ACPI_START_INDEX = 1,
> +};
> +
> +enum crb_start_method {
> + CRB_SM_ACPI_START = 2,
> + CRB_SM_CRB = 7,
> + CRB_SM_CRB_WITH_ACPI_START = 8,
> +};
> +
> +struct acpi_tpm2 {
> + struct acpi_table_header hdr;
> + u16 platform_class;
> + u16 reserved;
> + u64 control_area_pa;
> + u32 start_method;
> +} __packed;
> +
> +enum crb_ca_request {
> + CRB_CA_REQ_GO_IDLE  = BIT(0),
> + CRB_CA_REQ_CMD_READY= BIT(1),
> +};
> +
> +enum crb_ca_status {
> + CRB_CA_STS_ERROR= BIT(0),
> + CRB_CA_STS_TPM_IDLE = BIT(1),
> +};
> +
> +enum crb_start {
> + CRB_START_INVOKE= BIT(0),
> +};
> +
> +enum crb_cancel {
> + CRB_CANCEL_INVOKE   = BIT(0),
> +};
> +
> +struct crb_control_area {
> + u32 req;
> + u32 sts;
> + u32 cancel;
> + u32 start;
> + u32 int_enable;
> + u32 int_sts;
> + u32 cmd_size;
> + u64 cmd_pa;
> + u32 rsp_size;
> + u64 rsp_pa;
> +} __packed;
> +
> +enum crb_status {
> + CRB_STS_COMPLETE= BIT(0),
> +};
> +
> +enum crb_flags {
> + CRB_FL_ACPI_START   = BIT(0),
> + CRB_FL_CRB_START= BIT(1),
> +};
> +
> +struct crb_priv {
> + unsigned int flags;
> + struct crb_control_area *cca;
> + u8 *cmd;
> + u8 *rsp;
> +};
> +
> +#ifdef CONFIG_PM_SLEEP
> +int crb_suspend(struct device *dev)
> +{
> + return 0;
> +}
> +
> +static int crb_resume(struct device *dev)
> +{
> + struct tpm_chip *chip = dev_get_drvdata(dev);
> +
> + (void) tpm2_do_selftest(chip);
 ^ ??? What's this?
> +
> + return 0;
> +}
> +#endif

Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tpmdd-devel] [PATCH v9 8/8] tpm: TPM 2.0 FIFO Interface

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 23:18:33 schrieb Peter Hüwe:
> Hi Jarkko,
> 
> Am Donnerstag, 4. Dezember 2014, 06:55:18 schrieb Jarkko Sakkinen:
> > From: Will Arthur 
> > 
> > Detect TPM 2.0 by using the extended STS (STS3) register. For TPM 2.0,
> > instead of calling tpm_get_timeouts(), assign duration and timeout
> > values defined in the TPM 2.0 PTP specification.
> > 
> > Signed-off-by: Will Arthur 
> > Signed-off-by: Jarkko Sakkinen 
> > ---
> > 
> >  drivers/char/tpm/tpm_tis.c | 80
> > 
> > ++ 1 file changed, 67
> > insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> > index 89e1abb..71cbb2d 100644
> > --- a/drivers/char/tpm/tpm_tis.c
> > +++ b/drivers/char/tpm/tpm_tis.c
> > @@ -1,5 +1,6 @@
> > 
> >  /*
> >  
> >   * Copyright (C) 2005, 2006 IBM Corporation
> > 
> > + * Copyright (C) 2014 Intel Corporation
> > 
> >   *
> >   * Authors:
> >   * Leendert van Doorn 
> > 
> > @@ -44,6 +45,10 @@ enum tis_status {
> > 
> > TPM_STS_DATA_EXPECT = 0x08,
> >  
> >  };
> > 
> > +enum tis_status3 {
> > +   TPM_STS3_TPM2_FAM = 0x04,
> > +};
> > +
> > 
> >  enum tis_int_flags {
> >  
> > TPM_GLOBAL_INT_ENABLE = 0x8000,
> > TPM_INTF_BURST_COUNT_STATIC = 0x100,
> > 
> > @@ -70,6 +75,7 @@ enum tis_defaults {
> > 
> >  #defineTPM_INT_STATUS(l)   (0x0010 | ((l) << 12))
> >  #defineTPM_INTF_CAPS(l)(0x0014 | ((l) << 12))
> >  #defineTPM_STS(l)  (0x0018 | ((l) << 12))
> > 
> > +#defineTPM_STS3(l) (0x001b | ((l) << 12))
> > 
> >  #defineTPM_DATA_FIFO(l)(0x0024 | ((l) << 12))
> >  
> >  #defineTPM_DID_VID(l)  (0x0F00 | ((l) << 12))
> > 
> > @@ -363,6 +369,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip,
> > u8 *buf, size_t len) {
> > 
> > int rc;
> > u32 ordinal;
> > 
> > +   unsigned long dur;
> > 
> > rc = tpm_tis_send_data(chip, buf, len);
> > if (rc < 0)
> > 
> > @@ -374,9 +381,14 @@ static int tpm_tis_send_main(struct tpm_chip *chip,
> > u8 *buf, size_t len)
> > 
> > if (chip->vendor.irq) {
> > 
> > ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
> > 
> > +
> > +   if (chip->flags & TPM_CHIP_FLAG_TPM2)
> > +   dur = tpm2_calc_ordinal_duration(chip, ordinal);
> > +   else
> > +   dur = tpm_calc_ordinal_duration(chip, ordinal);
> > +
> > 
> > if (wait_for_tpm_stat
> > 
> > -   (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
> > -tpm_calc_ordinal_duration(chip, ordinal),
> > +   (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
> > 
> >  >vendor.read_queue, false) < 0) {
> > 
> > rc = -ETIME;
> > goto out_err;
> > 
> > @@ -588,6 +600,7 @@ static int tpm_tis_init(struct device *dev,
> > acpi_handle acpi_dev_handle, int rc, i, irq_s, irq_e, probe;
> > 
> > struct tpm_chip *chip;
> > struct priv_data *priv;
> > 
> > +   u8 sts3;
> > 
> > priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
> > if (priv == NULL)
> > 
> > @@ -604,11 +617,28 @@ static int tpm_tis_init(struct device *dev,
> > acpi_handle acpi_dev_handle, if (!chip->vendor.iobase)
> > 
> > return -EIO;
> > 
> > +   sts3 = ioread8(chip->vendor.iobase + TPM_STS3(1));
> > +   if ((sts3 & TPM_STS3_TPM2_FAM) == TPM_STS3_TPM2_FAM)
> > +   chip->flags = TPM_CHIP_FLAG_TPM2;
> > +
> > 
> > /* Default timeouts */
> > 
> > -   chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> > -   chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
> > -   chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> > -   chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> > +   if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> > +   chip->vendor.timeout_a = usecs_to_jiffies(TPM2_TIMEOUT_A);
> > +   chip->vendor.timeout_b = usecs_to_jiffies(TPM2_TIMEOUT_B);
> > +  

Re: [PATCH v9 8/8] tpm: TPM 2.0 FIFO Interface

2014-12-04 Thread Peter Hüwe
Hi Jarkko,

Am Donnerstag, 4. Dezember 2014, 06:55:18 schrieb Jarkko Sakkinen:
> From: Will Arthur 
> 
> Detect TPM 2.0 by using the extended STS (STS3) register. For TPM 2.0,
> instead of calling tpm_get_timeouts(), assign duration and timeout
> values defined in the TPM 2.0 PTP specification.
> 
> Signed-off-by: Will Arthur 
> Signed-off-by: Jarkko Sakkinen 
> ---
>  drivers/char/tpm/tpm_tis.c | 80
> ++ 1 file changed, 67
> insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 89e1abb..71cbb2d 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -1,5 +1,6 @@
>  /*
>   * Copyright (C) 2005, 2006 IBM Corporation
> + * Copyright (C) 2014 Intel Corporation
>   *
>   * Authors:
>   * Leendert van Doorn 
> @@ -44,6 +45,10 @@ enum tis_status {
>   TPM_STS_DATA_EXPECT = 0x08,
>  };
> 
> +enum tis_status3 {
> + TPM_STS3_TPM2_FAM = 0x04,
> +};
> +
>  enum tis_int_flags {
>   TPM_GLOBAL_INT_ENABLE = 0x8000,
>   TPM_INTF_BURST_COUNT_STATIC = 0x100,
> @@ -70,6 +75,7 @@ enum tis_defaults {
>  #define  TPM_INT_STATUS(l)   (0x0010 | ((l) << 12))
>  #define  TPM_INTF_CAPS(l)(0x0014 | ((l) << 12))
>  #define  TPM_STS(l)  (0x0018 | ((l) << 12))
> +#define  TPM_STS3(l) (0x001b | ((l) << 12))
>  #define  TPM_DATA_FIFO(l)(0x0024 | ((l) << 12))
> 
>  #define  TPM_DID_VID(l)  (0x0F00 | ((l) << 12))
> @@ -363,6 +369,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8
> *buf, size_t len) {
>   int rc;
>   u32 ordinal;
> + unsigned long dur;
> 
>   rc = tpm_tis_send_data(chip, buf, len);
>   if (rc < 0)
> @@ -374,9 +381,14 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8
> *buf, size_t len)
> 
>   if (chip->vendor.irq) {
>   ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
> +
> + if (chip->flags & TPM_CHIP_FLAG_TPM2)
> + dur = tpm2_calc_ordinal_duration(chip, ordinal);
> + else
> + dur = tpm_calc_ordinal_duration(chip, ordinal);
> +
>   if (wait_for_tpm_stat
> - (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
> -  tpm_calc_ordinal_duration(chip, ordinal),
> + (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
>>vendor.read_queue, false) < 0) {
>   rc = -ETIME;
>   goto out_err;
> @@ -588,6 +600,7 @@ static int tpm_tis_init(struct device *dev, acpi_handle
> acpi_dev_handle, int rc, i, irq_s, irq_e, probe;
>   struct tpm_chip *chip;
>   struct priv_data *priv;
> + u8 sts3;
> 
>   priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
>   if (priv == NULL)
> @@ -604,11 +617,28 @@ static int tpm_tis_init(struct device *dev,
> acpi_handle acpi_dev_handle, if (!chip->vendor.iobase)
>   return -EIO;
> 
> + sts3 = ioread8(chip->vendor.iobase + TPM_STS3(1));
> + if ((sts3 & TPM_STS3_TPM2_FAM) == TPM_STS3_TPM2_FAM)
> + chip->flags = TPM_CHIP_FLAG_TPM2;
> +
>   /* Default timeouts */
> - chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> - chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
> - chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> - chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> + if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> + chip->vendor.timeout_a = usecs_to_jiffies(TPM2_TIMEOUT_A);
> + chip->vendor.timeout_b = usecs_to_jiffies(TPM2_TIMEOUT_B);
> + chip->vendor.timeout_c = usecs_to_jiffies(TPM2_TIMEOUT_C);
> + chip->vendor.timeout_d = usecs_to_jiffies(TPM2_TIMEOUT_D);
> + chip->vendor.duration[TPM_SHORT] =
> + usecs_to_jiffies(TPM2_DURATION_SHORT);
> + chip->vendor.duration[TPM_MEDIUM] =
> + usecs_to_jiffies(TPM2_DURATION_MEDIUM);
> + chip->vendor.duration[TPM_LONG] =
> + usecs_to_jiffies(TPM2_DURATION_LONG);
> + } else {
> + chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> + chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
> + chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> + chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> + }
> 
>   if (wait_startup(chip, 0) != 0) {
>   rc = -ENODEV;
> @@ -623,8 +653,8 @@ static int tpm_tis_init(struct device *dev, acpi_handle
> acpi_dev_handle, vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
>   chip->vendor.manufacturer_id = vendor;
> 
> - dev_info(dev,
> -  "1.2 TPM (device-id 0x%X, rev-id %d)\n",
> + dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
> + 

Re: [PATCH v9 8/8] tpm: TPM 2.0 FIFO Interface

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:18 schrieb Jarkko Sakkinen:
> From: Will Arthur 
> 
> Detect TPM 2.0 by using the extended STS (STS3) register. For TPM 2.0,
> instead of calling tpm_get_timeouts(), assign duration and timeout
> values defined in the TPM 2.0 PTP specification.
> 
> Signed-off-by: Will Arthur 
> Signed-off-by: Jarkko Sakkinen 
> ---
Should we change the KConfig string?
 TPM Interface Specification 1.2 Interface
is not quite accurate anymore after applying this patch.

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 4/8] tpm: rename chip->dev to chip->pdev

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:14 schrieb Jarkko Sakkinen:
> Rename chip->dev to chip->pdev to make it explicit that this not the
> character device but actually represents the platform device.
> 
> Signed-off-by: Jarkko Sakkinen 
> ---
>  drivers/char/tpm/tpm-chip.c |  4 ++--
>  drivers/char/tpm/tpm-dev.c  | 10 +-
>  drivers/char/tpm/tpm-interface.c| 29 +++--
>  drivers/char/tpm/tpm-sysfs.c|  6 +++---
>  drivers/char/tpm/tpm.h  |  4 ++--
>  drivers/char/tpm/tpm_atmel.c| 14 +++---
>  drivers/char/tpm/tpm_i2c_atmel.c| 16 
>  drivers/char/tpm/tpm_i2c_infineon.c |  6 +++---
>  drivers/char/tpm/tpm_i2c_nuvoton.c  | 22 +++---
>  drivers/char/tpm/tpm_i2c_stm_st33.c | 14 +++---
>  drivers/char/tpm/tpm_infineon.c | 22 +++---
>  drivers/char/tpm/tpm_nsc.c  | 20 ++--
>  drivers/char/tpm/tpm_ppi.c  |  4 ++--
>  drivers/char/tpm/tpm_tis.c  | 14 +++---
>  14 files changed, 93 insertions(+), 92 deletions(-)
> 
:(

With CONFIG_OF set I get a compile error.

drivers/char/tpm/tpm_i2c_stm_st33.c: In Funktion 
»tpm_stm_i2c_of_request_resources«:
drivers/char/tpm/tpm_i2c_stm_st33.c:649:3: Fehler: Inkompatibler Typ für 
Argument 1 von »dev_err«
In file included from include/linux/pci.h:30:0,
 from drivers/char/tpm/tpm_i2c_stm_st33.c:32:
include/linux/device.h:1044:5: Anmerkung: »const struct device *« erwartet, 
aber Argument hat Typ »struct device«
drivers/char/tpm/tpm_i2c_stm_st33.c:662:3: Fehler: Inkompatibler Typ für 
Argument 1 von »dev_err«
In file included from include/linux/pci.h:30:0,
 from drivers/char/tpm/tpm_i2c_stm_st33.c:32:
include/linux/device.h:1044:5: Anmerkung: »const struct device *« erwartet, 
aber Argument hat Typ »struct device«
scripts/Makefile.build:263: recipe for target 
'drivers/char/tpm/tpm_i2c_stm_st33.o' failed
make[3]: *** [drivers/char/tpm/tpm_i2c_stm_st33.o] Error 1
scripts/Makefile.build:404: recipe for target 'drivers/char/tpm' failed
make[2]: *** [drivers/char/tpm] Error 2
scripts/Makefile.build:404: recipe for target 'drivers/char' failed
make[1]: *** [drivers/char] Error 2
Makefile:929: recipe for target 'drivers' failed
make: *** [drivers] Error 2


Sorry,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 3/8] tpm: fix raciness of PPI interface lookup

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:13 schrieb Jarkko Sakkinen:
> Traversal of the ACPI device tree was not done right. PPI interface
> should be looked up only from the ACPI device that is the platform
> device for the TPM. This could cause problems with systems with
> two TPM chips such as 4th gen Intel systems.
> 
> In addition, added the missing license and copyright platter to
> the tpm_ppi.c.
> 
> Signed-off-by: Jarkko Sakkinen 

:(

> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -580,8 +580,9 @@ static void tpm_tis_remove(struct tpm_chip *chip)
>   release_locality(chip, chip->vendor.locality, 1);
>  }
> 
> -static int tpm_tis_init(struct device *dev, resource_size_t start,
> - resource_size_t len, unsigned int irq)
> +static int tpm_tis_init(struct device *dev, acpi_handle acpi_dev_handle,
> + resource_size_t start, resource_size_t len,
> + unsigned int irq)
>  {
>   u32 vendor, intfcaps, intmask;
>   int rc, i, irq_s, irq_e, probe;
> @@ -597,6 +598,7 @@ static int tpm_tis_init(struct device *dev,
> resource_size_t start, return PTR_ERR(chip);
> 
>   chip->vendor.priv = priv;
> + chip->acpi_dev_handle = acpi_dev_handle;
> 
>   chip->vendor.iobase = devm_ioremap(dev, start, len);
>   if (!chip->vendor.iobase)
> @@ -827,6 +829,7 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
>  {
>   resource_size_t start, len;
>   unsigned int irq = 0;
> + acpi_handle acpi_dev_handle = NULL;
> 
>   start = pnp_mem_start(pnp_dev, 0);
>   len = pnp_mem_len(pnp_dev, 0);
> @@ -839,7 +842,10 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
>   if (is_itpm(pnp_dev))
>   itpm = true;
> 
> - return tpm_tis_init(_dev->dev, start, len, irq);
> + if (pnp_acpi_device(pnp_dev))
> + acpi_dev_handle = pnp_acpi_device(pnp_dev)->handle;
> +
> + return tpm_tis_init(_dev->dev, acpi_dev_handle, start, len, irq);
>  }

With CONFIG_ACPI not set I get a build error :(

  CC [M]  drivers/char/tpm/tpm_tis.o
drivers/char/tpm/tpm_tis.c: In function 'tpm_tis_init':
drivers/char/tpm/tpm_tis.c:614:6: error: 'struct tpm_chip' has no member named 
'acpi_dev_handle'
scripts/Makefile.build:263: recipe for target 'drivers/char/tpm/tpm_tis.o' 
failed
make[3]: *** [drivers/char/tpm/tpm_tis.o] Error 1
scripts/Makefile.build:404: recipe for target 'drivers/char/tpm' failed
make[2]: *** [drivers/char/tpm] Error 2
scripts/Makefile.build:404: recipe for target 'drivers/char' failed
make[1]: *** [drivers/char] Error 2
Makefile:929: recipe for target 'drivers' failed
make: *** [drivers] Error 2


Please fix.
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 7/8] tpm: TPM 2.0 CRB Interface

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:17 schrieb Jarkko Sakkinen:
> tpm_crb is a driver for TPM 2.0 Command Response Buffer (CRB) Interface
> as defined in PC Client Platform TPM Profile (PTP) Specification.
> 
> Only polling and single locality is supported as these are the limitations
> of the available hardware, Platform Trust Techonlogy (PTT) in Haswell
> CPUs.
> 
> The driver always applies CRB with ACPI start because PTT reports using
> only ACPI start as start method but as a result of my testing it requires
> also CRB start.
> 
> Signed-off-by: Jarkko Sakkinen 

:(

 make -C /data/data-old/linux-2.6/ M=$(pwd) modules C=1 CHECK=sparse
make: Entering directory '/data/data-old/linux-2.6'
  CHECK   /data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:99:5: warning: symbol 
'crb_suspend' was not declared. Should it be static?
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:121:14: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:121:14:expected void 
[noderef] *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:121:14:got unsigned int 
*
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:137:13: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:137:13:expected void 
[noderef] *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:137:13:got unsigned int 
*
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:173:19: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:173:19:expected void 
[noderef] *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:173:19:got unsigned int 
*
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:177:34: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:177:34:expected void 
[noderef] *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:177:34:got unsigned int 
*
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:187:63: warning: incorrect 
type in argument 2 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:187:63:expected void 
[noderef] *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:187:63:got unsigned int 
*
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:199:56: warning: incorrect 
type in argument 2 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:199:56:expected void 
[noderef] *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:199:56:got unsigned int 
*
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:207:27: warning: incorrect 
type in argument 2 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:207:27:expected void 
[noderef] *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:207:27:got unsigned int 
*
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:277:22: warning: cast 
removes address space of expression
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:284:33: warning: incorrect 
type in argument 2 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:284:33:expected void 
const volatile [noderef] *src
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:284:33:got unsigned 
long long *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:287:56: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:287:56:expected void 
[noderef] *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:287:56:got unsigned int 
*
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:286:19: warning: incorrect 
type in assignment (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:286:19:expected 
unsigned char [usertype] *cmd
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:286:19:got void 
[noderef] *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:293:33: warning: incorrect 
type in argument 2 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:293:33:expected void 
const volatile [noderef] *src
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:293:33:got unsigned 
long long *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:296:56: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:296:56:expected void 
[noderef] *
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:296:56:got unsigned int 
*
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:295:19: warning: incorrect 
type in assignment (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:295:19:expected 
unsigned char [usertype] *rsp
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:295:19:got void 
[noderef] *

Re: [PATCH v9 7/8] tpm: TPM 2.0 CRB Interface

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:17 schrieb Jarkko Sakkinen:
 tpm_crb is a driver for TPM 2.0 Command Response Buffer (CRB) Interface
 as defined in PC Client Platform TPM Profile (PTP) Specification.
 
 Only polling and single locality is supported as these are the limitations
 of the available hardware, Platform Trust Techonlogy (PTT) in Haswell
 CPUs.
 
 The driver always applies CRB with ACPI start because PTT reports using
 only ACPI start as start method but as a result of my testing it requires
 also CRB start.
 
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com

:(

 make -C /data/data-old/linux-2.6/ M=$(pwd) modules C=1 CHECK=sparse
make: Entering directory '/data/data-old/linux-2.6'
  CHECK   /data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:99:5: warning: symbol 
'crb_suspend' was not declared. Should it be static?
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:121:14: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:121:14:expected void 
[noderef] asn:2*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:121:14:got unsigned int 
*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:137:13: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:137:13:expected void 
[noderef] asn:2*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:137:13:got unsigned int 
*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:173:19: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:173:19:expected void 
[noderef] asn:2*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:173:19:got unsigned int 
*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:177:34: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:177:34:expected void 
[noderef] asn:2*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:177:34:got unsigned int 
*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:187:63: warning: incorrect 
type in argument 2 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:187:63:expected void 
[noderef] asn:2*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:187:63:got unsigned int 
*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:199:56: warning: incorrect 
type in argument 2 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:199:56:expected void 
[noderef] asn:2*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:199:56:got unsigned int 
*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:207:27: warning: incorrect 
type in argument 2 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:207:27:expected void 
[noderef] asn:2*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:207:27:got unsigned int 
*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:277:22: warning: cast 
removes address space of expression
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:284:33: warning: incorrect 
type in argument 2 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:284:33:expected void 
const volatile [noderef] asn:2*src
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:284:33:got unsigned 
long long *noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:287:56: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:287:56:expected void 
[noderef] asn:2*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:287:56:got unsigned int 
*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:286:19: warning: incorrect 
type in assignment (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:286:19:expected 
unsigned char [usertype] *cmd
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:286:19:got void 
[noderef] asn:2*
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:293:33: warning: incorrect 
type in argument 2 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:293:33:expected void 
const volatile [noderef] asn:2*src
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:293:33:got unsigned 
long long *noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:296:56: warning: incorrect 
type in argument 1 (different address spaces)
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:296:56:expected void 
[noderef] asn:2*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:296:56:got unsigned int 
*noident
/data/data-old/linux-2.6/drivers/char/tpm/tpm_crb.c:295:19: warning: incorrect 
type in assignment (different address 

Re: [PATCH v9 3/8] tpm: fix raciness of PPI interface lookup

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:13 schrieb Jarkko Sakkinen:
 Traversal of the ACPI device tree was not done right. PPI interface
 should be looked up only from the ACPI device that is the platform
 device for the TPM. This could cause problems with systems with
 two TPM chips such as 4th gen Intel systems.
 
 In addition, added the missing license and copyright platter to
 the tpm_ppi.c.
 
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com

:(

 --- a/drivers/char/tpm/tpm_tis.c
 +++ b/drivers/char/tpm/tpm_tis.c
 @@ -580,8 +580,9 @@ static void tpm_tis_remove(struct tpm_chip *chip)
   release_locality(chip, chip-vendor.locality, 1);
  }
 
 -static int tpm_tis_init(struct device *dev, resource_size_t start,
 - resource_size_t len, unsigned int irq)
 +static int tpm_tis_init(struct device *dev, acpi_handle acpi_dev_handle,
 + resource_size_t start, resource_size_t len,
 + unsigned int irq)
  {
   u32 vendor, intfcaps, intmask;
   int rc, i, irq_s, irq_e, probe;
 @@ -597,6 +598,7 @@ static int tpm_tis_init(struct device *dev,
 resource_size_t start, return PTR_ERR(chip);
 
   chip-vendor.priv = priv;
 + chip-acpi_dev_handle = acpi_dev_handle;
 
   chip-vendor.iobase = devm_ioremap(dev, start, len);
   if (!chip-vendor.iobase)
 @@ -827,6 +829,7 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
  {
   resource_size_t start, len;
   unsigned int irq = 0;
 + acpi_handle acpi_dev_handle = NULL;
 
   start = pnp_mem_start(pnp_dev, 0);
   len = pnp_mem_len(pnp_dev, 0);
 @@ -839,7 +842,10 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
   if (is_itpm(pnp_dev))
   itpm = true;
 
 - return tpm_tis_init(pnp_dev-dev, start, len, irq);
 + if (pnp_acpi_device(pnp_dev))
 + acpi_dev_handle = pnp_acpi_device(pnp_dev)-handle;
 +
 + return tpm_tis_init(pnp_dev-dev, acpi_dev_handle, start, len, irq);
  }

With CONFIG_ACPI not set I get a build error :(

  CC [M]  drivers/char/tpm/tpm_tis.o
drivers/char/tpm/tpm_tis.c: In function 'tpm_tis_init':
drivers/char/tpm/tpm_tis.c:614:6: error: 'struct tpm_chip' has no member named 
'acpi_dev_handle'
scripts/Makefile.build:263: recipe for target 'drivers/char/tpm/tpm_tis.o' 
failed
make[3]: *** [drivers/char/tpm/tpm_tis.o] Error 1
scripts/Makefile.build:404: recipe for target 'drivers/char/tpm' failed
make[2]: *** [drivers/char/tpm] Error 2
scripts/Makefile.build:404: recipe for target 'drivers/char' failed
make[1]: *** [drivers/char] Error 2
Makefile:929: recipe for target 'drivers' failed
make: *** [drivers] Error 2


Please fix.
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 4/8] tpm: rename chip-dev to chip-pdev

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:14 schrieb Jarkko Sakkinen:
 Rename chip-dev to chip-pdev to make it explicit that this not the
 character device but actually represents the platform device.
 
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com
 ---
  drivers/char/tpm/tpm-chip.c |  4 ++--
  drivers/char/tpm/tpm-dev.c  | 10 +-
  drivers/char/tpm/tpm-interface.c| 29 +++--
  drivers/char/tpm/tpm-sysfs.c|  6 +++---
  drivers/char/tpm/tpm.h  |  4 ++--
  drivers/char/tpm/tpm_atmel.c| 14 +++---
  drivers/char/tpm/tpm_i2c_atmel.c| 16 
  drivers/char/tpm/tpm_i2c_infineon.c |  6 +++---
  drivers/char/tpm/tpm_i2c_nuvoton.c  | 22 +++---
  drivers/char/tpm/tpm_i2c_stm_st33.c | 14 +++---
  drivers/char/tpm/tpm_infineon.c | 22 +++---
  drivers/char/tpm/tpm_nsc.c  | 20 ++--
  drivers/char/tpm/tpm_ppi.c  |  4 ++--
  drivers/char/tpm/tpm_tis.c  | 14 +++---
  14 files changed, 93 insertions(+), 92 deletions(-)
 
:(

With CONFIG_OF set I get a compile error.

drivers/char/tpm/tpm_i2c_stm_st33.c: In Funktion 
»tpm_stm_i2c_of_request_resources«:
drivers/char/tpm/tpm_i2c_stm_st33.c:649:3: Fehler: Inkompatibler Typ für 
Argument 1 von »dev_err«
In file included from include/linux/pci.h:30:0,
 from drivers/char/tpm/tpm_i2c_stm_st33.c:32:
include/linux/device.h:1044:5: Anmerkung: »const struct device *« erwartet, 
aber Argument hat Typ »struct device«
drivers/char/tpm/tpm_i2c_stm_st33.c:662:3: Fehler: Inkompatibler Typ für 
Argument 1 von »dev_err«
In file included from include/linux/pci.h:30:0,
 from drivers/char/tpm/tpm_i2c_stm_st33.c:32:
include/linux/device.h:1044:5: Anmerkung: »const struct device *« erwartet, 
aber Argument hat Typ »struct device«
scripts/Makefile.build:263: recipe for target 
'drivers/char/tpm/tpm_i2c_stm_st33.o' failed
make[3]: *** [drivers/char/tpm/tpm_i2c_stm_st33.o] Error 1
scripts/Makefile.build:404: recipe for target 'drivers/char/tpm' failed
make[2]: *** [drivers/char/tpm] Error 2
scripts/Makefile.build:404: recipe for target 'drivers/char' failed
make[1]: *** [drivers/char] Error 2
Makefile:929: recipe for target 'drivers' failed
make: *** [drivers] Error 2


Sorry,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 8/8] tpm: TPM 2.0 FIFO Interface

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:18 schrieb Jarkko Sakkinen:
 From: Will Arthur will.c.art...@intel.com
 
 Detect TPM 2.0 by using the extended STS (STS3) register. For TPM 2.0,
 instead of calling tpm_get_timeouts(), assign duration and timeout
 values defined in the TPM 2.0 PTP specification.
 
 Signed-off-by: Will Arthur will.c.art...@intel.com
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com
 ---
Should we change the KConfig string?
 TPM Interface Specification 1.2 Interface
is not quite accurate anymore after applying this patch.

Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 8/8] tpm: TPM 2.0 FIFO Interface

2014-12-04 Thread Peter Hüwe
Hi Jarkko,

Am Donnerstag, 4. Dezember 2014, 06:55:18 schrieb Jarkko Sakkinen:
 From: Will Arthur will.c.art...@intel.com
 
 Detect TPM 2.0 by using the extended STS (STS3) register. For TPM 2.0,
 instead of calling tpm_get_timeouts(), assign duration and timeout
 values defined in the TPM 2.0 PTP specification.
 
 Signed-off-by: Will Arthur will.c.art...@intel.com
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com
 ---
  drivers/char/tpm/tpm_tis.c | 80
 ++ 1 file changed, 67
 insertions(+), 13 deletions(-)
 
 diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
 index 89e1abb..71cbb2d 100644
 --- a/drivers/char/tpm/tpm_tis.c
 +++ b/drivers/char/tpm/tpm_tis.c
 @@ -1,5 +1,6 @@
  /*
   * Copyright (C) 2005, 2006 IBM Corporation
 + * Copyright (C) 2014 Intel Corporation
   *
   * Authors:
   * Leendert van Doorn leend...@watson.ibm.com
 @@ -44,6 +45,10 @@ enum tis_status {
   TPM_STS_DATA_EXPECT = 0x08,
  };
 
 +enum tis_status3 {
 + TPM_STS3_TPM2_FAM = 0x04,
 +};
 +
  enum tis_int_flags {
   TPM_GLOBAL_INT_ENABLE = 0x8000,
   TPM_INTF_BURST_COUNT_STATIC = 0x100,
 @@ -70,6 +75,7 @@ enum tis_defaults {
  #define  TPM_INT_STATUS(l)   (0x0010 | ((l)  12))
  #define  TPM_INTF_CAPS(l)(0x0014 | ((l)  12))
  #define  TPM_STS(l)  (0x0018 | ((l)  12))
 +#define  TPM_STS3(l) (0x001b | ((l)  12))
  #define  TPM_DATA_FIFO(l)(0x0024 | ((l)  12))
 
  #define  TPM_DID_VID(l)  (0x0F00 | ((l)  12))
 @@ -363,6 +369,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8
 *buf, size_t len) {
   int rc;
   u32 ordinal;
 + unsigned long dur;
 
   rc = tpm_tis_send_data(chip, buf, len);
   if (rc  0)
 @@ -374,9 +381,14 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8
 *buf, size_t len)
 
   if (chip-vendor.irq) {
   ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
 +
 + if (chip-flags  TPM_CHIP_FLAG_TPM2)
 + dur = tpm2_calc_ordinal_duration(chip, ordinal);
 + else
 + dur = tpm_calc_ordinal_duration(chip, ordinal);
 +
   if (wait_for_tpm_stat
 - (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
 -  tpm_calc_ordinal_duration(chip, ordinal),
 + (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
chip-vendor.read_queue, false)  0) {
   rc = -ETIME;
   goto out_err;
 @@ -588,6 +600,7 @@ static int tpm_tis_init(struct device *dev, acpi_handle
 acpi_dev_handle, int rc, i, irq_s, irq_e, probe;
   struct tpm_chip *chip;
   struct priv_data *priv;
 + u8 sts3;
 
   priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
   if (priv == NULL)
 @@ -604,11 +617,28 @@ static int tpm_tis_init(struct device *dev,
 acpi_handle acpi_dev_handle, if (!chip-vendor.iobase)
   return -EIO;
 
 + sts3 = ioread8(chip-vendor.iobase + TPM_STS3(1));
 + if ((sts3  TPM_STS3_TPM2_FAM) == TPM_STS3_TPM2_FAM)
 + chip-flags = TPM_CHIP_FLAG_TPM2;
 +
   /* Default timeouts */
 - chip-vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
 - chip-vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
 - chip-vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
 - chip-vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
 + if (chip-flags  TPM_CHIP_FLAG_TPM2) {
 + chip-vendor.timeout_a = usecs_to_jiffies(TPM2_TIMEOUT_A);
 + chip-vendor.timeout_b = usecs_to_jiffies(TPM2_TIMEOUT_B);
 + chip-vendor.timeout_c = usecs_to_jiffies(TPM2_TIMEOUT_C);
 + chip-vendor.timeout_d = usecs_to_jiffies(TPM2_TIMEOUT_D);
 + chip-vendor.duration[TPM_SHORT] =
 + usecs_to_jiffies(TPM2_DURATION_SHORT);
 + chip-vendor.duration[TPM_MEDIUM] =
 + usecs_to_jiffies(TPM2_DURATION_MEDIUM);
 + chip-vendor.duration[TPM_LONG] =
 + usecs_to_jiffies(TPM2_DURATION_LONG);
 + } else {
 + chip-vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
 + chip-vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
 + chip-vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
 + chip-vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
 + }
 
   if (wait_startup(chip, 0) != 0) {
   rc = -ENODEV;
 @@ -623,8 +653,8 @@ static int tpm_tis_init(struct device *dev, acpi_handle
 acpi_dev_handle, vendor = ioread32(chip-vendor.iobase + TPM_DID_VID(0));
   chip-vendor.manufacturer_id = vendor;
 
 - dev_info(dev,
 -  1.2 TPM (device-id 0x%X, rev-id %d)\n,
 + dev_info(dev, %s TPM (device-id 0x%X, rev-id %d)\n,
 +  (chip-flags  TPM_CHIP_FLAG_TPM2) ? 2.0 : 

Re: [tpmdd-devel] [PATCH v9 8/8] tpm: TPM 2.0 FIFO Interface

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 23:18:33 schrieb Peter Hüwe:
 Hi Jarkko,
 
 Am Donnerstag, 4. Dezember 2014, 06:55:18 schrieb Jarkko Sakkinen:
  From: Will Arthur will.c.art...@intel.com
  
  Detect TPM 2.0 by using the extended STS (STS3) register. For TPM 2.0,
  instead of calling tpm_get_timeouts(), assign duration and timeout
  values defined in the TPM 2.0 PTP specification.
  
  Signed-off-by: Will Arthur will.c.art...@intel.com
  Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com
  ---
  
   drivers/char/tpm/tpm_tis.c | 80
  
  ++ 1 file changed, 67
  insertions(+), 13 deletions(-)
  
  diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
  index 89e1abb..71cbb2d 100644
  --- a/drivers/char/tpm/tpm_tis.c
  +++ b/drivers/char/tpm/tpm_tis.c
  @@ -1,5 +1,6 @@
  
   /*
   
* Copyright (C) 2005, 2006 IBM Corporation
  
  + * Copyright (C) 2014 Intel Corporation
  
*
* Authors:
* Leendert van Doorn leend...@watson.ibm.com
  
  @@ -44,6 +45,10 @@ enum tis_status {
  
  TPM_STS_DATA_EXPECT = 0x08,
   
   };
  
  +enum tis_status3 {
  +   TPM_STS3_TPM2_FAM = 0x04,
  +};
  +
  
   enum tis_int_flags {
   
  TPM_GLOBAL_INT_ENABLE = 0x8000,
  TPM_INTF_BURST_COUNT_STATIC = 0x100,
  
  @@ -70,6 +75,7 @@ enum tis_defaults {
  
   #defineTPM_INT_STATUS(l)   (0x0010 | ((l)  12))
   #defineTPM_INTF_CAPS(l)(0x0014 | ((l)  12))
   #defineTPM_STS(l)  (0x0018 | ((l)  12))
  
  +#defineTPM_STS3(l) (0x001b | ((l)  12))
  
   #defineTPM_DATA_FIFO(l)(0x0024 | ((l)  12))
   
   #defineTPM_DID_VID(l)  (0x0F00 | ((l)  12))
  
  @@ -363,6 +369,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip,
  u8 *buf, size_t len) {
  
  int rc;
  u32 ordinal;
  
  +   unsigned long dur;
  
  rc = tpm_tis_send_data(chip, buf, len);
  if (rc  0)
  
  @@ -374,9 +381,14 @@ static int tpm_tis_send_main(struct tpm_chip *chip,
  u8 *buf, size_t len)
  
  if (chip-vendor.irq) {
  
  ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
  
  +
  +   if (chip-flags  TPM_CHIP_FLAG_TPM2)
  +   dur = tpm2_calc_ordinal_duration(chip, ordinal);
  +   else
  +   dur = tpm_calc_ordinal_duration(chip, ordinal);
  +
  
  if (wait_for_tpm_stat
  
  -   (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
  -tpm_calc_ordinal_duration(chip, ordinal),
  +   (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
  
   chip-vendor.read_queue, false)  0) {
  
  rc = -ETIME;
  goto out_err;
  
  @@ -588,6 +600,7 @@ static int tpm_tis_init(struct device *dev,
  acpi_handle acpi_dev_handle, int rc, i, irq_s, irq_e, probe;
  
  struct tpm_chip *chip;
  struct priv_data *priv;
  
  +   u8 sts3;
  
  priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
  if (priv == NULL)
  
  @@ -604,11 +617,28 @@ static int tpm_tis_init(struct device *dev,
  acpi_handle acpi_dev_handle, if (!chip-vendor.iobase)
  
  return -EIO;
  
  +   sts3 = ioread8(chip-vendor.iobase + TPM_STS3(1));
  +   if ((sts3  TPM_STS3_TPM2_FAM) == TPM_STS3_TPM2_FAM)
  +   chip-flags = TPM_CHIP_FLAG_TPM2;
  +
  
  /* Default timeouts */
  
  -   chip-vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
  -   chip-vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
  -   chip-vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
  -   chip-vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
  +   if (chip-flags  TPM_CHIP_FLAG_TPM2) {
  +   chip-vendor.timeout_a = usecs_to_jiffies(TPM2_TIMEOUT_A);
  +   chip-vendor.timeout_b = usecs_to_jiffies(TPM2_TIMEOUT_B);
  +   chip-vendor.timeout_c = usecs_to_jiffies(TPM2_TIMEOUT_C);
  +   chip-vendor.timeout_d = usecs_to_jiffies(TPM2_TIMEOUT_D);
  +   chip-vendor.duration[TPM_SHORT] =
  +   usecs_to_jiffies(TPM2_DURATION_SHORT);
  +   chip-vendor.duration[TPM_MEDIUM] =
  +   usecs_to_jiffies(TPM2_DURATION_MEDIUM);
  +   chip-vendor.duration[TPM_LONG] =
  +   usecs_to_jiffies(TPM2_DURATION_LONG);
  +   } else {
  +   chip-vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
  +   chip-vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
  +   chip-vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
  +   chip-vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
  +   }
  
  if (wait_startup(chip, 0) != 0) {
  
  rc = -ENODEV;
  
  @@ -623,8 +653,8 @@ static int tpm_tis_init(struct device *dev,
  acpi_handle acpi_dev_handle, vendor = ioread32(chip-vendor.iobase +
  TPM_DID_VID(0));
  
  chip-vendor.manufacturer_id = vendor

Re: [PATCH v9 7/8] tpm: TPM 2.0 CRB Interface

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:17 schrieb Jarkko Sakkinen:
 tpm_crb is a driver for TPM 2.0 Command Response Buffer (CRB) Interface
 as defined in PC Client Platform TPM Profile (PTP) Specification.
 
 Only polling and single locality is supported as these are the limitations
 of the available hardware, Platform Trust Techonlogy (PTT) in Haswell
 CPUs.
 
 The driver always applies CRB with ACPI start because PTT reports using
 only ACPI start as start method but as a result of my testing it requires
 also CRB start.
 
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com
 ---
  drivers/char/tpm/Kconfig   |   9 ++
  drivers/char/tpm/Makefile  |   1 +
  drivers/char/tpm/tpm_crb.c | 356
 + 3 files changed, 366
 insertions(+)
  create mode 100644 drivers/char/tpm/tpm_crb.c
 
 diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
 index 3d0873b..9d4e375 100644
 --- a/drivers/char/tpm/Kconfig
 +++ b/drivers/char/tpm/Kconfig
 @@ -122,4 +122,13 @@ config TCG_XEN
 To compile this driver as a module, choose M here; the module
 will be called xen-tpmfront.
 
 +config TCG_CRB
 + tristate TPM 2.0 CRB Interface
 + depends on X86  ACPI
 + ---help---
 +   If you have a TPM security chip that is compliant with the
 +   TCG CRB 2.0 TPM specification say Yes and it will be accessible
 +   from within Linux.  To compile this driver as a module, choose
 +   M here; the module will be called tpm_crb.
 +
  endif # TCG_TPM
 diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
 index 88848ed..990cf18 100644
 --- a/drivers/char/tpm/Makefile
 +++ b/drivers/char/tpm/Makefile
 @@ -22,3 +22,4 @@ obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o
  obj-$(CONFIG_TCG_IBMVTPM) += tpm_ibmvtpm.o
  obj-$(CONFIG_TCG_TIS_I2C_ST33) += tpm_i2c_stm_st33.o
  obj-$(CONFIG_TCG_XEN) += xen-tpmfront.o
 +obj-$(CONFIG_TCG_CRB) += tpm_crb.o
 diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
 new file mode 100644
 index 000..eb78f93
 --- /dev/null
 +++ b/drivers/char/tpm/tpm_crb.c
 @@ -0,0 +1,356 @@
 +/*
 + * Copyright (C) 2014 Intel Corporation
 + *
 + * Authors:
 + * Jarkko Sakkinen jarkko.sakki...@linux.intel.com
 + *
 + * Maintained by: tpmdd-de...@lists.sourceforge.net
 + *
 + * This device driver implements the TPM interface as defined in
 + * the TCG CRB 2.0 TPM specification.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; version 2
 + * of the License.
 + */
 +
 +#include linux/acpi.h
 +#include linux/highmem.h
 +#include linux/rculist.h
 +#include linux/module.h
 +#include linux/platform_device.h
 +#include tpm.h
 +
 +#define ACPI_SIG_TPM2 TPM2
 +
 +static const u8 CRB_ACPI_START_UUID[] = {
 + /*  */ 0xAB, 0x6C, 0xBF, 0x6B, 0x63, 0x54, 0x14, 0x47,
 + /* 0008 */ 0xB7, 0xCD, 0xF0, 0x20, 0x3C, 0x03, 0x68, 0xD4
 +};
 +
 +enum crb_defaults {
 + CRB_ACPI_START_REVISION_ID = 1,
 + CRB_ACPI_START_INDEX = 1,
 +};
 +
 +enum crb_start_method {
 + CRB_SM_ACPI_START = 2,
 + CRB_SM_CRB = 7,
 + CRB_SM_CRB_WITH_ACPI_START = 8,
 +};
 +
 +struct acpi_tpm2 {
 + struct acpi_table_header hdr;
 + u16 platform_class;
 + u16 reserved;
 + u64 control_area_pa;
 + u32 start_method;
 +} __packed;
 +
 +enum crb_ca_request {
 + CRB_CA_REQ_GO_IDLE  = BIT(0),
 + CRB_CA_REQ_CMD_READY= BIT(1),
 +};
 +
 +enum crb_ca_status {
 + CRB_CA_STS_ERROR= BIT(0),
 + CRB_CA_STS_TPM_IDLE = BIT(1),
 +};
 +
 +enum crb_start {
 + CRB_START_INVOKE= BIT(0),
 +};
 +
 +enum crb_cancel {
 + CRB_CANCEL_INVOKE   = BIT(0),
 +};
 +
 +struct crb_control_area {
 + u32 req;
 + u32 sts;
 + u32 cancel;
 + u32 start;
 + u32 int_enable;
 + u32 int_sts;
 + u32 cmd_size;
 + u64 cmd_pa;
 + u32 rsp_size;
 + u64 rsp_pa;
 +} __packed;
 +
 +enum crb_status {
 + CRB_STS_COMPLETE= BIT(0),
 +};
 +
 +enum crb_flags {
 + CRB_FL_ACPI_START   = BIT(0),
 + CRB_FL_CRB_START= BIT(1),
 +};
 +
 +struct crb_priv {
 + unsigned int flags;
 + struct crb_control_area *cca;
 + u8 *cmd;
 + u8 *rsp;
 +};
 +
 +#ifdef CONFIG_PM_SLEEP
 +int crb_suspend(struct device *dev)
 +{
 + return 0;
 +}
 +
 +static int crb_resume(struct device *dev)
 +{
 + struct tpm_chip *chip = dev_get_drvdata(dev);
 +
 + (void) tpm2_do_selftest(chip);
 ^ ??? What's this?
 +
 + return 0;
 +}
 +#endif

Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tpmdd-devel] [PATCH v8 6/8] tpm: TPM 2.0 baseline support

2014-12-04 Thread Peter Hüwe
Am Mittwoch, 3. Dezember 2014, 03:28:35 schrieb Stefan Berger:
 On 12/02/2014 05:31 PM, Jarkko Sakkinen wrote:
  +
  +/**
  + * tpm2_startup() - send startup command to the TPM chip
  + * @chip:  TPM chip to use.
  + * @startup_type   startup type. The value is either
  + * TPM_SU_CLEAR or TPM_SU_STATE.
  + *
  + * 0 is returned when the operation is successful. If a negative number
  is + * returned it remarks a POSIX error code. If a positive number is
  returned + * it remarks a TPM error.
  + */
  +int tpm2_startup(struct tpm_chip *chip, __be16 startup_type)
  +{
  +   struct tpm2_cmd cmd;
  +
  +   cmd.header.in = tpm2_startup_header;
  +
  +   cmd.params.startup_in.startup_type = startup_type;
  +   return tpm_transmit_cmd(chip, cmd, sizeof(cmd),
  +   attempting to start the TPM);
  +}
 
 I suppose you need to send this command because your firmware does not
 do it ?Following TPM1.2 I guess the BIOS / UEFI should send this instead
 and sending it later would actually be wrong. Hm, I don't find from
 where you are calling this... do you need it ? Can you remove it?
 
 Stefan

Hi,

I think it would be good to send a TPM2_Startup if the TPM sends a 
TPM_RC_INITIALIZE (0x100) - so it becomes atleast usable.
Of course the BIOS/UEFI/Firmware should send the TPM2_Startup, but if there is 
no such thing, I would prefer Linux to do it, rather than nobody.
(analog: This was done for embedded platforms with TPM1.2).

In the current situation (v9) it is not possible to use the TPM2 on a machine 
without bios integration. :( (so I cannot test here :( )




Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9 6/8] tpm: TPM 2.0 baseline support

2014-12-04 Thread Peter Hüwe
Am Donnerstag, 4. Dezember 2014, 06:55:16 schrieb Jarkko Sakkinen:
 TPM 2.0 devices are separated by adding a field 'flags' to struct
 tpm_chip and defining a flag TPM_CHIP_FLAG_TPM2 for tagging them.
 
 This patch adds the following internal functions:
 
 - tpm2_get_random()
 - tpm2_get_tpm_pt()
 - tpm2_pcr_extend()
 - tpm2_pcr_read()
 - tpm2_startup()
 
 Additionally, the following exported functions are implemented for
 implementing TPM 2.0 device drivers:
 
 - tpm2_do_selftest()
 - tpm2_calc_ordinal_durations()
 - tpm2_gen_interrupt()
 
 The existing functions that are exported for the use for existing
 subsystems have been changed to check the flags field in struct
 tpm_chip and use appropriate TPM 2.0 counterpart if
 TPM_CHIP_FLAG_TPM2 is est.
 
 The code for tpm2_calc_ordinal_duration() and tpm2_startup() were
 originally written by Will Arthur.
 
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com
 Signed-off-by: Will Arthur will.c.art...@intel.com
 ---
  drivers/char/tpm/Makefile|   2 +-
  drivers/char/tpm/tpm-chip.c  |  27 +-
  drivers/char/tpm/tpm-interface.c |  24 +-
  drivers/char/tpm/tpm.h   |  61 +
  drivers/char/tpm/tpm2-cmd.c  | 542
 +++ 5 files changed, 641
 insertions(+), 15 deletions(-)
  create mode 100644 drivers/char/tpm/tpm2-cmd.c
 
 diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile
 index c715596..88848ed 100644
 --- a/drivers/char/tpm/Makefile
 +++ b/drivers/char/tpm/Makefile
 @@ -2,7 +2,7 @@
  # Makefile for the kernel tpm device drivers.
  #
  obj-$(CONFIG_TCG_TPM) += tpm.o
 -tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o tpm-chip.o
 +tpm-y := tpm-interface.o tpm-dev.o tpm-sysfs.o tpm-chip.o tpm2-cmd.o
  tpm-$(CONFIG_ACPI) += tpm_ppi.o
 
  ifdef CONFIG_ACPI
 diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
 index 7741e28..3f3f2de 100644
 --- a/drivers/char/tpm/tpm-chip.c
 +++ b/drivers/char/tpm/tpm-chip.c
 @@ -195,15 +195,18 @@ int tpm_chip_register(struct tpm_chip *chip)
   if (rc)
   return rc;
 
 - rc = tpm_sysfs_add_device(chip);
 - if (rc)
 - goto del_misc;
 + /* Populate sysfs for TPM1 devices. */
 + if (!(chip-flags  TPM_CHIP_FLAG_TPM2)) {
 + rc = tpm_sysfs_add_device(chip);
 + if (rc)
 + goto del_misc;
 
 - rc = tpm_add_ppi(chip);
 - if (rc)
 - goto del_sysfs;
 + rc = tpm_add_ppi(chip);
 + if (rc)
 + goto del_sysfs;
 
 - chip-bios_dir = tpm_bios_log_setup(chip-devname);
 + chip-bios_dir = tpm_bios_log_setup(chip-devname);
 + }
 
   /* Make the chip available. */
   spin_lock(driver_lock);
 @@ -236,10 +239,12 @@ void tpm_chip_unregister(struct tpm_chip *chip)
   spin_unlock(driver_lock);
   synchronize_rcu();
 
 - if (chip-bios_dir)
 - tpm_bios_log_teardown(chip-bios_dir);
 - tpm_remove_ppi(chip);
 - tpm_sysfs_del_device(chip);
 + if (!(chip-flags  TPM_CHIP_FLAG_TPM2)) {
 + if (chip-bios_dir)
 + tpm_bios_log_teardown(chip-bios_dir);
 + tpm_remove_ppi(chip);
 + tpm_sysfs_del_device(chip);
 + }
 
   tpm_dev_del_device(chip);
  }
 diff --git a/drivers/char/tpm/tpm-interface.c
 b/drivers/char/tpm/tpm-interface.c index b6f6b17..8a14887 100644
 --- a/drivers/char/tpm/tpm-interface.c
 +++ b/drivers/char/tpm/tpm-interface.c
 @@ -360,7 +360,10 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char
 *buf, if (chip-vendor.irq)
   goto out_recv;
 
 - stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
 + if (chip-flags  TPM_CHIP_FLAG_TPM2)
 + stop = jiffies + tpm2_calc_ordinal_duration(chip, ordinal);
 + else
 + stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal);
   do {
   u8 status = chip-ops-status(chip);
   if ((status  chip-ops-req_complete_mask) ==
 @@ -483,7 +486,7 @@ static const struct tpm_input_header tpm_startup_header
 = { static int tpm_startup(struct tpm_chip *chip, __be16 startup_type) {
   struct tpm_cmd_t start_cmd;
 - start_cmd.header.in = tpm_startup_header;
 +
WHY?!? This renders tpm_startup useless.

So NACK for this part.
   start_cmd.params.startup_in.startup_type = startup_type;
   return tpm_transmit_cmd(chip, start_cmd, TPM_INTERNAL_RESULT_SIZE,
   attempting to start the TPM);

I'll get you an TPM1.2 :)

Thanks
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tpmdd-devel] [PATCH v8 0/8] TPM 2.0 support

2014-12-02 Thread Peter Hüwe
Am Mittwoch, 3. Dezember 2014, 00:24:43 schrieb Aaro Koskinen:
> Hi,
> 
> On Wed, Dec 03, 2014 at 12:21:07AM +0100, Peter Hüwe wrote:
> > --- a/drivers/char/tpm/tpm_i2c_nuvoton.c
> > +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
> > @@ -605,10 +605,8 @@ static int i2c_nuvoton_probe(struct i2c_client
> > *client,
> > 
> > return -ENODEV;
> > 
> > rc = tpm_chip_register(chip);
> > 
> > -   if (rc)
> > -   return rc;
> > 
> > -   return 0;
> > +   return rc;
> 
> Maybe just return tpm_chip_register(chip)?

Even better.

(I should go to bed now ;)
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tpmdd-devel] [PATCH v8 0/8] TPM 2.0 support

2014-12-02 Thread Peter Hüwe
Am Mittwoch, 3. Dezember 2014, 00:16:19 schrieb Peter Hüwe:
> Am Dienstag, 2. Dezember 2014, 23:31:12 schrieb Jarkko Sakkinen:
> > This patch set enables TPM2 protocol and provides drivers for FIFO and
> > CRB interfaces. This patch set does not export any sysfs attributes for
> > TPM 2.0 because existing sysfs attributes have three non-trivial issues:
> > 
> > - They are associated with the platform device instead of character
> > 
> >   device.
> > 
> > - They are are not trivial key-value pairs but contain text that is
> > 
> >   not easily parsed by a computer.
> > 
> > - Raciness as described in
> > 
> > http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly
> > /
> > 
> > This is too big effort to be included into this patch set and requires
> > more discussion.
> > 
> > v2:
> > - Improved struct tpm_chip life-cycle by taking advantage of devres
> > 
> >   API.
> > 
> > - Refined sysfs attributes as simple key-values thereby not repeating
> > 
> >   mistakes in TPM1 sysfs attributes.
> > 
> > - Documented functions in tpm-chip.c and tpm2-cmd.c.
> > - Documented sysfs attributes.
> > 
> > v3:
> > - Lots of fixes in calling order in device drivers (thanks to Jason
> > 
> >   Gunthorpe for pointing these out!).
> > 
> > - Attach sysfs attributes to the misc device because it represents
> > 
> >   TPM device to the user space.
> > 
> > v4:
> > - Disable sysfs attibutes for TPM 2.0 for until we can sort out the
> > 
> >   best approach for them.
> > 
> > - Fixed all the style issues found with checkpatch.pl.
> > 
> > v5:
> > - missing EXPORT_SYMBOL_GPL()
> > - own class for TPM devices used for TPM 2.0 devices and onwards.
> > 
> > v6:
> > - Non-racy initialization for sysfs attributes using struct device's
> > 
> >   groups field.
> > 
> > - The class 'tpm' is used now for all TPM devices. For the first device
> > 
> >   node major MISC_MAJOR and minor TPM_MINOR is used in order to retain
> >   backwards compatability.
> > 
> > v7:
> > - Release device number and free struct tpm_chip memory inside
> > 
> >   tpm_dev_release callback.
> > 
> > - Moved code from tpm-interface.c and tpm_dev.c to tpm-chip.c.
> > 
> > v8:
> > - Cleaned up unneeded cast from tpm_transmit_cmd().
> > - Cleaned up redundant PPI_VERSION_LEN constant from tpm_ppi.c.
> > - Fixed tpm_tis to use tpm2_calc_ordinal_duration() for TPM2 devices.
> > - tpm_crb: in crb_recv, check that count can hold the TPM header at
> > 
> >   minimum.
> > 
> > - tpm_crb: add enumerations for bit flags in start and cancel fields
> > 
> >   of the control area.
> > 
> > - tpm_crb: use ioremap() for command and response buffer because
> > 
> >   they might be anywhere.
> > 
> > - tpm_crb: use IO access functions for reading ioremapped buffers
> > 
> >   because using direct pointers is not portable.
> > 
> > - tpm_crb: only apply ACPI start if start method reported by the
> > 
> >   TPM2 ACPI table allows it.
> > 
> > - In tpm2_pcr_read() just calculate index and bit and get rid of
> > 
> >   hacky loop.
> > 
> > - Do not add sysfs attributes for TPM 2.0 devices.
> > 
> > Jarkko Sakkinen (7):
> >   tpm: merge duplicate transmit_cmd() functions
> >   tpm: two-phase chip management functions
> >   tpm: fix raciness of PPI interface lookup
> >   tpm: rename chip->dev to chip->pdev
> >   tpm: device class for tpm
> >   tpm: TPM 2.0 baseline support
> >   tpm: TPM 2.0 CRB Interface
> > 
> > Will Arthur (1):
> >   tpm: TPM 2.0 FIFO Interface
> >  
> >  drivers/char/tpm/Kconfig|   9 +
> >  drivers/char/tpm/Makefile   |   3 +-
> >  drivers/char/tpm/tpm-chip.c | 251 
> >  drivers/char/tpm/tpm-dev.c  |  42 +--
> >  drivers/char/tpm/tpm-interface.c| 261 ++--
> >  drivers/char/tpm/tpm-sysfs.c|  29 +-
> >  drivers/char/tpm/tpm.h  | 113 ++-
> >  drivers/char/tpm/tpm2-cmd.c | 571
> > 
> >  drivers/char/tpm/tpm_atmel.c   
> > |
> > 
> >  25 +-
> >  drivers/char/tpm/tpm_crb.c  | 356 ++
> >  drivers/char/tpm/tpm_i2c_atmel.c|  49 ++--
> >  drivers/char/tpm/tpm_i2c_infineon.c |  43 +--
> >  drivers/char/tpm/tpm_i2c_nuvoton.

Re: [PATCH v8 0/8] TPM 2.0 support

2014-12-02 Thread Peter Hüwe
Am Dienstag, 2. Dezember 2014, 23:31:12 schrieb Jarkko Sakkinen:
> This patch set enables TPM2 protocol and provides drivers for FIFO and
> CRB interfaces. This patch set does not export any sysfs attributes for
> TPM 2.0 because existing sysfs attributes have three non-trivial issues:
> 
> - They are associated with the platform device instead of character
>   device.
> - They are are not trivial key-value pairs but contain text that is
>   not easily parsed by a computer.
> - Raciness as described in
>  
> http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/
> 
> This is too big effort to be included into this patch set and requires
> more discussion.
> 
> v2:
> - Improved struct tpm_chip life-cycle by taking advantage of devres
>   API.
> - Refined sysfs attributes as simple key-values thereby not repeating
>   mistakes in TPM1 sysfs attributes.
> - Documented functions in tpm-chip.c and tpm2-cmd.c.
> - Documented sysfs attributes.
> 
> v3:
> - Lots of fixes in calling order in device drivers (thanks to Jason
>   Gunthorpe for pointing these out!).
> - Attach sysfs attributes to the misc device because it represents
>   TPM device to the user space.
> 
> v4:
> - Disable sysfs attibutes for TPM 2.0 for until we can sort out the
>   best approach for them.
> - Fixed all the style issues found with checkpatch.pl.
> 
> v5:
> - missing EXPORT_SYMBOL_GPL()
> - own class for TPM devices used for TPM 2.0 devices and onwards.
> 
> v6:
> - Non-racy initialization for sysfs attributes using struct device's
>   groups field.
> - The class 'tpm' is used now for all TPM devices. For the first device
>   node major MISC_MAJOR and minor TPM_MINOR is used in order to retain
>   backwards compatability.
> 
> v7:
> - Release device number and free struct tpm_chip memory inside
>   tpm_dev_release callback.
> - Moved code from tpm-interface.c and tpm_dev.c to tpm-chip.c.
> 
> v8:
> - Cleaned up unneeded cast from tpm_transmit_cmd().
> - Cleaned up redundant PPI_VERSION_LEN constant from tpm_ppi.c.
> - Fixed tpm_tis to use tpm2_calc_ordinal_duration() for TPM2 devices.
> - tpm_crb: in crb_recv, check that count can hold the TPM header at
>   minimum.
> - tpm_crb: add enumerations for bit flags in start and cancel fields
>   of the control area.
> - tpm_crb: use ioremap() for command and response buffer because
>   they might be anywhere.
> - tpm_crb: use IO access functions for reading ioremapped buffers
>   because using direct pointers is not portable.
> - tpm_crb: only apply ACPI start if start method reported by the
>   TPM2 ACPI table allows it.
> - In tpm2_pcr_read() just calculate index and bit and get rid of
>   hacky loop.
> - Do not add sysfs attributes for TPM 2.0 devices.
> 
> Jarkko Sakkinen (7):
>   tpm: merge duplicate transmit_cmd() functions
>   tpm: two-phase chip management functions
>   tpm: fix raciness of PPI interface lookup
>   tpm: rename chip->dev to chip->pdev
>   tpm: device class for tpm
>   tpm: TPM 2.0 baseline support
>   tpm: TPM 2.0 CRB Interface
> 
> Will Arthur (1):
>   tpm: TPM 2.0 FIFO Interface
> 
>  drivers/char/tpm/Kconfig|   9 +
>  drivers/char/tpm/Makefile   |   3 +-
>  drivers/char/tpm/tpm-chip.c | 251 
>  drivers/char/tpm/tpm-dev.c  |  42 +--
>  drivers/char/tpm/tpm-interface.c| 261 ++--
>  drivers/char/tpm/tpm-sysfs.c|  29 +-
>  drivers/char/tpm/tpm.h  | 113 ++-
>  drivers/char/tpm/tpm2-cmd.c | 571
>  drivers/char/tpm/tpm_atmel.c|
>  25 +-
>  drivers/char/tpm/tpm_crb.c  | 356 ++
>  drivers/char/tpm/tpm_i2c_atmel.c|  49 ++--
>  drivers/char/tpm/tpm_i2c_infineon.c |  43 +--
>  drivers/char/tpm/tpm_i2c_nuvoton.c  |  68 ++---

When applying to linux-v3.18-rc6 I get this new coccinelle warning:
drivers/char/tpm/tpm_i2c_nuvoton.c:607:1-3: WARNING: end returns can be 
simpified


make -C ../../../linux/ M=$(pwd) coccicheck

Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v8 7/8] tpm: TPM 2.0 CRB Interface

2014-12-02 Thread Peter Hüwe
Am Dienstag, 2. Dezember 2014, 23:31:19 schrieb Jarkko Sakkinen:
> tpm_crb is a driver for TPM 2.0 Command Response Buffer (CRB) Interface
> as defined in PC Client Platform TPM Profile (PTP) Specification.
> 
> Only polling and single locality is supported as these are the limitations
> of the available hardware, Platform Trust Techonlogy (PTT) in Haswell
> CPUs.
> 
> The driver always applies CRB with ACPI start because PTT reports using
> only ACPI start as start method but as a result of my testing it requires
> also CRB start.
> 
> Signed-off-by: Jarkko Sakkinen 
> ---

If I apply it on top of security/next or linux-3.18-rc6 I get the following 
compile error:

drivers/char/tpm/tpm_crb.c: In function 'crb_acpi_add':
drivers/char/tpm/tpm_crb.c:271:6: error: too many arguments to function 
'acpi_device_hid'
In file included from include/linux/acpi.h:43:0,
 from drivers/char/tpm/tpm_crb.c:18:
include/acpi/acpi_bus.h:253:13: note: declared here
drivers/char/tpm/tpm_crb.c:271:6: error: too few arguments to function 
'strcmp'
scripts/Makefile.build:263: recipe for target 'drivers/char/tpm/tpm_crb.o' 
failed
make[3]: *** [drivers/char/tpm/tpm_crb.o] Error 1
scripts/Makefile.build:402: recipe for target 'drivers/char/tpm' failed
make[2]: *** [drivers/char/tpm] Error 2
scripts/Makefile.build:402: recipe for target 'drivers/char' failed
make[1]: *** [drivers/char] Error 2
Makefile:937: recipe for target 'drivers' failed


Please compile test your stuff.

;-(
Peter


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v8 0/8] TPM 2.0 support

2014-12-02 Thread Peter Hüwe
Hi Jarkko,


Am Dienstag, 2. Dezember 2014, 23:31:12 schrieb Jarkko Sakkinen:
> This patch set enables TPM2 protocol and provides drivers for FIFO and
> CRB interfaces. This patch set does not export any sysfs attributes for
> TPM 2.0 because existing sysfs attributes have three non-trivial issues:
> 


which tree are you basing your patches against?
Can you use 
https://github.com/PeterHuewe/linux-tpmdd for-james
 please?

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] char: tpm: Add missing error check for devm_kzalloc

2014-12-02 Thread Peter Hüwe
Am Freitag, 19. September 2014, 09:14:39 schrieb Kiran Padwal:
> Currently these driver are missing a check on the return value of
> devm_kzalloc, which would cause a NULL pointer dereference in a OOM
> situation.
> 
> This patch adds a missing check for tpm_i2c_atmel.c and tpm_i2c_nuvoton.c
> 
> Signed-off-by: Kiran Padwal 
Applied to my tree:
https://github.com/PeterHuewe/linux-tpmdd for-james

Will be included in the next pull-request.

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] tpm/tpm_ibmvtpm: Fail in ibmvtpm_get_data if driver_data is bad

2014-12-02 Thread Peter Hüwe
Hi Anton,

is this patchset still needed after Vicky's patch 
"[tpmdd-devel] Fix NULL return in tpm_ibmvtpm_get_desired_dma"
https://patchwork.ozlabs.org/patch/402315/

Ashley raised some concerns.

Since merge window is coming up, a fast reply is appreciated.


Thanks,
Peter

Am Freitag, 19. September 2014, 23:29:42 schrieb Anton Blanchard:
> I'm looking at an oops in tpm_ibmvtpm_get_desired_dma:
> 
>   28: 00 00 20 39 li  r9,0
>   2c: 10 00 01 e8 ld  r0,16(r1)
>   30: 28 00 69 80 lwz r3,40(r9)
> 
> We set r9 to 0 then load r9+40. The problem is actually in
> ibmvtpm_get_data, it can return NULL but the rest of the driver
> never expects it.
> 
> Add a BUG_ON in ibmvtpm_get_data. We still need to identify the root
> cause but at least this makes it obvious what went wrong.
> 
> Cc: sta...@vger.kernel.org
> Signed-off-by: Anton Blanchard 
> ---
> 
> diff --git a/drivers/char/tpm/tpm_ibmvtpm.c
> b/drivers/char/tpm/tpm_ibmvtpm.c index af74c57..0d1eeba 100644
> --- a/drivers/char/tpm/tpm_ibmvtpm.c
> +++ b/drivers/char/tpm/tpm_ibmvtpm.c
> @@ -63,9 +63,9 @@ static int ibmvtpm_send_crq(struct vio_dev *vdev, u64 w1,
> u64 w2) static struct ibmvtpm_dev *ibmvtpm_get_data(const struct device
> *dev) {
>   struct tpm_chip *chip = dev_get_drvdata(dev);
> - if (chip)
> - return (struct ibmvtpm_dev *)TPM_VPRIV(chip);
> - return NULL;
> +
> + BUG_ON(!chip);
> + return (struct ibmvtpm_dev *)TPM_VPRIV(chip);
>  }
> 
>  /**

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] tpm/tpm_ibmvtpm: Fail in ibmvtpm_get_data if driver_data is bad

2014-12-02 Thread Peter Hüwe
Hi,

so shall I apply this patch? or not?

Thanks,
Peter

Am Dienstag, 2. Dezember 2014, 20:22:35 schrieb Ashley Lai:
> > @@ -63,9 +63,9 @@ static int ibmvtpm_send_crq(struct vio_dev *vdev, u64
> > w1, u64 w2) static struct ibmvtpm_dev *ibmvtpm_get_data(const struct
> > device *dev) {
> > 
> > struct tpm_chip *chip = dev_get_drvdata(dev);
> > 
> > -   if (chip)
> > -   return (struct ibmvtpm_dev *)TPM_VPRIV(chip);
> > -   return NULL;
> > +
> > +   BUG_ON(!chip);
> 
> With the recent patch from Vicky, it is possible to have a NULL value for
> chip which will trigger a false positive for BUG_ON(!chip).
> 
> > +   return (struct ibmvtpm_dev *)TPM_VPRIV(chip);
> > }
> > 
> > /**

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] tpm/tpm_ibmvtpm: Fail in ibmvtpm_get_data if driver_data is bad

2014-12-02 Thread Peter Hüwe
Hi,

so shall I apply this patch? or not?

Thanks,
Peter

Am Dienstag, 2. Dezember 2014, 20:22:35 schrieb Ashley Lai:
  @@ -63,9 +63,9 @@ static int ibmvtpm_send_crq(struct vio_dev *vdev, u64
  w1, u64 w2) static struct ibmvtpm_dev *ibmvtpm_get_data(const struct
  device *dev) {
  
  struct tpm_chip *chip = dev_get_drvdata(dev);
  
  -   if (chip)
  -   return (struct ibmvtpm_dev *)TPM_VPRIV(chip);
  -   return NULL;
  +
  +   BUG_ON(!chip);
 
 With the recent patch from Vicky, it is possible to have a NULL value for
 chip which will trigger a false positive for BUG_ON(!chip).
 
  +   return (struct ibmvtpm_dev *)TPM_VPRIV(chip);
  }
  
  /**

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/2] tpm/tpm_ibmvtpm: Fail in ibmvtpm_get_data if driver_data is bad

2014-12-02 Thread Peter Hüwe
Hi Anton,

is this patchset still needed after Vicky's patch 
[tpmdd-devel] Fix NULL return in tpm_ibmvtpm_get_desired_dma
https://patchwork.ozlabs.org/patch/402315/

Ashley raised some concerns.

Since merge window is coming up, a fast reply is appreciated.


Thanks,
Peter

Am Freitag, 19. September 2014, 23:29:42 schrieb Anton Blanchard:
 I'm looking at an oops in tpm_ibmvtpm_get_desired_dma:
 
   28: 00 00 20 39 li  r9,0
   2c: 10 00 01 e8 ld  r0,16(r1)
   30: 28 00 69 80 lwz r3,40(r9)
 
 We set r9 to 0 then load r9+40. The problem is actually in
 ibmvtpm_get_data, it can return NULL but the rest of the driver
 never expects it.
 
 Add a BUG_ON in ibmvtpm_get_data. We still need to identify the root
 cause but at least this makes it obvious what went wrong.
 
 Cc: sta...@vger.kernel.org
 Signed-off-by: Anton Blanchard an...@samba.org
 ---
 
 diff --git a/drivers/char/tpm/tpm_ibmvtpm.c
 b/drivers/char/tpm/tpm_ibmvtpm.c index af74c57..0d1eeba 100644
 --- a/drivers/char/tpm/tpm_ibmvtpm.c
 +++ b/drivers/char/tpm/tpm_ibmvtpm.c
 @@ -63,9 +63,9 @@ static int ibmvtpm_send_crq(struct vio_dev *vdev, u64 w1,
 u64 w2) static struct ibmvtpm_dev *ibmvtpm_get_data(const struct device
 *dev) {
   struct tpm_chip *chip = dev_get_drvdata(dev);
 - if (chip)
 - return (struct ibmvtpm_dev *)TPM_VPRIV(chip);
 - return NULL;
 +
 + BUG_ON(!chip);
 + return (struct ibmvtpm_dev *)TPM_VPRIV(chip);
  }
 
  /**

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] char: tpm: Add missing error check for devm_kzalloc

2014-12-02 Thread Peter Hüwe
Am Freitag, 19. September 2014, 09:14:39 schrieb Kiran Padwal:
 Currently these driver are missing a check on the return value of
 devm_kzalloc, which would cause a NULL pointer dereference in a OOM
 situation.
 
 This patch adds a missing check for tpm_i2c_atmel.c and tpm_i2c_nuvoton.c
 
 Signed-off-by: Kiran Padwal kiran.pad...@smartplayin.com
Applied to my tree:
https://github.com/PeterHuewe/linux-tpmdd for-james

Will be included in the next pull-request.

Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v8 0/8] TPM 2.0 support

2014-12-02 Thread Peter Hüwe
Hi Jarkko,


Am Dienstag, 2. Dezember 2014, 23:31:12 schrieb Jarkko Sakkinen:
 This patch set enables TPM2 protocol and provides drivers for FIFO and
 CRB interfaces. This patch set does not export any sysfs attributes for
 TPM 2.0 because existing sysfs attributes have three non-trivial issues:
 


which tree are you basing your patches against?
Can you use 
https://github.com/PeterHuewe/linux-tpmdd for-james
 please?

Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v8 7/8] tpm: TPM 2.0 CRB Interface

2014-12-02 Thread Peter Hüwe
Am Dienstag, 2. Dezember 2014, 23:31:19 schrieb Jarkko Sakkinen:
 tpm_crb is a driver for TPM 2.0 Command Response Buffer (CRB) Interface
 as defined in PC Client Platform TPM Profile (PTP) Specification.
 
 Only polling and single locality is supported as these are the limitations
 of the available hardware, Platform Trust Techonlogy (PTT) in Haswell
 CPUs.
 
 The driver always applies CRB with ACPI start because PTT reports using
 only ACPI start as start method but as a result of my testing it requires
 also CRB start.
 
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com
 ---

If I apply it on top of security/next or linux-3.18-rc6 I get the following 
compile error:

drivers/char/tpm/tpm_crb.c: In function 'crb_acpi_add':
drivers/char/tpm/tpm_crb.c:271:6: error: too many arguments to function 
'acpi_device_hid'
In file included from include/linux/acpi.h:43:0,
 from drivers/char/tpm/tpm_crb.c:18:
include/acpi/acpi_bus.h:253:13: note: declared here
drivers/char/tpm/tpm_crb.c:271:6: error: too few arguments to function 
'strcmp'
scripts/Makefile.build:263: recipe for target 'drivers/char/tpm/tpm_crb.o' 
failed
make[3]: *** [drivers/char/tpm/tpm_crb.o] Error 1
scripts/Makefile.build:402: recipe for target 'drivers/char/tpm' failed
make[2]: *** [drivers/char/tpm] Error 2
scripts/Makefile.build:402: recipe for target 'drivers/char' failed
make[1]: *** [drivers/char] Error 2
Makefile:937: recipe for target 'drivers' failed


Please compile test your stuff.

;-(
Peter


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v8 0/8] TPM 2.0 support

2014-12-02 Thread Peter Hüwe
Am Dienstag, 2. Dezember 2014, 23:31:12 schrieb Jarkko Sakkinen:
 This patch set enables TPM2 protocol and provides drivers for FIFO and
 CRB interfaces. This patch set does not export any sysfs attributes for
 TPM 2.0 because existing sysfs attributes have three non-trivial issues:
 
 - They are associated with the platform device instead of character
   device.
 - They are are not trivial key-value pairs but contain text that is
   not easily parsed by a computer.
 - Raciness as described in
  
 http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/
 
 This is too big effort to be included into this patch set and requires
 more discussion.
 
 v2:
 - Improved struct tpm_chip life-cycle by taking advantage of devres
   API.
 - Refined sysfs attributes as simple key-values thereby not repeating
   mistakes in TPM1 sysfs attributes.
 - Documented functions in tpm-chip.c and tpm2-cmd.c.
 - Documented sysfs attributes.
 
 v3:
 - Lots of fixes in calling order in device drivers (thanks to Jason
   Gunthorpe for pointing these out!).
 - Attach sysfs attributes to the misc device because it represents
   TPM device to the user space.
 
 v4:
 - Disable sysfs attibutes for TPM 2.0 for until we can sort out the
   best approach for them.
 - Fixed all the style issues found with checkpatch.pl.
 
 v5:
 - missing EXPORT_SYMBOL_GPL()
 - own class for TPM devices used for TPM 2.0 devices and onwards.
 
 v6:
 - Non-racy initialization for sysfs attributes using struct device's
   groups field.
 - The class 'tpm' is used now for all TPM devices. For the first device
   node major MISC_MAJOR and minor TPM_MINOR is used in order to retain
   backwards compatability.
 
 v7:
 - Release device number and free struct tpm_chip memory inside
   tpm_dev_release callback.
 - Moved code from tpm-interface.c and tpm_dev.c to tpm-chip.c.
 
 v8:
 - Cleaned up unneeded cast from tpm_transmit_cmd().
 - Cleaned up redundant PPI_VERSION_LEN constant from tpm_ppi.c.
 - Fixed tpm_tis to use tpm2_calc_ordinal_duration() for TPM2 devices.
 - tpm_crb: in crb_recv, check that count can hold the TPM header at
   minimum.
 - tpm_crb: add enumerations for bit flags in start and cancel fields
   of the control area.
 - tpm_crb: use ioremap() for command and response buffer because
   they might be anywhere.
 - tpm_crb: use IO access functions for reading ioremapped buffers
   because using direct pointers is not portable.
 - tpm_crb: only apply ACPI start if start method reported by the
   TPM2 ACPI table allows it.
 - In tpm2_pcr_read() just calculate index and bit and get rid of
   hacky loop.
 - Do not add sysfs attributes for TPM 2.0 devices.
 
 Jarkko Sakkinen (7):
   tpm: merge duplicate transmit_cmd() functions
   tpm: two-phase chip management functions
   tpm: fix raciness of PPI interface lookup
   tpm: rename chip-dev to chip-pdev
   tpm: device class for tpm
   tpm: TPM 2.0 baseline support
   tpm: TPM 2.0 CRB Interface
 
 Will Arthur (1):
   tpm: TPM 2.0 FIFO Interface
 
  drivers/char/tpm/Kconfig|   9 +
  drivers/char/tpm/Makefile   |   3 +-
  drivers/char/tpm/tpm-chip.c | 251 
  drivers/char/tpm/tpm-dev.c  |  42 +--
  drivers/char/tpm/tpm-interface.c| 261 ++--
  drivers/char/tpm/tpm-sysfs.c|  29 +-
  drivers/char/tpm/tpm.h  | 113 ++-
  drivers/char/tpm/tpm2-cmd.c | 571
  drivers/char/tpm/tpm_atmel.c|
  25 +-
  drivers/char/tpm/tpm_crb.c  | 356 ++
  drivers/char/tpm/tpm_i2c_atmel.c|  49 ++--
  drivers/char/tpm/tpm_i2c_infineon.c |  43 +--
  drivers/char/tpm/tpm_i2c_nuvoton.c  |  68 ++---

When applying to linux-v3.18-rc6 I get this new coccinelle warning:
drivers/char/tpm/tpm_i2c_nuvoton.c:607:1-3: WARNING: end returns can be 
simpified


make -C ../../../linux/ M=$(pwd) coccicheck

Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tpmdd-devel] [PATCH v8 0/8] TPM 2.0 support

2014-12-02 Thread Peter Hüwe
Am Mittwoch, 3. Dezember 2014, 00:16:19 schrieb Peter Hüwe:
 Am Dienstag, 2. Dezember 2014, 23:31:12 schrieb Jarkko Sakkinen:
  This patch set enables TPM2 protocol and provides drivers for FIFO and
  CRB interfaces. This patch set does not export any sysfs attributes for
  TPM 2.0 because existing sysfs attributes have three non-trivial issues:
  
  - They are associated with the platform device instead of character
  
device.
  
  - They are are not trivial key-value pairs but contain text that is
  
not easily parsed by a computer.
  
  - Raciness as described in
  
  http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly
  /
  
  This is too big effort to be included into this patch set and requires
  more discussion.
  
  v2:
  - Improved struct tpm_chip life-cycle by taking advantage of devres
  
API.
  
  - Refined sysfs attributes as simple key-values thereby not repeating
  
mistakes in TPM1 sysfs attributes.
  
  - Documented functions in tpm-chip.c and tpm2-cmd.c.
  - Documented sysfs attributes.
  
  v3:
  - Lots of fixes in calling order in device drivers (thanks to Jason
  
Gunthorpe for pointing these out!).
  
  - Attach sysfs attributes to the misc device because it represents
  
TPM device to the user space.
  
  v4:
  - Disable sysfs attibutes for TPM 2.0 for until we can sort out the
  
best approach for them.
  
  - Fixed all the style issues found with checkpatch.pl.
  
  v5:
  - missing EXPORT_SYMBOL_GPL()
  - own class for TPM devices used for TPM 2.0 devices and onwards.
  
  v6:
  - Non-racy initialization for sysfs attributes using struct device's
  
groups field.
  
  - The class 'tpm' is used now for all TPM devices. For the first device
  
node major MISC_MAJOR and minor TPM_MINOR is used in order to retain
backwards compatability.
  
  v7:
  - Release device number and free struct tpm_chip memory inside
  
tpm_dev_release callback.
  
  - Moved code from tpm-interface.c and tpm_dev.c to tpm-chip.c.
  
  v8:
  - Cleaned up unneeded cast from tpm_transmit_cmd().
  - Cleaned up redundant PPI_VERSION_LEN constant from tpm_ppi.c.
  - Fixed tpm_tis to use tpm2_calc_ordinal_duration() for TPM2 devices.
  - tpm_crb: in crb_recv, check that count can hold the TPM header at
  
minimum.
  
  - tpm_crb: add enumerations for bit flags in start and cancel fields
  
of the control area.
  
  - tpm_crb: use ioremap() for command and response buffer because
  
they might be anywhere.
  
  - tpm_crb: use IO access functions for reading ioremapped buffers
  
because using direct pointers is not portable.
  
  - tpm_crb: only apply ACPI start if start method reported by the
  
TPM2 ACPI table allows it.
  
  - In tpm2_pcr_read() just calculate index and bit and get rid of
  
hacky loop.
  
  - Do not add sysfs attributes for TPM 2.0 devices.
  
  Jarkko Sakkinen (7):
tpm: merge duplicate transmit_cmd() functions
tpm: two-phase chip management functions
tpm: fix raciness of PPI interface lookup
tpm: rename chip-dev to chip-pdev
tpm: device class for tpm
tpm: TPM 2.0 baseline support
tpm: TPM 2.0 CRB Interface
  
  Will Arthur (1):
tpm: TPM 2.0 FIFO Interface
   
   drivers/char/tpm/Kconfig|   9 +
   drivers/char/tpm/Makefile   |   3 +-
   drivers/char/tpm/tpm-chip.c | 251 
   drivers/char/tpm/tpm-dev.c  |  42 +--
   drivers/char/tpm/tpm-interface.c| 261 ++--
   drivers/char/tpm/tpm-sysfs.c|  29 +-
   drivers/char/tpm/tpm.h  | 113 ++-
   drivers/char/tpm/tpm2-cmd.c | 571
  
   drivers/char/tpm/tpm_atmel.c   
  |
  
   25 +-
   drivers/char/tpm/tpm_crb.c  | 356 ++
   drivers/char/tpm/tpm_i2c_atmel.c|  49 ++--
   drivers/char/tpm/tpm_i2c_infineon.c |  43 +--
   drivers/char/tpm/tpm_i2c_nuvoton.c  |  68 ++---
 
 When applying to linux-v3.18-rc6 I get this new coccinelle warning:
 drivers/char/tpm/tpm_i2c_nuvoton.c:607:1-3: WARNING: end returns can be
 simpified
 
 
 make -C ../../../linux/ M=$(pwd) coccicheck
 
Consider folding this patch to remove the warning



From cb1b82859ba98f8573624905d2b3cc8d10f456b2 Mon Sep 17 00:00:00 2001
From: Peter Huewe peterhu...@gmx.de
Date: Wed, 3 Dec 2014 00:18:52 +0100
Subject: [PATCH] tpm:tpm_i2c_nuvoton: simpyl return statements

if !rc evals to false it is 0
- we can return rc in both cases

Signed-off-by: Peter Huewe peterhu...@gmx.de
---
 drivers/char/tpm/tpm_i2c_nuvoton.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c 
b/drivers/char/tpm/tpm_i2c_nuvoton.c
index 14246e2..79f4fef 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -605,10 +605,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
return -ENODEV;
 
rc = tpm_chip_register(chip

Re: [tpmdd-devel] [PATCH v8 0/8] TPM 2.0 support

2014-12-02 Thread Peter Hüwe
Am Mittwoch, 3. Dezember 2014, 00:24:43 schrieb Aaro Koskinen:
 Hi,
 
 On Wed, Dec 03, 2014 at 12:21:07AM +0100, Peter Hüwe wrote:
  --- a/drivers/char/tpm/tpm_i2c_nuvoton.c
  +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
  @@ -605,10 +605,8 @@ static int i2c_nuvoton_probe(struct i2c_client
  *client,
  
  return -ENODEV;
  
  rc = tpm_chip_register(chip);
  
  -   if (rc)
  -   return rc;
  
  -   return 0;
  +   return rc;
 
 Maybe just return tpm_chip_register(chip)?

Even better.

(I should go to bed now ;)
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v10] tpm_tis: verify interrupt during init

2014-11-30 Thread Peter Hüwe
Hi Scot,

Am Montag, 29. September 2014, 19:24:57 schrieb Jason Gunthorpe:
> On Wed, Sep 24, 2014 at 10:41:10PM +, Scot Doyle wrote:
> > Some machines, such as the Acer C720 and Toshiba CB35, have TPMs that do
> > not send IRQs while also having an ACPI TPM entry indicating that they
> > will be sent. These machines freeze on resume while the tpm_tis module
> > waits for an IRQ, eventually timing out.
> > 
> > When in interrupt mode, the tpm_tis module should receive an IRQ during
> > module init. Fall back to polling mode if none is received when expected.
> > 
> > Signed-off-by: Scot Doyle 
> > Tested-by: Michael Mullin 
> 
> Looks good with enable fixed
> 
> Reviewed-By: Jason Gunthorpe 


Applied to my tree:
https://github.com/PeterHuewe/linux-tpmdd for-james

Will be included in the next pull-request.

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] char: tpm: Deletion of unnecessary checks before the function call "tpm_dev_vendor_release"

2014-11-30 Thread Peter Hüwe
Applied to my tree:
https://github.com/PeterHuewe/linux-tpmdd for-james

Will be included in the next pull-request.

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/1] char: tpm: Deletion of unnecessary checks before the function call tpm_dev_vendor_release

2014-11-30 Thread Peter Hüwe
Applied to my tree:
https://github.com/PeterHuewe/linux-tpmdd for-james

Will be included in the next pull-request.

Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v10] tpm_tis: verify interrupt during init

2014-11-30 Thread Peter Hüwe
Hi Scot,

Am Montag, 29. September 2014, 19:24:57 schrieb Jason Gunthorpe:
 On Wed, Sep 24, 2014 at 10:41:10PM +, Scot Doyle wrote:
  Some machines, such as the Acer C720 and Toshiba CB35, have TPMs that do
  not send IRQs while also having an ACPI TPM entry indicating that they
  will be sent. These machines freeze on resume while the tpm_tis module
  waits for an IRQ, eventually timing out.
  
  When in interrupt mode, the tpm_tis module should receive an IRQ during
  module init. Fall back to polling mode if none is received when expected.
  
  Signed-off-by: Scot Doyle lkm...@scotdoyle.com
  Tested-by: Michael Mullin masmul...@gmail.com
 
 Looks good with enable fixed
 
 Reviewed-By: Jason Gunthorpe jguntho...@obsidianresearch.com


Applied to my tree:
https://github.com/PeterHuewe/linux-tpmdd for-james

Will be included in the next pull-request.

Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


.exit.text section in vmlinux ?

2014-10-21 Thread Peter Hüwe
Hi,

as far as I remember everything marked with __exit or __exit_data will only be 
used/called when unloading a module, and gets moved to the .exit.text or 
.exit.data sections.

Why are these sections present in the vmlinux/vmlinux.bin/bzImage and not 
dropped by the linker or at least objdump? 
This code will never be called for everything compiled in - in an allyesconfig 
build these sections account for ~80kb of code.

Is there something I'm missing here, or can we add "--remove-section 
.exit.data --remove-section .exit.text" to the OBJCOPYFLAGS for vmlinux?


Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


.exit.text section in vmlinux ?

2014-10-21 Thread Peter Hüwe
Hi,

as far as I remember everything marked with __exit or __exit_data will only be 
used/called when unloading a module, and gets moved to the .exit.text or 
.exit.data sections.

Why are these sections present in the vmlinux/vmlinux.bin/bzImage and not 
dropped by the linker or at least objdump? 
This code will never be called for everything compiled in - in an allyesconfig 
build these sections account for ~80kb of code.

Is there something I'm missing here, or can we add --remove-section 
.exit.data --remove-section .exit.text to the OBJCOPYFLAGS for vmlinux?


Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tpmdd-devel] [PATCH v1 12/12] tpm: TPM2 sysfs attributes

2014-09-24 Thread Peter Hüwe
Am Mittwoch, 24. September 2014, 19:59:40 schrieb Jason Gunthorpe:
> On Wed, Sep 24, 2014 at 01:34:11PM -0400, Stefan Berger wrote:
> > On 09/24/2014 01:13 PM, Jason Gunthorpe wrote:
> > >On Wed, Sep 24, 2014 at 12:06:02PM +0300, Jarkko Sakkinen wrote:
> > >>+static ssize_t durations_show(struct device *dev, struct
> > >>device_attribute *attr, +   char *buf)
> > >>+{
> > >>+ struct tpm_chip *chip = dev_get_drvdata(dev);
> > >>+
> > >>+ if (chip->vendor.duration[TPM_LONG] == 0)
> > >>+ return 0;
> > >>+
> > >>+ return sprintf(buf, "%d %d %d [%s]\n",
> > >>+jiffies_to_usecs(chip->vendor.duration[TPM_SHORT]),
> > >>+jiffies_to_usecs(chip->vendor.duration[TPM_MEDIUM]),
> > >>+jiffies_to_usecs(chip->vendor.duration[TPM_LONG]),
> > >>+chip->vendor.duration_adjusted
> > >>+? "adjusted" : "original");
> > >>+}
> > >>+static DEVICE_ATTR_RO(durations);
> > >
> > >Seem useless since the durations are constant, drop it?
> > 
> > We show them for TPM 1.2 as well, so I'd keep them fo TPM2.
> 
> The durations are constant and hardwired in the driver for TPM2, and
> the sysfs file format does not follow the one-value-per-file
> rule.
> 
> So it doesn't display anything useful. In TPM2 mode all the timeouts
> are constant and known, so I'd rather see it go away.


If it is more or less a no-op since we have set chip-
>vendor.duration[TPM_SHORT] for other code to work, we can show the values for 
TPM2.0.

However I think we don't need any extra code to show or hide the sysfs files 
for TPM2.0.

Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v1 12/12] tpm: TPM2 sysfs attributes

2014-09-24 Thread Peter Hüwe
Am Mittwoch, 24. September 2014, 22:19:38 schrieb Jason Gunthorpe:
> On Wed, Sep 24, 2014 at 10:02:34PM +0300, Jarkko Sakkinen wrote:
> > > The pcrs file never conformed to the sysfs rules, if TPM2 is getting a
> > > whole new file set, I wouldn't mind seeing it not include the
> > > non-conformant ones. What do you think?
> > 
> > I think that it's better to put extra focus on these sysfs attributes in
> > first patch set because it's user space visible. What's wrong in the
> > current pcrs file?
> 
> Each PCR should be a distinct sysfs file, probably with a
> directory. One Value Per File is the rule.

That would be 24*2 files only for pcrs... 
Documentation/filesystems/sysfs.txt says:

"
Attributes should be ASCII text files, preferably with only one value
per file. It is noted that it may not be efficient to contain only one
value per file, so it is socially acceptable to express an array of
values of the same type. "

So it would be more or less o.k. to have it in one file like we had.


Then however:
"Mixing types, expressing multiple lines of data, and doing fancy
formatting of data is heavily frowned upon. Doing these things may get
you publicly humiliated and your code rewritten without notice."


Do we really need the PCRs as sysfs files?
I know they are handy as a dev, but does any application actually use this 
directly?


Thanks,
Peter



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v1 03/12] tpm: TPM2 support for tpm_pcr_read()

2014-09-24 Thread Peter Hüwe
Am Mittwoch, 24. September 2014, 21:43:23 schrieb Jarkko Sakkinen:
> On Wed, Sep 24, 2014 at 10:53:20AM -0600, Jason Gunthorpe wrote:
> > On Wed, Sep 24, 2014 at 12:05:53PM +0300, Jarkko Sakkinen wrote:
> > > +static struct tpm_input_header tpm2_pcrread_header = {
> > 
> > Missing const - all of these static structures in tpm2-cmds.c are missing
> > the const, please fix them all.
> > 
> > > + .tag = cpu_to_be16(TPM2_ST_NO_SESSIONS),
> > > + .length = cpu_to_be32(TPM2_PCR_READ_IN_SIZE),
> > > + .ordinal = cpu_to_be32(TPM2_CC_PCR_READ)
> > > +};
> > 
> > BTW, I always thought this was a goofy and very expensive way to store
> > 3 values and zero initialize. If you want to do something different in
> > the tpm2-cmds.c that would be great too...
> 
> What do you think about the way trusted module builds messages? It's easier
> to maintain and debug than the approach used in the tpm subsystem.


Can you post an example (e.g. for the command stream above)

Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v1 12/12] tpm: TPM2 sysfs attributes

2014-09-24 Thread Peter Hüwe
Am Mittwoch, 24. September 2014, 19:13:38 schrieb Jason Gunthorpe:
> On Wed, Sep 24, 2014 at 12:06:02PM +0300, Jarkko Sakkinen wrote:
> > Added tpm2-sysfs.c that implements sysfs attributes for a TPM2
> > device.
> 
> You need to document in Documentation every new sysfs that is added.
> 
> The existing ones are not documented :(

For 1.2 - they are.
Documentation/ABI/stable/sysfs-class-tpm
So we also now what our stable sysfs abi is :)



Peter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v1 12/12] tpm: TPM2 sysfs attributes

2014-09-24 Thread Peter Hüwe
Am Mittwoch, 24. September 2014, 19:13:38 schrieb Jason Gunthorpe:
 On Wed, Sep 24, 2014 at 12:06:02PM +0300, Jarkko Sakkinen wrote:
  Added tpm2-sysfs.c that implements sysfs attributes for a TPM2
  device.
 
 You need to document in Documentation every new sysfs that is added.
 
 The existing ones are not documented :(

For 1.2 - they are.
Documentation/ABI/stable/sysfs-class-tpm
So we also now what our stable sysfs abi is :)



Peter

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v1 03/12] tpm: TPM2 support for tpm_pcr_read()

2014-09-24 Thread Peter Hüwe
Am Mittwoch, 24. September 2014, 21:43:23 schrieb Jarkko Sakkinen:
 On Wed, Sep 24, 2014 at 10:53:20AM -0600, Jason Gunthorpe wrote:
  On Wed, Sep 24, 2014 at 12:05:53PM +0300, Jarkko Sakkinen wrote:
   +static struct tpm_input_header tpm2_pcrread_header = {
  
  Missing const - all of these static structures in tpm2-cmds.c are missing
  the const, please fix them all.
  
   + .tag = cpu_to_be16(TPM2_ST_NO_SESSIONS),
   + .length = cpu_to_be32(TPM2_PCR_READ_IN_SIZE),
   + .ordinal = cpu_to_be32(TPM2_CC_PCR_READ)
   +};
  
  BTW, I always thought this was a goofy and very expensive way to store
  3 values and zero initialize. If you want to do something different in
  the tpm2-cmds.c that would be great too...
 
 What do you think about the way trusted module builds messages? It's easier
 to maintain and debug than the approach used in the tpm subsystem.


Can you post an example (e.g. for the command stream above)

Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v1 12/12] tpm: TPM2 sysfs attributes

2014-09-24 Thread Peter Hüwe
Am Mittwoch, 24. September 2014, 22:19:38 schrieb Jason Gunthorpe:
 On Wed, Sep 24, 2014 at 10:02:34PM +0300, Jarkko Sakkinen wrote:
   The pcrs file never conformed to the sysfs rules, if TPM2 is getting a
   whole new file set, I wouldn't mind seeing it not include the
   non-conformant ones. What do you think?
  
  I think that it's better to put extra focus on these sysfs attributes in
  first patch set because it's user space visible. What's wrong in the
  current pcrs file?
 
 Each PCR should be a distinct sysfs file, probably with a
 directory. One Value Per File is the rule.

That would be 24*2 files only for pcrs... 
Documentation/filesystems/sysfs.txt says:


Attributes should be ASCII text files, preferably with only one value
per file. It is noted that it may not be efficient to contain only one
value per file, so it is socially acceptable to express an array of
values of the same type. 

So it would be more or less o.k. to have it in one file like we had.


Then however:
Mixing types, expressing multiple lines of data, and doing fancy
formatting of data is heavily frowned upon. Doing these things may get
you publicly humiliated and your code rewritten without notice.


Do we really need the PCRs as sysfs files?
I know they are handy as a dev, but does any application actually use this 
directly?


Thanks,
Peter



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [tpmdd-devel] [PATCH v1 12/12] tpm: TPM2 sysfs attributes

2014-09-24 Thread Peter Hüwe
Am Mittwoch, 24. September 2014, 19:59:40 schrieb Jason Gunthorpe:
 On Wed, Sep 24, 2014 at 01:34:11PM -0400, Stefan Berger wrote:
  On 09/24/2014 01:13 PM, Jason Gunthorpe wrote:
  On Wed, Sep 24, 2014 at 12:06:02PM +0300, Jarkko Sakkinen wrote:
  +static ssize_t durations_show(struct device *dev, struct
  device_attribute *attr, +   char *buf)
  +{
  + struct tpm_chip *chip = dev_get_drvdata(dev);
  +
  + if (chip-vendor.duration[TPM_LONG] == 0)
  + return 0;
  +
  + return sprintf(buf, %d %d %d [%s]\n,
  +jiffies_to_usecs(chip-vendor.duration[TPM_SHORT]),
  +jiffies_to_usecs(chip-vendor.duration[TPM_MEDIUM]),
  +jiffies_to_usecs(chip-vendor.duration[TPM_LONG]),
  +chip-vendor.duration_adjusted
  +? adjusted : original);
  +}
  +static DEVICE_ATTR_RO(durations);
  
  Seem useless since the durations are constant, drop it?
  
  We show them for TPM 1.2 as well, so I'd keep them fo TPM2.
 
 The durations are constant and hardwired in the driver for TPM2, and
 the sysfs file format does not follow the one-value-per-file
 rule.
 
 So it doesn't display anything useful. In TPM2 mode all the timeouts
 are constant and known, so I'd rather see it go away.


If it is more or less a no-op since we have set chip-
vendor.duration[TPM_SHORT] for other code to work, we can show the values for 
TPM2.0.

However I think we don't need any extra code to show or hide the sysfs files 
for TPM2.0.

Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH v8] tpm_tis: verify interrupt during init

2014-09-22 Thread Peter Hüwe
Am Montag, 22. September 2014, 19:13:38 schrieb Jason Gunthorpe:

> 
> This does look much nicer, lets use this version.
> 
> I think Peter were prefer a new clean patch that superceeds the
> original.
> 
> > +   if (!priv->irq_tested) {
> 
> I think the sleep and check is still needed here, the IRQ delivery
> could race relative to the MMIO read of completion, a sleep is the
> only way we could attempt to synchronize them..
> 

So will there be a v9?

Merge Window is coming up shortly, so I would like to have this sorted out 
soon ;)

Thanks,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC PATCH v8] tpm_tis: verify interrupt during init

2014-09-22 Thread Peter Hüwe
Am Montag, 22. September 2014, 19:13:38 schrieb Jason Gunthorpe:

 
 This does look much nicer, lets use this version.
 
 I think Peter were prefer a new clean patch that superceeds the
 original.
 
  +   if (!priv-irq_tested) {
 
 I think the sleep and check is still needed here, the IRQ delivery
 could race relative to the MMIO read of completion, a sleep is the
 only way we could attempt to synchronize them..
 

So will there be a v9?

Merge Window is coming up shortly, so I would like to have this sorted out 
soon ;)

Thanks,
Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm: merge duplicate transmit_cmd() functions

2014-09-13 Thread Peter Hüwe
Hi


Am Samstag, 13. September 2014, 19:35:33 schrieb Jarkko Sakkinen:
> Replaced transmit_cmd() functions in tpm-interface.c and tpm-sysfs.c
> with a single tpm_transmit_cmd() that can be used in both files.
> 
> This patch is preliminary clean up work for the TPM2 support. This
> function is needed for implementing TPM2 versions of the in-kernel
> TPM utility functions.
> 
> Signed-off-by: Jarkko Sakkinen 

why the renaming?


> 
>  ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
>size_t bufsiz);
Can this be removed then?

> +ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_cmd_t *cmd,
> +  int len, const char *desc);
>  extern int tpm_get_timeouts(struct tpm_chip *);
>  extern void tpm_gen_interrupt(struct tpm_chip *);
>  extern int tpm_do_selftest(struct tpm_chip *);



Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm: merge duplicate transmit_cmd() functions

2014-09-13 Thread Peter Hüwe
Hi


Am Samstag, 13. September 2014, 19:35:33 schrieb Jarkko Sakkinen:
 Replaced transmit_cmd() functions in tpm-interface.c and tpm-sysfs.c
 with a single tpm_transmit_cmd() that can be used in both files.
 
 This patch is preliminary clean up work for the TPM2 support. This
 function is needed for implementing TPM2 versions of the in-kernel
 TPM utility functions.
 
 Signed-off-by: Jarkko Sakkinen jarkko.sakki...@linux.intel.com

why the renaming?


 
  ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
size_t bufsiz);
Can this be removed then?

 +ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_cmd_t *cmd,
 +  int len, const char *desc);
  extern int tpm_get_timeouts(struct tpm_chip *);
  extern void tpm_gen_interrupt(struct tpm_chip *);
  extern int tpm_do_selftest(struct tpm_chip *);



Peter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] [REGRESSION] i2c-acpi: Fix NULL Pointer dereference

2014-09-12 Thread Peter Hüwe
Am Freitag, 12. September 2014, 21:09:47 schrieb Peter Huewe:
> If adapter->dev.parent == NULL there is a NULL pointer dereference in
> acpi_i2c_install_space_handler and acpi_i2c_remove_space_handler.
> 
> This is present since introduction of this code:
> 366047515c6e "i2c: rework kernel config I2C_ACPI" or even
> da3c6647ee08 "I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI"
> 
> The adapter->dev.parent == NULL case is valid for the i2c_stub,
> so loading i2c_stub with ACPI_I2C_OPREGION enabled results in an oops.
> This is also valid at least for i2c_tiny_usb and i2c_robotfuzz_osif.
> 
> Fix by checking whether it is null before calling ACPI_HANDLE.
> 
> Signed-off-by: Peter Huewe 
> ---

Patch against current i2c/master.

For those who care - here's the oops:
# modprobe i2c_stub chip_addr=0x20
# dmesg

[   39.315090] i2c-stub: Virtual chip at 0x20
[   39.315149] BUG: unable to handle kernel NULL pointer dereference at 
0240
[   39.317716] IP: [] acpi_i2c_install_space_handler+0x16/0xb2
[   39.320261] PGD 40db4b067 PUD 40d2bf067 PMD 0 
[   39.322848] Oops:  [#1] PREEMPT SMP 
[   39.325360] Modules linked in: i2c_stub(+) w83627ehf hwmon_vid ipv6 usbhid 
snd_hda_codec_hdmi x86_pkg_temp_thermal snd_hda_codec_realtek coretemp 
snd_hda_codec_generic kvm_intel kvm crc32_pclmul ghash_clmulni_intel 
snd_hda_intel 
snd_hda_controller pcspkr snd_hda_codec i2c_i801 snd_hwdep snd_pcm snd_timer 
snd 
battery tpm_tis tpm
[   39.330770] CPU: 0 PID: 2783 Comm: modprobe Not tainted 
3.17.0-rc4-00131-gd030671 
#151
[   39.333451] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./Z77 
Pro4, 
BIOS P1.70 01/17/2013
[   39.336153] task: 88040e4bd7d0 ti: 88040e60c000 task.ti: 
88040e60c000
[   39.338876] RIP: 0010:[]  [] 
acpi_i2c_install_space_handler+0x16/0xb2
[   39.341657] RSP: 0018:88040e60fca8  EFLAGS: 00010296
[   39.344421] RAX:  RBX: c099db30 RCX: 88040d8def40
[   39.347193] RDX: ffed RSI: 8800bff975e0 RDI: c099db30
[   39.349965] RBP: 88040e60fcc8 R08: 8800bff975e0 R09: 8800bff975e0
[   39.352742] R10: c099db78 R11: 88040b51c028 R12: c099db78
[   39.355510] R13: c099db30 R14:  R15: c099ded0
[   39.358275] FS:  7f638fd52700() GS:88041f20() 
knlGS:
[   39.361008] CS:  0010 DS:  ES:  CR0: 80050033
[   39.363681] CR2: 0240 CR3: 00040dbba000 CR4: 001407f0
[   39.366332] Stack:
[   39.368924]  88040d8def40 c099db30 c099db78 

[   39.371576]  88040e60fcf8 8248e2ee c099db30 
0001
[   39.374216]   82782250 88040e60fd28 
8248e424
[   39.376840] Call Trace:
[   39.379424]  [] i2c_register_adapter+0x1bc/0x299
[   39.382044]  [] i2c_add_adapter+0x59/0x60
[   39.384650]  [] i2c_stub_init+0x1b6/0x1d4 [i2c_stub]
[   39.387277]  [] ? 0xc09a
[   39.389896]  [] ? 0xc09a
[   39.392504]  [] do_one_initcall+0xea/0x184
[   39.395128]  [] ? vfree+0x74/0x7b
[   39.397763]  [] load_module+0x1b0f/0x1e11
[   39.397768]  [] ? module_unload_free+0xd2/0xd2
[   39.397773]  [] SyS_finit_module+0x56/0x6c
[   39.397779]  [] tracesys+0xdd/0xe2
[   39.397822] Code: 48 c7 c6 37 37 70 82 31 c0 e8 56 66 f5 ff 48 83 c4 18 5b 
5d c3 
55 ba ed ff ff ff 48 89 e5 41 55 49 89 fd 41 54 53 51 48 8b 47 48 <48> 8b 80 40 
02 00 
00 48 85 c0 0f 84 82 00 00 00 4c 8b 60 08 4d 
[   39.397827] RIP  [] 
acpi_i2c_install_space_handler+0x16/0xb2
[   39.397828]  RSP 
[   39.397829] CR2: 0240
[   39.397863] ---[ end trace 9f55e6ce67fb ]---

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] [REGRESSION] i2c-acpi: Fix NULL Pointer dereference

2014-09-12 Thread Peter Hüwe
Am Freitag, 12. September 2014, 21:09:47 schrieb Peter Huewe:
 If adapter-dev.parent == NULL there is a NULL pointer dereference in
 acpi_i2c_install_space_handler and acpi_i2c_remove_space_handler.
 
 This is present since introduction of this code:
 366047515c6e i2c: rework kernel config I2C_ACPI or even
 da3c6647ee08 I2C/ACPI: Clean up I2C ACPI code and Add CONFIG_I2C_ACPI
 
 The adapter-dev.parent == NULL case is valid for the i2c_stub,
 so loading i2c_stub with ACPI_I2C_OPREGION enabled results in an oops.
 This is also valid at least for i2c_tiny_usb and i2c_robotfuzz_osif.
 
 Fix by checking whether it is null before calling ACPI_HANDLE.
 
 Signed-off-by: Peter Huewe peterhu...@gmx.de
 ---

Patch against current i2c/master.

For those who care - here's the oops:
# modprobe i2c_stub chip_addr=0x20
# dmesg

[   39.315090] i2c-stub: Virtual chip at 0x20
[   39.315149] BUG: unable to handle kernel NULL pointer dereference at 
0240
[   39.317716] IP: [8248ed65] acpi_i2c_install_space_handler+0x16/0xb2
[   39.320261] PGD 40db4b067 PUD 40d2bf067 PMD 0 
[   39.322848] Oops:  [#1] PREEMPT SMP 
[   39.325360] Modules linked in: i2c_stub(+) w83627ehf hwmon_vid ipv6 usbhid 
snd_hda_codec_hdmi x86_pkg_temp_thermal snd_hda_codec_realtek coretemp 
snd_hda_codec_generic kvm_intel kvm crc32_pclmul ghash_clmulni_intel 
snd_hda_intel 
snd_hda_controller pcspkr snd_hda_codec i2c_i801 snd_hwdep snd_pcm snd_timer 
snd 
battery tpm_tis tpm
[   39.330770] CPU: 0 PID: 2783 Comm: modprobe Not tainted 
3.17.0-rc4-00131-gd030671 
#151
[   39.333451] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./Z77 
Pro4, 
BIOS P1.70 01/17/2013
[   39.336153] task: 88040e4bd7d0 ti: 88040e60c000 task.ti: 
88040e60c000
[   39.338876] RIP: 0010:[8248ed65]  [8248ed65] 
acpi_i2c_install_space_handler+0x16/0xb2
[   39.341657] RSP: 0018:88040e60fca8  EFLAGS: 00010296
[   39.344421] RAX:  RBX: c099db30 RCX: 88040d8def40
[   39.347193] RDX: ffed RSI: 8800bff975e0 RDI: c099db30
[   39.349965] RBP: 88040e60fcc8 R08: 8800bff975e0 R09: 8800bff975e0
[   39.352742] R10: c099db78 R11: 88040b51c028 R12: c099db78
[   39.355510] R13: c099db30 R14:  R15: c099ded0
[   39.358275] FS:  7f638fd52700() GS:88041f20() 
knlGS:
[   39.361008] CS:  0010 DS:  ES:  CR0: 80050033
[   39.363681] CR2: 0240 CR3: 00040dbba000 CR4: 001407f0
[   39.366332] Stack:
[   39.368924]  88040d8def40 c099db30 c099db78 

[   39.371576]  88040e60fcf8 8248e2ee c099db30 
0001
[   39.374216]   82782250 88040e60fd28 
8248e424
[   39.376840] Call Trace:
[   39.379424]  [8248e2ee] i2c_register_adapter+0x1bc/0x299
[   39.382044]  [8248e424] i2c_add_adapter+0x59/0x60
[   39.384650]  [c09a01b6] i2c_stub_init+0x1b6/0x1d4 [i2c_stub]
[   39.387277]  [c09a] ? 0xc09a
[   39.389896]  [c09a] ? 0xc09a
[   39.392504]  [8200030e] do_one_initcall+0xea/0x184
[   39.395128]  [82172a63] ? vfree+0x74/0x7b
[   39.397763]  [82109550] load_module+0x1b0f/0x1e11
[   39.397768]  [82106d13] ? module_unload_free+0xd2/0xd2
[   39.397773]  [82109943] SyS_finit_module+0x56/0x6c
[   39.397779]  [8255fdcb] tracesys+0xdd/0xe2
[   39.397822] Code: 48 c7 c6 37 37 70 82 31 c0 e8 56 66 f5 ff 48 83 c4 18 5b 
5d c3 
55 ba ed ff ff ff 48 89 e5 41 55 49 89 fd 41 54 53 51 48 8b 47 48 48 8b 80 40 
02 00 
00 48 85 c0 0f 84 82 00 00 00 4c 8b 60 08 4d 
[   39.397827] RIP  [8248ed65] 
acpi_i2c_install_space_handler+0x16/0xb2
[   39.397828]  RSP 88040e60fca8
[   39.397829] CR2: 0240
[   39.397863] ---[ end trace 9f55e6ce67fb ]---

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm: fix interrupt timeouts

2014-09-09 Thread Peter Hüwe
Hi Scot,
Am Montag, 25. August 2014, 09:14:03 schrieb Scot Doyle:
> commit 4c663cfc523a88d97a8309b04a089c27dc57fd7e
> wait: fix false timeouts when using wait_event_timeout()
> 
> changed the semantics of wait_event_interruptible_timeout so that a
> condition check is performed after timeout and 1 is returned if true.

is this one still valid or superseeded by one of the other patches?

Thanks,
Peter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm: fix interrupt timeouts

2014-09-09 Thread Peter Hüwe
Hi Scot,
Am Montag, 25. August 2014, 09:14:03 schrieb Scot Doyle:
 commit 4c663cfc523a88d97a8309b04a089c27dc57fd7e
 wait: fix false timeouts when using wait_event_timeout()
 
 changed the semantics of wait_event_interruptible_timeout so that a
 condition check is performed after timeout and 1 is returned if true.

is this one still valid or superseeded by one of the other patches?

Thanks,
Peter

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm_tis: Verify ACPI-specified interrupt

2014-08-22 Thread Peter Hüwe
CC: Luigi, he works at Google and is responsible for the TPMs in 
Chromebooks ;)

Thanks,
Peter

Am Freitag, 22. August 2014, 22:32:41 schrieb Jason Gunthorpe:
> On Fri, Aug 22, 2014 at 08:17:27PM +, Scot Doyle wrote:
> > On Fri, 22 Aug 2014, Jason Gunthorpe wrote:
> > > On Fri, Aug 22, 2014 at 12:58:41AM +, Scot Doyle wrote:
> > >> Some machines, such as the Acer C720 and Toshiba CB35, have 
TPMs
> > >> that do not use interrupts while also having an ACPI TPM 
entry
> > > 
> > > How do these machines work in Windows?
> > 
> > I don't know. Since they're Chromebooks (booted in legacy mode 
running
> > SeaBIOS instead of depthcharge or whatever ChromeOS uses), I 
think
> > they're mostly used to run Linux.
> 
> I remain somewhat confused - there have already been TPM patches 
for
> Chromebooks from Google - presumably the TPM actually does work
> fine. Make sure you are using a Linux with the ATMEL timeout fix, 
that
> is particularly applicable to Chromebooks IIRC.
> 
> And again, the driver uses interrupts when booting, so I'm 
somewhat
> confused what the problem is. I wouldn't think the driver would
> successfully attach if interrupts were enabled but the interrupt
> didn't work? Can you elaborate on what is going on during boot 
with
> the interrupt, and the boot time GET_DURATIONS and TPM_STARTUP
> sequences?
> 
> Perhaps the driver is timing out all commands and going ahead and
> attaching anyhow? If this is the case I think we'd get a good 
result
> if we just fixed that and had the driver simply not attach. Then 
your
> resume will not be broken.
> 
> > > I'd be more comfortable with some kind of ACPI black list or 
patch or
> > > something? What is normal for handling broken ACPI?
> > 
> > I would be more comfortable with this general approach as well. 
However,
> > I've had to submit several patches for individual Chromebooks 
related to
> > backlight control since the VBT also is misconfigured. Would it 
be
> > possible to find a blacklist mechanism that didn't require 
identifying
> > each Chromebook separately, since they seem to have this issue 
on an
> > ongoing basis?
> 
> So, if you are booting the Chromebook in some weird way, is this 
a
> problem that can be addressed by patching SeaBIOS instead of the
> kernel? The internet says the SeaBIOS payload is replaceable on 
the
> Chromebook.
> 
> Can it fix the ACPI tables to be correct before lauching Linux?
> 
> > A more general approach might be to verify the ACPI interrupt 
for
> > systems matching the first three identifiers.
> 
> Testing the interrupt and failing driver attach if it doesn't 
work
> seems very reasonable to me, I would view that as a bug fix in 
the driver.
> 
> Jason

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] tpm_tis: Verify ACPI-specified interrupt

2014-08-22 Thread Peter Hüwe
CC: Luigi, he works at Google and is responsible for the TPMs in 
Chromebooks ;)

Thanks,
Peter

Am Freitag, 22. August 2014, 22:32:41 schrieb Jason Gunthorpe:
 On Fri, Aug 22, 2014 at 08:17:27PM +, Scot Doyle wrote:
  On Fri, 22 Aug 2014, Jason Gunthorpe wrote:
   On Fri, Aug 22, 2014 at 12:58:41AM +, Scot Doyle wrote:
   Some machines, such as the Acer C720 and Toshiba CB35, have 
TPMs
   that do not use interrupts while also having an ACPI TPM 
entry
   
   How do these machines work in Windows?
  
  I don't know. Since they're Chromebooks (booted in legacy mode 
running
  SeaBIOS instead of depthcharge or whatever ChromeOS uses), I 
think
  they're mostly used to run Linux.
 
 I remain somewhat confused - there have already been TPM patches 
for
 Chromebooks from Google - presumably the TPM actually does work
 fine. Make sure you are using a Linux with the ATMEL timeout fix, 
that
 is particularly applicable to Chromebooks IIRC.
 
 And again, the driver uses interrupts when booting, so I'm 
somewhat
 confused what the problem is. I wouldn't think the driver would
 successfully attach if interrupts were enabled but the interrupt
 didn't work? Can you elaborate on what is going on during boot 
with
 the interrupt, and the boot time GET_DURATIONS and TPM_STARTUP
 sequences?
 
 Perhaps the driver is timing out all commands and going ahead and
 attaching anyhow? If this is the case I think we'd get a good 
result
 if we just fixed that and had the driver simply not attach. Then 
your
 resume will not be broken.
 
   I'd be more comfortable with some kind of ACPI black list or 
patch or
   something? What is normal for handling broken ACPI?
  
  I would be more comfortable with this general approach as well. 
However,
  I've had to submit several patches for individual Chromebooks 
related to
  backlight control since the VBT also is misconfigured. Would it 
be
  possible to find a blacklist mechanism that didn't require 
identifying
  each Chromebook separately, since they seem to have this issue 
on an
  ongoing basis?
 
 So, if you are booting the Chromebook in some weird way, is this 
a
 problem that can be addressed by patching SeaBIOS instead of the
 kernel? The internet says the SeaBIOS payload is replaceable on 
the
 Chromebook.
 
 Can it fix the ACPI tables to be correct before lauching Linux?
 
  A more general approach might be to verify the ACPI interrupt 
for
  systems matching the first three identifiers.
 
 Testing the interrupt and failing driver attach if it doesn't 
work
 seems very reasonable to me, I would view that as a bug fix in 
the driver.
 
 Jason

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   >