All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Gavin Shan <gshan@redhat.com>
Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] KVM: arm/arm64: Fix young bit from mmu notifier
Date: Tue, 21 Jan 2020 13:28:19 +0000	[thread overview]
Message-ID: <55ae5a0f91f2e675a4e71d83bef9d911@kernel.org> (raw)
In-Reply-To: <20200121055659.19560-1-gshan@redhat.com>

On 2020-01-21 05:56, Gavin Shan wrote:
> kvm_test_age_hva() is called upon mmu_notifier_test_young(), but wrong
> address range has been passed to handle_hva_to_gpa(). With the wrong
> address range, no young bits will be checked in handle_hva_to_gpa().
> It means zero is always returned from mmu_notifier_test_young().
> 
> This fixes the issue by passing correct address range to the underly
> function handle_hva_to_gpa(), so that the hardware young (access) bit
> will be visited.
> 
> Cc: stable@vger.kernel.org # v4.1+
> Fixes: 35307b9a5f7e ("arm/arm64: KVM: Implement Stage-2 page aging")
> Signed-off-by: Gavin Shan <gshan@redhat.com>
> ---
>  virt/kvm/arm/mmu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
> index 0b32a904a1bb..a2777efb558e 100644
> --- a/virt/kvm/arm/mmu.c
> +++ b/virt/kvm/arm/mmu.c
> @@ -2147,7 +2147,8 @@ int kvm_test_age_hva(struct kvm *kvm, unsigned 
> long hva)
>  	if (!kvm->arch.pgd)
>  		return 0;
>  	trace_kvm_test_age_hva(hva);
> -	return handle_hva_to_gpa(kvm, hva, hva, kvm_test_age_hva_handler, 
> NULL);
> +	return handle_hva_to_gpa(kvm, hva, hva + PAGE_SIZE,
> +				 kvm_test_age_hva_handler, NULL);
>  }
> 
>  void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu)

I knew this start/end thing (instead of start/size) would bite us
one of these days. Terribly embarrassing. On the other hand, who
really wants to swap things out? ;-)

Out of curiosity, how did you find this one?

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Gavin Shan <gshan@redhat.com>
Cc: eric.auger@redhat.com, drjones@redhat.com,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] KVM: arm/arm64: Fix young bit from mmu notifier
Date: Tue, 21 Jan 2020 13:28:19 +0000	[thread overview]
Message-ID: <55ae5a0f91f2e675a4e71d83bef9d911@kernel.org> (raw)
In-Reply-To: <20200121055659.19560-1-gshan@redhat.com>

On 2020-01-21 05:56, Gavin Shan wrote:
> kvm_test_age_hva() is called upon mmu_notifier_test_young(), but wrong
> address range has been passed to handle_hva_to_gpa(). With the wrong
> address range, no young bits will be checked in handle_hva_to_gpa().
> It means zero is always returned from mmu_notifier_test_young().
> 
> This fixes the issue by passing correct address range to the underly
> function handle_hva_to_gpa(), so that the hardware young (access) bit
> will be visited.
> 
> Cc: stable@vger.kernel.org # v4.1+
> Fixes: 35307b9a5f7e ("arm/arm64: KVM: Implement Stage-2 page aging")
> Signed-off-by: Gavin Shan <gshan@redhat.com>
> ---
>  virt/kvm/arm/mmu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
> index 0b32a904a1bb..a2777efb558e 100644
> --- a/virt/kvm/arm/mmu.c
> +++ b/virt/kvm/arm/mmu.c
> @@ -2147,7 +2147,8 @@ int kvm_test_age_hva(struct kvm *kvm, unsigned 
> long hva)
>  	if (!kvm->arch.pgd)
>  		return 0;
>  	trace_kvm_test_age_hva(hva);
> -	return handle_hva_to_gpa(kvm, hva, hva, kvm_test_age_hva_handler, 
> NULL);
> +	return handle_hva_to_gpa(kvm, hva, hva + PAGE_SIZE,
> +				 kvm_test_age_hva_handler, NULL);
>  }
> 
>  void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu)

I knew this start/end thing (instead of start/size) would bite us
one of these days. Terribly embarrassing. On the other hand, who
really wants to swap things out? ;-)

Out of curiosity, how did you find this one?

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-01-21 13:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-21  5:56 [PATCH] KVM: arm/arm64: Fix young bit from mmu notifier Gavin Shan
2020-01-21  5:56 ` Gavin Shan
2020-01-21 13:28 ` Marc Zyngier [this message]
2020-01-21 13:28   ` Marc Zyngier
2020-01-21 23:07   ` Gavin Shan
2020-01-21 23:07     ` Gavin Shan

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=55ae5a0f91f2e675a4e71d83bef9d911@kernel.org \
    --to=maz@kernel.org \
    --cc=gshan@redhat.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.