当前位置: 首页>>代码示例>>C++>>正文


C++ pgd_present函数代码示例

本文整理汇总了C++中pgd_present函数的典型用法代码示例。如果您正苦于以下问题:C++ pgd_present函数的具体用法?C++ pgd_present怎么用?C++ pgd_present使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pgd_present函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: __do_vmalloc_fault

static int __do_vmalloc_fault(unsigned long addr, struct mm_struct *mm)
{
	/* Synchronise this task's top level page-table
	 * with the 'reference' page table.
	 */
	int offset = __pgd_offset(addr);
	pgd_t *pgd, *pgd_k;
	pmd_t *pmd, *pmd_k;

	pgd_k = init_mm.pgd + offset;
	if (!pgd_present(*pgd_k))
		goto bad_area;

	pgd = mm->pgd + offset;
#if 0	/* note that we are two-level */
	if (!pgd_present(*pgd))
		set_pgd(pgd, *pgd_k);
#endif

	pmd_k = pmd_offset(pgd_k, addr);
	if (pmd_none(*pmd_k))
		goto bad_area;

	pmd = pmd_offset(pgd, addr);
	if (!pmd_none(*pmd))
		goto bad_area;
	set_pmd(pmd, *pmd_k);
	return 1;

bad_area:
	return -2;
}
开发者ID:dmgerman,项目名称:linux-pre-history,代码行数:32,代码来源:fault-common.c

示例2: find_num_contig

static int find_num_contig(struct mm_struct *mm, unsigned long addr,
			   pte_t *ptep, pte_t pte, size_t *pgsize)
{
	pgd_t *pgd = pgd_offset(mm, addr);
	pud_t *pud;
	pmd_t *pmd;

	*pgsize = PAGE_SIZE;
	if (!pte_cont(pte))
		return 1;
	if (!pgd_present(*pgd)) {
		VM_BUG_ON(!pgd_present(*pgd));
		return 1;
	}
	pud = pud_offset(pgd, addr);
	if (!pud_present(*pud)) {
		VM_BUG_ON(!pud_present(*pud));
		return 1;
	}
	pmd = pmd_offset(pud, addr);
	if (!pmd_present(*pmd)) {
		VM_BUG_ON(!pmd_present(*pmd));
		return 1;
	}
	if ((pte_t *)pmd == ptep) {
		*pgsize = PMD_SIZE;
		return CONT_PMDS;
	}
	return CONT_PTES;
}
开发者ID:291700351,项目名称:linux,代码行数:30,代码来源:hugetlbpage.c

示例3: handle_tlbmiss

static int handle_tlbmiss(struct mm_struct *mm,
              unsigned long long protection_flags,
              unsigned long long textaccess,
              unsigned long address)
{
    pgd_t *dir;
    pud_t *pud;
    pmd_t *pmd;
    pte_t *pte;
    pte_t entry;

    /* NB. The PGD currently only contains a single entry - there is no
       page table tree stored for the top half of the address space since
       virtual pages in that region should never be mapped in user mode.
       (In kernel mode, the only things in that region are the 512Mb super
       page (locked in), and vmalloc (modules) +  I/O device pages (handled
       by handle_vmalloc_fault), so no PGD for the upper half is required
       by kernel mode either).

       See how mm->pgd is allocated and initialised in pgd_alloc to see why
       the next test is necessary.  - RPC */
    if (address >= (unsigned long) TASK_SIZE)
        /* upper half - never has page table entries. */
        return 0;

    dir = pgd_offset(mm, address);
    if (pgd_none(*dir) || !pgd_present(*dir))
        return 0;
    if (!pgd_present(*dir))
        return 0;

    pud = pud_offset(dir, address);
    if (pud_none(*pud) || !pud_present(*pud))
        return 0;

    pmd = pmd_offset(pud, address);
    if (pmd_none(*pmd) || !pmd_present(*pmd))
        return 0;

    pte = pte_offset_kernel(pmd, address);
    entry = *pte;

    if (pte_none(entry) || !pte_present(entry))
        return 0;

    /*
     * If the page doesn't have sufficient protection bits set to
     * service the kind of fault being handled, there's not much
     * point doing the TLB refill.  Punt the fault to the general
     * handler.
     */
    if ((pte_val(entry) & protection_flags) != protection_flags)
        return 0;

        __do_tlb_refill(address, textaccess, pte);

    return 1;
}
开发者ID:274914765,项目名称:C,代码行数:58,代码来源:fault_64.c

示例4: sys_my_syscall

asmlinkage long sys_my_syscall( int pid, unsigned long address)
{
   
   struct task_struct* task;
   struct mm_struct* mm;
   pgd_t* pgd;
   pud_t* pud;
   pmd_t* pmd;
   pte_t* pte;
   unsigned long pte_val ;
   printk(KERN_INFO "PID: %d, VIRTUAL_ADDR: 0x%lx\n", pid, address);
   for_each_process(task)
   {
     if(task->pid == pid)
     {           
      printk(KERN_INFO "Task %d found\n", task->pid);
      mm = task->mm;
      
      pgd = pgd_offset(mm, address);
      printk(KERN_INFO "PGD INFO: PRESENT: %d, BAD: %d, NONE: %d\n", pgd_present(*pgd), pgd_bad(*pgd), pgd_none(*pgd));
      if(!(pgd_none(*pgd) || pgd_bad(*pgd)) && pgd_present(*pgd))
      {
        printk(KERN_INFO "PGD INFO: PRESENT: %d, BAD: %d, NONE: %d\n", pgd_present(*pgd), pgd_bad(*pgd), pgd_none(*pgd));
        pud = pud_offset(pgd, address);
        printk(KERN_INFO "PUD INFO: PRESENT: %d, BAD: %d, NONE: %d\n", pud_present(*pud), pud_bad(*pud), pud_none(*pud));
           
        if(!(pud_none(*pud) || pud_bad(*pud)) && pud_present(*pud))
        {
          printk(KERN_INFO "PUD INFO: PRESENT: %d, BAD: %d, NONE: %d\n", pud_present(*pud), pud_bad(*pud), pud_none(*pud));
          pmd = pmd_offset(pud, address);
          printk(KERN_INFO "PMD INFO: PRESENT: %d, BAD: %d, NONE: %d\n", pmd_present(*pmd), pmd_bad(*pmd), pmd_none(*pmd));
           
          if(!(pmd_none(*pmd) || pmd_bad(*pmd)) && pmd_present(*pmd))
          {
            printk(KERN_INFO "PMD INFO: PRESENT: %d, BAD: %d, NONE: %d\n", pmd_present(*pmd), pmd_bad(*pmd), pmd_none(*pmd));
            pte = pte_offset_map(pmd, address);
            printk(KERN_INFO "PTE INFO: PRESENT: %d PTE: 0x%lx \n ", pte_present(*pte), pte->pte);


            pte_val = pte->pte;
            
            if(pte_val == 0)
                pte_val = __pte_to_swp_entry(*pte).val;
            
            pte_unmap(pte);
            printk(KERN_INFO "pte_val: %lx\n" , pte_val);
            return pte_val;
            
            }
        }
      }
    }
  }
  printk(KERN_INFO "Data not found!\n");
  return 0;
}
开发者ID:amastov,项目名称:CSE430P3,代码行数:56,代码来源:my_syscall.c

示例5: walk_pgd_level

static void walk_pgd_level(struct seq_file *m)
{
#ifdef CONFIG_X86_64
	pgd_t *start = (pgd_t *) &init_level4_pgt;
#else
	pgd_t *start = swapper_pg_dir;
#endif
	int i;
	struct pg_state st;

	memset(&st, 0, sizeof(st));

	for (i = 0; i < PTRS_PER_PGD; i++) {
		st.current_address = normalize_addr(i * PGD_LEVEL_MULT);
		if (!pgd_none(*start)) {
			pgprotval_t prot = pgd_val(*start) & PTE_FLAGS_MASK;

			if (pgd_large(*start) || !pgd_present(*start))
				note_page(m, &st, __pgprot(prot), 1);
			else
				walk_pud_level(m, &st, *start,
					       i * PGD_LEVEL_MULT);
		} else
			note_page(m, &st, __pgprot(0), 1);

		start++;
	}

	/* Flush out the last page */
	st.current_address = normalize_addr(PTRS_PER_PGD*PGD_LEVEL_MULT);
	note_page(m, &st, __pgprot(0), 0);
}
开发者ID:03199618,项目名称:linux,代码行数:32,代码来源:dump_pagetables.c

示例6: pgd_index

static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
{
	unsigned index = pgd_index(address);
	pgd_t *pgd_k;
	pud_t *pud, *pud_k;
	pmd_t *pmd, *pmd_k;

	pgd += index;
	pgd_k = init_mm.pgd + index;

	if (!pgd_present(*pgd_k))
		return NULL;

	pud = pud_offset(pgd, address);
	pud_k = pud_offset(pgd_k, address);
	if (!pud_present(*pud_k))
		return NULL;

	pmd = pmd_offset(pud, address);
	pmd_k = pmd_offset(pud_k, address);
	if (!pmd_present(*pmd_k))
		return NULL;
	if (!pmd_present(*pmd)) {
		set_pmd(pmd, *pmd_k);
		arch_flush_lazy_mmu_mode();
	} else
		BUG_ON(pmd_ptfn(*pmd) != pmd_ptfn(*pmd_k));
	return pmd_k;
}
开发者ID:0xroot,项目名称:Blackphone-BP1-Kernel,代码行数:29,代码来源:fault.c

示例7: lookup_pte

pte_t *
lookup_pte(pgd_t *page_dir, unsigned long pf_address)
{
	/*
	 * find the page table entry within the page table hierarchy
	 */
	pte_t *pte = NULL;
	pgd_t *pgd = page_dir + pgd_index(pf_address);

#ifdef DEBUG_LOOKUP_PTABS
	if ((int)page_dir < 0x1000) {
		printk("%s: page_dir=%x\n", __func__, (int)page_dir);
		enter_kdebug("page_dir<4096");
	}
	printk("%s: %lx pdir = %p\n", __func__, pf_address, pgd);
#endif
	if (pgd_present(*pgd)) {
		pmd_t *pmd = pmd_offset(pgd, pf_address);
#ifdef DEBUG_LOOKUP_PTABS
		printk("pgd_present(*%x) is true\n", pgd);
		printk(" pmd = %p\n", pmd);
#endif
		if (pmd_present(*pmd)) {
#ifdef DEBUG_LOOKUP_PTABS
			printk("pmd_present(*%x) is true\n", pmd);
#endif
			pte = pte_offset_map(pmd, pf_address);
		}
	}
#ifdef DEBUG_LOOKUP_PTABS
	printk("returning:  pte = %p\n", pte);
#endif
	return pte;
}
开发者ID:CSU-GH,项目名称:okl4_3.0,代码行数:34,代码来源:tlb.c

示例8: kvm_mips_flush_gpa_pgd

static bool kvm_mips_flush_gpa_pgd(pgd_t *pgd, unsigned long start_gpa,
				   unsigned long end_gpa)
{
	pud_t *pud;
	unsigned long end = ~0ul;
	int i_min = pgd_index(start_gpa);
	int i_max = pgd_index(end_gpa);
	bool safe_to_remove = (i_min == 0 && i_max == PTRS_PER_PGD - 1);
	int i;

	for (i = i_min; i <= i_max; ++i, start_gpa = 0) {
		if (!pgd_present(pgd[i]))
			continue;

		pud = pud_offset(pgd + i, 0);
		if (i == i_max)
			end = end_gpa;

		if (kvm_mips_flush_gpa_pud(pud, start_gpa, end)) {
			pgd_clear(pgd + i);
			pud_free(NULL, pud);
		} else {
			safe_to_remove = false;
		}
	}
	return safe_to_remove;
}
开发者ID:0x7f454c46,项目名称:linux,代码行数:27,代码来源:mmu.c

示例9: handle_vmalloc_fault

static int handle_vmalloc_fault(unsigned long address)
{
	/*
	 * Synchronize this task's top level page-table
	 * with the 'reference' page table.
	 */
	pgd_t *pgd, *pgd_k;
	pud_t *pud, *pud_k;
	pmd_t *pmd, *pmd_k;

	pgd = pgd_offset_fast(current->active_mm, address);
	pgd_k = pgd_offset_k(address);

	if (!pgd_present(*pgd_k))
		goto bad_area;

	pud = pud_offset(pgd, address);
	pud_k = pud_offset(pgd_k, address);
	if (!pud_present(*pud_k))
		goto bad_area;

	pmd = pmd_offset(pud, address);
	pmd_k = pmd_offset(pud_k, address);
	if (!pmd_present(*pmd_k))
		goto bad_area;

	set_pmd(pmd, *pmd_k);

	/* XXX: create the TLB entry here */
	return 0;

bad_area:
	return 1;
}
开发者ID:1n00bB,项目名称:android_kernel_lenovo_a6010,代码行数:34,代码来源:fault.c

示例10: kernel_ident_mapping_init

int kernel_ident_mapping_init(struct x86_mapping_info *info, pgd_t *pgd_page,
			      unsigned long pstart, unsigned long pend)
{
	unsigned long addr = pstart + info->offset;
	unsigned long end = pend + info->offset;
	unsigned long next;
	int result;

	for (; addr < end; addr = next) {
		pgd_t *pgd = pgd_page + pgd_index(addr);
		pud_t *pud;

		next = (addr & PGDIR_MASK) + PGDIR_SIZE;
		if (next > end)
			next = end;

		if (pgd_present(*pgd)) {
			pud = pud_offset(pgd, 0);
			result = ident_pud_init(info, pud, addr, next);
			if (result)
				return result;
			continue;
		}

		pud = (pud_t *)info->alloc_pgt_page(info->context);
		if (!pud)
			return -ENOMEM;
		result = ident_pud_init(info, pud, addr, next);
		if (result)
			return result;
		set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE));
	}

	return 0;
}
开发者ID:AshishNamdev,项目名称:linux,代码行数:35,代码来源:ident_map.c

示例11: oleole_flush_guest_virt_memory

int oleole_flush_guest_virt_memory(oleole_guest_system_t *gsys)
{
	unsigned long flags;
	unsigned long start, end;
	struct vm_area_struct	*vma;
	struct mm_struct *mm;
	pgd_t *pgd;

	spin_lock_irqsave(&gsys->lock, flags);
	vma = gsys->vma;
	spin_unlock_irqrestore(&gsys->lock, flags);

	if (!vma)
		return -1;

	mm = vma->vm_mm;

	if (!mm)
		return -1;

	start = vma->vm_start + OLEOLE_GUSET_VIRT_SPACE_OFFSET;
	end   = start         + 0x100000000UL;

	down_write(&mm->mmap_sem);

	pgd = pgd_offset(mm, start);
	if (!pgd_present(*pgd))
		goto miss;

	for (; start < end ; start += PUD_SIZE) {
		pud_t *pud;
		pmd_t *pmd;
		struct page *page;

		pud = pud_offset(pgd, start);
		if (!pud_present(*pud))
			goto miss;

		free_pmd_range(pud);

		pmd = pmd_offset(pud, 0);
		page = virt_to_page(pmd);
		__free_page(page);
		pud_clear(pud);
	}
miss:

	up_write(&mm->mmap_sem);

	__flush_tlb();

	return 0;
}
开发者ID:nminoru,项目名称:oleolevm,代码行数:53,代码来源:oleole_spt.c

示例12: page_present

static int page_present(struct mm_struct *mm, void __user *uptr, int wr)
{
	unsigned long addr = (unsigned long)uptr;
	pgd_t *pgd = pgd_offset(mm, addr);
	if (pgd_present(*pgd)) {
		pmd_t *pmd = pmd_offset(pgd, addr);
		if (pmd_present(*pmd)) {
			pte_t *pte = pte_offset_map(pmd, addr);
			return (pte_present(*pte) && (!wr || pte_write(*pte)));
		}
	}
	return 0;
}
开发者ID:GodFox,项目名称:magx_kernel_xpixl,代码行数:13,代码来源:signal.c

示例13: pgd_offset

pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
{
	pgd_t *pgdp;
	pud_t *pudp;
	pmd_t *pmdp = NULL;

	pgdp = pgd_offset(mm, addr);
	if (pgd_present(*pgdp)) {
		pudp = pud_offset(pgdp, addr);
		if (pud_present(*pudp))
			pmdp = pmd_offset(pudp, addr);
	}
	return (pte_t *) pmdp;
}
开发者ID:03199618,项目名称:linux,代码行数:14,代码来源:hugetlbpage.c

示例14: put_long

/*
 * This routine puts a long into any process space by following the page
 * tables. NOTE! You should check that the long isn't on a page boundary,
 * and that it is in the task area before calling this: this routine does
 * no checking.
 *
 * Now keeps R/W state of page so that a text page stays readonly
 * even if a debugger scribbles breakpoints into it.  -M.U-
 */
static void put_long(struct task_struct * tsk, struct vm_area_struct * vma, unsigned long addr,
	unsigned long data)
{
	pgd_t *pgdir;
	pmd_t *pgmiddle;
	pte_t *pgtable;
	unsigned long page;
		
repeat:
	pgdir = pgd_offset(vma->vm_mm, addr);
	if (!pgd_present(*pgdir)) {
		do_no_page(tsk, vma, addr, 1);
		goto repeat;
	}
	if (pgd_bad(*pgdir)) {
		printk("ptrace: bad page directory %08lx\n", pgd_val(*pgdir));
		pgd_clear(pgdir);
		return;
	}
	pgmiddle = pmd_offset(pgdir,addr);
	if (pmd_none(*pgmiddle)) {
		do_no_page(tsk, vma, addr, 1);
		goto repeat;
	}
	if (pmd_bad(*pgmiddle)) {
		printk("ptrace: bad page directory %08lx\n",
		       pmd_val(*pgmiddle));
		pmd_clear(pgmiddle);
		return;
	}
	pgtable = pte_offset(pgmiddle, addr);
	if (!pte_present(*pgtable)) {
		do_no_page(tsk, vma, addr, 1);
		goto repeat;
	}
	page = pte_page(*pgtable);
	if (!pte_write(*pgtable)) {
		do_wp_page(tsk, vma, addr, 2);
		goto repeat;
	}
/* this is a hack for non-kernel-mapped video buffers and similar */
	if (page < high_memory) {
		*(unsigned long *) (page + (addr & ~PAGE_MASK)) = data;
		flush_page_to_ram (page);
	}
/* we're bypassing pagetables, so we have to set the dirty bit ourselves */
/* this should also re-instate whatever read-only mode there was before */
	*pgtable = pte_mkdirty(mk_pte(page, vma->vm_page_prot));
	flush_tlb_all();
}
开发者ID:shattered,项目名称:linux-m68k,代码行数:59,代码来源:ptrace.c

示例15: pgd_offset

pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
{
    pgd_t *pgd;
    pud_t *pud;
    pmd_t *pmd = NULL;

    pgd = pgd_offset(mm, addr);
    if (pgd_present(*pgd)) {
        pud = pud_offset(pgd, addr);
        if (pud_present(*pud))
            pmd = pmd_offset(pud, addr);
    }
    return (pte_t *) pmd;
}
开发者ID:KrisChaplin,项目名称:LRT2x4_v1.0.2.06_GPL_source,代码行数:14,代码来源:hugetlbpage.c


注:本文中的pgd_present函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。