Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 May 2012 00:45:27 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        "arm@freebsd.org" <arm@FreeBSD.org>
Cc:        Alan Cox <alc@FreeBSD.org>
Subject:   Review needed
Message-ID:  <EBCFF89A-18E8-48B8-A7BD-09C0B942DAB1@bsdimp.com>

next in thread | raw e-mail | index | archive | help
I just tried to bring up an old Gateworks AVILA board that I'd acquired =
a long time ago....

After fighting through a few bugs in the nanobsd build, I managed to get =
an image.

That image failed to boot.  When it harvested entropy, it just started =
printing pmap_mincore() over and over again until I hit ^T enough to let =
the rest of the boot process continue.  Sure enough, arm's =
pmap_mincore() returns 0 after printing this.

So, I cobbled together the following after looking at mips and amd64's =
pmap_mincore() functions.

I've just cut and pasted it here since I think that might be easier to =
review than a diff, but I've also uploaded that as well to =
http://people.freebsd.org/~imp/arm-pmap_mincore.diff

Comments?

Warner

/*                                                                       =
                                                                         =
                                           =20
 * perform the pmap work for mincore                                     =
                                                                         =
                                           =20
 */
int
pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *locked_pa)
{
        struct l2_bucket *l2b;
        pt_entry_t *ptep, pte;
        vm_paddr_t pa;
        vm_page_t m;
        int val;
        boolean_t managed;

        PMAP_LOCK(pmap);
retry:
        l2b =3D pmap_get_l2_bucket(pmap, addr);
        if (l2b =3D=3D NULL) {
                val =3D 0;
                goto out;
        }
        ptep =3D &l2b->l2b_kva[l2pte_index(addr)];
        pte =3D (ptep !=3D NULL) ? *ptep : 0;
        if (!l2pte_valid(pte)) {
                val =3D 0;
                goto out;
        }
        val =3D MINCORE_INCORE;
	if (pte & L2_S_PROT_W)
                val |=3D MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER;
        managed =3D false;
        pa =3D l2pte_pa(pte);
        m =3D PHYS_TO_VM_PAGE(pa);
        if (m !=3D NULL && !(m->oflags & VPO_UNMANAGED))
                managed =3D true;
        if (managed) {
                /*                                                       =
                                                                         =
                                           =20
                 * This may falsely report the given address as          =
                                                                         =
                                          =20
                 * MINCORE_REFERENCED.  Unfortunately, due to the lack =
of                                                                       =
                                            =20
                 * per-PTE reference information, it is impossible to    =
                                                                         =
                                           =20
                 * determine if the address is MINCORE_REFERENCED.       =
                                                                         =
                                          =20
                 */
                if ((m->aflags & PGA_REFERENCED) !=3D 0)
                        val |=3D MINCORE_REFERENCED | =
MINCORE_REFERENCED_OTHER;
        }
        if ((val & (MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER)) =
!=3D
            (MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER) && =
managed) {
                /* Ensure that "PHYS_TO_VM_PAGE(pa)->object" doesn't =
change. */
                if (vm_page_pa_tryrelock(pmap, pa, locked_pa))
                        goto retry;
        } else
out:
                PA_UNLOCK_COND(*locked_pa);
        PMAP_UNLOCK(pmap);
        return (val);
}




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?EBCFF89A-18E8-48B8-A7BD-09C0B942DAB1>