2019-06-04 02:11:33 -06:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*
To disallow user-space visibility into some of the core kernel data-types
such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header
spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-01-18 02:42:17 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
|
|
|
|
*/
|
|
|
|
#ifndef __ASM_ARC_PAGE_H
|
|
|
|
#define __ASM_ARC_PAGE_H
|
|
|
|
|
2013-02-11 07:25:33 -07:00
|
|
|
#include <uapi/asm/page.h>
|
ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*
To disallow user-space visibility into some of the core kernel data-types
such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header
spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-01-18 02:42:17 -07:00
|
|
|
|
2013-01-18 02:42:19 -07:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
|
|
|
#define clear_page(paddr) memset((paddr), 0, PAGE_SIZE)
|
2021-01-04 20:44:53 -07:00
|
|
|
#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
|
2013-01-18 02:42:19 -07:00
|
|
|
#define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
|
|
|
|
|
2013-05-09 10:24:51 -06:00
|
|
|
struct vm_area_struct;
|
|
|
|
struct page;
|
|
|
|
|
|
|
|
#define __HAVE_ARCH_COPY_USER_HIGHPAGE
|
|
|
|
|
|
|
|
void copy_user_highpage(struct page *to, struct page *from,
|
|
|
|
unsigned long u_vaddr, struct vm_area_struct *vma);
|
|
|
|
void clear_user_page(void *to, unsigned long u_vaddr, struct page *page);
|
|
|
|
|
2013-01-18 02:42:19 -07:00
|
|
|
#undef STRICT_MM_TYPECHECKS
|
|
|
|
|
|
|
|
#ifdef STRICT_MM_TYPECHECKS
|
|
|
|
/*
|
|
|
|
* These are used to make use of C type-checking..
|
|
|
|
*/
|
|
|
|
typedef struct {
|
2016-05-03 03:23:40 -06:00
|
|
|
#ifdef CONFIG_ARC_HAS_PAE40
|
|
|
|
unsigned long long pte;
|
|
|
|
#else
|
2013-01-18 02:42:19 -07:00
|
|
|
unsigned long pte;
|
2016-05-03 03:23:40 -06:00
|
|
|
#endif
|
2013-01-18 02:42:19 -07:00
|
|
|
} pte_t;
|
|
|
|
typedef struct {
|
|
|
|
unsigned long pgd;
|
|
|
|
} pgd_t;
|
|
|
|
typedef struct {
|
|
|
|
unsigned long pgprot;
|
|
|
|
} pgprot_t;
|
|
|
|
|
|
|
|
#define pte_val(x) ((x).pte)
|
|
|
|
#define pgd_val(x) ((x).pgd)
|
|
|
|
#define pgprot_val(x) ((x).pgprot)
|
|
|
|
|
|
|
|
#define __pte(x) ((pte_t) { (x) })
|
|
|
|
#define __pgd(x) ((pgd_t) { (x) })
|
|
|
|
#define __pgprot(x) ((pgprot_t) { (x) })
|
|
|
|
|
2013-01-22 04:18:45 -07:00
|
|
|
#define pte_pgprot(x) __pgprot(pte_val(x))
|
|
|
|
|
2013-01-18 02:42:19 -07:00
|
|
|
#else /* !STRICT_MM_TYPECHECKS */
|
|
|
|
|
2015-02-06 08:44:57 -07:00
|
|
|
#ifdef CONFIG_ARC_HAS_PAE40
|
|
|
|
typedef unsigned long long pte_t;
|
|
|
|
#else
|
2013-01-18 02:42:19 -07:00
|
|
|
typedef unsigned long pte_t;
|
2015-02-06 08:44:57 -07:00
|
|
|
#endif
|
2013-01-18 02:42:19 -07:00
|
|
|
typedef unsigned long pgd_t;
|
|
|
|
typedef unsigned long pgprot_t;
|
|
|
|
|
|
|
|
#define pte_val(x) (x)
|
|
|
|
#define pgd_val(x) (x)
|
|
|
|
#define pgprot_val(x) (x)
|
|
|
|
#define __pte(x) (x)
|
2014-07-08 07:13:47 -06:00
|
|
|
#define __pgd(x) (x)
|
2013-01-18 02:42:19 -07:00
|
|
|
#define __pgprot(x) (x)
|
2013-01-22 04:18:45 -07:00
|
|
|
#define pte_pgprot(x) (x)
|
2013-01-18 02:42:19 -07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2015-08-27 21:09:57 -06:00
|
|
|
typedef pte_t * pgtable_t;
|
|
|
|
|
2016-05-05 03:23:48 -06:00
|
|
|
/*
|
|
|
|
* Use virt_to_pfn with caution:
|
|
|
|
* If used in pte or paddr related macros, it could cause truncation
|
|
|
|
* in PAE40 builds
|
|
|
|
* As a rule of thumb, only use it in helpers starting with virt_
|
|
|
|
* You have been warned !
|
|
|
|
*/
|
2015-12-18 01:27:41 -07:00
|
|
|
#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
|
|
|
|
|
arc: use FLATMEM with freeing of unused memory map instead of DISCONTIGMEM
Currently ARC uses DISCONTIGMEM to cope with sparse physical memory address
space on systems with 2 memory banks. While DISCONTIGMEM avoids wasting
memory on unpopulated memory map, it adds both memory and CPU overhead
relatively to FLATMEM. Moreover, DISCONTINGMEM is generally considered
deprecated.
The obvious replacement for DISCONTIGMEM would be SPARSEMEM, but it is also
less efficient than FLATMEM in pfn_to_page() and page_to_pfn() conversions.
Besides it requires tuning of SECTION_SIZE which is not trivial for
possible ARC memory configuration.
Since the memory map for both banks is always allocated from the "lowmem"
bank, it is possible to use FLATMEM for two-bank configuration and simply
free the unused hole in the memory map. All is required for that is to
provide ARC-specific pfn_valid() that will take into account actual
physical memory configuration and define HAVE_ARCH_PFN_VALID.
The resulting kernel image configured with defconfig + HIGHMEM=y is
smaller:
$ size a/vmlinux b/vmlinux
text data bss dec hex filename
4673503 1245456 279756 6198715 5e95bb a/vmlinux
4658706 1246864 279756 6185326 5e616e b/vmlinux
$ ./scripts/bloat-o-meter a/vmlinux b/vmlinux
add/remove: 28/30 grow/shrink: 42/399 up/down: 10986/-29025 (-18039)
...
Total: Before=4709315, After = 4691276, chg -0.38%
Booting nSIM with haps_ns.dts results in the following memory usage
reports:
a:
Memory: 1559104K/1572864K available (3531K kernel code, 595K rwdata, 752K rodata, 136K init, 275K bss, 13760K reserved, 0K cma-reserved, 1048576K highmem)
b:
Memory: 1559112K/1572864K available (3519K kernel code, 594K rwdata, 752K rodata, 136K init, 280K bss, 13752K reserved, 0K cma-reserved, 1048576K highmem)
Link: https://lkml.kernel.org/r/20201101170454.9567-11-rppt@kernel.org
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Ungerer <gerg@linux-m68k.org>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Meelis Roos <mroos@linux.ee>
Cc: Michael Schmitz <schmitzmic@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-14 20:10:04 -07:00
|
|
|
/*
|
|
|
|
* When HIGHMEM is enabled we have holes in the memory map so we need
|
|
|
|
* pfn_valid() that takes into account the actual extents of the physical
|
|
|
|
* memory
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_HIGHMEM
|
|
|
|
|
|
|
|
extern unsigned long arch_pfn_offset;
|
|
|
|
#define ARCH_PFN_OFFSET arch_pfn_offset
|
|
|
|
|
|
|
|
extern int pfn_valid(unsigned long pfn);
|
|
|
|
#define pfn_valid pfn_valid
|
2013-01-18 02:42:19 -07:00
|
|
|
|
arc: use FLATMEM with freeing of unused memory map instead of DISCONTIGMEM
Currently ARC uses DISCONTIGMEM to cope with sparse physical memory address
space on systems with 2 memory banks. While DISCONTIGMEM avoids wasting
memory on unpopulated memory map, it adds both memory and CPU overhead
relatively to FLATMEM. Moreover, DISCONTINGMEM is generally considered
deprecated.
The obvious replacement for DISCONTIGMEM would be SPARSEMEM, but it is also
less efficient than FLATMEM in pfn_to_page() and page_to_pfn() conversions.
Besides it requires tuning of SECTION_SIZE which is not trivial for
possible ARC memory configuration.
Since the memory map for both banks is always allocated from the "lowmem"
bank, it is possible to use FLATMEM for two-bank configuration and simply
free the unused hole in the memory map. All is required for that is to
provide ARC-specific pfn_valid() that will take into account actual
physical memory configuration and define HAVE_ARCH_PFN_VALID.
The resulting kernel image configured with defconfig + HIGHMEM=y is
smaller:
$ size a/vmlinux b/vmlinux
text data bss dec hex filename
4673503 1245456 279756 6198715 5e95bb a/vmlinux
4658706 1246864 279756 6185326 5e616e b/vmlinux
$ ./scripts/bloat-o-meter a/vmlinux b/vmlinux
add/remove: 28/30 grow/shrink: 42/399 up/down: 10986/-29025 (-18039)
...
Total: Before=4709315, After = 4691276, chg -0.38%
Booting nSIM with haps_ns.dts results in the following memory usage
reports:
a:
Memory: 1559104K/1572864K available (3531K kernel code, 595K rwdata, 752K rodata, 136K init, 275K bss, 13760K reserved, 0K cma-reserved, 1048576K highmem)
b:
Memory: 1559112K/1572864K available (3519K kernel code, 594K rwdata, 752K rodata, 136K init, 280K bss, 13752K reserved, 0K cma-reserved, 1048576K highmem)
Link: https://lkml.kernel.org/r/20201101170454.9567-11-rppt@kernel.org
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Ungerer <gerg@linux-m68k.org>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Meelis Roos <mroos@linux.ee>
Cc: Michael Schmitz <schmitzmic@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-14 20:10:04 -07:00
|
|
|
#else /* CONFIG_HIGHMEM */
|
|
|
|
|
|
|
|
#define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_RAM_BASE)
|
2015-12-18 01:27:41 -07:00
|
|
|
#define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
|
arc: use FLATMEM with freeing of unused memory map instead of DISCONTIGMEM
Currently ARC uses DISCONTIGMEM to cope with sparse physical memory address
space on systems with 2 memory banks. While DISCONTIGMEM avoids wasting
memory on unpopulated memory map, it adds both memory and CPU overhead
relatively to FLATMEM. Moreover, DISCONTINGMEM is generally considered
deprecated.
The obvious replacement for DISCONTIGMEM would be SPARSEMEM, but it is also
less efficient than FLATMEM in pfn_to_page() and page_to_pfn() conversions.
Besides it requires tuning of SECTION_SIZE which is not trivial for
possible ARC memory configuration.
Since the memory map for both banks is always allocated from the "lowmem"
bank, it is possible to use FLATMEM for two-bank configuration and simply
free the unused hole in the memory map. All is required for that is to
provide ARC-specific pfn_valid() that will take into account actual
physical memory configuration and define HAVE_ARCH_PFN_VALID.
The resulting kernel image configured with defconfig + HIGHMEM=y is
smaller:
$ size a/vmlinux b/vmlinux
text data bss dec hex filename
4673503 1245456 279756 6198715 5e95bb a/vmlinux
4658706 1246864 279756 6185326 5e616e b/vmlinux
$ ./scripts/bloat-o-meter a/vmlinux b/vmlinux
add/remove: 28/30 grow/shrink: 42/399 up/down: 10986/-29025 (-18039)
...
Total: Before=4709315, After = 4691276, chg -0.38%
Booting nSIM with haps_ns.dts results in the following memory usage
reports:
a:
Memory: 1559104K/1572864K available (3531K kernel code, 595K rwdata, 752K rodata, 136K init, 275K bss, 13760K reserved, 0K cma-reserved, 1048576K highmem)
b:
Memory: 1559112K/1572864K available (3519K kernel code, 594K rwdata, 752K rodata, 136K init, 280K bss, 13752K reserved, 0K cma-reserved, 1048576K highmem)
Link: https://lkml.kernel.org/r/20201101170454.9567-11-rppt@kernel.org
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Ungerer <gerg@linux-m68k.org>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Meelis Roos <mroos@linux.ee>
Cc: Michael Schmitz <schmitzmic@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-14 20:10:04 -07:00
|
|
|
|
|
|
|
#endif /* CONFIG_HIGHMEM */
|
2013-01-18 02:42:19 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* __pa, __va, virt_to_page (ALERT: deprecated, don't use them)
|
|
|
|
*
|
|
|
|
* These macros have historically been misnamed
|
|
|
|
* virt here means link-address/program-address as embedded in object code.
|
2015-12-18 01:27:41 -07:00
|
|
|
* And for ARC, link-addr = physical address
|
2013-01-18 02:42:19 -07:00
|
|
|
*/
|
2016-05-05 03:23:48 -06:00
|
|
|
#define __pa(vaddr) ((unsigned long)(vaddr))
|
2013-01-18 02:42:19 -07:00
|
|
|
#define __va(paddr) ((void *)((unsigned long)(paddr)))
|
|
|
|
|
2016-04-17 23:19:56 -06:00
|
|
|
#define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr))
|
2015-12-18 01:27:41 -07:00
|
|
|
#define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr))
|
2013-01-18 02:42:19 -07:00
|
|
|
|
2013-06-05 06:19:14 -06:00
|
|
|
/* Default Permissions for stack/heaps pages (Non Executable) */
|
2020-04-10 15:33:05 -06:00
|
|
|
#define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
|
2013-01-18 02:42:19 -07:00
|
|
|
|
|
|
|
#define WANT_PAGE_VIRTUAL 1
|
|
|
|
|
|
|
|
#include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */
|
|
|
|
#include <asm-generic/getorder.h>
|
|
|
|
|
ARC: Fundamental ARCH data-types/defines
* L1_CACHE_SHIFT
* PAGE_SIZE, PAGE_OFFSET
* struct pt_regs, struct user_regs_struct
* struct thread_struct, cpu_relax(), task_pt_regs(), start_thread(), ...
* struct thread_info, THREAD_SIZE, INIT_THREAD_INFO(), TIF_*, ...
* BUG()
* ELF_*
* Elf_*
To disallow user-space visibility into some of the core kernel data-types
such as struct pt_regs, #ifdef __KERNEL__ which also makes the UAPI header
spit (further patch in the series) to NOT export it to asm/uapi/ptrace.h
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Jonas Bonn <jonas.bonn@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2013-01-18 02:42:17 -07:00
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
|
|
|
|
#endif
|