to fix the bug for tboot on x86_32 brought by c/s 19914 and 19922
PATCH 1/1 to fix the bug for tboot on x86_32 brought by c/s 19914 and 19922
The changesets 19914 and 19922 remove the bitmap for boot allocator, which causes first_valid_mfn is reduced and starts from the end of xen. On the other hand, on x86_64, the xen heap is got considering e820 table, while on x86_32 the xen heap is specified to be < xenheap_phys_end. This range overlaps tboot range. So, the tboot range is scrubbed by scrub_heap_pages() during start_xen() on x86_32. Then the result is that for TXT support on x86_32, shutdown/reboot/Sx doesn't work properly. (i.e. hang)
This patch is to fix that by reserving tboot range as "inuse" in xen heap on x86_32. Then xen code will not touch the range.
---
xen/arch/x86/setup.c +3 -0
@@ -1066,6 +1066,9 @@ void __init __start_xen(unsigned long mbif ( !tboot_protect_mem_regions () )panic ("Could not protect TXT memory regions\n" ); +if ( !tboot_reserve_range () ) +panic ("Could not reserve tboot range, tboot has been overwritten\n" ); +/* Create initial domain 0. */ dom0 =domain_create (0 , DOMCRF_s3_integrity,DOM0_SSIDREF );if ( (dom0 ==NULL ) || (alloc_dom0_vcpu0 () ==NULL ) )
xen/arch/x86/tboot.c +87 -34
202 lines not on this page · raw message
xen/common/page_alloc.c +68 -13
147 lines not on this page · raw message
xen/include/asm-x86/tboot.h +1 -0
@@ -114,6 +114,7 @@ extern tboot_shared_t *g_tboot_shared;extern tboot_shared_t *g_tboot_shared;void tboot_probe (void ); +int tboot_reserve_range (void );void tboot_shutdown (uint32_t shutdown_type);int tboot_in_measured_env (void );int tboot_protect_mem_regions (void );
xen/include/xen/mm.h +1 -0
@@ -62,6 +62,7 @@ unsigned int online_page(unsigned long munsigned int online_page (unsigned long mfn,uint32_t *status);int offline_page (unsigned long mfn,int broken,uint32_t *status);int query_page_offline (unsigned long mfn,uint32_t *status); +int reserve_page_as_used (unsigned long mfn);void scrub_heap_pages (void );
xen/arch/x86/setup.c +3 -0
@@ -1066,6 +1066,9 @@ void __init __start_xen(unsigned long mbif ( !tboot_protect_mem_regions () )panic ("Could not protect TXT memory regions\n" ); +if ( !tboot_reserve_range () ) +panic ("Could not reserve tboot range, tboot has been overwritten\n" ); +/* Create initial domain 0. */ dom0 =domain_create (0 , DOMCRF_s3_integrity,DOM0_SSIDREF );if ( (dom0 ==NULL ) || (alloc_dom0_vcpu0 () ==NULL ) )
xen/arch/x86/tboot.c +87 -34
202 lines not on this page · raw message
xen/common/page_alloc.c +68 -13
147 lines not on this page · raw message
xen/include/asm-x86/tboot.h +1 -0
@@ -114,6 +114,7 @@ extern tboot_shared_t *g_tboot_shared;extern tboot_shared_t *g_tboot_shared;void tboot_probe (void ); +int tboot_reserve_range (void );void tboot_shutdown (uint32_t shutdown_type);int tboot_in_measured_env (void );int tboot_protect_mem_regions (void );
xen/include/xen/mm.h +1 -0
@@ -62,6 +62,7 @@ unsigned int online_page(unsigned long munsigned int online_page (unsigned long mfn,uint32_t *status);int offline_page (unsigned long mfn,int broken,uint32_t *status);int query_page_offline (unsigned long mfn,uint32_t *status); +int reserve_page_as_used (unsigned long mfn);void scrub_heap_pages (void );
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 8 lines · Shane Wang
The changesets 19914 and 19922 remove the bitmap for boot allocator, which causes
first_valid_mfnis reduced and starts from the end of xen. On the other hand, onx86_64, the xen heap is got considering e820 table, while onx86_32the xen heap is specified to be <xenheap_phys_end. This range overlaps tboot range.
So, the tboot range is scrubbed byscrub_heap_pages()duringstart_xen()onx86_32. Then the result is that for TXT support onx86_32, shutdown/reboot/Sx doesn't work properly. (i.e. hang)
So... The problem is that xenheap on x86_32 does not respect e820? I'll fix that if that's the issue. It will be a much smaller change, and to arch/x86/setup.c only.
-- Keir
Quoted 2 lines
This patch is to fix that by reserving tboot range as "inuse" in xen heap on
x86_32. Then xen code will not touch the range.
Quoted 11 lines · Keir Fraser
Quoted 8 lines · Shane Wang
The changesets 19914 and 19922 remove the bitmap for boot allocator, which causes
first_valid_mfnis reduced and starts from the end of xen. On the other hand, onx86_64, the xen heap is got considering e820 table, while onx86_32the xen heap is specified to be <xenheap_phys_end. This range overlaps tboot range. So, the tboot range is scrubbed byscrub_heap_pages()duringstart_xen()onx86_32. Then the result is that for TXT support onx86_32, shutdown/reboot/Sx doesn't work properly. (i.e. hang)
Quoted 3 lines
So... The problem is that xenheap on
x86_32does not respect e820? I'll fix that if that's the issue. It will be a much smaller change, and toarch/x86/setup.conly.
Yes, it is. It seems x86_32 only respects after xenheap is created.
Quoted 5 lines
-- Keir
Quoted 2 lines
This patch is to fix that by reserving tboot range as "inuse" in xen heap on
x86_32. Then xen code will not touch the range.
Quoted 4 lines · Shane
Quoted 3 lines
So... The problem is that xenheap on
x86_32does not respect e820? I'll fix that if that's the issue. It will be a much smaller change, and toarch/x86/setup.conly.Yes, it is. It seems
x86_32only respects after xenheap is created.
Okay, this should then be fixed by xen-unstable:20403, which I have also backported to xen-3.4-testing for Xen 3.4.2 release.
-- Keir