Verify ebda segment looks sane before using during resume.
diff --git a/src/asm-offsets.c b/src/asm-offsets.c
index ea49296..c324151 100644
--- a/src/asm-offsets.c
+++ b/src/asm-offsets.c
@@ -27,4 +27,5 @@
 
     COMMENT("EBDA");
     DEFINE(EBDA_OFFSET_TOP_STACK, EBDA_OFFSET_TOP_STACK);
+    DEFINE(EBDA_SEGMENT_START, EBDA_SEGMENT_START);
 }
diff --git a/src/biosvar.h b/src/biosvar.h
index fceb876..c0b46cc 100644
--- a/src/biosvar.h
+++ b/src/biosvar.h
@@ -235,6 +235,12 @@
     u8 extra_stack[512] __aligned(8);
 } PACKED;
 
+// The initial size and location of EBDA
+#define EBDA_SIZE_START \
+    DIV_ROUND_UP(sizeof(struct extended_bios_data_area_s), 1024)
+#define EBDA_SEGMENT_START \
+    FLATPTR_TO_SEG((640 - EBDA_SIZE_START) * 1024)
+
 // Accessor functions
 static inline u16 get_ebda_seg() {
     return GET_BDA(ebda_seg);
diff --git a/src/post.c b/src/post.c
index a642e18..97fe6ac 100644
--- a/src/post.c
+++ b/src/post.c
@@ -76,9 +76,9 @@
     struct bios_data_area_s *bda = MAKE_FLATPTR(SEG_BDA, 0);
     memset(bda, 0, sizeof(*bda));
 
-    int esize = DIV_ROUND_UP(sizeof(struct extended_bios_data_area_s), 1024);
+    int esize = EBDA_SIZE_START;
     SET_BDA(mem_size_kb, 640 - esize);
-    u16 eseg = FLATPTR_TO_SEG((640 - esize) * 1024);
+    u16 eseg = EBDA_SEGMENT_START;
     SET_BDA(ebda_seg, eseg);
 
     struct extended_bios_data_area_s *ebda = get_ebda_ptr();
diff --git a/src/romlayout.S b/src/romlayout.S
index eca4240..9fe5c71 100644
--- a/src/romlayout.S
+++ b/src/romlayout.S
@@ -251,8 +251,13 @@
         movw $SEG_BDA, %ax
         movw %ax, %ds
         movw BDA_ebda_seg, %ax
-        // XXX - should verify ebda_seg looks sane.
-        movw %ax, %ds
+
+        cmpw $EBDA_SEGMENT_START, %ax
+        jle 2f
+        // EBDA segment doesn't look valid - use startup value.
+        movw $EBDA_SEGMENT_START, %ax
+
+2:      movw %ax, %ds
         movw %ax, %ss
         movl $EBDA_OFFSET_TOP_STACK, %esp