[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] help -- A question about ' XENFEAT_auto_translated_physmap':



Hi Jan,

A question about ' XENFEAT_auto_translated_physmap':

In linux code, in arch/x86/xen/mmu.c,

 __xen_pgd_walk()
{
....

        if (xen_feature(XENFEAT_auto_translated_physmap))
                return 0;
....
}



Why xen_feature(XENFEAT_auto_translated_physmap) is true, then return directly?
If not return directly, is there any potential risk?






Detail for  __xen_pgd_walk():

static int __xen_pgd_walk(struct mm_struct *mm, pgd_t *pgd,
                          int (*func)(struct mm_struct *mm, struct page *,
                                      enum pt_level),
                          unsigned long limit)
{
        int flush = 0;
        unsigned hole_low, hole_high;
        unsigned pgdidx_limit, pudidx_limit, pmdidx_limit;
        unsigned pgdidx, pudidx, pmdidx;

        /* The limit is the last byte to be touched */
        limit--;
        BUG_ON(limit >= FIXADDR_TOP);

        if (xen_feature(XENFEAT_auto_translated_physmap))
                return 0;

        /*
         * 64-bit has a great big hole in the middle of the address
         * space, which contains the Xen mappings.  On 32-bit these
         * will end up making a zero-sized hole and so is a no-op.
         */
        hole_low = pgd_index(USER_LIMIT);
        hole_high = pgd_index(PAGE_OFFSET);

        pgdidx_limit = pgd_index(limit);
#if PTRS_PER_PUD > 1
        pudidx_limit = pud_index(limit);
#else
        pudidx_limit = 0;
#endif
#if PTRS_PER_PMD > 1
        pmdidx_limit = pmd_index(limit);
#else
        pmdidx_limit = 0;
#endif

        for (pgdidx = 0; pgdidx <= pgdidx_limit; pgdidx++) {
                pud_t *pud;

                if (pgdidx >= hole_low && pgdidx < hole_high)
                        continue;

                if (!pgd_val(pgd[pgdidx]))
                        continue;

                pud = pud_offset(&pgd[pgdidx], 0);

                if (PTRS_PER_PUD > 1) /* not folded */
                        flush |= (*func)(mm, virt_to_page(pud), PT_PUD);

                for (pudidx = 0; pudidx < PTRS_PER_PUD; pudidx++) {
                        pmd_t *pmd;

                        if (pgdidx == pgdidx_limit &&
                            pudidx > pudidx_limit)
                                goto out;

                        if (pud_none(pud[pudidx]))
                                continue;

                        pmd = pmd_offset(&pud[pudidx], 0);

                        if (PTRS_PER_PMD > 1) /* not folded */
                                flush |= (*func)(mm, virt_to_page(pmd), PT_PMD);

                        for (pmdidx = 0; pmdidx < PTRS_PER_PMD; pmdidx++) {
                                struct page *pte;

                                if (pgdidx == pgdidx_limit &&
                                    pudidx == pudidx_limit &&
                                    pmdidx > pmdidx_limit)
                                        goto out;

                                if (pmd_none(pmd[pmdidx]))
                                        continue;

                                pte = pmd_page(pmd[pmdidx]);
                                flush |= (*func)(mm, pte, PT_PTE);
                        }
                }
        }

out:
        /* Do the top level last, so that the callbacks can use it as
           a cue to do final things like tlb flushes. */
        flush |= (*func)(mm, virt_to_page(pgd), PT_PGD);

        return flush;
}



Quan






_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.