Blame SOURCES/kvm-pflash_cfi01-Log-use-of-flawed-write-to-buffer.patch

7711c0
From d35903b0e772c0cdcd3f685dbee81ffbd110a24a Mon Sep 17 00:00:00 2001
7711c0
From: Markus Armbruster <armbru@redhat.com>
7711c0
Date: Fri, 17 May 2019 06:50:54 +0200
7711c0
Subject: [PATCH 27/53] pflash_cfi01: Log use of flawed "write to buffer"
7711c0
MIME-Version: 1.0
7711c0
Content-Type: text/plain; charset=UTF-8
7711c0
Content-Transfer-Encoding: 8bit
7711c0
7711c0
RH-Author: Markus Armbruster <armbru@redhat.com>
7711c0
Message-id: <20190517065120.12028-6-armbru@redhat.com>
7711c0
Patchwork-id: 87990
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v3 05/31] pflash_cfi01: Log use of flawed "write to buffer"
7711c0
Bugzilla: 1624009
7711c0
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7711c0
RH-Acked-by: Thomas Huth <thuth@redhat.com>
7711c0
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
7711c0
Our implementation of "write to buffer" (command 0xE8) is flawed.
7711c0
LOG_UNIMP its use, and add some FIXME comments.
7711c0
7711c0
Signed-off-by: Markus Armbruster <armbru@redhat.com>
7711c0
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7711c0
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7711c0
Message-Id: <20190308094610.21210-4-armbru@redhat.com>
7711c0
(cherry picked from commit 4dbda935e054600667f9e57095fa97e2ce5936f9)
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 hw/block/pflash_cfi01.c | 13 +++++++++++++
7711c0
 1 file changed, 13 insertions(+)
7711c0
7711c0
diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
7711c0
index c565db1..3a6bd10 100644
7711c0
--- a/hw/block/pflash_cfi01.c
7711c0
+++ b/hw/block/pflash_cfi01.c
7711c0
@@ -515,6 +515,10 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
7711c0
             break;
7711c0
         case 0xe8: /* Write to buffer */
7711c0
             DPRINTF("%s: Write to buffer\n", __func__);
7711c0
+            /* FIXME should save @offset, @width for case 1+ */
7711c0
+            qemu_log_mask(LOG_UNIMP,
7711c0
+                          "%s: Write to buffer emulation is flawed\n",
7711c0
+                          __func__);
7711c0
             pfl->status |= 0x80; /* Ready! */
7711c0
             break;
7711c0
         case 0xf0: /* Probe for AMD flash */
7711c0
@@ -558,6 +562,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
7711c0
             /* Mask writeblock size based on device width, or bank width if
7711c0
              * device width not specified.
7711c0
              */
7711c0
+            /* FIXME check @offset, @width */
7711c0
             if (pfl->device_width) {
7711c0
                 value = extract32(value, 0, pfl->device_width * 8);
7711c0
             } else {
7711c0
@@ -595,7 +600,13 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
7711c0
     case 2:
7711c0
         switch (pfl->cmd) {
7711c0
         case 0xe8: /* Block write */
7711c0
+            /* FIXME check @offset, @width */
7711c0
             if (!pfl->ro) {
7711c0
+                /*
7711c0
+                 * FIXME writing straight to memory is *wrong*.  We
7711c0
+                 * should write to a buffer, and flush it to memory
7711c0
+                 * only on confirm command (see below).
7711c0
+                 */
7711c0
                 pflash_data_write(pfl, offset, value, width, be);
7711c0
             } else {
7711c0
                 pfl->status |= 0x10; /* Programming error */
7711c0
@@ -611,6 +622,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
7711c0
                 pfl->wcycle++;
7711c0
                 if (!pfl->ro) {
7711c0
                     /* Flush the entire write buffer onto backing storage.  */
7711c0
+                    /* FIXME premature! */
7711c0
                     pflash_update(pfl, offset & mask, pfl->writeblock_size);
7711c0
                 } else {
7711c0
                     pfl->status |= 0x10; /* Programming error */
7711c0
@@ -627,6 +639,7 @@ static void pflash_write(PFlashCFI01 *pfl, hwaddr offset,
7711c0
         switch (pfl->cmd) {
7711c0
         case 0xe8: /* Block write */
7711c0
             if (cmd == 0xd0) {
7711c0
+                /* FIXME this is where we should write out the buffer */
7711c0
                 pfl->wcycle = 0;
7711c0
                 pfl->status |= 0x80;
7711c0
             } else {
7711c0
-- 
7711c0
1.8.3.1
7711c0