Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5136795iog; Wed, 22 Jun 2022 12:47:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uUWccjRRto5XodqKFbEeoPLORKBT8kP2H8BjGYWZzSXM1whpJniYW4Oqin28nn2Ac+l11F X-Received: by 2002:a17:903:216:b0:167:921c:6590 with SMTP id r22-20020a170903021600b00167921c6590mr35752164plh.83.1655927265521; Wed, 22 Jun 2022 12:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655927265; cv=none; d=google.com; s=arc-20160816; b=lOG5rST4fr/LDep0xzPfxJL4ipXsOTFCitvfr1qwKRWvuKyNABqgcPWt1hla3xkd0h bu/t/gGLZNI1+qc03NMoCtcy8kCVMBSrumq1zJXNIdZyEpjYwaEm/aWkyH9t5ZMdwQc8 vopDivJNXvhe4lb/YgKL3hohWzoJtNBcmWBIeNuKKU7pOQG94lBzPcbqCFOHXYxXni8S oUWvy2HFDcNRTP91L96izQlV081oRhlhiug4z4X92CMgmcy1/ZhehwdTB9ZjDVEXJI63 rhuyJdj8FYts2inMmCc4RCUloPz+3dQK2BKj7/ZQ+9RMulLfwAU3S8DUNuCNstbcawj4 ObGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TANehd7tekYb0UZg4NW5mydgr8WNy/wIBmS4rIExPPQ=; b=JG1OMKbVcYcChSbjAmOMBnrv/KMFGL3pK16R7udTOW3WKuFsMlVC+RH4Efv4loSfZV jjeTUULpBFCfTuqmbTC25wBw3+t/NkBd109weCUlJZpRH7VtKlFKGy7Fw9SIwQsEy2T7 DCk9/EEPSRjgv3IbcW0OFyx59GTMP+DiUI0W5Sup4nk6o8VCXI4eYTWWNjBM4i+7P9M/ koJRWtBasNgaVHn4NG8rUBj4MElM83DAMpJUQvUbOOZ47Gw62rTkRqkCkdM47Z80Hg1d xt+v9g+a8eki9kwNdghhps/Semr9BnSgIrST/1gFf9bN6UY/EqpMfC6IZl0CB4HUpGRQ akDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HR5mGisR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a170902f54200b00163e9849d54si25656604plf.214.2022.06.22.12.47.33; Wed, 22 Jun 2022 12:47:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HR5mGisR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358833AbiFVT3M (ORCPT + 99 others); Wed, 22 Jun 2022 15:29:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354289AbiFVT1Y (ORCPT ); Wed, 22 Jun 2022 15:27:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 509D83B545 for ; Wed, 22 Jun 2022 12:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655926038; 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=TANehd7tekYb0UZg4NW5mydgr8WNy/wIBmS4rIExPPQ=; b=HR5mGisR/VJufsL6r2DQJOnXRw/tVCvncz7J36z3vqTTZ9ETgvr4oXt08Ca2chkB+KDlWK AP+JKMXVPXhu5zDGd86QwxKSZjQ/QzDqQy8tjwsJ3dPFPKPES+6ZIt4QfUZZpeILW1kJsg hc+9v9KyKvIWSEhWBWW+JfAuKK0EmC0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-135-rWmigOwvMd6tIaaXzUsX2A-1; Wed, 22 Jun 2022 15:27:13 -0400 X-MC-Unique: rWmigOwvMd6tIaaXzUsX2A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A440294EDC2; Wed, 22 Jun 2022 19:27:12 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0410C1121314; Wed, 22 Jun 2022 19:27:11 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: maz@kernel.org, anup@brainfault.org, seanjc@google.com, bgardon@google.com, peterx@redhat.com, maciej.szmigiero@oracle.com, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, pfeiner@google.com, jiangshanlai@gmail.com, dmatlack@google.com Subject: [PATCH v7 03/23] KVM: x86/mmu: Stop passing "direct" to mmu_alloc_root() Date: Wed, 22 Jun 2022 15:26:50 -0400 Message-Id: <20220622192710.2547152-4-pbonzini@redhat.com> In-Reply-To: <20220622192710.2547152-1-pbonzini@redhat.com> References: <20220622192710.2547152-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Matlack The "direct" argument is vcpu->arch.mmu->root_role.direct, because unlike non-root page tables, it's impossible to have a direct root in an indirect MMU. So just use that. Suggested-by: Lai Jiangshan Signed-off-by: David Matlack Message-Id: <20220516232138.1783324-4-dmatlack@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/mmu/mmu.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 844b58ddb3bb..2e30398fe59f 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3369,8 +3369,9 @@ static int mmu_check_root(struct kvm_vcpu *vcpu, gfn_t root_gfn) } static hpa_t mmu_alloc_root(struct kvm_vcpu *vcpu, gfn_t gfn, gva_t gva, - u8 level, bool direct) + u8 level) { + bool direct = vcpu->arch.mmu->root_role.direct; struct kvm_mmu_page *sp; sp = kvm_mmu_get_page(vcpu, gfn, gva, level, direct, ACC_ALL); @@ -3396,7 +3397,7 @@ static int mmu_alloc_direct_roots(struct kvm_vcpu *vcpu) root = kvm_tdp_mmu_get_vcpu_root_hpa(vcpu); mmu->root.hpa = root; } else if (shadow_root_level >= PT64_ROOT_4LEVEL) { - root = mmu_alloc_root(vcpu, 0, 0, shadow_root_level, true); + root = mmu_alloc_root(vcpu, 0, 0, shadow_root_level); mmu->root.hpa = root; } else if (shadow_root_level == PT32E_ROOT_LEVEL) { if (WARN_ON_ONCE(!mmu->pae_root)) { @@ -3408,7 +3409,7 @@ static int mmu_alloc_direct_roots(struct kvm_vcpu *vcpu) WARN_ON_ONCE(IS_VALID_PAE_ROOT(mmu->pae_root[i])); root = mmu_alloc_root(vcpu, i << (30 - PAGE_SHIFT), - i << 30, PT32_ROOT_LEVEL, true); + i << 30, PT32_ROOT_LEVEL); mmu->pae_root[i] = root | PT_PRESENT_MASK | shadow_me_value; } @@ -3532,7 +3533,7 @@ static int mmu_alloc_shadow_roots(struct kvm_vcpu *vcpu) */ if (mmu->cpu_role.base.level >= PT64_ROOT_4LEVEL) { root = mmu_alloc_root(vcpu, root_gfn, 0, - mmu->root_role.level, false); + mmu->root_role.level); mmu->root.hpa = root; goto set_root_pgd; } @@ -3578,7 +3579,7 @@ static int mmu_alloc_shadow_roots(struct kvm_vcpu *vcpu) } root = mmu_alloc_root(vcpu, root_gfn, i << 30, - PT32_ROOT_LEVEL, false); + PT32_ROOT_LEVEL); mmu->pae_root[i] = root | pm_mask; } -- 2.31.1