linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vTPM: fix memory allocation flag for rtce buffer at kernel boot
@ 2015-10-08  0:10 Hon Ching(Vicky) Lo
  2015-10-08  0:10 ` [PATCH v2 1/3] vTPM: fix searching for the right vTPM node in device tree Hon Ching(Vicky) Lo
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hon Ching(Vicky) Lo @ 2015-10-08  0:10 UTC (permalink / raw)
  To: lo1; +Cc: linux-kernel, Hon Ching(Vicky) Lo

At ibm vtpm initialzation, tpm_ibmvtpm_probe() registers its interrupt
handler, ibmvtpm_interrupt, which calls ibmvtpm_crq_process to allocate
memory for rtce buffer.  The current code uses 'GFP_KERNEL' as the
type of kernel memory allocation, which resulted a warning at
kernel/lockdep.c.  This patch uses 'GFP_ATOMIC' instead so that the
allocation is high-priority and does not sleep.

Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>
---
 drivers/char/tpm/tpm_ibmvtpm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index 27ebf95..3e6a226 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -491,7 +491,7 @@ static void ibmvtpm_crq_process(struct ibmvtpm_crq *crq,
 			}
 			ibmvtpm->rtce_size = be16_to_cpu(crq->len);
 			ibmvtpm->rtce_buf = kmalloc(ibmvtpm->rtce_size,
-						    GFP_KERNEL);
+						    GFP_ATOMIC);
 			if (!ibmvtpm->rtce_buf) {
 				dev_err(ibmvtpm->dev, "Failed to allocate memory for rtce buffer\n");
 				return;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] vTPM: fix searching for the right vTPM node in device tree
  2015-10-08  0:10 [PATCH] vTPM: fix memory allocation flag for rtce buffer at kernel boot Hon Ching(Vicky) Lo
@ 2015-10-08  0:10 ` Hon Ching(Vicky) Lo
  2015-10-08  0:10 ` [PATCH v2 2/3] vTPM: reformat event log to be byte-aligned Hon Ching(Vicky) Lo
  2015-10-08  0:10 ` [PATCH v2 3/3] vTPM: get the buffer allocated for event log instead of the actual log Hon Ching(Vicky) Lo
  2 siblings, 0 replies; 5+ messages in thread
From: Hon Ching(Vicky) Lo @ 2015-10-08  0:10 UTC (permalink / raw)
  To: lo1; +Cc: linux-kernel, Hon Ching(Vicky) Lo

Replace all occurrences of '/ibm,vtpm' with '/vdevice/vtpm',
as only the latter is ganranteed to be available for the client OS.
The '/ibm,vtpm' node should only be used by Open Firmware, which
is susceptible to changes.

Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/prom_init.c |    8 ++++----
 drivers/char/tpm/tpm_of.c       |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 1a85d8f..b9b6bb1 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1422,12 +1422,12 @@ static void __init prom_instantiate_sml(void)
 
 	prom_debug("prom_instantiate_sml: start...\n");
 
-	ibmvtpm_node = call_prom("finddevice", 1, 1, ADDR("/ibm,vtpm"));
+	ibmvtpm_node = call_prom("finddevice", 1, 1, ADDR("/vdevice/vtpm"));
 	prom_debug("ibmvtpm_node: %x\n", ibmvtpm_node);
 	if (!PHANDLE_VALID(ibmvtpm_node))
 		return;
 
-	ibmvtpm_inst = call_prom("open", 1, 1, ADDR("/ibm,vtpm"));
+	ibmvtpm_inst = call_prom("open", 1, 1, ADDR("/vdevice/vtpm"));
 	if (!IHANDLE_VALID(ibmvtpm_inst)) {
 		prom_printf("opening vtpm package failed (%x)\n", ibmvtpm_inst);
 		return;
@@ -1456,9 +1456,9 @@ static void __init prom_instantiate_sml(void)
 
 	reserve_mem(base, size);
 
-	prom_setprop(ibmvtpm_node, "/ibm,vtpm", "linux,sml-base",
+	prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-base",
 		     &base, sizeof(base));
-	prom_setprop(ibmvtpm_node, "/ibm,vtpm", "linux,sml-size",
+	prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-size",
 		     &size, sizeof(size));
 
 	prom_debug("sml base     = 0x%x\n", base);
diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c
index 62a22ce..6c73199 100644
--- a/drivers/char/tpm/tpm_of.c
+++ b/drivers/char/tpm/tpm_of.c
@@ -31,7 +31,7 @@ int read_log(struct tpm_bios_log *log)
 		return -EFAULT;
 	}
 
-	np = of_find_node_by_name(NULL, "ibm,vtpm");
+	np = of_find_node_by_name(NULL, "vtpm");
 	if (!np) {
 		pr_err("%s: ERROR - IBMVTPM not supported\n", __func__);
 		return -ENODEV;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] vTPM: reformat event log to be byte-aligned
  2015-10-08  0:10 [PATCH] vTPM: fix memory allocation flag for rtce buffer at kernel boot Hon Ching(Vicky) Lo
  2015-10-08  0:10 ` [PATCH v2 1/3] vTPM: fix searching for the right vTPM node in device tree Hon Ching(Vicky) Lo
@ 2015-10-08  0:10 ` Hon Ching(Vicky) Lo
  2015-10-08  0:10 ` [PATCH v2 3/3] vTPM: get the buffer allocated for event log instead of the actual log Hon Ching(Vicky) Lo
  2 siblings, 0 replies; 5+ messages in thread
From: Hon Ching(Vicky) Lo @ 2015-10-08  0:10 UTC (permalink / raw)
  To: lo1; +Cc: linux-kernel, Hon Ching(Vicky) Lo

The event log generated by OpenFirmware in PowerPC is 4-byte aligned.
This patch reformats the log to be byte-aligned for the Linux client.

Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/prom_init.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index b9b6bb1..8a5c248 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1417,8 +1417,9 @@ static void __init prom_instantiate_sml(void)
 {
 	phandle ibmvtpm_node;
 	ihandle ibmvtpm_inst;
-	u32 entry = 0, size = 0;
+	u32 entry = 0, size = 0, succ = 0;
 	u64 base;
+	__be32 val;
 
 	prom_debug("prom_instantiate_sml: start...\n");
 
@@ -1433,6 +1434,16 @@ static void __init prom_instantiate_sml(void)
 		return;
 	}
 
+	if (prom_getprop(ibmvtpm_node, "ibm,sml-efi-reformat-supported",
+			 &val, sizeof(val)) != PROM_ERROR) {
+		if (call_prom_ret("call-method", 2, 2, &succ,
+				  ADDR("reformat-sml-to-efi-alignment"),
+				  ibmvtpm_inst) != 0 || succ == 0) {
+			prom_printf("Reformat SML to EFI alignment failed\n");
+			return;
+		}
+	}
+
 	if (call_prom_ret("call-method", 2, 2, &size,
 			  ADDR("sml-get-handover-size"),
 			  ibmvtpm_inst) != 0 || size == 0) {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] vTPM: get the buffer allocated for event log instead of the actual log
  2015-10-08  0:10 [PATCH] vTPM: fix memory allocation flag for rtce buffer at kernel boot Hon Ching(Vicky) Lo
  2015-10-08  0:10 ` [PATCH v2 1/3] vTPM: fix searching for the right vTPM node in device tree Hon Ching(Vicky) Lo
  2015-10-08  0:10 ` [PATCH v2 2/3] vTPM: reformat event log to be byte-aligned Hon Ching(Vicky) Lo
@ 2015-10-08  0:10 ` Hon Ching(Vicky) Lo
  2 siblings, 0 replies; 5+ messages in thread
From: Hon Ching(Vicky) Lo @ 2015-10-08  0:10 UTC (permalink / raw)
  To: lo1; +Cc: linux-kernel, Hon Ching(Vicky) Lo

The OS should ask Power Firmware (PFW) for the size of the buffer
allocated for the event log, instead of the size of the actual
event log.  It then passes the buffer adddress and size to PFW in
the handover process, into which PFW copies the log.

Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/prom_init.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 8a5c248..08fe5e7 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1442,13 +1442,20 @@ static void __init prom_instantiate_sml(void)
 			prom_printf("Reformat SML to EFI alignment failed\n");
 			return;
 		}
-	}
 
-	if (call_prom_ret("call-method", 2, 2, &size,
-			  ADDR("sml-get-handover-size"),
-			  ibmvtpm_inst) != 0 || size == 0) {
-		prom_printf("SML get handover size failed\n");
-		return;
+		if (call_prom_ret("call-method", 2, 2, &size,
+				  ADDR("sml-get-allocated-size"),
+				  ibmvtpm_inst) != 0 || size == 0) {
+			prom_printf("SML get allocated size failed\n");
+			return;
+		}
+	} else {
+		if (call_prom_ret("call-method", 2, 2, &size,
+				  ADDR("sml-get-handover-size"),
+				  ibmvtpm_inst) != 0 || size == 0) {
+			prom_printf("SML get handover size failed\n");
+			return;
+		}
 	}
 
 	base = alloc_down(size, PAGE_SIZE, 0);
@@ -1457,6 +1464,8 @@ static void __init prom_instantiate_sml(void)
 
 	prom_printf("instantiating sml at 0x%x...", base);
 
+	memset((void *)base, 0, size);
+
 	if (call_prom_ret("call-method", 4, 2, &entry,
 			  ADDR("sml-handover"),
 			  ibmvtpm_inst, size, base) != 0 || entry == 0) {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] vTPM: fix searching for the right vTPM node in device tree
  2015-10-08  0:11 [PATCH] vTPM: fix memory allocation flag for rtce buffer at kernel boot Hon Ching(Vicky) Lo
@ 2015-10-08  0:11 ` Hon Ching(Vicky) Lo
  0 siblings, 0 replies; 5+ messages in thread
From: Hon Ching(Vicky) Lo @ 2015-10-08  0:11 UTC (permalink / raw)
  To: tpmdd-devel
  Cc: Peter Huewe, Ashley Lai, Mimi Zohar, Vicky Lo, linux-kernel,
	Hon Ching(Vicky) Lo

Replace all occurrences of '/ibm,vtpm' with '/vdevice/vtpm',
as only the latter is ganranteed to be available for the client OS.
The '/ibm,vtpm' node should only be used by Open Firmware, which
is susceptible to changes.

Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/prom_init.c |    8 ++++----
 drivers/char/tpm/tpm_of.c       |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 1a85d8f..b9b6bb1 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -1422,12 +1422,12 @@ static void __init prom_instantiate_sml(void)
 
 	prom_debug("prom_instantiate_sml: start...\n");
 
-	ibmvtpm_node = call_prom("finddevice", 1, 1, ADDR("/ibm,vtpm"));
+	ibmvtpm_node = call_prom("finddevice", 1, 1, ADDR("/vdevice/vtpm"));
 	prom_debug("ibmvtpm_node: %x\n", ibmvtpm_node);
 	if (!PHANDLE_VALID(ibmvtpm_node))
 		return;
 
-	ibmvtpm_inst = call_prom("open", 1, 1, ADDR("/ibm,vtpm"));
+	ibmvtpm_inst = call_prom("open", 1, 1, ADDR("/vdevice/vtpm"));
 	if (!IHANDLE_VALID(ibmvtpm_inst)) {
 		prom_printf("opening vtpm package failed (%x)\n", ibmvtpm_inst);
 		return;
@@ -1456,9 +1456,9 @@ static void __init prom_instantiate_sml(void)
 
 	reserve_mem(base, size);
 
-	prom_setprop(ibmvtpm_node, "/ibm,vtpm", "linux,sml-base",
+	prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-base",
 		     &base, sizeof(base));
-	prom_setprop(ibmvtpm_node, "/ibm,vtpm", "linux,sml-size",
+	prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-size",
 		     &size, sizeof(size));
 
 	prom_debug("sml base     = 0x%x\n", base);
diff --git a/drivers/char/tpm/tpm_of.c b/drivers/char/tpm/tpm_of.c
index 62a22ce..6c73199 100644
--- a/drivers/char/tpm/tpm_of.c
+++ b/drivers/char/tpm/tpm_of.c
@@ -31,7 +31,7 @@ int read_log(struct tpm_bios_log *log)
 		return -EFAULT;
 	}
 
-	np = of_find_node_by_name(NULL, "ibm,vtpm");
+	np = of_find_node_by_name(NULL, "vtpm");
 	if (!np) {
 		pr_err("%s: ERROR - IBMVTPM not supported\n", __func__);
 		return -ENODEV;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-08  0:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-08  0:10 [PATCH] vTPM: fix memory allocation flag for rtce buffer at kernel boot Hon Ching(Vicky) Lo
2015-10-08  0:10 ` [PATCH v2 1/3] vTPM: fix searching for the right vTPM node in device tree Hon Ching(Vicky) Lo
2015-10-08  0:10 ` [PATCH v2 2/3] vTPM: reformat event log to be byte-aligned Hon Ching(Vicky) Lo
2015-10-08  0:10 ` [PATCH v2 3/3] vTPM: get the buffer allocated for event log instead of the actual log Hon Ching(Vicky) Lo
  -- strict thread matches above, loose matches on Subject: below --
2015-10-08  0:11 [PATCH] vTPM: fix memory allocation flag for rtce buffer at kernel boot Hon Ching(Vicky) Lo
2015-10-08  0:11 ` [PATCH v2 1/3] vTPM: fix searching for the right vTPM node in device tree Hon Ching(Vicky) Lo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).