tpm: remove @flags from tpm_transmit()
Remove @flags from tpm_transmit() API. It is no longer used for anything. Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Tested-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Reviewed-by: James Bottomley <James.Bottomley@HansenPartnership.com> Tested-by: Alexander Steffen <Alexander.Steffen@infineon.com>
This commit is contained in:
Родитель
a3fbfae82b
Коммит
47a6c28b68
|
@ -37,7 +37,7 @@ struct class *tpm_class;
|
||||||
struct class *tpmrm_class;
|
struct class *tpmrm_class;
|
||||||
dev_t tpm_devt;
|
dev_t tpm_devt;
|
||||||
|
|
||||||
static int tpm_request_locality(struct tpm_chip *chip, unsigned int flags)
|
static int tpm_request_locality(struct tpm_chip *chip)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ static int tpm_request_locality(struct tpm_chip *chip, unsigned int flags)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tpm_relinquish_locality(struct tpm_chip *chip, unsigned int flags)
|
static void tpm_relinquish_locality(struct tpm_chip *chip)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ static void tpm_relinquish_locality(struct tpm_chip *chip, unsigned int flags)
|
||||||
chip->locality = -1;
|
chip->locality = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tpm_cmd_ready(struct tpm_chip *chip, unsigned int flags)
|
static int tpm_cmd_ready(struct tpm_chip *chip)
|
||||||
{
|
{
|
||||||
if (!chip->ops->cmd_ready)
|
if (!chip->ops->cmd_ready)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -74,7 +74,7 @@ static int tpm_cmd_ready(struct tpm_chip *chip, unsigned int flags)
|
||||||
return chip->ops->cmd_ready(chip);
|
return chip->ops->cmd_ready(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tpm_go_idle(struct tpm_chip *chip, unsigned int flags)
|
static int tpm_go_idle(struct tpm_chip *chip)
|
||||||
{
|
{
|
||||||
if (!chip->ops->go_idle)
|
if (!chip->ops->go_idle)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -85,13 +85,12 @@ static int tpm_go_idle(struct tpm_chip *chip, unsigned int flags)
|
||||||
/**
|
/**
|
||||||
* tpm_chip_start() - power on the TPM
|
* tpm_chip_start() - power on the TPM
|
||||||
* @chip: a TPM chip to use
|
* @chip: a TPM chip to use
|
||||||
* @flags: TPM transmit flags
|
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* * The response length - OK
|
* * The response length - OK
|
||||||
* * -errno - A system error
|
* * -errno - A system error
|
||||||
*/
|
*/
|
||||||
int tpm_chip_start(struct tpm_chip *chip, unsigned int flags)
|
int tpm_chip_start(struct tpm_chip *chip)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -99,16 +98,16 @@ int tpm_chip_start(struct tpm_chip *chip, unsigned int flags)
|
||||||
chip->ops->clk_enable(chip, true);
|
chip->ops->clk_enable(chip, true);
|
||||||
|
|
||||||
if (chip->locality == -1) {
|
if (chip->locality == -1) {
|
||||||
ret = tpm_request_locality(chip, flags);
|
ret = tpm_request_locality(chip);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
chip->ops->clk_enable(chip, false);
|
chip->ops->clk_enable(chip, false);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = tpm_cmd_ready(chip, flags);
|
ret = tpm_cmd_ready(chip);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
tpm_relinquish_locality(chip, flags);
|
tpm_relinquish_locality(chip);
|
||||||
if (chip->ops->clk_enable)
|
if (chip->ops->clk_enable)
|
||||||
chip->ops->clk_enable(chip, false);
|
chip->ops->clk_enable(chip, false);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -121,16 +120,15 @@ EXPORT_SYMBOL_GPL(tpm_chip_start);
|
||||||
/**
|
/**
|
||||||
* tpm_chip_stop() - power off the TPM
|
* tpm_chip_stop() - power off the TPM
|
||||||
* @chip: a TPM chip to use
|
* @chip: a TPM chip to use
|
||||||
* @flags: TPM transmit flags
|
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* * The response length - OK
|
* * The response length - OK
|
||||||
* * -errno - A system error
|
* * -errno - A system error
|
||||||
*/
|
*/
|
||||||
void tpm_chip_stop(struct tpm_chip *chip, unsigned int flags)
|
void tpm_chip_stop(struct tpm_chip *chip)
|
||||||
{
|
{
|
||||||
tpm_go_idle(chip, flags);
|
tpm_go_idle(chip);
|
||||||
tpm_relinquish_locality(chip, flags);
|
tpm_relinquish_locality(chip);
|
||||||
if (chip->ops->clk_enable)
|
if (chip->ops->clk_enable)
|
||||||
chip->ops->clk_enable(chip, false);
|
chip->ops->clk_enable(chip, false);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +156,7 @@ int tpm_try_get_ops(struct tpm_chip *chip)
|
||||||
goto out_ops;
|
goto out_ops;
|
||||||
|
|
||||||
mutex_lock(&chip->tpm_mutex);
|
mutex_lock(&chip->tpm_mutex);
|
||||||
rc = tpm_chip_start(chip, 0);
|
rc = tpm_chip_start(chip);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out_lock;
|
goto out_lock;
|
||||||
|
|
||||||
|
@ -181,7 +179,7 @@ EXPORT_SYMBOL_GPL(tpm_try_get_ops);
|
||||||
*/
|
*/
|
||||||
void tpm_put_ops(struct tpm_chip *chip)
|
void tpm_put_ops(struct tpm_chip *chip)
|
||||||
{
|
{
|
||||||
tpm_chip_stop(chip, 0);
|
tpm_chip_stop(chip);
|
||||||
mutex_unlock(&chip->tpm_mutex);
|
mutex_unlock(&chip->tpm_mutex);
|
||||||
up_read(&chip->ops_sem);
|
up_read(&chip->ops_sem);
|
||||||
put_device(&chip->dev);
|
put_device(&chip->dev);
|
||||||
|
@ -297,9 +295,9 @@ static int tpm_class_shutdown(struct device *dev)
|
||||||
|
|
||||||
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
|
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
|
||||||
down_write(&chip->ops_sem);
|
down_write(&chip->ops_sem);
|
||||||
if (!tpm_chip_start(chip, 0)) {
|
if (!tpm_chip_start(chip)) {
|
||||||
tpm2_shutdown(chip, TPM2_SU_CLEAR);
|
tpm2_shutdown(chip, TPM2_SU_CLEAR);
|
||||||
tpm_chip_stop(chip, 0);
|
tpm_chip_stop(chip);
|
||||||
}
|
}
|
||||||
chip->ops = NULL;
|
chip->ops = NULL;
|
||||||
up_write(&chip->ops_sem);
|
up_write(&chip->ops_sem);
|
||||||
|
@ -480,9 +478,9 @@ static void tpm_del_char_device(struct tpm_chip *chip)
|
||||||
/* Make the driver uncallable. */
|
/* Make the driver uncallable. */
|
||||||
down_write(&chip->ops_sem);
|
down_write(&chip->ops_sem);
|
||||||
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
|
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
|
||||||
if (!tpm_chip_start(chip, 0)) {
|
if (!tpm_chip_start(chip)) {
|
||||||
tpm2_shutdown(chip, TPM2_SU_CLEAR);
|
tpm2_shutdown(chip, TPM2_SU_CLEAR);
|
||||||
tpm_chip_stop(chip, 0);
|
tpm_chip_stop(chip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
chip->ops = NULL;
|
chip->ops = NULL;
|
||||||
|
@ -566,11 +564,11 @@ int tpm_chip_register(struct tpm_chip *chip)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = tpm_chip_start(chip, 0);
|
rc = tpm_chip_start(chip);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
rc = tpm_auto_startup(chip);
|
rc = tpm_auto_startup(chip);
|
||||||
tpm_chip_stop(chip, 0);
|
tpm_chip_stop(chip);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ static ssize_t tpm_dev_transmit(struct tpm_chip *chip, struct tpm_space *space,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_rc;
|
goto out_rc;
|
||||||
|
|
||||||
len = tpm_transmit(chip, buf, bufsiz, 0);
|
len = tpm_transmit(chip, buf, bufsiz);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
ret = len;
|
ret = len;
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,7 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);
|
EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);
|
||||||
|
|
||||||
static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz,
|
static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
|
||||||
unsigned int flags)
|
|
||||||
{
|
{
|
||||||
struct tpm_header *header = buf;
|
struct tpm_header *header = buf;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -143,7 +142,6 @@ out_recv:
|
||||||
* @chip: a TPM chip to use
|
* @chip: a TPM chip to use
|
||||||
* @buf: a TPM command buffer
|
* @buf: a TPM command buffer
|
||||||
* @bufsiz: length of the TPM command buffer
|
* @bufsiz: length of the TPM command buffer
|
||||||
* @flags: TPM transmit flags
|
|
||||||
*
|
*
|
||||||
* A wrapper around tpm_try_transmit() that handles TPM2_RC_RETRY returns from
|
* A wrapper around tpm_try_transmit() that handles TPM2_RC_RETRY returns from
|
||||||
* the TPM and retransmits the command after a delay up to a maximum wait of
|
* the TPM and retransmits the command after a delay up to a maximum wait of
|
||||||
|
@ -156,8 +154,7 @@ out_recv:
|
||||||
* * The response length - OK
|
* * The response length - OK
|
||||||
* * -errno - A system error
|
* * -errno - A system error
|
||||||
*/
|
*/
|
||||||
ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
|
ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz)
|
||||||
unsigned int flags)
|
|
||||||
{
|
{
|
||||||
struct tpm_header *header = (struct tpm_header *)buf;
|
struct tpm_header *header = (struct tpm_header *)buf;
|
||||||
/* space for header and handles */
|
/* space for header and handles */
|
||||||
|
@ -177,7 +174,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
|
||||||
memcpy(save, buf, save_size);
|
memcpy(save, buf, save_size);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ret = tpm_try_transmit(chip, buf, bufsiz, flags);
|
ret = tpm_try_transmit(chip, buf, bufsiz);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
break;
|
break;
|
||||||
rc = be32_to_cpu(header->return_code);
|
rc = be32_to_cpu(header->return_code);
|
||||||
|
@ -210,7 +207,6 @@ ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
|
||||||
* @chip: a TPM chip to use
|
* @chip: a TPM chip to use
|
||||||
* @buf: a TPM command buffer
|
* @buf: a TPM command buffer
|
||||||
* @min_rsp_body_length: minimum expected length of response body
|
* @min_rsp_body_length: minimum expected length of response body
|
||||||
* @flags: TPM transmit flags
|
|
||||||
* @desc: command description used in the error message
|
* @desc: command description used in the error message
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
|
@ -219,14 +215,13 @@ ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
|
||||||
* * TPM_RC - A TPM error
|
* * TPM_RC - A TPM error
|
||||||
*/
|
*/
|
||||||
ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
|
ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
|
||||||
size_t min_rsp_body_length, unsigned int flags,
|
size_t min_rsp_body_length, const char *desc)
|
||||||
const char *desc)
|
|
||||||
{
|
{
|
||||||
const struct tpm_header *header = (struct tpm_header *)buf->data;
|
const struct tpm_header *header = (struct tpm_header *)buf->data;
|
||||||
int err;
|
int err;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
len = tpm_transmit(chip, buf->data, PAGE_SIZE, flags);
|
len = tpm_transmit(chip, buf->data, PAGE_SIZE);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return len;
|
return len;
|
||||||
|
|
||||||
|
@ -375,8 +370,7 @@ int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
memcpy(buf.data, cmd, buflen);
|
memcpy(buf.data, cmd, buflen);
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0,
|
rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to a send a command");
|
||||||
"attempting to a send a command");
|
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
out:
|
out:
|
||||||
tpm_put_ops(chip);
|
tpm_put_ops(chip);
|
||||||
|
@ -416,9 +410,9 @@ int tpm_pm_suspend(struct device *dev)
|
||||||
|
|
||||||
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
|
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
|
||||||
mutex_lock(&chip->tpm_mutex);
|
mutex_lock(&chip->tpm_mutex);
|
||||||
if (!tpm_chip_start(chip, 0)) {
|
if (!tpm_chip_start(chip)) {
|
||||||
tpm2_shutdown(chip, TPM2_SU_STATE);
|
tpm2_shutdown(chip, TPM2_SU_STATE);
|
||||||
tpm_chip_stop(chip, 0);
|
tpm_chip_stop(chip);
|
||||||
}
|
}
|
||||||
mutex_unlock(&chip->tpm_mutex);
|
mutex_unlock(&chip->tpm_mutex);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -55,7 +55,7 @@ static ssize_t pubek_show(struct device *dev, struct device_attribute *attr,
|
||||||
tpm_buf_append(&tpm_buf, anti_replay, sizeof(anti_replay));
|
tpm_buf_append(&tpm_buf, anti_replay, sizeof(anti_replay));
|
||||||
|
|
||||||
if (tpm_transmit_cmd(chip, &tpm_buf, READ_PUBEK_RESULT_MIN_BODY_SIZE,
|
if (tpm_transmit_cmd(chip, &tpm_buf, READ_PUBEK_RESULT_MIN_BODY_SIZE,
|
||||||
0, "attempting to read the PUBEK"))
|
"attempting to read the PUBEK"))
|
||||||
goto out_buf;
|
goto out_buf;
|
||||||
|
|
||||||
out = (struct tpm_readpubek_out *)&tpm_buf.data[10];
|
out = (struct tpm_readpubek_out *)&tpm_buf.data[10];
|
||||||
|
|
|
@ -485,11 +485,9 @@ extern const struct file_operations tpm_fops;
|
||||||
extern const struct file_operations tpmrm_fops;
|
extern const struct file_operations tpmrm_fops;
|
||||||
extern struct idr dev_nums_idr;
|
extern struct idr dev_nums_idr;
|
||||||
|
|
||||||
ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
|
ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz);
|
||||||
unsigned int flags);
|
|
||||||
ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
|
ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
|
||||||
size_t min_rsp_body_length, unsigned int flags,
|
size_t min_rsp_body_length, const char *desc);
|
||||||
const char *desc);
|
|
||||||
int tpm_get_timeouts(struct tpm_chip *);
|
int tpm_get_timeouts(struct tpm_chip *);
|
||||||
int tpm_auto_startup(struct tpm_chip *chip);
|
int tpm_auto_startup(struct tpm_chip *chip);
|
||||||
|
|
||||||
|
@ -514,8 +512,8 @@ static inline void tpm_msleep(unsigned int delay_msec)
|
||||||
delay_msec * 1000);
|
delay_msec * 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
int tpm_chip_start(struct tpm_chip *chip, unsigned int flags);
|
int tpm_chip_start(struct tpm_chip *chip);
|
||||||
void tpm_chip_stop(struct tpm_chip *chip, unsigned int flags);
|
void tpm_chip_stop(struct tpm_chip *chip);
|
||||||
struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip);
|
struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip);
|
||||||
__must_check int tpm_try_get_ops(struct tpm_chip *chip);
|
__must_check int tpm_try_get_ops(struct tpm_chip *chip);
|
||||||
void tpm_put_ops(struct tpm_chip *chip);
|
void tpm_put_ops(struct tpm_chip *chip);
|
||||||
|
@ -548,8 +546,7 @@ int tpm2_pcr_read(struct tpm_chip *chip, u32 pcr_idx, u8 *res_buf);
|
||||||
int tpm2_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, u32 count,
|
int tpm2_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, u32 count,
|
||||||
struct tpm2_digest *digests);
|
struct tpm2_digest *digests);
|
||||||
int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max);
|
int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max);
|
||||||
void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
|
void tpm2_flush_context(struct tpm_chip *chip, u32 handle);
|
||||||
unsigned int flags);
|
|
||||||
int tpm2_seal_trusted(struct tpm_chip *chip,
|
int tpm2_seal_trusted(struct tpm_chip *chip,
|
||||||
struct trusted_key_payload *payload,
|
struct trusted_key_payload *payload,
|
||||||
struct trusted_key_options *options);
|
struct trusted_key_options *options);
|
||||||
|
|
|
@ -334,7 +334,7 @@ static int tpm1_startup(struct tpm_chip *chip)
|
||||||
|
|
||||||
tpm_buf_append_u16(&buf, TPM_ST_CLEAR);
|
tpm_buf_append_u16(&buf, TPM_ST_CLEAR);
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0, "attempting to start the TPM");
|
rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to start the TPM");
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ int tpm1_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, const u8 *hash,
|
||||||
tpm_buf_append_u32(&buf, pcr_idx);
|
tpm_buf_append_u32(&buf, pcr_idx);
|
||||||
tpm_buf_append(&buf, hash, TPM_DIGEST_SIZE);
|
tpm_buf_append(&buf, hash, TPM_DIGEST_SIZE);
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, TPM_DIGEST_SIZE, 0, log_msg);
|
rc = tpm_transmit_cmd(chip, &buf, TPM_DIGEST_SIZE, log_msg);
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,7 @@ ssize_t tpm1_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap,
|
||||||
tpm_buf_append_u32(&buf, 4);
|
tpm_buf_append_u32(&buf, 4);
|
||||||
tpm_buf_append_u32(&buf, subcap_id);
|
tpm_buf_append_u32(&buf, subcap_id);
|
||||||
}
|
}
|
||||||
rc = tpm_transmit_cmd(chip, &buf, min_cap_length, 0, desc);
|
rc = tpm_transmit_cmd(chip, &buf, min_cap_length, desc);
|
||||||
if (!rc)
|
if (!rc)
|
||||||
*cap = *(cap_t *)&buf.data[TPM_HEADER_SIZE + 4];
|
*cap = *(cap_t *)&buf.data[TPM_HEADER_SIZE + 4];
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
|
@ -529,7 +529,7 @@ int tpm1_get_random(struct tpm_chip *chip, u8 *dest, size_t max)
|
||||||
do {
|
do {
|
||||||
tpm_buf_append_u32(&buf, num_bytes);
|
tpm_buf_append_u32(&buf, num_bytes);
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, sizeof(out->rng_data_len), 0,
|
rc = tpm_transmit_cmd(chip, &buf, sizeof(out->rng_data_len),
|
||||||
"attempting get random");
|
"attempting get random");
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -574,7 +574,7 @@ int tpm1_pcr_read(struct tpm_chip *chip, u32 pcr_idx, u8 *res_buf)
|
||||||
|
|
||||||
tpm_buf_append_u32(&buf, pcr_idx);
|
tpm_buf_append_u32(&buf, pcr_idx);
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, TPM_DIGEST_SIZE, 0,
|
rc = tpm_transmit_cmd(chip, &buf, TPM_DIGEST_SIZE,
|
||||||
"attempting to read a pcr value");
|
"attempting to read a pcr value");
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -608,7 +608,7 @@ static int tpm1_continue_selftest(struct tpm_chip *chip)
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0, "continue selftest");
|
rc = tpm_transmit_cmd(chip, &buf, 0, "continue selftest");
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -734,7 +734,7 @@ int tpm1_pm_suspend(struct tpm_chip *chip, u32 tpm_suspend_pcr)
|
||||||
return rc;
|
return rc;
|
||||||
/* now do the actual savestate */
|
/* now do the actual savestate */
|
||||||
for (try = 0; try < TPM_RETRY; try++) {
|
for (try = 0; try < TPM_RETRY; try++) {
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0, NULL);
|
rc = tpm_transmit_cmd(chip, &buf, 0, NULL);
|
||||||
/*
|
/*
|
||||||
* If the TPM indicates that it is too busy to respond to
|
* If the TPM indicates that it is too busy to respond to
|
||||||
* this command then retry before giving up. It can take
|
* this command then retry before giving up. It can take
|
||||||
|
|
|
@ -197,7 +197,7 @@ int tpm2_pcr_read(struct tpm_chip *chip, u32 pcr_idx, u8 *res_buf)
|
||||||
tpm_buf_append(&buf, (const unsigned char *)pcr_select,
|
tpm_buf_append(&buf, (const unsigned char *)pcr_select,
|
||||||
sizeof(pcr_select));
|
sizeof(pcr_select));
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0, res_buf ?
|
rc = tpm_transmit_cmd(chip, &buf, 0, res_buf ?
|
||||||
"attempting to read a pcr value" : NULL);
|
"attempting to read a pcr value" : NULL);
|
||||||
if (rc == 0 && res_buf) {
|
if (rc == 0 && res_buf) {
|
||||||
out = (struct tpm2_pcr_read_out *)&buf.data[TPM_HEADER_SIZE];
|
out = (struct tpm2_pcr_read_out *)&buf.data[TPM_HEADER_SIZE];
|
||||||
|
@ -264,8 +264,7 @@ int tpm2_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, u32 count,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0,
|
rc = tpm_transmit_cmd(chip, &buf, 0, "attempting extend a PCR value");
|
||||||
"attempting extend a PCR value");
|
|
||||||
|
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
|
|
||||||
|
@ -312,7 +311,7 @@ int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max)
|
||||||
err = tpm_transmit_cmd(chip, &buf,
|
err = tpm_transmit_cmd(chip, &buf,
|
||||||
offsetof(struct tpm2_get_random_out,
|
offsetof(struct tpm2_get_random_out,
|
||||||
buffer),
|
buffer),
|
||||||
0, "attempting get random");
|
"attempting get random");
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -341,14 +340,11 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tpm2_flush_context_cmd() - execute a TPM2_FlushContext command
|
* tpm2_flush_context() - execute a TPM2_FlushContext command
|
||||||
* @chip: TPM chip to use
|
* @chip: TPM chip to use
|
||||||
* @handle: context handle
|
* @handle: context handle
|
||||||
* @flags: tpm transmit flags - bitmap
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
|
void tpm2_flush_context(struct tpm_chip *chip, u32 handle)
|
||||||
unsigned int flags)
|
|
||||||
{
|
{
|
||||||
struct tpm_buf buf;
|
struct tpm_buf buf;
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -362,7 +358,7 @@ void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
|
||||||
|
|
||||||
tpm_buf_append_u32(&buf, handle);
|
tpm_buf_append_u32(&buf, handle);
|
||||||
|
|
||||||
tpm_transmit_cmd(chip, &buf, 0, flags, "flushing context");
|
tpm_transmit_cmd(chip, &buf, 0, "flushing context");
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +472,7 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 4, 0, "sealing data");
|
rc = tpm_transmit_cmd(chip, &buf, 4, "sealing data");
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -513,7 +509,6 @@ out:
|
||||||
* @payload: the key data in clear and encrypted form
|
* @payload: the key data in clear and encrypted form
|
||||||
* @options: authentication values and other options
|
* @options: authentication values and other options
|
||||||
* @blob_handle: returned blob handle
|
* @blob_handle: returned blob handle
|
||||||
* @flags: tpm transmit flags
|
|
||||||
*
|
*
|
||||||
* Return: 0 on success.
|
* Return: 0 on success.
|
||||||
* -E2BIG on wrong payload size.
|
* -E2BIG on wrong payload size.
|
||||||
|
@ -523,7 +518,7 @@ out:
|
||||||
static int tpm2_load_cmd(struct tpm_chip *chip,
|
static int tpm2_load_cmd(struct tpm_chip *chip,
|
||||||
struct trusted_key_payload *payload,
|
struct trusted_key_payload *payload,
|
||||||
struct trusted_key_options *options,
|
struct trusted_key_options *options,
|
||||||
u32 *blob_handle, unsigned int flags)
|
u32 *blob_handle)
|
||||||
{
|
{
|
||||||
struct tpm_buf buf;
|
struct tpm_buf buf;
|
||||||
unsigned int private_len;
|
unsigned int private_len;
|
||||||
|
@ -558,7 +553,7 @@ static int tpm2_load_cmd(struct tpm_chip *chip,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 4, flags, "loading blob");
|
rc = tpm_transmit_cmd(chip, &buf, 4, "loading blob");
|
||||||
if (!rc)
|
if (!rc)
|
||||||
*blob_handle = be32_to_cpup(
|
*blob_handle = be32_to_cpup(
|
||||||
(__be32 *) &buf.data[TPM_HEADER_SIZE]);
|
(__be32 *) &buf.data[TPM_HEADER_SIZE]);
|
||||||
|
@ -579,7 +574,6 @@ out:
|
||||||
* @payload: the key data in clear and encrypted form
|
* @payload: the key data in clear and encrypted form
|
||||||
* @options: authentication values and other options
|
* @options: authentication values and other options
|
||||||
* @blob_handle: blob handle
|
* @blob_handle: blob handle
|
||||||
* @flags: tpm_transmit_cmd flags
|
|
||||||
*
|
*
|
||||||
* Return: 0 on success
|
* Return: 0 on success
|
||||||
* -EPERM on tpm error status
|
* -EPERM on tpm error status
|
||||||
|
@ -588,7 +582,7 @@ out:
|
||||||
static int tpm2_unseal_cmd(struct tpm_chip *chip,
|
static int tpm2_unseal_cmd(struct tpm_chip *chip,
|
||||||
struct trusted_key_payload *payload,
|
struct trusted_key_payload *payload,
|
||||||
struct trusted_key_options *options,
|
struct trusted_key_options *options,
|
||||||
u32 blob_handle, unsigned int flags)
|
u32 blob_handle)
|
||||||
{
|
{
|
||||||
struct tpm_buf buf;
|
struct tpm_buf buf;
|
||||||
u16 data_len;
|
u16 data_len;
|
||||||
|
@ -608,7 +602,7 @@ static int tpm2_unseal_cmd(struct tpm_chip *chip,
|
||||||
options->blobauth /* hmac */,
|
options->blobauth /* hmac */,
|
||||||
TPM_DIGEST_SIZE);
|
TPM_DIGEST_SIZE);
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 6, flags, "unsealing");
|
rc = tpm_transmit_cmd(chip, &buf, 6, "unsealing");
|
||||||
if (rc > 0)
|
if (rc > 0)
|
||||||
rc = -EPERM;
|
rc = -EPERM;
|
||||||
|
|
||||||
|
@ -652,12 +646,12 @@ int tpm2_unseal_trusted(struct tpm_chip *chip,
|
||||||
u32 blob_handle;
|
u32 blob_handle;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = tpm2_load_cmd(chip, payload, options, &blob_handle, 0);
|
rc = tpm2_load_cmd(chip, payload, options, &blob_handle);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
rc = tpm2_unseal_cmd(chip, payload, options, blob_handle, 0);
|
rc = tpm2_unseal_cmd(chip, payload, options, blob_handle);
|
||||||
tpm2_flush_context_cmd(chip, blob_handle, 0);
|
tpm2_flush_context(chip, blob_handle);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,7 +687,7 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value,
|
||||||
tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES);
|
tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES);
|
||||||
tpm_buf_append_u32(&buf, property_id);
|
tpm_buf_append_u32(&buf, property_id);
|
||||||
tpm_buf_append_u32(&buf, 1);
|
tpm_buf_append_u32(&buf, 1);
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0, NULL);
|
rc = tpm_transmit_cmd(chip, &buf, 0, NULL);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
out = (struct tpm2_get_cap_out *)
|
out = (struct tpm2_get_cap_out *)
|
||||||
&buf.data[TPM_HEADER_SIZE];
|
&buf.data[TPM_HEADER_SIZE];
|
||||||
|
@ -723,7 +717,7 @@ void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type)
|
||||||
if (rc)
|
if (rc)
|
||||||
return;
|
return;
|
||||||
tpm_buf_append_u16(&buf, shutdown_type);
|
tpm_buf_append_u16(&buf, shutdown_type);
|
||||||
tpm_transmit_cmd(chip, &buf, 0, 0, "stopping the TPM");
|
tpm_transmit_cmd(chip, &buf, 0, "stopping the TPM");
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,7 +746,7 @@ static int tpm2_do_selftest(struct tpm_chip *chip)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
tpm_buf_append_u8(&buf, full);
|
tpm_buf_append_u8(&buf, full);
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0,
|
rc = tpm_transmit_cmd(chip, &buf, 0,
|
||||||
"attempting the self test");
|
"attempting the self test");
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
|
|
||||||
|
@ -789,7 +783,7 @@ int tpm2_probe(struct tpm_chip *chip)
|
||||||
tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES);
|
tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES);
|
||||||
tpm_buf_append_u32(&buf, TPM_PT_TOTAL_COMMANDS);
|
tpm_buf_append_u32(&buf, TPM_PT_TOTAL_COMMANDS);
|
||||||
tpm_buf_append_u32(&buf, 1);
|
tpm_buf_append_u32(&buf, 1);
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0, NULL);
|
rc = tpm_transmit_cmd(chip, &buf, 0, NULL);
|
||||||
/* We ignore TPM return codes on purpose. */
|
/* We ignore TPM return codes on purpose. */
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
out = (struct tpm_header *)buf.data;
|
out = (struct tpm_header *)buf.data;
|
||||||
|
@ -828,7 +822,7 @@ static ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
|
||||||
tpm_buf_append_u32(&buf, 0);
|
tpm_buf_append_u32(&buf, 0);
|
||||||
tpm_buf_append_u32(&buf, 1);
|
tpm_buf_append_u32(&buf, 1);
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 9, 0, "get tpm pcr allocation");
|
rc = tpm_transmit_cmd(chip, &buf, 9, "get tpm pcr allocation");
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -899,7 +893,7 @@ static int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip)
|
||||||
tpm_buf_append_u32(&buf, TPM2_CC_FIRST);
|
tpm_buf_append_u32(&buf, TPM2_CC_FIRST);
|
||||||
tpm_buf_append_u32(&buf, nr_commands);
|
tpm_buf_append_u32(&buf, nr_commands);
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 9 + 4 * nr_commands, 0, NULL);
|
rc = tpm_transmit_cmd(chip, &buf, 9 + 4 * nr_commands, NULL);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -956,7 +950,7 @@ static int tpm2_startup(struct tpm_chip *chip)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
tpm_buf_append_u16(&buf, TPM2_SU_CLEAR);
|
tpm_buf_append_u16(&buf, TPM2_SU_CLEAR);
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0, "attempting to start the TPM");
|
rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to start the TPM");
|
||||||
tpm_buf_destroy(&buf);
|
tpm_buf_destroy(&buf);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -38,7 +38,7 @@ static void tpm2_flush_sessions(struct tpm_chip *chip, struct tpm_space *space)
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(space->session_tbl); i++) {
|
for (i = 0; i < ARRAY_SIZE(space->session_tbl); i++) {
|
||||||
if (space->session_tbl[i])
|
if (space->session_tbl[i])
|
||||||
tpm2_flush_context_cmd(chip, space->session_tbl[i], 0);
|
tpm2_flush_context(chip, space->session_tbl[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,9 +60,9 @@ int tpm2_init_space(struct tpm_space *space)
|
||||||
void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space)
|
void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space)
|
||||||
{
|
{
|
||||||
mutex_lock(&chip->tpm_mutex);
|
mutex_lock(&chip->tpm_mutex);
|
||||||
if (!tpm_chip_start(chip, 0)) {
|
if (!tpm_chip_start(chip)) {
|
||||||
tpm2_flush_sessions(chip, space);
|
tpm2_flush_sessions(chip, space);
|
||||||
tpm_chip_stop(chip, 0);
|
tpm_chip_stop(chip);
|
||||||
}
|
}
|
||||||
mutex_unlock(&chip->tpm_mutex);
|
mutex_unlock(&chip->tpm_mutex);
|
||||||
kfree(space->context_buf);
|
kfree(space->context_buf);
|
||||||
|
@ -85,7 +85,7 @@ static int tpm2_load_context(struct tpm_chip *chip, u8 *buf,
|
||||||
body_size = sizeof(*ctx) + be16_to_cpu(ctx->blob_size);
|
body_size = sizeof(*ctx) + be16_to_cpu(ctx->blob_size);
|
||||||
tpm_buf_append(&tbuf, &buf[*offset], body_size);
|
tpm_buf_append(&tbuf, &buf[*offset], body_size);
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &tbuf, 4, 0, NULL);
|
rc = tpm_transmit_cmd(chip, &tbuf, 4, NULL);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
dev_warn(&chip->dev, "%s: failed with a system error %d\n",
|
dev_warn(&chip->dev, "%s: failed with a system error %d\n",
|
||||||
__func__, rc);
|
__func__, rc);
|
||||||
|
@ -133,7 +133,7 @@ static int tpm2_save_context(struct tpm_chip *chip, u32 handle, u8 *buf,
|
||||||
|
|
||||||
tpm_buf_append_u32(&tbuf, handle);
|
tpm_buf_append_u32(&tbuf, handle);
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &tbuf, 0, 0, NULL);
|
rc = tpm_transmit_cmd(chip, &tbuf, 0, NULL);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
dev_warn(&chip->dev, "%s: failed with a system error %d\n",
|
dev_warn(&chip->dev, "%s: failed with a system error %d\n",
|
||||||
__func__, rc);
|
__func__, rc);
|
||||||
|
@ -169,7 +169,7 @@ void tpm2_flush_space(struct tpm_chip *chip)
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++)
|
for (i = 0; i < ARRAY_SIZE(space->context_tbl); i++)
|
||||||
if (space->context_tbl[i] && ~space->context_tbl[i])
|
if (space->context_tbl[i] && ~space->context_tbl[i])
|
||||||
tpm2_flush_context_cmd(chip, space->context_tbl[i], 0);
|
tpm2_flush_context(chip, space->context_tbl[i]);
|
||||||
|
|
||||||
tpm2_flush_sessions(chip, space);
|
tpm2_flush_sessions(chip, space);
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ static int tpm2_map_response_header(struct tpm_chip *chip, u32 cc, u8 *rsp,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
out_no_slots:
|
out_no_slots:
|
||||||
tpm2_flush_context_cmd(chip, phandle, 0);
|
tpm2_flush_context(chip, phandle);
|
||||||
dev_warn(&chip->dev, "%s: out of slots for 0x%08X\n", __func__,
|
dev_warn(&chip->dev, "%s: out of slots for 0x%08X\n", __func__,
|
||||||
phandle);
|
phandle);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -504,7 +504,7 @@ static int tpm2_save_space(struct tpm_chip *chip)
|
||||||
} else if (rc)
|
} else if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
tpm2_flush_context_cmd(chip, space->context_tbl[i], 0);
|
tpm2_flush_context(chip, space->context_tbl[i]);
|
||||||
space->context_tbl[i] = ~0;
|
space->context_tbl[i] = ~0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -916,11 +916,11 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
|
||||||
intmask &= ~TPM_GLOBAL_INT_ENABLE;
|
intmask &= ~TPM_GLOBAL_INT_ENABLE;
|
||||||
tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask);
|
tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask);
|
||||||
|
|
||||||
rc = tpm_chip_start(chip, 0);
|
rc = tpm_chip_start(chip);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out_err;
|
goto out_err;
|
||||||
rc = tpm2_probe(chip);
|
rc = tpm2_probe(chip);
|
||||||
tpm_chip_stop(chip, 0);
|
tpm_chip_stop(chip);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out_err;
|
goto out_err;
|
||||||
|
|
||||||
|
|
|
@ -416,7 +416,7 @@ static int vtpm_proxy_request_locality(struct tpm_chip *chip, int locality)
|
||||||
|
|
||||||
proxy_dev->state |= STATE_DRIVER_COMMAND;
|
proxy_dev->state |= STATE_DRIVER_COMMAND;
|
||||||
|
|
||||||
rc = tpm_transmit_cmd(chip, &buf, 0, 0, "attempting to set locality");
|
rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to set locality");
|
||||||
|
|
||||||
proxy_dev->state &= ~STATE_DRIVER_COMMAND;
|
proxy_dev->state &= ~STATE_DRIVER_COMMAND;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче