diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
index cd1683dad3bf..fb65ba9426a1 100644
--- a/security/integrity/ima/ima_fs.c
+++ b/security/integrity/ima/ima_fs.c
@@ -116,9 +116,12 @@ void ima_putc(struct seq_file *m, void *data, int datalen)
 		seq_putc(m, *(char *)data++);
 }
 
+static struct dentry **ima_ascii_measurements_files;
+static struct dentry **ima_binary_measurements_files;
+
 /* print format:
  *       32bit-le=pcr#
- *       char[20]=template digest
+ *       char[n]=template digest
  *       32bit-le=template name size
  *       char[n]=template name
  *       [eventdata length]
@@ -130,9 +133,25 @@ int ima_measurements_show(struct seq_file *m, void *v)
 	struct ima_queue_entry *qe = v;
 	struct ima_template_entry *e;
 	char *template_name;
+	struct dentry *dentry;
 	u32 pcr, namelen, template_data_len; /* temporary fields */
 	bool is_ima_template = false;
-	int i;
+	int i, algo_idx;
+	enum hash_algo algo;
+
+	dentry = m->file->f_path.dentry;
+	algo_idx = ima_sha1_idx;
+	algo = HASH_ALGO_SHA1;
+
+	if (ima_tpm_chip) {
+		for (i = 0; i < NR_BANKS(ima_tpm_chip); i++) {
+			if (dentry == ima_binary_measurements_files[i]) {
+				algo_idx = i;
+				algo = ima_tpm_chip->allocated_banks[i].crypto_id;
+				break;
+			}
+		}
+	}
 
 	/* get entry */
 	e = qe->entry;
@@ -151,7 +170,7 @@ int ima_measurements_show(struct seq_file *m, void *v)
 	ima_putc(m, &pcr, sizeof(e->pcr));
 
 	/* 2nd: template digest */
-	ima_putc(m, e->digests[ima_sha1_idx].digest, TPM_DIGEST_SIZE);
+	ima_putc(m, e->digests[algo_idx].digest, hash_digest_size[algo]);
 
 	/* 3rd: template name size */
 	namelen = !ima_canonical_fmt ? strlen(template_name) :
@@ -220,7 +239,23 @@ static int ima_ascii_measurements_show(struct seq_file *m, void *v)
 	struct ima_queue_entry *qe = v;
 	struct ima_template_entry *e;
 	char *template_name;
-	int i;
+	struct dentry *dentry;
+	int i, algo_idx;
+	enum hash_algo algo;
+
+	dentry = m->file->f_path.dentry;
+	algo_idx = ima_sha1_idx;
+	algo = HASH_ALGO_SHA1;
+
+	if (ima_tpm_chip) {
+		for (i = 0; i < NR_BANKS(ima_tpm_chip); i++) {
+			if (dentry == ima_ascii_measurements_files[i]) {
+				algo_idx = i;
+				algo = ima_tpm_chip->allocated_banks[i].crypto_id;
+				break;
+			}
+		}
+	}
 
 	/* get entry */
 	e = qe->entry;
@@ -233,8 +268,8 @@ static int ima_ascii_measurements_show(struct seq_file *m, void *v)
 	/* 1st: PCR used (config option) */
 	seq_printf(m, "%2d ", e->pcr);
 
-	/* 2nd: SHA1 template hash */
-	ima_print_digest(m, e->digests[ima_sha1_idx].digest, TPM_DIGEST_SIZE);
+	/* 2nd: template hash */
+	ima_print_digest(m, e->digests[algo_idx].digest, hash_digest_size[algo]);
 
 	/* 3th:  template name */
 	seq_printf(m, " %s", template_name);
@@ -379,6 +414,84 @@ static const struct seq_operations ima_policy_seqops = {
 };
 #endif
 
+/*
+ * Remove the securityfs files created for each hash algo configured
+ * in the TPM, excluded ascii_runtime_measurements and
+ * binary_runtime_measurements.
+ */
+static void remove_measurements_list_files(struct dentry **files)
+{
+	int i, len;
+	len = ima_tpm_chip ? NR_BANKS(ima_tpm_chip) : 1;
+
+	if (files)
+	{
+		for (i = 0; i < len; i++) {
+			if (files[i]) {
+				securityfs_remove(files[i]);
+			}
+		}
+
+		kfree(files);
+	}
+}
+
+/*
+ * Allocate a file in the securityfs for each hash algo configured
+ * in the TPM (for ascii and binary output). In case no TPM chip is
+ * detected only sha1 files are created.
+ */
+static int create_measurements_list_files(void)
+{	
+	int i, len;
+	u16 algo;
+	char file_name[NAME_MAX+1];
+	struct dentry *dfile;
+
+	/* 
+	 * Allocate NR_BANKS(ima_tpm_chip) files in case a tpm chip is detected,
+	 * otherwise allocate just one file for sha1.
+	 */
+	len = ima_tpm_chip ? NR_BANKS(ima_tpm_chip) : 1;
+
+	ima_ascii_measurements_files = kmalloc_array(len,
+				sizeof(struct dentry *), GFP_KERNEL);
+	if(!ima_ascii_measurements_files)
+		return -ENOMEM;
+
+	ima_binary_measurements_files = kmalloc_array(len,
+				sizeof(struct dentry *), GFP_KERNEL);
+	if(!ima_binary_measurements_files)
+		return -ENOMEM;
+
+	for (i = 0; i < len; i++) {
+		algo = ima_tpm_chip ? ima_tpm_chip->allocated_banks[i].crypto_id :
+								HASH_ALGO_SHA1;
+
+		sprintf(file_name, "ascii_runtime_measurements_%s",
+					hash_algo_name[algo]);
+		dfile = securityfs_create_file(file_name,
+					S_IRUSR | S_IRGRP, ima_dir, NULL,
+					&ima_ascii_measurements_ops);
+		if (IS_ERR(dfile))
+			return PTR_ERR(dfile);
+
+		ima_ascii_measurements_files[i] = dfile;
+
+		sprintf(file_name, "binary_runtime_measurements_%s",
+					hash_algo_name[algo]);
+		dfile = securityfs_create_file(file_name,
+					S_IRUSR | S_IRGRP, ima_dir, NULL,
+					&ima_measurements_ops);
+		if (IS_ERR(dfile))
+			return PTR_ERR(dfile);
+
+		ima_binary_measurements_files[i] = dfile;
+	}
+
+	return 0;
+}
+
 /*
  * ima_open_policy: sequentialize access to the policy file
  */
@@ -465,19 +578,21 @@ int __init ima_fs_init(void)
 		goto out;
 	}
 
-	binary_runtime_measurements =
-	    securityfs_create_file("binary_runtime_measurements",
-				   S_IRUSR | S_IRGRP, ima_dir, NULL,
-				   &ima_measurements_ops);
+	ret = create_measurements_list_files();
+	if (ret != 0)
+		goto out;
+
+	binary_runtime_measurements = securityfs_create_symlink(
+		"binary_runtime_measurements", ima_dir, 
+		"binary_runtime_measurements_sha1", NULL);
 	if (IS_ERR(binary_runtime_measurements)) {
 		ret = PTR_ERR(binary_runtime_measurements);
 		goto out;
 	}
 
-	ascii_runtime_measurements =
-	    securityfs_create_file("ascii_runtime_measurements",
-				   S_IRUSR | S_IRGRP, ima_dir, NULL,
-				   &ima_ascii_measurements_ops);
+	ascii_runtime_measurements = securityfs_create_symlink(
+		"ascii_runtime_measurements", ima_dir,
+		"ascii_runtime_measurements_sha1", NULL);
 	if (IS_ERR(ascii_runtime_measurements)) {
 		ret = PTR_ERR(ascii_runtime_measurements);
 		goto out;
@@ -515,6 +630,8 @@ int __init ima_fs_init(void)
 	securityfs_remove(runtime_measurements_count);
 	securityfs_remove(ascii_runtime_measurements);
 	securityfs_remove(binary_runtime_measurements);
+	remove_measurements_list_files(ima_ascii_measurements_files);
+	remove_measurements_list_files(ima_binary_measurements_files);
 	securityfs_remove(ima_symlink);
 	securityfs_remove(ima_dir);

