summaryrefslogtreecommitdiffstats
path: root/mboxd_windows.c
diff options
context:
space:
mode:
authorSuraj Jitindar Singh <sjitindarsingh@gmail.com>2017-10-06 14:29:45 +1100
committerSuraj Jitindar Singh <sjitindarsingh@gmail.com>2017-10-10 14:41:41 +1100
commit8493c33b1adbaf0adaa6bf2b7c1696e86a89ab1b (patch)
treecdb32d1930cb3630c6b193a8b80be7e4a6335a3d /mboxd_windows.c
parent5cd1a433f48c659dbebc1c31840890ba29f4fe16 (diff)
downloadphosphor-mboxd-8493c33b1adbaf0adaa6bf2b7c1696e86a89ab1b.tar.gz
phosphor-mboxd-8493c33b1adbaf0adaa6bf2b7c1696e86a89ab1b.zip
vpnor: Fix unable to read unaligned partition override files
Currently when using vpnor and an override file is applied which has an unaligned size it is impossible to read the last unaligned bit of the file. This is because the response to the host truncates the window size when converting from bytes to blocks (effectively aligning down the size and causing the window to look smaller than it is). We could blindly align up the size but then the host would be within its rights to access uninitialised memory which we would like to avoid. To work around this we always align the window size up to a multiple of block size. Any memory not read from the file is set to 0xFF to mimic erased flash. Fixes: https://github.com/openbmc/openbmc/issues/2344 Reported-by: Stewart Smith <sesmith@au1.ibm.com> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> Change-Id: Ic857c31e9402b98ab19dba1a23adc74eaf40491b
Diffstat (limited to 'mboxd_windows.c')
-rw-r--r--mboxd_windows.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mboxd_windows.c b/mboxd_windows.c
index e4d9882..afe28b2 100644
--- a/mboxd_windows.c
+++ b/mboxd_windows.c
@@ -635,7 +635,10 @@ int create_map_window(struct mbox_context *context,
reset_window(context, cur);
return rc;
}
- cur->size = rc;
+ /* rc isn't guaranteed to be aligned, so align up */
+ cur->size = align_up(rc, (1ULL << context->block_size_shift));
+ /* Would like a known value, pick 0xFF to it looks like erased flash */
+ memset(cur->mem + rc, 0xFF, cur->size - rc);
/*
* Since for V1 windows aren't constrained to start at multiples of
OpenPOWER on IntegriCloud