From: Maindoor <sanjeevfiles@yahoo.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: change_page_attr support on ppc, patch discussion
Date: Wed, 28 Apr 2010 01:27:32 -0700 (PDT) [thread overview]
Message-ID: <193202.72183.qm@web63006.mail.re1.yahoo.com> (raw)
[-- 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 --]
reply other threads:[~2010-04-28 8:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=193202.72183.qm@web63006.mail.re1.yahoo.com \
--to=sanjeevfiles@yahoo.com \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox