* change_page_attr support on ppc, patch discussion
@ 2010-04-28 8:27 Maindoor
0 siblings, 0 replies; only message in thread
From: Maindoor @ 2010-04-28 8:27 UTC (permalink / raw)
To: linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 2009 bytes --]
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.
[-- Attachment #2: Type: text/html, Size: 2827 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-04-28 8:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-28 8:27 change_page_attr support on ppc, patch discussion Maindoor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).