From patchwork Fri Apr 15 21:58:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12815472 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04A96C433EF for ; Fri, 15 Apr 2022 22:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rwuWSzmwhNSVL/TaO3aqY0danNIVLzS/W9vKqg0h/7w=; b=CUmqcl2xBtvxAmGi7WeYPzVBEZ rAw2GBTi5/8/Nvvx2RbnTWACBJ3Wtw05t7Y/fc7s97tKig+gP38k+RgwBxRlf9sx4oCSClSenripY UDoaaVJNHmqYEQ5xYva3gu/PNhWhl6PVDzKaaa7VPL67q5uMmu+UX8aYRww+b/3bfplqcj0HLvi/d KO+Y0WLn5JFANBwEvrUY07phmqRoKq8d42OTpZpxGqxwuOGLQgKhbeOrdlq/FBIWKwu4sTmOxFX1E KRgzDa8IlddWiXdxRu2a7MZwLh5PCTrGoanOUkQdkZBmidag1CXOfoPJuwlIVko6PWZhoKkCFWzvJ X3pEQIXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfU2E-00BTwN-9V; Fri, 15 Apr 2022 22:03:22 +0000 Received: from mail-io1-xd4a.google.com ([2607:f8b0:4864:20::d4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfTyK-00BS4w-5v for linux-arm-kernel@lists.infradead.org; Fri, 15 Apr 2022 21:59:21 +0000 Received: by mail-io1-xd4a.google.com with SMTP id c25-20020a5d9399000000b00652e2b23358so1130402iol.6 for ; Fri, 15 Apr 2022 14:59:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ukSikfLZPySq7lKrWdQC3W4tZRZDdV+TXwwmzbO5VKE=; b=UFQNViFm5ywOL6fUUgUmBF2pMIllmvYSsEmxRVNh1gzD1izmJ3LtYUTbQoVRVd6R7/ jqzms2/UXzy9A1cKXaPCa6uGhs2jB4kYpL25R2bC00CDonStKGhvdJ4YVdoFWKmexTi/ QkfTtuq7/OrDuIAAqPw+yUALYUDmuCCrGRxB9F24yb275VyW2/5r9d7nu5//Jrfs1gyU bBbceIMSX7GVKPd/CqxGaga7ODuF8yOc8fr/uf+kbuofz35ev3lh9BLs/jGFbUXJ/kkj 2mjW+x4bwKEomG8LlUwv7ZO+oESMs9ddaaWpZvG/caTzJIQruvv70SZXMOewJ76h8qCh w+3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ukSikfLZPySq7lKrWdQC3W4tZRZDdV+TXwwmzbO5VKE=; b=J1vNwhaYvBejCSXy3oWmBqZ/a0UNCCKdcYYP5wDffeSi164v2n+C3AmmWz07Tif8ve fGQaKF64c5h+o1KmezPovk0jQny5M5//KpJfNHLQIKNJc1lDI2Ezrtn4xbL3oE68Ix6B SB/U4IZuNx3K5awDyUyfcJZv4w7X2bdbRZ1M7XSsthV0LhSNqwbqsO6SDk3GVPcoFsuW 6ZKGaHQKgbPQxqfzmJV19Nko/Amlj+jhduFoxVXrzMLbzC4SMysazbIpQWQFDocZW9kL B8kUHgON7h9hH9k4vyJBnN7YtLC1DyiPdaI2tf2Z5oZ3INlU28r+4RRHVg2uzE7EnfW8 XSLg== X-Gm-Message-State: AOAM5302zVM6y3B+KmvBn8lfF6LaCH3NIEvMRIprfNhyXaFKz6WDrVNC X3HM0L96yo7k1L2CvZxPffuu4EQ/VgQ= X-Google-Smtp-Source: ABdhPJw3+rg28SXpnYzElP/Fh1mOEN5FS2KtRHWJcXruhJlFqtNNF+kNgwwNT/3GJfepUrZ+VWNiihmiJLs= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6e02:1a4f:b0:2c7:a4c8:25f5 with SMTP id u15-20020a056e021a4f00b002c7a4c825f5mr334502ilv.64.1650059958943; Fri, 15 Apr 2022 14:59:18 -0700 (PDT) Date: Fri, 15 Apr 2022 21:58:55 +0000 In-Reply-To: <20220415215901.1737897-1-oupton@google.com> Message-Id: <20220415215901.1737897-12-oupton@google.com> Mime-Version: 1.0 References: <20220415215901.1737897-1-oupton@google.com> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [RFC PATCH 11/17] KVM: arm64: Move MMU cache init/destroy into helpers From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Peter Shier , Ricardo Koller , Reiji Watanabe , Paolo Bonzini , Sean Christopherson , Ben Gardon , David Matlack , Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220415_145920_304076_2D684DF8 X-CRM114-Status: GOOD ( 10.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_mmu.h | 2 ++ arch/arm64/kvm/arm.c | 4 ++-- arch/arm64/kvm/mmu.c | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 74735a864eee..3bb7b678a7e7 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -172,6 +172,8 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu); phys_addr_t kvm_mmu_get_httbr(void); phys_addr_t kvm_get_idmap_vector(void); int kvm_mmu_init(u32 *hyp_va_bits); +void kvm_mmu_vcpu_init(struct kvm_vcpu *vcpu); +void kvm_mmu_vcpu_destroy(struct kvm_vcpu *vcpu); static inline void *__kvm_vector_slot2addr(void *base, enum arm64_hyp_spectre_vector slot) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 523bc934fe2f..f7862fec1595 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -320,7 +320,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) vcpu->arch.target = -1; bitmap_zero(vcpu->arch.features, KVM_VCPU_MAX_FEATURES); - vcpu->arch.mmu_page_cache.gfp_zero = __GFP_ZERO; + kvm_mmu_vcpu_init(vcpu); /* Set up the timer */ kvm_timer_vcpu_init(vcpu); @@ -349,7 +349,7 @@ void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) if (vcpu_has_run_once(vcpu) && unlikely(!irqchip_in_kernel(vcpu->kvm))) static_branch_dec(&userspace_irqchip_in_use); - kvm_mmu_free_memory_cache(&vcpu->arch.mmu_page_cache); + kvm_mmu_vcpu_destroy(vcpu); kvm_timer_vcpu_terminate(vcpu); kvm_pmu_vcpu_destroy(vcpu); diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 53ae2c0640bc..f29d5179196b 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1601,6 +1601,16 @@ int kvm_mmu_init(u32 *hyp_va_bits) return err; } +void kvm_mmu_vcpu_init(struct kvm_vcpu *vcpu) +{ + vcpu->arch.mmu_page_cache.gfp_zero = __GFP_ZERO; +} + +void kvm_mmu_vcpu_destroy(struct kvm_vcpu *vcpu) +{ + kvm_mmu_free_memory_cache(&vcpu->arch.mmu_page_cache); +} + void kvm_arch_commit_memory_region(struct kvm *kvm, struct kvm_memory_slot *old, const struct kvm_memory_slot *new,