From a243241a43b48a7cf0fbe47e54851bd8f2c2023e Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 31 Jul 2009 08:24:27 -0700 Subject: memdisk: don't write the EDD DPT unless we are in EDD mode... Don't write the EDD DPT unless we're actually in EDD mode! Otherwise we end up corrupting memory beyond the defined code. This was the reason 5ca2764460883f5e9a5bd83db00f242ea1272e33 worked, by moving variables out of the corruption zone. Debugged-by: Shao Miller Signed-off-by: H. Peter Anvin --- memdisk/setup.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/memdisk/setup.c b/memdisk/setup.c index 958f6011..7af16108 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -895,19 +895,21 @@ void setup(const struct real_mode_args *rm_args_ptr) } /* Set up an EDD drive parameter table */ - pptr->edd_dpt.sectors = geometry->sectors; - /* The EDD spec has this as <= 15482880 sectors (1024x240x63); - this seems to make very little sense. Try for something saner. */ - if (geometry->c <= 1024 && geometry->h <= 255 && geometry->s <= 63) { + if (do_edd) { + pptr->edd_dpt.sectors = geometry->sectors; + /* The EDD spec has this as <= 15482880 sectors (1024x240x63); + this seems to make very little sense. Try for something saner. */ + if (geometry->c <= 1024 && geometry->h <= 255 && geometry->s <= 63) { pptr->edd_dpt.c = geometry->c; pptr->edd_dpt.h = geometry->h; pptr->edd_dpt.s = geometry->s; pptr->edd_dpt.flags |= 0x0002; /* Geometry valid */ - } - if (!(geometry->driveno & 0x80)) { + } + if (!(geometry->driveno & 0x80)) { /* Floppy drive. Mark it as a removable device with media change notification; media is present. */ pptr->edd_dpt.flags |= 0x0014; + } } /* The size is given by hptr->total_size plus the size of the E820 -- cgit v1.2.1