From nobody Mon Feb 9 08:11:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1563315409; cv=none; d=zoho.com; s=zohoarc; b=bTCdhU2Zs5s7MNlufBh7xmhF6dokXyg0uJ5RAN4Bnop5PB+E1o+lM5uuhIR1hgS2AlAX0PWdCxYRC8Q/5c7MkEhDCraiwENhdgqlcKfT1BOo6uQS2xp4PjZEaJB+WyCVGOpHvzUAQsTBqU2rcuc5cHwNy/9naBpvODGxoBiKUq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563315409; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=D6EqkF38sKMixXQpd9P0czN4HMYBXwrKE7bhIDLGL5g=; b=NMT9eFOrR9sG6MUb8zmCbz0qmlyz4BK9wSLGAe7Z3pPtwdptmdMvXqK1aPdBkHeBzVLGmw89JJVW+lJfRuCanFjFh703csQnArRMvl1os2/23RcTanIQewmLwvLfUDcRusatQbHdfmuBzNfaO52hsksKZ8WVOiiUF3DTCMHCyzU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563315409547622.5715252053211; Tue, 16 Jul 2019 15:16:49 -0700 (PDT) Received: from localhost ([::1]:52628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnVkd-0007Ci-Vd for importer@patchew.org; Tue, 16 Jul 2019 18:16:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41593) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hnVkG-0006A2-MU for qemu-devel@nongnu.org; Tue, 16 Jul 2019 18:16:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hnVkF-0002MY-H5 for qemu-devel@nongnu.org; Tue, 16 Jul 2019 18:16:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55504) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hnVkD-0002Jj-5j; Tue, 16 Jul 2019 18:16:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A11E8553A; Tue, 16 Jul 2019 22:16:20 +0000 (UTC) Received: from x1w.redhat.com (ovpn-204-58.brq.redhat.com [10.40.204.58]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C5BC5DAA4; Tue, 16 Jul 2019 22:16:14 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Date: Wed, 17 Jul 2019 00:15:52 +0200 Message-Id: <20190716221555.11145-3-philmd@redhat.com> In-Reply-To: <20190716221555.11145-1-philmd@redhat.com> References: <20190716221555.11145-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 16 Jul 2019 22:16:20 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH-for-4.1 v6 2/5] hw/block/pflash_cfi01: Document use of non-CFI compliant command '0x00' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Laszlo Ersek , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Markus Armbruster , Max Reitz , Alistair Francis , John Snow , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The command 0x00 is used by this model since its origin (commit 05ee37ebf630). In this commit the command is described with a amusing '/* ??? */' comment, probably meaning 'FIXME'. switch (cmd) { case 0x00: /* ??? */ ... This comment survived 12 years because the 0x00 value is indeed not specified by the CFI open standard (as of this commit). The 'cmd' field is transfered during migration. To keep the migration feature working with older QEMU version, we have to take a lot of care with migrated field. We figured out it is too late to remove a non-specified value from this model (this would make migration review very complex). It is however not too late to improve the documentation. Add few comments to remember this is a special value related to QEMU, and we won't find information about it on the CFI spec. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- v6: new patch --- hw/block/pflash_cfi01.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index a9529957f8..6838e8a1ab 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -277,9 +277,13 @@ static uint32_t pflash_read(PFlashCFI01 *pfl, hwaddr o= ffset, /* This should never happen : reset state & treat it as a read */ DPRINTF("%s: unknown command state: %x\n", __func__, pfl->cmd); pfl->wcycle =3D 0; - pfl->cmd =3D 0; + /* + * The command 0x00 is not assigned by the CFI open standard, + * but QEMU historically uses it for the READ_ARRAY command (0xff). + */ + pfl->cmd =3D 0x00; /* fall through to read code */ - case 0x00: + case 0x00: /* This model reset value for READ_ARRAY (not CFI compliant= ) */ /* Flash area read */ ret =3D pflash_data_read(pfl, offset, width, be); break; @@ -448,7 +452,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, case 0: /* read mode */ switch (cmd) { - case 0x00: /* ??? */ + case 0x00: /* This model reset value for READ_ARRAY (not CFI) */ goto reset_flash; case 0x10: /* Single Byte Program */ case 0x40: /* Single Byte Program */ @@ -645,7 +649,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offse= t, trace_pflash_reset(); memory_region_rom_device_set_romd(&pfl->mem, true); pfl->wcycle =3D 0; - pfl->cmd =3D 0; + pfl->cmd =3D 0x00; /* This model reset value for READ_ARRAY (not CFI) = */ } =20 =20 @@ -761,7 +765,11 @@ static void pflash_cfi01_realize(DeviceState *dev, Err= or **errp) } =20 pfl->wcycle =3D 0; - pfl->cmd =3D 0; + /* + * The command 0x00 is not assigned by the CFI open standard, + * but QEMU historically uses it for the READ_ARRAY command (0xff). + */ + pfl->cmd =3D 0x00; pfl->status =3D 0x80; /* WSM ready */ /* Hardcoded CFI table */ /* Standard "QRY" string */ --=20 2.20.1