From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 728F8C43460 for ; Wed, 7 Apr 2021 01:32:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38C7D6124C for ; Wed, 7 Apr 2021 01:32:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343642AbhDGBcR (ORCPT ); Tue, 6 Apr 2021 21:32:17 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:15617 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243397AbhDGBcO (ORCPT ); Tue, 6 Apr 2021 21:32:14 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FFRdr26qKz18HS3; Wed, 7 Apr 2021 09:29:52 +0800 (CST) Received: from [10.174.184.42] (10.174.184.42) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Wed, 7 Apr 2021 09:31:59 +0800 Subject: Re: [PATCH] KVM: MMU: protect TDP MMU pages only down to required level To: Sean Christopherson References: <20210402121704.3424115-1-pbonzini@redhat.com> <8d9b028b-1e3a-b4eb-5d44-604ddab6560e@huawei.com> CC: Paolo Bonzini , , , Ben Gardon From: Keqian Zhu Message-ID: Date: Wed, 7 Apr 2021 09:31:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> >> 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 >>> Signed-off-by: Paolo Bonzini >>> --- >>> 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); >>> >>> /* >>> > . >