Received: from eggs.gnu.org ([2001:4830:134:3::10]:53604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUZrK-00073F-Kh for qemu-devel@nongnu.org; Tue, 02 Aug 2016 09:35:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUZrF-0006e3-En for qemu-devel@nongnu.org; Tue, 02 Aug 2016 09:35:49 -0400 Received: from indium.canonical.com ([91.189.90.7]:60466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUZrF-0006dq-3C for qemu-devel@nongnu.org; Tue, 02 Aug 2016 09:35:45 -0400 Received: from loganberry.canonical.com ([91.189.90.37]) by indium.canonical.com with esmtp (Exim 4.76 #1 (Debian)) id 1bUZrD-0005aS-AJ for ; Tue, 02 Aug 2016 13:35:43 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 700FB2E80C8 for ; Tue, 2 Aug 2016 13:35:42 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Date: Tue, 02 Aug 2016 13:30:01 -0000 From: Kevin Wolf <1608802@bugs.launchpad.net> Reply-To: Bug 1608802 <1608802@bugs.launchpad.net> Sender: bounces@canonical.com References: <20160802061128.22869.50660.malonedeb@soybean.canonical.com> Message-Id: <20160802133001.21093.64034.malone@wampee.canonical.com> Errors-To: bounces@canonical.com Subject: [Qemu-devel] [Bug 1608802] Re: READ_DMA (0xC8) command does not work correctly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Okay, I think there are two parts to this, and both the test case and qemu = are buggy, though perhaps the test case more seriously than qemu. The ATA spec describes DMA commands as having two phases, preparation and transfer. During the first phase, BSY=3D1,DRQ=3D0 is required. In the secon= d phase, the device can use the same status (BSY=3D1,DRQ=3D0) or switch to BSY=3D0,D= RQ=3D1. I couldn't find clear information on which state the device should be in be= tween receiving the ATA command and enabling the bus master operation, which is w= hat the test case checks, but it must be one of the two. So the reason that the test case is buggy is that it waits for DRQ to be se= t, while the spec only guarantees that either DRQ or BSY is set during the transfer. It doesn't work on hardware that sets BSY rather than DRQ. (It al= so means that the test expects the device to be in the transfer state before t= he bus master is enabled.) The problem with qemu is that it sets _both_ bits, whereas the spec requires that only one of them is set. Apparently most drivers don't care about this= as long as any of the bits is set, but technically it's wrong. -- = You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1608802 Title: READ_DMA (0xC8) command does not work correctly Status in QEMU: Confirmed Bug description: The QEMU PC emulation of DMA does not behave like real hardware or other virtualization software. From the original bug report (Benjamin David Lunt): =C2=A0=C2=A0=C2=A0=C2=A0Back to the READ_DMA command, it is my conclusion= that the =C2=A0=C2=A0=C2=A0=C2=A0READ_DMA command, more precisely, the BUS Master = part of QEMU is =C2=A0=C2=A0=C2=A0=C2=A0in error. The tests that people have done to see= if it works, is =C2=A0=C2=A0=C2=A0=C2=A0probably the guest finding out that DMA doesn't w= ork and defaulting =C2=A0=C2=A0=C2=A0=C2=A0to PIO, but since the read was successful visuall= y to the user, the =C2=A0=C2=A0=C2=A0=C2=A0user assumed the READ_DMA command works, where th= e guest actually =C2=A0=C2=A0=C2=A0=C2=A0defaulted back to PIO transfers without notice. =C2=A0=C2=A0=C2=A0=C2=A0My code works on real hardware (numerous machines= ), Bochs, and Oracle's =C2=A0=C2=A0=C2=A0=C2=A0Virtual Box. =C2=A0=C2=A0=C2=A0=C2=A0... =C2=A0=C2=A0=C2=A0=C2=A0I have a small test suite, zipped and included at: =C2=A0=C2=A0=C2=A0=C2=A0www.fysnet.net/temp/c8bug.zip =C2=A0=C2=A0=C2=A0=C2=A0Within this zip file is a.img. This is a freeDOS = bootable =C2=A0=C2=A0=C2=A0=C2=A0floppy. Emulate it with QEMU and then at the DOS= prompt, run =C2=A0=C2=A0=C2=A0=C2=A0c8bug.exe. =C2=A0=C2=A0=C2=A0=C2=A0It will say that the drive is not ready. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"Drive never became ready" =C2=A0=C2=A0=C2=A0=C2=A0(along with a few other lines of text) =C2=A0=C2=A0=C2=A0=C2=A0The source for this test suite is also included. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0c8bug.c is the c source code =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0c8bug.h is the header file =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0ctype.h is a quick way to get 'bit8u' type = defines =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0timer.h is a delay routine from another pro= ject I have =C2=A0=C2=A0=C2=A0=C2=A0(The base IO addresses are assumed and set at the= top of c8bug.c) =C2=A0=C2=A0=C2=A0=C2=A0(compiled with DJGPP for DPMI) =C2=A0=C2=A0=C2=A0=C2=A0q.bat is my command line for QEMU =C2=A0=C2=A0=C2=A0=C2=A0On all other machines and VirtualBox, the control= ler is ready =C2=A0=C2=A0=C2=A0=C2=A0for me to receive the sector data. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"Drive is ready to transmit data..." =C2=A0=C2=A0=C2=A0=C2=A0However, in QEMU, the controller never becomes re= ady. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0"Drive never became ready" The bug was reported for QEMU for Windows, but I can confirm that QEMU for Linux also shows that behaviour, while VirtualBox works. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1608802/+subscriptions