public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] lib/alloc_page: Zero allocated pages
@ 2019-05-02 15:40 nadav.amit
  2019-05-03  8:19 ` Andrew Jones
  0 siblings, 1 reply; 3+ messages in thread
From: nadav.amit @ 2019-05-02 15:40 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Nadav Amit

From: Nadav Amit <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, which apparently is the case after seabios runs.
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.

Do not assume that memory is zeroed. Clear it once it is allocated to
allow tests to easily be reproducible.

Signed-off-by: Nadav Amit <nadav.amit@gmail.com>
---
 lib/alloc_page.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/alloc_page.c b/lib/alloc_page.c
index 730f2b5..b0f4515 100644
--- a/lib/alloc_page.c
+++ b/lib/alloc_page.c
@@ -65,6 +65,7 @@ void *alloc_page()
 	freelist = *(void **)freelist;
 	spin_unlock(&lock);
 
+	memset(p, 0, PAGE_SIZE);
 	return p;
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-03 17:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-02 15:40 [kvm-unit-tests PATCH] lib/alloc_page: Zero allocated pages nadav.amit
2019-05-03  8:19 ` Andrew Jones
2019-05-03 17:16   ` Nadav Amit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox