From: Nadav Amit <nadav.amit@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Krish Sadhukhan <krish.sadhukhan@oracle.com>,
Andrew Jones <drjones@redhat.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Nadav Amit <nadav.amit@gmail.com>
Subject: [kvm-unit-tests PATCH v3 1/4] lib/alloc_page: Zero allocated pages
Date: Thu, 9 May 2019 13:05:55 -0700 [thread overview]
Message-ID: <20190509200558.12347-2-nadav.amit@gmail.com> (raw)
In-Reply-To: <20190509200558.12347-1-nadav.amit@gmail.com>
One of the most important properties of tests is reproducibility. For
tests to be reproducible, the same environment should be set on each
test invocation.
When it comes to memory content, this is not exactly the case in
kvm-unit-tests. The tests might, mistakenly or intentionally, assume
that memory is zeroed (by the BIOS or KVM). However, failures might not
be reproducible if this assumption is broken.
As an example, consider x86 do_iret(), which mistakenly does not push
SS:RSP onto the stack on 64-bit mode, although they are popped
unconditionally on iret.
Do not assume that memory is zeroed. Clear it once it is allocated to
allow tests to easily be reproduced.
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: Nadav Amit <nadav.amit@gmail.com>
---
lib/alloc_page.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/alloc_page.c b/lib/alloc_page.c
index 730f2b5..97d1339 100644
--- a/lib/alloc_page.c
+++ b/lib/alloc_page.c
@@ -65,6 +65,8 @@ void *alloc_page()
freelist = *(void **)freelist;
spin_unlock(&lock);
+ if (p)
+ memset(p, 0, PAGE_SIZE);
return p;
}
@@ -126,6 +128,8 @@ void *alloc_pages(unsigned long order)
}
}
spin_unlock(&lock);
+ if (run_start)
+ memset(run_start, 0, n * PAGE_SIZE);
return run_start;
}
--
2.17.1
next prev parent reply other threads:[~2019-05-10 3:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-09 20:05 [kvm-unit-tests PATCH v3 0/4] Zero allocated pages Nadav Amit
2019-05-09 20:05 ` Nadav Amit [this message]
2019-05-15 9:18 ` [kvm-unit-tests PATCH v3 1/4] lib/alloc_page: " Andrew Jones
2019-05-09 20:05 ` [kvm-unit-tests PATCH v3 2/4] x86: Remove redundant page zeroing Nadav Amit
2019-05-09 20:05 ` [kvm-unit-tests PATCH v3 3/4] lib: " Nadav Amit
2019-05-15 9:19 ` Andrew Jones
2019-05-09 20:05 ` [kvm-unit-tests PATCH v3 4/4] arm: " Nadav Amit
2019-05-15 9:27 ` Andrew Jones
2019-05-10 12:55 ` [kvm-unit-tests PATCH v3 0/4] Zero allocated pages Konrad Rzeszutek Wilk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190509200558.12347-2-nadav.amit@gmail.com \
--to=nadav.amit@gmail.com \
--cc=alexandru.elisei@arm.com \
--cc=drjones@redhat.com \
--cc=krish.sadhukhan@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox