Lines Matching +full:use +full:- +full:minimum +full:- +full:ecc
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Persistent Storage - platform driver interface parts.
5 * Copyright (C) 2007-2008 Google, Inc.
39 * We defer making "oops" entries appear in pstore - see
43 static int pstore_update_ms = -1;
46 "(default is -1, which means runtime updates are disabled; "
57 "powerpc-ofw",
58 "powerpc-common",
60 "powerpc-opal",
81 MODULE_PARM_DESC(backend, "specific backend to use");
90 MODULE_PARM_DESC(compress, "compression to use");
274 return -EINVAL; in pstore_compress()
291 /* Skip if not built-in or compression backend not selected yet. */ in allocate_buf_for_compression()
299 if (!crypto_has_comp(zbackend->name, 0, 0)) { in allocate_buf_for_compression()
300 pr_err("Unknown compression: %s\n", zbackend->name); in allocate_buf_for_compression()
304 size = zbackend->zbufsize(psinfo->bufsize); in allocate_buf_for_compression()
307 zbackend->name, size); in allocate_buf_for_compression()
314 size, zbackend->name); in allocate_buf_for_compression()
318 ctx = crypto_alloc_comp(zbackend->name, 0, 0); in allocate_buf_for_compression()
321 pr_err("crypto_alloc_comp('%s') failed: %ld\n", zbackend->name, in allocate_buf_for_compression()
326 /* A non-NULL big_oops_buf indicates compression is available. */ in allocate_buf_for_compression()
331 pr_info("Using crash dump compression: %s\n", zbackend->name); in allocate_buf_for_compression()
350 * Copy the recent messages from big_oops_buf to psinfo->buf
359 if (total_len > psinfo->bufsize) { in copy_kmsg_to_buffer()
360 diff = total_len - psinfo->bufsize + hsize; in copy_kmsg_to_buffer()
361 memcpy(psinfo->buf, big_oops_buf, hsize); in copy_kmsg_to_buffer()
362 memcpy(psinfo->buf + hsize, big_oops_buf + diff, in copy_kmsg_to_buffer()
363 psinfo->bufsize - hsize); in copy_kmsg_to_buffer()
364 total_len = psinfo->bufsize; in copy_kmsg_to_buffer()
366 memcpy(psinfo->buf, big_oops_buf, total_len); in copy_kmsg_to_buffer()
376 record->psi = psinfo; in pstore_record_init()
379 record->time = ns_to_timespec64(ktime_get_real_fast_ns()); in pstore_record_init()
399 if (!spin_trylock_irqsave(&psinfo->buf_lock, flags)) { in pstore_dump()
405 spin_lock_irqsave(&psinfo->buf_lock, flags); in pstore_dump()
415 int zipped_len = -1; in pstore_dump()
424 record.buf = psinfo->buf; in pstore_dump()
430 dst = psinfo->buf; in pstore_dump()
431 dst_size = psinfo->bufsize; in pstore_dump()
437 dst_size -= header_size; in pstore_dump()
445 zipped_len = pstore_compress(dst, psinfo->buf, in pstore_dump()
447 psinfo->bufsize); in pstore_dump()
460 ret = psinfo->write(&record); in pstore_dump()
469 spin_unlock_irqrestore(&psinfo->buf_lock, flags); in pstore_dump()
502 psinfo->write(&record); in pstore_console_write()
507 .index = -1,
513 strscpy(pstore_console.name, psinfo->name, in pstore_register_console()
537 if (record->buf) in pstore_write_user_compat()
538 return -EINVAL; in pstore_write_user_compat()
540 record->buf = memdup_user(buf, record->size); in pstore_write_user_compat()
541 if (IS_ERR(record->buf)) { in pstore_write_user_compat()
542 ret = PTR_ERR(record->buf); in pstore_write_user_compat()
546 ret = record->psi->write(record); in pstore_write_user_compat()
548 kfree(record->buf); in pstore_write_user_compat()
550 record->buf = NULL; in pstore_write_user_compat()
552 return unlikely(ret < 0) ? ret : record->size; in pstore_write_user_compat()
564 if (backend && strcmp(backend, psi->name)) { in pstore_register()
565 pr_warn("ignoring unexpected backend '%s'\n", psi->name); in pstore_register()
566 return -EPERM; in pstore_register()
570 if (!psi->flags) { in pstore_register()
572 psi->name); in pstore_register()
573 return -EINVAL; in pstore_register()
577 if (!psi->read || !psi->write) { in pstore_register()
579 psi->name); in pstore_register()
580 return -EINVAL; in pstore_register()
586 psinfo->name, psi->name); in pstore_register()
588 return -EBUSY; in pstore_register()
591 if (!psi->write_user) in pstore_register()
592 psi->write_user = pstore_write_user_compat; in pstore_register()
594 mutex_init(&psinfo->read_mutex); in pstore_register()
595 spin_lock_init(&psinfo->buf_lock); in pstore_register()
597 if (psi->flags & PSTORE_FLAGS_DMESG) in pstore_register()
602 if (psi->flags & PSTORE_FLAGS_DMESG) { in pstore_register()
603 pstore_dumper.max_reason = psinfo->max_reason; in pstore_register()
606 if (psi->flags & PSTORE_FLAGS_CONSOLE) in pstore_register()
608 if (psi->flags & PSTORE_FLAGS_FTRACE) in pstore_register()
610 if (psi->flags & PSTORE_FLAGS_PMSG) in pstore_register()
620 backend = kstrdup(psi->name, GFP_KERNEL); in pstore_register()
622 pr_info("Registered %s as persistent store backend\n", psi->name); in pstore_register()
644 if (psi->flags & PSTORE_FLAGS_PMSG) in pstore_unregister()
646 if (psi->flags & PSTORE_FLAGS_FTRACE) in pstore_unregister()
648 if (psi->flags & PSTORE_FLAGS_CONSOLE) in pstore_unregister()
650 if (psi->flags & PSTORE_FLAGS_DMESG) in pstore_unregister()
675 if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS) || !record->compressed) in decompress_record()
679 if (record->type != PSTORE_TYPE_DMESG) { in decompress_record()
680 pr_warn("ignored compressed record type %d\n", record->type); in decompress_record()
690 /* Allocate enough space to hold max decompression and ECC. */ in decompress_record()
692 workspace = kmalloc(unzipped_len + record->ecc_notice_size, in decompress_record()
698 ret = crypto_comp_decompress(tfm, record->buf, record->size, in decompress_record()
706 /* Append ECC notice to decompressed buffer. */ in decompress_record()
707 memcpy(workspace + unzipped_len, record->buf + record->size, in decompress_record()
708 record->ecc_notice_size); in decompress_record()
710 /* Copy decompressed contents into an minimum-sized allocation. */ in decompress_record()
711 unzipped = kmemdup(workspace, unzipped_len + record->ecc_notice_size, in decompress_record()
718 kfree(record->buf); in decompress_record()
719 record->buf = unzipped; in decompress_record()
720 record->size = unzipped_len; in decompress_record()
721 record->compressed = false; in decompress_record()
726 * files in our filesystem. Don't warn about -EEXIST errors
727 * when we are re-scanning the backing store looking to add new
739 mutex_lock(&psi->read_mutex); in pstore_get_backend_records()
740 if (psi->open && psi->open(psi)) in pstore_get_backend_records()
748 for (; stop_loop; stop_loop--) { in pstore_get_backend_records()
759 record->size = psi->read(record); in pstore_get_backend_records()
762 if (record->size <= 0) { in pstore_get_backend_records()
771 kfree(record->buf); in pstore_get_backend_records()
772 kfree(record->priv); in pstore_get_backend_records()
774 if (rc != -EEXIST || !quiet) in pstore_get_backend_records()
778 if (psi->close) in pstore_get_backend_records()
779 psi->close(psi); in pstore_get_backend_records()
781 mutex_unlock(&psi->read_mutex); in pstore_get_backend_records()
785 failed, psi->name); in pstore_get_backend_records()
788 psi->name); in pstore_get_backend_records()
813 for (step = zbackends; step->name; step++) { in pstore_choose_compression()
814 if (!strcmp(compress, step->name)) { in pstore_choose_compression()