.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2010 Marco Stornelli <marco.stornelli@gmail.com> |
---|
3 | 4 | * Copyright (C) 2011 Kees Cook <keescook@chromium.org> |
---|
4 | 5 | * Copyright (C) 2011 Google, Inc. |
---|
5 | | - * |
---|
6 | | - * This software is licensed under the terms of the GNU General Public |
---|
7 | | - * License version 2, as published by the Free Software Foundation, and |
---|
8 | | - * may be copied, distributed, and modified under those terms. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | | - * GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | 6 | */ |
---|
16 | 7 | |
---|
17 | 8 | #ifndef __LINUX_PSTORE_RAM_H__ |
---|
.. | .. |
---|
22 | 13 | #include <linux/init.h> |
---|
23 | 14 | #include <linux/kernel.h> |
---|
24 | 15 | #include <linux/list.h> |
---|
25 | | -#include <linux/types.h> |
---|
26 | 16 | #include <linux/pstore.h> |
---|
| 17 | +#include <linux/types.h> |
---|
27 | 18 | |
---|
28 | 19 | /* |
---|
29 | 20 | * Choose whether access to the RAM zone requires locking or not. If a zone |
---|
.. | .. |
---|
31 | 22 | * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required. |
---|
32 | 23 | */ |
---|
33 | 24 | #define PRZ_FLAG_NO_LOCK BIT(0) |
---|
| 25 | +/* |
---|
| 26 | + * If a PRZ should only have a single-boot lifetime, this marks it as |
---|
| 27 | + * getting wiped after its contents get copied out after boot. |
---|
| 28 | + */ |
---|
| 29 | +#define PRZ_FLAG_ZAP_OLD BIT(1) |
---|
34 | 30 | |
---|
35 | 31 | struct persistent_ram_buffer; |
---|
36 | 32 | struct rs_control; |
---|
37 | | - |
---|
38 | | -struct persistent_ram_buffer { |
---|
39 | | - uint32_t sig; |
---|
40 | | - atomic_t start; |
---|
41 | | - atomic_t size; |
---|
42 | | - uint8_t data[0]; |
---|
43 | | -}; |
---|
44 | 33 | |
---|
45 | 34 | struct persistent_ram_ecc_info { |
---|
46 | 35 | int block_size; |
---|
.. | .. |
---|
50 | 39 | uint16_t *par; |
---|
51 | 40 | }; |
---|
52 | 41 | |
---|
| 42 | +/** |
---|
| 43 | + * struct persistent_ram_zone - Details of a persistent RAM zone (PRZ) |
---|
| 44 | + * used as a pstore backend |
---|
| 45 | + * |
---|
| 46 | + * @paddr: physical address of the mapped RAM area |
---|
| 47 | + * @size: size of mapping |
---|
| 48 | + * @label: unique name of this PRZ |
---|
| 49 | + * @type: frontend type for this PRZ |
---|
| 50 | + * @flags: holds PRZ_FLAGS_* bits |
---|
| 51 | + * |
---|
| 52 | + * @buffer_lock: |
---|
| 53 | + * locks access to @buffer "size" bytes and "start" offset |
---|
| 54 | + * @buffer: |
---|
| 55 | + * pointer to actual RAM area managed by this PRZ |
---|
| 56 | + * @buffer_size: |
---|
| 57 | + * bytes in @buffer->data (not including any trailing ECC bytes) |
---|
| 58 | + * |
---|
| 59 | + * @par_buffer: |
---|
| 60 | + * pointer into @buffer->data containing ECC bytes for @buffer->data |
---|
| 61 | + * @par_header: |
---|
| 62 | + * pointer into @buffer->data containing ECC bytes for @buffer header |
---|
| 63 | + * (i.e. all fields up to @data) |
---|
| 64 | + * @rs_decoder: |
---|
| 65 | + * RSLIB instance for doing ECC calculations |
---|
| 66 | + * @corrected_bytes: |
---|
| 67 | + * ECC corrected bytes accounting since boot |
---|
| 68 | + * @bad_blocks: |
---|
| 69 | + * ECC uncorrectable bytes accounting since boot |
---|
| 70 | + * @ecc_info: |
---|
| 71 | + * ECC configuration details |
---|
| 72 | + * |
---|
| 73 | + * @old_log: |
---|
| 74 | + * saved copy of @buffer->data prior to most recent wipe |
---|
| 75 | + * @old_log_size: |
---|
| 76 | + * bytes contained in @old_log |
---|
| 77 | + * |
---|
| 78 | + */ |
---|
53 | 79 | struct persistent_ram_zone { |
---|
54 | 80 | phys_addr_t paddr; |
---|
55 | 81 | size_t size; |
---|
56 | 82 | void *vaddr; |
---|
| 83 | + char *label; |
---|
| 84 | + enum pstore_type_id type; |
---|
| 85 | + u32 flags; |
---|
| 86 | + |
---|
| 87 | + raw_spinlock_t buffer_lock; |
---|
57 | 88 | struct persistent_ram_buffer *buffer; |
---|
58 | 89 | size_t buffer_size; |
---|
59 | | - u32 flags; |
---|
60 | | - raw_spinlock_t buffer_lock; |
---|
61 | 90 | |
---|
62 | | - /* ECC correction */ |
---|
63 | 91 | char *par_buffer; |
---|
64 | 92 | char *par_header; |
---|
65 | 93 | struct rs_control *rs_decoder; |
---|
.. | .. |
---|
71 | 99 | size_t old_log_size; |
---|
72 | 100 | }; |
---|
73 | 101 | |
---|
74 | | -struct ramoops_context { |
---|
75 | | - struct persistent_ram_zone **dprzs; /* Oops dump zones */ |
---|
76 | | - struct persistent_ram_zone *cprz; /* Console zone */ |
---|
77 | | - struct persistent_ram_zone **fprzs; /* Ftrace zones */ |
---|
78 | | - struct persistent_ram_zone *mprz; /* PMSG zone */ |
---|
79 | | -#ifdef CONFIG_PSTORE_BOOT_LOG |
---|
80 | | - struct persistent_ram_zone **boot_przs; /* BOOT log zones */ |
---|
81 | | -#endif |
---|
82 | | - phys_addr_t phys_addr; |
---|
83 | | - unsigned long size; |
---|
84 | | - unsigned int memtype; |
---|
85 | | - size_t record_size; |
---|
86 | | - size_t console_size; |
---|
87 | | - size_t ftrace_size; |
---|
88 | | - size_t pmsg_size; |
---|
89 | | -#ifdef CONFIG_PSTORE_BOOT_LOG |
---|
90 | | - size_t boot_log_size; |
---|
91 | | -#endif |
---|
92 | | - int dump_oops; |
---|
93 | | - u32 flags; |
---|
94 | | - struct persistent_ram_ecc_info ecc_info; |
---|
95 | | - unsigned int max_dump_cnt; |
---|
96 | | - unsigned int dump_write_cnt; |
---|
97 | | - /* _read_cnt need clear on ramoops_pstore_open */ |
---|
98 | | - unsigned int dump_read_cnt; |
---|
99 | | - unsigned int console_read_cnt; |
---|
100 | | - unsigned int max_ftrace_cnt; |
---|
101 | | - unsigned int ftrace_read_cnt; |
---|
102 | | - unsigned int pmsg_read_cnt; |
---|
103 | | -#ifdef CONFIG_PSTORE_BOOT_LOG |
---|
104 | | - unsigned int boot_log_read_cnt; |
---|
105 | | - unsigned int max_boot_log_cnt; |
---|
106 | | -#endif |
---|
107 | | - struct pstore_info pstore; |
---|
108 | | -}; |
---|
109 | | - |
---|
110 | 102 | struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size, |
---|
111 | 103 | u32 sig, struct persistent_ram_ecc_info *ecc_info, |
---|
112 | | - unsigned int memtype, u32 flags); |
---|
| 104 | + unsigned int memtype, u32 flags, char *label); |
---|
113 | 105 | void persistent_ram_free(struct persistent_ram_zone *prz); |
---|
114 | 106 | void persistent_ram_zap(struct persistent_ram_zone *prz); |
---|
115 | 107 | |
---|
.. | .. |
---|
124 | 116 | void persistent_ram_free_old(struct persistent_ram_zone *prz); |
---|
125 | 117 | ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz, |
---|
126 | 118 | char *str, size_t len); |
---|
| 119 | +#ifdef CONFIG_PSTORE_BOOT_LOG |
---|
| 120 | +ssize_t ramoops_pstore_read_for_boot_log(struct pstore_record *record); |
---|
| 121 | +#endif |
---|
127 | 122 | |
---|
128 | 123 | /* |
---|
129 | 124 | * Ramoops platform data |
---|
.. | .. |
---|
145 | 140 | unsigned long boot_log_size; |
---|
146 | 141 | unsigned long max_boot_log_cnt; |
---|
147 | 142 | #endif |
---|
148 | | - int dump_oops; |
---|
| 143 | + int max_reason; |
---|
149 | 144 | u32 flags; |
---|
150 | 145 | struct persistent_ram_ecc_info ecc_info; |
---|
151 | 146 | }; |
---|