CHROMIUM: ramoops: Copy the entire buffer to deal with bit rot
authorSameer Nanda <snanda@chromium.org>
Tue, 4 Sep 2012 20:50:13 +0000 (13:50 -0700)
committerGerrit <chrome-bot@google.com>
Wed, 5 Sep 2012 17:58:33 +0000 (10:58 -0700)
If unclean shutdown is done by yanking power rails, the RAM may be in a
state where it is not getting refreshed for a short period of time. This
can cause bit rotting in RAM and throw off the wraparound and buffer
size calculation logic. To get around this, copy the entire console
buffer. Note that this, of course, won't do anything to fix the bit
rotting but the intent here is that some logs are better than none.

BUG=chrome-os-partner:13249
TEST=on a snow or link system do a warm reboot by pressing
alt-volume_up-r keys together. The system should reboot. Upon bootup,
check contents of "/dev/pstore/console-ramoops" and ensure they are from
dmesg of the previous boot.

Change-Id: I68b2b10a6b3fc29329979cc0c659b440436b771f
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/32180
Reviewed-by: Doug Anderson <dianders@chromium.org>
drivers/char/ramoops.c

index fa353e3..fde9138 100644 (file)
@@ -119,10 +119,16 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
 
        rambuf = cxt->virt_addr + (*id * cxt->record_size);
 #ifdef CONFIG_PSTORE_CONSOLE
-       if (*type == PSTORE_TYPE_CONSOLE)
+       if (*type == PSTORE_TYPE_CONSOLE) {
                rambuf = cxt->old_con_buf;
-#endif
+               /* Grab entire record to deal with RAM bit rot. */
+               size = cxt->record_size;
+       } else {
+               size = strnlen(rambuf, cxt->record_size);
+       }
+#else
        size = strnlen(rambuf, cxt->record_size);
+#endif
        *buf = kmalloc(size, GFP_KERNEL);
        if (*buf == NULL)
                return -ENOMEM;