Пример #1
0
    def __init__(self, ramdump):
        self.ramdump = ramdump
        self.domain_list = []

        root = self.ramdump.read_word('domain_root')
        if root is None:
            return
        rb_walker = rb_tree.RbTreeWalker(self.ramdump)
        rb_walker.walk(root, self._iommu_domain_func, self.domain_list)
Пример #2
0
    def parse(self):
        iommu_domains_rb_root = self.ramdump.addr_lookup(IOMMU_DOMAIN_VAR)
        if iommu_domains_rb_root is None:
            print_out_str(
                '[!] WARNING: IOMMU domains was not found in this build. No IOMMU page tables will be generated'
            )
            return

        out_dir = self.ramdump.outdir

        iommu_domains_rb_root_addr = self.ramdump.read_word(
            iommu_domains_rb_root)
        rb_walker = rb_tree.RbTreeWalker(self.ramdump)
        rb_walker.walk(iommu_domains_rb_root_addr, self.iommu_domain_func)

        for d in self.domain_list:
            self.out_file = open(
                '%s/msm_iommu_domain_%02d.txt' % (out_dir, d.domain_num), 'wb')
            redirect = 'OFF'
            if d.redirect is None:
                redirect = 'UNKNOWN'
            elif d.redirect > 0:
                redirect = 'ON'
            iommu_context = 'None attached'
            if len(d.ctx_list) > 0:
                iommu_context = ''
                for (num, name) in d.ctx_list:
                    iommu_context += '%s (%d) ' % (name, num)
            iommu_context = iommu_context.strip()

            self.out_file.write(
                'IOMMU Context: %s. Domain: %s (%d) [L2 cache redirect for page tables is %s]\n'
                % (iommu_context, d.client_name, d.domain_num, redirect))
            self.out_file.write(
                '[VA Start -- VA End  ] [Size      ] [PA Start   -- PA End  ] [Size      ] [Read/Write][Page Table Entry Size]\n'
            )
            if d.pg_table == 0:
                self.out_file.write(
                    'No Page Table Found. (Probably a secure domain)\n')
            else:
                self.print_page_table_pretty(d.pg_table)
                self.out_file.write('\n-------------\nRAW Dump\n')
                self.print_page_table(d.pg_table)
            self.out_file.close()
Пример #3
0
    def __init__(self, ramdump):
        self.ramdump = ramdump
        self.domain_list = []

        root = self.ramdump.read_word('domain_root')

        list_head_attachments = self.ramdump.read_pointer(
            'iommu_debug_attachments')

        if list_head_attachments is not None:
            list_head_arm_addr = self.ramdump.read_structure_field(
                list_head_attachments, 'struct list_head', 'prev')
            list_walker = llist.ListWalker(
                self.ramdump, list_head_arm_addr,
                self.ramdump.field_offset('struct iommu_debug_attachment',
                                          'list'))
            list_walker.walk(list_head_attachments,
                             self._iommu_domain_find_default, self.domain_list)

        if root is not None:
            rb_walker = rb_tree.RbTreeWalker(self.ramdump)
            rb_walker.walk(root, self._iommu_domain_func, self.domain_list)
Пример #4
0
    def print_cfs_state(self, cfs_rq_addr):
        tasks_timeline_offset = self.ramdump.field_offset(
            'struct cfs_rq', 'tasks_timeline')
        curr_offset = self.ramdump.field_offset('struct cfs_rq', 'curr')
        next_offset = self.ramdump.field_offset('struct cfs_rq', 'next')
        last_offset = self.ramdump.field_offset('struct cfs_rq', 'last')
        skip_offset = self.ramdump.field_offset('struct cfs_rq', 'skip')

        tasks_timeline_addr = self.ramdump.read_word(
            cfs_rq_addr + tasks_timeline_offset)

        curr_se = self.ramdump.read_word(cfs_rq_addr + curr_offset)
        self.print_cgroup_state('curr', curr_se)
        next_se = self.ramdump.read_word(cfs_rq_addr + next_offset)
        self.print_cgroup_state('next', next_se)
        last_se = self.ramdump.read_word(cfs_rq_addr + last_offset)
        self.print_cgroup_state('last', last_se)
        skip_se = self.ramdump.read_word(cfs_rq_addr + skip_offset)
        self.print_cgroup_state('skip', skip_se)

        rb_walker = rb_tree.RbTreeWalker(self.ramdump)
        rb_walker.walk(tasks_timeline_addr, self.cfs_node_func)
Пример #5
0
    def dump_vmas(self, ramdump, mm):
        def mm_rb_func(node, extra):
            vm_start = self.ramdump.read_u32(
                self.ramdump.sibling_field_addr(node, 'struct vm_area_struct',
                                                'vm_rb', 'vm_start'))
            vm_end = self.ramdump.read_u32(
                self.ramdump.sibling_field_addr(node, 'struct vm_area_struct',
                                                'vm_rb', 'vm_end'))
            vm_flags = self.ramdump.read_u32(
                self.ramdump.sibling_field_addr(node, 'struct vm_area_struct',
                                                'vm_rb', 'vm_flags'))
            vm_pgoff = self.ramdump.read_u32(
                self.ramdump.sibling_field_addr(node, 'struct vm_area_struct',
                                                'vm_rb', 'vm_pgoff'))
            vm_ops = self.ramdump.read_u32(
                self.ramdump.sibling_field_addr(node, 'struct vm_area_struct',
                                                'vm_rb', 'vm_ops'))
            print_out_str("{:08x}-{:08x} {:08x} {:08x} {:08x}".format(
                vm_start, vm_end, vm_flags, vm_pgoff, vm_ops))

        offset_mm_rb = ramdump.field_offset('struct mm_struct', 'mm_rb')
        root = ramdump.read_word(mm + offset_mm_rb)
        rb_walker = rb_tree.RbTreeWalker(self.ramdump)
        rb_walker.walk(root, mm_rb_func)