1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef GHES_H 2 #ifndef GHES_H 3 #define GHES_H 3 #define GHES_H 4 4 5 #include <acpi/apei.h> 5 #include <acpi/apei.h> 6 #include <acpi/hed.h> 6 #include <acpi/hed.h> 7 7 8 /* 8 /* 9 * One struct ghes is created for each generic 9 * One struct ghes is created for each generic hardware error source. 10 * It provides the context for APEI hardware e 10 * It provides the context for APEI hardware error timer/IRQ/SCI/NMI 11 * handler. 11 * handler. 12 * 12 * 13 * estatus: memory buffer for error status blo 13 * estatus: memory buffer for error status block, allocated during 14 * HEST parsing. 14 * HEST parsing. 15 */ 15 */ 16 #define GHES_EXITING 0x0002 16 #define GHES_EXITING 0x0002 17 17 18 struct ghes { 18 struct ghes { 19 union { 19 union { 20 struct acpi_hest_generic *gene 20 struct acpi_hest_generic *generic; 21 struct acpi_hest_generic_v2 *g 21 struct acpi_hest_generic_v2 *generic_v2; 22 }; 22 }; 23 struct acpi_hest_generic_status *estat 23 struct acpi_hest_generic_status *estatus; 24 unsigned long flags; 24 unsigned long flags; 25 union { 25 union { 26 struct list_head list; 26 struct list_head list; 27 struct timer_list timer; 27 struct timer_list timer; 28 unsigned int irq; 28 unsigned int irq; 29 }; 29 }; 30 struct device *dev; 30 struct device *dev; 31 struct list_head elist; 31 struct list_head elist; 32 }; 32 }; 33 33 34 struct ghes_estatus_node { 34 struct ghes_estatus_node { 35 struct llist_node llnode; 35 struct llist_node llnode; 36 struct acpi_hest_generic *generic; 36 struct acpi_hest_generic *generic; 37 struct ghes *ghes; 37 struct ghes *ghes; 38 38 39 int task_work_cpu; 39 int task_work_cpu; 40 struct callback_head task_work; 40 struct callback_head task_work; 41 }; 41 }; 42 42 43 struct ghes_estatus_cache { 43 struct ghes_estatus_cache { 44 u32 estatus_len; 44 u32 estatus_len; 45 atomic_t count; 45 atomic_t count; 46 struct acpi_hest_generic *generic; 46 struct acpi_hest_generic *generic; 47 unsigned long long time_in; 47 unsigned long long time_in; 48 struct rcu_head rcu; 48 struct rcu_head rcu; 49 }; 49 }; 50 50 51 enum { 51 enum { 52 GHES_SEV_NO = 0x0, 52 GHES_SEV_NO = 0x0, 53 GHES_SEV_CORRECTED = 0x1, 53 GHES_SEV_CORRECTED = 0x1, 54 GHES_SEV_RECOVERABLE = 0x2, 54 GHES_SEV_RECOVERABLE = 0x2, 55 GHES_SEV_PANIC = 0x3, 55 GHES_SEV_PANIC = 0x3, 56 }; 56 }; 57 57 58 #ifdef CONFIG_ACPI_APEI_GHES 58 #ifdef CONFIG_ACPI_APEI_GHES 59 /** 59 /** 60 * ghes_register_vendor_record_notifier - regi 60 * ghes_register_vendor_record_notifier - register a notifier for vendor 61 * records that the kernel would otherwise ign 61 * records that the kernel would otherwise ignore. 62 * @nb: pointer to the notifier_block structur 62 * @nb: pointer to the notifier_block structure of the event handler. 63 * 63 * 64 * return 0 : SUCCESS, non-zero : FAIL 64 * return 0 : SUCCESS, non-zero : FAIL 65 */ 65 */ 66 int ghes_register_vendor_record_notifier(struc 66 int ghes_register_vendor_record_notifier(struct notifier_block *nb); 67 67 68 /** 68 /** 69 * ghes_unregister_vendor_record_notifier - un 69 * ghes_unregister_vendor_record_notifier - unregister the previously 70 * registered vendor record notifier. 70 * registered vendor record notifier. 71 * @nb: pointer to the notifier_block structur 71 * @nb: pointer to the notifier_block structure of the vendor record handler. 72 */ 72 */ 73 void ghes_unregister_vendor_record_notifier(st 73 void ghes_unregister_vendor_record_notifier(struct notifier_block *nb); 74 74 75 struct list_head *ghes_get_devices(void); 75 struct list_head *ghes_get_devices(void); 76 76 77 void ghes_estatus_pool_region_free(unsigned lo 77 void ghes_estatus_pool_region_free(unsigned long addr, u32 size); 78 #else 78 #else 79 static inline struct list_head *ghes_get_devic 79 static inline struct list_head *ghes_get_devices(void) { return NULL; } 80 80 81 static inline void ghes_estatus_pool_region_fr 81 static inline void ghes_estatus_pool_region_free(unsigned long addr, u32 size) { return; } 82 #endif 82 #endif 83 83 84 int ghes_estatus_pool_init(unsigned int num_gh 84 int ghes_estatus_pool_init(unsigned int num_ghes); 85 85 86 static inline int acpi_hest_get_version(struct 86 static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata) 87 { 87 { 88 return gdata->revision >> 8; 88 return gdata->revision >> 8; 89 } 89 } 90 90 91 static inline void *acpi_hest_get_payload(stru 91 static inline void *acpi_hest_get_payload(struct acpi_hest_generic_data *gdata) 92 { 92 { 93 if (acpi_hest_get_version(gdata) >= 3) 93 if (acpi_hest_get_version(gdata) >= 3) 94 return (void *)(((struct acpi_ 94 return (void *)(((struct acpi_hest_generic_data_v300 *)(gdata)) + 1); 95 95 96 return gdata + 1; 96 return gdata + 1; 97 } 97 } 98 98 99 static inline int acpi_hest_get_error_length(s 99 static inline int acpi_hest_get_error_length(struct acpi_hest_generic_data *gdata) 100 { 100 { 101 return ((struct acpi_hest_generic_data 101 return ((struct acpi_hest_generic_data *)(gdata))->error_data_length; 102 } 102 } 103 103 104 static inline int acpi_hest_get_size(struct ac 104 static inline int acpi_hest_get_size(struct acpi_hest_generic_data *gdata) 105 { 105 { 106 if (acpi_hest_get_version(gdata) >= 3) 106 if (acpi_hest_get_version(gdata) >= 3) 107 return sizeof(struct acpi_hest 107 return sizeof(struct acpi_hest_generic_data_v300); 108 108 109 return sizeof(struct acpi_hest_generic 109 return sizeof(struct acpi_hest_generic_data); 110 } 110 } 111 111 112 static inline int acpi_hest_get_record_size(st 112 static inline int acpi_hest_get_record_size(struct acpi_hest_generic_data *gdata) 113 { 113 { 114 return (acpi_hest_get_size(gdata) + ac 114 return (acpi_hest_get_size(gdata) + acpi_hest_get_error_length(gdata)); 115 } 115 } 116 116 117 static inline void *acpi_hest_get_next(struct 117 static inline void *acpi_hest_get_next(struct acpi_hest_generic_data *gdata) 118 { 118 { 119 return (void *)(gdata) + acpi_hest_get 119 return (void *)(gdata) + acpi_hest_get_record_size(gdata); 120 } 120 } 121 121 122 #define apei_estatus_for_each_section(estatus, 122 #define apei_estatus_for_each_section(estatus, section) \ 123 for (section = (struct acpi_hest_gener 123 for (section = (struct acpi_hest_generic_data *)(estatus + 1); \ 124 (void *)section - (void *)(estatu 124 (void *)section - (void *)(estatus + 1) < estatus->data_length; \ 125 section = acpi_hest_get_next(sect 125 section = acpi_hest_get_next(section)) 126 126 127 #ifdef CONFIG_ACPI_APEI_SEA 127 #ifdef CONFIG_ACPI_APEI_SEA 128 int ghes_notify_sea(void); 128 int ghes_notify_sea(void); 129 #else 129 #else 130 static inline int ghes_notify_sea(void) { retu 130 static inline int ghes_notify_sea(void) { return -ENOENT; } 131 #endif 131 #endif 132 132 133 struct notifier_block; 133 struct notifier_block; 134 extern void ghes_register_report_chain(struct 134 extern void ghes_register_report_chain(struct notifier_block *nb); 135 extern void ghes_unregister_report_chain(struc 135 extern void ghes_unregister_report_chain(struct notifier_block *nb); 136 #endif /* GHES_H */ 136 #endif /* GHES_H */ 137 137
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.