* Fix kernel_kseg0_end address in case trampoline placed debug sympols * data there */
| 382 | * data there |
| 383 | */ |
| 384 | void |
| 385 | mips_postboot_fixup(void) |
| 386 | { |
| 387 | /* |
| 388 | * We store u_long sized objects into the reload area, so the array |
| 389 | * must be so aligned. The standard allows any alignment for char data. |
| 390 | */ |
| 391 | _Alignas(_Alignof(u_long)) static char fake_preload[256]; |
| 392 | caddr_t preload_ptr = (caddr_t)&fake_preload[0]; |
| 393 | size_t size = 0; |
| 394 | |
| 395 | #define PRELOAD_PUSH_VALUE(type, value) do { \ |
| 396 | *(type *)(preload_ptr + size) = (value); \ |
| 397 | size += sizeof(type); \ |
| 398 | } while (0); |
| 399 | |
| 400 | /* |
| 401 | * Provide kernel module file information |
| 402 | */ |
| 403 | PRELOAD_PUSH_VALUE(uint32_t, MODINFO_NAME); |
| 404 | PRELOAD_PUSH_VALUE(uint32_t, strlen("kernel") + 1); |
| 405 | strcpy((char*)(preload_ptr + size), "kernel"); |
| 406 | size += strlen("kernel") + 1; |
| 407 | size = roundup(size, sizeof(u_long)); |
| 408 | |
| 409 | PRELOAD_PUSH_VALUE(uint32_t, MODINFO_TYPE); |
| 410 | PRELOAD_PUSH_VALUE(uint32_t, strlen("elf kernel") + 1); |
| 411 | strcpy((char*)(preload_ptr + size), "elf kernel"); |
| 412 | size += strlen("elf kernel") + 1; |
| 413 | size = roundup(size, sizeof(u_long)); |
| 414 | |
| 415 | PRELOAD_PUSH_VALUE(uint32_t, MODINFO_ADDR); |
| 416 | PRELOAD_PUSH_VALUE(uint32_t, sizeof(vm_offset_t)); |
| 417 | PRELOAD_PUSH_VALUE(vm_offset_t, KERNLOADADDR); |
| 418 | size = roundup(size, sizeof(u_long)); |
| 419 | |
| 420 | PRELOAD_PUSH_VALUE(uint32_t, MODINFO_SIZE); |
| 421 | PRELOAD_PUSH_VALUE(uint32_t, sizeof(size_t)); |
| 422 | PRELOAD_PUSH_VALUE(size_t, (size_t)&end - KERNLOADADDR); |
| 423 | size = roundup(size, sizeof(u_long)); |
| 424 | |
| 425 | /* End marker */ |
| 426 | PRELOAD_PUSH_VALUE(uint32_t, 0); |
| 427 | PRELOAD_PUSH_VALUE(uint32_t, 0); |
| 428 | |
| 429 | #undef PRELOAD_PUSH_VALUE |
| 430 | |
| 431 | KASSERT((size < sizeof(fake_preload)), |
| 432 | ("fake preload size is more thenallocated")); |
| 433 | |
| 434 | preload_metadata = (void *)fake_preload; |
| 435 | |
| 436 | #ifdef DDB |
| 437 | Elf_Size *trampoline_data = (Elf_Size*)kernel_kseg0_end; |
| 438 | Elf_Size symtabsize = 0; |
| 439 | vm_offset_t ksym_start; |
| 440 | vm_offset_t ksym_end; |
| 441 |
no test coverage detected