From nobody Fri Nov 7 15:42:07 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548279324571575.5895504480599; Wed, 23 Jan 2019 13:35:24 -0800 (PST) Received: from localhost ([127.0.0.1]:42175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmQAu-0006AH-Gi for importer@patchew.org; Wed, 23 Jan 2019 16:35:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmPzU-0006Hg-Da for qemu-devel@nongnu.org; Wed, 23 Jan 2019 16:23:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gmPzT-0001rB-Ja for qemu-devel@nongnu.org; Wed, 23 Jan 2019 16:23:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56692) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gmPzN-0001lJ-Vs; Wed, 23 Jan 2019 16:23:15 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C2B19D43E; Wed, 23 Jan 2019 21:23:12 +0000 (UTC) Received: from localhost (ovpn-116-104.ams2.redhat.com [10.36.116.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id D056C65F72; Wed, 23 Jan 2019 21:23:09 +0000 (UTC) From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Wed, 23 Jan 2019 21:22:31 +0000 Message-Id: <20190123212234.32068-3-stefanha@redhat.com> In-Reply-To: <20190123212234.32068-1-stefanha@redhat.com> References: <20190123212234.32068-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 23 Jan 2019 21:23:12 +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 v2 2/5] pflash: flush rom device memory region X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Stefan Hajnoczi , qemu-block@nongnu.org, Peter Crosthwaite , =?UTF-8?q?Steffen=20G=C3=B6rtz?= , jim@groklearning.com, Max Reitz , qemu-arm@nongnu.org, Joel Stanley , Kevin Wolf , Paolo Bonzini , jusual@mail.ru, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" pflash devices should mark the memory region dirty and invalidate TBs after directly writing to the RAM backing the ROM device. Note that pflash_cfi01_get_memory() is used by several machine types to populate ROM contents directly. Callers are untouched by this patch because they only modify memory before the guest is started. Signed-off-by: Stefan Hajnoczi --- hw/block/pflash_cfi01.c | 5 +++++ hw/block/pflash_cfi02.c | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index bffb4c40e7..5301c11c18 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -446,6 +446,7 @@ static inline void pflash_data_write(pflash_t *pfl, hwa= ddr offset, break; } =20 + memory_region_flush_rom_device(&pfl->mem, offset, width); } =20 static void pflash_write(pflash_t *pfl, hwaddr offset, @@ -482,6 +483,8 @@ static void pflash_write(pflash_t *pfl, hwaddr offset, if (!pfl->ro) { memset(p + offset, 0xff, pfl->sector_len); pflash_update(pfl, offset, pfl->sector_len); + memory_region_flush_rom_device(&pfl->mem, offset, + pfl->sector_len); } else { pfl->status |=3D 0x20; /* Block erase error */ } @@ -763,6 +766,8 @@ static void pflash_cfi01_realize(DeviceState *dev, Erro= r **errp) error_setg(errp, "failed to read the initial flash content"); return; } + + memory_region_flush_rom_device(&pfl->mem, 0, total_len); } =20 /* Default to devices being used at their maximum device width. This w= as diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index 0f8b7b8c7b..d04572eca4 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -378,6 +378,8 @@ static void pflash_write (pflash_t *pfl, hwaddr offset, pflash_update(pfl, offset, 4); break; } + + memory_region_flush_rom_device(&pfl->orig_mem, offset, wid= th); } pfl->status =3D 0x00 | ~(value & 0x80); /* Let's pretend write is immediate */ @@ -426,6 +428,8 @@ static void pflash_write (pflash_t *pfl, hwaddr offset, if (!pfl->ro) { memset(pfl->storage, 0xFF, pfl->chip_len); pflash_update(pfl, 0, pfl->chip_len); + memory_region_flush_rom_device(&pfl->orig_mem, 0, + pfl->chip_len); } pfl->status =3D 0x00; /* Let's wait 5 seconds before chip erase is done */ @@ -441,6 +445,8 @@ static void pflash_write (pflash_t *pfl, hwaddr offset, if (!pfl->ro) { memset(p + offset, 0xFF, pfl->sector_len); pflash_update(pfl, offset, pfl->sector_len); + memory_region_flush_rom_device(&pfl->orig_mem, offset, + pfl->sector_len); } pfl->status =3D 0x00; /* Let's wait 1/2 second before sector erase is done */ @@ -590,6 +596,8 @@ static void pflash_cfi02_realize(DeviceState *dev, Erro= r **errp) error_setg(errp, "failed to read the initial flash content"); return; } + + memory_region_flush_rom_device(&pfl->orig_mem, 0, chip_len); } =20 pflash_setup_mappings(pfl); --=20 2.20.1