qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Xinyu Li <precinct@mail.ustc.edu.cn>, qemu-devel@nongnu.org
Cc: riku.voipio@iki.fi
Subject: Re: [PATCH] linux-user:Fix align mistake when mmap guest space
Date: Thu, 19 Dec 2019 10:24:59 +0100	[thread overview]
Message-ID: <698f1386-b706-16ff-60b2-779247f68ba5@vivier.eu> (raw)
In-Reply-To: <20191213022919.5934-1-precinct@mail.ustc.edu.cn>

Le 13/12/2019 à 03:29, Xinyu Li a écrit :
> In init_guest_space, we need to mmap guest space. If the return address
> of first mmap is not aligned with align, which was set to MAX(SHMLBA,
> qemu_host_page_size), we need unmap and a new mmap(space is larger than
> first size). The new size is named real_size, which is aligned_size +
> qemu_host_page_size. alugned_size is the guest space size. And add a
> qemu_host_page_size to avoid memory error when we align real_start
> manually (ROUND_UP(real_start, align)). But when SHMLBA >
> qemu_host_page_size, the added size will smaller than the size to align,
> which can make a mistake(in a mips machine, it appears). So change
> real_size from aligned_size +qemu_host_page_size
> to aligned_size + align will solve it.
> 
> Signed-off-by: Xinyu Li <precinct@mail.ustc.edu.cn>
> ---
>  linux-user/elfload.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index f6693e5760..312ded0779 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -2189,7 +2189,7 @@ unsigned long init_guest_space(unsigned long host_start,
>               * to where we need to put the commpage.
>               */
>              munmap((void *)real_start, host_size);
> -            real_size = aligned_size + qemu_host_page_size;
> +            real_size = aligned_size + align;
>              real_start = (unsigned long)
>                  mmap((void *)real_start, real_size, PROT_NONE, flags, -1, 0);
>              if (real_start == (unsigned long)-1) {
> 

Applied to my linux-user branch.

Thanks,
Laurent



      parent reply	other threads:[~2019-12-19  9:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13  2:29 [PATCH] linux-user:Fix align mistake when mmap guest space Xinyu Li
2019-12-13  9:00 ` Laurent Vivier
2019-12-19  0:04   ` Richard Henderson
2019-12-19  9:24 ` Laurent Vivier [this message]

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=698f1386-b706-16ff-60b2-779247f68ba5@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=precinct@mail.ustc.edu.cn \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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).