Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations | Functions
tpm.c File Reference
#include <linux/poll.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/freezer.h>
#include "tpm.h"
#include "tpm_eventlog.h"

Go to the source code of this file.

Macros

#define TPM_MAX_ORDINAL   243
 
#define TPM_MAX_PROTECTED_ORDINAL   12
 
#define TPM_PROTECTED_ORDINAL_MASK   0xFF
 
#define TPM_DIGEST_SIZE   20
 
#define TPM_RET_CODE_IDX   6
 
#define TPM_INTERNAL_RESULT_SIZE   200
 
#define TPM_TAG_RQU_COMMAND   cpu_to_be16(193)
 
#define TPM_ORD_GET_CAP   cpu_to_be32(101)
 
#define TPM_ORD_GET_RANDOM   cpu_to_be32(70)
 
#define TPM_ORD_CONTINUE_SELFTEST   83
 
#define CONTINUE_SELFTEST_RESULT_SIZE   10
 
#define TPM_ORDINAL_PCRREAD   cpu_to_be32(21)
 
#define READ_PCR_RESULT_SIZE   30
 
#define TPM_ORD_PCR_EXTEND   cpu_to_be32(20)
 
#define EXTEND_PCR_RESULT_SIZE   34
 
#define READ_PUBEK_RESULT_SIZE   314
 
#define TPM_ORD_READPUBEK   cpu_to_be32(124)
 
#define TPM_ORD_SAVESTATE   cpu_to_be32(152)
 
#define SAVESTATE_RESULT_SIZE   10
 
#define TPM_GETRANDOM_RESULT_SIZE   18
 
#define DEVNAME_SIZE   7
 

Enumerations

enum  tpm_duration { TPM_SHORT = 0, TPM_MEDIUM = 1, TPM_LONG = 2, TPM_UNDEFINED }
 
enum  tpm_capabilities { TPM_CAP_FLAG = cpu_to_be32(4), TPM_CAP_PROP = cpu_to_be32(5), CAP_VERSION_1_1 = cpu_to_be32(0x06), CAP_VERSION_1_2 = cpu_to_be32(0x1A) }
 
enum  tpm_sub_capabilities {
  TPM_CAP_PROP_PCR = cpu_to_be32(0x101), TPM_CAP_PROP_MANUFACTURER = cpu_to_be32(0x103), TPM_CAP_FLAG_PERM = cpu_to_be32(0x108), TPM_CAP_FLAG_VOL = cpu_to_be32(0x109),
  TPM_CAP_PROP_OWNER = cpu_to_be32(0x111), TPM_CAP_PROP_TIS_TIMEOUT = cpu_to_be32(0x115), TPM_CAP_PROP_TIS_DURATION = cpu_to_be32(0x120)
}
 

Functions

 module_param_named (suspend_pcr, tpm_suspend_pcr, uint, 0644)
 
 MODULE_PARM_DESC (suspend_pcr,"PCR to use for dummy writes to faciltate flush on suspend.")
 
unsigned long tpm_calc_ordinal_duration (struct tpm_chip *chip, u32 ordinal)
 
 EXPORT_SYMBOL_GPL (tpm_calc_ordinal_duration)
 
ssize_t tpm_getcap (struct device *dev, __be32 subcap_id, cap_t *cap, const char *desc)
 
void tpm_gen_interrupt (struct tpm_chip *chip)
 
 EXPORT_SYMBOL_GPL (tpm_gen_interrupt)
 
int tpm_get_timeouts (struct tpm_chip *chip)
 
 EXPORT_SYMBOL_GPL (tpm_get_timeouts)
 
ssize_t tpm_show_enabled (struct device *dev, struct device_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (tpm_show_enabled)
 
ssize_t tpm_show_active (struct device *dev, struct device_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (tpm_show_active)
 
ssize_t tpm_show_owned (struct device *dev, struct device_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (tpm_show_owned)
 
ssize_t tpm_show_temp_deactivated (struct device *dev, struct device_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (tpm_show_temp_deactivated)
 
int tpm_pcr_read (u32 chip_num, int pcr_idx, u8 *res_buf)
 
 EXPORT_SYMBOL_GPL (tpm_pcr_read)
 
int tpm_pcr_extend (u32 chip_num, int pcr_idx, const u8 *hash)
 
 EXPORT_SYMBOL_GPL (tpm_pcr_extend)
 
int tpm_do_selftest (struct tpm_chip *chip)
 
 EXPORT_SYMBOL_GPL (tpm_do_selftest)
 
int tpm_send (u32 chip_num, void *cmd, size_t buflen)
 
 EXPORT_SYMBOL_GPL (tpm_send)
 
ssize_t tpm_show_pcrs (struct device *dev, struct device_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (tpm_show_pcrs)
 
ssize_t tpm_show_pubek (struct device *dev, struct device_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (tpm_show_pubek)
 
ssize_t tpm_show_caps (struct device *dev, struct device_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (tpm_show_caps)
 
ssize_t tpm_show_caps_1_2 (struct device *dev, struct device_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (tpm_show_caps_1_2)
 
ssize_t tpm_show_durations (struct device *dev, struct device_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (tpm_show_durations)
 
ssize_t tpm_show_timeouts (struct device *dev, struct device_attribute *attr, char *buf)
 
 EXPORT_SYMBOL_GPL (tpm_show_timeouts)
 
ssize_t tpm_store_cancel (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 
 EXPORT_SYMBOL_GPL (tpm_store_cancel)
 
int wait_for_tpm_stat (struct tpm_chip *chip, u8 mask, unsigned long timeout, wait_queue_head_t *queue)
 
 EXPORT_SYMBOL_GPL (wait_for_tpm_stat)
 
int tpm_open (struct inode *inode, struct file *file)
 
 EXPORT_SYMBOL_GPL (tpm_open)
 
int tpm_release (struct inode *inode, struct file *file)
 
 EXPORT_SYMBOL_GPL (tpm_release)
 
ssize_t tpm_write (struct file *file, const char __user *buf, size_t size, loff_t *off)
 
 EXPORT_SYMBOL_GPL (tpm_write)
 
ssize_t tpm_read (struct file *file, char __user *buf, size_t size, loff_t *off)
 
 EXPORT_SYMBOL_GPL (tpm_read)
 
void tpm_remove_hardware (struct device *dev)
 
 EXPORT_SYMBOL_GPL (tpm_remove_hardware)
 
int tpm_pm_suspend (struct device *dev)
 
 EXPORT_SYMBOL_GPL (tpm_pm_suspend)
 
int tpm_pm_resume (struct device *dev)
 
 EXPORT_SYMBOL_GPL (tpm_pm_resume)
 
int tpm_get_random (u32 chip_num, u8 *out, size_t max)
 
 EXPORT_SYMBOL_GPL (tpm_get_random)
 
void tpm_dev_vendor_release (struct tpm_chip *chip)
 
 EXPORT_SYMBOL_GPL (tpm_dev_vendor_release)
 
 EXPORT_SYMBOL_GPL (tpm_dev_release)
 
struct tpm_chiptpm_register_hardware (struct device *dev, const struct tpm_vendor_specific *entry)
 
 EXPORT_SYMBOL_GPL (tpm_register_hardware)
 
 MODULE_AUTHOR ("Leendert van Doorn ([email protected])")
 
 MODULE_DESCRIPTION ("TPM Driver")
 
 MODULE_VERSION ("2.0")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define CONTINUE_SELFTEST_RESULT_SIZE   10

Definition at line 616 of file tpm.c.

#define DEVNAME_SIZE   7
#define EXTEND_PCR_RESULT_SIZE   34

Definition at line 787 of file tpm.c.

#define READ_PCR_RESULT_SIZE   30

Definition at line 728 of file tpm.c.

#define READ_PUBEK_RESULT_SIZE   314

Definition at line 916 of file tpm.c.

#define SAVESTATE_RESULT_SIZE   10

Definition at line 1278 of file tpm.c.

#define TPM_DIGEST_SIZE   20

Definition at line 438 of file tpm.c.

#define TPM_GETRANDOM_RESULT_SIZE   18

Definition at line 1334 of file tpm.c.

#define TPM_INTERNAL_RESULT_SIZE   200

Definition at line 477 of file tpm.c.

#define TPM_MAX_ORDINAL   243

Definition at line 42 of file tpm.c.

#define TPM_MAX_PROTECTED_ORDINAL   12

Definition at line 43 of file tpm.c.

#define TPM_ORD_CONTINUE_SELFTEST   83

Definition at line 615 of file tpm.c.

#define TPM_ORD_GET_CAP   cpu_to_be32(101)

Definition at line 479 of file tpm.c.

#define TPM_ORD_GET_RANDOM   cpu_to_be32(70)

Definition at line 480 of file tpm.c.

#define TPM_ORD_PCR_EXTEND   cpu_to_be32(20)

tpm_pcr_extend - extend pcr value with hash : tpm idx # or AN& : pcr idx to extend : hash value used to extend pcr value

The TPM driver should be built-in, but for whatever reason it isn't, protect against the chip disappearing, by incrementing the module usage count.

Definition at line 786 of file tpm.c.

#define TPM_ORD_READPUBEK   cpu_to_be32(124)

Definition at line 917 of file tpm.c.

#define TPM_ORD_SAVESTATE   cpu_to_be32(152)

Definition at line 1277 of file tpm.c.

#define TPM_ORDINAL_PCRREAD   cpu_to_be32(21)

Definition at line 727 of file tpm.c.

#define TPM_PROTECTED_ORDINAL_MASK   0xFF

Definition at line 44 of file tpm.c.

#define TPM_RET_CODE_IDX   6

Definition at line 439 of file tpm.c.

#define TPM_TAG_RQU_COMMAND   cpu_to_be16(193)

Definition at line 478 of file tpm.c.

Enumeration Type Documentation

Enumerator:
TPM_CAP_FLAG 
TPM_CAP_PROP 
CAP_VERSION_1_1 
CAP_VERSION_1_2 

Definition at line 441 of file tpm.c.

Enumerator:
TPM_SHORT 
TPM_MEDIUM 
TPM_LONG 
TPM_UNDEFINED 

Definition at line 35 of file tpm.c.

Enumerator:
TPM_CAP_PROP_PCR 
TPM_CAP_PROP_MANUFACTURER 
TPM_CAP_FLAG_PERM 
TPM_CAP_FLAG_VOL 
TPM_CAP_PROP_OWNER 
TPM_CAP_PROP_TIS_TIMEOUT 
TPM_CAP_PROP_TIS_DURATION 

Definition at line 448 of file tpm.c.

Function Documentation

EXPORT_SYMBOL_GPL ( tpm_calc_ordinal_duration  )
EXPORT_SYMBOL_GPL ( tpm_gen_interrupt  )
EXPORT_SYMBOL_GPL ( tpm_get_timeouts  )
EXPORT_SYMBOL_GPL ( tpm_show_enabled  )
EXPORT_SYMBOL_GPL ( tpm_show_active  )
EXPORT_SYMBOL_GPL ( tpm_show_owned  )
EXPORT_SYMBOL_GPL ( tpm_show_temp_deactivated  )
EXPORT_SYMBOL_GPL ( tpm_pcr_read  )
EXPORT_SYMBOL_GPL ( tpm_pcr_extend  )
EXPORT_SYMBOL_GPL ( tpm_do_selftest  )
EXPORT_SYMBOL_GPL ( tpm_send  )
EXPORT_SYMBOL_GPL ( tpm_show_pcrs  )
EXPORT_SYMBOL_GPL ( tpm_show_pubek  )
EXPORT_SYMBOL_GPL ( tpm_show_caps  )
EXPORT_SYMBOL_GPL ( tpm_show_caps_1_2  )
EXPORT_SYMBOL_GPL ( tpm_show_durations  )
EXPORT_SYMBOL_GPL ( tpm_show_timeouts  )
EXPORT_SYMBOL_GPL ( tpm_store_cancel  )
EXPORT_SYMBOL_GPL ( wait_for_tpm_stat  )
EXPORT_SYMBOL_GPL ( tpm_open  )
EXPORT_SYMBOL_GPL ( tpm_release  )
EXPORT_SYMBOL_GPL ( tpm_write  )
EXPORT_SYMBOL_GPL ( tpm_read  )
EXPORT_SYMBOL_GPL ( tpm_remove_hardware  )
EXPORT_SYMBOL_GPL ( tpm_pm_suspend  )
EXPORT_SYMBOL_GPL ( tpm_pm_resume  )
EXPORT_SYMBOL_GPL ( tpm_get_random  )
EXPORT_SYMBOL_GPL ( tpm_dev_vendor_release  )
EXPORT_SYMBOL_GPL ( tpm_dev_release  )
EXPORT_SYMBOL_GPL ( tpm_register_hardware  )
MODULE_AUTHOR ( "Leendert van Doorn ([email protected])"  )
MODULE_DESCRIPTION ( "TPM Driver"  )
MODULE_LICENSE ( "GPL"  )
module_param_named ( suspend_pcr  ,
tpm_suspend_pcr  ,
uint  ,
0644   
)
MODULE_PARM_DESC ( suspend_pcr  ,
"PCR to use for dummy writes to faciltate flush on suspend."   
)
MODULE_VERSION ( "2.0"  )
unsigned long tpm_calc_ordinal_duration ( struct tpm_chip chip,
u32  ordinal 
)

Definition at line 349 of file tpm.c.

void tpm_dev_vendor_release ( struct tpm_chip chip)

Definition at line 1388 of file tpm.c.

int tpm_do_selftest ( struct tpm_chip chip)

tpm_do_selftest - have the TPM continue its selftest and wait until it can receive further commands : TPM chip to use

Returns 0 on success, < 0 in case of fatal error or a value > 0 representing a TPM error code.

Definition at line 823 of file tpm.c.

void tpm_gen_interrupt ( struct tpm_chip chip)

Definition at line 516 of file tpm.c.

int tpm_get_random ( u32  chip_num,
u8 out,
size_t  max 
)

tpm_get_random() - Get random bytes from the tpm's RNG : A specific chip number for the request or TPM_ANY_NUM : destination buffer for the random bytes : the max number of bytes to write to

Returns < 0 on error and the number of bytes read on success

Definition at line 1349 of file tpm.c.

int tpm_get_timeouts ( struct tpm_chip chip)

Definition at line 531 of file tpm.c.

ssize_t tpm_getcap ( struct device dev,
__be32  subcap_id,
cap_t cap,
const char desc 
)

Definition at line 488 of file tpm.c.

int tpm_open ( struct inode inode,
struct file file 
)

Definition at line 1125 of file tpm.c.

int tpm_pcr_extend ( u32  chip_num,
int  pcr_idx,
const u8 hash 
)

Definition at line 794 of file tpm.c.

int tpm_pcr_read ( u32  chip_num,
int  pcr_idx,
u8 res_buf 
)

tpm_pcr_read - read a pcr value : tpm idx # or ANY : pcr idx to retrieve : TPM_PCR value size of res_buf is 20 bytes (or NULL if you don't care)

The TPM driver should be built-in, but for whatever reason it isn't, protect against the chip disappearing, by incrementing the module usage count.

Definition at line 762 of file tpm.c.

int tpm_pm_resume ( struct device dev)

Definition at line 1323 of file tpm.c.

int tpm_pm_suspend ( struct device dev)

Definition at line 1290 of file tpm.c.

ssize_t tpm_read ( struct file file,
char __user buf,
size_t  size,
loff_t *  off 
)

Definition at line 1223 of file tpm.c.

struct tpm_chip* tpm_register_hardware ( struct device dev,
const struct tpm_vendor_specific entry 
)
read

Definition at line 1427 of file tpm.c.

int tpm_release ( struct inode inode,
struct file file 
)

Definition at line 1166 of file tpm.c.

void tpm_remove_hardware ( struct device dev)

Definition at line 1253 of file tpm.c.

int tpm_send ( u32  chip_num,
void cmd,
size_t  buflen 
)

Definition at line 871 of file tpm.c.

ssize_t tpm_show_active ( struct device dev,
struct device_attribute attr,
char buf 
)

Definition at line 658 of file tpm.c.

ssize_t tpm_show_caps ( struct device dev,
struct device_attribute attr,
char buf 
)

Definition at line 982 of file tpm.c.

ssize_t tpm_show_caps_1_2 ( struct device dev,
struct device_attribute attr,
char buf 
)

Definition at line 1008 of file tpm.c.

ssize_t tpm_show_durations ( struct device dev,
struct device_attribute attr,
char buf 
)

Definition at line 1034 of file tpm.c.

ssize_t tpm_show_enabled ( struct device dev,
struct device_attribute attr,
char buf 
)

Definition at line 642 of file tpm.c.

ssize_t tpm_show_owned ( struct device dev,
struct device_attribute attr,
char buf 
)

Definition at line 674 of file tpm.c.

ssize_t tpm_show_pcrs ( struct device dev,
struct device_attribute attr,
char buf 
)

Definition at line 887 of file tpm.c.

ssize_t tpm_show_pubek ( struct device dev,
struct device_attribute attr,
char buf 
)

Definition at line 924 of file tpm.c.

ssize_t tpm_show_temp_deactivated ( struct device dev,
struct device_attribute attr,
char buf 
)

Definition at line 690 of file tpm.c.

ssize_t tpm_show_timeouts ( struct device dev,
struct device_attribute attr,
char buf 
)

Definition at line 1051 of file tpm.c.

ssize_t tpm_store_cancel ( struct device dev,
struct device_attribute attr,
const char buf,
size_t  count 
)

Definition at line 1066 of file tpm.c.

ssize_t tpm_write ( struct file file,
const char __user buf,
size_t  size,
loff_t *  off 
)

Definition at line 1181 of file tpm.c.

int wait_for_tpm_stat ( struct tpm_chip chip,
u8  mask,
unsigned long  timeout,
wait_queue_head_t queue 
)

Definition at line 1078 of file tpm.c.