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

Commit b4cb3527 authored by Patrick Daly's avatar Patrick Daly
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>
parent bba41e29
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -212,6 +212,9 @@ struct 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
};

/*
@@ -276,6 +279,13 @@ static u32 syslog_oops_buf_idx;
static const char log_oops_end[] = "---end of oops log buffer---";
#endif

#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

/* cpu currently holding logbuf_lock */
static volatile unsigned int logbuf_cpu = UINT_MAX;

@@ -434,6 +444,7 @@ static void log_store(int facility, int level,
		 * to signify a wrap around.
		 */
		memset(log_buf + log_next_idx, 0, sizeof(struct log));
		LOG_MAGIC((struct log *)(log_buf + log_next_idx));
		log_next_idx = 0;
	}

@@ -446,6 +457,7 @@ static void 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
@@ -1509,6 +1509,15 @@ config OOPS_LOG_BUFFER
	  allow wrap around but preserve the first oops and onward kernel
	  messages until buffer becomes full.

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 OOPS_LOG_BUF_SHIFT
	int "Oops log buffer size (16 => 64KB, 17 => 128KB)"
	depends on OOPS_LOG_BUFFER