From patchwork Tue Mar 2 14:59:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12114213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EECCC433E0 for ; Wed, 3 Mar 2021 20:50:26 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD65F64EF8 for ; Wed, 3 Mar 2021 20:50:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD65F64EF8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=7H7sQrTyDotrU+b/UR0LE3wVaeYktumM9TUtr8+b7w4=; b=ErRZfdOQ+Xa60O jwB2N6kWHVlvjgeU8FYocYdH9PihCCe+tPlCS0UdwuMCs9mcR+xNPtT8qpdvUjtZF0m9VmJ0gxQKj 0VmTvP5I2kIQO9V2j4D1Pcsu1M1vMIp9ASeOIHP/BzzFxZNH3+f5ctfA1q3Ao8f6u4/SX3lsbRdgu J/szBsZ5UZseKod13Z8QLlbJVsnmStozWibJ4EqXy4vrJ0V+dkYG9sBoDZbFR5ggGBsH80S55OR5F Ld8aptzUGZC02u2u5CiLNzmBTqqMFPYQHd1prVQHczqnhTIlsryu8p+JzMNKSgk1QyKHdcsDeieFN lBr8NF4w2k8q7uC0415Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHYLr-006TGO-Rj; Wed, 03 Mar 2021 20:44:12 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHT6n-005JB3-8t for linux-arm-kernel@desiato.infradead.org; Wed, 03 Mar 2021 15:08:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=lIPthT51J+nIs48nl/QvpI3Ln3AY2S6u6ppS3XkUMwM=; b=NCBtBRFvZNxwYvs0rrqQVu6QdW ItQaJvpzqoMeG4UwNTHwkVAasKenKVhqhJuFotHrN9HHE50VX8/rq1f6q6k/HeqyXbStQI/ZuzFyz 0nKKn4f0EG5XjrRIeTnExjcw8oDbef0Eh+PvKSlgaR4ntQpjMkMDh3jIX04SpXFxwMef2ziQ0Xuwq 0O40Q5m4GIogovkPGpqx11LPr9eZzAZsr+9/zpicAN8r6m7BKL3Df7YY4+otgcW8ZJIXrn3Je+C3j 3p1uSY5wC67wAkJm0v9qmteIf1SHk+PwLh2iibOA2oZVsKTShBtfpwWBdLOBQNFVKmU8Skhlie2jY GZGqbQRQ==; Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH6Wc-00HJEA-1h for linux-arm-kernel@lists.infradead.org; Tue, 02 Mar 2021 15:01:32 +0000 Received: by mail-wr1-x449.google.com with SMTP id h21so6835664wrc.19 for ; Tue, 02 Mar 2021 07:01:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=lIPthT51J+nIs48nl/QvpI3Ln3AY2S6u6ppS3XkUMwM=; b=HY2FQJKTnEHypa62GHDeyX5+DVpyd3kd+DNyVif3kQtZ0Ox8tb7XmQpSllG+iYjI1q 2QUVT2ttxPR69J+1gr+Neb8KNaKUHnwZPw3KUtPEso2PhLlezOzkuodC5vfiw9ttCpDt PRv1H5+P/SxKxew8i6WYse/QbcgSljdRs8FF7QDs49k78eLuvKtMpiJAuzX2X73QLIXU D6R6lQ6XuxLRnxSp+qKmjlwaaJbUgl6MooyomJKPlhfPlxL+ZUe44/BrLtDEXg46c0WL EuYGfH2gL3Od1t6WL3JKq7MFziOBysv7Jm4YOo4Ku6QwkNhrBF/wvIu6ii7T0msYsmIh 2teA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lIPthT51J+nIs48nl/QvpI3Ln3AY2S6u6ppS3XkUMwM=; b=G5iCygypiMJoXnQrCZKE2D+7yxkNZFRsH488brpVPmfBv43unn3ahiwdo9oZydMfzn fJTqVlVx2dv9qe2DtqbX3hmcc+LHjsIXlnN0sA8Ux+abjdrEBJOWMtFHBc5DFYscX0iU A+jG5Th6TCjszTRYqkQEgTL8SZHTdFsBLGd+/TdW39GHkvFglw2jw7ysHvHlRGU9bXFE aaNfE1D8YprfUjeaNv3OKSpgeopPpM8h1e+SPZ1U36amtGPxRNHCpD17bRXzOxgB+Wcc BMSj/cP9XqW9nFHLv3A16J8GlJ4WWxJszzflYiWdOmps6zSRbWlxfIEJu/0yGJW9Ezxp pIQQ== X-Gm-Message-State: AOAM532Y09KIZ+E+o4eaWtfyGuXxgrazA+VEjILQWo4Fd55yF08cXuvj tx1vkEglFKexY/i05puAdEOJtCFIlR4v X-Google-Smtp-Source: ABdhPJwsf7neAAxO1z8gBsowskCoHbhgsUYl3UEiGSThsujkIogwftEA1DRC0UHx1iWXfw2Ebq84LUWTcvS+ X-Received: from r2d2-qp.c.googlers.com ([fda3:e722:ac3:10:28:9cb1:c0a8:1652]) (user=qperret job=sendgmr) by 2002:a7b:c18e:: with SMTP id y14mr495425wmi.1.1614697217407; Tue, 02 Mar 2021 07:00:17 -0800 (PST) Date: Tue, 2 Mar 2021 14:59:35 +0000 In-Reply-To: <20210302150002.3685113-1-qperret@google.com> Message-Id: <20210302150002.3685113-6-qperret@google.com> Mime-Version: 1.0 References: <20210302150002.3685113-1-qperret@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH v3 05/32] 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_150132_840390_C780629A X-CRM114-Status: GOOD ( 12.85 ) 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 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; }