From patchwork Tue Mar 27 13:15:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 10310037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1474F6037D for ; Tue, 27 Mar 2018 13:23:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05E6A29BA2 for ; Tue, 27 Mar 2018 13:23:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEC9529C79; Tue, 27 Mar 2018 13:23:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABE3C29C6E for ; Tue, 27 Mar 2018 13:23:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752712AbeC0NQO (ORCPT ); Tue, 27 Mar 2018 09:16:14 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:55018 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752447AbeC0NQN (ORCPT ); Tue, 27 Mar 2018 09:16:13 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DB7B8165D; Tue, 27 Mar 2018 06:16:12 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1AEFB3F24A; Tue, 27 Mar 2018 06:16:09 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, cdall@kernel.org, marc.zyngier@arm.com, punit.agrawal@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, ard.biesheuvel@linaro.org, peter.maydell@linaro.org, kristina.martsenko@arm.com, mark.rutland@arm.com, Suzuki K Poulose , Steve Capper Subject: [PATCH v2 04/17] arm64: Refactor pud_huge for reusability Date: Tue, 27 Mar 2018 14:15:14 +0100 Message-Id: <1522156531-28348-5-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> References: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make pud_huge reusable for stage2 tables, independent of the stage1 levels. Cc: Steve Capper Cc: Mark Rutland Cc: Will Deacon Cc: Catalin Marinas Cc: Christoffer Dall Signed-off-by: Suzuki K Poulose Reviewed-by: Julien Grall --- arch/arm64/include/asm/pgtable.h | 5 +++++ arch/arm64/mm/hugetlbpage.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 5e22503..4a16c11 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -479,6 +479,11 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd) #define __raw_pud_bad(pud) (!(pud_val(pud) & PUD_TABLE_BIT)) #define __raw_pud_present(pud) pte_present(pud_pte(pud)) +static inline int __raw_pud_huge(pud_t pud) +{ + return pud_val(pud) && !(pud_val(pud) & PUD_TABLE_BIT); +} + static inline void __raw_set_pud(pud_t *pudp, pud_t pud) { WRITE_ONCE(*pudp, pud); diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index ecc6818..3f4bb43 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -35,7 +35,7 @@ int pmd_huge(pmd_t pmd) int pud_huge(pud_t pud) { #ifndef __PAGETABLE_PMD_FOLDED - return pud_val(pud) && !(pud_val(pud) & PUD_TABLE_BIT); + return __raw_pud_huge(pud); #else return 0; #endif