change_page_attr support on ppc, patch discussion

Maindoor sanjeevfiles at yahoo.com
Wed Apr 28 18:27:32 EST 2010


Hi,
I am trying to set a page of my data-structure as read-only on a USI MPC8347E.
This is primarily to figure a data structure corruption issue.
Added small support as follows:
ppc/mm/init.c:MMU_setup

    __map_without_bats = 1;
    __map_without_ltlbs = 1;


ppc/mm/pgtable.c

static int __change_page_attr(struct page *page, pgprot_t prot)
{
    pte_t *kpte;
    pmd_t *kpmd;
    unsigned long address;

    BUG_ON(PageHighMem(page));
    address = (unsigned long)page_address(page);

    if (v_mapped_by_bats(address) || v_mapped_by_tlbcam(address))
        return 0;
    if (!get_pteptr(&init_mm, address, &kpte, &kpmd))
        return -EINVAL;
    set_pte_at(&init_mm, address, kpte, mk_pte(page, prot));
    wmb();
    flush_HPTE(0, address, pmd_val(*kpmd));
    pte_unmap(kpte);
    mb();
    return 0;
}

/*
 * Change the page attributes of an page in the linear mapping.
*/
int change_page_attr(struct page *page, int numpages, pgprot_t prot)
{
    int i, err = 0;
    unsigned long flags;

    local_irq_save(flags);
    for (i = 0; i < numpages; i++, page++) {
        err = __change_page_attr(page, prot);
        if (err)
            break;
    }
    local_irq_restore(flags);
    return err;
}
EXPORT_SYMBOL(change_page_attr);

After allocation of my data structure, when I mark the page readonly like this:
change_page_attr(virt_to_page(dat_str), 1, PAGE_READONLY);

it works (throws Oops) but only for the first time, but subsequent writes
are going through. I expect even the subsequent writes to fail.

One more quirkiness to this is, after changing the page attribute I need to
read the element at least once for this to work.

Have I written the supportive api's (above ) correctly ? This is on 2.6.18 kernel.
If there is any other way to catch this corruption please let me know.
kgdb and bdi won't help me as it is a dynamically created data-structure and I
have timing constraints.

Regards,
Maindoor.




      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20100428/fdaa6b67/attachment-0001.htm>


More information about the Linuxppc-dev mailing list