Commit 69824bcc authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'pstore-v4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull pstore updates from Kees Cook:
 "This cycle was almost entirely improvements to the pstore compression
  options, noted below:

   - Add lz4hc and 842 to pstore compression options (Geliang Tang)

   - Refactor to use crypto compression API (Geliang Tang)

   - Fix up Kconfig dependencies for compression (Arnd Bergmann)

   - Allow for run-time compression selection

   - Remove stack VLA usage"

* tag 'pstore-v4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  pstore: fix crypto dependencies
  pstore: Use crypto compress API
  pstore/ram: Do not use stack VLA for parity workspace
  pstore: Select compression at runtime
  pstore: Avoid size casts for 842 compression
  pstore: Add lz4hc and 842 compression support
parents 3b54765c 58eb5b67
config PSTORE config PSTORE
tristate "Persistent store support" tristate "Persistent store support"
select CRYPTO if PSTORE_COMPRESS
default n default n
help help
This option enables generic access to platform level This option enables generic access to platform level
...@@ -12,35 +13,89 @@ config PSTORE ...@@ -12,35 +13,89 @@ config PSTORE
If you don't have a platform persistent store driver, If you don't have a platform persistent store driver,
say N. say N.
choice config PSTORE_DEFLATE_COMPRESS
prompt "Choose compression algorithm" tristate "DEFLATE (ZLIB) compression"
default y
depends on PSTORE depends on PSTORE
default PSTORE_ZLIB_COMPRESS select CRYPTO_DEFLATE
help
This option chooses compression algorithm.
config PSTORE_ZLIB_COMPRESS
bool "ZLIB"
select ZLIB_DEFLATE
select ZLIB_INFLATE
help help
This option enables ZLIB compression algorithm support. This option enables DEFLATE (also known as ZLIB) compression
algorithm support.
config PSTORE_LZO_COMPRESS config PSTORE_LZO_COMPRESS
bool "LZO" tristate "LZO compression"
select LZO_COMPRESS depends on PSTORE
select LZO_DECOMPRESS select CRYPTO_LZO
help help
This option enables LZO compression algorithm support. This option enables LZO compression algorithm support.
config PSTORE_LZ4_COMPRESS config PSTORE_LZ4_COMPRESS
bool "LZ4" tristate "LZ4 compression"
select LZ4_COMPRESS depends on PSTORE
select LZ4_DECOMPRESS select CRYPTO_LZ4
help help
This option enables LZ4 compression algorithm support. This option enables LZ4 compression algorithm support.
config PSTORE_LZ4HC_COMPRESS
tristate "LZ4HC compression"
depends on PSTORE
select CRYPTO_LZ4HC
help
This option enables LZ4HC (high compression) mode algorithm.
config PSTORE_842_COMPRESS
bool "842 compression"
depends on PSTORE
select CRYPTO_842
help
This option enables 842 compression algorithm support.
config PSTORE_COMPRESS
def_bool y
depends on PSTORE
depends on PSTORE_DEFLATE_COMPRESS || PSTORE_LZO_COMPRESS || \
PSTORE_LZ4_COMPRESS || PSTORE_LZ4HC_COMPRESS || \
PSTORE_842_COMPRESS
choice
prompt "Default pstore compression algorithm"
depends on PSTORE_COMPRESS
help
This option chooses the default active compression algorithm.
This change be changed at boot with "pstore.compress=..." on
the kernel command line.
Currently, pstore has support for 5 compression algorithms:
deflate, lzo, lz4, lz4hc and 842.
The default compression algorithm is deflate.
config PSTORE_DEFLATE_COMPRESS_DEFAULT
bool "deflate" if PSTORE_DEFLATE_COMPRESS
config PSTORE_LZO_COMPRESS_DEFAULT
bool "lzo" if PSTORE_LZO_COMPRESS
config PSTORE_LZ4_COMPRESS_DEFAULT
bool "lz4" if PSTORE_LZ4_COMPRESS
config PSTORE_LZ4HC_COMPRESS_DEFAULT
bool "lz4hc" if PSTORE_LZ4HC_COMPRESS
config PSTORE_842_COMPRESS_DEFAULT
bool "842" if PSTORE_842_COMPRESS
endchoice endchoice
config PSTORE_COMPRESS_DEFAULT
string
depends on PSTORE_COMPRESS
default "deflate" if PSTORE_DEFLATE_COMPRESS_DEFAULT
default "lzo" if PSTORE_LZO_COMPRESS_DEFAULT
default "lz4" if PSTORE_LZ4_COMPRESS_DEFAULT
default "lz4hc" if PSTORE_LZ4HC_COMPRESS_DEFAULT
default "842" if PSTORE_842_COMPRESS_DEFAULT
config PSTORE_CONSOLE config PSTORE_CONSOLE
bool "Log kernel console messages" bool "Log kernel console messages"
depends on PSTORE depends on PSTORE
......
...@@ -486,6 +486,8 @@ static int __init init_pstore_fs(void) ...@@ -486,6 +486,8 @@ static int __init init_pstore_fs(void)
{ {
int err; int err;
pstore_choose_compression();
/* Create a convenient mount point for people to access pstore */ /* Create a convenient mount point for people to access pstore */
err = sysfs_create_mount_point(fs_kobj, "pstore"); err = sysfs_create_mount_point(fs_kobj, "pstore");
if (err) if (err)
......
...@@ -37,4 +37,7 @@ extern bool pstore_is_mounted(void); ...@@ -37,4 +37,7 @@ extern bool pstore_is_mounted(void);
extern void pstore_record_init(struct pstore_record *record, extern void pstore_record_init(struct pstore_record *record,
struct pstore_info *psi); struct pstore_info *psi);
/* Called during module_init() */
extern void __init pstore_choose_compression(void);
#endif #endif
This diff is collapsed.
...@@ -938,7 +938,7 @@ static int __init ramoops_init(void) ...@@ -938,7 +938,7 @@ static int __init ramoops_init(void)
ramoops_register_dummy(); ramoops_register_dummy();
return platform_driver_register(&ramoops_driver); return platform_driver_register(&ramoops_driver);
} }
postcore_initcall(ramoops_init); late_initcall(ramoops_init);
static void __exit ramoops_exit(void) static void __exit ramoops_exit(void)
{ {
......
...@@ -98,24 +98,23 @@ static void notrace persistent_ram_encode_rs8(struct persistent_ram_zone *prz, ...@@ -98,24 +98,23 @@ static void notrace persistent_ram_encode_rs8(struct persistent_ram_zone *prz,
uint8_t *data, size_t len, uint8_t *ecc) uint8_t *data, size_t len, uint8_t *ecc)
{ {
int i; int i;
uint16_t par[prz->ecc_info.ecc_size];
/* Initialize the parity buffer */ /* Initialize the parity buffer */
memset(par, 0, sizeof(par)); memset(prz->ecc_info.par, 0,
encode_rs8(prz->rs_decoder, data, len, par, 0); prz->ecc_info.ecc_size * sizeof(prz->ecc_info.par[0]));
encode_rs8(prz->rs_decoder, data, len, prz->ecc_info.par, 0);
for (i = 0; i < prz->ecc_info.ecc_size; i++) for (i = 0; i < prz->ecc_info.ecc_size; i++)
ecc[i] = par[i]; ecc[i] = prz->ecc_info.par[i];
} }
static int persistent_ram_decode_rs8(struct persistent_ram_zone *prz, static int persistent_ram_decode_rs8(struct persistent_ram_zone *prz,
void *data, size_t len, uint8_t *ecc) void *data, size_t len, uint8_t *ecc)
{ {
int i; int i;
uint16_t par[prz->ecc_info.ecc_size];
for (i = 0; i < prz->ecc_info.ecc_size; i++) for (i = 0; i < prz->ecc_info.ecc_size; i++)
par[i] = ecc[i]; prz->ecc_info.par[i] = ecc[i];
return decode_rs8(prz->rs_decoder, data, par, len, return decode_rs8(prz->rs_decoder, data, prz->ecc_info.par, len,
NULL, 0, NULL, 0, NULL); NULL, 0, NULL, 0, NULL);
} }
...@@ -228,6 +227,15 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz, ...@@ -228,6 +227,15 @@ static int persistent_ram_init_ecc(struct persistent_ram_zone *prz,
return -EINVAL; return -EINVAL;
} }
/* allocate workspace instead of using stack VLA */
prz->ecc_info.par = kmalloc_array(prz->ecc_info.ecc_size,
sizeof(*prz->ecc_info.par),
GFP_KERNEL);
if (!prz->ecc_info.par) {
pr_err("cannot allocate ECC parity workspace\n");
return -ENOMEM;
}
prz->corrected_bytes = 0; prz->corrected_bytes = 0;
prz->bad_blocks = 0; prz->bad_blocks = 0;
...@@ -514,6 +522,13 @@ void persistent_ram_free(struct persistent_ram_zone *prz) ...@@ -514,6 +522,13 @@ void persistent_ram_free(struct persistent_ram_zone *prz)
} }
prz->vaddr = NULL; prz->vaddr = NULL;
} }
if (prz->rs_decoder) {
free_rs(prz->rs_decoder);
prz->rs_decoder = NULL;
}
kfree(prz->ecc_info.par);
prz->ecc_info.par = NULL;
persistent_ram_free_old(prz); persistent_ram_free_old(prz);
kfree(prz); kfree(prz);
} }
......
...@@ -39,6 +39,7 @@ struct persistent_ram_ecc_info { ...@@ -39,6 +39,7 @@ struct persistent_ram_ecc_info {
int ecc_size; int ecc_size;
int symsize; int symsize;
int poly; int poly;
uint16_t *par;
}; };
struct persistent_ram_zone { struct persistent_ram_zone {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment