Remove variable buffer size and partial reads from tpm.c
PATCH 1/1 Remove variable buffer size and partial reads from tpm.c
I am removing the experimental feature that allows buffer sizes for transfers from TPMs larger than 2kb. This could become useful if a vTPM is located in its owns domain and needs to be serialized for suspension or migration and the packet size becomes bigger than the current limit. Partial reads were supposed to complement this feature for applications to know how many bytes to read from /dev/tpm0.
The TSS stack that uses /dev/tpm0 does not rely on any of these changes and continues to work.
This makes the file equivalent to the one in 2.6.17.
Signed-off-by Stefan Berger <[email protected]>
xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm.c +0 -55
@@ -30,9 +30,7 @@enum tpm_const {TPM_MINOR =224 ,/* officially assigned */ -#ifndef CONFIG_XEN TPM_BUFSIZE =2048 , -#endif TPM_NUM_DEVICES =256 , };
@@ -333,11 +331,7 @@ static void timeout_work(void *ptr)down (&chip->buffer_mutex);atomic_set (&chip->data_pending,0 ); -#ifndef CONFIG_XEN memset (chip->data_buffer,0 ,TPM_BUFSIZE ); -#else -memset (chip->data_buffer,0 ,get_chip_buffersize (chip)); -#endif up (&chip->buffer_mutex); }
@@ -927,12 +921,7 @@ int tpm_open(struct inode *inode, structspin_unlock (&driver_lock); -#ifndef CONFIG_XEN chip->data_buffer =kmalloc (TPM_BUFSIZE *sizeof (u8),GFP_KERNEL ); -#else - chip->data_buffer =kmalloc (get_chip_buffersize (chip) *sizeof (u8), -GFP_KERNEL ); -#endif if (chip->data_buffer ==NULL ) { chip->num_opens--;put_device (chip->dev);
@@ -980,13 +969,8 @@ ssize_t tpm_write(struct file *file, condown (&chip->buffer_mutex); -#ifndef CONFIG_XEN if (in_size >TPM_BUFSIZE ) in_size =TPM_BUFSIZE ; -#else -if (in_size >get_chip_buffersize (chip)) - in_size =get_chip_buffersize (chip); -#endif if (copy_from_user (chip->data_buffer, (void __user *) buf, in_size)) {
@@ -995,17 +979,9 @@ ssize_t tpm_write(struct file *file, con }/* atomic tpm command send and result receive */ -#ifndef CONFIG_XEN out_size =tpm_transmit (chip, chip->data_buffer,TPM_BUFSIZE ); -#else - out_size =tpm_transmit (chip, chip->data_buffer, -get_chip_buffersize (chip)); -#endif atomic_set (&chip->data_pending, out_size); -#ifdef CONFIG_XEN -atomic_set (&chip->data_position,0 ); -#endif up (&chip->buffer_mutex);/* Set a timeout by which the reader must come claim the result */
@@ -1020,52 +996,21 @@ ssize_t tpm_read(struct file *file, char {struct tpm_chip *chip = file->private_data;int ret_size; -#ifdef CONFIG_XEN -int pos, pending =0 ; -#endif -#ifndef CONFIG_XEN del_singleshot_timer_sync (&chip->user_read_timer);flush_scheduled_work (); -#endif ret_size =atomic_read (&chip->data_pending); -#ifndef CONFIG_XEN atomic_set (&chip->data_pending,0 ); -#endif if (ret_size >0 ) {/* relay data */ if (size < ret_size) ret_size = size; -#ifdef CONFIG_XEN - pos =atomic_read (&chip->data_position); -#endif down (&chip->buffer_mutex); -#ifndef CONFIG_XEN if (copy_to_user (buf, chip->data_buffer, ret_size)) -#else -if (copy_to_user (buf, &chip->data_buffer[pos], ret_size)) { -#endif ret_size = -EFAULT ; -#ifdef CONFIG_XEN - }else { - pending =atomic_read (&chip->data_pending) - ret_size; -if ( pending ) { -atomic_set (&chip->data_pending, pending); -atomic_set (&chip->data_position, - pos+ret_size); - } - } -#endif up (&chip->buffer_mutex); } -#ifdef CONFIG_XEN -if ( ret_size <=0 || pending ==0 ) { -atomic_set (&chip->data_pending,0 ); -del_singleshot_timer_sync (&chip->user_read_timer); -flush_scheduled_work (); - } -#endif return ret_size; }EXPORT_SYMBOL_GPL (tpm_read);
xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm.h +0 -23
@@ -26,12 +26,6 @@#include <linux/platform_device.h> #include <linux/io.h> -#ifdef CONFIG_XEN -enum tpm_bufsize { -TPM_MIN_BUFFERSIZE =2048 , -TPM_MAX_BUFFERSIZE =64 *1024 , -}; -#endif enum tpm_timeout {TPM_TIMEOUT =5 ,/* msecs */
@@ -68,9 +62,6 @@ struct tpm_vendor_specific {const u8 req_complete_mask;const u8 req_complete_val;const u8 req_canceled; -#ifdef CONFIG_XEN -u32 buffersize; -#endif void __iomem *iobase;/* ioremapped address */ unsigned long base;/* TPM base address */
@@ -104,9 +95,6 @@ struct tpm_chip {/* Data passed to and from the tpm via the read/write calls */ u8 *data_buffer;atomic_t data_pending; -#ifdef CONFIG_XEN -atomic_t data_position; -#endif struct semaphore buffer_mutex;struct timer_list user_read_timer;/* user needs to claim result */
@@ -138,17 +126,6 @@ static inline void tpm_write_index(int b }#ifdef CONFIG_XEN -static inline u32 get_chip_buffersize (struct tpm_chip *chip) -{ -u32 size = chip->vendor.buffersize; -if (size >TPM_MAX_BUFFERSIZE ) { -return TPM_MAX_BUFFERSIZE ; - }else if (size <TPM_MIN_BUFFERSIZE ) { -return TPM_MIN_BUFFERSIZE ; - } -return size; -} -static inline void *chip_get_private (const struct tpm_chip *chip) {return chip->priv;
xen-unstable.hg/linux-2.6-xen-sparse/drivers/char/tpm/tpm_vtpm.c +0 -3
@@ -519,9 +519,6 @@ struct tpm_chip *init_vtpm(struct device vtpms->tpmvd = tvd; vtpms->tpm_private = tp; -if (tvd) - tpm_vtpm.buffersize = tvd->max_tx_size; - chip =tpm_register_hardware (dev, &tpm_vtpm);if (!chip) { rc = -ENODEV ;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel