x86: moke show_page_walk() more robust
PATCH 1/1 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().
xen/arch/x86/x86_32/traps.c +4 -2
@@ -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);
xen/arch/x86/x86_64/mm.c +1 -0
@@ -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 ));
xen/arch/x86/x86_64/traps.c +6 -3
@@ -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);
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
Quoted 83 lines · Jan Beulich
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 <[email protected]>---
2009-07-10.orig/xen/arch/x86/x86_32/traps.c2009-07-10 13:58:56.000000000 +0200
+++2009-07-10/xen/arch/x86/x86_32/traps.c2009-07-17 11:12:42.000000000 +0200xen/arch/x86/x86_32/traps.c +15
-7@@ -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
[email protected]
http://lists.xensource.com/xen-devel
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
Quoted 1 line
Quoted 1 line
Quoted 1 line
Keir Fraser <[email protected]> 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
Quoted 83 lines · Jan Beulich
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 <[email protected]>---
2009-07-10.orig/xen/arch/x86/x86_32/traps.c2009-07-10 13:58:56.000000000 +0200
+++2009-07-10/xen/arch/x86/x86_32/traps.c2009-07-17 11:12:42.000000000 +0200xen/arch/x86/x86_32/traps.c +15
-7@@ -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
[email protected]
http://lists.xensource.com/xen-devel
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
Quoted 104 lines · Jan Beulich
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
Quoted 1 line
Quoted 1 line
Quoted 1 line
Keir Fraser <[email protected]> 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
Quoted 86 lines · Jan Beulich
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 <[email protected]>---
2009-07-10.orig/xen/arch/x86/x86_32/traps.c2009-07-10 13:58:56.000000000 +0200
+++2009-07-10/xen/arch/x86/x86_32/traps.c2009-07-17 11:12:42.000000000 +0200xen/arch/x86/x86_32/traps.c +16
-7@@ -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
[email protected]
http://lists.xensource.com/xen-devel