[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1105171745300.12963@kaball-desktop>
Date: Tue, 17 May 2011 18:50:55 +0100
From: Stefano Stabellini <stefano.stabellini@...citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
CC: Stefano Stabellini <Stefano.Stabellini@...citrix.com>,
"yinghai@...nel.org" <yinghai@...nel.org>,
"jeremy@...p.org" <jeremy@...p.org>,
"hpa@...or.com" <hpa@...or.com>,
"hpa@...ux.intel.com" <hpa@...ux.intel.com>,
Ian Campbell <Ian.Campbell@...citrix.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"xen-devel@...ts.xensource.com" <xen-devel@...ts.xensource.com>
Subject: Re: Xen MMU's requirement to pin pages RO and
initial_memory_mapping.
On Mon, 16 May 2011, Konrad Rzeszutek Wilk wrote:
> > They become pagetable pages when:
> >
> > - they are explicitly pinned by pin_pagetable_pfn
> >
> > - they are hooked into the current pagetable
>
> Ok, so could we use those two calls to trigger the pagetable walk
> and mark them RO as appropiate? Which call sites are those? The
> xen_set_pgd/xen_set_pud/xen_set_pmd ?
xen_alloc_pte_init and xen_alloc_pmd_init are the ones that mark the
pagetable pages RO and pin them, calling make_lowmem_page_readonly and
pin_pagetable_pfn.
alloc_pte/pmd are called right before hooking them into the pagetable;
unfortunately that means that they fail at marking the pagetable pages
RO: make_lowmem_page_readonly uses lookup_address to find the pte
corresponding to a page, however at this point the pagetable pages are
not mapped yet (usually they are not hooked but when they are hooked, the
upper level pagetable page is not hooked), so lookup_address fails.
In order to catch these errors Xen has a parachute: xen_set_pte_init,
the function that takes care of writing a pte to memory and that on xen
converts pfns to mfns, also marks pagetable pages RO trying to
understand when that is appropriate.
This is all very ugly and delicate.
I think alloc_pte/pmd were always thought to be used to mark and pin
pagetable pages but they currently fail during the initial pagetable
setup. If we could fix alloc_pte/pmd most of the problems and the hacks
would go away.
Ideally we could remove both mask_rw_pte (currently responsible for
marking pagetable pages RO, called from xen_set_pte_init) and
x86_init.mapping.pagetable_reserve.
More thinking (and caffeine) needed...
> Presumarily we don't have
> to do that for the PTE's that are already mapped (as
> xen_setup_kernel_pagetable, and xen_map_identity_early do this
> already).
No, we don't.
We do need to make sure they stay RO on x86_32 where we write the
pagetable pages in two steps and we switch pagetable to swapper_pg_dir.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists