* get_pteptr mystery
@ 2002-12-19 0:06 Hollis Blanchard
2002-12-19 0:23 ` Paul Mackerras
2003-01-06 23:35 ` Hollis Blanchard
0 siblings, 2 replies; 5+ messages in thread
From: Hollis Blanchard @ 2002-12-19 0:06 UTC (permalink / raw)
To: devel list
I need to mark the first kernel code page writeable because I need to
write to 0xc00000fc. Can someone tell me why the following code fails?
get_pteptr returns 0.
addr = 0xc00000fc;
if (0 != get_pteptr(&init_mm, addr, &ptep)) {
/* mark it writable */
*ptep = pte_mkwrite(*ptep);
/* flush this page from hw TLB */
flush_tlb_range(&init_mm, addr, addr+1);
} else {
printk(KERN_ERR "couldn't get PTE!\n");
}
I've also tried using pgd_offset_k/pmd_offset/pte_offset by hand, but it
seems that the first time any error checking is done is in pte_offset,
and that fails. Specifically
pmd_offset(pgd_offset_k(0xc00000fc)) = c0158000
but
((pmd *)c0158000)->pmd = 0
My code runs at init time, after mm initialization but before init. Does
that mean I can't use init_mm...?
All I want is the pte pointer for 0xc00000fc. Advice welcome. :)
-Hollis
--
PowerPC Linux
IBM Linux Technology Center
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: get_pteptr mystery
2002-12-19 0:06 get_pteptr mystery Hollis Blanchard
@ 2002-12-19 0:23 ` Paul Mackerras
2002-12-19 0:41 ` Hollis Blanchard
2003-01-06 23:35 ` Hollis Blanchard
1 sibling, 1 reply; 5+ messages in thread
From: Paul Mackerras @ 2002-12-19 0:23 UTC (permalink / raw)
To: Hollis Blanchard; +Cc: devel list
Hollis Blanchard writes:
> I need to mark the first kernel code page writeable because I need to
> write to 0xc00000fc. Can someone tell me why the following code fails?
> get_pteptr returns 0.
What platform, what tree? :)
Paul.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: get_pteptr mystery
2002-12-19 0:23 ` Paul Mackerras
@ 2002-12-19 0:41 ` Hollis Blanchard
0 siblings, 0 replies; 5+ messages in thread
From: Hollis Blanchard @ 2002-12-19 0:41 UTC (permalink / raw)
To: Paul Mackerras; +Cc: devel list
On Wed, 2002-12-18 at 18:23, Paul Mackerras wrote:
> Hollis Blanchard writes:
>
> > I need to mark the first kernel code page writeable because I need to
> > write to 0xc00000fc. Can someone tell me why the following code fails?
> > get_pteptr returns 0.
>
> What platform, what tree? :)
Right, sorry. linuxppc_2_4_devel running on a 405LP (Beech board).
-Hollis
--
PowerPC Linux
IBM Linux Technology Center
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: get_pteptr mystery
2002-12-19 0:06 get_pteptr mystery Hollis Blanchard
2002-12-19 0:23 ` Paul Mackerras
@ 2003-01-06 23:35 ` Hollis Blanchard
2003-01-07 23:05 ` David Gibson
1 sibling, 1 reply; 5+ messages in thread
From: Hollis Blanchard @ 2003-01-06 23:35 UTC (permalink / raw)
To: devel list
On Wed, 2002-12-18 at 18:06, Hollis Blanchard wrote:
>
> I need to mark the first kernel code page writeable because I need to
> write to 0xc00000fc. Can someone tell me why the following code fails?
> get_pteptr returns 0.
>
> addr = 0xc00000fc;
> if (0 != get_pteptr(&init_mm, addr, &ptep)) {
> /* mark it writable */
> *ptep = pte_mkwrite(*ptep);
> /* flush this page from hw TLB */
> flush_tlb_range(&init_mm, addr, addr+1);
> } else {
> printk(KERN_ERR "couldn't get PTE!\n");
> }
FYI: whoever added HIGHMEM support to mm/init.c:paging_init() already
had this problem, and solved it by calling map_page(addr, 0, 0) first.
I guess that the page is really not present in the software pagetable,
and the map_page call forces it in:
map_page(PKMAP_BASE, 0, 0); /* XXX gross */
pkmap_page_table = pte_offset(pmd_offset(pgd_offset_k(PKMAP_BASE),
PKMAP_BASE), PKMAP_BASE);
(get_pteptr just calls pte/pmd/pgd_offset with some error checking.)
-Hollis
--
PowerPC Linux
IBM Linux Technology Center
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: get_pteptr mystery
2003-01-06 23:35 ` Hollis Blanchard
@ 2003-01-07 23:05 ` David Gibson
0 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2003-01-07 23:05 UTC (permalink / raw)
To: devel list
On Mon, Jan 06, 2003 at 05:35:58PM -0600, Hollis Blanchard wrote:
>
> On Wed, 2002-12-18 at 18:06, Hollis Blanchard wrote:
> >
> > I need to mark the first kernel code page writeable because I need to
> > write to 0xc00000fc. Can someone tell me why the following code fails?
> > get_pteptr returns 0.
> >
> > addr = 0xc00000fc;
> > if (0 != get_pteptr(&init_mm, addr, &ptep)) {
> > /* mark it writable */
> > *ptep = pte_mkwrite(*ptep);
> > /* flush this page from hw TLB */
> > flush_tlb_range(&init_mm, addr, addr+1);
> > } else {
> > printk(KERN_ERR "couldn't get PTE!\n");
> > }
>
> FYI: whoever added HIGHMEM support to mm/init.c:paging_init() already
> had this problem, and solved it by calling map_page(addr, 0, 0) first.
>
> I guess that the page is really not present in the software pagetable,
> and the map_page call forces it in:
> map_page(PKMAP_BASE, 0, 0); /* XXX gross */
> pkmap_page_table = pte_offset(pmd_offset(pgd_offset_k(PKMAP_BASE),
> PKMAP_BASE), PKMAP_BASE);
> (get_pteptr just calls pte/pmd/pgd_offset with some error checking.)
Erm.. be very careful about this in 2.5. Since we use a large-page
mapping for that address there, it won't in fact have a "normal" PTE.
So attempting to frob it could cause bad things to happen.
--
David Gibson | For every complex problem there is a
david@gibson.dropbear.id.au | solution which is simple, neat and
| wrong.
http://www.ozlabs.org/people/dgibson
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-01-07 23:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-19 0:06 get_pteptr mystery Hollis Blanchard
2002-12-19 0:23 ` Paul Mackerras
2002-12-19 0:41 ` Hollis Blanchard
2003-01-06 23:35 ` Hollis Blanchard
2003-01-07 23:05 ` David Gibson
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).