prmt.c (caa2bd07f5c5f09acf62072906daeaa667e2b645) | prmt.c (c52ca713279da78881d36b49acd36288a46bbec8) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Author: Erik Kaneda <erik.kaneda@intel.com> 4 * Copyright 2020 Intel Corporation 5 * 6 * prmt.c 7 * 8 * Each PRM service is an executable that is run in a restricted environment --- 82 unchanged lines hidden (view full) --- 91 92static int __init 93acpi_parse_prmt(union acpi_subtable_headers *header, const unsigned long end) 94{ 95 struct acpi_prmt_module_info *module_info; 96 struct acpi_prmt_handler_info *handler_info; 97 struct prm_handler_info *th; 98 struct prm_module_info *tm; | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Author: Erik Kaneda <erik.kaneda@intel.com> 4 * Copyright 2020 Intel Corporation 5 * 6 * prmt.c 7 * 8 * Each PRM service is an executable that is run in a restricted environment --- 82 unchanged lines hidden (view full) --- 91 92static int __init 93acpi_parse_prmt(union acpi_subtable_headers *header, const unsigned long end) 94{ 95 struct acpi_prmt_module_info *module_info; 96 struct acpi_prmt_handler_info *handler_info; 97 struct prm_handler_info *th; 98 struct prm_module_info *tm; |
99 u64 mmio_count = 0; | 99 u64 *mmio_count; |
100 u64 cur_handler = 0; 101 u32 module_info_size = 0; 102 u64 mmio_range_size = 0; 103 void *temp_mmio; 104 105 module_info = (struct acpi_prmt_module_info *) header; 106 module_info_size = struct_size(tm, handlers, module_info->handler_info_count); 107 tm = kmalloc(module_info_size, GFP_KERNEL); | 100 u64 cur_handler = 0; 101 u32 module_info_size = 0; 102 u64 mmio_range_size = 0; 103 void *temp_mmio; 104 105 module_info = (struct acpi_prmt_module_info *) header; 106 module_info_size = struct_size(tm, handlers, module_info->handler_info_count); 107 tm = kmalloc(module_info_size, GFP_KERNEL); |
108 if (!tm) 109 goto parse_prmt_out1; |
|
108 109 guid_copy(&tm->guid, (guid_t *) module_info->module_guid); 110 tm->major_rev = module_info->major_rev; 111 tm->minor_rev = module_info->minor_rev; 112 tm->handler_count = module_info->handler_info_count; 113 tm->updatable = true; 114 115 if (module_info->mmio_list_pointer) { 116 /* 117 * Each module is associated with a list of addr 118 * ranges that it can use during the service 119 */ | 110 111 guid_copy(&tm->guid, (guid_t *) module_info->module_guid); 112 tm->major_rev = module_info->major_rev; 113 tm->minor_rev = module_info->minor_rev; 114 tm->handler_count = module_info->handler_info_count; 115 tm->updatable = true; 116 117 if (module_info->mmio_list_pointer) { 118 /* 119 * Each module is associated with a list of addr 120 * ranges that it can use during the service 121 */ |
120 mmio_count = *(u64 *) memremap(module_info->mmio_list_pointer, 8, MEMREMAP_WB); 121 mmio_range_size = struct_size(tm->mmio_info, addr_ranges, mmio_count); | 122 mmio_count = (u64 *) memremap(module_info->mmio_list_pointer, 8, MEMREMAP_WB); 123 if (!mmio_count) 124 goto parse_prmt_out2; 125 126 mmio_range_size = struct_size(tm->mmio_info, addr_ranges, *mmio_count); |
122 tm->mmio_info = kmalloc(mmio_range_size, GFP_KERNEL); | 127 tm->mmio_info = kmalloc(mmio_range_size, GFP_KERNEL); |
128 if (!tm->mmio_info) 129 goto parse_prmt_out3; 130 |
|
123 temp_mmio = memremap(module_info->mmio_list_pointer, mmio_range_size, MEMREMAP_WB); | 131 temp_mmio = memremap(module_info->mmio_list_pointer, mmio_range_size, MEMREMAP_WB); |
132 if (!temp_mmio) 133 goto parse_prmt_out4; |
|
124 memmove(tm->mmio_info, temp_mmio, mmio_range_size); 125 } else { | 134 memmove(tm->mmio_info, temp_mmio, mmio_range_size); 135 } else { |
126 mmio_range_size = struct_size(tm->mmio_info, addr_ranges, mmio_count); 127 tm->mmio_info = kmalloc(mmio_range_size, GFP_KERNEL); | 136 tm->mmio_info = kmalloc(sizeof(*tm->mmio_info), GFP_KERNEL); 137 if (!tm->mmio_info) 138 goto parse_prmt_out2; 139 |
128 tm->mmio_info->mmio_count = 0; 129 } 130 131 INIT_LIST_HEAD(&tm->module_list); 132 list_add(&tm->module_list, &prm_module_list); 133 134 handler_info = get_first_handler(module_info); 135 do { 136 th = &tm->handlers[cur_handler]; 137 138 guid_copy(&th->guid, (guid_t *)handler_info->handler_guid); 139 th->handler_addr = efi_pa_va_lookup(handler_info->handler_address); 140 th->static_data_buffer_addr = efi_pa_va_lookup(handler_info->static_data_buffer_address); 141 th->acpi_param_buffer_addr = efi_pa_va_lookup(handler_info->acpi_param_buffer_address); 142 } while (++cur_handler < tm->handler_count && (handler_info = get_next_handler(handler_info))); 143 144 return 0; | 140 tm->mmio_info->mmio_count = 0; 141 } 142 143 INIT_LIST_HEAD(&tm->module_list); 144 list_add(&tm->module_list, &prm_module_list); 145 146 handler_info = get_first_handler(module_info); 147 do { 148 th = &tm->handlers[cur_handler]; 149 150 guid_copy(&th->guid, (guid_t *)handler_info->handler_guid); 151 th->handler_addr = efi_pa_va_lookup(handler_info->handler_address); 152 th->static_data_buffer_addr = efi_pa_va_lookup(handler_info->static_data_buffer_address); 153 th->acpi_param_buffer_addr = efi_pa_va_lookup(handler_info->acpi_param_buffer_address); 154 } while (++cur_handler < tm->handler_count && (handler_info = get_next_handler(handler_info))); 155 156 return 0; |
157 158parse_prmt_out4: 159 kfree(tm->mmio_info); 160parse_prmt_out3: 161 memunmap(mmio_count); 162parse_prmt_out2: 163 kfree(tm); 164parse_prmt_out1: 165 return -ENOMEM; |
|
145} 146 147#define GET_MODULE 0 148#define GET_HANDLER 1 149 150static void *find_guid_info(const guid_t *guid, u8 mode) 151{ 152 struct prm_handler_info *cur_handler; --- 161 unchanged lines hidden --- | 166} 167 168#define GET_MODULE 0 169#define GET_HANDLER 1 170 171static void *find_guid_info(const guid_t *guid, u8 mode) 172{ 173 struct prm_handler_info *cur_handler; --- 161 unchanged lines hidden --- |