Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    [SOLVED] Pte problem

    hye fellas

    #include <linux/linkage.h>

    pgd_t *pgd;
    pud_t *pud;
    pmd_t *pmd;
    pte_t *pte;
    int N_VMA = 0;
    unsigned long int addr;
    struct page *page = NULL;
    unsigned long phys_addr;

    //static void *print_mem(struct task_struct *task);

    static void *print_mem(struct task_struct *task)
    { struct mm_struct *mm1;
    struct vm_area_struct *vma;

    mm1 = task->mm;
    vma = mm1->mmap;
    addr = vma->vm_start;

    while(vma && (mm1->map_count > N_VMA)){

    while(addr <= vma->vm_end)
    pgd = pgd_offset(mm1, addr);
    if ( pgd_bad(*pgd) || (!pgd_present(*pgd)))
    printk("Page does not exit or swapped out\n");

    pud = pud_offset(pgd, addr);
    if ( pud_bad(*pud) || (!pud_present(*pud)))

    pmd = pmd_offset(pud, addr);
    if (pmd_bad(*pmd) || (!pmd_present(*pmd)))

    pte = pte_offset_map(pmd, addr);
    if (pte_present(*pte))
    //page = pte_page(*pte);
    phys_addr = pte_pfn(*pte);

    printk(KERN_DEBUG "|\t%p\t|\t%p\t|\n",(void*)addr, (void*)phys_addr);
    addr += 4096;

    vma = vma->vm_next;

    asmlinkage long sys_getpgmap(int i){
    struct task_struct *task1;
    printk("Get the process ID %d\n", i);
    { if(task1->pid == i)
    { printk("%d\n",task1->pid);
    return 0;
    when I enter a process ID, it retreives the physical adresses but then it froze the whole Operating system Linux Ubuntu.
    Can someone help me with this code?

  2. #2
    I fixed the problem. I had to create user code that received the output of Kernel terminal. Now, it workd well and niw I could map any Process id and get all its physical adresses that reside in the main memory.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts