Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3679957ybx; Mon, 4 Nov 2019 00:54:47 -0800 (PST) X-Google-Smtp-Source: APXvYqxk5yUWGDqsreqksqTvMhj3q2uxRG7IkW+iomnwU74RGFyS7SjU5poFD0IuUmeyo6mC/Z+S X-Received: by 2002:a17:906:cca:: with SMTP id l10mr1135739ejh.161.1572857687582; Mon, 04 Nov 2019 00:54:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572857687; cv=none; d=google.com; s=arc-20160816; b=EO9sDjy4j0AceBd3FT9Jp1VLmEb6iJLhp2ix6y6xsfX2bH96LDkNlCZiuwEoNArU7e TKpx6kfiJviUstf5OGoWvzs5z1tqqhLUI92BUeIIbsDlZ6TcAkLKh04sIA/pu+karwfa F31rEBYMZZmqKrDbvhyDhV+Op6wJLCJ86mk1UupogvV8pHOwKaOfyw6PR7d2VWq1xeND 3NM9ZbwdTRaIajeQHF08SW3MNedL0mc4j8cJ88yTXBA7bfVj6hLIEeVlwp29yP+y51YK H7e3qP8TTI8JTQGgYHT0iJf5CP8nC5sLmIGjfyO6w7D7lp2I8EEK/uBQmd0YbGq/0sqW yH3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=GYjZrWOpHSUixQhZsn7ygM+yxGXVBJ03F6mLmE9VTEE=; b=j4zjBmx9f6FN+f53N37va6vr7+P4n+PWFB4OcxMqsJdqMZX+oxYRTj1fS6YHcdcGdm BirBj0ieElLv8eI5qiCKVWYHQoemo2PyVpvVLEnnfxMqyy5tMDvRJSrovcpZ4ue8yMVW r4ZGGBKIgFeNeZ5QB0AJJR6CiitCxgFjxC7yq3UUClhaMsfRonrsH3U82Dl2sY+cDxMu x43Mb3Vbd/sBUAq9fOVIhTuPvSCGgaHZY5vUyuu4Blv2y6SYWomCOdwZL4EqfEuv4KTe NQUQA0HgRdQi2G93DvpYoVWbdUWOex0jrUPEEWIL95pPgJKSn5b5QaZyEhmRYiROAfy5 I60Q== ARC-Authentication-Results: i=1; mx.google.com; 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 b7si6985789ede.12.2019.11.04.00.54.23; Mon, 04 Nov 2019 00:54:47 -0800 (PST) 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; 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 S1727500AbfKDIxr convert rfc822-to-8bit (ORCPT + 99 others); Mon, 4 Nov 2019 03:53:47 -0500 Received: from mail-oi1-f193.google.com ([209.85.167.193]:38732 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726633AbfKDIxr (ORCPT ); Mon, 4 Nov 2019 03:53:47 -0500 Received: by mail-oi1-f193.google.com with SMTP id v186so13415641oie.5; Mon, 04 Nov 2019 00:53:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ftGbwwjNOfRweFmtue9SSD86OxwGEsa99D0pa3CKj2k=; b=HpbztpII/svDnq10yz1drtIH+d4+R+GSoswoV9RyteMMcorLbbVYVxWjQKvryyilng PoC3cCpQ3LIRwjtw5/qrbJPNq+lCcz6tY8h+9DAKhqO+UTUfCklqmQRKSpgN9xMgJyNe b/IlplB6H5c5F0bMjpxsZAY7PXm+6nwEJqqVf3z71/NIf2GU9a3Luo3lAbfhglE1By6X ZV7/6j410o5ECiXg5/dO71WRU4Z06pA4WPIToC7UeeWtwnYLNSxLIEpax+U4fuVUNfcP lBbLRYHonW26kqi348Js3ptBp7MmFpGdTTfiLB/mp63I0e8/rbsO2wwf+4ni46Bpk2HY V95Q== X-Gm-Message-State: APjAAAWzcvVjKRZhoJMS+TTmMiqZGm9qUcpU7pOjuIx4R+Yuaxkbljty 84gA9Vvo0uaWic3edABUtm1cf7wIdXEULxGIv+8= X-Received: by 2002:aca:882:: with SMTP id 124mr32125oii.54.1572857625673; Mon, 04 Nov 2019 00:53:45 -0800 (PST) MIME-Version: 1.0 References: <1572850587-20314-1-git-send-email-rppt@kernel.org> <1572850587-20314-6-git-send-email-rppt@kernel.org> In-Reply-To: <1572850587-20314-6-git-send-email-rppt@kernel.org> From: Geert Uytterhoeven Date: Mon, 4 Nov 2019 09:53:34 +0100 Message-ID: Subject: Re: [PATCH v3 05/13] m68k: mm: use pgtable-nopXd instead of 4level-fixup To: Mike Rapoport 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mike, 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 and > adjust page table manipulation macros and functions accordingly. > > Signed-off-by: Mike Rapoport > Acked-by: Greg Ungerer Thanks for your patch! The build error reported for v1 by kbuild test robot when building for sun3x is still there (m68k defconfig or sun3x_defconfig): arch/m68k/sun3x/dvma.c: In function ‘dvma_map_cpu’: arch/m68k/sun3x/dvma.c:98:33: error: passing argument 2 of ‘pmd_alloc’ from incompatible pointer type [-Werror=incompatible-pointer-types] if((pmd = pmd_alloc(&init_mm, pgd, vaddr)) == NULL) { ^~~ In file included from arch/m68k/sun3x/dvma.c:17: include/linux/mm.h:1875:61: note: expected ‘pud_t *’ {aka ‘struct *’} but argument is of type ‘pgd_t *’ {aka ‘struct *’} static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) ~~~~~~~^~~ This indeed boots fine on ARAnyM, which emulates on 68040. It would be good to have some boot testing on '020/030, too. > --- a/arch/m68k/mm/kmap.c > +++ b/arch/m68k/mm/kmap.c > @@ -196,17 +198,21 @@ void __iomem *__ioremap(unsigned long physaddr, unsigned long size, int cachefla > printk ("\npa=%#lx va=%#lx ", physaddr, virtaddr); > #endif > pgd_dir = pgd_offset_k(virtaddr); > - pmd_dir = pmd_alloc(&init_mm, pgd_dir, virtaddr); > + p4d_dir = p4d_offset(pgd_dir, virtaddr); > + pud_dir = pud_offset(p4d_dir, virtaddr); > + pmd_dir = 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 == 3 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. Perhaps this can be made more clear by reverting the order? I.e. #if CONFIG_PGTABLE_LEVELS == 3 if (CPU_IS_020_OR_030) { ... } else #endif { Or is there some better way? > pmd_dir->pmd[(virtaddr/PTRTREESIZE) & 15] = physaddr; > physaddr += PTRTREESIZE; > virtaddr += PTRTREESIZE; > size -= PTRTREESIZE; > +#endif > } else { > pte_dir = pte_alloc_kernel(pmd_dir, virtaddr); > if (!pte_dir) { > @@ -258,19 +264,24 @@ void __iounmap(void *addr, unsigned long size) > { > unsigned long virtaddr = (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 = 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 = p4d_offset(pgd_dir, virtaddr); > + pud_dir = 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 = pmd_offset(pgd_dir, virtaddr); > + pmd_dir = pmd_offset(pud_dir, virtaddr); > > if (CPU_IS_020_OR_030) { > +#if CONFIG_PGTABLE_LEVELS == 3 Likewise. > int pmd_off = (virtaddr/PTRTREESIZE) & 15; > int pmd_type = pmd_dir->pmd[pmd_off] & _DESCTYPE_MASK; > > @@ -341,14 +355,17 @@ void kernel_set_cachemode(void *addr, unsigned long size, int cmode) > > while ((long)size > 0) { > pgd_dir = pgd_offset_k(virtaddr); > - if (pgd_bad(*pgd_dir)) { > - printk("iocachemode: bad pgd(%08lx)\n", pgd_val(*pgd_dir)); > - pgd_clear(pgd_dir); > + p4d_dir = p4d_offset(pgd_dir, virtaddr); > + pud_dir = pud_offset(p4d_dir, virtaddr); > + if (pud_bad(*pud_dir)) { > + printk("iocachemode: bad pud(%08lx)\n", pud_val(*pud_dir)); > + pud_clear(pud_dir); > return; > } > - pmd_dir = pmd_offset(pgd_dir, virtaddr); > + pmd_dir = pmd_offset(pud_dir, virtaddr); > > if (CPU_IS_020_OR_030) { > +#if CONFIG_PGTABLE_LEVELS == 3 Likewise > int pmd_off = (virtaddr/PTRTREESIZE) & 15; > > if ((pmd_dir->pmd[pmd_off] & _DESCTYPE_MASK) == _PAGE_PRESENT) { Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds