Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5981673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:58:37+00:00 2026-05-22T21:58:37+00:00

Is there any suitable way to get the physical address by the logical one

  • 0

Is there any suitable way to get the physical address by the logical one except to walk through page directory entries by hand? I’ve looked for this functionality in kernel’s sources and found that there is a follow_page function that do it well with built-in huge and transparent-huge pages support. But it’s not exported to kernel modules (why???)…

So, I don’t want to invent the wheel and I think that it’s not very good to reimplement the follow_page functionality by hand.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:58:37+00:00Added an answer on May 22, 2026 at 9:58 pm

    Well, it might looks as something like that (follow PTE from an virtual address):

    void follow_pte(struct mm_struct * mm, unsigned long address, pte_t * entry)
    {
        pgd_t * pgd = pgd_offset(mm, address);
    
        printk("follow_pte() for %lx\n", address);
    
        entry->pte = 0;
        if (!pgd_none(*pgd) && !pgd_bad(*pgd)) {
            pud_t * pud = pud_offset(pgd, address);
            struct vm_area_struct * vma = find_vma(mm, address);
    
            printk(" pgd = %lx\n", pgd_val(*pgd));
    
            if (pud_none(*pud)) {
                printk("  pud = empty\n");
                return;
            }
            if (pud_huge(*pud) && vma->vm_flags & VM_HUGETLB) {
                entry->pte = pud_val(*pud);
                printk("  pud = huge\n");
                return;
            }
    
            if (!pud_bad(*pud)) {
                pmd_t * pmd = pmd_offset(pud, address);
    
                printk("  pud = %lx\n", pud_val(*pud));
    
                if (pmd_none(*pmd)) {
                    printk("   pmd = empty\n");
                    return;
                }
                if (pmd_huge(*pmd) && vma->vm_flags & VM_HUGETLB) {
                    entry->pte = pmd_val(*pmd);
                    printk("   pmd = huge\n");
                    return;
                }
                if (pmd_trans_huge(*pmd)) {
                    entry->pte = pmd_val(*pmd);
                    printk("   pmd = trans_huge\n");
                    return;
                }
                if (!pmd_bad(*pmd)) {
                    pte_t * pte = pte_offset_map(pmd, address);
    
                    printk("   pmd = %lx\n", pmd_val(*pmd));
    
                    if (!pte_none(*pte)) {
                        entry->pte = pte_val(*pte);
                        printk("    pte = %lx\n", pte_val(*pte));
                    } else {
                        printk("    pte = empty\n");
                    }
                    pte_unmap(pte);
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to get notified when an NSManagedObjectContext is about to insert
I am pretty new to maven. Is there any plugin or packaging type suitable
Hey, I'm just wondering if there's any easy function to make text suitable to
Is there any way in Notepad++ (or even with another tool) to change the
Is there any way I can set a formatter on models that will convert
Is there any way to use Google's API to retrieve a user's current zipcode
Is there any way to overload the > (greater than) operator, to be able
Is there any way we can fetch X509 Public Cetrificates using c# from AD
I searched the site already but couldn't find any suitable information. As there is
Is there any way to disable ReSharper Web Form/MVC (.aspx) Code Formatting on Brace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.