summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGabe Black <gabeblack@chromium.org>2011-10-07 06:42:56 -0700
committerGabe Black (Do Not Use) <gabeblack@google.com>2011-10-11 16:08:13 -0700
commitcfb04c97ca4d3e6fb7e365dc784a044c813cac1a (patch)
tree908a845d4f9ae120a9d163c95564a0cf7d45132d /common
parent382230dc8b04fd4d3282223bc63609044ec16346 (diff)
Refactor the memory wipe infrastructure to better support x86
The memory wipe infrastructure in u-boot makes some assumptions about how memory is arranged that make it not quite fit with x86. Specifically, it assumes that there is a single region of memory, and with certain exceptions that's what should be wiped. In x86, specifically in the e820 map, there are multiple regions of RAM, possibly multiple regions to exclued from that that may completely, partially, or not overlap with the others, and then u-boot related regions. This is addressed by making the memory wipe infrastructure a little more generic. Now, areas can be added and subtracted arbitrarily, and will accumulate in the order they're encountered. In the x86 use case, we can add the e820 regions marked as RAM, subtract the areas marked as anything else, and subtract the u-boot related regions. Rather than tracking the actual regions of the address space, this implementation tracks the boundaries between the regions using a linked list. The code itself is short and relatively simple, and I tried to ensure that it was as clear as possible to make any memory (or other) bugs easier to see and fix. BUG=chrome-os-partner:6195 BUG=chrome-os-partner:6194 TEST=Built and booted on kaen using the A-A cable. Ran vboot_test memwipe, and a modified version that took advantage of the new API. Change-Id: I122fbf499ef473350afa27b612cb0e565366b1ad Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: http://gerrit.chromium.org/gerrit/9715 Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_vboot_test.c17
-rw-r--r--common/cmd_vboot_twostop.c21
2 files changed, 20 insertions, 18 deletions
diff --git a/common/cmd_vboot_test.c b/common/cmd_vboot_test.c
index 8521a62e03..ff8b9efbb3 100644
--- a/common/cmd_vboot_test.c
+++ b/common/cmd_vboot_test.c
@@ -123,21 +123,22 @@ static int do_vboot_test_memwipe(cmd_tbl_t *cmdtp,
const size_t size = strlen(s);
uintptr_t base = (uintptr_t)s;
- memory_wipe_init(&wipe, base, base + size);
+ memory_wipe_init(&wipe);
+ memory_wipe_add(&wipe, base, base + size);
/* Result: ---------- */
- memory_wipe_exclude(&wipe, base + 1, base + 2);
+ memory_wipe_sub(&wipe, base + 1, base + 2);
/* Result: -B-------- */
- memory_wipe_exclude(&wipe, base + 5, base + 7);
+ memory_wipe_sub(&wipe, base + 5, base + 7);
/* Result: -B---FG--- */
- memory_wipe_exclude(&wipe, base + 2, base + 3);
+ memory_wipe_sub(&wipe, base + 2, base + 3);
/* Result: -BC--FG--- */
- memory_wipe_exclude(&wipe, base + 9, base + 10);
+ memory_wipe_sub(&wipe, base + 9, base + 10);
/* Result: -BC--FG--J */
- memory_wipe_exclude(&wipe, base + 4, base + 6);
+ memory_wipe_sub(&wipe, base + 4, base + 6);
/* Result: -BC-EFG--J */
- memory_wipe_exclude(&wipe, base + 3, base + 5);
+ memory_wipe_sub(&wipe, base + 3, base + 5);
/* Result: -BCDEFG--J */
- memory_wipe_exclude(&wipe, base + 2, base + 8);
+ memory_wipe_sub(&wipe, base + 2, base + 8);
/* Result: -BCDEFGH-J */
memory_wipe_execute(&wipe);
diff --git a/common/cmd_vboot_twostop.c b/common/cmd_vboot_twostop.c
index d56b627141..9441041a83 100644
--- a/common/cmd_vboot_twostop.c
+++ b/common/cmd_vboot_twostop.c
@@ -178,27 +178,28 @@ wipe_unused_memory(crossystem_data_t *cdata, VbCommonParams *cparams)
if (fdt_decode_memory(gd->blob, &config))
VbExError(PREFIX "FDT decode memory section error\n");
- memory_wipe_init(&wipe, config.start, config.end);
+ memory_wipe_init(&wipe);
+ memory_wipe_add(&wipe, config.start, config.end);
/* Excludes stack, fdt, gd, bd, heap, u-boot, framebuffer, etc. */
- memory_wipe_exclude(&wipe, get_current_sp() - STACK_MARGIN, config.end);
+ memory_wipe_sub(&wipe, get_current_sp() - STACK_MARGIN, config.end);
/* Excludes the shared data between bootstub and main firmware. */
- memory_wipe_exclude(&wipe, (uintptr_t)cdata,
+ memory_wipe_sub(&wipe, (uintptr_t)cdata,
(uintptr_t)cdata + sizeof(*cdata));
- memory_wipe_exclude(&wipe, (uintptr_t)cparams->gbb_data,
+ memory_wipe_sub(&wipe, (uintptr_t)cparams->gbb_data,
(uintptr_t)cparams->gbb_data + cparams->gbb_size);
/* Excludes the LP0 vector. */
- memory_wipe_exclude(&wipe,
- (uintptr_t)TEGRA_LP0_ADDR,
- (uintptr_t)(TEGRA_LP0_ADDR + TEGRA_LP0_SIZE));
+ memory_wipe_sub(&wipe,
+ (uintptr_t)TEGRA_LP0_ADDR,
+ (uintptr_t)(TEGRA_LP0_ADDR + TEGRA_LP0_SIZE));
/* Excludes the frame buffer. */
fb_size = lcd_get_size(&lcd_line_length);
- memory_wipe_exclude(&wipe,
- (uintptr_t)gd->fb_base,
- (uintptr_t)gd->fb_base + fb_size);
+ memory_wipe_sub(&wipe,
+ (uintptr_t)gd->fb_base,
+ (uintptr_t)gd->fb_base + fb_size);
memory_wipe_execute(&wipe);
#endif