qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Keqian Zhu <zhukeqian1@huawei.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	jiangkunkun@huawei.com, qemu-devel@nongnu.org,
	Peter Xu <peterx@redhat.com>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	qemu-arm@nongnu.org, wanghaibin.wang@huawei.com,
	Zenghui Yu <yuzenghui@huawei.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2 2/2] accel: kvm: Add aligment assert for kvm_log_clear_one_slot
Date: Thu, 17 Dec 2020 13:18:25 +0100	[thread overview]
Message-ID: <20201217121825.hkoyulksli62446y@kamzik.brq.redhat.com> (raw)
In-Reply-To: <20201217014941.22872-3-zhukeqian1@huawei.com>

On Thu, Dec 17, 2020 at 09:49:41AM +0800, Keqian Zhu wrote:
> The parameters start and size are transfered from QEMU memory
> emulation layer. It can promise that they are TARGET_PAGE_SIZE
> aligned. However, KVM needs they are qemu_real_page_size aligned.
> 
> Though no caller breaks this aligned requirement currently, we'd
> better add an explicit assert to avoid future breaking.
> 
> Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
> ---
>  accel/kvm/kvm-all.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> ---
> v2
>  - Address Andrew's commment (Use assert instead of return err).
> 
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index f6b16a8df8..73b195cc41 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -692,6 +692,10 @@ out:
>  #define KVM_CLEAR_LOG_ALIGN  (qemu_real_host_page_size << KVM_CLEAR_LOG_SHIFT)
>  #define KVM_CLEAR_LOG_MASK   (-KVM_CLEAR_LOG_ALIGN)
>  
> +/*
> + * As the granule of kvm dirty log is qemu_real_host_page_size,
> + * @start and @size are expected and restricted to align to it.
> + */
>  static int kvm_log_clear_one_slot(KVMSlot *mem, int as_id, uint64_t start,
>                                    uint64_t size)
>  {
> @@ -701,6 +705,9 @@ static int kvm_log_clear_one_slot(KVMSlot *mem, int as_id, uint64_t start,
>      unsigned long *bmap_clear = NULL, psize = qemu_real_host_page_size;
>      int ret;
>  
> +    /* Make sure start and size are qemu_real_host_page_size aligned */
> +    assert(QEMU_IS_ALIGNED(start | size, psize));
> +
>      /*
>       * We need to extend either the start or the size or both to
>       * satisfy the KVM interface requirement.  Firstly, do the start
> -- 
> 2.23.0
> 
>

Reviewed-by: Andrew Jones <drjones@redhat.com>



  reply	other threads:[~2020-12-17 12:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17  1:49 [PATCH v2 0/2] accel: kvm: Some bugfixes for kvm dirty log Keqian Zhu
2020-12-17  1:49 ` [PATCH v2 1/2] accel: kvm: Fix memory waste under mismatch page size Keqian Zhu
2020-12-17  1:49 ` [PATCH v2 2/2] accel: kvm: Add aligment assert for kvm_log_clear_one_slot Keqian Zhu
2020-12-17 12:18   ` Andrew Jones [this message]
2020-12-17 14:36   ` Peter Xu
2021-02-01 15:14   ` Philippe Mathieu-Daudé
2021-02-02  1:17     ` Keqian Zhu
2021-03-09 13:48   ` Thomas Huth
2021-03-09 14:05     ` Keqian Zhu
2021-03-09 14:45       ` Thomas Huth
2021-03-09 14:57         ` Dr. David Alan Gilbert
2021-03-09 16:08           ` Peter Xu
2021-03-10  1:57             ` Keqian Zhu
2021-03-09 16:20           ` Thomas Huth
2021-03-09 16:26             ` Peter Maydell
2021-03-09 19:03               ` Paolo Bonzini
2021-03-09 15:11         ` zhukeqian
2021-01-06  7:07 ` [PATCH v2 0/2] accel: kvm: Some bugfixes for kvm dirty log Keqian Zhu
2021-01-25  7:51 ` Keqian Zhu
2021-02-01 13:07   ` Keqian Zhu
2021-03-02 11:43 ` [PING] " Keqian Zhu
2021-03-02 13:14   ` 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=20201217121825.hkoyulksli62446y@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=jiangkunkun@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wanghaibin.wang@huawei.com \
    --cc=yuzenghui@huawei.com \
    --cc=zhukeqian1@huawei.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).