| 176 | } |
| 177 | |
| 178 | static int |
| 179 | handle_free_request(const struct malloc_mp_req *m) |
| 180 | { |
| 181 | const struct rte_memseg_list *msl; |
| 182 | void *start, *end; |
| 183 | size_t len; |
| 184 | |
| 185 | len = m->free_req.len; |
| 186 | start = m->free_req.addr; |
| 187 | end = RTE_PTR_ADD(start, len - 1); |
| 188 | |
| 189 | /* check if the requested memory actually exists */ |
| 190 | msl = rte_mem_virt2memseg_list(start); |
| 191 | if (msl == NULL) { |
| 192 | RTE_LOG(ERR, EAL, "Requested to free unknown memory\n"); |
| 193 | return -1; |
| 194 | } |
| 195 | |
| 196 | /* check if end is within the same memory region */ |
| 197 | if (rte_mem_virt2memseg_list(end) != msl) { |
| 198 | RTE_LOG(ERR, EAL, "Requested to free memory spanning multiple regions\n"); |
| 199 | return -1; |
| 200 | } |
| 201 | |
| 202 | /* we're supposed to only free memory that's not external */ |
| 203 | if (msl->external) { |
| 204 | RTE_LOG(ERR, EAL, "Requested to free external memory\n"); |
| 205 | return -1; |
| 206 | } |
| 207 | |
| 208 | /* now that we've validated the request, announce it */ |
| 209 | eal_memalloc_mem_event_notify(RTE_MEM_EVENT_FREE, |
| 210 | m->free_req.addr, m->free_req.len); |
| 211 | |
| 212 | /* now, do the actual freeing */ |
| 213 | return malloc_heap_free_pages(m->free_req.addr, m->free_req.len); |
| 214 | } |
| 215 | |
| 216 | static int |
| 217 | handle_alloc_request(const struct malloc_mp_req *m, |
no test coverage detected