Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3565028ybb; Mon, 23 Mar 2020 03:34:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs0atIdsE4tCKxiFCwuk0J79Hv9rtR23L9dluQ+pBt3l8LxYubKHueu21ML454YKXevbbd8 X-Received: by 2002:a9d:12cc:: with SMTP id g70mr16471010otg.115.1584959641306; Mon, 23 Mar 2020 03:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584959641; cv=none; d=google.com; s=arc-20160816; b=fwK+euJFxXSNnnscjtqiwWQ8utFPw/3Q0gLxi5ILw+09BKSypoYUzkszODdF/65luG sDmKhv2UBZk5ov2xGO1O+88525bOZPteekfUiuGSMZ3rPp8DMFz8MrxeFEh7HbY+SMom 7hNo9UU//tmYKNaU3SVAJWE1corcQEk/Jwp73vlE995kFpEu3dV65DZ8Ydwrw0z0z0Hh W8IdwLVVnMSzvz12WD5tmUESgPJ8CCGx30JePURBSiykAF2HXd/wYNezKm1Xz8GbobhR xyVLb0/+InB46hgj1WRtC16DROGSh5VEAHa3X+/apwm4rbM3ywmc934ZCXsD1mFrHMrC 3WGw== 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 :dkim-signature; bh=59Ut9IY4o/q5MZFN98JGtJfE2YyEe3hnu26+XZPTOIo=; b=nOemk+24CJDT+VstQ/jmvuhUfcPxwLhqQfRuifMX3BrvV0VT94xgoywQdnCgGHFUHF V4hEg9XLFn45LNf0k+CDIQB+Xx+PEcGFuY0yT6+oLs/b5Y87CfR77CjOZszsCrg6zR/e 6dl+p5TTclfMaBcFQrV9HEO92Z9qLY6PM4O9cYl6rHjDEnR5sh9U8tK5oB99yb64OPFf DTXsk+pBi6kLRaqAKph+PTObcbcbRxKJ+rRb/DuG/DFia9ltUzlR/GZSeD31oYzlPK+m UBG8cD0nPyUY3jEtlA02IrrksuPJtthf0BePN7GMFAiuoia432hUmjewOBtMkxd7Etcz zp3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="lQzO1/oM"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si3244058otk.166.2020.03.23.03.33.33; Mon, 23 Mar 2020 03:34:01 -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=@gmail.com header.s=20161025 header.b="lQzO1/oM"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727908AbgCWKci (ORCPT + 99 others); Mon, 23 Mar 2020 06:32:38 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40753 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727829AbgCWKci (ORCPT ); Mon, 23 Mar 2020 06:32:38 -0400 Received: by mail-wm1-f65.google.com with SMTP id a81so8385832wmf.5; Mon, 23 Mar 2020 03:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=59Ut9IY4o/q5MZFN98JGtJfE2YyEe3hnu26+XZPTOIo=; b=lQzO1/oMkjJlrnRwkhpmsHy8gUzTzpBjViiDOt1dlcveGJijRmQZy0ei+PbS1diI1L OucC4Hl8fpR+/xIAcYduI8ZL0RsFPGN4Ucf9PepZYb1VtlU1iEPAzp5KMHa1+kwLdTvA 7fQAts/DtpCIgIf9kKffMYLxAVmUI+sG9NR3JAnTBLedGl7PiKaOA9IP506C55ioOEVf +fZ2N5c9AFJb8O7fy5M1p41MheEf2MaGSnV5hl73wfpd71PS4TwdmQjDjaqXaPXFR2cl L6HebqUBoBZc/KL2E/y9fDjrY9FSzaVyXeLsvgpBHd7JEAGyXjsUtSGudWa4uvzNywDs JqLQ== 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=59Ut9IY4o/q5MZFN98JGtJfE2YyEe3hnu26+XZPTOIo=; b=GcAWT94mhrHy/PZNNFaZD0nOOVp3Tk6587NxQ43npcbKhnqQZdiKbBHw29JUXwFpB1 d6ir9hOrik7scGkJkgIkgdjjAfMG+7eLo/0zOhD1wxlKxNKdMVEcIKiZ+glhcD8011Dy LRxXOJNNscVUHOwa33XqjFu4S+MsH0v9Iy0o0IgX8YTKSL8VijO89Tacq5yvRDh+Jym2 dYLW4yq93SlbxfV3CkTRIej52JGV9fFiEfW+3wZsAdhObM+VaeKJ4mf8b3y5gkvVmBZY jE2N08W5nfPc8mIp2JzsrUcOdA6ZplgOdBGQsMGaVkLMW05MNcNMrDpowJMGxSXPLpdI Hp0g== X-Gm-Message-State: ANhLgQ28ZUXUo/oemQR+XB/LKrLVGJ3E/JHL0vZ5gxjroRjtp0gIu32L bbBOdL6hztPLdRiyG741zbcU0jLUhIR7MvrezjY= X-Received: by 2002:a05:600c:228f:: with SMTP id 15mr7693466wmf.140.1584959554995; Mon, 23 Mar 2020 03:32:34 -0700 (PDT) MIME-Version: 1.0 References: <20200224193436.26860-1-atish.patra@wdc.com> In-Reply-To: From: David Abdurachmanov Date: Mon, 23 Mar 2020 12:31:58 +0200 Message-ID: Subject: Re: [PATCH] RISC-V: Move all address space definition macros to one place To: Palmer Dabbelt Cc: Atish Patra , "linux-kernel@vger.kernel.org List" , Albert Ou , nickhu@andestech.com, Bjorn Topel , Anup Patel , stable@vger.kernel.org, Mike Rapoport , Thomas Gleixner , Paul Walmsley , Greentime Hu , akpm@linux-foundation.org, linux-riscv Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 21, 2020 at 10:29 PM David Abdurachmanov wrote: > > On Fri, Mar 6, 2020 at 2:20 AM Palmer Dabbelt = wrote: > > > > On Mon, 24 Feb 2020 11:34:36 PST (-0800), Atish Patra wrote: > > > If both CONFIG_KASAN and CONFIG_SPARSEMEM_VMEMMAP are set, we get the > > > following compilation error. > > > > > > --------------------------------------------------------------- > > > ./arch/riscv/include/asm/pgtable-64.h: In function =E2=80=98pud_page= =E2=80=99: > > > ./include/asm-generic/memory_model.h:54:29: error: =E2=80=98vmemmap= =E2=80=99 undeclared > > > (first use in this function); did you mean =E2=80=98mem_map=E2=80=99? > > > #define __pfn_to_page(pfn) (vmemmap + (pfn)) > > > ^~~~~~~ > > > ./include/asm-generic/memory_model.h:82:21: note: in expansion of > > > macro =E2=80=98__pfn_to_page=E2=80=99 > > > > > > #define pfn_to_page __pfn_to_page > > > ^~~~~~~~~~~~~ > > > ./arch/riscv/include/asm/pgtable-64.h:70:9: note: in expansion of mac= ro > > > =E2=80=98pfn_to_page=E2=80=99 > > > return pfn_to_page(pud_val(pud) >> _PAGE_PFN_SHIFT); > > > --------------------------------------------------------------- > > > > > > Fix the compliation errors by moving all the address space definition > > > macros before including pgtable-64.h. > > > > > > Cc: stable@vger.kernel.org > > > Fixes: 8ad8b72721d0 (riscv: Add KASAN support) > > > > > > Signed-off-by: Atish Patra > > > --- > > > arch/riscv/include/asm/pgtable.h | 78 +++++++++++++++++-------------= -- > > > 1 file changed, 41 insertions(+), 37 deletions(-) > > > > > > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/as= m/pgtable.h > > > index 453afb0a570a..4f6ee48a42e8 100644 > > > --- a/arch/riscv/include/asm/pgtable.h > > > +++ b/arch/riscv/include/asm/pgtable.h > > > @@ -19,6 +19,47 @@ > > > #include > > > #include > > > > > > +#ifdef CONFIG_MMU > > > + > > > +#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) > > > +#define VMALLOC_END (PAGE_OFFSET - 1) > > > +#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) > > > + > > > +#define BPF_JIT_REGION_SIZE (SZ_128M) > > > +#define BPF_JIT_REGION_START (PAGE_OFFSET - BPF_JIT_REGION_SIZE) > > > +#define BPF_JIT_REGION_END (VMALLOC_END) > > > + > > > +/* > > > + * Roughly size the vmemmap space to be large enough to fit enough > > > + * struct pages to map half the virtual address space. Then > > > + * position vmemmap directly below the VMALLOC region. > > > + */ > > > +#define VMEMMAP_SHIFT \ > > > + (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT) > > > +#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT) > > > +#define VMEMMAP_END (VMALLOC_START - 1) > > > +#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) > > > + > > > +/* > > > + * Define vmemmap for pfn_to_page & page_to_pfn calls. Needed if ker= nel > > > + * is configured with CONFIG_SPARSEMEM_VMEMMAP enabled. > > > + */ > > > +#define vmemmap ((struct page *)VMEMMAP_START) > > > + > > > +#define PCI_IO_SIZE SZ_16M > > > +#define PCI_IO_END VMEMMAP_START > > > +#define PCI_IO_START (PCI_IO_END - PCI_IO_SIZE) > > > + > > > +#define FIXADDR_TOP PCI_IO_START > > > +#ifdef CONFIG_64BIT > > > +#define FIXADDR_SIZE PMD_SIZE > > > +#else > > > +#define FIXADDR_SIZE PGDIR_SIZE > > > +#endif > > > +#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) > > > + > > > +#endif > > > + > > > #ifdef CONFIG_64BIT > > > #include > > > #else > > > @@ -90,31 +131,6 @@ extern pgd_t swapper_pg_dir[]; > > > #define __S110 PAGE_SHARED_EXEC > > > #define __S111 PAGE_SHARED_EXEC > > > > > > -#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1) > > > -#define VMALLOC_END (PAGE_OFFSET - 1) > > > -#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE) > > > - > > > -#define BPF_JIT_REGION_SIZE (SZ_128M) > > > -#define BPF_JIT_REGION_START (PAGE_OFFSET - BPF_JIT_REGION_SIZE) > > > -#define BPF_JIT_REGION_END (VMALLOC_END) > > > - > > > -/* > > > - * Roughly size the vmemmap space to be large enough to fit enough > > > - * struct pages to map half the virtual address space. Then > > > - * position vmemmap directly below the VMALLOC region. > > > - */ > > > -#define VMEMMAP_SHIFT \ > > > - (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT) > > > -#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT) > > > -#define VMEMMAP_END (VMALLOC_START - 1) > > > -#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE) > > > - > > > -/* > > > - * Define vmemmap for pfn_to_page & page_to_pfn calls. Needed if ker= nel > > > - * is configured with CONFIG_SPARSEMEM_VMEMMAP enabled. > > > - */ > > > -#define vmemmap ((struct page *)VMEMMAP_START) > > > - > > > static inline int pmd_present(pmd_t pmd) > > > { > > > return (pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROT_NONE)); > > > @@ -452,18 +468,6 @@ static inline int ptep_clear_flush_young(struct = vm_area_struct *vma, > > > #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }= ) > > > #define __swp_entry_to_pte(x) ((pte_t) { (x).val }) > > > > > > -#define PCI_IO_SIZE SZ_16M > > > -#define PCI_IO_END VMEMMAP_START > > > -#define PCI_IO_START (PCI_IO_END - PCI_IO_SIZE) > > > - > > > -#define FIXADDR_TOP PCI_IO_START > > > -#ifdef CONFIG_64BIT > > > -#define FIXADDR_SIZE PMD_SIZE > > > -#else > > > -#define FIXADDR_SIZE PGDIR_SIZE > > > -#endif > > > -#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) > > > - > > > /* > > > * Task size is 0x4000000000 for RV64 or 0x9fc00000 for RV32. > > > * Note that PGDIR_SIZE must evenly divide TASK_SIZE. > > > > While this isn't technically a fix, I'm inclined to target it for the R= Cs just > > to avoid conflicts. I've put it on for-next now so the builders have s= ome time > > to chew on things, as I don't want to put in a non-fix too quickly. > > I hit the same issue in Fedora/RISCV while building kernel-5.6.0-0.rc6, a= nd > we don't have KASAN selected. We do have CONFIG_SPARSEMEM_VMEMMAP > selected. > > I will try this patch tomorrow. > Confirmed to solve my build errors with kernel in Fedora/RISCV. david