All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: <qemu-devel@nongnu.org>, <qemu-trivial@nongnu.org>
Cc: <peter.maydell@linaro.org>, <thuth@redhat.com>,
	<armbru@redhat.com>, <mst@redhat.com>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v4 1/2] util/mmap-alloc: check parameter before using
Date: Wed, 21 Dec 2016 14:35:19 +0800	[thread overview]
Message-ID: <585A22A7.6000203@cn.fujitsu.com> (raw)
In-Reply-To: <1478094287-15009-2-git-send-email-caoj.fnst@cn.fujitsu.com>

ping

On 11/02/2016 09:44 PM, Cao jin wrote:
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>  util/mmap-alloc.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
> index 5a85aa3..d713a72 100644
> --- a/util/mmap-alloc.c
> +++ b/util/mmap-alloc.c
> @@ -12,6 +12,7 @@
>  
>  #include "qemu/osdep.h"
>  #include "qemu/mmap-alloc.h"
> +#include "qemu/host-utils.h"
>  
>  #define HUGETLBFS_MAGIC       0x958458f6
>  
> @@ -61,18 +62,18 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared)
>  #else
>      void *ptr = mmap(0, total, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
>  #endif
> -    size_t offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr;
> +    size_t offset;
>      void *ptr1;
>  
>      if (ptr == MAP_FAILED) {
>          return MAP_FAILED;
>      }
>  
> -    /* Make sure align is a power of 2 */
> -    assert(!(align & (align - 1)));
> +    assert(is_power_of_2(align));
>      /* Always align to host page size */
>      assert(align >= getpagesize());
>  
> +    offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr;
>      ptr1 = mmap(ptr + offset, size, PROT_READ | PROT_WRITE,
>                  MAP_FIXED |
>                  (fd == -1 ? MAP_ANONYMOUS : 0) |
> 

-- 
Sincerely,
Cao jin




WARNING: multiple messages have this Message-ID (diff)
From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Cc: peter.maydell@linaro.org, thuth@redhat.com, armbru@redhat.com,
	mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH v4 1/2] util/mmap-alloc: check parameter before using
Date: Wed, 21 Dec 2016 14:35:19 +0800	[thread overview]
Message-ID: <585A22A7.6000203@cn.fujitsu.com> (raw)
In-Reply-To: <1478094287-15009-2-git-send-email-caoj.fnst@cn.fujitsu.com>

ping

On 11/02/2016 09:44 PM, Cao jin wrote:
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>  util/mmap-alloc.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
> index 5a85aa3..d713a72 100644
> --- a/util/mmap-alloc.c
> +++ b/util/mmap-alloc.c
> @@ -12,6 +12,7 @@
>  
>  #include "qemu/osdep.h"
>  #include "qemu/mmap-alloc.h"
> +#include "qemu/host-utils.h"
>  
>  #define HUGETLBFS_MAGIC       0x958458f6
>  
> @@ -61,18 +62,18 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared)
>  #else
>      void *ptr = mmap(0, total, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
>  #endif
> -    size_t offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr;
> +    size_t offset;
>      void *ptr1;
>  
>      if (ptr == MAP_FAILED) {
>          return MAP_FAILED;
>      }
>  
> -    /* Make sure align is a power of 2 */
> -    assert(!(align & (align - 1)));
> +    assert(is_power_of_2(align));
>      /* Always align to host page size */
>      assert(align >= getpagesize());
>  
> +    offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr;
>      ptr1 = mmap(ptr + offset, size, PROT_READ | PROT_WRITE,
>                  MAP_FIXED |
>                  (fd == -1 ? MAP_ANONYMOUS : 0) |
> 

-- 
Sincerely,
Cao jin

  parent reply	other threads:[~2016-12-21  6:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02 13:44 [Qemu-trivial] [PATCH v4 0/2] trivial changes on util/mmap-alloc Cao jin
2016-11-02 13:44 ` [Qemu-devel] " Cao jin
2016-11-02 13:44 ` [Qemu-trivial] [PATCH v4 1/2] util/mmap-alloc: check parameter before using Cao jin
2016-11-02 13:44   ` [Qemu-devel] " Cao jin
2016-11-02 20:41   ` [Qemu-trivial] " Thomas Huth
2016-11-02 20:41     ` [Qemu-devel] " Thomas Huth
2016-12-21  6:35   ` Cao jin [this message]
2016-12-21  6:35     ` Cao jin
2016-11-02 13:44 ` [Qemu-trivial] [PATCH v4 2/2] util/mmap-alloc: refactor a little bit for readability Cao jin
2016-11-02 13:44   ` [Qemu-devel] " Cao jin
2017-01-12 11:12 ` [Qemu-trivial] [PATCH v4 0/2] trivial changes on util/mmap-alloc Michael Tokarev
2017-01-12 11:12   ` [Qemu-devel] " Michael Tokarev

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=585A22A7.6000203@cn.fujitsu.com \
    --to=caoj.fnst@cn.fujitsu.com \
    --cc=armbru@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.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 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.