def pageFaultHapAlone(self, hap_cpu): #cpu = SIM_current_processor() #if cpu != hap_cpu: # self.lgr.debug('pageFaultHap, wrong cpu %s %s' % (cpu.name, hap_cpu.name)) # return use_cell = self.cell if self.debugging_pid is not None: use_cell = self.context_manager.getRESimContext() cpu, comm, pid = self.task_utils.curProc() eip = self.exception_eip if self.cpu.architecture == 'arm': reg_num = self.cpu.iface.int_register.get_number("combined_data_far") else: reg_num = self.cpu.iface.int_register.get_number("cr2") cr2 = self.cpu.iface.int_register.read(reg_num) if pid not in self.faulted_pages: self.faulted_pages[pid] = [] if cr2 in self.faulted_pages[pid]: return self.faulted_pages[pid].append(cr2) self.lgr.debug('pageFaultHap for %d (%s) at 0x%x faulting address: 0x%x' % (pid, comm, eip, cr2)) if eip != cr2: instruct = SIM_disassemble_address(self.cpu, eip, 1, 0) #self.lgr.debug('faulting instruction %s' % instruct[1]) else: #self.lgr.debug('eip 0x%x not mapped' % eip) pass if pageUtils.isIA32E(cpu): page_info = pageUtils.findPageTableIA32E(self.cpu, cr2, self.lgr) else: page_info = pageUtils.findPageTable(self.cpu, cr2, self.lgr) if not page_info.page_exists: prec = Prec(self.cpu, comm, pid, cr2, eip) list_addr = self.task_utils.getTaskListPtr() ''' if not, assume not yet in task list ''' if list_addr is not None: SIM_run_alone(self.watchExit, None) self.task_rec_break[pid] = SIM_breakpoint(use_cell, Sim_Break_Linear, Sim_Access_Write, list_addr, self.mem_utils.WORD_SIZE, 0) self.lgr.debug('pageFaultHap pid:%d set list break %d at 0x%x cycle 0x%x' % (pid, self.task_rec_break[pid], list_addr, prec.cycles)) self.task_rec_hap[pid] = SIM_hap_add_callback_index("Core_Breakpoint_Memop", self.taskRecHap, prec, self.task_rec_break[pid]) #SIM_break_simulation('page fault page does not exist at 0x%x proc %d (%s)' % (cr2, pid, comm)) #self.lgr.debug('page fault page does not exist at 0x%x proc %d (%s)' % (cr2, pid, comm)) ##self.lgr.debug(page_info.valueString()) if not page_info.ptable_exists: #self.lgr.debug('watch pdir address of 0x%x' % page_info.pdir_addr) self.lgr.debug('watch pdir address of 0x%x' % page_info.ptable_addr) self.watchPdir(page_info.ptable_addr, prec) else: #self.lgr.debug('watch ptable address of 0x%x' % page_info.ptable_addr) self.lgr.debug('watch ptable address of 0x%x' % page_info.page_addr) self.watchPtable(page_info.page_addr, prec) else: self.lgr.error('pageFaultHap proc %s (%d) gone?' % (comm, pid))
def pageFaultHap(self, compat32, third, forth, memory): if self.fault_hap is None: return #cpu, comm, pid = self.task_utils.curProc() #self.lgr.debug('pageFaultHap pid:%d third: %s forth: %s' % (pid, str(third), str(forth))) #cpu = SIM_current_processor() #if cpu != hap_cpu: # self.lgr.debug('pageFaultHap, wrong cpu %s %s' % (cpu.name, hap_cpu.name)) # return #use_cell = self.cell #if self.debugging_pid is not None: # use_cell = self.context_manager.getRESimContext() cpu, comm, pid = self.task_utils.curProc() eip = self.exception_eip cur_pc = self.mem_utils.getRegValue(cpu, 'pc') if self.cpu.architecture == 'arm': if cur_pc == self.param.page_fault: ''' prefetch abort ''' reg_num = None else: reg_num = self.cpu.iface.int_register.get_number( "combined_data_far") else: reg_num = self.cpu.iface.int_register.get_number("cr2") if reg_num is not None: cr2 = self.cpu.iface.int_register.read(reg_num) else: cr2 = eip if pid not in self.faulted_pages: self.faulted_pages[pid] = [] if cr2 in self.faulted_pages[pid]: self.lgr.debug( 'pageFaultHapAlone, addr 0x%x already handled for pid:%d cur_pc: 0x%x' % (cr2, pid, cur_pc)) return self.faulted_pages[pid].append(cr2) #self.lgr.debug('pageFaultHapAlone for %d (%s) faulting address: 0x%x' % (pid, comm, cr2)) #self.lgr.debug('pageFaultHap for %d (%s) at 0x%x faulting address: 0x%x' % (pid, comm, eip, cr2)) #self.lgr.debug('len of faulted pages is now %d' % len(self.faulted_pages)) if cpu.architecture == 'arm': page_info = pageUtils.findPageTableArm(self.cpu, cr2, self.lgr) elif pageUtils.isIA32E(cpu): page_info = pageUtils.findPageTableIA32E(self.cpu, cr2, self.lgr) else: page_info = pageUtils.findPageTable(self.cpu, cr2, self.lgr) prec = Prec(self.cpu, comm, pid, cr2, eip) if pid not in self.pending_faults: self.pending_faults[pid] = prec #self.lgr.debug('pageFaultHapAlone add pending fault for %d cycle 0x%x' % (pid, prec.cycles)) hack_rec = (compat32, page_info, prec) SIM_run_alone(self.pageFaultHapAlone, hack_rec)
def pageFaultHapAlone(self, compat32): #cpu = SIM_current_processor() #if cpu != hap_cpu: # self.lgr.debug('pageFaultHap, wrong cpu %s %s' % (cpu.name, hap_cpu.name)) # return use_cell = self.cell if self.debugging_pid is not None: use_cell = self.context_manager.getRESimContext() cpu, comm, pid = self.task_utils.curProc() eip = self.exception_eip cur_pc = self.mem_utils.getRegValue(cpu, 'pc') if self.cpu.architecture == 'arm': if cur_pc == self.param.page_fault: ''' prefetch abort ''' reg_num = None else: reg_num = self.cpu.iface.int_register.get_number( "combined_data_far") else: reg_num = self.cpu.iface.int_register.get_number("cr2") if reg_num is not None: cr2 = self.cpu.iface.int_register.read(reg_num) else: cr2 = eip if pid not in self.faulted_pages: self.faulted_pages[pid] = [] if cr2 in self.faulted_pages[pid]: self.lgr.debug( 'pageFaultHapAlone, addr 0x%x already handled for pid%d cur_pc: 0x%x' % (cr2, pid, cur_pc)) return self.faulted_pages[pid].append(cr2) #self.lgr.debug('pageFaultHapAlone for %d (%s) faulting address: 0x%x' % (pid, comm, cr2)) #self.lgr.debug('pageFaultHap for %d (%s) at 0x%x faulting address: 0x%x' % (pid, comm, eip, cr2)) if eip != cr2: instruct = SIM_disassemble_address(self.cpu, eip, 1, 0) #self.lgr.debug('faulting instruction %s' % instruct[1]) else: #self.lgr.debug('eip 0x%x not mapped' % eip) pass if cpu.architecture == 'arm': page_info = pageUtils.findPageTableArm(self.cpu, cr2, self.lgr) elif pageUtils.isIA32E(cpu): page_info = pageUtils.findPageTableIA32E(self.cpu, cr2, self.lgr) else: page_info = pageUtils.findPageTable(self.cpu, cr2, self.lgr) if not page_info.page_exists: prec = Prec(self.cpu, comm, pid, cr2, eip) if pid not in self.pending_faults: self.pending_faults[pid] = prec #self.lgr.debug('pageFaultHapAlone add pending fault for %d cycle 0x%x' % (pid, prec.cycles)) else: #self.lgr.debug('pageFaultHapAlone ALREADY pending fault for %d this cycle 0x%x' % (pid, prec.cycles)) pass ''' Rely on ContextManager to watch for task kills if debugging -- and not ''' if self.debugging_pid is None: #SIM_run_alone(self.watchExit, compat32) self.context_manager.watchExit() ''' list_addr = self.task_utils.getTaskListPtr() if list_addr is not None: SIM_run_alone(self.watchExit, compat32) self.task_rec_break[pid] = SIM_breakpoint(use_cell, Sim_Break_Linear, Sim_Access_Write, list_addr, self.mem_utils.WORD_SIZE, 0) self.lgr.debug('pageFaultHap pid:%d set list break %d at 0x%x cycle 0x%x' % (pid, self.task_rec_break[pid], list_addr, prec.cycles)) self.task_rec_hap[pid] = SIM_hap_add_callback_index("Core_Breakpoint_Memop", self.taskRecHap, prec, self.task_rec_break[pid]) #SIM_break_simulation('page fault page does not exist at 0x%x proc %d (%s)' % (cr2, pid, comm)) #self.lgr.debug('page fault page does not exist at 0x%x proc %d (%s)' % (cr2, pid, comm)) ##self.lgr.debug(page_info.valueString()) else: self.lgr.error('pageFaultHap proc %s (%d) gone?' % (comm, pid)) ''' if not page_info.ptable_exists: if page_info.ptable_addr is not None: #self.lgr.debug('watch pdir address of 0x%x' % page_info.pdir_addr) #self.lgr.debug('watch pdir address of 0x%x' % page_info.ptable_addr) self.watchPdir(page_info.ptable_addr, prec) else: #self.lgr.debug('pageFaultGen pageFaultHapAlone ptable_addr was None') self.watchPdir(page_info.pdir_addr, prec) elif page_info.page_addr is not None: #self.lgr.debug('watch ptable address of 0x%x' % page_info.ptable_addr) #self.lgr.debug('watch ptable address of 0x%x' % page_info.page_addr) self.watchPtable(page_info.page_addr, prec) else: #self.lgr.debug('pageFaultGen pageFaultHapAlone page_addr was None') self.watchPtable(page_info.ptable_addr, prec) else: #self.lgr.debug('pageFaultHap page must exist? pid %d %s' % (pid, page_info.valueString())) pass
def pageFaultHap(self, compat32, third, forth, memory): if self.fault_hap is None: return #self.lgr.debug('pageFaultHap') #cpu, comm, pid = self.task_utils.curProc() #self.lgr.debug('pageFaultHap pid:%d third: %s forth: %s' % (pid, str(third), str(forth))) #cpu = SIM_current_processor() #if cpu != hap_cpu: # self.lgr.debug('pageFaultHap, wrong cpu %s %s' % (cpu.name, hap_cpu.name)) # return #use_cell = self.cell #if self.debugging_pid is not None: # use_cell = self.context_manager.getRESimContext() cpu, comm, pid = self.task_utils.curProc() if not self.context_manager.watchingThis(): #self.lgr.debug('pageFaultHap pid:%d, contextManager says not watching' % pid) return eip = self.exception_eip cur_pc = self.mem_utils.getRegValue(cpu, 'pc') access_type = None if self.cpu.architecture == 'arm': if cur_pc == self.param.page_fault: ''' prefetch abort ''' reg_num = None else: reg_num = self.cpu.iface.int_register.get_number( "combined_data_far") data_fault_reg = self.cpu.iface.int_register.get_number( "combined_data_fsr") fault = self.cpu.iface.int_register.read(data_fault_reg) access_type = memUtils.testBit(fault, 11) self.lgr.debug( 'data fault pid:%d reg value 0x%x violation type: %d' % (pid, fault, access_type)) else: reg_num = self.cpu.iface.int_register.get_number("cr2") if reg_num is not None: cr2 = self.cpu.iface.int_register.read(reg_num) #self.lgr.debug('cr2 read is 0x%x' % cr2) else: cr2 = eip if pid not in self.faulted_pages: self.faulted_pages[pid] = [] if cr2 in self.faulted_pages[pid]: #self.lgr.debug('pageFaultHap, addr 0x%x already handled for pid:%d cur_pc: 0x%x' % (cr2, pid, cur_pc)) return self.faulted_pages[pid].append(cr2) #self.lgr.debug('pageFaultHapAlone for %d (%s) faulting address: 0x%x' % (pid, comm, cr2)) #self.lgr.debug('pageFaultHap for %d (%s) at 0x%x faulting address: 0x%x' % (pid, comm, eip, cr2)) #self.lgr.debug('len of faulted pages is now %d' % len(self.faulted_pages)) if cpu.architecture == 'arm': page_info = pageUtils.findPageTableArm(self.cpu, cr2, self.lgr) elif pageUtils.isIA32E(cpu): page_info = pageUtils.findPageTableIA32E(self.cpu, cr2, self.lgr) else: page_info = pageUtils.findPageTable(self.cpu, cr2, self.lgr) prec = Prec(self.cpu, comm, pid, cr2, eip) if pid not in self.pending_faults: self.pending_faults[pid] = prec #self.lgr.debug('pageFaultHap add pending fault for %d addr 0x%x cycle 0x%x' % (pid, prec.cr2, prec.cycles)) if self.mode_hap is None: #self.lgr.debug('pageFaultGen adding mode hap') self.mode_hap = SIM_hap_add_callback_obj( "Core_Mode_Change", cpu, 0, self.modeChanged, pid) hack_rec = (compat32, page_info, prec) SIM_run_alone(self.pageFaultHapAlone, hack_rec)