From 8493c33b1adbaf0adaa6bf2b7c1696e86a89ab1b Mon Sep 17 00:00:00 2001 From: Suraj Jitindar Singh Date: Fri, 6 Oct 2017 14:29:45 +1100 Subject: 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 Signed-off-by: Suraj Jitindar Singh Change-Id: Ic857c31e9402b98ab19dba1a23adc74eaf40491b --- mboxd_windows.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mboxd_windows.c') 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 -- cgit v1.2.1