Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp547492pxk; Wed, 23 Sep 2020 09:35:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJF6g0FAIQ0JRofJJWBNUUGrXe892/YYOHS9ssbv/L3P+8ioBd+7fBOZk8O1+ebNWy0P+f X-Received: by 2002:a17:906:b47:: with SMTP id v7mr495025ejg.310.1600878931038; Wed, 23 Sep 2020 09:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600878931; cv=none; d=google.com; s=arc-20160816; b=HrsmeKhweOC/kMkYTkUCtVyDB8xB7MS5z8kvEX7PNrq5BGeqj7S2QM5o61Kgri28j4 Rvc49fzXq0CABFHQU4l0aii7USPABG6jqH187i7NEhnz/qhFaG3Kz0q6mAqKk3w2pDeU eLSQx2324KryxIGh8aCegYeJ8r6rv1PZ4VD8RlbMao40EPKqlbgZ/ZU6kvTPe7/eawSN FxfL3pQHaBFCSqJe1H0pGNFMvcjb94ATyJRs6pDiSiZjaCDQtqRM5rpebXjxuswY9k2v yyKRsLnsGhmJ9d5yIgkITX0qX0rkK23xag9fFdDbNX4S3DAn8t3gu7YLqGRRLU+/CvIt UVLw== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=VLl85wskaJfo6xvHJhGJlJRxpWJetIzKcHUcgpS5SaA=; b=fT6eXnJ5RWkfe3h50rYbyIk43ZbQD9WpTjebVmWr0CAuwG0Dzmj3nB09SznoUbDRFP BPa2wBkxRT9e6VcTQLZ9Su6hQnABesb/2EycslHVDZVL3FHaHbzlSDyz6opqXLk1KO7N EpbnqmaCgJRq/YzOUutC1GAt5oh/3jmymCMlXtZU1ayCfBCemnVkbZEA4Kg4vb+XP3b0 uIbrzes/LeA6OT4nXo2ofEml3AkHprtuRp0Q26Zify6jnYQPHSL6iSVgjae9luUBVoFe kO0Y8TUXHkWlcb3gYNq5pn3CQPzFZIqTx1WaR9UBDHn8k/9E+xzd6jseDdIpfogPDLYV etuA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k12si255308eji.645.2020.09.23.09.35.06; Wed, 23 Sep 2020 09:35:31 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726613AbgIWQdP (ORCPT + 99 others); Wed, 23 Sep 2020 12:33:15 -0400 Received: from mga12.intel.com ([192.55.52.136]:27783 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbgIWQdP (ORCPT ); Wed, 23 Sep 2020 12:33:15 -0400 IronPort-SDR: vyjTp+K7jFAtj1NxaWM0ujy+bqotUWvunx88KoRjEZRQysh1O/OhMs4CK0LRNLYXmweeBnbPhV eFa1B/tJTp2Q== X-IronPort-AV: E=McAfee;i="6000,8403,9753"; a="140413544" X-IronPort-AV: E=Sophos;i="5.77,293,1596524400"; d="scan'208";a="140413544" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2020 09:33:14 -0700 IronPort-SDR: qAOAGD9cR6U9BamXE2pPCcOnr6pygIUmJ1axxJv3JnIoo+SX3OaBXZZcIPzNOLx0ImDAzhjAlO JqtGTlpPmC5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,293,1596524400"; d="scan'208";a="348938302" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.160]) by orsmga007.jf.intel.com with ESMTP; 23 Sep 2020 09:33:14 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] KVM: x86/mmu: Move individual kvm_mmu initialization into common helper Date: Wed, 23 Sep 2020 09:33:14 -0700 Message-Id: <20200923163314.8181-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move initialization of 'struct kvm_mmu' fields into alloc_mmu_pages() to consolidate code, and rename the helper to __kvm_mmu_create(). No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 76c5826e29a2..a2c4c71ce5f2 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5682,11 +5682,17 @@ static void free_mmu_pages(struct kvm_mmu *mmu) free_page((unsigned long)mmu->lm_root); } -static int alloc_mmu_pages(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu) +static int __kvm_mmu_create(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu) { struct page *page; int i; + mmu->root_hpa = INVALID_PAGE; + mmu->root_pgd = 0; + mmu->translate_gpa = translate_gpa; + for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++) + mmu->prev_roots[i] = KVM_MMU_ROOT_INFO_INVALID; + /* * When using PAE paging, the four PDPTEs are treated as 'root' pages, * while the PDP table is a per-vCPU construct that's allocated at MMU @@ -5712,7 +5718,6 @@ static int alloc_mmu_pages(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu) int kvm_mmu_create(struct kvm_vcpu *vcpu) { - uint i; int ret; vcpu->arch.mmu_pte_list_desc_cache.kmem_cache = pte_list_desc_cache; @@ -5726,25 +5731,13 @@ int kvm_mmu_create(struct kvm_vcpu *vcpu) vcpu->arch.mmu = &vcpu->arch.root_mmu; vcpu->arch.walk_mmu = &vcpu->arch.root_mmu; - vcpu->arch.root_mmu.root_hpa = INVALID_PAGE; - vcpu->arch.root_mmu.root_pgd = 0; - vcpu->arch.root_mmu.translate_gpa = translate_gpa; - for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++) - vcpu->arch.root_mmu.prev_roots[i] = KVM_MMU_ROOT_INFO_INVALID; - - vcpu->arch.guest_mmu.root_hpa = INVALID_PAGE; - vcpu->arch.guest_mmu.root_pgd = 0; - vcpu->arch.guest_mmu.translate_gpa = translate_gpa; - for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++) - vcpu->arch.guest_mmu.prev_roots[i] = KVM_MMU_ROOT_INFO_INVALID; - vcpu->arch.nested_mmu.translate_gpa = translate_nested_gpa; - ret = alloc_mmu_pages(vcpu, &vcpu->arch.guest_mmu); + ret = __kvm_mmu_create(vcpu, &vcpu->arch.guest_mmu); if (ret) return ret; - ret = alloc_mmu_pages(vcpu, &vcpu->arch.root_mmu); + ret = __kvm_mmu_create(vcpu, &vcpu->arch.root_mmu); if (ret) goto fail_allocate_root; -- 2.28.0