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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C935C433EF for ; Wed, 8 Dec 2021 09:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230046AbhLHJhr (ORCPT ); Wed, 8 Dec 2021 04:37:47 -0500 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:57728 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbhLHJhq (ORCPT ); Wed, 8 Dec 2021 04:37:46 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=laijs@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0UztY64i_1638956051; Received: from 30.22.113.150(mailfrom:laijs@linux.alibaba.com fp:SMTPD_---0UztY64i_1638956051) by smtp.aliyun-inc.com(127.0.0.1); Wed, 08 Dec 2021 17:34:12 +0800 Message-ID: Date: Wed, 8 Dec 2021 17:34:11 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH 16/15] KVM: X86: Update mmu->pdptrs only when it is changed Content-Language: en-US To: Paolo Bonzini , Sean Christopherson , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" References: <20211108124407.12187-1-jiangshanlai@gmail.com> <20211111144527.88852-1-jiangshanlai@gmail.com> <60743c95-f9aa-a7c6-1709-39c70e224321@redhat.com> From: Lai Jiangshan In-Reply-To: <60743c95-f9aa-a7c6-1709-39c70e224321@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/12/8 17:09, Paolo Bonzini wrote: > On 12/8/21 00:43, Sean Christopherson wrote: >> what guarantees the that PDPTRs in the VMCS are sync'd with >> mmu->pdptrs?  I'm not saying they aren't, I just want the changelog >> to prove that they are. > > If they aren't synced you should *already* have dirty VCPU_EXREG_PDPTR and pending KVM_REQ_LOAD_MMU_PGD, shouldn't you? > As long as the caching invariants are respected, this patch is fairly safe, and if they aren't there are plenty of > preexisting bugs anyway. > They can be not synced in other side: not available. If (!kvm_register_is_available(vcpu, VCPU_EXREG_PDPTR)) it will make no sense to compare mmu->pdptrs when EPT is enabled. Because vmcs might have different copy, it is better to just mark it dirty in load_pdptrs(). (SVM is OK even with NPT enabled, since vmcb doesn't have a copy) I haven't investigated enough then and today. It is quit complicated. Thanks Lai > >> The next patch does add a fairly heavy unload of the current root for >> !TDP, but that's a bug fix and should be ordered before any >> optimizations anyways.