get_pteptr mystery

Hollis Blanchard hollis at austin.ibm.com
Tue Jan 7 10:35:58 EST 2003


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/





More information about the Linuxppc-dev mailing list