All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"David Hildenbrand" <david@redhat.com>
Subject: [PATCH kvm-unit-tests v3 10/11] s390x: add test for (v)malloc
Date: Tue, 13 Feb 2018 17:23:20 +0100	[thread overview]
Message-ID: <20180213162321.20522-11-david@redhat.com> (raw)
In-Reply-To: <20180213162321.20522-1-david@redhat.com>

Let's test if basic allocation works and we get virtual addresses.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 s390x/selftest.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/s390x/selftest.c b/s390x/selftest.c
index 905713f..18a40e1 100644
--- a/s390x/selftest.c
+++ b/s390x/selftest.c
@@ -10,7 +10,10 @@
  */
 #include <libcflat.h>
 #include <util.h>
+#include <alloc.h>
 #include <asm/interrupt.h>
+#include <asm/barrier.h>
+#include <asm/pgtable.h>
 
 static void test_fp(void)
 {
@@ -37,6 +40,31 @@ static void test_pgm_int(void)
 	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
 }
 
+static void test_malloc(void)
+{
+	int *tmp = malloc(sizeof(int));
+	int *tmp2 = malloc(sizeof(int));
+
+	*tmp = 123456789;
+	*tmp2 = 123456789;
+	mb();
+
+	report("malloc: got vaddr", (uintptr_t)tmp & 0xf000000000000000ul);
+	report("malloc: access works", *tmp == 123456789);
+	report("malloc: got 2nd vaddr", (uintptr_t)tmp2 & 0xf000000000000000ul);
+	report("malloc: access works", (*tmp2 == 123456789));
+	report("malloc: addresses differ", tmp != tmp2);
+
+	expect_pgm_int();
+	configure_dat(0);
+	*tmp = 987654321;
+	configure_dat(1);
+	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
+
+	free(tmp);
+	free(tmp2);
+}
+
 int main(int argc, char**argv)
 {
 	report_prefix_push("selftest");
@@ -49,6 +77,7 @@ int main(int argc, char**argv)
 
 	test_fp();
 	test_pgm_int();
+	test_malloc();
 
 	return report_summary();
 }
-- 
2.14.3

  parent reply	other threads:[~2018-02-13 16:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-13 16:23 [PATCH kvm-unit-tests v3 00/11] s390x: vmalloc support David Hildenbrand
2018-02-13 16:23 ` [PATCH kvm-unit-tests v3 01/11] s390x: fix TEST BLOCK tests David Hildenbrand
2018-02-13 16:23 ` [PATCH kvm-unit-tests v3 02/11] s390x: use highest addresses for PGM_ADDRESSING errors David Hildenbrand
2018-02-13 16:23 ` [PATCH kvm-unit-tests v3 03/11] s390x: set initital stack pointer to stackptr, not stacktop David Hildenbrand
2018-02-13 16:23 ` [PATCH kvm-unit-tests v3 04/11] s390x: add missing sclp definitions from QEMU David Hildenbrand
2018-02-13 16:23 ` [PATCH kvm-unit-tests v3 05/11] s390x: rename sclp_setup() to sclp_ascii_setup() David Hildenbrand
2018-02-13 16:23 ` [PATCH kvm-unit-tests v3 06/11] s390x: detect installed memory David Hildenbrand
2018-02-13 16:23 ` [PATCH kvm-unit-tests v3 07/11] s390x: initialize the physical allocator David Hildenbrand
2018-02-14 12:05   ` Thomas Huth
2018-02-14 12:22     ` David Hildenbrand
2018-02-13 16:23 ` [PATCH kvm-unit-tests v3 08/11] s390x: add vmalloc support David Hildenbrand
2018-02-13 16:23 ` [PATCH kvm-unit-tests v3 09/11] s390x: enable DAT in PGM interrupt handler David Hildenbrand
2018-02-13 16:23 ` David Hildenbrand [this message]
2018-02-13 16:23 ` [PATCH kvm-unit-tests v3 11/11] s390x: add sieve test David Hildenbrand
2018-02-13 16:26   ` Christian Borntraeger
2018-02-13 16:44     ` Paolo Bonzini
2018-02-13 17:02       ` David Hildenbrand
2018-02-13 17:08         ` David Hildenbrand
2018-02-14 11:51           ` Paolo Bonzini
2018-02-14 12:56             ` David Hildenbrand
2018-02-14 13:15               ` David Hildenbrand
2018-02-13 17:09     ` David Hildenbrand
2018-02-14 11:52 ` [PATCH kvm-unit-tests v3 00/11] s390x: vmalloc support Paolo Bonzini

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=20180213162321.20522-11-david@redhat.com \
    --to=david@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=thuth@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.