Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp676575pxf; Wed, 7 Apr 2021 09:00:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAtd39X6oHzf86J02Np2U0BJINTm/KcMsyFsl1l1VzRQCDSgGTLZTwNVrw818l1dTzMxgc X-Received: by 2002:aa7:d759:: with SMTP id a25mr5434349eds.248.1617811232041; Wed, 07 Apr 2021 09:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617811232; cv=none; d=google.com; s=arc-20160816; b=MekG4iZT1+t6eAyuU+fQsX82NiXc7CDOok53UNGBHHYOrHy9lDlgOBSvqod9GqWtfT BbEDMCCHKlPNrV8/qX34bt2fkpjdQzZcWnby8NX6yzczM1D9oLc3B5B9D2JnbNXniKZC DlCPpUklirWrman5822StxkOy6xnZ/jX6RV2WUic/HoRLueCBDJimC25W99lTSeF47sb InDJR1qkpO2BhbwkRJzw0b+OTQn5xWjK1SUssDMO5B67G5aNeOKf692BbCOI/NtVumFs 2TambizV2CEc9n3IE8nq7bI8NXtfpwdJcHUCBgAfS1gdJnI91sDm/kPjwqhP+8blGivl Bz2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=bDH267iDQDgc31pmXte1co0foHbL4NweLs3pbnqXoF4=; b=wb7HSLQV6JFbzJRsUsdA4hWOTdBuWkt6XG0OwM+gJg75UcuPFi5wznDsn1bzk3k7Qs gPKOzNomcJQGwuV9A5g/dxbEXyBYvn7ukocuc+kUAzNUcdaB8r42mzQzr3imsQvuiT2A wTyDdcPjcQybD/BEyivkI87dUaUh1pdVoDEIz/Z3xutF3MlYGu49fnMy0tqOfRDYvyRW pvZ9dK5BY1u4t1oZzeU+LdhFnjbRXPmldL8xtrL6e9pSxVmTonwdb9N9p7O26a69tH8T kW5RQlQn0sCk3WVJyPJ/euoRo2YxtqBu0EQYt9Tv020wMUd5LBnI6q9QtkfcSjXaXPHM Nx4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si6908837ejc.580.2021.04.07.09.00.07; Wed, 07 Apr 2021 09:00:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343542AbhDGBcP (ORCPT + 99 others); Tue, 6 Apr 2021 21:32:15 -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); >>> >>> /* >>> > . >