Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull pstore fixes from Kees Cook:
"Fixes for pstore ramoops driver to catch bad kfree() and to use better
DT bindings"

* tag 'pstore-v4.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
ramoops: use persistent_ram_free() instead of kfree() for freeing prz
ramoops: use DT reserved-memory bindings

+59 -36
+4 -4
Documentation/devicetree/bindings/misc/ramoops.txt Documentation/devicetree/bindings/reserved-memory/ramoops.txt
··· 2 2 ========================= 3 3 4 4 ramoops provides persistent RAM storage for oops and panics, so they can be 5 - recovered after a reboot. It is a backend to pstore, so this node is named 6 - "ramoops" after the backend, rather than "pstore" which is the subsystem. 5 + recovered after a reboot. This is a child-node of "/reserved-memory", and 6 + is named "ramoops" after the backend, rather than "pstore" which is the 7 + subsystem. 7 8 8 9 Parts of this storage may be set aside for other persistent log buffers, such 9 10 as kernel log messages, or for optional ECC error-correction data. The total ··· 22 21 23 22 - compatible: must be "ramoops" 24 23 25 - - memory-region: phandle to a region of memory that is preserved between 26 - reboots 24 + - reg: region of memory that is preserved between reboots 27 25 28 26 29 27 Optional properties:
+27 -11
Documentation/ramoops.txt
··· 45 45 46 46 2. Setting the parameters 47 47 48 - Setting the ramoops parameters can be done in 3 different manners: 49 - 1. Use the module parameters (which have the names of the variables described 50 - as before). 51 - For quick debugging, you can also reserve parts of memory during boot 52 - and then use the reserved memory for ramoops. For example, assuming a machine 53 - with > 128 MB of memory, the following kernel command line will tell the 54 - kernel to use only the first 128 MB of memory, and place ECC-protected ramoops 55 - region at 128 MB boundary: 48 + Setting the ramoops parameters can be done in several different manners: 49 + 50 + A. Use the module parameters (which have the names of the variables described 51 + as before). For quick debugging, you can also reserve parts of memory during 52 + boot and then use the reserved memory for ramoops. For example, assuming a 53 + machine with > 128 MB of memory, the following kernel command line will tell 54 + the kernel to use only the first 128 MB of memory, and place ECC-protected 55 + ramoops region at 128 MB boundary: 56 56 "mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1" 57 - 2. Use Device Tree bindings, as described in 58 - Documentation/device-tree/bindings/misc/ramoops.txt. 59 - 3. Use a platform device and set the platform data. The parameters can then 57 + 58 + B. Use Device Tree bindings, as described in 59 + Documentation/device-tree/bindings/reserved-memory/ramoops.txt. 60 + For example: 61 + 62 + reserved-memory { 63 + #address-cells = <2>; 64 + #size-cells = <2>; 65 + ranges; 66 + 67 + ramoops@8f000000 { 68 + compatible = "ramoops"; 69 + reg = <0 0x8f000000 0 0x100000>; 70 + record-size = <0x4000>; 71 + console-size = <0x4000>; 72 + }; 73 + }; 74 + 75 + C. Use a platform device and set the platform data. The parameters can then 60 76 be set through that platform data. An example of doing that is: 61 77 62 78 #include <linux/pstore_ram.h>
+18 -2
drivers/of/platform.c
··· 499 499 500 500 static int __init of_platform_default_populate_init(void) 501 501 { 502 - if (of_have_populated_dt()) 503 - of_platform_default_populate(NULL, NULL, NULL); 502 + struct device_node *node; 503 + 504 + if (!of_have_populated_dt()) 505 + return -ENODEV; 506 + 507 + /* 508 + * Handle ramoops explicitly, since it is inside /reserved-memory, 509 + * which lacks a "compatible" property. 510 + */ 511 + node = of_find_node_by_path("/reserved-memory"); 512 + if (node) { 513 + node = of_find_compatible_node(node, NULL, "ramoops"); 514 + if (node) 515 + of_platform_device_create(node, NULL, NULL); 516 + } 517 + 518 + /* Populate everything else. */ 519 + of_platform_default_populate(NULL, NULL, NULL); 504 520 505 521 return 0; 506 522 }
+10 -19
fs/pstore/ram.c
··· 486 486 struct ramoops_platform_data *pdata) 487 487 { 488 488 struct device_node *of_node = pdev->dev.of_node; 489 - struct device_node *mem_region; 490 - struct resource res; 489 + struct resource *res; 491 490 u32 value; 492 491 int ret; 493 492 494 493 dev_dbg(&pdev->dev, "using Device Tree\n"); 495 494 496 - mem_region = of_parse_phandle(of_node, "memory-region", 0); 497 - if (!mem_region) { 498 - dev_err(&pdev->dev, "no memory-region phandle\n"); 499 - return -ENODEV; 500 - } 501 - 502 - ret = of_address_to_resource(mem_region, 0, &res); 503 - of_node_put(mem_region); 504 - if (ret) { 495 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 496 + if (!res) { 505 497 dev_err(&pdev->dev, 506 - "failed to translate memory-region to resource: %d\n", 507 - ret); 508 - return ret; 498 + "failed to locate DT /reserved-memory resource\n"); 499 + return -EINVAL; 509 500 } 510 501 511 - pdata->mem_size = resource_size(&res); 512 - pdata->mem_address = res.start; 502 + pdata->mem_size = resource_size(res); 503 + pdata->mem_address = res->start; 513 504 pdata->mem_type = of_property_read_bool(of_node, "unbuffered"); 514 505 pdata->dump_oops = !of_property_read_bool(of_node, "no-dump-oops"); 515 506 ··· 643 652 kfree(cxt->pstore.buf); 644 653 fail_clear: 645 654 cxt->pstore.bufsize = 0; 646 - kfree(cxt->mprz); 655 + persistent_ram_free(cxt->mprz); 647 656 fail_init_mprz: 648 - kfree(cxt->fprz); 657 + persistent_ram_free(cxt->fprz); 649 658 fail_init_fprz: 650 - kfree(cxt->cprz); 659 + persistent_ram_free(cxt->cprz); 651 660 fail_init_cprz: 652 661 ramoops_free_przs(cxt); 653 662 fail_out: