From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 5C3E8CA9ECF for ; Mon, 4 Nov 2019 09:48:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 155D521D7D for ; Mon, 4 Nov 2019 09:48:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="yIO+RdRi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 155D521D7D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9D9496B0005; Mon, 4 Nov 2019 04:48:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 98B776B0006; Mon, 4 Nov 2019 04:48:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87A0E6B0007; Mon, 4 Nov 2019 04:48:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0050.hostedemail.com [216.40.44.50]) by kanga.kvack.org (Postfix) with ESMTP id 6E3C06B0005 for ; Mon, 4 Nov 2019 04:48:03 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 21768181AEF1E for ; Mon, 4 Nov 2019 09:48:03 +0000 (UTC) X-FDA: 76118118846.02.lead54_8070e22459d0e X-HE-Tag: lead54_8070e22459d0e X-Filterd-Recvd-Size: 9645 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Mon, 4 Nov 2019 09:48:02 +0000 (UTC) Received: from rapoport-lnx (nesher1.haifa.il.ibm.com [195.110.40.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 703FA222D2; Mon, 4 Nov 2019 09:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572860881; bh=jF2dTw4x+geuuqWT+rNLEAExdkU6oqK6ll5Aip/G7wo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=yIO+RdRi15/vhMR8gf577AKF/lpxu4XVhUJZy1DLQjBpIac45yVLkW8bxFv1JrMxI yZ1wC+sVzO1/hBGimU5x16z9OqkqLi949PDdXnnhKpHXL9oAbagRWpOMkzhiQoM5bs EavnCVX+JUJOuq3PVNevDE54nL9/PZK4/k8P5qpU= Date: Mon, 4 Nov 2019 11:47:49 +0200 From: Mike Rapoport To: Geert Uytterhoeven Cc: Linux MM , Andrew Morton , Anton Ivanov , Arnd Bergmann , "David S. Miller" , Greentime Hu , Greg Ungerer , Helge Deller , "James E.J. Bottomley" , Jeff Dike , "Kirill A. Shutemov" , Linus Torvalds , Mark Salter , Matt Turner , Michal Simek , Peter Rosin , Richard Weinberger , Rolf Eike Beer , Russell King , Sam Creasey , Vincent Chen , Vineet Gupta , alpha , Linux-Arch , Linux ARM , linux-c6x-dev@linux-c6x.org, Linux Kernel Mailing List , linux-m68k , Parisc List , linux-um@lists.infradead.org, sparclinux , Mike Rapoport Subject: Re: [PATCH v3 05/13] m68k: mm: use pgtable-nopXd instead of 4level-fixup Message-ID: <20191104094748.GB23288@rapoport-lnx> References: <1572850587-20314-1-git-send-email-rppt@kernel.org> <1572850587-20314-6-git-send-email-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Nov 04, 2019 at 09:53:34AM +0100, Geert Uytterhoeven wrote: > Hi Mike, >=20 > On Mon, Nov 4, 2019 at 7:57 AM Mike Rapoport wrote: > > From: Mike Rapoport > > m68k has two or three levels of page tables and can use appropriate > > pgtable-nopXd and folding of the upper layers. > > > > Replace usage of include/asm-generic/4level-fixup.h and explicit > > definitions of __PAGETABLE_PxD_FOLDED in m68k with > > include/asm-generic/pgtable-nopmd.h for two-level configurations and = with > > include/asm-generic/pgtable-nopud.h for three-lelve configurations an= d > > adjust page table manipulation macros and functions accordingly. > > > > Signed-off-by: Mike Rapoport > > Acked-by: Greg Ungerer >=20 > Thanks for your patch! >=20 > The build error reported for v1 by kbuild test robot when building for > sun3x is still there (m68k defconfig or sun3x_defconfig): >=20 > arch/m68k/sun3x/dvma.c: In function =E2=80=98dvma_map_cpu=E2=80=99: > arch/m68k/sun3x/dvma.c:98:33: error: passing argument 2 of > =E2=80=98pmd_alloc=E2=80=99 from incompatible pointer type > [-Werror=3Dincompatible-pointer-types] > if((pmd =3D pmd_alloc(&init_mm, pgd, vaddr)) =3D=3D NULL) { > ^~~ > In file included from arch/m68k/sun3x/dvma.c:17: > include/linux/mm.h:1875:61: note: expected =E2=80=98pud_t *=E2=80=99= {aka =E2=80=98struct > *=E2=80=99} but argument is of type =E2=80=98pgd_t *=E2=80=99= {aka =E2=80=98struct > *=E2=80=99} > static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, > unsigned long address) > ~~~~~~~^~~ The initial report was against older mmotm (base: git://git.cmpxchg.org/linux-mmotm.git master) and I presumed this was the cause of the error. Will fix in v4. =20 > This indeed boots fine on ARAnyM, which emulates on 68040. > It would be good to have some boot testing on '020/030, too. =20 To be honest, I have no idea how to to that :) > > --- a/arch/m68k/mm/kmap.c > > +++ b/arch/m68k/mm/kmap.c >=20 > > @@ -196,17 +198,21 @@ void __iomem *__ioremap(unsigned long physaddr,= unsigned long size, int cachefla > > printk ("\npa=3D%#lx va=3D%#lx ", physaddr, v= irtaddr); > > #endif > > pgd_dir =3D pgd_offset_k(virtaddr); > > - pmd_dir =3D pmd_alloc(&init_mm, pgd_dir, virtaddr); > > + p4d_dir =3D p4d_offset(pgd_dir, virtaddr); > > + pud_dir =3D pud_offset(p4d_dir, virtaddr); > > + pmd_dir =3D pmd_alloc(&init_mm, pud_dir, virtaddr); > > if (!pmd_dir) { > > printk("ioremap: no mem for pmd_dir\n"); > > return NULL; > > } > > > > if (CPU_IS_020_OR_030) { > > +#if CONFIG_PGTABLE_LEVELS =3D=3D 3 >=20 > This check puzzled me a bit: when we get here, CONFIG_PGTABLE_LEVELS is > always true. > However, the check cannot be removed, as the code it protects fails to = compile > when building for Coldfire. >=20 > Perhaps this can be made more clear by reverting the order? > I.e. >=20 > #if CONFIG_PGTABLE_LEVELS =3D=3D 3 > if (CPU_IS_020_OR_030) { > ... > } else > #endif > { >=20 > Or is there some better way? I think reverting the order is fine. Here it's a bit ugly because of '} else {', but for the other cases below it will fine. =20 > > pmd_dir->pmd[(virtaddr/PTRTREESIZE) & 15] =3D= physaddr; > > physaddr +=3D PTRTREESIZE; > > virtaddr +=3D PTRTREESIZE; > > size -=3D PTRTREESIZE; > > +#endif > > } else { > > pte_dir =3D pte_alloc_kernel(pmd_dir, virtadd= r); > > if (!pte_dir) { > > @@ -258,19 +264,24 @@ void __iounmap(void *addr, unsigned long size) > > { > > unsigned long virtaddr =3D (unsigned long)addr; > > pgd_t *pgd_dir; > > + p4d_t *p4d_dir; > > + pud_t *pud_dir; > > pmd_t *pmd_dir; > > pte_t *pte_dir; > > > > while ((long)size > 0) { > > pgd_dir =3D pgd_offset_k(virtaddr); > > - if (pgd_bad(*pgd_dir)) { > > - printk("iounmap: bad pgd(%08lx)\n", pgd_val(*= pgd_dir)); > > - pgd_clear(pgd_dir); > > + p4d_dir =3D p4d_offset(pgd_dir, virtaddr); > > + pud_dir =3D pud_offset(p4d_dir, virtaddr); > > + if (pud_bad(*pud_dir)) { > > + printk("iounmap: bad pgd(%08lx)\n", pud_val(*= pud_dir)); > > + pud_clear(pud_dir); > > return; > > } > > - pmd_dir =3D pmd_offset(pgd_dir, virtaddr); > > + pmd_dir =3D pmd_offset(pud_dir, virtaddr); > > > > if (CPU_IS_020_OR_030) { > > +#if CONFIG_PGTABLE_LEVELS =3D=3D 3 >=20 > Likewise. >=20 > > int pmd_off =3D (virtaddr/PTRTREESIZE) & 15; > > int pmd_type =3D pmd_dir->pmd[pmd_off] & _DES= CTYPE_MASK; > > >=20 > > @@ -341,14 +355,17 @@ void kernel_set_cachemode(void *addr, unsigned = long size, int cmode) > > > > while ((long)size > 0) { > > pgd_dir =3D pgd_offset_k(virtaddr); > > - if (pgd_bad(*pgd_dir)) { > > - printk("iocachemode: bad pgd(%08lx)\n", pgd_v= al(*pgd_dir)); > > - pgd_clear(pgd_dir); > > + p4d_dir =3D p4d_offset(pgd_dir, virtaddr); > > + pud_dir =3D pud_offset(p4d_dir, virtaddr); > > + if (pud_bad(*pud_dir)) { > > + printk("iocachemode: bad pud(%08lx)\n", pud_v= al(*pud_dir)); > > + pud_clear(pud_dir); > > return; > > } > > - pmd_dir =3D pmd_offset(pgd_dir, virtaddr); > > + pmd_dir =3D pmd_offset(pud_dir, virtaddr); > > > > if (CPU_IS_020_OR_030) { > > +#if CONFIG_PGTABLE_LEVELS =3D=3D 3 >=20 > Likewise >=20 > > int pmd_off =3D (virtaddr/PTRTREESIZE) & 15; > > > > if ((pmd_dir->pmd[pmd_off] & _DESCTYPE_MASK) = =3D=3D _PAGE_PRESENT) { >=20 > Gr{oetje,eeting}s, >=20 > Geert >=20 > --=20 > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-= m68k.org >=20 > In personal conversations with technical people, I call myself a hacker= . But > when I'm talking to journalists I just say "programmer" or something li= ke that. > -- Linus Torvalds --=20 Sincerely yours, Mike.