nvram.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. /*
  2. * c 2001 PPC 64 Team, IBM Corp
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. *
  9. * /dev/nvram driver for PPC64
  10. *
  11. * This perhaps should live in drivers/char
  12. */
  13. #include <linux/types.h>
  14. #include <linux/errno.h>
  15. #include <linux/init.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/slab.h>
  18. #include <linux/kmsg_dump.h>
  19. #include <linux/ctype.h>
  20. #include <linux/zlib.h>
  21. #include <asm/uaccess.h>
  22. #include <asm/nvram.h>
  23. #include <asm/rtas.h>
  24. #include <asm/prom.h>
  25. #include <asm/machdep.h>
  26. /* Max bytes to read/write in one go */
  27. #define NVRW_CNT 0x20
  28. static unsigned int nvram_size;
  29. static int nvram_fetch, nvram_store;
  30. static char nvram_buf[NVRW_CNT]; /* assume this is in the first 4GB */
  31. static DEFINE_SPINLOCK(nvram_lock);
  32. struct err_log_info {
  33. int error_type;
  34. unsigned int seq_num;
  35. };
  36. struct nvram_os_partition {
  37. const char *name;
  38. int req_size; /* desired size, in bytes */
  39. int min_size; /* minimum acceptable size (0 means req_size) */
  40. long size; /* size of data portion (excluding err_log_info) */
  41. long index; /* offset of data portion of partition */
  42. };
  43. static struct nvram_os_partition rtas_log_partition = {
  44. .name = "ibm,rtas-log",
  45. .req_size = 2079,
  46. .min_size = 1055,
  47. .index = -1
  48. };
  49. static struct nvram_os_partition oops_log_partition = {
  50. .name = "lnx,oops-log",
  51. .req_size = 4000,
  52. .min_size = 2000,
  53. .index = -1
  54. };
  55. static const char *pseries_nvram_os_partitions[] = {
  56. "ibm,rtas-log",
  57. "lnx,oops-log",
  58. NULL
  59. };
  60. static void oops_to_nvram(struct kmsg_dumper *dumper,
  61. enum kmsg_dump_reason reason,
  62. const char *old_msgs, unsigned long old_len,
  63. const char *new_msgs, unsigned long new_len);
  64. static struct kmsg_dumper nvram_kmsg_dumper = {
  65. .dump = oops_to_nvram
  66. };
  67. /* See clobbering_unread_rtas_event() */
  68. #define NVRAM_RTAS_READ_TIMEOUT 5 /* seconds */
  69. static unsigned long last_unread_rtas_event; /* timestamp */
  70. /*
  71. * For capturing and compressing an oops or panic report...
  72. * big_oops_buf[] holds the uncompressed text we're capturing.
  73. *
  74. * oops_buf[] holds the compressed text, preceded by a prefix.
  75. * The prefix is just a u16 holding the length of the compressed* text.
  76. * (*Or uncompressed, if compression fails.) oops_buf[] gets written
  77. * to NVRAM.
  78. *
  79. * oops_len points to the prefix. oops_data points to the compressed text.
  80. *
  81. * +- oops_buf
  82. * | +- oops_data
  83. * v v
  84. * +------------+-----------------------------------------------+
  85. * | length | text |
  86. * | (2 bytes) | (oops_data_sz bytes) |
  87. * +------------+-----------------------------------------------+
  88. * ^
  89. * +- oops_len
  90. *
  91. * We preallocate these buffers during init to avoid kmalloc during oops/panic.
  92. */
  93. static size_t big_oops_buf_sz;
  94. static char *big_oops_buf, *oops_buf;
  95. static u16 *oops_len;
  96. static char *oops_data;
  97. static size_t oops_data_sz;
  98. /* Compression parameters */
  99. #define COMPR_LEVEL 6
  100. #define WINDOW_BITS 12
  101. #define MEM_LEVEL 4
  102. static struct z_stream_s stream;
  103. static ssize_t pSeries_nvram_read(char *buf, size_t count, loff_t *index)
  104. {
  105. unsigned int i;
  106. unsigned long len;
  107. int done;
  108. unsigned long flags;
  109. char *p = buf;
  110. if (nvram_size == 0 || nvram_fetch == RTAS_UNKNOWN_SERVICE)
  111. return -ENODEV;
  112. if (*index >= nvram_size)
  113. return 0;
  114. i = *index;
  115. if (i + count > nvram_size)
  116. count = nvram_size - i;
  117. spin_lock_irqsave(&nvram_lock, flags);
  118. for (; count != 0; count -= len) {
  119. len = count;
  120. if (len > NVRW_CNT)
  121. len = NVRW_CNT;
  122. if ((rtas_call(nvram_fetch, 3, 2, &done, i, __pa(nvram_buf),
  123. len) != 0) || len != done) {
  124. spin_unlock_irqrestore(&nvram_lock, flags);
  125. return -EIO;
  126. }
  127. memcpy(p, nvram_buf, len);
  128. p += len;
  129. i += len;
  130. }
  131. spin_unlock_irqrestore(&nvram_lock, flags);
  132. *index = i;
  133. return p - buf;
  134. }
  135. static ssize_t pSeries_nvram_write(char *buf, size_t count, loff_t *index)
  136. {
  137. unsigned int i;
  138. unsigned long len;
  139. int done;
  140. unsigned long flags;
  141. const char *p = buf;
  142. if (nvram_size == 0 || nvram_store == RTAS_UNKNOWN_SERVICE)
  143. return -ENODEV;
  144. if (*index >= nvram_size)
  145. return 0;
  146. i = *index;
  147. if (i + count > nvram_size)
  148. count = nvram_size - i;
  149. spin_lock_irqsave(&nvram_lock, flags);
  150. for (; count != 0; count -= len) {
  151. len = count;
  152. if (len > NVRW_CNT)
  153. len = NVRW_CNT;
  154. memcpy(nvram_buf, p, len);
  155. if ((rtas_call(nvram_store, 3, 2, &done, i, __pa(nvram_buf),
  156. len) != 0) || len != done) {
  157. spin_unlock_irqrestore(&nvram_lock, flags);
  158. return -EIO;
  159. }
  160. p += len;
  161. i += len;
  162. }
  163. spin_unlock_irqrestore(&nvram_lock, flags);
  164. *index = i;
  165. return p - buf;
  166. }
  167. static ssize_t pSeries_nvram_get_size(void)
  168. {
  169. return nvram_size ? nvram_size : -ENODEV;
  170. }
  171. /* nvram_write_os_partition, nvram_write_error_log
  172. *
  173. * We need to buffer the error logs into nvram to ensure that we have
  174. * the failure information to decode. If we have a severe error there
  175. * is no way to guarantee that the OS or the machine is in a state to
  176. * get back to user land and write the error to disk. For example if
  177. * the SCSI device driver causes a Machine Check by writing to a bad
  178. * IO address, there is no way of guaranteeing that the device driver
  179. * is in any state that is would also be able to write the error data
  180. * captured to disk, thus we buffer it in NVRAM for analysis on the
  181. * next boot.
  182. *
  183. * In NVRAM the partition containing the error log buffer will looks like:
  184. * Header (in bytes):
  185. * +-----------+----------+--------+------------+------------------+
  186. * | signature | checksum | length | name | data |
  187. * |0 |1 |2 3|4 15|16 length-1|
  188. * +-----------+----------+--------+------------+------------------+
  189. *
  190. * The 'data' section would look like (in bytes):
  191. * +--------------+------------+-----------------------------------+
  192. * | event_logged | sequence # | error log |
  193. * |0 3|4 7|8 error_log_size-1|
  194. * +--------------+------------+-----------------------------------+
  195. *
  196. * event_logged: 0 if event has not been logged to syslog, 1 if it has
  197. * sequence #: The unique sequence # for each event. (until it wraps)
  198. * error log: The error log from event_scan
  199. */
  200. int nvram_write_os_partition(struct nvram_os_partition *part, char * buff,
  201. int length, unsigned int err_type, unsigned int error_log_cnt)
  202. {
  203. int rc;
  204. loff_t tmp_index;
  205. struct err_log_info info;
  206. if (part->index == -1) {
  207. return -ESPIPE;
  208. }
  209. if (length > part->size) {
  210. length = part->size;
  211. }
  212. info.error_type = err_type;
  213. info.seq_num = error_log_cnt;
  214. tmp_index = part->index;
  215. rc = ppc_md.nvram_write((char *)&info, sizeof(struct err_log_info), &tmp_index);
  216. if (rc <= 0) {
  217. pr_err("%s: Failed nvram_write (%d)\n", __FUNCTION__, rc);
  218. return rc;
  219. }
  220. rc = ppc_md.nvram_write(buff, length, &tmp_index);
  221. if (rc <= 0) {
  222. pr_err("%s: Failed nvram_write (%d)\n", __FUNCTION__, rc);
  223. return rc;
  224. }
  225. return 0;
  226. }
  227. int nvram_write_error_log(char * buff, int length,
  228. unsigned int err_type, unsigned int error_log_cnt)
  229. {
  230. int rc = nvram_write_os_partition(&rtas_log_partition, buff, length,
  231. err_type, error_log_cnt);
  232. if (!rc)
  233. last_unread_rtas_event = get_seconds();
  234. return rc;
  235. }
  236. /* nvram_read_error_log
  237. *
  238. * Reads nvram for error log for at most 'length'
  239. */
  240. int nvram_read_error_log(char * buff, int length,
  241. unsigned int * err_type, unsigned int * error_log_cnt)
  242. {
  243. int rc;
  244. loff_t tmp_index;
  245. struct err_log_info info;
  246. if (rtas_log_partition.index == -1)
  247. return -1;
  248. if (length > rtas_log_partition.size)
  249. length = rtas_log_partition.size;
  250. tmp_index = rtas_log_partition.index;
  251. rc = ppc_md.nvram_read((char *)&info, sizeof(struct err_log_info), &tmp_index);
  252. if (rc <= 0) {
  253. printk(KERN_ERR "nvram_read_error_log: Failed nvram_read (%d)\n", rc);
  254. return rc;
  255. }
  256. rc = ppc_md.nvram_read(buff, length, &tmp_index);
  257. if (rc <= 0) {
  258. printk(KERN_ERR "nvram_read_error_log: Failed nvram_read (%d)\n", rc);
  259. return rc;
  260. }
  261. *error_log_cnt = info.seq_num;
  262. *err_type = info.error_type;
  263. return 0;
  264. }
  265. /* This doesn't actually zero anything, but it sets the event_logged
  266. * word to tell that this event is safely in syslog.
  267. */
  268. int nvram_clear_error_log(void)
  269. {
  270. loff_t tmp_index;
  271. int clear_word = ERR_FLAG_ALREADY_LOGGED;
  272. int rc;
  273. if (rtas_log_partition.index == -1)
  274. return -1;
  275. tmp_index = rtas_log_partition.index;
  276. rc = ppc_md.nvram_write((char *)&clear_word, sizeof(int), &tmp_index);
  277. if (rc <= 0) {
  278. printk(KERN_ERR "nvram_clear_error_log: Failed nvram_write (%d)\n", rc);
  279. return rc;
  280. }
  281. last_unread_rtas_event = 0;
  282. return 0;
  283. }
  284. /* pseries_nvram_init_os_partition
  285. *
  286. * This sets up a partition with an "OS" signature.
  287. *
  288. * The general strategy is the following:
  289. * 1.) If a partition with the indicated name already exists...
  290. * - If it's large enough, use it.
  291. * - Otherwise, recycle it and keep going.
  292. * 2.) Search for a free partition that is large enough.
  293. * 3.) If there's not a free partition large enough, recycle any obsolete
  294. * OS partitions and try again.
  295. * 4.) Will first try getting a chunk that will satisfy the requested size.
  296. * 5.) If a chunk of the requested size cannot be allocated, then try finding
  297. * a chunk that will satisfy the minum needed.
  298. *
  299. * Returns 0 on success, else -1.
  300. */
  301. static int __init pseries_nvram_init_os_partition(struct nvram_os_partition
  302. *part)
  303. {
  304. loff_t p;
  305. int size;
  306. /* Scan nvram for partitions */
  307. nvram_scan_partitions();
  308. /* Look for ours */
  309. p = nvram_find_partition(part->name, NVRAM_SIG_OS, &size);
  310. /* Found one but too small, remove it */
  311. if (p && size < part->min_size) {
  312. pr_info("nvram: Found too small %s partition,"
  313. " removing it...\n", part->name);
  314. nvram_remove_partition(part->name, NVRAM_SIG_OS, NULL);
  315. p = 0;
  316. }
  317. /* Create one if we didn't find */
  318. if (!p) {
  319. p = nvram_create_partition(part->name, NVRAM_SIG_OS,
  320. part->req_size, part->min_size);
  321. if (p == -ENOSPC) {
  322. pr_info("nvram: No room to create %s partition, "
  323. "deleting any obsolete OS partitions...\n",
  324. part->name);
  325. nvram_remove_partition(NULL, NVRAM_SIG_OS,
  326. pseries_nvram_os_partitions);
  327. p = nvram_create_partition(part->name, NVRAM_SIG_OS,
  328. part->req_size, part->min_size);
  329. }
  330. }
  331. if (p <= 0) {
  332. pr_err("nvram: Failed to find or create %s"
  333. " partition, err %d\n", part->name, (int)p);
  334. return -1;
  335. }
  336. part->index = p;
  337. part->size = nvram_get_partition_size(p) - sizeof(struct err_log_info);
  338. return 0;
  339. }
  340. static void __init nvram_init_oops_partition(int rtas_partition_exists)
  341. {
  342. int rc;
  343. rc = pseries_nvram_init_os_partition(&oops_log_partition);
  344. if (rc != 0) {
  345. if (!rtas_partition_exists)
  346. return;
  347. pr_notice("nvram: Using %s partition to log both"
  348. " RTAS errors and oops/panic reports\n",
  349. rtas_log_partition.name);
  350. memcpy(&oops_log_partition, &rtas_log_partition,
  351. sizeof(rtas_log_partition));
  352. }
  353. oops_buf = kmalloc(oops_log_partition.size, GFP_KERNEL);
  354. if (!oops_buf) {
  355. pr_err("nvram: No memory for %s partition\n",
  356. oops_log_partition.name);
  357. return;
  358. }
  359. oops_len = (u16*) oops_buf;
  360. oops_data = oops_buf + sizeof(u16);
  361. oops_data_sz = oops_log_partition.size - sizeof(u16);
  362. /*
  363. * Figure compression (preceded by elimination of each line's <n>
  364. * severity prefix) will reduce the oops/panic report to at most
  365. * 45% of its original size.
  366. */
  367. big_oops_buf_sz = (oops_data_sz * 100) / 45;
  368. big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL);
  369. if (big_oops_buf) {
  370. stream.workspace = kmalloc(zlib_deflate_workspacesize(
  371. WINDOW_BITS, MEM_LEVEL), GFP_KERNEL);
  372. if (!stream.workspace) {
  373. pr_err("nvram: No memory for compression workspace; "
  374. "skipping compression of %s partition data\n",
  375. oops_log_partition.name);
  376. kfree(big_oops_buf);
  377. big_oops_buf = NULL;
  378. }
  379. } else {
  380. pr_err("No memory for uncompressed %s data; "
  381. "skipping compression\n", oops_log_partition.name);
  382. stream.workspace = NULL;
  383. }
  384. rc = kmsg_dump_register(&nvram_kmsg_dumper);
  385. if (rc != 0) {
  386. pr_err("nvram: kmsg_dump_register() failed; returned %d\n", rc);
  387. kfree(oops_buf);
  388. kfree(big_oops_buf);
  389. kfree(stream.workspace);
  390. }
  391. }
  392. static int __init pseries_nvram_init_log_partitions(void)
  393. {
  394. int rc;
  395. rc = pseries_nvram_init_os_partition(&rtas_log_partition);
  396. nvram_init_oops_partition(rc == 0);
  397. return 0;
  398. }
  399. machine_arch_initcall(pseries, pseries_nvram_init_log_partitions);
  400. int __init pSeries_nvram_init(void)
  401. {
  402. struct device_node *nvram;
  403. const unsigned int *nbytes_p;
  404. unsigned int proplen;
  405. nvram = of_find_node_by_type(NULL, "nvram");
  406. if (nvram == NULL)
  407. return -ENODEV;
  408. nbytes_p = of_get_property(nvram, "#bytes", &proplen);
  409. if (nbytes_p == NULL || proplen != sizeof(unsigned int)) {
  410. of_node_put(nvram);
  411. return -EIO;
  412. }
  413. nvram_size = *nbytes_p;
  414. nvram_fetch = rtas_token("nvram-fetch");
  415. nvram_store = rtas_token("nvram-store");
  416. printk(KERN_INFO "PPC64 nvram contains %d bytes\n", nvram_size);
  417. of_node_put(nvram);
  418. ppc_md.nvram_read = pSeries_nvram_read;
  419. ppc_md.nvram_write = pSeries_nvram_write;
  420. ppc_md.nvram_size = pSeries_nvram_get_size;
  421. return 0;
  422. }
  423. /*
  424. * Try to capture the last capture_len bytes of the printk buffer. Return
  425. * the amount actually captured.
  426. */
  427. static size_t capture_last_msgs(const char *old_msgs, size_t old_len,
  428. const char *new_msgs, size_t new_len,
  429. char *captured, size_t capture_len)
  430. {
  431. if (new_len >= capture_len) {
  432. memcpy(captured, new_msgs + (new_len - capture_len),
  433. capture_len);
  434. return capture_len;
  435. } else {
  436. /* Grab the end of old_msgs. */
  437. size_t old_tail_len = min(old_len, capture_len - new_len);
  438. memcpy(captured, old_msgs + (old_len - old_tail_len),
  439. old_tail_len);
  440. memcpy(captured + old_tail_len, new_msgs, new_len);
  441. return old_tail_len + new_len;
  442. }
  443. }
  444. /*
  445. * Are we using the ibm,rtas-log for oops/panic reports? And if so,
  446. * would logging this oops/panic overwrite an RTAS event that rtas_errd
  447. * hasn't had a chance to read and process? Return 1 if so, else 0.
  448. *
  449. * We assume that if rtas_errd hasn't read the RTAS event in
  450. * NVRAM_RTAS_READ_TIMEOUT seconds, it's probably not going to.
  451. */
  452. static int clobbering_unread_rtas_event(void)
  453. {
  454. return (oops_log_partition.index == rtas_log_partition.index
  455. && last_unread_rtas_event
  456. && get_seconds() - last_unread_rtas_event <=
  457. NVRAM_RTAS_READ_TIMEOUT);
  458. }
  459. /* Squeeze out each line's <n> severity prefix. */
  460. static size_t elide_severities(char *buf, size_t len)
  461. {
  462. char *in, *out, *buf_end = buf + len;
  463. /* Assume a <n> at the very beginning marks the start of a line. */
  464. int newline = 1;
  465. in = out = buf;
  466. while (in < buf_end) {
  467. if (newline && in+3 <= buf_end &&
  468. *in == '<' && isdigit(in[1]) && in[2] == '>') {
  469. in += 3;
  470. newline = 0;
  471. } else {
  472. newline = (*in == '\n');
  473. *out++ = *in++;
  474. }
  475. }
  476. return out - buf;
  477. }
  478. /* Derived from logfs_compress() */
  479. static int nvram_compress(const void *in, void *out, size_t inlen,
  480. size_t outlen)
  481. {
  482. int err, ret;
  483. ret = -EIO;
  484. err = zlib_deflateInit2(&stream, COMPR_LEVEL, Z_DEFLATED, WINDOW_BITS,
  485. MEM_LEVEL, Z_DEFAULT_STRATEGY);
  486. if (err != Z_OK)
  487. goto error;
  488. stream.next_in = in;
  489. stream.avail_in = inlen;
  490. stream.total_in = 0;
  491. stream.next_out = out;
  492. stream.avail_out = outlen;
  493. stream.total_out = 0;
  494. err = zlib_deflate(&stream, Z_FINISH);
  495. if (err != Z_STREAM_END)
  496. goto error;
  497. err = zlib_deflateEnd(&stream);
  498. if (err != Z_OK)
  499. goto error;
  500. if (stream.total_out >= stream.total_in)
  501. goto error;
  502. ret = stream.total_out;
  503. error:
  504. return ret;
  505. }
  506. /* Compress the text from big_oops_buf into oops_buf. */
  507. static int zip_oops(size_t text_len)
  508. {
  509. int zipped_len = nvram_compress(big_oops_buf, oops_data, text_len,
  510. oops_data_sz);
  511. if (zipped_len < 0) {
  512. pr_err("nvram: compression failed; returned %d\n", zipped_len);
  513. pr_err("nvram: logging uncompressed oops/panic report\n");
  514. return -1;
  515. }
  516. *oops_len = (u16) zipped_len;
  517. return 0;
  518. }
  519. /*
  520. * This is our kmsg_dump callback, called after an oops or panic report
  521. * has been written to the printk buffer. We want to capture as much
  522. * of the printk buffer as possible. First, capture as much as we can
  523. * that we think will compress sufficiently to fit in the lnx,oops-log
  524. * partition. If that's too much, go back and capture uncompressed text.
  525. */
  526. static void oops_to_nvram(struct kmsg_dumper *dumper,
  527. enum kmsg_dump_reason reason,
  528. const char *old_msgs, unsigned long old_len,
  529. const char *new_msgs, unsigned long new_len)
  530. {
  531. static unsigned int oops_count = 0;
  532. static bool panicking = false;
  533. static DEFINE_SPINLOCK(lock);
  534. unsigned long flags;
  535. size_t text_len;
  536. unsigned int err_type = ERR_TYPE_KERNEL_PANIC_GZ;
  537. int rc = -1;
  538. switch (reason) {
  539. case KMSG_DUMP_RESTART:
  540. case KMSG_DUMP_HALT:
  541. case KMSG_DUMP_POWEROFF:
  542. /* These are almost always orderly shutdowns. */
  543. return;
  544. case KMSG_DUMP_OOPS:
  545. break;
  546. case KMSG_DUMP_PANIC:
  547. panicking = true;
  548. break;
  549. case KMSG_DUMP_EMERG:
  550. if (panicking)
  551. /* Panic report already captured. */
  552. return;
  553. break;
  554. default:
  555. pr_err("%s: ignoring unrecognized KMSG_DUMP_* reason %d\n",
  556. __FUNCTION__, (int) reason);
  557. return;
  558. }
  559. if (clobbering_unread_rtas_event())
  560. return;
  561. if (!spin_trylock_irqsave(&lock, flags))
  562. return;
  563. if (big_oops_buf) {
  564. text_len = capture_last_msgs(old_msgs, old_len,
  565. new_msgs, new_len, big_oops_buf, big_oops_buf_sz);
  566. text_len = elide_severities(big_oops_buf, text_len);
  567. rc = zip_oops(text_len);
  568. }
  569. if (rc != 0) {
  570. text_len = capture_last_msgs(old_msgs, old_len,
  571. new_msgs, new_len, oops_data, oops_data_sz);
  572. err_type = ERR_TYPE_KERNEL_PANIC;
  573. *oops_len = (u16) text_len;
  574. }
  575. (void) nvram_write_os_partition(&oops_log_partition, oops_buf,
  576. (int) (sizeof(*oops_len) + *oops_len), err_type, ++oops_count);
  577. spin_unlock_irqrestore(&lock, flags);
  578. }