Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4149206pxf; Tue, 6 Apr 2021 09:03:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNH/y7jtLgFrrP3um529UJoc0Yi2NTGiFgwMOokGwqvq6HlnUFTgd7IBU2sY0tUwPG3Khc X-Received: by 2002:a02:a88e:: with SMTP id l14mr1719356jam.59.1617724984048; Tue, 06 Apr 2021 09:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617724984; cv=none; d=google.com; s=arc-20160816; b=p9Gyhht8SnrB10+99sMbWKVjXoIXJKjQu5OyJvqxd4uJCTbBLANH6fdabDJVdahloL w0qBH+7pzd0rzIH7/qzK0R3/k7lwwhkF9eey5kBzBiy3AB6+ENOKeobJMeDovduAoJB3 CPzd3H7V+7LAxUTynJCJoRKanF5lNN6Ab0byT/tbTvfVqHcWWUvFLfLGD3B73Sk4f9yg 5KeP+25ee5TtreY7ydLoWYefW1tAuuEQNdNLR4CXpiUB+ZHKiupyp51+gTw7l/ZvG3WK YfRJ3NFEq9Iw808xi90LdSeMl2CTaNRBTK9fbbLwrr2yPDJe1ZpDRTg8E1HWoN6NRILe ILPw== 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=kCI7VeJcA7rK5yyrPQXNIjDnLNK9OAf0N7vV8GN4DHc=; b=b3IVu9k7wh04OHTZ4zjla2Dm3IIjjUAlAbffwN3T8XrvdF2L7hWkoQHhXTxKJ0n4hX g03CidVitLTtjX3JPqu3xBVA/H03IK5/lUyioSKk2JNtOFc3X3aTuRZsZIaXsUmhqK4Q oJwh4m3S/1T+ajVu+OWuacW4BCTP6W0iZfQ4lnDWPxVgboMubODKWsiORudix0tWxmK+ 6e+SecFKyg7Y7xfbV7n5aI7Mwh+709mr+huvvQciibT9rXw23VCCDK5GFyKttaWW3LbF 8lgL3J1t2s4yU1fJRxy509gvXgvOG2ZAeJghcdaM6cw/gg4Ztb1Ku52KXpnMB1EKAx7u mkkg== 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 y5si19950229iof.34.2021.04.06.09.02.43; Tue, 06 Apr 2021 09:03:04 -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 S243977AbhDFG0N (ORCPT + 99 others); Tue, 6 Apr 2021 02:26:13 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:15551 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237136AbhDFG0N (ORCPT ); Tue, 6 Apr 2021 02:26:13 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FDyBv2FFrzPmFw; Tue, 6 Apr 2021 14:23:19 +0800 (CST) Received: from [10.174.184.42] (10.174.184.42) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Tue, 6 Apr 2021 14:26:01 +0800 Subject: Re: [PATCH] KVM: MMU: protect TDP MMU pages only down to required level To: Paolo Bonzini , , References: <20210402121704.3424115-1-pbonzini@redhat.com> CC: Ben Gardon From: Keqian Zhu Message-ID: <8d9b028b-1e3a-b4eb-5d44-604ddab6560e@huawei.com> Date: Tue, 6 Apr 2021 14:26:01 +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: <20210402121704.3424115-1-pbonzini@redhat.com> Content-Type: text/plain; charset="utf-8" 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 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 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); > > /* >