All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] Add Huge Page support for parisc
@ 2015-11-20 21:38 Helge Deller
  2015-11-20 21:38 ` [PATCH 1/9] parisc: Fix wrong comment regarding first pmd entry flags Helge Deller
                   ` (8 more replies)
  0 siblings, 9 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin

The following patch series adds huge page (large page) support to parisc.

Both 32 and 64bit kernels are supported as long as kernel is being compiled for
PA8X00 / PA2.0 CPUs.

Helge Deller (9):
  parisc: Fix wrong comment regarding first pmd entry flags
  parisc: Drop definition of start_thread_som for HP-UX SOM binaries
  parisc: Fix asm/mman.h regarding MAP_HUGETLB and MADV_XX flags
  parisc: Add defines for Huge page support
  parisc: Initialize the fault vector earlier in the boot process.
  parisc: Increase initial kernel mapping to 32MB on 64bit kernel
  parisc: Use long branch to do_syscall_trace_exit
  parisc: Add Huge Page and HUGETLBFS support
  parisc: Map kernel text and data on huge pages

 arch/parisc/Kconfig                 |   3 +
 arch/parisc/include/asm/hugetlb.h   |  85 +++++++++++++++++++
 arch/parisc/include/asm/page.h      |  13 ++-
 arch/parisc/include/asm/pgalloc.h   |   2 +-
 arch/parisc/include/asm/pgtable.h   |  26 +++++-
 arch/parisc/include/asm/processor.h |  27 ------
 arch/parisc/include/uapi/asm/mman.h |  29 +++----
 arch/parisc/kernel/asm-offsets.c    |   8 ++
 arch/parisc/kernel/entry.S          |  56 ++++++++-----
 arch/parisc/kernel/head.S           |   4 +-
 arch/parisc/kernel/setup.c          |  14 +++-
 arch/parisc/kernel/syscall.S        |   4 +-
 arch/parisc/kernel/traps.c          |  35 ++++----
 arch/parisc/kernel/vmlinux.lds.S    |   9 +-
 arch/parisc/mm/Makefile             |   1 +
 arch/parisc/mm/hugetlbpage.c        | 162 ++++++++++++++++++++++++++++++++++++
 arch/parisc/mm/init.c               |  42 ++++------
 17 files changed, 394 insertions(+), 126 deletions(-)
 create mode 100644 arch/parisc/include/asm/hugetlb.h
 create mode 100644 arch/parisc/mm/hugetlbpage.c

-- 
2.1.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/9] parisc: Fix wrong comment regarding first pmd entry flags
  2015-11-20 21:38 [PATCH 0/9] Add Huge Page support for parisc Helge Deller
@ 2015-11-20 21:38 ` Helge Deller
  2015-11-20 21:38 ` [PATCH 2/9] parisc: Drop definition of start_thread_som for HP-UX SOM binaries Helge Deller
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin

The first pmd entry is marked with PxD_FLAG_ATTACHED instead of
_PAGE_GATEWAY.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/include/asm/pgalloc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
index 3edbb9f..f2fd327 100644
--- a/arch/parisc/include/asm/pgalloc.h
+++ b/arch/parisc/include/asm/pgalloc.h
@@ -35,7 +35,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 				        PxD_FLAG_VALID | 
 					PxD_FLAG_ATTACHED) 
 			+ (__u32)(__pa((unsigned long)pgd) >> PxD_VALUE_SHIFT));
-		/* The first pmd entry also is marked with _PAGE_GATEWAY as
+		/* The first pmd entry also is marked with PxD_FLAG_ATTACHED as
 		 * a signal that this pmd may not be freed */
 		__pgd_val_set(*pgd, PxD_FLAG_ATTACHED);
 #endif
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/9] parisc: Drop definition of start_thread_som for HP-UX SOM binaries
  2015-11-20 21:38 [PATCH 0/9] Add Huge Page support for parisc Helge Deller
  2015-11-20 21:38 ` [PATCH 1/9] parisc: Fix wrong comment regarding first pmd entry flags Helge Deller
@ 2015-11-20 21:38 ` Helge Deller
  2015-11-20 21:38   ` Helge Deller
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin

The definition of start_thread_som was planned to be used to execute
HP-UX SOM binaries. Since HP-UX compatibility was dropped with kernel 4.0
there is no need to carry it further.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/include/asm/processor.h | 27 ---------------------------
 1 file changed, 27 deletions(-)

diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h
index 54adb60..7e759ec 100644
--- a/arch/parisc/include/asm/processor.h
+++ b/arch/parisc/include/asm/processor.h
@@ -192,33 +192,6 @@ void show_trace(struct task_struct *task, unsigned long *stack);
  */
 typedef unsigned int elf_caddr_t;
 
-#define start_thread_som(regs, new_pc, new_sp) do {	\
-	unsigned long *sp = (unsigned long *)new_sp;	\
-	__u32 spaceid = (__u32)current->mm->context;	\
-	unsigned long pc = (unsigned long)new_pc;	\
-	/* offset pc for priv. level */			\
-	pc |= 3;					\
-							\
-	regs->iasq[0] = spaceid;			\
-	regs->iasq[1] = spaceid;			\
-	regs->iaoq[0] = pc;				\
-	regs->iaoq[1] = pc + 4;                         \
-	regs->sr[2] = LINUX_GATEWAY_SPACE;              \
-	regs->sr[3] = 0xffff;				\
-	regs->sr[4] = spaceid;				\
-	regs->sr[5] = spaceid;				\
-	regs->sr[6] = spaceid;				\
-	regs->sr[7] = spaceid;				\
-	regs->gr[ 0] = USER_PSW;                        \
-	regs->gr[30] = ((new_sp)+63)&~63;		\
-	regs->gr[31] = pc;				\
-							\
-	get_user(regs->gr[26],&sp[0]);			\
-	get_user(regs->gr[25],&sp[-1]); 		\
-	get_user(regs->gr[24],&sp[-2]); 		\
-	get_user(regs->gr[23],&sp[-3]); 		\
-} while(0)

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/9] parisc: Fix asm/mman.h regarding MAP_HUGETLB and MADV_XX flags
  2015-11-20 21:38 [PATCH 0/9] Add Huge Page support for parisc Helge Deller
@ 2015-11-20 21:38   ` Helge Deller
  2015-11-20 21:38 ` [PATCH 2/9] parisc: Drop definition of start_thread_som for HP-UX SOM binaries Helge Deller
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin, stable

On parisc we have up to now never supported Huge Pages, even glibc did
not defined MAP_HUGETLB for parisc. Since the Huge Page support is being
added now, clean up existing definitions for MAP_HUGETLB and friends.

Drop lots of MADV_xxK_PAGES flags, which were never used and were
designed for a patch which was never integrated into the Linux
kernel. Instead move other MADV_ flags to make them more compatible to
other linux architectures.

Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/include/uapi/asm/mman.h | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h
index 294d251..9ac77f1 100644
--- a/arch/parisc/include/uapi/asm/mman.h
+++ b/arch/parisc/include/uapi/asm/mman.h
@@ -19,11 +19,12 @@
 #define MAP_EXECUTABLE	0x1000		/* mark it as an executable */
 #define MAP_LOCKED	0x2000		/* pages are locked */
 #define MAP_NORESERVE	0x4000		/* don't check for reservations */
-#define MAP_GROWSDOWN	0x8000		/* stack-like segment */
+#define MAP_GROWSDOWN	0x8000		/* x86 stack-like segment */
 #define MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
 #define MAP_NONBLOCK	0x20000		/* do not block on IO */
-#define MAP_STACK	0x40000		/* give out an address that is best suited for process/thread stacks */
-#define MAP_HUGETLB	0x80000		/* create a huge page mapping */
+#define MAP_HUGETLB	0x40000		/* create a huge page mapping */
+#define MAP_GROWSUP	0x80000		/* parisc stack-like segment */
+#define MAP_STACK	MAP_GROWSUP	/* give out an address that is best suited for process/thread stacks */
 
 #define MS_SYNC		1		/* synchronous memory sync */
 #define MS_ASYNC	2		/* sync memory asynchronously */
@@ -46,25 +47,15 @@
 #define MADV_DONTFORK	10		/* don't inherit across fork */
 #define MADV_DOFORK	11		/* do inherit across fork */
 
-/* The range 12-64 is reserved for page size specification. */
-#define MADV_4K_PAGES   12              /* Use 4K pages  */
-#define MADV_16K_PAGES  14              /* Use 16K pages */
-#define MADV_64K_PAGES  16              /* Use 64K pages */
-#define MADV_256K_PAGES 18              /* Use 256K pages */
-#define MADV_1M_PAGES   20              /* Use 1 Megabyte pages */
-#define MADV_4M_PAGES   22              /* Use 4 Megabyte pages */
-#define MADV_16M_PAGES  24              /* Use 16 Megabyte pages */
-#define MADV_64M_PAGES  26              /* Use 64 Megabyte pages */
+#define MADV_MERGEABLE   12		/* KSM may merge identical pages */
+#define MADV_UNMERGEABLE 13		/* KSM may not merge identical pages */
 
-#define MADV_MERGEABLE   65		/* KSM may merge identical pages */
-#define MADV_UNMERGEABLE 66		/* KSM may not merge identical pages */
+#define MADV_HUGEPAGE	14		/* Worth backing with hugepages */
+#define MADV_NOHUGEPAGE	15		/* Not worth backing with hugepages */
 
-#define MADV_HUGEPAGE	67		/* Worth backing with hugepages */
-#define MADV_NOHUGEPAGE	68		/* Not worth backing with hugepages */

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/9] parisc: Fix asm/mman.h regarding MAP_HUGETLB and MADV_XX flags
@ 2015-11-20 21:38   ` Helge Deller
  0 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin, stable

On parisc we have up to now never supported Huge Pages, even glibc did
not defined MAP_HUGETLB for parisc. Since the Huge Page support is being
added now, clean up existing definitions for MAP_HUGETLB and friends.

Drop lots of MADV_xxK_PAGES flags, which were never used and were
designed for a patch which was never integrated into the Linux
kernel. Instead move other MADV_ flags to make them more compatible to
other linux architectures.

Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/include/uapi/asm/mman.h | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h
index 294d251..9ac77f1 100644
--- a/arch/parisc/include/uapi/asm/mman.h
+++ b/arch/parisc/include/uapi/asm/mman.h
@@ -19,11 +19,12 @@
 #define MAP_EXECUTABLE	0x1000		/* mark it as an executable */
 #define MAP_LOCKED	0x2000		/* pages are locked */
 #define MAP_NORESERVE	0x4000		/* don't check for reservations */
-#define MAP_GROWSDOWN	0x8000		/* stack-like segment */
+#define MAP_GROWSDOWN	0x8000		/* x86 stack-like segment */
 #define MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
 #define MAP_NONBLOCK	0x20000		/* do not block on IO */
-#define MAP_STACK	0x40000		/* give out an address that is best suited for process/thread stacks */
-#define MAP_HUGETLB	0x80000		/* create a huge page mapping */
+#define MAP_HUGETLB	0x40000		/* create a huge page mapping */
+#define MAP_GROWSUP	0x80000		/* parisc stack-like segment */
+#define MAP_STACK	MAP_GROWSUP	/* give out an address that is best suited for process/thread stacks */
 
 #define MS_SYNC		1		/* synchronous memory sync */
 #define MS_ASYNC	2		/* sync memory asynchronously */
@@ -46,25 +47,15 @@
 #define MADV_DONTFORK	10		/* don't inherit across fork */
 #define MADV_DOFORK	11		/* do inherit across fork */
 
-/* The range 12-64 is reserved for page size specification. */
-#define MADV_4K_PAGES   12              /* Use 4K pages  */
-#define MADV_16K_PAGES  14              /* Use 16K pages */
-#define MADV_64K_PAGES  16              /* Use 64K pages */
-#define MADV_256K_PAGES 18              /* Use 256K pages */
-#define MADV_1M_PAGES   20              /* Use 1 Megabyte pages */
-#define MADV_4M_PAGES   22              /* Use 4 Megabyte pages */
-#define MADV_16M_PAGES  24              /* Use 16 Megabyte pages */
-#define MADV_64M_PAGES  26              /* Use 64 Megabyte pages */
+#define MADV_MERGEABLE   12		/* KSM may merge identical pages */
+#define MADV_UNMERGEABLE 13		/* KSM may not merge identical pages */
 
-#define MADV_MERGEABLE   65		/* KSM may merge identical pages */
-#define MADV_UNMERGEABLE 66		/* KSM may not merge identical pages */
+#define MADV_HUGEPAGE	14		/* Worth backing with hugepages */
+#define MADV_NOHUGEPAGE	15		/* Not worth backing with hugepages */
 
-#define MADV_HUGEPAGE	67		/* Worth backing with hugepages */
-#define MADV_NOHUGEPAGE	68		/* Not worth backing with hugepages */
-
-#define MADV_DONTDUMP   69		/* Explicity exclude from the core dump,
+#define MADV_DONTDUMP   16		/* Explicity exclude from the core dump,
 					   overrides the coredump filter bits */
-#define MADV_DODUMP	70		/* Clear the MADV_NODUMP flag */
+#define MADV_DODUMP	17		/* Clear the MADV_NODUMP flag */
 
 /* compatibility flags */
 #define MAP_FILE	0
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/9] parisc: Add defines for Huge page support
  2015-11-20 21:38 [PATCH 0/9] Add Huge Page support for parisc Helge Deller
                   ` (2 preceding siblings ...)
  2015-11-20 21:38   ` Helge Deller
@ 2015-11-20 21:38 ` Helge Deller
  2015-11-20 21:38 ` [PATCH 5/9] parisc: Initialize the fault vector earlier in the boot process Helge Deller
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin

Huge pages on parisc will have the same size as one pmd table, which
is on a 64bit kernel 2MB on a kernel with 4K kernel page sizes, and
on a 32bit kernel 4MB when used with 4K kernel pages.

Since parisc does not physically supports 2MB huge page sizes, emulate
it with two consecutive 1MB page sizes instead. Keeping the same huge
page size as one pmd will allow us to add transparent huge page support
later on.

Bit 21 in the pte flags was unused and will now be used to mark a page
as huge page (_PAGE_HPAGE_BIT).

Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/include/asm/page.h    | 13 ++++++++++++-
 arch/parisc/include/asm/pgtable.h | 20 +++++++++++++++++---
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/arch/parisc/include/asm/page.h b/arch/parisc/include/asm/page.h
index 60d5d17..80e742a 100644
--- a/arch/parisc/include/asm/page.h
+++ b/arch/parisc/include/asm/page.h
@@ -145,11 +145,22 @@ extern int npmem_ranges;
 #endif /* CONFIG_DISCONTIGMEM */
 
 #ifdef CONFIG_HUGETLB_PAGE
-#define HPAGE_SHIFT		22	/* 4MB (is this fixed?) */
+#define HPAGE_SHIFT		PMD_SHIFT /* fixed for transparent huge pages */
 #define HPAGE_SIZE      	((1UL) << HPAGE_SHIFT)
 #define HPAGE_MASK		(~(HPAGE_SIZE - 1))
 #define HUGETLB_PAGE_ORDER	(HPAGE_SHIFT - PAGE_SHIFT)
+
+#if defined(CONFIG_64BIT) && defined(CONFIG_PARISC_PAGE_SIZE_4KB)
+# define REAL_HPAGE_SHIFT	20 /* 20 = 1MB */
+# define _HUGE_PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_1M
+#elif !defined(CONFIG_64BIT) && defined(CONFIG_PARISC_PAGE_SIZE_4KB)
+# define REAL_HPAGE_SHIFT	22 /* 22 = 4MB */
+# define _HUGE_PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_4M
+#else
+# define REAL_HPAGE_SHIFT	24 /* 24 = 16MB */
+# define _HUGE_PAGE_SIZE_ENCODING_DEFAULT _PAGE_SIZE_ENCODING_16M
 #endif
+#endif /* CONFIG_HUGETLB_PAGE */
 
 #define virt_addr_valid(kaddr)	pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
 
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index f93c4a4..638317a 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -167,7 +167,7 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
 #define _PAGE_NO_CACHE_BIT 24   /* (0x080) Uncached Page (U bit) */
 #define _PAGE_ACCESSED_BIT 23   /* (0x100) Software: Page Accessed */
 #define _PAGE_PRESENT_BIT  22   /* (0x200) Software: translation valid */
-/* bit 21 was formerly the FLUSH bit but is now unused */
+#define _PAGE_HPAGE_BIT    21   /* (0x400) Software: Huge Page */
 #define _PAGE_USER_BIT     20   /* (0x800) Software: User accessible page */
 
 /* N.B. The bits are defined in terms of a 32 bit word above, so the */
@@ -194,6 +194,7 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
 #define _PAGE_NO_CACHE (1 << xlate_pabit(_PAGE_NO_CACHE_BIT))
 #define _PAGE_ACCESSED (1 << xlate_pabit(_PAGE_ACCESSED_BIT))
 #define _PAGE_PRESENT  (1 << xlate_pabit(_PAGE_PRESENT_BIT))
+#define _PAGE_HUGE     (1 << xlate_pabit(_PAGE_HPAGE_BIT))
 #define _PAGE_USER     (1 << xlate_pabit(_PAGE_USER_BIT))
 
 #define _PAGE_TABLE	(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE |  _PAGE_DIRTY | _PAGE_ACCESSED)
@@ -217,7 +218,7 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
 #define PxD_FLAG_VALID    (1 << xlate_pabit(_PxD_VALID_BIT))
 #define PxD_FLAG_MASK     (0xf)
 #define PxD_FLAG_SHIFT    (4)
-#define PxD_VALUE_SHIFT   (8) /* (PAGE_SHIFT-PxD_FLAG_SHIFT) */
+#define PxD_VALUE_SHIFT   (PFN_PTE_SHIFT-PxD_FLAG_SHIFT)
 
 #ifndef __ASSEMBLY__
 
@@ -363,6 +364,18 @@ static inline pte_t pte_mkwrite(pte_t pte)	{ pte_val(pte) |= _PAGE_WRITE; return
 static inline pte_t pte_mkspecial(pte_t pte)	{ return pte; }
 
 /*
+ * Huge pte definitions.
+ */
+#ifdef CONFIG_HUGETLB_PAGE
+#define pte_huge(pte)           (pte_val(pte) & _PAGE_HUGE)
+#define pte_mkhuge(pte)         (__pte(pte_val(pte) | _PAGE_HUGE))
+#else
+#define pte_huge(pte)           (0)
+#define pte_mkhuge(pte)         (pte)
+#endif
+
+
+/*
  * Conversion functions: convert a page and protection to a page entry,
  * and a page entry and page directory to the page they refer to.
  */
@@ -410,8 +423,9 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 /* Find an entry in the second-level page table.. */
 
 #if CONFIG_PGTABLE_LEVELS == 3
+#define pmd_index(addr)         (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
 #define pmd_offset(dir,address) \
-((pmd_t *) pgd_page_vaddr(*(dir)) + (((address)>>PMD_SHIFT) & (PTRS_PER_PMD-1)))
+((pmd_t *) pgd_page_vaddr(*(dir)) + pmd_index(address))
 #else
 #define pmd_offset(dir,addr) ((pmd_t *) dir)
 #endif
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/9] parisc: Initialize the fault vector earlier in the boot process.
  2015-11-20 21:38 [PATCH 0/9] Add Huge Page support for parisc Helge Deller
                   ` (3 preceding siblings ...)
  2015-11-20 21:38 ` [PATCH 4/9] parisc: Add defines for Huge page support Helge Deller
@ 2015-11-20 21:38 ` Helge Deller
  2015-11-20 21:38 ` [PATCH 6/9] parisc: Increase initial kernel mapping to 32MB on 64bit kernel Helge Deller
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin

A fault vector on parisc needs to be 2K aligned.  Furthermore the
checksum of the fault vector needs to sum up to 0 which is being
calculated and written at runtime.

Up to now we aligned both PA20 and PA11 fault vectors on the same 4K
page in order to easily write the checksum after having mapped the
kernel read-only (by mapping this page only as read-write).
But when we want to map the kernel text and data on huge pages this
makes things harder.
So, simplify it by aligning both fault vectors on 2K boundries and write
the checksum before we map the page read-only.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/kernel/entry.S | 11 +++--------
 arch/parisc/kernel/setup.c |  3 +++
 arch/parisc/kernel/traps.c | 35 +++++++++++++++--------------------
 3 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index c5ef408..b2fdc44 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -646,17 +646,12 @@
 
 
 	/*
-	 * Align fault_vector_20 on 4K boundary so that both
-	 * fault_vector_11 and fault_vector_20 are on the
-	 * same page. This is only necessary as long as we
-	 * write protect the kernel text, which we may stop
-	 * doing once we use large page translations to cover
-	 * the static part of the kernel address space.
+	 * Fault_vectors are architecturally required to be aligned on a 2K
+	 * boundary
 	 */
 
 	.text
-
-	.align 4096
+	.align 2048
 
 ENTRY(fault_vector_20)
 	/* First vector is invalid (0) */
diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
index 72a3c65..f097762 100644
--- a/arch/parisc/kernel/setup.c
+++ b/arch/parisc/kernel/setup.c
@@ -377,6 +377,7 @@ arch_initcall(parisc_init);
 void start_parisc(void)
 {
 	extern void start_kernel(void);
+	extern void early_trap_init(void);
 
 	int ret, cpunum;
 	struct pdc_coproc_cfg coproc_cfg;
@@ -397,6 +398,8 @@ void start_parisc(void)
 		panic("must have an fpu to boot linux");
 	}
 
+	early_trap_init(); /* initialize checksum of fault_vector */
+
 	start_kernel();
 	// not reached
 }
diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
index b99b39f..553b098 100644
--- a/arch/parisc/kernel/traps.c
+++ b/arch/parisc/kernel/traps.c
@@ -807,7 +807,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
 }
 
 
-int __init check_ivt(void *iva)
+void __init initialize_ivt(const void *iva)
 {
 	extern u32 os_hpmc_size;
 	extern const u32 os_hpmc[];
@@ -818,8 +818,8 @@ int __init check_ivt(void *iva)
 	u32 *hpmcp;
 	u32 length;
 
-	if (strcmp((char *)iva, "cows can fly"))
-		return -1;
+	if (strcmp((const char *)iva, "cows can fly"))
+		panic("IVT invalid");
 
 	ivap = (u32 *)iva;
 
@@ -839,28 +839,23 @@ int __init check_ivt(void *iva)
 	    check += ivap[i];
 
 	ivap[5] = -check;
-
-	return 0;
 }
 	
-#ifndef CONFIG_64BIT
-extern const void fault_vector_11;
-#endif
-extern const void fault_vector_20;
 
-void __init trap_init(void)
+/* early_trap_init() is called before we set up kernel mappings and
+ * write-protect the kernel */
+void  __init early_trap_init(void)
 {
-	void *iva;
+	extern const void fault_vector_20;
 
-	if (boot_cpu_data.cpu_type >= pcxu)
-		iva = (void *) &fault_vector_20;
-	else
-#ifdef CONFIG_64BIT
-		panic("Can't boot 64-bit OS on PA1.1 processor!");
-#else
-		iva = (void *) &fault_vector_11;
+#ifndef CONFIG_64BIT
+	extern const void fault_vector_11;
+	initialize_ivt(&fault_vector_11);
 #endif
 
-	if (check_ivt(iva))
-		panic("IVT invalid");
+	initialize_ivt(&fault_vector_20);
+}
+
+void __init trap_init(void)
+{
 }
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/9] parisc: Increase initial kernel mapping to 32MB on 64bit kernel
  2015-11-20 21:38 [PATCH 0/9] Add Huge Page support for parisc Helge Deller
                   ` (4 preceding siblings ...)
  2015-11-20 21:38 ` [PATCH 5/9] parisc: Initialize the fault vector earlier in the boot process Helge Deller
@ 2015-11-20 21:38 ` Helge Deller
  2015-11-20 21:38 ` [PATCH 7/9] parisc: Use long branch to do_syscall_trace_exit Helge Deller
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin

For the 64bit kernel the initially 16 MB kernel memory might become too
small if you build a kernel with many modules built-in and with kernel
text and data areas mapped on huge pages.

This patch increases the initial mapping to 32MB for 64bit kernels and
keeps 16MB for 32bit kernels.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/include/asm/pgtable.h | 6 +++++-
 arch/parisc/kernel/head.S         | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index 638317a..d8534f9 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -83,7 +83,11 @@ static inline void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
 	printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, (unsigned long)pgd_val(e))
 
 /* This is the size of the initially mapped kernel memory */
-#define KERNEL_INITIAL_ORDER	24	/* 0 to 1<<24 = 16MB */
+#ifdef CONFIG_64BIT
+#define KERNEL_INITIAL_ORDER	25	/* 1<<25 = 32MB */
+#else
+#define KERNEL_INITIAL_ORDER	24	/* 1<<24 = 16MB */
+#endif
 #define KERNEL_INITIAL_SIZE	(1 << KERNEL_INITIAL_ORDER)
 
 #if CONFIG_PGTABLE_LEVELS == 3
diff --git a/arch/parisc/kernel/head.S b/arch/parisc/kernel/head.S
index e7d6452..75aa0db 100644
--- a/arch/parisc/kernel/head.S
+++ b/arch/parisc/kernel/head.S
@@ -69,7 +69,7 @@ $bss_loop:
 	stw,ma          %arg2,4(%r1)
 	stw,ma          %arg3,4(%r1)
 
-	/* Initialize startup VM. Just map first 8/16 MB of memory */
+	/* Initialize startup VM. Just map first 16/32 MB of memory */
 	load32		PA(swapper_pg_dir),%r4
 	mtctl		%r4,%cr24	/* Initialize kernel root pointer */
 	mtctl		%r4,%cr25	/* Initialize user root pointer */
@@ -107,7 +107,7 @@ $bss_loop:
 	/* Now initialize the PTEs themselves.  We use RWX for
 	 * everything ... it will get remapped correctly later */
 	ldo		0+_PAGE_KERNEL_RWX(%r0),%r3 /* Hardwired 0 phys addr start */
-	ldi		(1<<(KERNEL_INITIAL_ORDER-PAGE_SHIFT)),%r11 /* PFN count */
+	load32		(1<<(KERNEL_INITIAL_ORDER-PAGE_SHIFT)),%r11 /* PFN count */
 	load32		PA(pg0),%r1
 
 $pgt_fill_loop:
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 7/9] parisc: Use long branch to do_syscall_trace_exit
  2015-11-20 21:38 [PATCH 0/9] Add Huge Page support for parisc Helge Deller
                   ` (5 preceding siblings ...)
  2015-11-20 21:38 ` [PATCH 6/9] parisc: Increase initial kernel mapping to 32MB on 64bit kernel Helge Deller
@ 2015-11-20 21:38 ` Helge Deller
  2015-11-20 21:38 ` [PATCH 8/9] parisc: Add Huge Page and HUGETLBFS support Helge Deller
  2015-11-20 21:38 ` [PATCH 9/9] parisc: Map kernel text and data on huge pages Helge Deller
  8 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin

Use the 22bit instead of the 17bit branch instruction on a 64bit kernel
to reach the do_syscall_trace_exit function from the gateway page.
A huge page enabled kernel may need the additional branch distance bits.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/kernel/syscall.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
index 0b8d26d..3fbd725 100644
--- a/arch/parisc/kernel/syscall.S
+++ b/arch/parisc/kernel/syscall.S
@@ -369,7 +369,7 @@ tracesys_exit:
 	ldo	-16(%r30),%r29			/* Reference param save area */
 #endif
 	ldo	TASK_REGS(%r1),%r26
-	bl	do_syscall_trace_exit,%r2
+	BL	do_syscall_trace_exit,%r2
 	STREG   %r28,TASK_PT_GR28(%r1)          /* save return value now */
 	ldo     -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1      /* get task ptr */
 	LDREG	TI_TASK(%r1), %r1
@@ -390,7 +390,7 @@ tracesys_sigexit:
 #ifdef CONFIG_64BIT
 	ldo	-16(%r30),%r29			/* Reference param save area */
 #endif
-	bl	do_syscall_trace_exit,%r2
+	BL	do_syscall_trace_exit,%r2
 	ldo	TASK_REGS(%r1),%r26
 
 	ldil	L%syscall_exit_rfi,%r1
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 8/9] parisc: Add Huge Page and HUGETLBFS support
  2015-11-20 21:38 [PATCH 0/9] Add Huge Page support for parisc Helge Deller
                   ` (6 preceding siblings ...)
  2015-11-20 21:38 ` [PATCH 7/9] parisc: Use long branch to do_syscall_trace_exit Helge Deller
@ 2015-11-20 21:38 ` Helge Deller
  2015-11-20 21:38 ` [PATCH 9/9] parisc: Map kernel text and data on huge pages Helge Deller
  8 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin

This patch adds huge page support to allow userspace to allocate huge
pages and to use hugetlbfs filesystem on 32- and 64-bit Linux kernels.
A later patch will add kernel support to map kernel text and data on
huge pages.

The only requirement is, that the kernel needs to be compiled for a
PA8X00 CPU (PA2.0 architecture). Older PA1.X CPUs do not support
variable page sizes. 64bit Kernels are compiled for PA2.0 by default.

Technically on parisc multiple physical huge pages may be needed to
emulate standard 2MB huge pages.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/Kconfig               |   3 +
 arch/parisc/include/asm/hugetlb.h |  85 ++++++++++++++++++++
 arch/parisc/kernel/entry.S        |  45 +++++++----
 arch/parisc/kernel/setup.c        |  11 ++-
 arch/parisc/mm/Makefile           |   1 +
 arch/parisc/mm/hugetlbpage.c      | 162 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 292 insertions(+), 15 deletions(-)
 create mode 100644 arch/parisc/include/asm/hugetlb.h
 create mode 100644 arch/parisc/mm/hugetlbpage.c

diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index c365469..729f891 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -108,6 +108,9 @@ config PGTABLE_LEVELS
 	default 3 if 64BIT && PARISC_PAGE_SIZE_4KB
 	default 2
 
+config SYS_SUPPORTS_HUGETLBFS
+	def_bool y if PA20
+
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
diff --git a/arch/parisc/include/asm/hugetlb.h b/arch/parisc/include/asm/hugetlb.h
new file mode 100644
index 0000000..7d56a9c
--- /dev/null
+++ b/arch/parisc/include/asm/hugetlb.h
@@ -0,0 +1,85 @@
+#ifndef _ASM_PARISC64_HUGETLB_H
+#define _ASM_PARISC64_HUGETLB_H
+
+#include <asm/page.h>
+#include <asm-generic/hugetlb.h>
+
+
+void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
+		     pte_t *ptep, pte_t pte);
+
+pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
+			      pte_t *ptep);
+
+static inline int is_hugepage_only_range(struct mm_struct *mm,
+					 unsigned long addr,
+					 unsigned long len) {
+	return 0;
+}
+
+/*
+ * If the arch doesn't supply something else, assume that hugepage
+ * size aligned regions are ok without further preparation.
+ */
+static inline int prepare_hugepage_range(struct file *file,
+			unsigned long addr, unsigned long len)
+{
+	if (len & ~HPAGE_MASK)
+		return -EINVAL;
+	if (addr & ~HPAGE_MASK)
+		return -EINVAL;
+	return 0;
+}
+
+static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
+					  unsigned long addr, unsigned long end,
+					  unsigned long floor,
+					  unsigned long ceiling)
+{
+	free_pgd_range(tlb, addr, end, floor, ceiling);
+}
+
+static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
+					 unsigned long addr, pte_t *ptep)
+{
+}
+
+static inline int huge_pte_none(pte_t pte)
+{
+	return pte_none(pte);
+}
+
+static inline pte_t huge_pte_wrprotect(pte_t pte)
+{
+	return pte_wrprotect(pte);
+}
+
+static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
+					   unsigned long addr, pte_t *ptep)
+{
+	pte_t old_pte = *ptep;
+	set_huge_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
+}
+
+static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
+					     unsigned long addr, pte_t *ptep,
+					     pte_t pte, int dirty)
+{
+	int changed = !pte_same(*ptep, pte);
+	if (changed) {
+		set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
+		flush_tlb_page(vma, addr);
+	}
+	return changed;
+}
+
+static inline pte_t huge_ptep_get(pte_t *ptep)
+{
+	return *ptep;
+}
+
+static inline void arch_clear_hugepage_flags(struct page *page)
+{
+}
+
+#endif /* _ASM_PARISC64_HUGETLB_H */
diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index b2fdc44..623496c 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -502,21 +502,38 @@
 	STREG		\pte,0(\ptp)
 	.endm
 
+	/* We have (depending on the page size):
+	 * - 38 to 52-bit Physical Page Number
+	 * - 12 to 26-bit page offset
+	 */
 	/* bitshift difference between a PFN (based on kernel's PAGE_SIZE)
 	 * to a CPU TLB 4k PFN (4k => 12 bits to shift) */
-	#define PAGE_ADD_SHIFT  (PAGE_SHIFT-12)
+	#define PAGE_ADD_SHIFT		(PAGE_SHIFT-12)
+	#define PAGE_ADD_HUGE_SHIFT	(REAL_HPAGE_SHIFT-12)
 
 	/* Drop prot bits and convert to page addr for iitlbt and idtlbt */
-	.macro		convert_for_tlb_insert20 pte
+	.macro		convert_for_tlb_insert20 pte,tmp
+#ifdef CONFIG_HUGETLB_PAGE
+	copy		\pte,\tmp
+	extrd,u		\tmp,(63-ASM_PFN_PTE_SHIFT)+(63-58)+PAGE_ADD_SHIFT,\
+				64-PAGE_SHIFT-PAGE_ADD_SHIFT,\pte
+
+	depdi		_PAGE_SIZE_ENCODING_DEFAULT,63,\
+				(63-58)+PAGE_ADD_SHIFT,\pte
+	extrd,u,*=	\tmp,_PAGE_HPAGE_BIT+32,1,%r0
+	depdi		_HUGE_PAGE_SIZE_ENCODING_DEFAULT,63,\
+				(63-58)+PAGE_ADD_HUGE_SHIFT,\pte
+#else /* Huge pages disabled */
 	extrd,u		\pte,(63-ASM_PFN_PTE_SHIFT)+(63-58)+PAGE_ADD_SHIFT,\
 				64-PAGE_SHIFT-PAGE_ADD_SHIFT,\pte
 	depdi		_PAGE_SIZE_ENCODING_DEFAULT,63,\
 				(63-58)+PAGE_ADD_SHIFT,\pte
+#endif
 	.endm
 
 	/* Convert the pte and prot to tlb insertion values.  How
 	 * this happens is quite subtle, read below */
-	.macro		make_insert_tlb	spc,pte,prot
+	.macro		make_insert_tlb	spc,pte,prot,tmp
 	space_to_prot   \spc \prot        /* create prot id from space */
 	/* The following is the real subtlety.  This is depositing
 	 * T <-> _PAGE_REFTRAP
@@ -553,7 +570,7 @@
 	depdi		1,12,1,\prot
 
 	/* Drop prot bits and convert to page addr for iitlbt and idtlbt */
-	convert_for_tlb_insert20 \pte
+	convert_for_tlb_insert20 \pte \tmp
 	.endm
 
 	/* Identical macro to make_insert_tlb above, except it
@@ -1142,7 +1159,7 @@ dtlb_miss_20w:
 	tlb_lock	spc,ptp,pte,t0,t1,dtlb_check_alias_20w
 	update_accessed	ptp,pte,t0,t1
 
-	make_insert_tlb	spc,pte,prot
+	make_insert_tlb	spc,pte,prot,t1
 	
 	idtlbt          pte,prot
 
@@ -1168,7 +1185,7 @@ nadtlb_miss_20w:
 	tlb_lock	spc,ptp,pte,t0,t1,nadtlb_check_alias_20w
 	update_accessed	ptp,pte,t0,t1
 
-	make_insert_tlb	spc,pte,prot
+	make_insert_tlb	spc,pte,prot,t1
 
 	idtlbt          pte,prot
 
@@ -1262,7 +1279,7 @@ dtlb_miss_20:
 	tlb_lock	spc,ptp,pte,t0,t1,dtlb_check_alias_20
 	update_accessed	ptp,pte,t0,t1
 
-	make_insert_tlb	spc,pte,prot
+	make_insert_tlb	spc,pte,prot,t1
 
 	f_extend	pte,t1
 
@@ -1290,7 +1307,7 @@ nadtlb_miss_20:
 	tlb_lock	spc,ptp,pte,t0,t1,nadtlb_check_alias_20
 	update_accessed	ptp,pte,t0,t1
 
-	make_insert_tlb	spc,pte,prot
+	make_insert_tlb	spc,pte,prot,t1
 
 	f_extend	pte,t1
 	
@@ -1399,7 +1416,7 @@ itlb_miss_20w:
 	tlb_lock	spc,ptp,pte,t0,t1,itlb_fault
 	update_accessed	ptp,pte,t0,t1
 
-	make_insert_tlb	spc,pte,prot
+	make_insert_tlb	spc,pte,prot,t1
 	
 	iitlbt          pte,prot
 
@@ -1423,7 +1440,7 @@ naitlb_miss_20w:
 	tlb_lock	spc,ptp,pte,t0,t1,naitlb_check_alias_20w
 	update_accessed	ptp,pte,t0,t1
 
-	make_insert_tlb	spc,pte,prot
+	make_insert_tlb	spc,pte,prot,t1
 
 	iitlbt          pte,prot
 
@@ -1509,7 +1526,7 @@ itlb_miss_20:
 	tlb_lock	spc,ptp,pte,t0,t1,itlb_fault
 	update_accessed	ptp,pte,t0,t1
 
-	make_insert_tlb	spc,pte,prot
+	make_insert_tlb	spc,pte,prot,t1
 
 	f_extend	pte,t1
 
@@ -1529,7 +1546,7 @@ naitlb_miss_20:
 	tlb_lock	spc,ptp,pte,t0,t1,naitlb_check_alias_20
 	update_accessed	ptp,pte,t0,t1
 
-	make_insert_tlb	spc,pte,prot
+	make_insert_tlb	spc,pte,prot,t1
 
 	f_extend	pte,t1
 
@@ -1561,7 +1578,7 @@ dbit_trap_20w:
 	tlb_lock	spc,ptp,pte,t0,t1,dbit_fault
 	update_dirty	ptp,pte,t1
 
-	make_insert_tlb	spc,pte,prot
+	make_insert_tlb	spc,pte,prot,t1
 		
 	idtlbt          pte,prot
 
@@ -1605,7 +1622,7 @@ dbit_trap_20:
 	tlb_lock	spc,ptp,pte,t0,t1,dbit_fault
 	update_dirty	ptp,pte,t1
 
-	make_insert_tlb	spc,pte,prot
+	make_insert_tlb	spc,pte,prot,t1
 
 	f_extend	pte,t1
 	
diff --git a/arch/parisc/kernel/setup.c b/arch/parisc/kernel/setup.c
index f097762..f7ea626 100644
--- a/arch/parisc/kernel/setup.c
+++ b/arch/parisc/kernel/setup.c
@@ -130,7 +130,16 @@ void __init setup_arch(char **cmdline_p)
 	printk(KERN_INFO "The 32-bit Kernel has started...\n");
 #endif
 
-	printk(KERN_INFO "Default page size is %dKB.\n", (int)(PAGE_SIZE / 1024));
+	printk(KERN_INFO "Kernel default page size is %d KB. Huge pages ",
+		(int)(PAGE_SIZE / 1024));
+#ifdef CONFIG_HUGETLB_PAGE
+	printk(KERN_CONT "enabled with %d MB physical and %d MB virtual size",
+		 1 << (REAL_HPAGE_SHIFT - 20), 1 << (HPAGE_SHIFT - 20));
+#else
+	printk(KERN_CONT "disabled");
+#endif
+	printk(KERN_CONT ".\n");
+
 
 	pdc_console_init();
 
diff --git a/arch/parisc/mm/Makefile b/arch/parisc/mm/Makefile
index 758ceef..134393d 100644
--- a/arch/parisc/mm/Makefile
+++ b/arch/parisc/mm/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-y	 := init.o fault.o ioremap.o
+obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c
new file mode 100644
index 0000000..36033c0
--- /dev/null
+++ b/arch/parisc/mm/hugetlbpage.c
@@ -0,0 +1,162 @@
+/*
+ * PARISC64 Huge TLB page support.
+ *
+ * This parisc implementation is heavily based on the SPARC and x86 code.
+ *
+ * Copyright (C) 2015 Helge Deller <deller@gmx.de>
+ */
+
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/hugetlb.h>
+#include <linux/pagemap.h>
+#include <linux/sysctl.h>
+
+#include <asm/mman.h>
+#include <asm/pgalloc.h>
+#include <asm/tlb.h>
+#include <asm/tlbflush.h>
+#include <asm/cacheflush.h>
+#include <asm/mmu_context.h>
+
+
+unsigned long
+hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
+		unsigned long len, unsigned long pgoff, unsigned long flags)
+{
+	struct hstate *h = hstate_file(file);
+
+	if (len & ~huge_page_mask(h))
+		return -EINVAL;
+	if (len > TASK_SIZE)
+		return -ENOMEM;
+
+	if (flags & MAP_FIXED)
+		if (prepare_hugepage_range(file, addr, len))
+			return -EINVAL;
+
+	if (addr)
+		addr = ALIGN(addr, huge_page_size(h));
+
+	/* we need to make sure the colouring is OK */
+	return arch_get_unmapped_area(file, addr, len, pgoff, flags);
+}
+
+
+pte_t *huge_pte_alloc(struct mm_struct *mm,
+			unsigned long addr, unsigned long sz)
+{
+	pgd_t *pgd;
+	pud_t *pud;
+	pmd_t *pmd;
+	pte_t *pte = NULL;
+
+	/* We must align the address, because our caller will run
+	 * set_huge_pte_at() on whatever we return, which writes out
+	 * all of the sub-ptes for the hugepage range.  So we have
+	 * to give it the first such sub-pte.
+	 */
+	addr &= HPAGE_MASK;
+
+	pgd = pgd_offset(mm, addr);
+	pud = pud_alloc(mm, pgd, addr);
+	if (pud) {
+		pmd = pmd_alloc(mm, pud, addr);
+		if (pmd)
+			pte = pte_alloc_map(mm, NULL, pmd, addr);
+	}
+	return pte;
+}
+
+pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
+{
+	pgd_t *pgd;
+	pud_t *pud;
+	pmd_t *pmd;
+	pte_t *pte = NULL;
+
+	addr &= HPAGE_MASK;
+
+	pgd = pgd_offset(mm, addr);
+	if (!pgd_none(*pgd)) {
+		pud = pud_offset(pgd, addr);
+		if (!pud_none(*pud)) {
+			pmd = pmd_offset(pud, addr);
+			if (!pmd_none(*pmd))
+				pte = pte_offset_map(pmd, addr);
+		}
+	}
+	return pte;
+}
+
+/* Purge data and instruction TLB entries.  Must be called holding
+ * the pa_tlb_lock.  The TLB purge instructions are slow on SMP
+ * machines since the purge must be broadcast to all CPUs.
+ */
+static inline void purge_tlb_entries_huge(struct mm_struct *mm, unsigned long addr)
+{
+	unsigned long flags;
+	int i;
+
+	/* We may use multiple physical huge pages (e.g. 2x1 MB) to emulate
+	 * Linux standard huge pages (e.g. 2 MB) */
+	BUILD_BUG_ON(REAL_HPAGE_SHIFT > HPAGE_SHIFT);
+
+	addr &= HPAGE_MASK;
+	addr |= _HUGE_PAGE_SIZE_ENCODING_DEFAULT;
+
+	spin_lock_irqsave(&pa_tlb_lock, flags);
+
+	mtsp(mm->context, 1);
+	for (i = 0; i < (1 << (HPAGE_SHIFT-REAL_HPAGE_SHIFT)); i++) {
+		pdtlb(addr);
+		if (unlikely(split_tlb))
+			pitlb(addr);
+		addr += (1UL << REAL_HPAGE_SHIFT);
+	}
+
+	spin_unlock_irqrestore(&pa_tlb_lock, flags);
+}
+
+void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
+		     pte_t *ptep, pte_t entry)
+{
+	unsigned long addr_start;
+	int i;
+
+	addr &= HPAGE_MASK;
+	addr_start = addr;
+
+	for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
+		/* Directly write pte entry.  We could call set_pte_at(mm, addr, ptep, entry)
+		 * instead, but then we get double locking on pa_tlb_lock. */
+		*ptep = entry;
+		ptep++;
+		addr += PAGE_SIZE;
+		pte_val(entry) += PAGE_SIZE;
+	}
+
+	purge_tlb_entries_huge(mm, addr_start);
+}
+
+
+pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
+			      pte_t *ptep)
+{
+	pte_t entry;
+
+	entry = *ptep;
+	set_huge_pte_at(mm, addr, ptep, __pte(0));
+
+	return entry;
+}
+
+int pmd_huge(pmd_t pmd)
+{
+	return 0;
+}
+
+int pud_huge(pud_t pud)
+{
+	return 0;
+}
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 9/9] parisc: Map kernel text and data on huge pages
  2015-11-20 21:38 [PATCH 0/9] Add Huge Page support for parisc Helge Deller
                   ` (7 preceding siblings ...)
  2015-11-20 21:38 ` [PATCH 8/9] parisc: Add Huge Page and HUGETLBFS support Helge Deller
@ 2015-11-20 21:38 ` Helge Deller
  8 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:38 UTC (permalink / raw)
  To: linux-parisc; +Cc: James Bottomley, John David Anglin

Adjust the linker script and map_pages() to map kernel text and data on
physical 1MB huge/large pages.

The bss section is the last section in the kernel layout and if huge
pages are enabled we may end off with unused memory which we now will
use for the bootmap tables.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/kernel/asm-offsets.c |  8 ++++++++
 arch/parisc/kernel/vmlinux.lds.S |  9 ++++++---
 arch/parisc/mm/init.c            | 42 +++++++++++++++++-----------------------
 3 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/arch/parisc/kernel/asm-offsets.c b/arch/parisc/kernel/asm-offsets.c
index 59001ce..d2f6257 100644
--- a/arch/parisc/kernel/asm-offsets.c
+++ b/arch/parisc/kernel/asm-offsets.c
@@ -290,6 +290,14 @@ int main(void)
 	DEFINE(ASM_PFN_PTE_SHIFT, PFN_PTE_SHIFT);
 	DEFINE(ASM_PT_INITIAL, PT_INITIAL);
 	BLANK();
+	/* HUGEPAGE_SIZE is only used in vmlinux.lds.S to align kernel text
+	 * and kernel data on physical huge pages */
+#ifdef CONFIG_HUGETLB_PAGE
+	DEFINE(HUGEPAGE_SIZE, 1UL << REAL_HPAGE_SHIFT);
+#else
+	DEFINE(HUGEPAGE_SIZE, PAGE_SIZE);
+#endif
+	BLANK();
 	DEFINE(EXCDATA_IP, offsetof(struct exception_data, fault_ip));
 	DEFINE(EXCDATA_SPACE, offsetof(struct exception_data, fault_space));
 	DEFINE(EXCDATA_ADDR, offsetof(struct exception_data, fault_addr));
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index 0dacc5c..308f290 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -60,7 +60,7 @@ SECTIONS
 		EXIT_DATA
 	}
 	PERCPU_SECTION(8)
-	. = ALIGN(PAGE_SIZE);
+	. = ALIGN(HUGEPAGE_SIZE);
 	__init_end = .;
 	/* freed after init ends here */
 
@@ -116,7 +116,7 @@ SECTIONS
 	 * that we can properly leave these
 	 * as writable
 	 */
-	. = ALIGN(PAGE_SIZE);
+	. = ALIGN(HUGEPAGE_SIZE);
 	data_start = .;
 
 	EXCEPTION_TABLE(8)
@@ -135,8 +135,11 @@ SECTIONS
 	_edata = .;
 
 	/* BSS */
-	BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 8)
+	BSS_SECTION(PAGE_SIZE, PAGE_SIZE, PAGE_SIZE)
+
+	/* bootmap is allocated in setup_bootmem() directly behind bss. */
 
+	. = ALIGN(HUGEPAGE_SIZE);
 	_end = . ;
 
 	STABS_DEBUG
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index c229427..976fb6e 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -265,7 +265,7 @@ static void __init setup_bootmem(void)
 	for (i = 0; i < npmem_ranges; i++)
 		bootmap_pages += bootmem_bootmap_pages(pmem_ranges[i].pages);
 
-	bootmap_start_pfn = PAGE_ALIGN(__pa((unsigned long) &_end)) >> PAGE_SHIFT;
+	bootmap_start_pfn = PAGE_ALIGN(__pa((unsigned long) &__bss_stop)) >> PAGE_SHIFT;
 
 #ifdef CONFIG_DISCONTIGMEM
 	for (i = 0; i < MAX_PHYSMEM_RANGES; i++) {
@@ -407,15 +407,11 @@ static void __init map_pages(unsigned long start_vaddr,
 	unsigned long vaddr;
 	unsigned long ro_start;
 	unsigned long ro_end;
-	unsigned long fv_addr;
-	unsigned long gw_addr;
-	extern const unsigned long fault_vector_20;
-	extern void * const linux_gateway_page;
+	unsigned long kernel_end;
 
 	ro_start = __pa((unsigned long)_text);
 	ro_end   = __pa((unsigned long)&data_start);
-	fv_addr  = __pa((unsigned long)&fault_vector_20) & PAGE_MASK;
-	gw_addr  = __pa((unsigned long)&linux_gateway_page) & PAGE_MASK;
+	kernel_end  = __pa((unsigned long)&_end);
 
 	end_paddr = start_paddr + size;
 
@@ -473,24 +469,25 @@ static void __init map_pages(unsigned long start_vaddr,
 			for (tmp2 = start_pte; tmp2 < PTRS_PER_PTE; tmp2++, pg_table++) {
 				pte_t pte;
 
-				/*
-				 * Map the fault vector writable so we can
-				 * write the HPMC checksum.
-				 */
 				if (force)
 					pte =  __mk_pte(address, pgprot);
-				else if (parisc_text_address(vaddr) &&
-					 address != fv_addr)
+				else if (parisc_text_address(vaddr)) {
 					pte = __mk_pte(address, PAGE_KERNEL_EXEC);
+					if (address >= ro_start && address < kernel_end)
+						pte = pte_mkhuge(pte);
+				}
 				else
 #if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
-				if (address >= ro_start && address < ro_end
-							&& address != fv_addr
-							&& address != gw_addr)
-					pte = __mk_pte(address, PAGE_KERNEL_RO);
-				else
+				if (address >= ro_start && address < ro_end) {
+					pte = __mk_pte(address, PAGE_KERNEL_EXEC);
+					pte = pte_mkhuge(pte);
+				} else
 #endif
+				{
 					pte = __mk_pte(address, pgprot);
+					if (address >= ro_start && address < kernel_end)
+						pte = pte_mkhuge(pte);
+				}
 
 				if (address >= end_paddr) {
 					if (force)
@@ -534,15 +531,12 @@ void free_initmem(void)
 
 	/* force the kernel to see the new TLB entries */
 	__flush_tlb_range(0, init_begin, init_end);
-	/* Attempt to catch anyone trying to execute code here
-	 * by filling the page with BRK insns.
-	 */
-	memset((void *)init_begin, 0x00, init_end - init_begin);
+
 	/* finally dump all the instructions which were cached, since the
 	 * pages are no-longer executable */
 	flush_icache_range(init_begin, init_end);
 	
-	free_initmem_default(-1);
+	free_initmem_default(POISON_FREE_INITMEM);
 
 	/* set up a new led state on systems shipped LED State panel */
 	pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BCOMPLETE);
@@ -712,8 +706,8 @@ static void __init pagetable_init(void)
 		unsigned long size;
 
 		start_paddr = pmem_ranges[range].start_pfn << PAGE_SHIFT;
-		end_paddr = start_paddr + (pmem_ranges[range].pages << PAGE_SHIFT);
 		size = pmem_ranges[range].pages << PAGE_SHIFT;
+		end_paddr = start_paddr + size;
 
 		map_pages((unsigned long)__va(start_paddr), start_paddr,
 			  size, PAGE_KERNEL, 0);
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/9] parisc: Fix asm/mman.h regarding MAP_HUGETLB and MADV_XX flags
  2015-11-20 21:38   ` Helge Deller
  (?)
@ 2015-11-21 20:57   ` Ben Hutchings
  2015-11-21 22:22     ` Helge Deller
  -1 siblings, 1 reply; 16+ messages in thread
From: Ben Hutchings @ 2015-11-21 20:57 UTC (permalink / raw)
  To: Helge Deller, linux-parisc; +Cc: James Bottomley, John David Anglin, stable

[-- Attachment #1: Type: text/plain, Size: 4303 bytes --]

On Fri, 2015-11-20 at 22:38 +0100, Helge Deller wrote:
> On parisc we have up to now never supported Huge Pages, even glibc did
> not defined MAP_HUGETLB for parisc. Since the Huge Page support is being
> added now, clean up existing definitions for MAP_HUGETLB and friends.
> 
> Drop lots of MADV_xxK_PAGES flags, which were never used and were
> designed for a patch which was never integrated into the Linux
> kernel. Instead move other MADV_ flags to make them more compatible to
> other linux architectures.

Changing the unimplemented values seems fine, but how can it be OK to
renumber MAP_GROWSUP, MADV_DONTDUMP and MADV_DODUMP?

Ben.

> Cc: stable@vger.kernel.org
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>  arch/parisc/include/uapi/asm/mman.h | 29 ++++++++++-------------------
>  1 file changed, 10 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h
> index 294d251..9ac77f1 100644
> --- a/arch/parisc/include/uapi/asm/mman.h
> +++ b/arch/parisc/include/uapi/asm/mman.h
> @@ -19,11 +19,12 @@
>  #define MAP_EXECUTABLE> 	> 0x1000> 	> 	> /* mark it as an executable */
>  #define MAP_LOCKED> 	> 0x2000> 	> 	> /* pages are locked */
>  #define MAP_NORESERVE> 	> 0x4000> 	> 	> /* don't check for reservations */
> -#define MAP_GROWSDOWN> 	> 0x8000> 	> 	> /* stack-like segment */
> +#define MAP_GROWSDOWN> 	> 0x8000> 	> 	> /* x86 stack-like segment */
>  #define MAP_POPULATE> 	> 0x10000> 	> 	> /* populate (prefault) pagetables */
>  #define MAP_NONBLOCK> 	> 0x20000> 	> 	> /* do not block on IO */
> -#define MAP_STACK> 	> 0x40000> 	> 	> /* give out an address that is best suited for process/thread stacks */
> -#define MAP_HUGETLB> 	> 0x80000> 	> 	> /* create a huge page mapping */
> +#define MAP_HUGETLB> 	> 0x40000> 	> 	> /* create a huge page mapping */
> +#define MAP_GROWSUP> 	> 0x80000> 	> 	> /* parisc stack-like segment */
> +#define MAP_STACK> 	> MAP_GROWSUP> 	> /* give out an address that is best suited for process/thread stacks */
>  
>  #define MS_SYNC> 	> 	> 1> 	> 	> /* synchronous memory sync */
>  #define MS_ASYNC> 	> 2> 	> 	> /* sync memory asynchronously */
> @@ -46,25 +47,15 @@
>  #define MADV_DONTFORK> 	> 10> 	> 	> /* don't inherit across fork */
>  #define MADV_DOFORK> 	> 11> 	> 	> /* do inherit across fork */
>  
> -/* The range 12-64 is reserved for page size specification. */
> -#define MADV_4K_PAGES   12              /* Use 4K pages  */
> -#define MADV_16K_PAGES  14              /* Use 16K pages */
> -#define MADV_64K_PAGES  16              /* Use 64K pages */
> -#define MADV_256K_PAGES 18              /* Use 256K pages */
> -#define MADV_1M_PAGES   20              /* Use 1 Megabyte pages */
> -#define MADV_4M_PAGES   22              /* Use 4 Megabyte pages */
> -#define MADV_16M_PAGES  24              /* Use 16 Megabyte pages */
> -#define MADV_64M_PAGES  26              /* Use 64 Megabyte pages */
> +#define MADV_MERGEABLE   12> 	> 	> /* KSM may merge identical pages */
> +#define MADV_UNMERGEABLE 13> 	> 	> /* KSM may not merge identical pages */
>  
> -#define MADV_MERGEABLE   65> 	> 	> /* KSM may merge identical pages */
> -#define MADV_UNMERGEABLE 66> 	> 	> /* KSM may not merge identical pages */
> +#define MADV_HUGEPAGE> 	> 14> 	> 	> /* Worth backing with hugepages */
> +#define MADV_NOHUGEPAGE> 	> 15> 	> 	> /* Not worth backing with hugepages */
>  
> -#define MADV_HUGEPAGE> 	> 67> 	> 	> /* Worth backing with hugepages */
> -#define MADV_NOHUGEPAGE> 	> 68> 	> 	> /* Not worth backing with hugepages */
> -
> -#define MADV_DONTDUMP   69> 	> 	> /* Explicity exclude from the core dump,
> +#define MADV_DONTDUMP   16> 	> 	> /* Explicity exclude from the core dump,
>  > 	> 	> 	> 	> 	>    overrides the coredump filter bits */
> -#define MADV_DODUMP> 	> 70> 	> 	> /* Clear the MADV_NODUMP flag */
> +#define MADV_DODUMP> 	> 17> 	> 	> /* Clear the MADV_NODUMP flag */
>  
>  /* compatibility flags */
>  #define MAP_FILE> 	> 0
-- 
Ben Hutchings
If you seem to know what you are doing, you'll be given more to do.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/9] parisc: Fix asm/mman.h regarding MAP_HUGETLB and MADV_XX flags
  2015-11-21 20:57   ` Ben Hutchings
@ 2015-11-21 22:22     ` Helge Deller
  2015-11-22  2:21       ` Ben Hutchings
  0 siblings, 1 reply; 16+ messages in thread
From: Helge Deller @ 2015-11-21 22:22 UTC (permalink / raw)
  To: Ben Hutchings, linux-parisc; +Cc: James Bottomley, John David Anglin, stable

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Ben,

On 21.11.2015 21:57, Ben Hutchings wrote:
> On Fri, 2015-11-20 at 22:38 +0100, Helge Deller wrote:
>> On parisc we have up to now never supported Huge Pages, even glibc did
>> not defined MAP_HUGETLB for parisc. Since the Huge Page support is being
>> added now, clean up existing definitions for MAP_HUGETLB and friends.
>>
>> Drop lots of MADV_xxK_PAGES flags, which were never used and were
>> designed for a patch which was never integrated into the Linux
>> kernel. Instead move other MADV_ flags to make them more compatible to
>> other linux architectures.
> 
> Changing the unimplemented values seems fine, but how can it be OK to
> renumber MAP_GROWSUP, MADV_DONTDUMP and MADV_DODUMP?

MAP_GROWSUP is new.
MAP_STACK changed, but doesn't seeem to be used inside the kernel anyway.
MAP_HUGETLB is new.

MADV_DONTDUMP and MADV_DODUMP changed, but I tend to think that they are
not widely used (if at all on parisc), and even in glibc they are only
accessible if applications included <linux/mman.h>.
So, having the same value for both as all other architectures gives long-term
probably more benefits than keeping the current values.
My testings up to now didn't showed problems, but I'm not religious on it.
If everyone thinks it's better to not change MADV_DONTDUMP and MADV_DODUMP
I will do so.

*BUT*:
This patch was not planned by me to be sent to the stable mailing list *yet*.
Please don't apply it to the stable kernels yet, since it's not upstream yet.
I was planning to push it down with the upstream commit...

(git send-mail fooled me, I just sent to the linux-parisc mailing list, James
and Dave, but I wasn't aware that git-send-mail sent it automatically too stable
as well)
 
Helge

>> Cc: stable@vger.kernel.org
>> Signed-off-by: Helge Deller <deller@gmx.de>
>> ---
>>  arch/parisc/include/uapi/asm/mman.h | 29 ++++++++++-------------------
>>  1 file changed, 10 insertions(+), 19 deletions(-)
>>
>> diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h
>> index 294d251..9ac77f1 100644
>> --- a/arch/parisc/include/uapi/asm/mman.h
>> +++ b/arch/parisc/include/uapi/asm/mman.h
>> @@ -19,11 +19,12 @@
>>  #define MAP_EXECUTABLE> 	> 0x1000> 	> 	> /* mark it as an executable */
>>  #define MAP_LOCKED> 	> 0x2000> 	> 	> /* pages are locked */
>>  #define MAP_NORESERVE> 	> 0x4000> 	> 	> /* don't check for reservations */
>> -#define MAP_GROWSDOWN> 	> 0x8000> 	> 	> /* stack-like segment */
>> +#define MAP_GROWSDOWN> 	> 0x8000> 	> 	> /* x86 stack-like segment */
>>  #define MAP_POPULATE> 	> 0x10000> 	> 	> /* populate (prefault) pagetables */
>>  #define MAP_NONBLOCK> 	> 0x20000> 	> 	> /* do not block on IO */
>> -#define MAP_STACK> 	> 0x40000> 	> 	> /* give out an address that is best suited for process/thread stacks */
>> -#define MAP_HUGETLB> 	> 0x80000> 	> 	> /* create a huge page mapping */
>> +#define MAP_HUGETLB> 	> 0x40000> 	> 	> /* create a huge page mapping */
>> +#define MAP_GROWSUP> 	> 0x80000> 	> 	> /* parisc stack-like segment */
>> +#define MAP_STACK> 	> MAP_GROWSUP> 	> /* give out an address that is best suited for process/thread stacks */
>>  
>>  #define MS_SYNC> 	> 	> 1> 	> 	> /* synchronous memory sync */
>>  #define MS_ASYNC> 	> 2> 	> 	> /* sync memory asynchronously */
>> @@ -46,25 +47,15 @@
>>  #define MADV_DONTFORK> 	> 10> 	> 	> /* don't inherit across fork */
>>  #define MADV_DOFORK> 	> 11> 	> 	> /* do inherit across fork */
>>  
>> -/* The range 12-64 is reserved for page size specification. */
>> -#define MADV_4K_PAGES   12              /* Use 4K pages  */
>> -#define MADV_16K_PAGES  14              /* Use 16K pages */
>> -#define MADV_64K_PAGES  16              /* Use 64K pages */
>> -#define MADV_256K_PAGES 18              /* Use 256K pages */
>> -#define MADV_1M_PAGES   20              /* Use 1 Megabyte pages */
>> -#define MADV_4M_PAGES   22              /* Use 4 Megabyte pages */
>> -#define MADV_16M_PAGES  24              /* Use 16 Megabyte pages */
>> -#define MADV_64M_PAGES  26              /* Use 64 Megabyte pages */
>> +#define MADV_MERGEABLE   12> 	> 	> /* KSM may merge identical pages */
>> +#define MADV_UNMERGEABLE 13> 	> 	> /* KSM may not merge identical pages */
>>  
>> -#define MADV_MERGEABLE   65> 	> 	> /* KSM may merge identical pages */
>> -#define MADV_UNMERGEABLE 66> 	> 	> /* KSM may not merge identical pages */
>> +#define MADV_HUGEPAGE> 	> 14> 	> 	> /* Worth backing with hugepages */
>> +#define MADV_NOHUGEPAGE> 	> 15> 	> 	> /* Not worth backing with hugepages */
>>  
>> -#define MADV_HUGEPAGE> 	> 67> 	> 	> /* Worth backing with hugepages */
>> -#define MADV_NOHUGEPAGE> 	> 68> 	> 	> /* Not worth backing with hugepages */
>> -
>> -#define MADV_DONTDUMP   69> 	> 	> /* Explicity exclude from the core dump,
>> +#define MADV_DONTDUMP   16> 	> 	> /* Explicity exclude from the core dump,
>>  > 	> 	> 	> 	> 	>    overrides the coredump filter bits */
>> -#define MADV_DODUMP> 	> 70> 	> 	> /* Clear the MADV_NODUMP flag */
>> +#define MADV_DODUMP> 	> 17> 	> 	> /* Clear the MADV_NODUMP flag */
>>  
>>  /* compatibility flags */
>>  #define MAP_FILE> 	> 0

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJWUO69AAoJEKGDlV8wpRJBs5YP/3UzD7XA3kfkxKbvUCddjBt8
4UI4xzo7HyVKc2C6IRCihIWqb6KbSw+6dgqVNIPqZIOfeiueHYAz92X36mJB4c/B
xXmoUK2W6aKNDIXI4pmzZ//7MRvblSLQTjtSKb2z9sKe2SffJjra8khQGQCKcZcm
/xRYgzwMFw37YaGQnYABlciCHOEdAoN7vN5NhUXbxUHFdDIYxM+wXm0BzBudKvPT
/dMnGIvRnS4XCminK+wCXPQMR4E6MMBr3+UsRZm8G7/r7VmqKXg2BRbTQfeMV5a7
s3+1tw5p0a6DzrTngSDZK/udHnzvd16Beugha1lIKVBinYfG9nyu6ZI0y0kMank5
571swgUzRjxWLWRsSPbowO4gZJCWSS4mFC4RnziW5nzFzzXMC9tD2Osp9EL8yev3
NLPoxr1YcajS4CcOMpyS00rq1VBjKdwqAxDCXsLDEj7YFv7wSHkW8+BK4TfkuHYk
v7tV3NxLZdbr0IPEliiegf/+XnBVSmyTVk7kSV+NOub8X1RfL6MO8jcDV44yd5OZ
rgE8lkmEMh00cSU35YP1+MhuRDujRVQhIj2Xk36eO1R3a6pDb3y8B3w35KxxCobz
Onxa2KNSn6u7DEBOSDIGc9yxxjYR5M+Fnqs6wPCpGndbwaumOFB3VAR3Pfi/J/z5
dgwjngMT7PlZzry3K6jE
=s6EG
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/9] parisc: Fix asm/mman.h regarding MAP_HUGETLB and MADV_XX flags
  2015-11-21 22:22     ` Helge Deller
@ 2015-11-22  2:21       ` Ben Hutchings
  2015-11-22 11:10         ` Helge Deller
  0 siblings, 1 reply; 16+ messages in thread
From: Ben Hutchings @ 2015-11-22  2:21 UTC (permalink / raw)
  To: Helge Deller, linux-parisc; +Cc: James Bottomley, John David Anglin, stable

[-- Attachment #1: Type: text/plain, Size: 1777 bytes --]

On Sat, 2015-11-21 at 23:22 +0100, Helge Deller wrote:
> Hi Ben,
> 
> On 21.11.2015 21:57, Ben Hutchings wrote:
> > On Fri, 2015-11-20 at 22:38 +0100, Helge Deller wrote:
> > > On parisc we have up to now never supported Huge Pages, even glibc did
> > > not defined MAP_HUGETLB for parisc. Since the Huge Page support is being
> > > added now, clean up existing definitions for MAP_HUGETLB and friends.
> > > 
> > > Drop lots of MADV_xxK_PAGES flags, which were never used and were
> > > designed for a patch which was never integrated into the Linux
> > > kernel. Instead move other MADV_ flags to make them more compatible to
> > > other linux architectures.
> > 
> > Changing the unimplemented values seems fine, but how can it be OK to
> > renumber MAP_GROWSUP, MADV_DONTDUMP and MADV_DODUMP?
> 
> MAP_GROWSUP is new.
> MAP_STACK changed, but doesn't seeem to be used inside the kernel anyway.

It may not be implemented in the kernel, but it is certainly used by
userland:
https://sources.debian.net/src/glibc/2.19-20/nptl/allocatestack.c/#L513

So you can't assign any new semantics to that bit, and you might as
well keep MAP_STACK as the same value.

> MAP_HUGETLB is new.
> 
> MADV_DONTDUMP and MADV_DODUMP changed, but I tend to think that they are
> not widely used (if at all on parisc), and even in glibc they are only
> accessible if applications included .
> So, having the same value for both as all other architectures gives long-term
> probably more benefits than keeping the current values.
[...]

This does not trump the fact that existing applications may break and
that is something we generally try very hard to avoid.

Ben.

-- 
Ben Hutchings
If you seem to know what you are doing, you'll be given more to do.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/9] parisc: Fix asm/mman.h regarding MAP_HUGETLB and MADV_XX flags
  2015-11-22  2:21       ` Ben Hutchings
@ 2015-11-22 11:10         ` Helge Deller
  0 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-22 11:10 UTC (permalink / raw)
  To: Ben Hutchings, linux-parisc; +Cc: James Bottomley, John David Anglin, stable

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Ben,

On 22.11.2015 03:21, Ben Hutchings wrote:
> On Sat, 2015-11-21 at 23:22 +0100, Helge Deller wrote:
>> On 21.11.2015 21:57, Ben Hutchings wrote:
>>> On Fri, 2015-11-20 at 22:38 +0100, Helge Deller wrote:
>>>> On parisc we have up to now never supported Huge Pages, even glibc did
>>>> not defined MAP_HUGETLB for parisc. Since the Huge Page support is being
>>>> added now, clean up existing definitions for MAP_HUGETLB and friends.
>>>>
>>>> Drop lots of MADV_xxK_PAGES flags, which were never used and were
>>>> designed for a patch which was never integrated into the Linux
>>>> kernel. Instead move other MADV_ flags to make them more compatible to
>>>> other linux architectures.
>>>
>>> Changing the unimplemented values seems fine, but how can it be OK to
>>> renumber MAP_GROWSUP, MADV_DONTDUMP and MADV_DODUMP?
>>
>> MAP_GROWSUP is new.
>> MAP_STACK changed, but doesn't seeem to be used inside the kernel anyway.
> 
> It may not be implemented in the kernel, but it is certainly used by
> userland:
> https://sources.debian.net/src/glibc/2.19-20/nptl/allocatestack.c/#L513

I knew this one, but didn't faced any problems.

Anyway, I will rework my patch and just drop the unnecessary MADV_xxxK_PAGES
flags.

Thanks!

Helge
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJWUaK8AAoJEKGDlV8wpRJBZRYP/2veyj1ZhqmF1uE8h/t96H3G
WWhmQyzce8VJZUbOQdicYIUbLWj4CZLQUE+l59afPTHQqnUTo6nHKhsOKl4SBp8t
2+77qWUsDnv68pt4IOGAiAVJSYVgtkK+cB4ROmDJAUzJY5aVQF9/kfsDGx1+RWeX
ozXmRoGY/ANCVDiO+y8hOraOb6XHWhHidHNfynadAGVvy9egqHi7H6shb1KbFVIi
puw5kZD9grcvBoE+Ot0hpsufsjfvdeNRXwXQKW7+bwpIKbowxFbi6OyCJn9uy7aW
7uFBiJbDl4ZFk9zsE3dkEWDi6fyFgpBZic/p9lDCr95e26q8peTBpkgz1oHpzDh+
Q2/8zMu0vHKSVNAeuU16dQXT7yKSXKjBnLPFHzrvGLTRXQ9SLJmFx6+UVRUANe0e
K5/Hd8FDs1X0+5wOSK0Kj2CwQwZoO3K9XAZ5TTPQhw/2FTh7Kq5ixMUPhoiYtN4X
zpZZPE5Dd6JgCWm9SR5XM3V26DDz1gSZLs9FjdcVDW4xSivKK6X9onPEoB5ju2o+
/C78qDopRkhmaklYortbZ3wK/UEYSWKVtGmzW6L+/evC9M+/i3nmqMmMab7TjZDV
+plleRrZzbNnPpLdqOXMNlaKg9k232GjcoilMdigb0GRXvDj0KXqPeu9HkFnI7dV
utuUBUrWRZIfjha65eZa
=fi31
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/9] parisc: Fix asm/mman.h regarding MAP_HUGETLB and MADV_XX flags
       [not found] <1448054745-11031-1-git-send-email-deller@gmx.de>
@ 2015-11-20 21:25 ` Helge Deller
  0 siblings, 0 replies; 16+ messages in thread
From: Helge Deller @ 2015-11-20 21:25 UTC (permalink / raw)
  To: helge.deller; +Cc: stable

On parisc we have up to now never supported Huge Pages, even glibc did
not defined MAP_HUGETLB for parisc. Since the Huge Page support is being
added now, clean up existing definitions for MAP_HUGETLB and friends.

Drop lots of MADV_xxK_PAGES flags, which were never used and were
designed for a patch which was never integrated into the Linux
kernel. Instead move other MADV_ flags to make them more compatible to
other linux architectures.

Cc: stable@vger.kernel.org
Signed-off-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/include/uapi/asm/mman.h | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/arch/parisc/include/uapi/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h
index 294d251..9ac77f1 100644
--- a/arch/parisc/include/uapi/asm/mman.h
+++ b/arch/parisc/include/uapi/asm/mman.h
@@ -19,11 +19,12 @@
 #define MAP_EXECUTABLE	0x1000		/* mark it as an executable */
 #define MAP_LOCKED	0x2000		/* pages are locked */
 #define MAP_NORESERVE	0x4000		/* don't check for reservations */
-#define MAP_GROWSDOWN	0x8000		/* stack-like segment */
+#define MAP_GROWSDOWN	0x8000		/* x86 stack-like segment */
 #define MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
 #define MAP_NONBLOCK	0x20000		/* do not block on IO */
-#define MAP_STACK	0x40000		/* give out an address that is best suited for process/thread stacks */
-#define MAP_HUGETLB	0x80000		/* create a huge page mapping */
+#define MAP_HUGETLB	0x40000		/* create a huge page mapping */
+#define MAP_GROWSUP	0x80000		/* parisc stack-like segment */
+#define MAP_STACK	MAP_GROWSUP	/* give out an address that is best suited for process/thread stacks */
 
 #define MS_SYNC		1		/* synchronous memory sync */
 #define MS_ASYNC	2		/* sync memory asynchronously */
@@ -46,25 +47,15 @@
 #define MADV_DONTFORK	10		/* don't inherit across fork */
 #define MADV_DOFORK	11		/* do inherit across fork */
 
-/* The range 12-64 is reserved for page size specification. */
-#define MADV_4K_PAGES   12              /* Use 4K pages  */
-#define MADV_16K_PAGES  14              /* Use 16K pages */
-#define MADV_64K_PAGES  16              /* Use 64K pages */
-#define MADV_256K_PAGES 18              /* Use 256K pages */
-#define MADV_1M_PAGES   20              /* Use 1 Megabyte pages */
-#define MADV_4M_PAGES   22              /* Use 4 Megabyte pages */
-#define MADV_16M_PAGES  24              /* Use 16 Megabyte pages */
-#define MADV_64M_PAGES  26              /* Use 64 Megabyte pages */
+#define MADV_MERGEABLE   12		/* KSM may merge identical pages */
+#define MADV_UNMERGEABLE 13		/* KSM may not merge identical pages */
 
-#define MADV_MERGEABLE   65		/* KSM may merge identical pages */
-#define MADV_UNMERGEABLE 66		/* KSM may not merge identical pages */
+#define MADV_HUGEPAGE	14		/* Worth backing with hugepages */
+#define MADV_NOHUGEPAGE	15		/* Not worth backing with hugepages */
 
-#define MADV_HUGEPAGE	67		/* Worth backing with hugepages */
-#define MADV_NOHUGEPAGE	68		/* Not worth backing with hugepages */
-
-#define MADV_DONTDUMP   69		/* Explicity exclude from the core dump,
+#define MADV_DONTDUMP   16		/* Explicity exclude from the core dump,
 					   overrides the coredump filter bits */
-#define MADV_DODUMP	70		/* Clear the MADV_NODUMP flag */
+#define MADV_DODUMP	17		/* Clear the MADV_NODUMP flag */
 
 /* compatibility flags */
 #define MAP_FILE	0
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-11-22 11:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20 21:38 [PATCH 0/9] Add Huge Page support for parisc Helge Deller
2015-11-20 21:38 ` [PATCH 1/9] parisc: Fix wrong comment regarding first pmd entry flags Helge Deller
2015-11-20 21:38 ` [PATCH 2/9] parisc: Drop definition of start_thread_som for HP-UX SOM binaries Helge Deller
2015-11-20 21:38 ` [PATCH 3/9] parisc: Fix asm/mman.h regarding MAP_HUGETLB and MADV_XX flags Helge Deller
2015-11-20 21:38   ` Helge Deller
2015-11-21 20:57   ` Ben Hutchings
2015-11-21 22:22     ` Helge Deller
2015-11-22  2:21       ` Ben Hutchings
2015-11-22 11:10         ` Helge Deller
2015-11-20 21:38 ` [PATCH 4/9] parisc: Add defines for Huge page support Helge Deller
2015-11-20 21:38 ` [PATCH 5/9] parisc: Initialize the fault vector earlier in the boot process Helge Deller
2015-11-20 21:38 ` [PATCH 6/9] parisc: Increase initial kernel mapping to 32MB on 64bit kernel Helge Deller
2015-11-20 21:38 ` [PATCH 7/9] parisc: Use long branch to do_syscall_trace_exit Helge Deller
2015-11-20 21:38 ` [PATCH 8/9] parisc: Add Huge Page and HUGETLBFS support Helge Deller
2015-11-20 21:38 ` [PATCH 9/9] parisc: Map kernel text and data on huge pages Helge Deller
     [not found] <1448054745-11031-1-git-send-email-deller@gmx.de>
2015-11-20 21:25 ` [PATCH 3/9] parisc: Fix asm/mman.h regarding MAP_HUGETLB and MADV_XX flags Helge Deller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.