[Lguest] [BUG + PATCH/Bugfix] x86/lguest: fix pgdir pmd index calculation

Ahmed S. Darwish darwish.07 at gmail.com
Wed Mar 5 02:11:39 EST 2008


On Tue, Mar 04, 2008 at 11:55:10PM +1100, Rusty Russell wrote:
> On Monday 25 February 2008 02:55:15 Ahmed S. Darwish wrote:
> > Hi all,
> >
> > Beginning from commits close to v2.6.25-rc2, running lguest always oopses
> > the host kernel. Oops is at [1].
> 
> OK, whatever the guest does should not break the host.  So your patch can't be
> the whole solution.
> 
> > static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval)
> > {
> > 	*pmdp = pmdval;
> > 	lazy_hcall(LHCALL_SET_PMD, __pa(pmdp)&PAGE_MASK,
> > 		   (__pa(pmdp)&(PAGE_SIZE-1))/4, 0);
> > }
> >
> > The first hcall parameter is global pgdir which looks fine. The second
> > parameter is the pmd index in the pgdir which is suspectful.
> >
> > AFAIK, calculating the index of pmd does not need a divisoin over four.
> > Removing the division made lguest work fine again . Patch is at [2].
> 
> Each pmd is 4 bytes long, so the divide by 4 gives the index into the (top
> level) page. ie. a number in the range 0 to 1023.
> 

aha, now it's clear. 

>
> Indeed, here's the correct fix.  Does it work for you?
> 

Yes it does (after removing the unrelated TSC-if-pentium+ checks). 

Thank you

-- 

"Better to light a candle, than curse the darkness"

Ahmed S. Darwish
Homepage: http://darwish.07.googlepages.com
Blog: http://darwish-07.blogspot.com




More information about the Lguest mailing list