All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] x86: ivybridge: Fix saving mrc cache and enable it
@ 2015-10-12  8:30 Bin Meng
  2015-10-12  8:30 ` [U-Boot] [PATCH 2/3] x86: quark: Implement mrc cache Bin Meng
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Bin Meng @ 2015-10-12  8:30 UTC (permalink / raw)
  To: u-boot

Currently sdram_initialise() saves pei_data->mrc_output directly to
gd->arch.mrc_output. This is incorrect as pei_data->mrc_output points
to an address on the stack whose content is no longer valid when we
call mrccache_reserve(). To fix this, save it on the heap instead.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 arch/x86/cpu/ivybridge/sdram.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/cpu/ivybridge/sdram.c b/arch/x86/cpu/ivybridge/sdram.c
index fc66a3c..f3d97ca 100644
--- a/arch/x86/cpu/ivybridge/sdram.c
+++ b/arch/x86/cpu/ivybridge/sdram.c
@@ -151,14 +151,8 @@ static int prepare_mrc_cache(struct pei_data *pei_data)
 	if (!mrc_cache)
 		return -ENOENT;
 
-	/*
-	 * TODO(sjg at chromium.org): Skip this for now as it causes boot
-	 * problems
-	 */
-	if (0) {
-		pei_data->mrc_input = mrc_cache->data;
-		pei_data->mrc_input_len = mrc_cache->data_size;
-	}
+	pei_data->mrc_input = mrc_cache->data;
+	pei_data->mrc_input_len = mrc_cache->data_size;
 	debug("%s: at %p, size %x checksum %04x\n", __func__,
 	      pei_data->mrc_input, pei_data->mrc_input_len,
 	      mrc_cache->checksum);
@@ -289,6 +283,7 @@ int sdram_initialise(struct pei_data *pei_data)
 	unsigned version;
 	const char *data;
 	uint16_t done;
+	char *cache;
 	int ret;
 
 	report_platform_info();
@@ -386,8 +381,13 @@ int sdram_initialise(struct pei_data *pei_data)
 		 * This will be copied to SDRAM in reserve_arch(), then written
 		 * to SPI flash in mrccache_save()
 		 */
-		gd->arch.mrc_output = (char *)pei_data->mrc_output;
-		gd->arch.mrc_output_len = pei_data->mrc_output_len;
+		cache = malloc(pei_data->mrc_output_len);
+		if (cache) {
+			memcpy(cache, pei_data->mrc_output,
+			       pei_data->mrc_output_len);
+			gd->arch.mrc_output = cache;
+			gd->arch.mrc_output_len = pei_data->mrc_output_len;
+		}
 		ret = write_seeds_to_cmos(pei_data);
 		if (ret)
 			debug("Failed to write seeds to CMOS: %d\n", ret);
-- 
1.8.2.1

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

end of thread, other threads:[~2015-10-19  2:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-12  8:30 [U-Boot] [PATCH 1/3] x86: ivybridge: Fix saving mrc cache and enable it Bin Meng
2015-10-12  8:30 ` [U-Boot] [PATCH 2/3] x86: quark: Implement mrc cache Bin Meng
2015-10-18 20:27   ` Simon Glass
2015-10-18 21:39     ` Simon Glass
2015-10-12  8:30 ` [U-Boot] [PATCH 3/3] x86: galileo: Enable " Bin Meng
2015-10-18 20:27   ` Simon Glass
2015-10-18 21:39     ` Simon Glass
2015-10-18 20:27 ` [U-Boot] [PATCH 1/3] x86: ivybridge: Fix saving mrc cache and enable it Simon Glass
2015-10-19  2:44   ` Bin Meng
2015-10-19  2:51     ` Simon Glass
2015-10-19  2:55       ` Bin Meng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.