qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Richard Henderson <richard.henderson@linaro.org>,
	David Hildenbrand <david@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	qemu-s390x@nongnu.org, qemu-devel@nongnu.org,
	Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH 3/3] tests/tcg/s390x: Test BRASL and BRCL with large negative offsets
Date: Fri, 11 Mar 2022 19:49:11 +0100	[thread overview]
Message-ID: <20220311184911.557245-4-iii@linux.ibm.com> (raw)
In-Reply-To: <20220311184911.557245-1-iii@linux.ibm.com>

Add a small test in order to prevent regressions.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tests/tcg/s390x/Makefile.target        |  1 +
 tests/tcg/s390x/branch-relative-long.c | 29 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 tests/tcg/s390x/branch-relative-long.c

diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 257c568c58..fd34b130f7 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -15,6 +15,7 @@ TESTS+=mvc
 TESTS+=shift
 TESTS+=trap
 TESTS+=signals-s390x
+TESTS+=branch-relative-long
 
 ifneq ($(HAVE_GDB_BIN),)
 GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py
diff --git a/tests/tcg/s390x/branch-relative-long.c b/tests/tcg/s390x/branch-relative-long.c
new file mode 100644
index 0000000000..b9fcee9873
--- /dev/null
+++ b/tests/tcg/s390x/branch-relative-long.c
@@ -0,0 +1,29 @@
+#include <assert.h>
+#include <stddef.h>
+#include <sys/mman.h>
+
+int main(void)
+{
+    const unsigned short opcodes[] = {
+        0xc005,  /* brasl %r0 */
+        0xc0f4,  /* brcl 0xf */
+    };
+    size_t length = 0x100000006;
+    unsigned char *buf;
+    int i;
+
+    buf = mmap(NULL, length, PROT_READ | PROT_WRITE | PROT_EXEC,
+               MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+    assert(buf != MAP_FAILED);
+
+    *(unsigned short *)&buf[0] = 0x07fe;  /* br %r14 */
+    *(unsigned int *)&buf[0x100000002] = 0x80000000;
+    for (i = 0; i < sizeof(opcodes) / sizeof(opcodes[0]); i++) {
+        *(unsigned short *)&buf[0x100000000] = opcodes[i];
+        ((void (*)(void))&buf[0x100000000])();
+    }
+
+    munmap(buf, length);
+
+    return 0;
+}
-- 
2.35.1



  parent reply	other threads:[~2022-03-11 18:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11 18:49 [PATCH 0/3] Fix BRASL and BRCL with large negative offsets Ilya Leoshkevich
2022-03-11 18:49 ` [PATCH 1/3] s390x/tcg: Fix BRASL with a large negative offset Ilya Leoshkevich
2022-03-11 18:55   ` David Hildenbrand
2022-03-11 18:49 ` [PATCH 2/3] s390x/tcg: Fix BRCL " Ilya Leoshkevich
2022-03-11 18:55   ` David Hildenbrand
2022-03-11 18:49 ` Ilya Leoshkevich [this message]
2022-03-11 18:57   ` [PATCH 3/3] tests/tcg/s390x: Test BRASL and BRCL with large negative offsets David Hildenbrand
2022-03-11 19:01     ` Ilya Leoshkevich
2022-03-11 20:32   ` Richard Henderson
2022-03-14  8:30     ` Christian Borntraeger
2022-03-14 10:17       ` David Hildenbrand
2022-03-14 17:59       ` Richard Henderson

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=20220311184911.557245-4-iii@linux.ibm.com \
    --to=iii@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).