From patchwork Fri Jun 2 16:09:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vipin Sharma X-Patchwork-Id: 102642 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1140038vqr; Fri, 2 Jun 2023 09:12:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Pmru85yhRpf6R2JcM/XpTuj+qDzJGHDCBRqTQDUL8bpD3dnpkePmRFYgWd6e5kuEJy6mS X-Received: by 2002:a17:902:e5ce:b0:1ae:7631:7fa9 with SMTP id u14-20020a170902e5ce00b001ae76317fa9mr423208plf.37.1685722320278; Fri, 02 Jun 2023 09:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685722320; cv=none; d=google.com; s=arc-20160816; b=uR6KeSXTC9J+JEZnXnaqDvTjOZsoHgrU1XmRgVt4XWa7hWxkSCi1fOScBhntn61Oe5 IGjzCPzb+SDZnARtyZhfn9ESWPACuTUixMYACO84wSsBf+nVwXAziLIxLTGFhP+mpcb9 ikCedZjiPz4ORPKeQcgKEi6L61gbGHKg4TkjOW/BC/yVkdEz7q5wf/Hl/oX+Via2va/G UPO511WGMHjpH2OxHFDmopv0/tQJy8ILqr8+tzuGckdxpD2JjW7dBsVGDeT73MmNidId mD0/RbCkni/XY2+Xx9Lw+BDbYVr7P6vzcA/9IDFvwKUkBvvxeod2rklkmOe4yutZTB7y 2H2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=Hryh0ZWAFdBP/1ensclnMWOs6DFcoKq9t8dEIwwzMjM=; b=npWIbuuxz4cOfCwxJpfmykrvhr/3M2B5qSxaYVu/LIQbnUr6CmCM8YjlBYtCHHk+Ky 3OIGa+GP9EGhc8LhL6RCkm9Shuj0J+nWdoNDUiar8a9ZP1ddTFMEgmyI9rTz4xaxJYyb vssi3+yV9MfXzZUfiaK1NKoOEJRYoaSduHrjLP3VOiJ0xHoMKReAYCfrjSpsV+Q5YfkZ 6nKldFxAj3T5rx4zq/DqZVWltUU23bDRxsmJjr4NDGivxdrZX++JzTCKE3F0gcvvYD3y Iy6auo3Y3V80DcTpsD+BkXX8kHouHyrwwYZzlcKRkNL59JWzI9Kg4N5TaTC1RbWQ+aq9 /HIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=yFcSJ5sk; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a170902da8800b001b00ae4ad40si1126406plx.368.2023.06.02.09.11.48; Fri, 02 Jun 2023 09:12:00 -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=@google.com header.s=20221208 header.b=yFcSJ5sk; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236760AbjFBQLL (ORCPT + 99 others); Fri, 2 Jun 2023 12:11:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236790AbjFBQK5 (ORCPT ); Fri, 2 Jun 2023 12:10:57 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 409B610E0 for ; Fri, 2 Jun 2023 09:10:10 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-565de486762so28471877b3.3 for ; Fri, 02 Jun 2023 09:10:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685722190; x=1688314190; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Hryh0ZWAFdBP/1ensclnMWOs6DFcoKq9t8dEIwwzMjM=; b=yFcSJ5sk1YiYcQktVHUrIraA4vq3gzBg01wawQ+99X99BcERdv6aw79BJglFIsX38X Jmk2e5UaolCr5t1qAVgv5xhRcuwqz8qsPeKTN4dMinvHjEGhpXtPGawN2ICvlDQZGj8D ZmOScsl1sdyn4gxehMyRauugNpIrQjpu1KxL67VdJydhpwrAe8TXpUojYixIDTXpkYLZ L/KcS63c1WkLy8I19gAWFgXf90HgC8c3L1xN5Hze37jt9RE4scxALJ3lb9KGpgKF7m+y IPNOsGvdWwTPZEtqpxeUuo6lpLAcPxZcX9jQeWMRNApjKkg5jyviIXgCTWMDwLFLuVTH Fsfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685722190; x=1688314190; 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=Hryh0ZWAFdBP/1ensclnMWOs6DFcoKq9t8dEIwwzMjM=; b=YbRopRQ5d4s1RPszjGmOFPaWm/yWA5OdEJzOTA/SwrtUFnFzRzus75ark+vK6dR6ye qJsccATYaRc319kTxhnyf5eSZHA8TzAjC7M8RsUzXp8sFE3b8FcCF8WdKmKBKR7pYXcd DEQ4MVlAuqigBDnuLEWbwtv2Egx6ucLgot/2CsyUz7YVZ+T/9LQ2erJrCSLu1POAHj6E cGk600D18SN+X/yBo/jZ4dAac6NVq9+fkMupMLUAIDnxtPJcJhAFOViIz2xwaHAm5a9B +8MKj2C7zslBNdTGkFpUhxmkfjSsdhz0imJ+ekVM3skijW3DO0l3pxBvRFeZ/juhOpWC 3SJw== X-Gm-Message-State: AC+VfDxhC9da1JnZpQoOi9rjyzmpeev9JyuwOdr4C1dEIfoQMlledidV MxLh7WeUSL55Qg2QS0XN9Bqw41tU3sXo X-Received: from vipin.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:479f]) (user=vipinsh job=sendgmr) by 2002:a25:bc7:0:b0:ba8:cbd2:61b3 with SMTP id 190-20020a250bc7000000b00ba8cbd261b3mr1223005ybl.5.1685722190144; Fri, 02 Jun 2023 09:09:50 -0700 (PDT) Date: Fri, 2 Jun 2023 09:09:13 -0700 In-Reply-To: <20230602160914.4011728-1-vipinsh@google.com> Mime-Version: 1.0 References: <20230602160914.4011728-1-vipinsh@google.com> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog Message-ID: <20230602160914.4011728-16-vipinsh@google.com> Subject: [PATCH v2 15/16] KVM: arm64: Provide option to pass page walker flag for huge page splits From: Vipin Sharma To: maz@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, chenhuacai@kernel.org, aleksandar.qemu.devel@gmail.com, tsbogend@alpha.franken.de, anup@brainfault.org, atishp@atishpatra.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, seanjc@google.com, pbonzini@redhat.com, dmatlack@google.com, ricarkol@google.com Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Vipin Sharma X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767607967355775596?= X-GMAIL-MSGID: =?utf-8?q?1767607967355775596?= Pass enum kvm_pgtable_walk_flags{} to kvm_mmu_split_huge_pages(). Use 0 as the flag value to make it no-op. In future commit kvm_mmu_split_huge_pages() will be used under both MMU read lock and MMU write lock. Flag allows to pass intent to use shared or non-shared page walkers to split the huge pages. Signed-off-by: Vipin Sharma --- arch/arm64/kvm/mmu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 34d2bd03cf5f..6dd964e3682c 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -118,7 +118,8 @@ static bool need_split_memcache_topup_or_resched(struct kvm *kvm) } static int kvm_mmu_split_huge_pages(struct kvm *kvm, phys_addr_t addr, - phys_addr_t end) + phys_addr_t end, + enum kvm_pgtable_walk_flags flags) { struct kvm_mmu_memory_cache *cache; struct kvm_pgtable *pgt; @@ -153,7 +154,8 @@ static int kvm_mmu_split_huge_pages(struct kvm *kvm, phys_addr_t addr, return -EINVAL; next = __stage2_range_addr_end(addr, end, chunk_size); - ret = kvm_pgtable_stage2_split(pgt, addr, next - addr, cache, 0); + ret = kvm_pgtable_stage2_split(pgt, addr, next - addr, cache, + flags); if (ret) break; } while (addr = next, addr != end); @@ -1112,7 +1114,7 @@ static void kvm_mmu_split_memory_region(struct kvm *kvm, int slot) end = (memslot->base_gfn + memslot->npages) << PAGE_SHIFT; write_lock(&kvm->mmu_lock); - kvm_mmu_split_huge_pages(kvm, start, end); + kvm_mmu_split_huge_pages(kvm, start, end, 0); write_unlock(&kvm->mmu_lock); } @@ -1149,7 +1151,7 @@ void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm, * again. */ if (kvm_dirty_log_manual_protect_and_init_set(kvm)) - kvm_mmu_split_huge_pages(kvm, start, end); + kvm_mmu_split_huge_pages(kvm, start, end, 0); write_unlock(&kvm->mmu_lock); }