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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49284C64EC4 for ; Mon, 6 Mar 2023 22:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbjCFWnG (ORCPT ); Mon, 6 Mar 2023 17:43:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230300AbjCFWmh (ORCPT ); Mon, 6 Mar 2023 17:42:37 -0500 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 262B586175 for ; Mon, 6 Mar 2023 14:42:06 -0800 (PST) Received: by mail-pg1-x549.google.com with SMTP id t185-20020a635fc2000000b00502e332493fso2489940pgb.12 for ; Mon, 06 Mar 2023 14:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678142519; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9itEUO5Up+fI8iZk0iLC4qpDns9vSkVb4A516EJM+I0=; b=at6TQkK22xH96lnLyAJmubroPcHciUudqTHcykVv1J4vGrW/W+Wm443aAB9k+s4VL6 QhJ271wtkDKYq+yN0qOuZEsZhFa7kpf1EYRE9YM+4gPWg5IHwL4hklbYs1zbUgsk7Bbk 3TcmaPFIIgEvnaZO3k4WnSCc9ZFBZvKPoYHHSFBvgDLaqrbu2ks/AokOLJOKlI1j/4HE AfdPl8TZkPDz4VBBwPbmvfYoWUHigzQM0524TwkBQBlm8NzIMPuKiJEruvOwxb7pvzzS Iuja/F2k+J1CiXNukSTAtlXOklCvIeUEOyDDUU+xou9hV6faTKP4unCqrQIVi3pzdUsT qK3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678142519; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9itEUO5Up+fI8iZk0iLC4qpDns9vSkVb4A516EJM+I0=; b=3pZhpn4VQ+2aq2icSz24gn4lSH2SW+QaMUR6VMDRH0EMh0rdM93/pT9TBs0rjxyKcO PFO6Gdr8RKrBWy7/VFce2zYW8F6tC+LufUDiVIA8KQctdB3nudnyP5+dRQ/sfEqRxQ5w xH1RyAYL6zthMFfpoxqKlXdwi4c4OIkyOTGQBjXPiJ9Sqmr7C4fRbsJpM2WqiDVHVFUV rnbfM5+Z3GGtFpiMQwMpnAC1aeyO1/zMwfGRnO5ZCgvX29GQMp7XqPaiVsU5C487kSyM HaXSHaAgtpcASAtL42jj8MFiBufSLamuSeYqseEE40gQukrTL0pwVYsYV9WMCTZbWYiP ETmQ== X-Gm-Message-State: AO0yUKUvlC0kaORWXw0Z3EWceXu+0CfqmNqHxdLk9LZB2iiL1CJBj5Lw A2Bah6PBgV8r5rO6x+l4KTW6OJNV1qBd X-Google-Smtp-Source: AK7set9LZnkcT+4mc88Pdxib2KGSekMwjKPwN1F6NV9DbxpH+EWfu7Z5xTPOZLDmNsyKAGya/UsFECxhTM3s X-Received: from vipin.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:479f]) (user=vipinsh job=sendgmr) by 2002:a17:902:9a03:b0:19a:afc4:2300 with SMTP id v3-20020a1709029a0300b0019aafc42300mr5089548plp.6.1678142518978; Mon, 06 Mar 2023 14:41:58 -0800 (PST) Date: Mon, 6 Mar 2023 14:41:23 -0800 In-Reply-To: <20230306224127.1689967-1-vipinsh@google.com> Mime-Version: 1.0 References: <20230306224127.1689967-1-vipinsh@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306224127.1689967-15-vipinsh@google.com> Subject: [Patch v4 14/18] KVM: mmu: Initialize kvm_mmu_memory_cache.gfp_zero to __GFP_ZERO by default From: Vipin Sharma To: seanjc@google.com, pbonzini@redhat.com, bgardon@google.com, dmatlack@google.com Cc: jmattson@google.com, mizhang@google.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Vipin Sharma Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Set __GFP_ZERO to gfp_zero in default initizliation of struct kvm_mmu_memory_cache{} All of the users of default initialization code of struct kvm_mmu_memory_cache{} explicitly sets gfp_zero to __GFP_ZERO. This can be moved to common initialization logic. Signed-off-by: Vipin Sharma --- arch/arm64/kvm/arm.c | 1 - arch/arm64/kvm/mmu.c | 1 - arch/riscv/kvm/mmu.c | 1 - arch/riscv/kvm/vcpu.c | 1 - arch/x86/kvm/mmu/mmu.c | 6 ------ include/linux/kvm_types.h | 4 +++- 6 files changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 2b3d88e4ace8..b4243978d962 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -331,7 +331,6 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) bitmap_zero(vcpu->arch.features, KVM_VCPU_MAX_FEATURES); INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_page_cache); - vcpu->arch.mmu_page_cache.gfp_zero = __GFP_ZERO; /* * Default value for the FP state, will be overloaded at load diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 8a56f071ca66..133eba96c41f 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -904,7 +904,6 @@ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa, if (is_protected_kvm_enabled()) return -EPERM; - cache.gfp_zero = __GFP_ZERO; size += offset_in_page(guest_ipa); guest_ipa &= PAGE_MASK; diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c index bdd8c17958dd..62550fd91c70 100644 --- a/arch/riscv/kvm/mmu.c +++ b/arch/riscv/kvm/mmu.c @@ -353,7 +353,6 @@ int kvm_riscv_gstage_ioremap(struct kvm *kvm, gpa_t gpa, phys_addr_t addr, end; KVM_MMU_MEMORY_CACHE(pcache); - pcache.gfp_zero = __GFP_ZERO; if (in_atomic) pcache.gfp_custom = GFP_ATOMIC | __GFP_ACCOUNT; diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index bc743e9122d1..f5a96ed1e426 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -164,7 +164,6 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) /* Mark this VCPU never ran */ vcpu->arch.ran_atleast_once = false; INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_page_cache); - vcpu->arch.mmu_page_cache.gfp_zero = __GFP_ZERO; bitmap_zero(vcpu->arch.isa, RISCV_ISA_EXT_MAX); /* Setup ISA features available to VCPU */ diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index b706087ef74e..d96afc849ee8 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5963,14 +5963,11 @@ int kvm_mmu_create(struct kvm_vcpu *vcpu) INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_pte_list_desc_cache); vcpu->arch.mmu_pte_list_desc_cache.kmem_cache = pte_list_desc_cache; - vcpu->arch.mmu_pte_list_desc_cache.gfp_zero = __GFP_ZERO; INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_page_header_cache); vcpu->arch.mmu_page_header_cache.kmem_cache = mmu_page_header_cache; - vcpu->arch.mmu_page_header_cache.gfp_zero = __GFP_ZERO; INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_shadow_page_cache); - vcpu->arch.mmu_shadow_page_cache.gfp_zero = __GFP_ZERO; mutex_init(&vcpu->arch.mmu_shadow_page_cache_lock); INIT_KVM_MMU_MEMORY_CACHE(&vcpu->arch.mmu_shadowed_info_cache); @@ -6138,14 +6135,11 @@ int kvm_mmu_init_vm(struct kvm *kvm) INIT_KVM_MMU_MEMORY_CACHE(&kvm->arch.split_page_header_cache); kvm->arch.split_page_header_cache.kmem_cache = mmu_page_header_cache; - kvm->arch.split_page_header_cache.gfp_zero = __GFP_ZERO; INIT_KVM_MMU_MEMORY_CACHE(&kvm->arch.split_shadow_page_cache); - kvm->arch.split_shadow_page_cache.gfp_zero = __GFP_ZERO; INIT_KVM_MMU_MEMORY_CACHE(&kvm->arch.split_desc_cache); kvm->arch.split_desc_cache.kmem_cache = pte_list_desc_cache; - kvm->arch.split_desc_cache.gfp_zero = __GFP_ZERO; return 0; } diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h index 192516eeccac..5da7953532ce 100644 --- a/include/linux/kvm_types.h +++ b/include/linux/kvm_types.h @@ -99,7 +99,9 @@ struct kvm_mmu_memory_cache { void **objects; }; -#define KVM_MMU_MEMORY_CACHE_INIT() { } +#define KVM_MMU_MEMORY_CACHE_INIT() { \ + .gfp_zero = __GFP_ZERO, \ +} #define KVM_MMU_MEMORY_CACHE(_name) \ struct kvm_mmu_memory_cache _name = KVM_MMU_MEMORY_CACHE_INIT() -- 2.40.0.rc0.216.gc4246ad0f0-goog