Skip to contentSkip to conversation

to fix the bug for tboot on x86_32 brought by c/s 19914 and 19922

PATCH In review Shane Wang 2 participants 4 messages Nov 6, 2009 – Nov 9, 2009

lore
Share & tools
lore

Shane Wang

author
#0 lore raw

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
diff -r e351f4cedded xen/arch/x86/setup.c
@@ -1066,6 +1066,9 @@ void __init __start_xen(unsigned long mb
     if ( !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
diff -r e351f4cedded xen/include/asm-x86/tboot.h
@@ -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
diff -r e351f4cedded xen/include/xen/mm.h
@@ -62,6 +62,7 @@ unsigned int online_page(unsigned long m
 unsigned 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
diff -r e351f4cedded xen/arch/x86/setup.c
@@ -1066,6 +1066,9 @@ void __init __start_xen(unsigned long mb
     if ( !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
diff -r e351f4cedded xen/include/asm-x86/tboot.h
@@ -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
diff -r e351f4cedded xen/include/xen/mm.h
@@ -62,6 +62,7 @@ unsigned int online_page(unsigned long m
 unsigned 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

#1 lore raw
Quoted 8 lines · Shane Wang

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)

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.

#2 lore raw
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_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)

Quoted 3 lines

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.

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.

#3 lore raw
Quoted 4 lines · Shane
Quoted 3 lines

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.

Yes, it is. It seems x86_32 only 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