Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B63F2CD98F6 for ; Fri, 19 Jun 2026 11:43:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1waXc3-00019B-De; Fri, 19 Jun 2026 07:42:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1waXc2-00018v-0c; Fri, 19 Jun 2026 07:42:18 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1waXbz-0008OK-Vh; Fri, 19 Jun 2026 07:42:17 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 7BE1F59697D; Fri, 19 Jun 2026 13:42:10 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id bzSNrKpeChb8; Fri, 19 Jun 2026 13:42:08 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 4BDD559694F; Fri, 19 Jun 2026 13:42:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 4A2AC596948; Fri, 19 Jun 2026 13:42:08 +0200 (CEST) Date: Fri, 19 Jun 2026 13:42:08 +0200 (CEST) From: BALATON Zoltan To: Matt Jacobson cc: qemu-devel@nongnu.org, Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, Mark Cave-Ayland , Laurent Vivier Subject: Re: [PATCH v2 1/5] hw/block: add Sony/Apple "SuperDrive" diskette drive In-Reply-To: <4E248F07-5231-4B3B-B79C-4B482FDD62AE@me.com> Message-ID: <4271f69f-f14e-18e5-8a36-4a19f736cdff@eik.bme.hu> References: <20260617235032.21491-1-mhjacobson@me.com> <20260617235032.21491-2-mhjacobson@me.com> <758dd5cb-ebdc-325c-37c1-e9120883f468@eik.bme.hu> <4E248F07-5231-4B3B-B79C-4B482FDD62AE@me.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Hello Matt, On Fri, 19 Jun 2026, Matt Jacobson wrote: > Hi Zoltan, > > Many thanks for taking the time to review. Thanks for taking the time to implement this and improve QEMU. >> On Jun 18, 2026, at 7:11 AM, BALATON Zoltan wrote: >> >> On Wed, 17 Jun 2026, Matt Jacobson wrote: >>> The Mac Quadra 800 contains a "SuperDrive" floppy drive that supports >>> both GCR (400 kB and 800 kB) and MFM (1440 kB) diskettes. Implement >>> an emulated version, to be controlled by a forthcoming SWIM2 device. >> >> A bit more explanation could be useful here. In the cover letter it's >> mentioned that GCR/MFM encoding is generated by this emulation. Maybe >> that should be mentioned here. But I don't see what it's needed for. I >> thought maybe for single bit reads but those are not emulated. So is >> encoded data needed at all or could be added later when emulating >> single bit reads making this a simpler patch? > > Apologies for the misunderstanding. > > The GCR-encoded data is filled into xfer_buffer, and from there it's > accessed through sony_drive_read_byte(). In fact, the Macintosh does > the GCR decoding *in software* (in the ".Sony" driver), so the encoding > is definitely required for the I/O to work correctly. This could be explained in the commit message so those not familiar with it (like me) get the basic theory of operation. That's what I meant by more explanation. It should not need to be too detailed, something like the above paragraph is enough detail just to note the tricky parts that are not obvious from first look at the code. > In real hardware, the SWIM2 floppy controller reads the data bit-by-bit > via the RDDATA0/RDDATA1 sense bits, but it seemed like overkill to force > the emulated controller and emulated drive to deal in individual bits. > So that's why I left that unimplemented (though it could be added later > if needed). I see, yes bit-by-bit is not needed unless something in the guest wants to use that but that can be added later if needed. Generally the approach in QEMU is to emulate things at a level that the guest code needs and parts can skipped that are not used by the guest to keep emulation simple. >> My original question that lead to to above was if the asserts in GCR >> encoding and elsewhere could be caused by the user supplying invalid >> data (i.e. bad disk image file) and thus crashing QEMU but I think if >> the disk images contain decoded data not raw GCR/MFM encoded images >> then these asserts would only be caused by errors in encoding functions >> in this file but I'm not completely sure. > > I don't think there are any situations where a bad disk image would > cause an assert. The asserts are for internal consistency only. Asserts for internal consistency are OK to catch programming errors. I'm not sure if we now prefer g_assert which gives more detailed log when it fires, we still have a mix of older asserts so it may depend on the maintainer's preference. To me either is fine. > However, your comment made me realize that there are cases where bad > input *from the guest* (on the write path) could cause a crash. That's > a bug, and I will amend the patch to defend against that. > > Happy to answer any other questions. Thanks again, I'm not familiar with the rest of the series so maybe somebody else can review those. Regards, BALATON Zoltan