hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/linux/pstore_ram.h
....@@ -1,17 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2010 Marco Stornelli <marco.stornelli@gmail.com>
34 * Copyright (C) 2011 Kees Cook <keescook@chromium.org>
45 * 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
- *
156 */
167
178 #ifndef __LINUX_PSTORE_RAM_H__
....@@ -22,8 +13,8 @@
2213 #include <linux/init.h>
2314 #include <linux/kernel.h>
2415 #include <linux/list.h>
25
-#include <linux/types.h>
2616 #include <linux/pstore.h>
17
+#include <linux/types.h>
2718
2819 /*
2920 * Choose whether access to the RAM zone requires locking or not. If a zone
....@@ -31,16 +22,14 @@
3122 * PRZ_FLAG_NO_LOCK is used. For all other cases, locking is required.
3223 */
3324 #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)
3430
3531 struct persistent_ram_buffer;
3632 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
-};
4433
4534 struct persistent_ram_ecc_info {
4635 int block_size;
....@@ -50,16 +39,55 @@
5039 uint16_t *par;
5140 };
5241
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
+ */
5379 struct persistent_ram_zone {
5480 phys_addr_t paddr;
5581 size_t size;
5682 void *vaddr;
83
+ char *label;
84
+ enum pstore_type_id type;
85
+ u32 flags;
86
+
87
+ raw_spinlock_t buffer_lock;
5788 struct persistent_ram_buffer *buffer;
5889 size_t buffer_size;
59
- u32 flags;
60
- raw_spinlock_t buffer_lock;
6190
62
- /* ECC correction */
6391 char *par_buffer;
6492 char *par_header;
6593 struct rs_control *rs_decoder;
....@@ -71,45 +99,9 @@
7199 size_t old_log_size;
72100 };
73101
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
-
110102 struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
111103 u32 sig, struct persistent_ram_ecc_info *ecc_info,
112
- unsigned int memtype, u32 flags);
104
+ unsigned int memtype, u32 flags, char *label);
113105 void persistent_ram_free(struct persistent_ram_zone *prz);
114106 void persistent_ram_zap(struct persistent_ram_zone *prz);
115107
....@@ -124,6 +116,9 @@
124116 void persistent_ram_free_old(struct persistent_ram_zone *prz);
125117 ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,
126118 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
127122
128123 /*
129124 * Ramoops platform data
....@@ -145,7 +140,7 @@
145140 unsigned long boot_log_size;
146141 unsigned long max_boot_log_cnt;
147142 #endif
148
- int dump_oops;
143
+ int max_reason;
149144 u32 flags;
150145 struct persistent_ram_ecc_info ecc_info;
151146 };