Commit a65d1a06c9f76d3285948a059b861d7534589cfc

Authored by Simon Glass
1 parent 2a07269062

sandbox: Zero the ram buffer on startup

At present the RAM buffer is not inited unless it is read from a file,
likely produced by an earlier phase of U-Boot. This causes valgrind
warnings whenever the RAM buffer is used. Correct this by initing it if
needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 8 additions and 0 deletions Side-by-side Diff

arch/sandbox/cpu/start.c
... ... @@ -180,6 +180,7 @@
180 180 printf("Failed to read RAM buffer '%s': %d\n", arg, err);
181 181 return err;
182 182 }
  183 + state->ram_buf_read = true;
183 184  
184 185 return 0;
185 186 }
... ... @@ -301,6 +302,12 @@
301 302  
302 303 static void setup_ram_buf(struct sandbox_state *state)
303 304 {
  305 + /* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
  306 + if (!state->ram_buf_read) {
  307 + memset(state->ram_buf, '\0', state->ram_size);
  308 + printf("clear %p %x\n", state->ram_buf, state->ram_size);
  309 + }
  310 +
304 311 gd->arch.ram_buf = state->ram_buf;
305 312 gd->ram_size = state->ram_size;
306 313 }
arch/sandbox/include/asm/state.h
... ... @@ -90,6 +90,7 @@
90 90 bool show_test_output; /* Don't suppress stdout in tests */
91 91 int default_log_level; /* Default log level for sandbox */
92 92 bool show_of_platdata; /* Show of-platdata in SPL */
  93 + bool ram_buf_read; /* true if we read the RAM buffer */
93 94  
94 95 /* Pointer to information for each SPI bus/cs */
95 96 struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]