Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp403502img; Wed, 20 Mar 2019 03:09:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZYnCUiDBcXZbdtvQZsZ2i+ycUwT1H42hpYMWyIaKgoQer9AWmRjBmnbHkycs0eTJxzjt5 X-Received: by 2002:a63:450f:: with SMTP id s15mr6466668pga.157.1553076582227; Wed, 20 Mar 2019 03:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553076582; cv=none; d=google.com; s=arc-20160816; b=C7j/lM/4PxoyKH2prUgk6vCQqmrz02wZORTmJ+deM3Y4tKq4CBbGo37G57SWNzCR2v 4Z3hd6mK7qlssTXbTgmDkS6syohlJe3RNQ+1geD8+WxpV9YxrHrXccPZebDosvtYCcxy vuMbNwlenYTRmx2V2ZtaqiVg88Rxok14tkJUOnnCHfDJuaAuZgApG75MrNfgC3+M6ld3 adFMFQkLAtMotSBRm3RI8yOxR+6erZK5en5An6EY/2HazM+5V3OnrRryj2YvPD+yH9KJ fECPQW2arAPvikp2MYWwGjgSHGMpqNAsWGj3aVuK3/bmF5iZH135lJKx2WnfvgG9RzT2 nWiQ== 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=vudUPerMLQi3dd/zw5E0qPtrcqQHJnlkft2XxIn5fdE=; b=jUr/q2B/JU/wPUspt8ORspqBI7xf5CWRMUW2VM9HdReQvPsmoOSE16456g8b/08d27 9CpgW2iqlajV3OEHp7hF48KkLwrZcdWM0TljDnM+z3o0cQNeybhQ3Y6G5aVNRRxF1B3t UvHxW3occ/9V44Fy7LHEibYq9cnE1+bt0HKZglSLOn+w5GfXT6c3gHcEtzouF/4/NTfp jhkCxEf0OjSzEonzhsNzpmHc0AVRyqm70DyOYuN8RshtpHx9ipWQawLfDPvHzrshfzOg tsaWHMR7N2wS3JmhSUaXaz/6kChXGPYfWKa1aaWQldMHngJKxYBlfgt3ASpdyZrFnkFg EfXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=EN0Qv39N; 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 f7si1285280pgs.316.2019.03.20.03.09.26; Wed, 20 Mar 2019 03:09:42 -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=EN0Qv39N; 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 S1727991AbfCTKIM (ORCPT + 99 others); Wed, 20 Mar 2019 06:08:12 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:8626 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727690AbfCTKGu (ORCPT ); Wed, 20 Mar 2019 06:06:50 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 44PQYz3P3qz9vC02; Wed, 20 Mar 2019 11:06:47 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=EN0Qv39N; 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 CIAH3mzzheRG; Wed, 20 Mar 2019 11:06:47 +0100 (CET) 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 44PQYz2Cfrz9vByx; Wed, 20 Mar 2019 11:06:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1553076407; bh=vudUPerMLQi3dd/zw5E0qPtrcqQHJnlkft2XxIn5fdE=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=EN0Qv39NEobTKZbM7BSI5/z2axMW5Tkn7YmmKz+6/wz0RcICQGysDUiUW4r8elKDB iW+kY8b/Iad+E/g7BUZLY7h9H6Yc8JJOVCflulXmwlvz9pWAz7G6Rrj9pDjvWG4zf1 PKz3oyWqp4kSwkUVetOEJKUT/15h0CoXC7wiirtQ= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 692CB8B918; Wed, 20 Mar 2019 11:06:48 +0100 (CET) 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 JIEmtOOUOzOU; Wed, 20 Mar 2019 11:06:48 +0100 (CET) Received: from po16846vm.idsi0.si.c-s.fr (unknown [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 464CF8B911; Wed, 20 Mar 2019 11:06:48 +0100 (CET) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 289B063AEF; Wed, 20 Mar 2019 10:06:48 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 12/27] 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: Wed, 20 Mar 2019 10:06:48 +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 2f9cf2bc601c..177c81079209 100644 --- a/arch/powerpc/include/asm/book3s/64/hugetlb.h +++ b/arch/powerpc/include/asm/book3s/64/hugetlb.h @@ -101,6 +101,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 209e6a219835..eb90c2db7601 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) { if (WARN_ON(!hugepd_ok(hpd))) @@ -29,4 +31,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 29d1568c7775..26a57ebaf5cf 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