Commit 66fd704d authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull tpm updates from Jarkko Sakkinen:
 "This is only a small pull request with fixes, as possible features
  moved to +1 release"

* tag 'tpmdd-next-6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd:
  tpm_crb: ffa_tpm: fix/update comments describing the CRB over FFA ABI
  tpm_crb_ffa: use dev_xx() macro to print log
  tpm_ffa_crb: access tpm service over FF-A direct message request v2
  tpm: remove kmalloc failure error message
parents 14418ddc ecc1ca91
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -257,11 +257,8 @@ static int tpm1_ascii_bios_measurements_show(struct seq_file *m, void *v)
	    (unsigned char *)(v + sizeof(struct tcpa_event));

	eventname = kmalloc(MAX_TEXT_EVENT, GFP_KERNEL);
	if (!eventname) {
		printk(KERN_ERR "%s: ERROR - No Memory for event name\n ",
		       __func__);
		return -EFAULT;
	}
	if (!eventname)
		return -ENOMEM;

	/* 1st: PCR */
	seq_printf(m, "%2d ", do_endian_conversion(event->pcr_index));
+51 −23
Original line number Diff line number Diff line
@@ -38,9 +38,11 @@
 * messages.
 *
 * All requests with FFA_MSG_SEND_DIRECT_REQ and FFA_MSG_SEND_DIRECT_RESP
 * are using the AArch32 SMC calling convention with register usage as
 * defined in FF-A specification:
 * w0:    Function ID (0x8400006F or 0x84000070)
 * are using the AArch32 or AArch64 SMC calling convention with register usage
 * as defined in FF-A specification:
 * w0:    Function ID
 *          -for 32-bit: 0x8400006F or 0x84000070
 *          -for 64-bit: 0xC400006F or 0xC4000070
 * w1:    Source/Destination IDs
 * w2:    Reserved (MBZ)
 * w3-w7: Implementation defined, free to be used below
@@ -68,7 +70,8 @@
#define CRB_FFA_GET_INTERFACE_VERSION 0x0f000001

/*
 * Return information on a given feature of the TPM service
 * Notifies the TPM service that a TPM command or TPM locality request is
 * ready to be processed, and allows the TPM service to process it.
 * Call register usage:
 * w3:    Not used (MBZ)
 * w4:    TPM service function ID, CRB_FFA_START
@@ -105,7 +108,10 @@ struct tpm_crb_ffa {
	u16 minor_version;
	/* lock to protect sending of FF-A messages: */
	struct mutex msg_data_lock;
	union {
		struct ffa_send_direct_data direct_msg_data;
		struct ffa_send_direct_data2 direct_msg_data2;
	};
};

static struct tpm_crb_ffa *tpm_crb_ffa;
@@ -185,6 +191,20 @@ static int __tpm_crb_ffa_send_recieve(unsigned long func_id,

	msg_ops = tpm_crb_ffa->ffa_dev->ops->msg_ops;

	if (ffa_partition_supports_direct_req2_recv(tpm_crb_ffa->ffa_dev)) {
		memset(&tpm_crb_ffa->direct_msg_data2, 0x00,
		       sizeof(struct ffa_send_direct_data2));

		tpm_crb_ffa->direct_msg_data2.data[0] = func_id;
		tpm_crb_ffa->direct_msg_data2.data[1] = a0;
		tpm_crb_ffa->direct_msg_data2.data[2] = a1;
		tpm_crb_ffa->direct_msg_data2.data[3] = a2;

		ret = msg_ops->sync_send_receive2(tpm_crb_ffa->ffa_dev,
				&tpm_crb_ffa->direct_msg_data2);
		if (!ret)
			ret = tpm_crb_ffa_to_linux_errno(tpm_crb_ffa->direct_msg_data2.data[0]);
	} else {
		memset(&tpm_crb_ffa->direct_msg_data, 0x00,
		       sizeof(struct ffa_send_direct_data));

@@ -197,6 +217,8 @@ static int __tpm_crb_ffa_send_recieve(unsigned long func_id,
				&tpm_crb_ffa->direct_msg_data);
		if (!ret)
			ret = tpm_crb_ffa_to_linux_errno(tpm_crb_ffa->direct_msg_data.data1);
	}


	return ret;
}
@@ -231,9 +253,14 @@ int tpm_crb_ffa_get_interface_version(u16 *major, u16 *minor)

	rc = __tpm_crb_ffa_send_recieve(CRB_FFA_GET_INTERFACE_VERSION, 0x00, 0x00, 0x00);
	if (!rc) {
		if (ffa_partition_supports_direct_req2_recv(tpm_crb_ffa->ffa_dev)) {
			*major = CRB_FFA_MAJOR_VERSION(tpm_crb_ffa->direct_msg_data2.data[1]);
			*minor = CRB_FFA_MINOR_VERSION(tpm_crb_ffa->direct_msg_data2.data[1]);
		} else {
			*major = CRB_FFA_MAJOR_VERSION(tpm_crb_ffa->direct_msg_data.data2);
			*minor = CRB_FFA_MINOR_VERSION(tpm_crb_ffa->direct_msg_data.data2);
		}
	}

	return rc;
}
@@ -277,8 +304,9 @@ static int tpm_crb_ffa_probe(struct ffa_device *ffa_dev)

	tpm_crb_ffa = ERR_PTR(-ENODEV); // set tpm_crb_ffa so we can detect probe failure

	if (!ffa_partition_supports_direct_recv(ffa_dev)) {
		pr_err("TPM partition doesn't support direct message receive.\n");
	if (!ffa_partition_supports_direct_recv(ffa_dev) &&
	    !ffa_partition_supports_direct_req2_recv(ffa_dev)) {
		dev_warn(&ffa_dev->dev, "partition doesn't support direct message receive.\n");
		return -EINVAL;
	}

@@ -299,17 +327,17 @@ static int tpm_crb_ffa_probe(struct ffa_device *ffa_dev)
	rc = tpm_crb_ffa_get_interface_version(&tpm_crb_ffa->major_version,
					       &tpm_crb_ffa->minor_version);
	if (rc) {
		pr_err("failed to get crb interface version. rc:%d", rc);
		dev_err(&ffa_dev->dev, "failed to get crb interface version. rc:%d\n", rc);
		goto out;
	}

	pr_info("ABI version %u.%u", tpm_crb_ffa->major_version,
	dev_info(&ffa_dev->dev, "ABI version %u.%u\n", tpm_crb_ffa->major_version,
		tpm_crb_ffa->minor_version);

	if (tpm_crb_ffa->major_version != CRB_FFA_VERSION_MAJOR ||
	    (tpm_crb_ffa->minor_version > 0 &&
	    tpm_crb_ffa->minor_version < CRB_FFA_VERSION_MINOR)) {
		pr_err("Incompatible ABI version");
		dev_warn(&ffa_dev->dev, "Incompatible ABI version\n");
		goto out;
	}