public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Kunkun Jiang <jiangkunkun@huawei.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: wanghaibin.wang@huawei.com, Keqian Zhu <zhukeqian1@huawei.com>
Subject: Re: [PATCH] kvm: Fixes lack of KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 enabled check
Date: Tue, 12 Jan 2021 11:20:56 +0100	[thread overview]
Message-ID: <9dd32bc9-a35c-e43f-51f2-c0989cca4e66@redhat.com> (raw)
In-Reply-To: <20210112092942.2310-1-jiangkunkun@huawei.com>

On 12/01/21 10:29, Kunkun Jiang wrote:
> The KVM_CLEAR_DIRTY_LOG ioctl lacks the check whether the capability
> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT is enabled or not. This may cause
> some problems if userspace calls the KVM_CLEAR_DIRTY_LOG ioctl, but
> dose't enable this capability. So we'd better to add it.
> 
> Fixes: 2a31b9db15353 ("kvm: introduce manual dirty log reprotect")
> Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
> ---
>   virt/kvm/kvm_main.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index fa9e3614d30e..8f5633d8a0e8 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1602,6 +1602,9 @@ static int kvm_clear_dirty_log_protect(struct kvm *kvm,
>   	unsigned long *dirty_bitmap_buffer;
>   	bool flush;
>   
> +	if (!kvm->manual_dirty_log_protect)
> +		return -EPERM;
> +
>   	/* Dirty ring tracking is exclusive to dirty log tracking */
>   	if (kvm->dirty_ring_size)
>   		return -ENXIO;

This is not a problem, KVM_CLEAR_DIRTY_LOG can always be used even if 
KVM_CAP_MANUAL_DIRTY_LOG_PROTECT was not enabled.  The meaning is the 
same: clear the bits without returning them.

Paolo


      reply	other threads:[~2021-01-12 10:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12  9:29 [PATCH] kvm: Fixes lack of KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 enabled check Kunkun Jiang
2021-01-12 10:20 ` Paolo Bonzini [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=9dd32bc9-a35c-e43f-51f2-c0989cca4e66@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jiangkunkun@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wanghaibin.wang@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