Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3034976ybt; Mon, 22 Jun 2020 13:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJRWV4NgLA4ezxGHzjJ/nRiBKOdEYY/15FOCz+4bImYKZ0MFN1izGc8k/ynb2CmHdaDE/+ X-Received: by 2002:aa7:c245:: with SMTP id y5mr19028103edo.189.1592856862231; Mon, 22 Jun 2020 13:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592856862; cv=none; d=google.com; s=arc-20160816; b=YO9gsRdTUlhMYQzKZmuzTivQahjlVBYOVYqg7RDcXWL/QRafpgCenoVp5hwYQ/cwp8 Nejbsr6KIVozgz+lDpVozgWOwb/BfG97ALx0wMIKjQm/5CX+VSa4Apr1jo4tHegdHAbv Ums8xs6FQwFpAedVQHwM996+rDIdJa0GAxGge30UKb7kWDd+UcXzeoTXrFG1C9lE8k6o WYy313dsvJDZ6vqa3EirFdHiD/KvuOR/AGxQe4KxTIUEcN8aW7pkK7yL3nKTpZ6yIgLG a+mnuCO9DjrZO0ze9tkZHeUOLX564WFV5XdGCzJpCRCZUPJuFiY05YcGy0kCmaJ1u0Lz ZLHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=qdwpRnDJeeudUNhOMdbCtyWeOSGI6OP2Q22pPHDfl4A=; b=Q6bOFstmOg3ufMBVV7kxFRd9/92HEW2aN+SBee+dDgVzLVFfXWSNeo3CWQerwRMpRm arY4lEGkyBNRe6k0wndDRA4gMs2vJT+6e5ZTPnBK2637FWlokN9OxpOtJACXdj4vCSmJ wLqB874YkW1Q+7gimcALinzlect6XxSCjVvjLY0xwyupSEnYuUXqbjYWmdQJuMNY933q aC9+MXdKoYFg6vd7iz46MAemf0YbMQQod5lWxch3Ri/G3s1W2PiaY2ifwfRnytmLoqeY 8bYlyiwv1SsHDQZ6XpTJDy0ydoszq9aEK22h0Riyi5G3/xDcphZbOysABlv4+WxdbM3L WKvg== 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 f6si1637994edq.225.2020.06.22.13.13.59; Mon, 22 Jun 2020 13:14:22 -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 S1730936AbgFVULo (ORCPT + 99 others); Mon, 22 Jun 2020 16:11:44 -0400 Received: from mga12.intel.com ([192.55.52.136]:60199 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730238AbgFVUJN (ORCPT ); Mon, 22 Jun 2020 16:09:13 -0400 IronPort-SDR: 9/RJgDUCF9TAC8SGogUjWNbi+60mCIAQyBbHvYnwGwAQfosrN3HVe8Vk/sYYNW7UUhoh1IGca1 zI6Lq9AI/2uA== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="123527726" X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="123527726" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 13:09:12 -0700 IronPort-SDR: k20phxHuVKzfP3a/Z2J/Y7rkPb1pVSfMh/pE6MIfuHHvB9z/OqUaCQ130N8EIEPF10anjFD0AQ Puo75HPQG3MQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,268,1589266800"; d="scan'208";a="318877073" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.152]) by FMSMGA003.fm.intel.com with ESMTP; 22 Jun 2020 13:09:11 -0700 From: Sean Christopherson To: Marc Zyngier , Paolo Bonzini , Arnd Bergmann Cc: James Morse , Julien Thierry , Suzuki K Poulose , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , Peter Feiner , Peter Shier , Junaid Shahid , Christoffer Dall Subject: [PATCH v2 07/21] KVM: x86/mmu: Topup memory caches after walking GVA->GPA Date: Mon, 22 Jun 2020 13:08:08 -0700 Message-Id: <20200622200822.4426-8-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200622200822.4426-1-sean.j.christopherson@intel.com> References: <20200622200822.4426-1-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Topup memory caches after walking the GVA->GPA translation during a shadow page fault, there is no need to ensure the caches are full when walking the GVA. As of commit f5a1e9f89504f ("KVM: MMU: remove call to kvm_mmu_pte_write from walk_addr"), the FNAME(walk_addr) flow no longer add rmaps via kvm_mmu_pte_write(). This avoids allocating memory in the case that the GVA is unmapped in the guest, and also provides a paper trail of why/when the memory caches need to be filled. Reviewed-by: Ben Gardon Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/paging_tmpl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 38c576495048..3de32122f601 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -791,10 +791,6 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code, pgprintk("%s: addr %lx err %x\n", __func__, addr, error_code); - r = mmu_topup_memory_caches(vcpu); - if (r) - return r; - /* * If PFEC.RSVD is set, this is a shadow page fault. * The bit needs to be cleared before walking guest page tables. @@ -822,6 +818,10 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code, return RET_PF_EMULATE; } + r = mmu_topup_memory_caches(vcpu); + if (r) + return r; + vcpu->arch.write_fault_to_shadow_pgtable = false; is_self_change_mapping = FNAME(is_self_change_mapping)(vcpu, -- 2.26.0