* [PATCH] KVM: MMU: protect TDP MMU pages only down to required level
@ 2021-04-02 12:17 Paolo Bonzini
2021-04-06 6:26 ` Keqian Zhu
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2021-04-02 12:17 UTC (permalink / raw)
To: linux-kernel, kvm; +Cc: Ben Gardon
When using manual protection of dirty pages, it is not necessary
to protect nested page tables down to the 4K level; instead KVM
can protect only hugepages in order to split them lazily, and
delay write protection at 4K-granularity until KVM_CLEAR_DIRTY_LOG.
This was overlooked in the TDP MMU, so do it there as well.
Fixes: a6a0b05da9f37 ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
Cc: Ben Gardon <bgardon@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
arch/x86/kvm/mmu/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index efb41f31e80a..0d92a269c5fa 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -5538,7 +5538,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm,
flush = slot_handle_level(kvm, memslot, slot_rmap_write_protect,
start_level, KVM_MAX_HUGEPAGE_LEVEL, false);
if (is_tdp_mmu_enabled(kvm))
- flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, PG_LEVEL_4K);
+ flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, start_level);
write_unlock(&kvm->mmu_lock);
/*
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: MMU: protect TDP MMU pages only down to required level
2021-04-02 12:17 [PATCH] KVM: MMU: protect TDP MMU pages only down to required level Paolo Bonzini
@ 2021-04-06 6:26 ` Keqian Zhu
2021-04-06 23:38 ` Sean Christopherson
0 siblings, 1 reply; 4+ messages in thread
From: Keqian Zhu @ 2021-04-06 6:26 UTC (permalink / raw)
To: Paolo Bonzini, linux-kernel, kvm; +Cc: Ben Gardon
Hi Paolo,
I'm just going to fix this issue, and found that you have done this ;-)
Please feel free to add:
Reviewed-by: Keqian Zhu <zhukeqian1@huawei.com>
Thanks,
Keqian
On 2021/4/2 20:17, Paolo Bonzini wrote:
> When using manual protection of dirty pages, it is not necessary
> to protect nested page tables down to the 4K level; instead KVM
> can protect only hugepages in order to split them lazily, and
> delay write protection at 4K-granularity until KVM_CLEAR_DIRTY_LOG.
> This was overlooked in the TDP MMU, so do it there as well.
>
> Fixes: a6a0b05da9f37 ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
> Cc: Ben Gardon <bgardon@google.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> arch/x86/kvm/mmu/mmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index efb41f31e80a..0d92a269c5fa 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -5538,7 +5538,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm,
> flush = slot_handle_level(kvm, memslot, slot_rmap_write_protect,
> start_level, KVM_MAX_HUGEPAGE_LEVEL, false);
> if (is_tdp_mmu_enabled(kvm))
> - flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, PG_LEVEL_4K);
> + flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, start_level);
> write_unlock(&kvm->mmu_lock);
>
> /*
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: MMU: protect TDP MMU pages only down to required level
2021-04-06 6:26 ` Keqian Zhu
@ 2021-04-06 23:38 ` Sean Christopherson
2021-04-07 1:31 ` Keqian Zhu
0 siblings, 1 reply; 4+ messages in thread
From: Sean Christopherson @ 2021-04-06 23:38 UTC (permalink / raw)
To: Keqian Zhu; +Cc: Paolo Bonzini, linux-kernel, kvm, Ben Gardon
On Tue, Apr 06, 2021, Keqian Zhu wrote:
> Hi Paolo,
>
> I'm just going to fix this issue, and found that you have done this ;-)
Ha, and meanwhile I'm having a serious case of deja vu[1]. It even received a
variant of the magic "Queued, thanks"[2]. Doesn't appear in either of the 5.12
pull requests though, must have gotten lost along the way.
[1] https://lkml.kernel.org/r/20210213005015.1651772-3-seanjc@google.com
[2] https://lkml.kernel.org/r/b5ab72f2-970f-64bd-891c-48f1c303548d@redhat.com
> Please feel free to add:
>
> Reviewed-by: Keqian Zhu <zhukeqian1@huawei.com>
>
> Thanks,
> Keqian
>
> On 2021/4/2 20:17, Paolo Bonzini wrote:
> > When using manual protection of dirty pages, it is not necessary
> > to protect nested page tables down to the 4K level; instead KVM
> > can protect only hugepages in order to split them lazily, and
> > delay write protection at 4K-granularity until KVM_CLEAR_DIRTY_LOG.
> > This was overlooked in the TDP MMU, so do it there as well.
> >
> > Fixes: a6a0b05da9f37 ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
> > Cc: Ben Gardon <bgardon@google.com>
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> > arch/x86/kvm/mmu/mmu.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> > index efb41f31e80a..0d92a269c5fa 100644
> > --- a/arch/x86/kvm/mmu/mmu.c
> > +++ b/arch/x86/kvm/mmu/mmu.c
> > @@ -5538,7 +5538,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm,
> > flush = slot_handle_level(kvm, memslot, slot_rmap_write_protect,
> > start_level, KVM_MAX_HUGEPAGE_LEVEL, false);
> > if (is_tdp_mmu_enabled(kvm))
> > - flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, PG_LEVEL_4K);
> > + flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, start_level);
> > write_unlock(&kvm->mmu_lock);
> >
> > /*
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] KVM: MMU: protect TDP MMU pages only down to required level
2021-04-06 23:38 ` Sean Christopherson
@ 2021-04-07 1:31 ` Keqian Zhu
0 siblings, 0 replies; 4+ messages in thread
From: Keqian Zhu @ 2021-04-07 1:31 UTC (permalink / raw)
To: Sean Christopherson; +Cc: Paolo Bonzini, linux-kernel, kvm, Ben Gardon
On 2021/4/7 7:38, Sean Christopherson wrote:
> On Tue, Apr 06, 2021, Keqian Zhu wrote:
>> Hi Paolo,
>>
>> I'm just going to fix this issue, and found that you have done this ;-)
>
> Ha, and meanwhile I'm having a serious case of deja vu[1]. It even received a
> variant of the magic "Queued, thanks"[2]. Doesn't appear in either of the 5.12
> pull requests though, must have gotten lost along the way.
Good job. We should pick them up :)
>
> [1] https://lkml.kernel.org/r/20210213005015.1651772-3-seanjc@google.com
> [2] https://lkml.kernel.org/r/b5ab72f2-970f-64bd-891c-48f1c303548d@redhat.com
>
>> Please feel free to add:
>>
>> Reviewed-by: Keqian Zhu <zhukeqian1@huawei.com>
>>
>> Thanks,
>> Keqian
>>
>> On 2021/4/2 20:17, Paolo Bonzini wrote:
>>> When using manual protection of dirty pages, it is not necessary
>>> to protect nested page tables down to the 4K level; instead KVM
>>> can protect only hugepages in order to split them lazily, and
>>> delay write protection at 4K-granularity until KVM_CLEAR_DIRTY_LOG.
>>> This was overlooked in the TDP MMU, so do it there as well.
>>>
>>> Fixes: a6a0b05da9f37 ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
>>> Cc: Ben Gardon <bgardon@google.com>
>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>> ---
>>> arch/x86/kvm/mmu/mmu.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
>>> index efb41f31e80a..0d92a269c5fa 100644
>>> --- a/arch/x86/kvm/mmu/mmu.c
>>> +++ b/arch/x86/kvm/mmu/mmu.c
>>> @@ -5538,7 +5538,7 @@ void kvm_mmu_slot_remove_write_access(struct kvm *kvm,
>>> flush = slot_handle_level(kvm, memslot, slot_rmap_write_protect,
>>> start_level, KVM_MAX_HUGEPAGE_LEVEL, false);
>>> if (is_tdp_mmu_enabled(kvm))
>>> - flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, PG_LEVEL_4K);
>>> + flush |= kvm_tdp_mmu_wrprot_slot(kvm, memslot, start_level);
>>> write_unlock(&kvm->mmu_lock);
>>>
>>> /*
>>>
> .
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-07 1:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-02 12:17 [PATCH] KVM: MMU: protect TDP MMU pages only down to required level Paolo Bonzini
2021-04-06 6:26 ` Keqian Zhu
2021-04-06 23:38 ` Sean Christopherson
2021-04-07 1:31 ` Keqian Zhu
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).