Skip to contentSkip to conversation

Hard disk support is broken in Windows 98SE guest

Qemu-devel Victor Shkamerda 3 participants 5 messages Oct 2, 2007 – Oct 3, 2007

lore
Share & tools
lore
#0 lore raw

Hi,

Hard disk support is broken in recent CVS for Windows 98SE OS guest. DOS also have problems. Windows 2003 seems to be fine.

Try to create hard disk image using "dd of=w98.img bs=1 count=0 seek=508M" and install Windows 98SE by booting from installation CD. Installation failed not able to partition, format and verify file system.

It all works fine in version 0.9.0.

With best regards,
Victor Shkamerda

-- --- --
LIMITARE DE OBLIGATIUNI: Mesajele expediate din cadrul Bancii Nationale a Moldovei sunt transmise cu buna intentie si nu trebuie considerate drept obligatorii in activitatea acestei organizatii. Informatia transmisa este destinata doar pentru adresat si poate contine date confidentiale si / sau privilegiate. In caz ca primiti mesajul dat din greseala, va rugam sa contactati expeditorul si sa stergeti informatia in cauza din computerul Dvs.
DISCLAIMER: Any e-mail messages from the National Bank of Moldova are sent in good faith, but shall not be binding nor construed as constituting any obligation on the part of the Bank. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you received this in error, please contact the sender and delete the material from any computer.

#1 lore raw
Quoted 11 lines · Victor Shkamerda

Hi,

Hard disk support is broken in recent CVS for Windows 98SE OS guest. DOS also have problems. Windows 2003 seems to be fine.

Try to create hard disk image using "dd of=w98.img bs=1 count=0 seek=508M" and install Windows 98SE by booting from installation CD. Installation failed not able to partition, format and verify file system.

It all works fine in version 0.9.0.

I don't have such a system for tests. Can you narrow down which CVS commit broke it?

Thiemo

#2 lore raw

Hello,

Quoted 1 line
Quoted 1 line
Quoted 1 line

On 10/2/2007 at 7:43 PM, in message <[email protected]>,

Quoted 2 lines · Thiemo Seufer

I don't have such a system for tests. Can you narrow down which CVS commit broke it?

hw/ide.c 1.64 works, version 1.65 doesn't. Only BIOS operations seems to be affected, so it may be BIOS fault after all. You can use FreeDOS for testing, it doesn't install too.

Victor Shkamerda

-- --- --
LIMITARE DE OBLIGATIUNI: Mesajele expediate din cadrul Bancii Nationale a Moldovei sunt transmise cu buna intentie si nu trebuie considerate drept obligatorii in activitatea acestei organizatii. Informatia transmisa este destinata doar pentru adresat si poate contine date confidentiale si / sau privilegiate. In caz ca primiti mesajul dat din greseala, va rugam sa contactati expeditorul si sa stergeti informatia in cauza din computerul Dvs.
DISCLAIMER: Any e-mail messages from the National Bank of Moldova are sent in good faith, but shall not be binding nor construed as constituting any obligation on the part of the Bank. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. If you received this in error, please contact the sender and delete the material from any computer.

#3 lore raw
Quoted 9 lines · Victor Shkamerda

Hello,

Quoted 1 line
Quoted 1 line
Quoted 1 line

On 10/2/2007 at 7:43 PM, in message <[email protected]>,

Quoted 2 lines · Thiemo Seufer

I don't have such a system for tests. Can you narrow down which CVS commit broke it?

hw/ide.c 1.64 works, version 1.65 doesn't. Only BIOS operations seems to be affected, so it may be BIOS fault after all. You can use FreeDOS for testing, it doesn't install too.

The problem seems to be that the BIOS does not wait for the previous write to complete before trying the next one. It's not clear to me whether this needs to be fixed in the BIOS or in hw/ide.c. One correct fix may be to have ide_sector_write set BUSY_STAT and then let the AIO callback function set the status to READY_STAT, but this definitely does not work well with the BOCHS BIOS. Here's a hack that seems to work, but it's pretty ugly:

Index: hw/ide.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/ide.c,v
retrieving revision 1.69

ide.c 3 Oct 2007 18:00:31 -0000 renamed from ide.c 17 Sep 2007 08:09:47 -0000 1.69 +3 -1
diff -a -u -r1.69 ide.c
@@ -900,7 +900,9 @@
     if(bm == NULL) {
        bm = qemu_mallocz(sizeof(BMDMAState));
        s->bmdma = bm;
-    }
+    } else if (bm->aiocb != NULL)
+        qemu_aio_wait();
+
     bm->ide_if = s;
     bm->dma_cb = ide_sector_write_aio_cb;
 

The danger here is that the AIO signal came in already by the time we call qemu_aio_wait() (but bm->aiocb was not called yet), which is pretty unlikely, but I think it could trigger a deadlock. I don't think that's correct, but the fact is the BIOS assumes that the write is done by the time it does another write. That seems to step on the io_buffer, which is part of the asynchronous write that is pending. Another solution may be to use a separate buffer for the write, but then you have a copy and you have to hold on to the memory until the write finishes. I think ultimately the correct fix is in the BIOS - perhaps a spinlock on BUSY_STAT like it does after seeks, or something like that. Maybe someone who knows more about this can comment. Please note that I am not asking for the above patch to be committed, just putting it out there as food for thought. It's probably (likely) the wrong approach.

The reason the old win2k-hack worked, even if the BIOS didn't wait for the IDE interrupt to write the next buffer, is because the actual host write() was synchronous and the IO buffer could be safely stepped on at any point after that. AIO writes have to hold on to the buffer until they complete (see man page for aio_write).

- Leo Reiter

#4 lore raw
Quoted 19 lines · Leonardo Reiter

Index: hw/ide.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/ide.c,v
retrieving revision 1.69
diff -a -u -r1.69 ide.c

ide.c 3 Oct 2007 18:00:31 -0000 renamed from ide.c 17 Sep 2007 08:09:47 -0000 1.69 +3 -1
@@ -900,7 +900,9 @@
     if(bm == NULL) {
        bm = qemu_mallocz(sizeof(BMDMAState));
        s->bmdma = bm;
-    }
+    } else if (bm->aiocb != NULL)
+        qemu_aio_wait();
+
     bm->ide_if = s;
     bm->dma_cb = ide_sector_write_aio_cb;
 
Quoted 3 lines

The danger here is that the AIO signal came in already by the time we call qemu_aio_wait() (but bm->aiocb was not called yet), which is pretty unlikely, but I think it could trigger a deadlock.

If you want to try that hack, I think it's probably safer (and more correct) to use qemu_aio_flush() instead of qemu_aio_wait().

Regards,

Leo Reiter