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
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 @@
 		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