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

Commit 1b3fc0be authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull pstore subsystem updates from Kees Cook:
 "This expands the supported compressors, fixes some bugs, and finally
  adds DT bindings"

* tag 'pstore-v4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  pstore/ram: add Device Tree bindings
  efi-pstore: implement efivars_pstore_exit()
  pstore: drop file opened reference count
  pstore: add lzo/lz4 compression support
  pstore: Cleanup pstore_dump()
  pstore: Enable compression on normal path (again)
  ramoops: Only unregister when registered
parents d31dcd92 74e630a7
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
Ramoops oops/panic logger
=========================

ramoops provides persistent RAM storage for oops and panics, so they can be
recovered after a reboot. It is a backend to pstore, so this node is named
"ramoops" after the backend, rather than "pstore" which is the subsystem.

Parts of this storage may be set aside for other persistent log buffers, such
as kernel log messages, or for optional ECC error-correction data.  The total
size of these optional buffers must fit in the reserved region.

Any remaining space will be used for a circular buffer of oops and panic
records.  These records have a configurable size, with a size of 0 indicating
that they should be disabled.

At least one of "record-size", "console-size", "ftrace-size", or "pmsg-size"
must be set non-zero, but are otherwise optional as listed below.


Required properties:

- compatible: must be "ramoops"

- memory-region: phandle to a region of memory that is preserved between
  reboots


Optional properties:

- ecc-size: enables ECC support and specifies ECC buffer size in bytes
  (defaults to 0: no ECC)

- record-size: maximum size in bytes of each dump done on oops/panic
  (defaults to 0: disabled)

- console-size: size in bytes of log buffer reserved for kernel messages
  (defaults to 0: disabled)

- ftrace-size: size in bytes of log buffer reserved for function tracing and
  profiling (defaults to 0: disabled)

- pmsg-size: size in bytes of log buffer reserved for userspace messages
  (defaults to 0: disabled)

- unbuffered: if present, use unbuffered mappings to map the reserved region
  (defaults to buffered mappings)

- no-dump-oops: if present, only dump panics (defaults to panics and oops)
+4 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ corrupt, but usually it is restorable.

2. Setting the parameters

Setting the ramoops parameters can be done in 2 different manners:
Setting the ramoops parameters can be done in 3 different manners:
 1. Use the module parameters (which have the names of the variables described
 as before).
 For quick debugging, you can also reserve parts of memory during boot
@@ -54,7 +54,9 @@ Setting the ramoops parameters can be done in 2 different manners:
 kernel to use only the first 128 MB of memory, and place ECC-protected ramoops
 region at 128 MB boundary:
 "mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1"
 2. Use a platform device and set the platform data. The parameters can then
 2. Use Device Tree bindings, as described in
 Documentation/device-tree/bindings/misc/ramoops.txt.
 3. Use a platform device and set the platform data. The parameters can then
 be set through that platform data. An example of doing that is:

#include <linux/pstore_ram.h>
+3 −1
Original line number Diff line number Diff line
@@ -444,7 +444,8 @@ static int nvram_pstore_write(enum pstore_type_id type,
 */
static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
				int *count, struct timespec *time, char **buf,
				bool *compressed, struct pstore_info *psi)
				bool *compressed, ssize_t *ecc_notice_size,
				struct pstore_info *psi)
{
	struct oops_log_info *oops_hdr;
	unsigned int err_type, id_no, size = 0;
@@ -545,6 +546,7 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
			return -ENOMEM;
		kfree(buff);

		*ecc_notice_size = 0;
		if (err_type == ERR_TYPE_KERNEL_PANIC_GZ)
			*compressed = true;
		else
+5 −2
Original line number Diff line number Diff line
@@ -927,7 +927,8 @@ static int erst_open_pstore(struct pstore_info *psi);
static int erst_close_pstore(struct pstore_info *psi);
static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count,
			   struct timespec *time, char **buf,
			   bool *compressed, struct pstore_info *psi);
			   bool *compressed, ssize_t *ecc_notice_size,
			   struct pstore_info *psi);
static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
		       u64 *id, unsigned int part, int count, bool compressed,
		       size_t size, struct pstore_info *psi);
@@ -987,7 +988,8 @@ static int erst_close_pstore(struct pstore_info *psi)

static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count,
			   struct timespec *time, char **buf,
			   bool *compressed, struct pstore_info *psi)
			   bool *compressed, ssize_t *ecc_notice_size,
			   struct pstore_info *psi)
{
	int rc;
	ssize_t len = 0;
@@ -1033,6 +1035,7 @@ static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, int *count,
	memcpy(*buf, rcd->data, len - sizeof(*rcd));
	*id = record_id;
	*compressed = false;
	*ecc_notice_size = 0;
	if (uuid_le_cmp(rcd->sec_hdr.section_type,
			CPER_SECTION_TYPE_DMESG_Z) == 0) {
		*type = PSTORE_TYPE_DMESG;
+13 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ struct pstore_read_data {
	int *count;
	struct timespec *timespec;
	bool *compressed;
	ssize_t *ecc_notice_size;
	char **buf;
};

@@ -69,6 +70,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
			*cb_data->compressed = true;
		else
			*cb_data->compressed = false;
		*cb_data->ecc_notice_size = 0;
	} else if (sscanf(name, "dump-type%u-%u-%d-%lu",
		   cb_data->type, &part, &cnt, &time) == 4) {
		*cb_data->id = generic_id(time, part, cnt);
@@ -76,6 +78,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
		cb_data->timespec->tv_sec = time;
		cb_data->timespec->tv_nsec = 0;
		*cb_data->compressed = false;
		*cb_data->ecc_notice_size = 0;
	} else if (sscanf(name, "dump-type%u-%u-%lu",
			  cb_data->type, &part, &time) == 3) {
		/*
@@ -88,6 +91,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
		cb_data->timespec->tv_sec = time;
		cb_data->timespec->tv_nsec = 0;
		*cb_data->compressed = false;
		*cb_data->ecc_notice_size = 0;
	} else
		return 0;

@@ -210,6 +214,7 @@ static int efi_pstore_sysfs_entry_iter(void *data, struct efivar_entry **pos)
static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
			       int *count, struct timespec *timespec,
			       char **buf, bool *compressed,
			       ssize_t *ecc_notice_size,
			       struct pstore_info *psi)
{
	struct pstore_read_data data;
@@ -220,6 +225,7 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
	data.count = count;
	data.timespec = timespec;
	data.compressed = compressed;
	data.ecc_notice_size = ecc_notice_size;
	data.buf = buf;

	*data.buf = kzalloc(EFIVARS_DATA_SIZE_MAX, GFP_KERNEL);
@@ -393,6 +399,13 @@ static __init int efivars_pstore_init(void)

static __exit void efivars_pstore_exit(void)
{
	if (!efi_pstore_info.bufsize)
		return;

	pstore_unregister(&efi_pstore_info);
	kfree(efi_pstore_info.buf);
	efi_pstore_info.buf = NULL;
	efi_pstore_info.bufsize = 0;
}

module_init(efivars_pstore_init);
Loading