From nobody Mon Sep 28 01:11:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; t=1785730775; cv=none; d=zohomail.com; s=zohoarc; b=KwzUrvewKEwEMZHgTYG6YkciFW1hcvbB1jbQ1FZo+rfZUSGixOnR1qPAPDu2NxKniSJ9/dJqfUCDnh3Dp5qbZDujoAC/byt3SlmSvEmtQ3Lq45JXlMAW0fP2+/pGPw4TZYTfVEd+cDZZxb1n80HExZETQ5G8Yt5MGZ6iHC+ve8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785730775; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pFg0IQ2u8lRhdx+cnZaKJqxxt1uXYe8gytmVsUf7ybY=; b=OqrTbOBdX0VVlYZ4gUc3YIZJ1kw5Dxz3x3c+t3tzn3iXJEytiqUoq5NjmQEI/oFVSFhdNzOv58B3YP08YE//7/1mTjGHSV+IJ11PAqkudtcAhRMIcKOODljeHCbFbntPRLM4+FocTryVjDyrMZ3OUNSB1wLbBW1pWmBisPF9SeI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785730775152663.5281809480533; Sun, 2 Aug 2026 21:19:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wqk8b-0003Wf-Jo; Mon, 03 Aug 2026 00:18:54 -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 1wqk8W-0003Vt-A0; Mon, 03 Aug 2026 00:18:48 -0400 Received: from [115.124.30.131] (helo=out30-131.freemail.mail.aliyun.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wqk8N-0004p9-46; Mon, 03 Aug 2026 00:18:48 -0400 Received: from localhost(mailfrom:guobin@linux.alibaba.com fp:SMTPD_---0X8ELlyQ_1785730689 cluster:ay36) by smtp.aliyun-inc.com; Mon, 03 Aug 2026 12:18:10 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1785730691; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=pFg0IQ2u8lRhdx+cnZaKJqxxt1uXYe8gytmVsUf7ybY=; b=o9oE9tW2/ICC8zzt6O3brTwv0zjJuRIBOEX/ADMf/8bJ0Bfa7JO2uzMzH3GxI7lXxTsWz05sFlU/eCVFc4meTKuW4hvESucOEc6I9fjjFjPfpSbTJCGOSzGm62UDiAW0zwYncng/rON7vtSKd6mGwI4gCmgAd/9OVba+h7qciv0= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R161e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033045133197; MF=guobin@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0X8ELlyQ_1785730689; From: Bin Guo To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, qemu-stable@nongnu.org Subject: [PATCH] hw/block/pflash_cfi01: Restore ROMD mode after migration Date: Mon, 3 Aug 2026 12:18:08 +0800 Message-ID: <20260803041808.58174-1-guobin@linux.alibaba.com> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 115.124.30.131 (deferred) Received-SPF: pass (zohomail.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=lists1p.gnu.org; Received-SPF: pass client-ip=115.124.30.131; envelope-from=guobin@linux.alibaba.com; helo=out30-131.freemail.mail.aliyun.com X-Spam_score_int: -166 X-Spam_score: -16.7 X-Spam_bar: ---------------- X-Spam_report: (-16.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linux.alibaba.com) X-ZM-MESSAGEID: 1785730777169158500 Content-Type: text/plain; charset="utf-8" pflash_post_load() did not restore the ROMD mode of the memory region. Although cmd and wcycle are migrated, the destination retains the default ROMD =3D true from realize. When the source was in a non-array mode (e.g. ID read, cmd =3D 0x90), reads on the destination bypass pflash_read() via the ROM fast path and return raw storage bytes instead of the command-specific response. Derive ROMD from the migrated cmd/wcycle in pflash_post_load. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4042 Cc: qemu-stable@nongnu.org Signed-off-by: Bin Guo Reviewed-by: Peter Maydell --- hw/block/pflash_cfi01.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 5b9ddb20b1..a13b91967e 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -1030,6 +1030,16 @@ static int pflash_post_load(void *opaque, int versio= n_id) { PFlashCFI01 *pfl =3D opaque; =20 + /* + * ROMD mode is not in the VMState; derive it from the migrated + * cmd and wcycle. Only (wcycle =3D=3D 0, cmd =3D=3D 0x00) is read-ar= ray. + */ + if (pfl->wcycle =3D=3D 0 && pfl->cmd =3D=3D 0x00) { + memory_region_rom_device_set_romd(&pfl->mem, true); + } else { + memory_region_rom_device_set_romd(&pfl->mem, false); + } + if (!pfl->ro) { pfl->vmstate =3D qemu_add_vm_change_state_handler(postload_update_= cb, pfl); --=20 2.50.1 (Apple Git-155)