Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp479732pxf; Wed, 10 Mar 2021 10:01:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXmWFkLZS09Ls/FFDmzwWXPCARQGS7xMAlY2x90EDRt8H1YkJx5I8BmpdT96KoCjMynacb X-Received: by 2002:a17:906:b2c3:: with SMTP id cf3mr4760623ejb.133.1615399306711; Wed, 10 Mar 2021 10:01:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615399306; cv=none; d=google.com; s=arc-20160816; b=XSoN8Yxv+PHh114AadAys5rTmIhPDgJEeTyyx39HxTjy2eZfsZV4sy5abnd46n+mgh SVKkJYFjw+wYYqaOiqFSXV9OlUIHgyOiy7VR37n0EJ350zWG26j6VMPqaPp5qmuCmhXP rwWfzabda3NqWb3UVMLJKgUsfEHBo50qR5PHG7KFYD7ndACVzqyhqfRCGJ8pHLAsBUWg INhJmG9BNhMSOP1FnyfEPH1NiJAIEv4ZjEgUTAOtepCX/PmIS58bHVFCIDWZXnkIcaPC tTzIHuwoIpHre1f2ouAk63WdOF+Pl7QYv8WgZDP0VJkrrwhfFq1lfyp7zzQAd1MWLuyv /LBg== 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:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=lIPthT51J+nIs48nl/QvpI3Ln3AY2S6u6ppS3XkUMwM=; b=l+vHj1yAKRjUQbgiekwDdXHGxYn6qVoD7eI8GQyyCcQ7mHaNexxE5XbNhvWodo/D9h 313GUoniTdZvw0fgzyuIe52riLkGSsnGZTwY0JszaKct4SnVx2/auc/8bjcFaz9+bM8X 8jCHa3LD06gw+VcX4tEH7pN11UeoSOIvGfFd6bPFUaiX5fp0XUN+9dxjhcpawnzlR/z/ mvjuDRrXomAgf1/nCmKMmDJXDyxlcwQwb5oAU+pKCKrmDYUO+yYGS4VzD418Gl9Nsmh9 P3GjccPLDrH6lTLwKtwML/hgapJQgfTMjUjpmCb9RTDGers2gv2DUgypzT00ImUiriuI CVyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fHBfJM8x; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 19si49280ejz.177.2021.03.10.10.01.20; Wed, 10 Mar 2021 10:01:46 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=fHBfJM8x; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233595AbhCJR6X (ORCPT + 99 others); Wed, 10 Mar 2021 12:58:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233633AbhCJR6G (ORCPT ); Wed, 10 Mar 2021 12:58:06 -0500 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 019B4C061760 for ; Wed, 10 Mar 2021 09:58:06 -0800 (PST) Received: by mail-qv1-xf4a.google.com with SMTP id jx11so13222256qvb.10 for ; Wed, 10 Mar 2021 09:58:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=lIPthT51J+nIs48nl/QvpI3Ln3AY2S6u6ppS3XkUMwM=; b=fHBfJM8xzLAclGXEjFaYJ5Rhln578wLzMWoSnqk9psHRaDBuLXBcARc1NhvK6zE3B1 cI2osMD4eClmpEaY1HG2sFX5g274O4sHptREG3EHY7jDQs+EYJD+eX0AZ/hpzN3YLGmp Y8QjFoJ1rGBijnkcrGc5QF/tGIGHoU258V1+/DMXbn9XDFr8KvWBiqDs4JlKA1EZ5Teb 9WPr3djabjTTnmuikYjQMgMjSzAxUvjpbqNOPWa0DZKjuxX5BUxiVqEBXB2KVvBeDAsg ffEpVSe+BFI6nvd6tRs+1g4UntXEnAu0/1UiOLszmNy6hb6AU8I4J4elFWEdhdROrc2Y 3yTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lIPthT51J+nIs48nl/QvpI3Ln3AY2S6u6ppS3XkUMwM=; b=YRNmi2ZmFcI6LS7fYiaTIntGvVUBZ6jRKTZe5Ck3W1rZhCTO/kOhvIWKsmCK7gMbmQ gZ5fdyz5rrpKfAHyY1WQ3BEVKYkRSIFwgHIGL0Edq/YTSDRoCC+pX8UB966y06znS6vn CLLV6soVBOv0ToB3YY9M38ZMPNT5FushshOQD2DgLd4F0ch2YuSP+UFRQBr3lwIs1urx cxJaLfcnhgdaXYWeRMoMoU+Cm2+4UI1TF7NE+wEeUWGqTLhrUywycl9AASzVZLNnwX+I F5UzhLT7K48vtJkUa94w4onk3OCWg4ZAtdyQMyxF5KYJmBtyKxQ6y3xc0btYC+2X8H85 g5DA== X-Gm-Message-State: AOAM530rh4f5Zi5y9pqEhDFotuj3Hl5NWiCqF1qLtbJYT4gRebMcnX/l NmEdVei1WsQcjDBv+MJOChlMdCapi7pt X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a0c:c60b:: with SMTP id v11mr4064868qvi.44.1615399085165; Wed, 10 Mar 2021 09:58:05 -0800 (PST) Date: Wed, 10 Mar 2021 17:57:22 +0000 In-Reply-To: <20210310175751.3320106-1-qperret@google.com> Message-Id: <20210310175751.3320106-6-qperret@google.com> Mime-Version: 1.0 References: <20210310175751.3320106-1-qperret@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v4 05/34] KVM: arm64: Avoid free_page() in page-table allocator From: Quentin Perret To: catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com Cc: android-kvm@google.com, linux-kernel@vger.kernel.org, kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, tabba@google.com, mark.rutland@arm.com, dbrazdil@google.com, mate.toth-pal@arm.com, seanjc@google.com, qperret@google.com, robh+dt@kernel.org, ardb@kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, the KVM page-table allocator uses a mix of put_page() and free_page() calls depending on the context even though page-allocation is always achieved using variants of __get_free_page(). Make the code consistent by using put_page() throughout, and reduce the memory management API surface used by the page-table code. This will ease factoring out page-allocation from pgtable.c, which is a pre-requisite to creating page-tables at EL2. Acked-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/pgtable.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 4d177ce1d536..81fe032f34d1 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -413,7 +413,7 @@ int kvm_pgtable_hyp_init(struct kvm_pgtable *pgt, u32 va_bits) static int hyp_free_walker(u64 addr, u64 end, u32 level, kvm_pte_t *ptep, enum kvm_pgtable_walk_flags flag, void * const arg) { - free_page((unsigned long)kvm_pte_follow(*ptep)); + put_page(virt_to_page(kvm_pte_follow(*ptep))); return 0; } @@ -425,7 +425,7 @@ void kvm_pgtable_hyp_destroy(struct kvm_pgtable *pgt) }; WARN_ON(kvm_pgtable_walk(pgt, 0, BIT(pgt->ia_bits), &walker)); - free_page((unsigned long)pgt->pgd); + put_page(virt_to_page(pgt->pgd)); pgt->pgd = NULL; } @@ -577,7 +577,7 @@ static int stage2_map_walk_table_post(u64 addr, u64 end, u32 level, if (!data->anchor) return 0; - free_page((unsigned long)kvm_pte_follow(*ptep)); + put_page(virt_to_page(kvm_pte_follow(*ptep))); put_page(virt_to_page(ptep)); if (data->anchor == ptep) { @@ -700,7 +700,7 @@ static int stage2_unmap_walker(u64 addr, u64 end, u32 level, kvm_pte_t *ptep, } if (childp) - free_page((unsigned long)childp); + put_page(virt_to_page(childp)); return 0; } @@ -897,7 +897,7 @@ static int stage2_free_walker(u64 addr, u64 end, u32 level, kvm_pte_t *ptep, put_page(virt_to_page(ptep)); if (kvm_pte_table(pte, level)) - free_page((unsigned long)kvm_pte_follow(pte)); + put_page(virt_to_page(kvm_pte_follow(pte))); return 0; } -- 2.30.1.766.gb4fecdf3b7-goog