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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12999C433F5 for ; Thu, 18 Nov 2021 15:19:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED4B861ACE for ; Thu, 18 Nov 2021 15:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231841AbhKRPWY (ORCPT ); Thu, 18 Nov 2021 10:22:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57792 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231797AbhKRPWX (ORCPT ); Thu, 18 Nov 2021 10:22:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637248762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=INCjZFk/dRFHQEXGl4wGgmHmqgk0czQ/SLR2ImWk3XM=; b=asJbZK4ixsLlOQaBPceI1Q4KgG6Moq4+hwphZuM7T59im9eOxzvfXimQhgUFmBJx09zlAw 6/7V9IoDbAlrHwWEdYxIUd96Ngi1sMEJMcJtDiFNXswjR1JzuYy5iwtszFX/9W9WC2zAJb vWc32tUovipd88KUvSdcghKnBoCXy8k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-490-1xSqo1LAOAetmjP36VnSVA-1; Thu, 18 Nov 2021 10:18:43 -0500 X-MC-Unique: 1xSqo1LAOAetmjP36VnSVA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 353228042E6; Thu, 18 Nov 2021 15:18:41 +0000 (UTC) Received: from [10.39.192.245] (unknown [10.39.192.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83E841048129; Thu, 18 Nov 2021 15:17:57 +0000 (UTC) Message-ID: Date: Thu, 18 Nov 2021 16:17:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH 09/15] KVM: SVM: Remove the unneeded code to mark available for CR3 Content-Language: en-US To: Lai Jiangshan , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Lai Jiangshan , Sean Christopherson , 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> <20211108124407.12187-10-jiangshanlai@gmail.com> From: Paolo Bonzini In-Reply-To: <20211108124407.12187-10-jiangshanlai@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/8/21 13:44, Lai Jiangshan wrote: > From: Lai Jiangshan > > VCPU_EXREG_CR3 is never cleared from vcpu->arch.regs_avail in SVM so > marking available for CR3 is mere an NOP, just remove it. > > And it is not required to mark it dirty since VCPU_EXREG_CR3 is neither > never cleared from vcpu->arch.regs_dirty and SVM doesn't use the dirty > information of VCPU_EXREG_CR3. > > Signed-off-by: Lai Jiangshan > --- > arch/x86/kvm/svm/nested.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c > index 13a58722e097..2d88ff584d61 100644 > --- a/arch/x86/kvm/svm/nested.c > +++ b/arch/x86/kvm/svm/nested.c > @@ -444,7 +444,6 @@ static int nested_svm_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, > kvm_mmu_new_pgd(vcpu, cr3); > > vcpu->arch.cr3 = cr3; > - kvm_register_mark_available(vcpu, VCPU_EXREG_CR3); > > /* Re-initialize the MMU, e.g. to pick up CR4 MMU role changes. */ > kvm_init_mmu(vcpu); > These two patches can be merged, I think, with a commit message like VCPU_EXREG_CR3 is never cleared from vcpu->arch.regs_avail or vcpu->arch.regs_dirty in SVM; therefore, marking CR3 as available is merely a NOP, and testing it will likewise always succeed. Paolo