aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-03-15 14:19:59 +0000
committerPeter Maydell <peter.maydell@linaro.org>2017-03-15 14:19:59 +0000
commit7584bf5e6fcb444a75687314ab9d06d2ba1f8e4e (patch)
tree6acdb80a67286f60f5b72c8687a0b52171d516eb
parent926e368388420a9728de1e31528ba48e7e8029b3 (diff)
parent9dc44aa5829eb3131a01378a738dee28a382bbc1 (diff)
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
# gpg: Signature made Wed 15 Mar 2017 05:05:04 GMT # gpg: using RSA key 0x9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/block-pull-request: os: don't corrupt pre-existing memory-backend data with prealloc Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--util/oslib-posix.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 956f66ab4a..94d81b9ec0 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -361,7 +361,19 @@ static void *do_touch_pages(void *arg)
memset_thread_failed = true;
} else {
for (i = 0; i < numpages; i++) {
- memset(addr, 0, 1);
+ /*
+ * Read & write back the same value, so we don't
+ * corrupt existing user/app data that might be
+ * stored.
+ *
+ * 'volatile' to stop compiler optimizing this away
+ * to a no-op
+ *
+ * TODO: get a better solution from kernel so we
+ * don't need to write at all so we don't cause
+ * wear on the storage backing the region...
+ */
+ *(volatile char *)addr = *addr;
addr += hpagesize;
}
}