Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp270689yba; Thu, 25 Apr 2019 23:02:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvWli1TSIJXjpUYee/JsQe7XROss5x3rD1+Ay8hm5FAG/c1G0t/Bqqy5oxO78gbCQ7OVSk X-Received: by 2002:a63:2a8f:: with SMTP id q137mr41917749pgq.31.1556258546216; Thu, 25 Apr 2019 23:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556258546; cv=none; d=google.com; s=arc-20160816; b=UdJ+iydv30FGAnAZfBA9+9yuDoQeAkBrhoxWhkOJaz+q767NrWKWxHSXZ+ctqL2D37 C5Y6FneMaJE39otuiHfdSzAxHn+w4/gL5xarH6LuADWzkeDRt+pOXyKRI4BwHWBxdZOY 0PaWR2F8KlV8HlkzgqDK4lZnTn/A9W5UhVKyMe2H+b5IWIjszgapLQ8lm7xPCGPyI7Jh XGM1LL/7qEFRfH4G9UF6ifdTxZmmnN/8Cy+RGStqSfZYWterXcF5WJ9lRaDLiRVvaX3Z qPON20ljcJEt0j5EWaqTldM/PRwDXAxessQ9w1lw3XIz6BvhXcDuMGYe30lc+hiYIDYF sICA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=Pk5RQ9wCD9+Ck6hgpF4fQOfimKb1UKnJCQj5/13kDgQ=; b=YP0Z/2TNdOZFaaf2erZmwwgvx31j0vGPO7XkXIEB0KltW/tSdnLTbMbq5wFMoVSGov LHhtixY2K3y7X48Zo85KEibzYCMA3H0asLJMb1WJHY7Kd2kG/fQZRQn5LUBahB6565wC +QcRgpYLSWpT+pJ8P2ghNlIlqzeI4USMb6na2r+jCzTYXk2OxHZxQS52JODixsjCgxez xBvBb967aEL0exCBG2CoLaUxuDfBGUlU0UCoGeyYmNAt0lu2xJHgKrnCR5C2CKTQgcCS nrhFWe3q/4yfH3hXlLXzgg/oZqpXJoWJj6A+SD+zo+Awx+rIyJx3vMy7zY1NvD88YqdN EyoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=rWqy9a9x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id be4si8901151plb.131.2019.04.25.23.02.11; Thu, 25 Apr 2019 23:02:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=rWqy9a9x; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727584AbfDZGAy (ORCPT + 99 others); Fri, 26 Apr 2019 02:00:54 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:3025 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726821AbfDZF7r (ORCPT ); Fri, 26 Apr 2019 01:59:47 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 44r3Ks2V8jz9v1vM; Fri, 26 Apr 2019 07:59:45 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=rWqy9a9x; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id AeOdWqkp6QY3; Fri, 26 Apr 2019 07:59:45 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 44r3Ks1SQXz9v1tj; Fri, 26 Apr 2019 07:59:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1556258385; bh=Pk5RQ9wCD9+Ck6hgpF4fQOfimKb1UKnJCQj5/13kDgQ=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=rWqy9a9xqhleBO6dRS4o6aoPc0saWR1arKZQjBLNHP9p5TuUckOZormXe2zs9Iuzw sz4tWJ480SuhuZMv1nQj0Ydwcpb5nCKcHHo/EKORP6Fy9kexnT0xfouvnYZ+Hp2f1c AiLnbqoAUiuOVdmYmx5FcZiA9sgrq9eYSTOwDvm8= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 1A2028B807; Fri, 26 Apr 2019 07:59:46 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ueT4PrQv3fE9; Fri, 26 Apr 2019 07:59:46 +0200 (CEST) Received: from po16846vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.6]) by messagerie.si.c-s.fr (Postfix) with ESMTP id EC3508B74C; Fri, 26 Apr 2019 07:59:45 +0200 (CEST) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id CB4D966276; Fri, 26 Apr 2019 05:59:45 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v2 10/17] powerpc/mm: add a helper to populate hugepd To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , aneesh.kumar@linux.ibm.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Fri, 26 Apr 2019 05:59:45 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patchs adds a subarch helper to populate hugepd. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/book3s/64/hugetlb.h | 5 +++++ arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h | 8 ++++++++ arch/powerpc/include/asm/nohash/hugetlb-book3e.h | 6 ++++++ arch/powerpc/mm/hugetlbpage.c | 20 +------------------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/hugetlb.h b/arch/powerpc/include/asm/book3s/64/hugetlb.h index 7c99f018f7b5..5537046b4c78 100644 --- a/arch/powerpc/include/asm/book3s/64/hugetlb.h +++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h @@ -100,6 +100,11 @@ static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr, return hugepd_page(hpd) + idx; } +static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift) +{ + *hpdp = __hugepd(__pa(new) | HUGEPD_VAL_BITS | (shift_to_mmu_psize(pshift) << 2)); +} + void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr); #endif diff --git a/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h b/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h index 27acd2ad2176..d9aa72fd76b3 100644 --- a/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h +++ b/arch/powerpc/include/asm/nohash/32/hugetlb-8xx.h @@ -2,6 +2,8 @@ #ifndef _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H #define _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H +#define PAGE_SHIFT_8M 23 + static inline pte_t *hugepd_page(hugepd_t hpd) { VM_BUG_ON(!hugepd_ok(hpd)); @@ -28,4 +30,10 @@ static inline void flush_hugetlb_page(struct vm_area_struct *vma, flush_tlb_page(vma, vmaddr); } +static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift) +{ + *hpdp = __hugepd(__pa(new) | _PMD_USER | _PMD_PRESENT | + (pshift == PAGE_SHIFT_8M ? _PMD_PAGE_8M : _PMD_PAGE_512K)); +} + #endif /* _ASM_POWERPC_NOHASH_32_HUGETLB_8XX_H */ diff --git a/arch/powerpc/include/asm/nohash/hugetlb-book3e.h b/arch/powerpc/include/asm/nohash/hugetlb-book3e.h index e94f1cd048ee..51439bcfe313 100644 --- a/arch/powerpc/include/asm/nohash/hugetlb-book3e.h +++ b/arch/powerpc/include/asm/nohash/hugetlb-book3e.h @@ -28,4 +28,10 @@ static inline pte_t *hugepte_offset(hugepd_t hpd, unsigned long addr, void flush_hugetlb_page(struct vm_area_struct *vma, unsigned long vmaddr); +static inline void hugepd_populate(hugepd_t *hpdp, pte_t *new, unsigned int pshift) +{ + /* We use the old format for PPC_FSL_BOOK3E */ + *hpdp = __hugepd(((unsigned long)new & ~PD_HUGE) | pshift); +} + #endif /* _ASM_POWERPC_NOHASH_HUGETLB_BOOK3E_H */ diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index ef0f5b8e87fd..0322a0617371 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -26,12 +26,6 @@ #include #include -#define PAGE_SHIFT_64K 16 -#define PAGE_SHIFT_512K 19 -#define PAGE_SHIFT_8M 23 -#define PAGE_SHIFT_16M 24 -#define PAGE_SHIFT_16G 34 - bool hugetlb_disabled = false; unsigned int HPAGE_SHIFT; @@ -95,19 +89,7 @@ static int __hugepte_alloc(struct mm_struct *mm, hugepd_t *hpdp, for (i = 0; i < num_hugepd; i++, hpdp++) { if (unlikely(!hugepd_none(*hpdp))) break; - else { -#ifdef CONFIG_PPC_BOOK3S_64 - *hpdp = __hugepd(__pa(new) | HUGEPD_VAL_BITS | - (shift_to_mmu_psize(pshift) << 2)); -#elif defined(CONFIG_PPC_8xx) - *hpdp = __hugepd(__pa(new) | _PMD_USER | - (pshift == PAGE_SHIFT_8M ? _PMD_PAGE_8M : - _PMD_PAGE_512K) | _PMD_PRESENT); -#else - /* We use the old format for PPC_FSL_BOOK3E */ - *hpdp = __hugepd(((unsigned long)new & ~PD_HUGE) | pshift); -#endif - } + hugepd_populate(hpdp, new, pshift); } /* If we bailed from the for loop early, an error occurred, clean up */ if (i < num_hugepd) { -- 2.13.3