Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f738cb7 authored by Patrick Daly's avatar Patrick Daly Committed by Matt Wagantall
Browse files

printk: Add LOG_BUF_MAGIC



Enable post-mortem ramdump analysis to retrieve the valid portions of the
log buffer in the event that portions are corrupted.

Change-Id: Icc47bdb5c030d8548509d14c8016892cc393dafa
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
[abhimany: resolve trivial merge conflicts]
Signed-off-by: default avatarAbhimanyu Kapur <abhimany@codeaurora.org>
parent 6672b849
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -227,6 +227,9 @@ struct printk_log {
	u8 facility;		/* syslog facility */
	u8 flags:5;		/* internal record flags */
	u8 level:3;		/* syslog level */
#if defined(CONFIG_LOG_BUF_MAGIC)
	u32 magic;		/* handle for ramdump analysis tools */
#endif
};

/*
@@ -286,6 +289,12 @@ u32 log_buf_len_get(void)
{
	return log_buf_len;
}
#if defined(CONFIG_LOG_BUF_MAGIC)
static u32 __log_align __used = LOG_ALIGN;
#define LOG_MAGIC(msg) ((msg)->magic = 0x5d7aefca)
#else
#define LOG_MAGIC(msg)
#endif

/* human readable text of the record */
static char *log_text(const struct printk_log *msg)
@@ -440,6 +449,7 @@ static int log_store(int facility, int level,
		 * to signify a wrap around.
		 */
		memset(log_buf + log_next_idx, 0, sizeof(struct printk_log));
		LOG_MAGIC((struct printk_log *)(log_buf + log_next_idx));
		log_next_idx = 0;
	}

@@ -456,6 +466,7 @@ static int log_store(int facility, int level,
	msg->facility = facility;
	msg->level = level & 7;
	msg->flags = flags & 0x1f;
	LOG_MAGIC(msg);
	if (ts_nsec > 0)
		msg->ts_nsec = ts_nsec;
	else
+9 −0
Original line number Diff line number Diff line
@@ -26,6 +26,15 @@ config MESSAGE_LOGLEVEL_DEFAULT
	  that are auditing their logs closely may want to set it to a lower
	  priority.

config LOG_BUF_MAGIC
	bool "Recovery of partially corrupted dmesg from ramdumps"
	depends on PRINTK
	help
	  Select this option to add a magic number to the log buf record. In the
	  event that a log buf record is corrupted, post-mortem crash analysis
	  tools may use this magic number to search for the next noncorrupted
	  log record.

config BOOT_PRINTK_DELAY
	bool "Delay each boot printk message by N milliseconds"
	depends on DEBUG_KERNEL && PRINTK && GENERIC_CALIBRATE_DELAY