X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/e2d2fc5c71f7d145cba7267989251af45e3bb5ba..7ddcb079202367355dddccdfa4318e57d50318be:/osfmk/kdp/ml/i386/kdp_x86_common.c diff --git a/osfmk/kdp/ml/i386/kdp_x86_common.c b/osfmk/kdp/ml/i386/kdp_x86_common.c index 221d683ac..6016e4835 100644 --- a/osfmk/kdp/ml/i386/kdp_x86_common.c +++ b/osfmk/kdp/ml/i386/kdp_x86_common.c @@ -38,6 +38,8 @@ #include #include +#include + #include #include @@ -374,3 +376,36 @@ kdp_machine_msr64_write(kdp_writemsr64_req_t *rq, caddr_t data, uint16_t lcpu) wrmsr64(msr, *value); return KDPERR_NO_ERROR; } + +pt_entry_t *debugger_ptep; +vm_map_offset_t debugger_window_kva; + +/* Establish a pagetable window that can be remapped on demand. + * This is utilized by the debugger to address regions outside + * the physical map. + */ + +void +kdp_machine_init(void) { + if (debug_boot_arg == 0) + return; + + vm_map_entry_t e; + kern_return_t kr = vm_map_find_space(kernel_map, + &debugger_window_kva, + PAGE_SIZE, 0, + VM_MAKE_TAG(VM_MEMORY_IOKIT), &e); + + if (kr != KERN_SUCCESS) { + panic("%s: vm_map_find_space failed with %d\n", __FUNCTION__, kr); + } + + vm_map_unlock(kernel_map); + + debugger_ptep = pmap_pte(kernel_pmap, debugger_window_kva); + + if (debugger_ptep == NULL) { + pmap_expand(kernel_pmap, debugger_window_kva); + debugger_ptep = pmap_pte(kernel_pmap, debugger_window_kva); + } +}