From: Sean Christopherson <seanjc@google.com>
To: Hou Wenlong <houwenlong.hwl@antgroup.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Lan Tianyu <Tianyu.Lan@microsoft.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] KVM: x86/mmu: Fix wrong gfn range of tlb flushing in kvm_set_pte_rmapp()
Date: Fri, 24 Jun 2022 22:53:25 +0000 [thread overview]
Message-ID: <YrZAZXHJTsUp8yuP@google.com> (raw)
In-Reply-To: <a92b4b56116f0f71ffceab2b4ff3c03f47fd468f.1656039275.git.houwenlong.hwl@antgroup.com>
On Fri, Jun 24, 2022, Hou Wenlong wrote:
> When the spte of hupe page is dropped in kvm_set_pte_rmapp(),
> the whole gfn range covered by the spte should be flushed.
> However, rmap_walk_init_level() doesn't align down the gfn
> for new level like tdp iterator does, then the gfn used in
> kvm_set_pte_rmapp() is not the base gfn of huge page. And
> the size of gfn range is wrong too for huge page. Since
> the base gfn of huge page is more meaningful during the
> rmap walking, so align down the gfn for new level and use
> the correct size of huge page for tlb flushing in
> kvm_set_pte_rmapp().
It's also worth noting that kvm_set_pte_rmapp() is the other user of the rmap
iterators that consumes @gfn, i.e. modifying iterator->gfn is safe-ish.
> Fixes: c3134ce240eed ("KVM: Replace old tlb flush function with new one to flush a specified range.")
> Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
> ---
> arch/x86/kvm/mmu/mmu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index b8a1f5b46b9d..37bfc88ea212 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -1427,7 +1427,7 @@ static bool kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
> }
>
> if (need_flush && kvm_available_flush_tlb_with_range()) {
> - kvm_flush_remote_tlbs_with_address(kvm, gfn, 1);
> + kvm_flush_remote_tlbs_with_address(kvm, gfn, KVM_PAGES_PER_HPAGE(level));
> return false;
> }
>
> @@ -1455,7 +1455,7 @@ static void
> rmap_walk_init_level(struct slot_rmap_walk_iterator *iterator, int level)
> {
> iterator->level = level;
> - iterator->gfn = iterator->start_gfn;
> + iterator->gfn = iterator->start_gfn & -KVM_PAGES_PER_HPAGE(level);
Hrm, arguably this be done on start_gfn in slot_rmap_walk_init(). Having iter->gfn
be less than iter->start_gfn will be odd.
> iterator->rmap = gfn_to_rmap(iterator->gfn, level, iterator->slot);
> iterator->end_rmap = gfn_to_rmap(iterator->end_gfn, level, iterator->slot);
> }
> --
> 2.31.1
>
next prev parent reply other threads:[~2022-06-24 22:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-24 3:36 [PATCH 0/5] Fix wrong gfn range of tlb flushing with range Hou Wenlong
2022-06-24 3:36 ` [PATCH 1/5] KVM: x86/mmu: Fix wrong gfn range of tlb flushing in validate_direct_spte() Hou Wenlong
2022-06-24 3:36 ` [PATCH 2/5] KVM: x86/mmu: Fix wrong gfn range of tlb flushing in kvm_set_pte_rmapp() Hou Wenlong
2022-06-24 22:53 ` Sean Christopherson [this message]
2022-06-27 4:00 ` Hou Wenlong
2022-06-24 3:36 ` [PATCH 3/5] KVM: x86/mmu: Reduce gfn range of tlb flushing in tdp_mmu_map_handle_target_level() Hou Wenlong
2022-06-24 3:37 ` [PATCH 4/5] KVM: x86/mmu: Fix wrong start gfn of tlb flushing with range Hou Wenlong
2022-06-24 3:37 ` [PATCH 5/5] KVM: x86/mmu: Use 1 as the size of gfn range for tlb flushing in FNAME(invlpg)() Hou Wenlong
2022-06-24 23:06 ` [PATCH 0/5] Fix wrong gfn range of tlb flushing with range Sean Christopherson
2022-06-25 9:13 ` Paolo Bonzini
2022-06-27 4:15 ` Hou Wenlong
2022-06-28 12:59 ` Paolo Bonzini
2022-07-26 22:59 ` David Matlack
2022-07-27 12:14 ` Hou Wenlong
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=YrZAZXHJTsUp8yuP@google.com \
--to=seanjc@google.com \
--cc=Tianyu.Lan@microsoft.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=houwenlong.hwl@antgroup.com \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.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.