summaryrefslogtreecommitdiffstats
path: root/vpnor/mboxd_flash.cpp
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-03-27 10:35:31 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-04-04 17:27:31 +0930
commit52a8319658c8ac3dcce2fed116d20d6014d7b143 (patch)
treec546f26c8d07e3284828b09d85574d3806cd1c1c /vpnor/mboxd_flash.cpp
parent943aba060f143667d502792f11e95f42bc7da346 (diff)
downloadphosphor-mboxd-52a8319658c8ac3dcce2fed116d20d6014d7b143.tar.gz
phosphor-mboxd-52a8319658c8ac3dcce2fed116d20d6014d7b143.zip
vpnor: Add handler for CREATE_WRITE_WINDOW
The virtual PNOR implementation enforces the read-only attribute of FFS partitions, which is a departure from how things were handled previously. In the past it was purely up to the host to respect the flags set on the partition, but nothing prevented the host from modifying it. Now it's possible for errors to occur when the host attempts to flush changes back to the flash: mboxd can deny the change. This denial can happen in a number of circumstances: 1. An explicit WRITE_FLUSH command from the host 2. An implicit WRITE_FLUSH via an explicit CLOSE_WINDOW command 3. An implicit WRITE_FLUSH via CREATE_{READ,WRITE}_WINDOW, which happens via the implicit CLOSE_WINDOW All of these attempts will fail if the write to the currently open window cannot be allowed to succeed. Failing to open a read window due to failure to flush pending writes is particularly painful, as we are not able to ever successfully open a window again. Instead, detect when the host attempts to open a write window over a anything but a writeable partition. If this case is detected, return an error for the CREATE_WRITE_WINDOW operation to prevent systemic failures later on. Change-Id: I991b6f1570d9b1b384b1024e3bd8a77e5efcd198 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Diffstat (limited to 'vpnor/mboxd_flash.cpp')
-rw-r--r--vpnor/mboxd_flash.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/vpnor/mboxd_flash.cpp b/vpnor/mboxd_flash.cpp
index ffe75c6..a774ec1 100644
--- a/vpnor/mboxd_flash.cpp
+++ b/vpnor/mboxd_flash.cpp
@@ -203,7 +203,9 @@ int write_flash(struct mbox_context* context, uint32_t offset, void* buf,
const struct pnor_partition& part = table->partition(offset);
if (part.data.user.data[1] & PARTITION_READONLY)
{
- /* FIXME: This should be done on CREATE_WRITE_WINDOW, not here */
+ MSG_ERR("Unreachable: Host attempted to write to read-only "
+ "partition %s\n",
+ part.data.name);
return -MBOX_R_WRITE_ERROR;
}
@@ -214,11 +216,10 @@ int write_flash(struct mbox_context* context, uint32_t offset, void* buf,
}
catch (vpnor::UnmappedOffset& e)
{
- /* Paper over the fact that the write isn't persistent */
- MSG_INFO("Dropping %d bytes host wrote to unmapped offset 0x%" PRIx32
- "\n",
- count, offset);
- return 0;
+ MSG_ERR("Unreachable: Host attempted to write %" PRIu32
+ " bytes to unmapped offset 0x%" PRIx32 "\n",
+ count, offset);
+ return -MBOX_R_WRITE_ERROR;
}
catch (const vpnor::OutOfBoundsOffset& e)
{
OpenPOWER on IntegriCloud