hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/include/linux/cper.h
....@@ -1,21 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * UEFI Common Platform Error Record
34 *
45 * Copyright (C) 2010, Intel Corp.
56 * Author: Huang Ying <ying.huang@intel.com>
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License version
9
- * 2 as published by the Free Software Foundation.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
197 */
208
219 #ifndef LINUX_CPER_H
....@@ -44,7 +32,7 @@
4432 */
4533 #define CPER_REC_LEN 256
4634 /*
47
- * Severity difinition for error_severity in struct cper_record_header
35
+ * Severity definition for error_severity in struct cper_record_header
4836 * and section_severity in struct cper_section_descriptor
4937 */
5038 enum {
....@@ -55,24 +43,21 @@
5543 };
5644
5745 /*
58
- * Validation bits difinition for validation_bits in struct
46
+ * Validation bits definition for validation_bits in struct
5947 * cper_record_header. If set, corresponding fields in struct
6048 * cper_record_header contain valid information.
61
- *
62
- * corresponds platform_id
6349 */
6450 #define CPER_VALID_PLATFORM_ID 0x0001
65
-/* corresponds timestamp */
6651 #define CPER_VALID_TIMESTAMP 0x0002
67
-/* corresponds partition_id */
6852 #define CPER_VALID_PARTITION_ID 0x0004
6953
7054 /*
7155 * Notification type used to generate error record, used in
72
- * notification_type in struct cper_record_header
73
- *
74
- * Corrected Machine Check
56
+ * notification_type in struct cper_record_header. These UUIDs are defined
57
+ * in the UEFI spec v2.7, sec N.2.1.
7558 */
59
+
60
+/* Corrected Machine Check */
7661 #define CPER_NOTIFY_CMC \
7762 GUID_INIT(0x2DCE8BB1, 0xBDD7, 0x450e, 0xB9, 0xAD, 0x9C, 0xF4, \
7863 0xEB, 0xD4, 0xF8, 0x90)
....@@ -122,14 +107,11 @@
122107 #define CPER_SEC_REV 0x0100
123108
124109 /*
125
- * Validation bits difinition for validation_bits in struct
110
+ * Validation bits definition for validation_bits in struct
126111 * cper_section_descriptor. If set, corresponding fields in struct
127112 * cper_section_descriptor contain valid information.
128
- *
129
- * corresponds fru_id
130113 */
131114 #define CPER_SEC_VALID_FRU_ID 0x1
132
-/* corresponds fru_text */
133115 #define CPER_SEC_VALID_FRU_TEXT 0x2
134116
135117 /*
....@@ -165,10 +147,11 @@
165147
166148 /*
167149 * Section type definitions, used in section_type field in struct
168
- * cper_section_descriptor
169
- *
170
- * Processor Generic
150
+ * cper_section_descriptor. These UUIDs are defined in the UEFI spec
151
+ * v2.7, sec N.2.2.
171152 */
153
+
154
+/* Processor Generic */
172155 #define CPER_SEC_PROC_GENERIC \
173156 GUID_INIT(0x9876CCAD, 0x47B4, 0x4bdb, 0xB6, 0x5E, 0x16, 0xF1, \
174157 0x93, 0xC4, 0xF3, 0xDB)
....@@ -247,6 +230,18 @@
247230 #define CPER_MEM_VALID_RANK_NUMBER 0x8000
248231 #define CPER_MEM_VALID_CARD_HANDLE 0x10000
249232 #define CPER_MEM_VALID_MODULE_HANDLE 0x20000
233
+#define CPER_MEM_VALID_ROW_EXT 0x40000
234
+#define CPER_MEM_VALID_BANK_GROUP 0x80000
235
+#define CPER_MEM_VALID_BANK_ADDRESS 0x100000
236
+#define CPER_MEM_VALID_CHIP_ID 0x200000
237
+
238
+#define CPER_MEM_EXT_ROW_MASK 0x3
239
+#define CPER_MEM_EXT_ROW_SHIFT 16
240
+
241
+#define CPER_MEM_BANK_ADDRESS_MASK 0xff
242
+#define CPER_MEM_BANK_GROUP_SHIFT 8
243
+
244
+#define CPER_MEM_CHIP_ID_SHIFT 5
250245
251246 #define CPER_PCIE_VALID_PORT_TYPE 0x0001
252247 #define CPER_PCIE_VALID_VERSION 0x0002
....@@ -325,220 +320,240 @@
325320 */
326321 #pragma pack(1)
327322
323
+/* Record Header, UEFI v2.7 sec N.2.1 */
328324 struct cper_record_header {
329325 char signature[CPER_SIG_SIZE]; /* must be CPER_SIG_RECORD */
330
- __u16 revision; /* must be CPER_RECORD_REV */
331
- __u32 signature_end; /* must be CPER_SIG_END */
332
- __u16 section_count;
333
- __u32 error_severity;
334
- __u32 validation_bits;
335
- __u32 record_length;
336
- __u64 timestamp;
326
+ u16 revision; /* must be CPER_RECORD_REV */
327
+ u32 signature_end; /* must be CPER_SIG_END */
328
+ u16 section_count;
329
+ u32 error_severity;
330
+ u32 validation_bits;
331
+ u32 record_length;
332
+ u64 timestamp;
337333 guid_t platform_id;
338334 guid_t partition_id;
339335 guid_t creator_id;
340336 guid_t notification_type;
341
- __u64 record_id;
342
- __u32 flags;
343
- __u64 persistence_information;
344
- __u8 reserved[12]; /* must be zero */
337
+ u64 record_id;
338
+ u32 flags;
339
+ u64 persistence_information;
340
+ u8 reserved[12]; /* must be zero */
345341 };
346342
343
+/* Section Descriptor, UEFI v2.7 sec N.2.2 */
347344 struct cper_section_descriptor {
348
- __u32 section_offset; /* Offset in bytes of the
345
+ u32 section_offset; /* Offset in bytes of the
349346 * section body from the base
350347 * of the record header */
351
- __u32 section_length;
352
- __u16 revision; /* must be CPER_RECORD_REV */
353
- __u8 validation_bits;
354
- __u8 reserved; /* must be zero */
355
- __u32 flags;
348
+ u32 section_length;
349
+ u16 revision; /* must be CPER_RECORD_REV */
350
+ u8 validation_bits;
351
+ u8 reserved; /* must be zero */
352
+ u32 flags;
356353 guid_t section_type;
357354 guid_t fru_id;
358
- __u32 section_severity;
359
- __u8 fru_text[20];
355
+ u32 section_severity;
356
+ u8 fru_text[20];
360357 };
361358
362
-/* Generic Processor Error Section */
359
+/* Generic Processor Error Section, UEFI v2.7 sec N.2.4.1 */
363360 struct cper_sec_proc_generic {
364
- __u64 validation_bits;
365
- __u8 proc_type;
366
- __u8 proc_isa;
367
- __u8 proc_error_type;
368
- __u8 operation;
369
- __u8 flags;
370
- __u8 level;
371
- __u16 reserved;
372
- __u64 cpu_version;
361
+ u64 validation_bits;
362
+ u8 proc_type;
363
+ u8 proc_isa;
364
+ u8 proc_error_type;
365
+ u8 operation;
366
+ u8 flags;
367
+ u8 level;
368
+ u16 reserved;
369
+ u64 cpu_version;
373370 char cpu_brand[128];
374
- __u64 proc_id;
375
- __u64 target_addr;
376
- __u64 requestor_id;
377
- __u64 responder_id;
378
- __u64 ip;
371
+ u64 proc_id;
372
+ u64 target_addr;
373
+ u64 requestor_id;
374
+ u64 responder_id;
375
+ u64 ip;
379376 };
380377
381
-/* IA32/X64 Processor Error Section */
378
+/* IA32/X64 Processor Error Section, UEFI v2.7 sec N.2.4.2 */
382379 struct cper_sec_proc_ia {
383
- __u64 validation_bits;
384
- __u64 lapic_id;
385
- __u8 cpuid[48];
380
+ u64 validation_bits;
381
+ u64 lapic_id;
382
+ u8 cpuid[48];
386383 };
387384
388
-/* IA32/X64 Processor Error Information Structure */
385
+/* IA32/X64 Processor Error Information Structure, UEFI v2.7 sec N.2.4.2.1 */
389386 struct cper_ia_err_info {
390387 guid_t err_type;
391
- __u64 validation_bits;
392
- __u64 check_info;
393
- __u64 target_id;
394
- __u64 requestor_id;
395
- __u64 responder_id;
396
- __u64 ip;
388
+ u64 validation_bits;
389
+ u64 check_info;
390
+ u64 target_id;
391
+ u64 requestor_id;
392
+ u64 responder_id;
393
+ u64 ip;
397394 };
398395
399
-/* IA32/X64 Processor Context Information Structure */
396
+/* IA32/X64 Processor Context Information Structure, UEFI v2.7 sec N.2.4.2.2 */
400397 struct cper_ia_proc_ctx {
401
- __u16 reg_ctx_type;
402
- __u16 reg_arr_size;
403
- __u32 msr_addr;
404
- __u64 mm_reg_addr;
398
+ u16 reg_ctx_type;
399
+ u16 reg_arr_size;
400
+ u32 msr_addr;
401
+ u64 mm_reg_addr;
405402 };
406403
407
-/* ARM Processor Error Section */
404
+/* ARM Processor Error Section, UEFI v2.7 sec N.2.4.4 */
408405 struct cper_sec_proc_arm {
409
- __u32 validation_bits;
410
- __u16 err_info_num; /* Number of Processor Error Info */
411
- __u16 context_info_num; /* Number of Processor Context Info Records*/
412
- __u32 section_length;
413
- __u8 affinity_level;
414
- __u8 reserved[3]; /* must be zero */
415
- __u64 mpidr;
416
- __u64 midr;
417
- __u32 running_state; /* Bit 0 set - Processor running. PSCI = 0 */
418
- __u32 psci_state;
406
+ u32 validation_bits;
407
+ u16 err_info_num; /* Number of Processor Error Info */
408
+ u16 context_info_num; /* Number of Processor Context Info Records*/
409
+ u32 section_length;
410
+ u8 affinity_level;
411
+ u8 reserved[3]; /* must be zero */
412
+ u64 mpidr;
413
+ u64 midr;
414
+ u32 running_state; /* Bit 0 set - Processor running. PSCI = 0 */
415
+ u32 psci_state;
419416 };
420417
421
-/* ARM Processor Error Information Structure */
418
+/* ARM Processor Error Information Structure, UEFI v2.7 sec N.2.4.4.1 */
422419 struct cper_arm_err_info {
423
- __u8 version;
424
- __u8 length;
425
- __u16 validation_bits;
426
- __u8 type;
427
- __u16 multiple_error;
428
- __u8 flags;
429
- __u64 error_info;
430
- __u64 virt_fault_addr;
431
- __u64 physical_fault_addr;
420
+ u8 version;
421
+ u8 length;
422
+ u16 validation_bits;
423
+ u8 type;
424
+ u16 multiple_error;
425
+ u8 flags;
426
+ u64 error_info;
427
+ u64 virt_fault_addr;
428
+ u64 physical_fault_addr;
432429 };
433430
434
-/* ARM Processor Context Information Structure */
431
+/* ARM Processor Context Information Structure, UEFI v2.7 sec N.2.4.4.2 */
435432 struct cper_arm_ctx_info {
436
- __u16 version;
437
- __u16 type;
438
- __u32 size;
433
+ u16 version;
434
+ u16 type;
435
+ u32 size;
439436 };
440437
441
-/* Old Memory Error Section UEFI 2.1, 2.2 */
438
+/* Old Memory Error Section, UEFI v2.1, v2.2 */
442439 struct cper_sec_mem_err_old {
443
- __u64 validation_bits;
444
- __u64 error_status;
445
- __u64 physical_addr;
446
- __u64 physical_addr_mask;
447
- __u16 node;
448
- __u16 card;
449
- __u16 module;
450
- __u16 bank;
451
- __u16 device;
452
- __u16 row;
453
- __u16 column;
454
- __u16 bit_pos;
455
- __u64 requestor_id;
456
- __u64 responder_id;
457
- __u64 target_id;
458
- __u8 error_type;
440
+ u64 validation_bits;
441
+ u64 error_status;
442
+ u64 physical_addr;
443
+ u64 physical_addr_mask;
444
+ u16 node;
445
+ u16 card;
446
+ u16 module;
447
+ u16 bank;
448
+ u16 device;
449
+ u16 row;
450
+ u16 column;
451
+ u16 bit_pos;
452
+ u64 requestor_id;
453
+ u64 responder_id;
454
+ u64 target_id;
455
+ u8 error_type;
459456 };
460457
461
-/* Memory Error Section UEFI >= 2.3 */
458
+/* Memory Error Section (UEFI >= v2.3), UEFI v2.8 sec N.2.5 */
462459 struct cper_sec_mem_err {
463
- __u64 validation_bits;
464
- __u64 error_status;
465
- __u64 physical_addr;
466
- __u64 physical_addr_mask;
467
- __u16 node;
468
- __u16 card;
469
- __u16 module;
470
- __u16 bank;
471
- __u16 device;
472
- __u16 row;
473
- __u16 column;
474
- __u16 bit_pos;
475
- __u64 requestor_id;
476
- __u64 responder_id;
477
- __u64 target_id;
478
- __u8 error_type;
479
- __u8 reserved;
480
- __u16 rank;
481
- __u16 mem_array_handle; /* card handle in UEFI 2.4 */
482
- __u16 mem_dev_handle; /* module handle in UEFI 2.4 */
460
+ u64 validation_bits;
461
+ u64 error_status;
462
+ u64 physical_addr;
463
+ u64 physical_addr_mask;
464
+ u16 node;
465
+ u16 card;
466
+ u16 module;
467
+ u16 bank;
468
+ u16 device;
469
+ u16 row;
470
+ u16 column;
471
+ u16 bit_pos;
472
+ u64 requestor_id;
473
+ u64 responder_id;
474
+ u64 target_id;
475
+ u8 error_type;
476
+ u8 extended;
477
+ u16 rank;
478
+ u16 mem_array_handle; /* "card handle" in UEFI 2.4 */
479
+ u16 mem_dev_handle; /* "module handle" in UEFI 2.4 */
483480 };
484481
485482 struct cper_mem_err_compact {
486
- __u64 validation_bits;
487
- __u16 node;
488
- __u16 card;
489
- __u16 module;
490
- __u16 bank;
491
- __u16 device;
492
- __u16 row;
493
- __u16 column;
494
- __u16 bit_pos;
495
- __u64 requestor_id;
496
- __u64 responder_id;
497
- __u64 target_id;
498
- __u16 rank;
499
- __u16 mem_array_handle;
500
- __u16 mem_dev_handle;
483
+ u64 validation_bits;
484
+ u16 node;
485
+ u16 card;
486
+ u16 module;
487
+ u16 bank;
488
+ u16 device;
489
+ u16 row;
490
+ u16 column;
491
+ u16 bit_pos;
492
+ u64 requestor_id;
493
+ u64 responder_id;
494
+ u64 target_id;
495
+ u16 rank;
496
+ u16 mem_array_handle;
497
+ u16 mem_dev_handle;
498
+ u8 extended;
501499 };
502500
501
+static inline u32 cper_get_mem_extension(u64 mem_valid, u8 mem_extended)
502
+{
503
+ if (!(mem_valid & CPER_MEM_VALID_ROW_EXT))
504
+ return 0;
505
+ return (mem_extended & CPER_MEM_EXT_ROW_MASK) << CPER_MEM_EXT_ROW_SHIFT;
506
+}
507
+
508
+/* PCI Express Error Section, UEFI v2.7 sec N.2.7 */
503509 struct cper_sec_pcie {
504
- __u64 validation_bits;
505
- __u32 port_type;
510
+ u64 validation_bits;
511
+ u32 port_type;
506512 struct {
507
- __u8 minor;
508
- __u8 major;
509
- __u8 reserved[2];
513
+ u8 minor;
514
+ u8 major;
515
+ u8 reserved[2];
510516 } version;
511
- __u16 command;
512
- __u16 status;
513
- __u32 reserved;
517
+ u16 command;
518
+ u16 status;
519
+ u32 reserved;
514520 struct {
515
- __u16 vendor_id;
516
- __u16 device_id;
517
- __u8 class_code[3];
518
- __u8 function;
519
- __u8 device;
520
- __u16 segment;
521
- __u8 bus;
522
- __u8 secondary_bus;
523
- __u16 slot;
524
- __u8 reserved;
521
+ u16 vendor_id;
522
+ u16 device_id;
523
+ u8 class_code[3];
524
+ u8 function;
525
+ u8 device;
526
+ u16 segment;
527
+ u8 bus;
528
+ u8 secondary_bus;
529
+ u16 slot;
530
+ u8 reserved;
525531 } device_id;
526532 struct {
527
- __u32 lower;
528
- __u32 upper;
533
+ u32 lower;
534
+ u32 upper;
529535 } serial_number;
530536 struct {
531
- __u16 secondary_status;
532
- __u16 control;
537
+ u16 secondary_status;
538
+ u16 control;
533539 } bridge;
534
- __u8 capability[60];
535
- __u8 aer_info[96];
540
+ u8 capability[60];
541
+ u8 aer_info[96];
542
+};
543
+
544
+/* Firmware Error Record Reference, UEFI v2.7 sec N.2.10 */
545
+struct cper_sec_fw_err_rec_ref {
546
+ u8 record_type;
547
+ u8 revision;
548
+ u8 reserved[6];
549
+ u64 record_identifier;
550
+ guid_t record_identifier_guid;
536551 };
537552
538553 /* Reset to default packing */
539554 #pragma pack()
540555
541
-extern const char * const cper_proc_error_type_strs[4];
556
+extern const char *const cper_proc_error_type_strs[4];
542557
543558 u64 cper_next_record_id(void);
544559 const char *cper_severity_str(unsigned int);