From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 4/4] mmapstress03: Fix 32bit test on 64bit kernel
Date: Thu, 12 Jan 2017 09:41:28 -0500 (EST) [thread overview]
Message-ID: <1342382447.1910370.1484232088575.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1484227419-16955-4-git-send-email-chrubis@suse.cz>
----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: ltp@lists.linux.it
> Sent: Thursday, 12 January, 2017 2:23:39 PM
> Subject: [LTP] [PATCH 4/4] mmapstress03: Fix 32bit test on 64bit kernel
>
> The ridiculously large mapping size has to be adjusted based on the
> kernel addressing size not on a pointer size otherwise the testcase
> segfaults when 32bit binary is executed on 64bit kernel.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
> testcases/kernel/mem/mmapstress/mmapstress03.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/testcases/kernel/mem/mmapstress/mmapstress03.c
> b/testcases/kernel/mem/mmapstress/mmapstress03.c
> index 76a77a9..fe25b7a 100644
> --- a/testcases/kernel/mem/mmapstress/mmapstress03.c
> +++ b/testcases/kernel/mem/mmapstress/mmapstress03.c
> @@ -45,6 +45,7 @@
> #include <stdlib.h>
>
> #include "test.h"
> +#include "tst_kernel.h"
>
> char *TCID = "mmapstress03";
> FILE *temp;
> @@ -61,7 +62,6 @@ void ok_exit();
> #define ERROR(M) (void)fprintf(stderr, "%s: errno = %d: " M "\n", TCID, \
> errno)
> #define NEG1 (char *)-1
> -#define POINTER_SIZE (sizeof(void *) << 3)
>
> static void do_test(void* brk_max, long pagesize);
>
> @@ -69,6 +69,7 @@ int main(void)
> {
> char *brk_max_addr, *hole_addr, *brk_start, *hole_start;
> size_t pagesize = (size_t) sysconf(_SC_PAGE_SIZE);
> + int kernel_bits = tst_kernel_bits();
>
> if ((brk_start = sbrk(0)) == NEG1) {
> ERROR("initial sbrk failed");
> @@ -137,9 +138,10 @@ int main(void)
> ERROR("failed to fiddle with brk at the end");
> anyfail();
> }
> +
> /* Ask for a ridiculously large mmap region at a high address */
> - if (mmap((void*) (1UL << (POINTER_SIZE - 1)) - pagesize,
> - (size_t) ((1UL << (POINTER_SIZE - 1)) - pagesize),
> + if (mmap((void*) (1UL << (kernel_bits - 1)) - pagesize,
Since this has same range as below, shouldn't it be also 1ULL?
Entire series looks OK to me.
Regards,
Jan
> + (size_t) ((1ULL << (kernel_bits - 1)) - pagesize),
> PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_FIXED | MAP_SHARED,
> 0, 0)
> != (void*) - 1) {
> --
> 2.7.3
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
next prev parent reply other threads:[~2017-01-12 14:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-12 13:23 [LTP] [PATCH 1/4] lib: Add tst_kernel_bits() Cyril Hrubis
2017-01-12 13:23 ` [LTP] [PATCH 2/4] vma03: Disable the test on 64bit kernel as well Cyril Hrubis
2017-01-12 13:23 ` [LTP] [PATCH 3/4] mmapstress03: Small cleanup Cyril Hrubis
2017-01-12 13:23 ` [LTP] [PATCH 4/4] mmapstress03: Fix 32bit test on 64bit kernel Cyril Hrubis
2017-01-12 14:41 ` Jan Stancek [this message]
2017-01-12 15:05 ` Cyril Hrubis
2017-01-12 16:41 ` Jan Stancek
2017-01-12 17:00 ` Cyril Hrubis
2017-01-12 17:00 ` Jan Stancek
2017-01-12 14:40 ` [LTP] [PATCH 1/4] lib: Add tst_kernel_bits() Jan Stancek
2017-01-12 14:45 ` Cyril Hrubis
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=1342382447.1910370.1484232088575.JavaMail.zimbra@redhat.com \
--to=jstancek@redhat.com \
--cc=ltp@lists.linux.it \
/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