Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp238747ybf; Thu, 27 Feb 2020 20:09:08 -0800 (PST) X-Google-Smtp-Source: APXvYqy5OiRODPonOFeaJlZ4JWROiLGR38nUFFqawXxFIT8aL3CzK+gayo037T8Vai5doOj+uhV+ X-Received: by 2002:a9d:6a85:: with SMTP id l5mr1842152otq.231.1582862948186; Thu, 27 Feb 2020 20:09:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582862948; cv=none; d=google.com; s=arc-20160816; b=hjuQ+nL1V8IeNVf2zOBRPJMG/iu1wJkup6607T4MPueLke7xwcBBhSn6Y5lp84UwsJ in3Iz1K2dTXe7wSZsv0d0j+feDjzmyefXpJxnv8wrQdDaER5zUpCn8RO4KrfFULQvbi6 Ehr0Tld/ge4fwzVpwL06vpFuQeuJr0PZbY1oHV7fDY9p+4gW7saU0XARYI6Mamo5qjvA gLv9vedR0TaxvKdWg+UsPAXkHh2en+tw08sYTAmPGP79u5+tllPHrdQhBbPZYd/ddR5F 9MRZkKlLfM2DzXTfgRkHQ6HT6/mTlCJupaWCA7qb50HtDhOcyebK0sPsS/CvXuzHHqPu bqeA== 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=E6J9poe7L3fgO6iROGjXXzLpbZbZiJ8HzNPUuKbvpBQ=; b=Ev40PMAnqibkONB58X/04p/pD6ZQZ3BLH7TZb62fZ3AGFv78zej55HxDzqu6tqGiaa Q/LBZZmjaixmrH7qit2YLpLJRSmDu3bHF2ncURoGeOcb7R6XmH2y94U/DTuSpZQu4CYj C7LL81MHBCtyvnJen8oARtOM4XmVXg0qZWc68CKMTFb3PfhFsEXbDxrxXqzQJi/MIOgC ao+6eiaOQCwdA/2nrZ5adXl/4UO3YIq39+zA7NdEBQYtM/EI9zNkPfEZ4KYV0KpagOBx 5GMJ6HXLGqevcPtuVDXZcN077QF1u9bDFX5X5TiRKaWqeJdKfpKaX5E+yQIiajR6Q2ec Yobg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=hQDPlPu8; 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 73si882866otf.257.2020.02.27.20.08.55; Thu, 27 Feb 2020 20:09:08 -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; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=hQDPlPu8; 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 S1730809AbgB1EIl (ORCPT + 99 others); Thu, 27 Feb 2020 23:08:41 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39130 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730638AbgB1EIk (ORCPT ); Thu, 27 Feb 2020 23:08:40 -0500 Received: by mail-wr1-f66.google.com with SMTP id y17so1398872wrn.6 for ; Thu, 27 Feb 2020 20:08:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=E6J9poe7L3fgO6iROGjXXzLpbZbZiJ8HzNPUuKbvpBQ=; b=hQDPlPu8i3UJQcAlFtZ1KPi0aDhVdJkeXxLsguGG1Tc7naaWqI5ah5b3ihvxIkto2b v6ZDujFuWr7KLdEUBiPLR5GDTrZe7oaUjM1RagyK1zH8LOZr1GU6/dvq9T+uSzwHdN1Z Ue0SfVA36T0pT+6Xz6egXnsKigQzLufF7186+OZW6SCax5kzWrCGeasoLAgnTWc0sxVa bI/ObTs5zwg1QTdM2cBtvTT35DvEURwJtsCq/amrCqwqKttX2fvrOrPOTj9i0qHsbUBN zCSAewl8rQbz27h73V2kSzxvnQ2pteIdNNAmxk4u9r1TvbC3ExHRbz+DO/BOWTPY8yYB GdwA== 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=E6J9poe7L3fgO6iROGjXXzLpbZbZiJ8HzNPUuKbvpBQ=; b=fWwvDIz9MKtdgG+v28HsTsyMAVLiKSf5SRiZfSgPRPYpYnOCliFIPjOSQ34p6Oyp1M vWVbOinFHhmU91IHtoo8xo7mDYjILHZop7A8ziCybGPziiTq1U7Vu/B3VLie3uG/f94j SoeRZF1YjyVFH8IZESZoIFM5gUZKJ2iWwi5FnQMb8Zw8lnnk8/eXD2F93q7I/Yu68K7W v0myPGV3sOQftLNp7LTwln9nmbpPiO8kPRpm20wNP5Bj27ilUdmRXrnHsvootW+KpfGb GoggFGuHDKJj2054JarOnlRGiBqCuatgwUhsmOwvo4ZEPa+36hmhCG+zf4dJBSKcMK1y ZBIw== X-Gm-Message-State: APjAAAUN1kHt6CmdLV9uAgIn9Tq2h/49rpMFWUhAugoJOOL5+cDvO1s/ ay7BDRtEmQdkTTOOTzixx5WH6OLsgxwnCdLjHej2pTX2 X-Received: by 2002:adf:ec84:: with SMTP id z4mr2481605wrn.61.1582862915813; Thu, 27 Feb 2020 20:08:35 -0800 (PST) MIME-Version: 1.0 References: <20200224193436.26860-1-atish.patra@wdc.com> In-Reply-To: <20200224193436.26860-1-atish.patra@wdc.com> From: Anup Patel Date: Fri, 28 Feb 2020 09:38:23 +0530 Message-ID: Subject: Re: [PATCH] RISC-V: Move all address space definition macros to one place To: Atish Patra Cc: "linux-kernel@vger.kernel.org List" , stable@vger.kernel.org, Albert Ou , Andrew Morton , Anup Patel , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , David Abdurachmanov , Greentime Hu , linux-riscv , Mike Rapoport , Nick Hu , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner 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 Tue, Feb 25, 2020 at 1:04 AM 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 macro > =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/asm/pg= table.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 kernel > + * 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 kernel > - * 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_a= rea_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. > -- > 2.25.0 > Looks good to me. At least now all virtual memory layout related defines are in one place. Reviewed-by: Anup Patel Regards, Anup