Received: by 2002:a17:90a:1609:0:0:0:0 with SMTP id n9csp2403028pja; Thu, 26 Mar 2020 14:44:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt033wCB7b1A2DYPudZG9tUeGQd9AmM1ZNqJxbEo8vfQPm2IgM4Rwcs/81gUQEb2hLHTkwB X-Received: by 2002:a9d:6b98:: with SMTP id b24mr7779881otq.242.1585259056499; Thu, 26 Mar 2020 14:44:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585259056; cv=none; d=google.com; s=arc-20160816; b=HrthKkIQRYXq+e+6ELRztq7zpdp10kpIuUOpiWx8cUnkK5D/kCfJ6UFmT2N0YXkQ8/ 8zbfAR1teG9UkK1BQLljG4McE0BSAGTDmCRjs59YCXrvH/8XqVxKbY2PPrjRwZHu9xCk zoKHoHlIpZwFFnpB77+DqDOs1huk8gfCLisSvN1i8L1Cc+YrYUYLw43Zg0/EaefI+ltS 0x7732tfKCk1MxfhtcwYYMOVYTdEOQb4xAcffdItAtiGD+ryKeainICbSN6n3oOhYwMJ wP+OBEOV87AkUc6U768/WtJXowivCEVGoZ4/Ccl6OPmQSU4D+JHtYEiKgEttSlmU6q1s Yo4Q== 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=f1NDn439r2NKX2oz5ZXFZ71Km/k0SiSxc8ZOwV4UNkM=; b=qV+bXSdWI8cUrFwojYvR+K03J35y+wpEtvSVdjfwO3dB71/orOH9WmR1sJVK6Mm26q 1ydn6AojY1gYDc/q2hKvVvtuX7p2wy7/cJwdx0LPNClD0YzFpFG7h3aUql3/tWfPOroS s4yUL+JZ3cIdjFe04CFyeEvT5poavKGKLcz4FNtVzBP9G/rWKRMWHe50xV1N97kTPpC3 13OPevuXDMZAyRUkr2zbCVlC7nAH9oxOOcrN9xM/Uezc5I4qCQbr1/5zvvil6JerIEaH KrNrJugAj1XMBZCyIMQPlqdKirxS+36W/hJqXS4G85ebUtrSy6UawV3YSavSVseljIrB mMTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=OjCourkV; 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 l21si232398otd.63.2020.03.26.14.44.01; Thu, 26 Mar 2020 14:44:16 -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=@atishpatra.org header.s=google header.b=OjCourkV; 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 S1727345AbgCZVng (ORCPT + 99 others); Thu, 26 Mar 2020 17:43:36 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:36173 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbgCZVng (ORCPT ); Thu, 26 Mar 2020 17:43:36 -0400 Received: by mail-wm1-f65.google.com with SMTP id g62so9680456wme.1 for ; Thu, 26 Mar 2020 14:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atishpatra.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=f1NDn439r2NKX2oz5ZXFZ71Km/k0SiSxc8ZOwV4UNkM=; b=OjCourkV/MTqGFeOswaVFQKQOplgKPa1zgys4mGBsxi9hAycFeq4i7NQjVeYvQYYIl Z5C2H5mjphkQ+Nzq2zlU7T2vv8LZ/NSe84Rr6iRA3IieJSPTBIV+JoDOcG6K4wpyQoRZ J/de/gJN5I9LMtrwEK6Or+ioTpGm8lNkGQ4HCR0llDNYMPMqWxVKs6jmh/+jHxnwzP7L cw0COxWs9e/U1bP2id4ENhz6rqKaqFx/0xAWfHGEsXqI5cEg9y5EHkmEHrW3QMCSlPzM 2ssLLxfTvxst3538bmc6yz2LSgwjSFKx6gc+tyKcSTosPXYfo5Ni3KfomzX3a+kPJ9d1 9MEw== 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=f1NDn439r2NKX2oz5ZXFZ71Km/k0SiSxc8ZOwV4UNkM=; b=uJk4Rq4QJYgAbYAmIq2aU+LvRKXfx1RrPZB7nR7tGIYCPfRyOPPwyl+VMprJLzbFWd wlSUXjKFzDQsZF0bqhTH3f+JhfUeqgNIu8XA+wEG6DWdN03qRhoIt8mycEFhSTvPe8zQ RDtFkQUW8ru6wFkGXbVXr5FdZv03Uw0oZxLRIvBoWnAjFwIkMuWJphuEq8rfCbRJBxQK +iJwJMOo4NcEiLysuNaLtURvVVNava1CCMs9CTyHnY3knuFTYi4RQifsvGvM5qP35xpn 79wMSEiX1qj9yQN0A/AgvmyIItMNEhENi7Hzn1fz1MoGPElP8+McasQWlnKQfLXDjS3l w66A== X-Gm-Message-State: ANhLgQ2InrRspQeOCLrFpsXdYwj/NjAcgHhlKp57mJyqdQ4dlNJkFlCJ 4YZ4+3gZRsxf5Nif/oV1pwfLWXgdCC3a2HtFD9Cs X-Received: by 2002:adf:e807:: with SMTP id o7mr12050229wrm.77.1585259011235; Thu, 26 Mar 2020 14:43:31 -0700 (PDT) MIME-Version: 1.0 References: <20200224193436.26860-1-atish.patra@wdc.com> In-Reply-To: From: Atish Patra Date: Thu, 26 Mar 2020 14:43:20 -0700 Message-ID: Subject: Re: [PATCH] RISC-V: Move all address space definition macros to one place To: David Abdurachmanov Cc: Palmer Dabbelt , Albert Ou , Nick Hu , Bjorn Topel , Anup Patel , "linux-kernel@vger.kernel.org List" , stable@vger.kernel.org, Mike Rapoport , Atish Patra , linux-riscv , Paul Walmsley , Greentime Hu , Thomas Gleixner , akpm@linux-foundation.org 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 Mon, Mar 23, 2020 at 3:32 AM David Abdurachmanov wrote: > > 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 t= he > > > > following compilation error. > > > > > > > > --------------------------------------------------------------- > > > > ./arch/riscv/include/asm/pgtable-64.h: In function =E2=80=98pud_pag= e=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 m= acro > > > > =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 definiti= on > > > > 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/= asm/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 k= ernel > > > > + * 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 k= ernel > > > > - * 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(struc= t 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= RCs just > > > to avoid conflicts. I've put it on for-next now so the builders have= some 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,= and > > we don't have KASAN selected. We do have CONFIG_SPARSEMEM_VMEMMAP > > selected. > > Yes. I just verified that. CONFIG_SPARSEMEM_VMEMMAP is enough to trigger the build error. The code that raises the compilation error is added by kasan patchset, but it is not dependent upon kasan. --- a/arch/riscv/include/asm/pgtable-64.h +++ b/arch/riscv/include/asm/pgtable-64.h @@ -58,6 +58,11 @@ static inline unsigned long pud_page_vaddr(pud_t pud) return (unsigned long)pfn_to_virt(pud_val(pud) >> _PAGE_PFN_SHIFT); } +static inline struct page *pud_page(pud_t pud) +{ + return pfn_to_page(pud_val(pud) >> _PAGE_PFN_SHIFT); +} + @palmer: I am not sure if it is too late for an RC-fix. If not, can you send it as an RC-fix ? Let me know if you want me to respin the patch editing the commit text. > > I will try this patch tomorrow. > > > Confirmed to solve my build errors with kernel in Fedora/RISCV. > > david > --=20 Regards, Atish