Jan Beulich
2009-Jul-17 09:20 UTC
[Xen-devel] [PATCH] x86: moke show_page_walk() more robust
This should fix the host crash reported in the thread "d273:v3: reserved bit in page table (ec=0019)" (but it specifically doesn''t deal with the yet unknown original cause of the problem). Also add in a missing line in x86-64''s do_page_walk(). Signed-off-by: Jan Beulich <jbeulich@novell.com> --- 2009-07-10.orig/xen/arch/x86/x86_32/traps.c 2009-07-10 13:58:56.000000000 +0200 +++ 2009-07-10/xen/arch/x86/x86_32/traps.c 2009-07-17 11:12:42.000000000 +0200 @@ -165,7 +165,8 @@ void show_page_walk(unsigned long addr) printk(" L3[0x%03lx] = %"PRIpte" %08lx\n", l3_table_offset(addr), l3e_get_intpte(l3e), pfn); unmap_domain_page(l3t); - if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) + if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || + !mfn_valid(mfn) ) return; l2t = map_domain_page(mfn); @@ -178,7 +179,8 @@ void show_page_walk(unsigned long addr) (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : ""); unmap_domain_page(l2t); if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || - (l2e_get_flags(l2e) & _PAGE_PSE) ) + (l2e_get_flags(l2e) & _PAGE_PSE) || + !mfn_valid(mfn) ) return; l1t = map_domain_page(mfn); --- 2009-07-10.orig/xen/arch/x86/x86_64/mm.c 2009-07-10 13:58:56.000000000 +0200 +++ 2009-07-10/xen/arch/x86/x86_64/mm.c 2009-07-17 11:10:29.000000000 +0200 @@ -124,6 +124,7 @@ void *do_page_walk(struct vcpu *v, unsig l3e = l3t[l3_table_offset(addr)]; mfn = l3e_get_pfn(l3e); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || !mfn_valid(mfn) ) + return NULL; if ( (l3e_get_flags(l3e) & _PAGE_PSE) ) return mfn_to_virt(mfn) + (addr & ((1UL << L3_PAGETABLE_SHIFT) - 1)); --- 2009-07-10.orig/xen/arch/x86/x86_64/traps.c 2009-07-10 13:58:56.000000000 +0200 +++ 2009-07-10/xen/arch/x86/x86_64/traps.c 2009-07-17 11:11:59.000000000 +0200 @@ -180,7 +180,8 @@ void show_page_walk(unsigned long addr) pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY; printk(" L4[0x%03lx] = %"PRIpte" %016lx\n", l4_table_offset(addr), l4e_get_intpte(l4e), pfn); - if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) ) + if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) || + !mfn_valid(mfn) ) return; l3t = mfn_to_virt(mfn); @@ -192,7 +193,8 @@ void show_page_walk(unsigned long addr) l3_table_offset(addr), l3e_get_intpte(l3e), pfn, (l3e_get_flags(l3e) & _PAGE_PSE) ? " (PSE)" : ""); if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || - (l3e_get_flags(l3e) & _PAGE_PSE) ) + (l3e_get_flags(l3e) & _PAGE_PSE) || + !mfn_valid(mfn) ) return; l2t = mfn_to_virt(mfn); @@ -204,7 +206,8 @@ void show_page_walk(unsigned long addr) l2_table_offset(addr), l2e_get_intpte(l2e), pfn, (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : ""); if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || - (l2e_get_flags(l2e) & _PAGE_PSE) ) + (l2e_get_flags(l2e) & _PAGE_PSE) || + !mfn_valid(mfn) ) return; l1t = mfn_to_virt(mfn); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2009-Jul-17 19:48 UTC
Re: [Xen-devel] [PATCH] x86: moke show_page_walk() more robust
Is this worthwhile? It''s kind of game over by this point, and we already dumped out the useful stuff. And the ensuing crash makes it very clear that the page walk discovered an invalid mfn (rather than this alternative of silently truncating the walk). -- Keir On 17/07/2009 10:20, "Jan Beulich" <JBeulich@novell.com> wrote:> This should fix the host crash reported in the thread "d273:v3: > reserved bit in page table (ec=0019)" (but it specifically doesn''t deal > with the yet unknown original cause of the problem). > > Also add in a missing line in x86-64''s do_page_walk(). > > Signed-off-by: Jan Beulich <jbeulich@novell.com> > > --- 2009-07-10.orig/xen/arch/x86/x86_32/traps.c 2009-07-10 13:58:56.000000000 > +0200 > +++ 2009-07-10/xen/arch/x86/x86_32/traps.c 2009-07-17 11:12:42.000000000 +0200 > @@ -165,7 +165,8 @@ void show_page_walk(unsigned long addr) > printk(" L3[0x%03lx] = %"PRIpte" %08lx\n", > l3_table_offset(addr), l3e_get_intpte(l3e), pfn); > unmap_domain_page(l3t); > - if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) > + if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || > + !mfn_valid(mfn) ) > return; > > l2t = map_domain_page(mfn); > @@ -178,7 +179,8 @@ void show_page_walk(unsigned long addr) > (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : ""); > unmap_domain_page(l2t); > if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || > - (l2e_get_flags(l2e) & _PAGE_PSE) ) > + (l2e_get_flags(l2e) & _PAGE_PSE) || > + !mfn_valid(mfn) ) > return; > > l1t = map_domain_page(mfn); > --- 2009-07-10.orig/xen/arch/x86/x86_64/mm.c 2009-07-10 13:58:56.000000000 > +0200 > +++ 2009-07-10/xen/arch/x86/x86_64/mm.c 2009-07-17 11:10:29.000000000 +0200 > @@ -124,6 +124,7 @@ void *do_page_walk(struct vcpu *v, unsig > l3e = l3t[l3_table_offset(addr)]; > mfn = l3e_get_pfn(l3e); > if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || !mfn_valid(mfn) ) > + return NULL; > if ( (l3e_get_flags(l3e) & _PAGE_PSE) ) > return mfn_to_virt(mfn) + (addr & ((1UL << L3_PAGETABLE_SHIFT) - 1)); > > --- 2009-07-10.orig/xen/arch/x86/x86_64/traps.c 2009-07-10 13:58:56.000000000 > +0200 > +++ 2009-07-10/xen/arch/x86/x86_64/traps.c 2009-07-17 11:11:59.000000000 +0200 > @@ -180,7 +180,8 @@ void show_page_walk(unsigned long addr) > pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY; > printk(" L4[0x%03lx] = %"PRIpte" %016lx\n", > l4_table_offset(addr), l4e_get_intpte(l4e), pfn); > - if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) ) > + if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) || > + !mfn_valid(mfn) ) > return; > > l3t = mfn_to_virt(mfn); > @@ -192,7 +193,8 @@ void show_page_walk(unsigned long addr) > l3_table_offset(addr), l3e_get_intpte(l3e), pfn, > (l3e_get_flags(l3e) & _PAGE_PSE) ? " (PSE)" : ""); > if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || > - (l3e_get_flags(l3e) & _PAGE_PSE) ) > + (l3e_get_flags(l3e) & _PAGE_PSE) || > + !mfn_valid(mfn) ) > return; > > l2t = mfn_to_virt(mfn); > @@ -204,7 +206,8 @@ void show_page_walk(unsigned long addr) > l2_table_offset(addr), l2e_get_intpte(l2e), pfn, > (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : ""); > if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || > - (l2e_get_flags(l2e) & _PAGE_PSE) ) > + (l2e_get_flags(l2e) & _PAGE_PSE) || > + !mfn_valid(mfn) ) > return; > > l1t = mfn_to_virt(mfn); > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jan Beulich
2009-Jul-20 06:39 UTC
Re: [Xen-devel] [PATCH] x86: moke show_page_walk() more robust
I very much think it is worthwhile: In the case given, a supposed guest crash resulted in a host crash - the expected behavior would have been to do the page table walk, then forward the fault to the guest. Jan>>> Keir Fraser <keir.fraser@eu.citrix.com> 17.07.09 21:48 >>>Is this worthwhile? It''s kind of game over by this point, and we already dumped out the useful stuff. And the ensuing crash makes it very clear that the page walk discovered an invalid mfn (rather than this alternative of silently truncating the walk). -- Keir On 17/07/2009 10:20, "Jan Beulich" <JBeulich@novell.com> wrote:> This should fix the host crash reported in the thread "d273:v3: > reserved bit in page table (ec=0019)" (but it specifically doesn''t deal > with the yet unknown original cause of the problem). > > Also add in a missing line in x86-64''s do_page_walk(). > > Signed-off-by: Jan Beulich <jbeulich@novell.com> > > --- 2009-07-10.orig/xen/arch/x86/x86_32/traps.c 2009-07-10 13:58:56.000000000 > +0200 > +++ 2009-07-10/xen/arch/x86/x86_32/traps.c 2009-07-17 11:12:42.000000000 +0200 > @@ -165,7 +165,8 @@ void show_page_walk(unsigned long addr) > printk(" L3[0x%03lx] = %"PRIpte" %08lx\n", > l3_table_offset(addr), l3e_get_intpte(l3e), pfn); > unmap_domain_page(l3t); > - if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) > + if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || > + !mfn_valid(mfn) ) > return; > > l2t = map_domain_page(mfn); > @@ -178,7 +179,8 @@ void show_page_walk(unsigned long addr) > (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : ""); > unmap_domain_page(l2t); > if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || > - (l2e_get_flags(l2e) & _PAGE_PSE) ) > + (l2e_get_flags(l2e) & _PAGE_PSE) || > + !mfn_valid(mfn) ) > return; > > l1t = map_domain_page(mfn); > --- 2009-07-10.orig/xen/arch/x86/x86_64/mm.c 2009-07-10 13:58:56.000000000 > +0200 > +++ 2009-07-10/xen/arch/x86/x86_64/mm.c 2009-07-17 11:10:29.000000000 +0200 > @@ -124,6 +124,7 @@ void *do_page_walk(struct vcpu *v, unsig > l3e = l3t[l3_table_offset(addr)]; > mfn = l3e_get_pfn(l3e); > if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || !mfn_valid(mfn) ) > + return NULL; > if ( (l3e_get_flags(l3e) & _PAGE_PSE) ) > return mfn_to_virt(mfn) + (addr & ((1UL << L3_PAGETABLE_SHIFT) - 1)); > > --- 2009-07-10.orig/xen/arch/x86/x86_64/traps.c 2009-07-10 13:58:56.000000000 > +0200 > +++ 2009-07-10/xen/arch/x86/x86_64/traps.c 2009-07-17 11:11:59.000000000 +0200 > @@ -180,7 +180,8 @@ void show_page_walk(unsigned long addr) > pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY; > printk(" L4[0x%03lx] = %"PRIpte" %016lx\n", > l4_table_offset(addr), l4e_get_intpte(l4e), pfn); > - if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) ) > + if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) || > + !mfn_valid(mfn) ) > return; > > l3t = mfn_to_virt(mfn); > @@ -192,7 +193,8 @@ void show_page_walk(unsigned long addr) > l3_table_offset(addr), l3e_get_intpte(l3e), pfn, > (l3e_get_flags(l3e) & _PAGE_PSE) ? " (PSE)" : ""); > if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || > - (l3e_get_flags(l3e) & _PAGE_PSE) ) > + (l3e_get_flags(l3e) & _PAGE_PSE) || > + !mfn_valid(mfn) ) > return; > > l2t = mfn_to_virt(mfn); > @@ -204,7 +206,8 @@ void show_page_walk(unsigned long addr) > l2_table_offset(addr), l2e_get_intpte(l2e), pfn, > (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : ""); > if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || > - (l2e_get_flags(l2e) & _PAGE_PSE) ) > + (l2e_get_flags(l2e) & _PAGE_PSE) || > + !mfn_valid(mfn) ) > return; > > l1t = mfn_to_virt(mfn); > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser
2009-Jul-20 07:06 UTC
Re: [Xen-devel] [PATCH] x86: moke show_page_walk() more robust
It''s not merely a guest crash. It shouldn''t be possible for a guest to end up with bogus PTEs. It''s a host consistency issue and hence a host crash is appropriate. -- Keir On 20/07/2009 07:39, "Jan Beulich" <JBeulich@novell.com> wrote:> I very much think it is worthwhile: In the case given, a supposed guest crash > resulted in a host crash - the expected behavior would have been to do the > page table walk, then forward the fault to the guest. > > Jan > >>>> Keir Fraser <keir.fraser@eu.citrix.com> 17.07.09 21:48 >>> > Is this worthwhile? It''s kind of game over by this point, and we already > dumped out the useful stuff. And the ensuing crash makes it very clear that > the page walk discovered an invalid mfn (rather than this alternative of > silently truncating the walk). > > -- Keir > > On 17/07/2009 10:20, "Jan Beulich" <JBeulich@novell.com> wrote: > >> This should fix the host crash reported in the thread "d273:v3: >> reserved bit in page table (ec=0019)" (but it specifically doesn''t deal >> with the yet unknown original cause of the problem). >> >> Also add in a missing line in x86-64''s do_page_walk(). >> >> Signed-off-by: Jan Beulich <jbeulich@novell.com> >> >> --- 2009-07-10.orig/xen/arch/x86/x86_32/traps.c 2009-07-10 13:58:56.000000000 >> +0200 >> +++ 2009-07-10/xen/arch/x86/x86_32/traps.c 2009-07-17 11:12:42.000000000 >> +0200 >> @@ -165,7 +165,8 @@ void show_page_walk(unsigned long addr) >> printk(" L3[0x%03lx] = %"PRIpte" %08lx\n", >> l3_table_offset(addr), l3e_get_intpte(l3e), pfn); >> unmap_domain_page(l3t); >> - if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) >> + if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || >> + !mfn_valid(mfn) ) >> return; >> >> l2t = map_domain_page(mfn); >> @@ -178,7 +179,8 @@ void show_page_walk(unsigned long addr) >> (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : ""); >> unmap_domain_page(l2t); >> if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || >> - (l2e_get_flags(l2e) & _PAGE_PSE) ) >> + (l2e_get_flags(l2e) & _PAGE_PSE) || >> + !mfn_valid(mfn) ) >> return; >> >> l1t = map_domain_page(mfn); >> --- 2009-07-10.orig/xen/arch/x86/x86_64/mm.c 2009-07-10 13:58:56.000000000 >> +0200 >> +++ 2009-07-10/xen/arch/x86/x86_64/mm.c 2009-07-17 11:10:29.000000000 +0200 >> @@ -124,6 +124,7 @@ void *do_page_walk(struct vcpu *v, unsig >> l3e = l3t[l3_table_offset(addr)]; >> mfn = l3e_get_pfn(l3e); >> if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || !mfn_valid(mfn) ) >> + return NULL; >> if ( (l3e_get_flags(l3e) & _PAGE_PSE) ) >> return mfn_to_virt(mfn) + (addr & ((1UL << L3_PAGETABLE_SHIFT) - >> 1)); >> >> --- 2009-07-10.orig/xen/arch/x86/x86_64/traps.c 2009-07-10 13:58:56.000000000 >> +0200 >> +++ 2009-07-10/xen/arch/x86/x86_64/traps.c 2009-07-17 11:11:59.000000000 >> +0200 >> @@ -180,7 +180,8 @@ void show_page_walk(unsigned long addr) >> pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY; >> printk(" L4[0x%03lx] = %"PRIpte" %016lx\n", >> l4_table_offset(addr), l4e_get_intpte(l4e), pfn); >> - if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) ) >> + if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) || >> + !mfn_valid(mfn) ) >> return; >> >> l3t = mfn_to_virt(mfn); >> @@ -192,7 +193,8 @@ void show_page_walk(unsigned long addr) >> l3_table_offset(addr), l3e_get_intpte(l3e), pfn, >> (l3e_get_flags(l3e) & _PAGE_PSE) ? " (PSE)" : ""); >> if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) || >> - (l3e_get_flags(l3e) & _PAGE_PSE) ) >> + (l3e_get_flags(l3e) & _PAGE_PSE) || >> + !mfn_valid(mfn) ) >> return; >> >> l2t = mfn_to_virt(mfn); >> @@ -204,7 +206,8 @@ void show_page_walk(unsigned long addr) >> l2_table_offset(addr), l2e_get_intpte(l2e), pfn, >> (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : ""); >> if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || >> - (l2e_get_flags(l2e) & _PAGE_PSE) ) >> + (l2e_get_flags(l2e) & _PAGE_PSE) || >> + !mfn_valid(mfn) ) >> return; >> >> l1t = mfn_to_virt(mfn); >> >> >> >> >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@lists.xensource.com >> http://lists.xensource.com/xen-devel > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel