All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/4] 52-bit userspace VAs
@ 2018-10-17 16:34 ` Steve Capper
  0 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-17 16:34 UTC (permalink / raw)
  To: linux-mm, linux-arm-kernel
  Cc: catalin.marinas, will.deacon, ard.biesheuvel, jcm, Steve Capper

This patch series brings support for 52-bit userspace VAs to systems that
have ARMv8.2-LVA and are running with a 48-bit VA_BITS and a 64KB
PAGE_SIZE.

If no hardware support is present, the kernel runs with a 48-bit VA space
for userspace.

Userspace can exploit this feature by providing an address hint to mmap
where addr[51:48] != 0. Otherwise all the VA mappings will behave in the
same way as a 48-bit VA system (this is to maintain compatibility with
software that assumes the maximum VA size on arm64 is 48-bit).

This patch series applies to 4.19-rc7.

Testing was in a model with Trusted Firmware and UEFI for boot.

The major change to V2 of the series is that mm/mmap.c is altered in the
first patch of the series (rather than copied over to arch/arm64).


Steve Capper (4):
  mm: mmap: Allow for "high" userspace addresses
  arm64: mm: Introduce DEFAULT_MAP_WINDOW
  arm64: mm: Define arch_get_mmap_end, arch_get_mmap_base
  arm64: mm: introduce 52-bit userspace support

 arch/arm64/Kconfig                      |  4 ++++
 arch/arm64/include/asm/assembler.h      |  7 +++----
 arch/arm64/include/asm/elf.h            |  2 +-
 arch/arm64/include/asm/mmu_context.h    |  3 +++
 arch/arm64/include/asm/pgalloc.h        |  4 ++++
 arch/arm64/include/asm/pgtable.h        | 16 +++++++++++++---
 arch/arm64/include/asm/processor.h      | 29 ++++++++++++++++++++++-------
 arch/arm64/kernel/head.S                | 13 +++++++++++++
 arch/arm64/mm/fault.c                   |  2 +-
 arch/arm64/mm/mmu.c                     |  1 +
 arch/arm64/mm/proc.S                    | 10 +++++++++-
 drivers/firmware/efi/arm-runtime.c      |  2 +-
 drivers/firmware/efi/libstub/arm-stub.c |  2 +-
 mm/mmap.c                               | 25 ++++++++++++++++++-------
 14 files changed, 94 insertions(+), 26 deletions(-)

-- 
2.11.0

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

* [PATCH V2 0/4] 52-bit userspace VAs
@ 2018-10-17 16:34 ` Steve Capper
  0 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-17 16:34 UTC (permalink / raw)
  To: linux-arm-kernel

This patch series brings support for 52-bit userspace VAs to systems that
have ARMv8.2-LVA and are running with a 48-bit VA_BITS and a 64KB
PAGE_SIZE.

If no hardware support is present, the kernel runs with a 48-bit VA space
for userspace.

Userspace can exploit this feature by providing an address hint to mmap
where addr[51:48] != 0. Otherwise all the VA mappings will behave in the
same way as a 48-bit VA system (this is to maintain compatibility with
software that assumes the maximum VA size on arm64 is 48-bit).

This patch series applies to 4.19-rc7.

Testing was in a model with Trusted Firmware and UEFI for boot.

The major change to V2 of the series is that mm/mmap.c is altered in the
first patch of the series (rather than copied over to arch/arm64).


Steve Capper (4):
  mm: mmap: Allow for "high" userspace addresses
  arm64: mm: Introduce DEFAULT_MAP_WINDOW
  arm64: mm: Define arch_get_mmap_end, arch_get_mmap_base
  arm64: mm: introduce 52-bit userspace support

 arch/arm64/Kconfig                      |  4 ++++
 arch/arm64/include/asm/assembler.h      |  7 +++----
 arch/arm64/include/asm/elf.h            |  2 +-
 arch/arm64/include/asm/mmu_context.h    |  3 +++
 arch/arm64/include/asm/pgalloc.h        |  4 ++++
 arch/arm64/include/asm/pgtable.h        | 16 +++++++++++++---
 arch/arm64/include/asm/processor.h      | 29 ++++++++++++++++++++++-------
 arch/arm64/kernel/head.S                | 13 +++++++++++++
 arch/arm64/mm/fault.c                   |  2 +-
 arch/arm64/mm/mmu.c                     |  1 +
 arch/arm64/mm/proc.S                    | 10 +++++++++-
 drivers/firmware/efi/arm-runtime.c      |  2 +-
 drivers/firmware/efi/libstub/arm-stub.c |  2 +-
 mm/mmap.c                               | 25 ++++++++++++++++++-------
 14 files changed, 94 insertions(+), 26 deletions(-)

-- 
2.11.0

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

* [PATCH V2 1/4] mm: mmap: Allow for "high" userspace addresses
  2018-10-17 16:34 ` Steve Capper
@ 2018-10-17 16:34   ` Steve Capper
  -1 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-17 16:34 UTC (permalink / raw)
  To: linux-mm, linux-arm-kernel
  Cc: catalin.marinas, will.deacon, ard.biesheuvel, jcm, Steve Capper

This patch adds support for "high" userspace addresses that are
optionally supported on the system and have to be requested via a hint
mechanism ("high" addr parameter to mmap).

Rather than duplicate the arch_get_unmapped_* stock implementations,
this patch instead introduces two architectural helper macros and
applies them to arch_get_unmapped_*:
 arch_get_mmap_end(addr) - get mmap upper limit depending on addr hint
 arch_get_mmap_base(addr, base) - get mmap_base depending on addr hint

If these macros are not defined in architectural code then they default
to (TASK_SIZE) and (base) so should not introduce any behavioural
changes to architectures that do not define them.

Signed-off-by: Steve Capper <steve.capper@arm.com>
---
Changed in V2, these alterations are made to mm/mmap.c rather than
copied over to arch/arm64 and modified there.
---
 mm/mmap.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 5f2b2b184c60..396b8ae12783 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2042,6 +2042,15 @@ unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
 	return gap_end;
 }
 
+
+#ifndef arch_get_mmap_end
+#define arch_get_mmap_end(addr)	(TASK_SIZE)
+#endif
+
+#ifndef arch_get_mmap_base
+#define arch_get_mmap_base(addr, base) (base)
+#endif
+
 /* Get an address range which is currently unmapped.
  * For shmat() with addr=0.
  *
@@ -2061,8 +2070,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	struct mm_struct *mm = current->mm;
 	struct vm_area_struct *vma, *prev;
 	struct vm_unmapped_area_info info;
+	const unsigned long mmap_end = arch_get_mmap_end(addr);
 
-	if (len > TASK_SIZE - mmap_min_addr)
+	if (len > mmap_end - mmap_min_addr)
 		return -ENOMEM;
 
 	if (flags & MAP_FIXED)
@@ -2071,7 +2081,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	if (addr) {
 		addr = PAGE_ALIGN(addr);
 		vma = find_vma_prev(mm, addr, &prev);
-		if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
+		if (mmap_end - len >= addr && addr >= mmap_min_addr &&
 		    (!vma || addr + len <= vm_start_gap(vma)) &&
 		    (!prev || addr >= vm_end_gap(prev)))
 			return addr;
@@ -2080,7 +2090,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	info.flags = 0;
 	info.length = len;
 	info.low_limit = mm->mmap_base;
-	info.high_limit = TASK_SIZE;
+	info.high_limit = mmap_end;
 	info.align_mask = 0;
 	return vm_unmapped_area(&info);
 }
@@ -2100,9 +2110,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	struct mm_struct *mm = current->mm;
 	unsigned long addr = addr0;
 	struct vm_unmapped_area_info info;
+	const unsigned long mmap_end = arch_get_mmap_end(addr);
 
 	/* requested length too big for entire address space */
-	if (len > TASK_SIZE - mmap_min_addr)
+	if (len > mmap_end - mmap_min_addr)
 		return -ENOMEM;
 
 	if (flags & MAP_FIXED)
@@ -2112,7 +2123,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	if (addr) {
 		addr = PAGE_ALIGN(addr);
 		vma = find_vma_prev(mm, addr, &prev);
-		if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
+		if (mmap_end - len >= addr && addr >= mmap_min_addr &&
 				(!vma || addr + len <= vm_start_gap(vma)) &&
 				(!prev || addr >= vm_end_gap(prev)))
 			return addr;
@@ -2121,7 +2132,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	info.flags = VM_UNMAPPED_AREA_TOPDOWN;
 	info.length = len;
 	info.low_limit = max(PAGE_SIZE, mmap_min_addr);
-	info.high_limit = mm->mmap_base;
+	info.high_limit = arch_get_mmap_base(addr, mm->mmap_base);
 	info.align_mask = 0;
 	addr = vm_unmapped_area(&info);
 
@@ -2135,7 +2146,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 		VM_BUG_ON(addr != -ENOMEM);
 		info.flags = 0;
 		info.low_limit = TASK_UNMAPPED_BASE;
-		info.high_limit = TASK_SIZE;
+		info.high_limit = mmap_end;
 		addr = vm_unmapped_area(&info);
 	}
 
-- 
2.11.0

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

* [PATCH V2 1/4] mm: mmap: Allow for "high" userspace addresses
@ 2018-10-17 16:34   ` Steve Capper
  0 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-17 16:34 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds support for "high" userspace addresses that are
optionally supported on the system and have to be requested via a hint
mechanism ("high" addr parameter to mmap).

Rather than duplicate the arch_get_unmapped_* stock implementations,
this patch instead introduces two architectural helper macros and
applies them to arch_get_unmapped_*:
 arch_get_mmap_end(addr) - get mmap upper limit depending on addr hint
 arch_get_mmap_base(addr, base) - get mmap_base depending on addr hint

If these macros are not defined in architectural code then they default
to (TASK_SIZE) and (base) so should not introduce any behavioural
changes to architectures that do not define them.

Signed-off-by: Steve Capper <steve.capper@arm.com>
---
Changed in V2, these alterations are made to mm/mmap.c rather than
copied over to arch/arm64 and modified there.
---
 mm/mmap.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 5f2b2b184c60..396b8ae12783 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2042,6 +2042,15 @@ unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
 	return gap_end;
 }
 
+
+#ifndef arch_get_mmap_end
+#define arch_get_mmap_end(addr)	(TASK_SIZE)
+#endif
+
+#ifndef arch_get_mmap_base
+#define arch_get_mmap_base(addr, base) (base)
+#endif
+
 /* Get an address range which is currently unmapped.
  * For shmat() with addr=0.
  *
@@ -2061,8 +2070,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	struct mm_struct *mm = current->mm;
 	struct vm_area_struct *vma, *prev;
 	struct vm_unmapped_area_info info;
+	const unsigned long mmap_end = arch_get_mmap_end(addr);
 
-	if (len > TASK_SIZE - mmap_min_addr)
+	if (len > mmap_end - mmap_min_addr)
 		return -ENOMEM;
 
 	if (flags & MAP_FIXED)
@@ -2071,7 +2081,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	if (addr) {
 		addr = PAGE_ALIGN(addr);
 		vma = find_vma_prev(mm, addr, &prev);
-		if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
+		if (mmap_end - len >= addr && addr >= mmap_min_addr &&
 		    (!vma || addr + len <= vm_start_gap(vma)) &&
 		    (!prev || addr >= vm_end_gap(prev)))
 			return addr;
@@ -2080,7 +2090,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
 	info.flags = 0;
 	info.length = len;
 	info.low_limit = mm->mmap_base;
-	info.high_limit = TASK_SIZE;
+	info.high_limit = mmap_end;
 	info.align_mask = 0;
 	return vm_unmapped_area(&info);
 }
@@ -2100,9 +2110,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	struct mm_struct *mm = current->mm;
 	unsigned long addr = addr0;
 	struct vm_unmapped_area_info info;
+	const unsigned long mmap_end = arch_get_mmap_end(addr);
 
 	/* requested length too big for entire address space */
-	if (len > TASK_SIZE - mmap_min_addr)
+	if (len > mmap_end - mmap_min_addr)
 		return -ENOMEM;
 
 	if (flags & MAP_FIXED)
@@ -2112,7 +2123,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	if (addr) {
 		addr = PAGE_ALIGN(addr);
 		vma = find_vma_prev(mm, addr, &prev);
-		if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
+		if (mmap_end - len >= addr && addr >= mmap_min_addr &&
 				(!vma || addr + len <= vm_start_gap(vma)) &&
 				(!prev || addr >= vm_end_gap(prev)))
 			return addr;
@@ -2121,7 +2132,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 	info.flags = VM_UNMAPPED_AREA_TOPDOWN;
 	info.length = len;
 	info.low_limit = max(PAGE_SIZE, mmap_min_addr);
-	info.high_limit = mm->mmap_base;
+	info.high_limit = arch_get_mmap_base(addr, mm->mmap_base);
 	info.align_mask = 0;
 	addr = vm_unmapped_area(&info);
 
@@ -2135,7 +2146,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
 		VM_BUG_ON(addr != -ENOMEM);
 		info.flags = 0;
 		info.low_limit = TASK_UNMAPPED_BASE;
-		info.high_limit = TASK_SIZE;
+		info.high_limit = mmap_end;
 		addr = vm_unmapped_area(&info);
 	}
 
-- 
2.11.0

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

* [PATCH V2 2/4] arm64: mm: Introduce DEFAULT_MAP_WINDOW
  2018-10-17 16:34 ` Steve Capper
@ 2018-10-17 16:34   ` Steve Capper
  -1 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-17 16:34 UTC (permalink / raw)
  To: linux-mm, linux-arm-kernel
  Cc: catalin.marinas, will.deacon, ard.biesheuvel, jcm, Steve Capper

We wish to introduce a 52-bit virtual address space for userspace but
maintain compatibility with software that assumes the maximum VA space
size is 48 bit.

In order to achieve this, on 52-bit VA systems, we make mmap behave as
if it were running on a 48-bit VA system (unless userspace explicitly
requests a VA where addr[51:48] != 0).

On a system running a 52-bit userspace we need TASK_SIZE to represent
the 52-bit limit as it is used in various places to distinguish between
kernelspace and userspace addresses.

Thus we need a new limit for mmap, stack, ELF loader and EFI (which uses
TTBR0) to represent the non-extended VA space.

This patch introduces DEFAULT_MAP_WINDOW and DEFAULT_MAP_WINDOW_64 and
switches the appropriate logic to use that instead of TASK_SIZE.

Signed-off-by: Steve Capper <steve.capper@arm.com>
---
 arch/arm64/include/asm/elf.h            | 2 +-
 arch/arm64/include/asm/processor.h      | 9 +++++++--
 drivers/firmware/efi/arm-runtime.c      | 2 +-
 drivers/firmware/efi/libstub/arm-stub.c | 2 +-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 433b9554c6a1..bc9bd9e77d9d 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -117,7 +117,7 @@
  * 64-bit, this is above 4GB to leave the entire 32-bit address
  * space open for things that want to use the area for 32-bit pointers.
  */
-#define ELF_ET_DYN_BASE		(2 * TASK_SIZE_64 / 3)
+#define ELF_ET_DYN_BASE		(2 * DEFAULT_MAP_WINDOW_64 / 3)
 
 #ifndef __ASSEMBLY__
 
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 79657ad91397..46c9d9ff028c 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -26,6 +26,8 @@
 
 #ifndef __ASSEMBLY__
 
+#define DEFAULT_MAP_WINDOW_64	(UL(1) << VA_BITS)
+
 /*
  * Default implementation of macro that returns current
  * instruction pointer ("program counter").
@@ -58,13 +60,16 @@
 				TASK_SIZE_32 : TASK_SIZE_64)
 #define TASK_SIZE_OF(tsk)	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
 				TASK_SIZE_32 : TASK_SIZE_64)
+#define DEFAULT_MAP_WINDOW	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
+				TASK_SIZE_32 : DEFAULT_MAP_WINDOW_64)
 #else
 #define TASK_SIZE		TASK_SIZE_64
+#define DEFAULT_MAP_WINDOW	DEFAULT_MAP_WINDOW_64
 #endif /* CONFIG_COMPAT */
 
-#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(TASK_SIZE / 4))
+#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
+#define STACK_TOP_MAX		DEFAULT_MAP_WINDOW_64
 
-#define STACK_TOP_MAX		TASK_SIZE_64
 #ifdef CONFIG_COMPAT
 #define AARCH32_VECTORS_BASE	0xffff0000
 #define STACK_TOP		(test_thread_flag(TIF_32BIT) ? \
diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
index 922cfb813109..952cec5b611a 100644
--- a/drivers/firmware/efi/arm-runtime.c
+++ b/drivers/firmware/efi/arm-runtime.c
@@ -38,7 +38,7 @@ static struct ptdump_info efi_ptdump_info = {
 	.mm		= &efi_mm,
 	.markers	= (struct addr_marker[]){
 		{ 0,		"UEFI runtime start" },
-		{ TASK_SIZE_64,	"UEFI runtime end" }
+		{ DEFAULT_MAP_WINDOW_64, "UEFI runtime end" }
 	},
 	.base_addr	= 0,
 };
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index 6920033de6d4..ac297c20ab1e 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -33,7 +33,7 @@
 #define EFI_RT_VIRTUAL_SIZE	SZ_512M
 
 #ifdef CONFIG_ARM64
-# define EFI_RT_VIRTUAL_LIMIT	TASK_SIZE_64
+# define EFI_RT_VIRTUAL_LIMIT	DEFAULT_MAP_WINDOW_64
 #else
 # define EFI_RT_VIRTUAL_LIMIT	TASK_SIZE
 #endif
-- 
2.11.0

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

* [PATCH V2 2/4] arm64: mm: Introduce DEFAULT_MAP_WINDOW
@ 2018-10-17 16:34   ` Steve Capper
  0 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-17 16:34 UTC (permalink / raw)
  To: linux-arm-kernel

We wish to introduce a 52-bit virtual address space for userspace but
maintain compatibility with software that assumes the maximum VA space
size is 48 bit.

In order to achieve this, on 52-bit VA systems, we make mmap behave as
if it were running on a 48-bit VA system (unless userspace explicitly
requests a VA where addr[51:48] != 0).

On a system running a 52-bit userspace we need TASK_SIZE to represent
the 52-bit limit as it is used in various places to distinguish between
kernelspace and userspace addresses.

Thus we need a new limit for mmap, stack, ELF loader and EFI (which uses
TTBR0) to represent the non-extended VA space.

This patch introduces DEFAULT_MAP_WINDOW and DEFAULT_MAP_WINDOW_64 and
switches the appropriate logic to use that instead of TASK_SIZE.

Signed-off-by: Steve Capper <steve.capper@arm.com>
---
 arch/arm64/include/asm/elf.h            | 2 +-
 arch/arm64/include/asm/processor.h      | 9 +++++++--
 drivers/firmware/efi/arm-runtime.c      | 2 +-
 drivers/firmware/efi/libstub/arm-stub.c | 2 +-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index 433b9554c6a1..bc9bd9e77d9d 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -117,7 +117,7 @@
  * 64-bit, this is above 4GB to leave the entire 32-bit address
  * space open for things that want to use the area for 32-bit pointers.
  */
-#define ELF_ET_DYN_BASE		(2 * TASK_SIZE_64 / 3)
+#define ELF_ET_DYN_BASE		(2 * DEFAULT_MAP_WINDOW_64 / 3)
 
 #ifndef __ASSEMBLY__
 
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 79657ad91397..46c9d9ff028c 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -26,6 +26,8 @@
 
 #ifndef __ASSEMBLY__
 
+#define DEFAULT_MAP_WINDOW_64	(UL(1) << VA_BITS)
+
 /*
  * Default implementation of macro that returns current
  * instruction pointer ("program counter").
@@ -58,13 +60,16 @@
 				TASK_SIZE_32 : TASK_SIZE_64)
 #define TASK_SIZE_OF(tsk)	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
 				TASK_SIZE_32 : TASK_SIZE_64)
+#define DEFAULT_MAP_WINDOW	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
+				TASK_SIZE_32 : DEFAULT_MAP_WINDOW_64)
 #else
 #define TASK_SIZE		TASK_SIZE_64
+#define DEFAULT_MAP_WINDOW	DEFAULT_MAP_WINDOW_64
 #endif /* CONFIG_COMPAT */
 
-#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(TASK_SIZE / 4))
+#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
+#define STACK_TOP_MAX		DEFAULT_MAP_WINDOW_64
 
-#define STACK_TOP_MAX		TASK_SIZE_64
 #ifdef CONFIG_COMPAT
 #define AARCH32_VECTORS_BASE	0xffff0000
 #define STACK_TOP		(test_thread_flag(TIF_32BIT) ? \
diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
index 922cfb813109..952cec5b611a 100644
--- a/drivers/firmware/efi/arm-runtime.c
+++ b/drivers/firmware/efi/arm-runtime.c
@@ -38,7 +38,7 @@ static struct ptdump_info efi_ptdump_info = {
 	.mm		= &efi_mm,
 	.markers	= (struct addr_marker[]){
 		{ 0,		"UEFI runtime start" },
-		{ TASK_SIZE_64,	"UEFI runtime end" }
+		{ DEFAULT_MAP_WINDOW_64, "UEFI runtime end" }
 	},
 	.base_addr	= 0,
 };
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index 6920033de6d4..ac297c20ab1e 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -33,7 +33,7 @@
 #define EFI_RT_VIRTUAL_SIZE	SZ_512M
 
 #ifdef CONFIG_ARM64
-# define EFI_RT_VIRTUAL_LIMIT	TASK_SIZE_64
+# define EFI_RT_VIRTUAL_LIMIT	DEFAULT_MAP_WINDOW_64
 #else
 # define EFI_RT_VIRTUAL_LIMIT	TASK_SIZE
 #endif
-- 
2.11.0

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

* [PATCH V2 3/4] arm64: mm: Define arch_get_mmap_end, arch_get_mmap_base
  2018-10-17 16:34 ` Steve Capper
@ 2018-10-17 16:34   ` Steve Capper
  -1 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-17 16:34 UTC (permalink / raw)
  To: linux-mm, linux-arm-kernel
  Cc: catalin.marinas, will.deacon, ard.biesheuvel, jcm, Steve Capper

Now that we have DEFAULT_MAP_WINDOW defined, we can arch_get_mmap_end
and arch_get_mmap_base helpers to allow for high addresses in mmap.

Signed-off-by: Steve Capper <steve.capper@arm.com>
---
 arch/arm64/include/asm/processor.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 46c9d9ff028c..5afc0c5eb1cb 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -78,6 +78,13 @@
 #define STACK_TOP		STACK_TOP_MAX
 #endif /* CONFIG_COMPAT */
 
+#define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\
+				DEFAULT_MAP_WINDOW)
+
+#define arch_get_mmap_base(addr, base) ((addr > DEFAULT_MAP_WINDOW) ? \
+					base + TASK_SIZE - DEFAULT_MAP_WINDOW :\
+					base)
+
 extern phys_addr_t arm64_dma_phys_limit;
 #define ARCH_LOW_ADDRESS_LIMIT	(arm64_dma_phys_limit - 1)
 
-- 
2.11.0

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

* [PATCH V2 3/4] arm64: mm: Define arch_get_mmap_end, arch_get_mmap_base
@ 2018-10-17 16:34   ` Steve Capper
  0 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-17 16:34 UTC (permalink / raw)
  To: linux-arm-kernel

Now that we have DEFAULT_MAP_WINDOW defined, we can arch_get_mmap_end
and arch_get_mmap_base helpers to allow for high addresses in mmap.

Signed-off-by: Steve Capper <steve.capper@arm.com>
---
 arch/arm64/include/asm/processor.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 46c9d9ff028c..5afc0c5eb1cb 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -78,6 +78,13 @@
 #define STACK_TOP		STACK_TOP_MAX
 #endif /* CONFIG_COMPAT */
 
+#define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\
+				DEFAULT_MAP_WINDOW)
+
+#define arch_get_mmap_base(addr, base) ((addr > DEFAULT_MAP_WINDOW) ? \
+					base + TASK_SIZE - DEFAULT_MAP_WINDOW :\
+					base)
+
 extern phys_addr_t arm64_dma_phys_limit;
 #define ARCH_LOW_ADDRESS_LIMIT	(arm64_dma_phys_limit - 1)
 
-- 
2.11.0

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

* [PATCH V2 4/4] arm64: mm: introduce 52-bit userspace support
  2018-10-17 16:34 ` Steve Capper
@ 2018-10-17 16:34   ` Steve Capper
  -1 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-17 16:34 UTC (permalink / raw)
  To: linux-mm, linux-arm-kernel
  Cc: catalin.marinas, will.deacon, ard.biesheuvel, jcm, Steve Capper

On arm64 there is optional support for a 52-bit virtual address space.
To exploit this one has to be running with a 64KB page size and be
running on hardware that supports this.

For an arm64 kernel supporting a 48 bit VA with a 64KB page size,
a few changes are needed to support a 52-bit userspace:
 * TCR_EL1.T0SZ needs to be 12 instead of 16,
 * pgd_offset needs to work with a different PTRS_PER_PGD,
 * PGD_SIZE needs to be increased,
 * TASK_SIZE needs to reflect the new size.

This patch implements the above when the support for 52-bit VAs is
detected at early boot time.

On arm64 userspace addresses translation is controlled by TTBR0_EL1. As
well as userspace, TTBR0_EL1 controls:
 * The identity mapping,
 * EFI runtime code.

It is possible to run a kernel with an identity mapping that has a
larger VA size than userspace (and for this case __cpu_set_tcr_t0sz()
would set TCR_EL1.T0SZ as appropriate). However, when the conditions for
52-bit userspace are met; it is possible to keep TCR_EL1.T0SZ fixed at
12. Thus in this patch, the TCR_EL1.T0SZ size changing logic is
disabled.

Signed-off-by: Steve Capper <steve.capper@arm.com>
---
Changed in V2: variable USER_DS limit dropped, this simplifies the
patch considerably. We check for userspace mappings with init_mm rather
than looking at the virtual address.
---
 arch/arm64/Kconfig                   |  4 ++++
 arch/arm64/include/asm/assembler.h   |  7 +++----
 arch/arm64/include/asm/mmu_context.h |  3 +++
 arch/arm64/include/asm/pgalloc.h     |  4 ++++
 arch/arm64/include/asm/pgtable.h     | 16 +++++++++++++---
 arch/arm64/include/asm/processor.h   | 13 ++++++++-----
 arch/arm64/kernel/head.S             | 13 +++++++++++++
 arch/arm64/mm/fault.c                |  2 +-
 arch/arm64/mm/mmu.c                  |  1 +
 arch/arm64/mm/proc.S                 | 10 +++++++++-
 10 files changed, 59 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1b1a0e95c751..ce6ebba101de 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -691,6 +691,10 @@ config ARM64_PA_BITS_52
 
 endchoice
 
+config ARM64_52BIT_VA
+	def_bool y
+	depends on ARM64_VA_BITS_48 && ARM64_64K_PAGES
+
 config ARM64_PA_BITS
 	int
 	default 48 if ARM64_PA_BITS_48
diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 0bcc98dbba56..8c8ed20beca9 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -343,11 +343,10 @@ alternative_endif
 	.endm
 
 /*
- * tcr_set_idmap_t0sz - update TCR.T0SZ so that we can load the ID map
+ * tcr_set_t0sz - update TCR.T0SZ so that we can load the ID map
  */
-	.macro	tcr_set_idmap_t0sz, valreg, tmpreg
-	ldr_l	\tmpreg, idmap_t0sz
-	bfi	\valreg, \tmpreg, #TCR_T0SZ_OFFSET, #TCR_TxSZ_WIDTH
+	.macro	tcr_set_t0sz, valreg, t0sz
+	bfi	\valreg, \t0sz, #TCR_T0SZ_OFFSET, #TCR_TxSZ_WIDTH
 	.endm
 
 /*
diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h
index 39ec0b8a689e..1b7408e8d794 100644
--- a/arch/arm64/include/asm/mmu_context.h
+++ b/arch/arm64/include/asm/mmu_context.h
@@ -72,6 +72,9 @@ extern u64 idmap_ptrs_per_pgd;
 
 static inline bool __cpu_uses_extended_idmap(void)
 {
+	if (IS_ENABLED(CONFIG_ARM64_52BIT_VA))
+		return false;
+
 	return unlikely(idmap_t0sz != TCR_T0SZ(VA_BITS));
 }
 
diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h
index 2e05bcd944c8..56c3ccabeffe 100644
--- a/arch/arm64/include/asm/pgalloc.h
+++ b/arch/arm64/include/asm/pgalloc.h
@@ -27,7 +27,11 @@
 #define check_pgt_cache()		do { } while (0)
 
 #define PGALLOC_GFP	(GFP_KERNEL | __GFP_ZERO)
+#ifdef CONFIG_ARM64_52BIT_VA
+#define PGD_SIZE	((1 << (52 - PGDIR_SHIFT)) * sizeof(pgd_t))
+#else
 #define PGD_SIZE	(PTRS_PER_PGD * sizeof(pgd_t))
+#endif
 
 #if CONFIG_PGTABLE_LEVELS > 2
 
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 1bdeca8918a6..b18df27b06e0 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -577,11 +577,21 @@ static inline phys_addr_t pgd_page_paddr(pgd_t pgd)
 #define pgd_ERROR(pgd)		__pgd_error(__FILE__, __LINE__, pgd_val(pgd))
 
 /* to find an entry in a page-table-directory */
-#define pgd_index(addr)		(((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
+#define pgd_index(addr, ptrs)		(((addr) >> PGDIR_SHIFT) & ((ptrs) - 1))
+#define _pgd_offset_raw(pgd, addr, ptrs) ((pgd) + pgd_index(addr, ptrs))
+#define pgd_offset_raw(pgd, addr)	(_pgd_offset_raw(pgd, addr, PTRS_PER_PGD))
 
-#define pgd_offset_raw(pgd, addr)	((pgd) + pgd_index(addr))
+static inline pgd_t *pgd_offset(const struct mm_struct *mm, unsigned long addr)
+{
+	pgd_t *ret;
+
+	if (IS_ENABLED(CONFIG_ARM64_52BIT_VA) && (mm != &init_mm))
+		ret = _pgd_offset_raw(mm->pgd, addr, 1ULL << (vabits_user - PGDIR_SHIFT));
+	else
+		ret = pgd_offset_raw(mm->pgd, addr);
 
-#define pgd_offset(mm, addr)	(pgd_offset_raw((mm)->pgd, (addr)))
+	return ret;
+}
 
 /* to find an entry in a kernel page-table-directory */
 #define pgd_offset_k(addr)	pgd_offset(&init_mm, addr)
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 5afc0c5eb1cb..886392ac38ff 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -19,13 +19,16 @@
 #ifndef __ASM_PROCESSOR_H
 #define __ASM_PROCESSOR_H
 
-#define TASK_SIZE_64		(UL(1) << VA_BITS)
-
-#define KERNEL_DS	UL(-1)
-#define USER_DS		(TASK_SIZE_64 - 1)
-
+#define KERNEL_DS		UL(-1)
+#ifdef CONFIG_ARM64_52BIT_VA
+#define USER_DS			((UL(1) << 52) - 1)
+#else
+#define USER_DS			((UL(1) << VA_BITS) - 1)
+#endif /* CONFIG_ARM64_52IT_VA */
 #ifndef __ASSEMBLY__
 
+extern u64 vabits_user;
+#define TASK_SIZE_64		(UL(1) << vabits_user)
 #define DEFAULT_MAP_WINDOW_64	(UL(1) << VA_BITS)
 
 /*
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index b0853069702f..796d119f2848 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -316,6 +316,19 @@ __create_page_tables:
 	adrp	x0, idmap_pg_dir
 	adrp	x3, __idmap_text_start		// __pa(__idmap_text_start)
 
+#ifdef CONFIG_ARM64_52BIT_VA
+	mrs_s	x6, SYS_ID_AA64MMFR2_EL1
+	and	x6, x6, #(0xf << ID_AA64MMFR2_LVA_SHIFT)
+	mov	x5, #52
+	cbnz	x6, 1f
+#endif
+	mov	x5, #VA_BITS
+1:
+	adr_l	x6, vabits_user
+	str	x5, [x6]
+	dmb	sy
+	dc	ivac, x6		// Invalidate potentially stale cache line
+
 	/*
 	 * VA_BITS may be too small to allow for an ID mapping to be created
 	 * that covers system RAM if that is located sufficiently high in the
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 50b30ff30de4..cbf14bc14aa3 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -153,7 +153,7 @@ void show_pte(unsigned long addr)
 
 	pr_alert("%s pgtable: %luk pages, %u-bit VAs, pgdp = %p\n",
 		 mm == &init_mm ? "swapper" : "user", PAGE_SIZE / SZ_1K,
-		 VA_BITS, mm->pgd);
+		 mm == &init_mm ? VA_BITS : (int) vabits_user, mm->pgd);
 	pgdp = pgd_offset(mm, addr);
 	pgd = READ_ONCE(*pgdp);
 	pr_alert("[%016lx] pgd=%016llx", addr, pgd_val(pgd));
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 8080c9f489c3..2aa9ea9bd2c2 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -52,6 +52,7 @@
 
 u64 idmap_t0sz = TCR_T0SZ(VA_BITS);
 u64 idmap_ptrs_per_pgd = PTRS_PER_PGD;
+u64 vabits_user __ro_after_init;
 
 u64 kimage_voffset __ro_after_init;
 EXPORT_SYMBOL(kimage_voffset);
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index 03646e6a2ef4..bd01506a2555 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -441,7 +441,15 @@ ENTRY(__cpu_setup)
 	ldr	x10, =TCR_TxSZ(VA_BITS) | TCR_CACHE_FLAGS | TCR_SMP_FLAGS | \
 			TCR_TG_FLAGS | TCR_KASLR_FLAGS | TCR_ASID16 | \
 			TCR_TBI0 | TCR_A1
-	tcr_set_idmap_t0sz	x10, x9
+
+#ifdef CONFIG_ARM64_52BIT_VA
+	ldr_l 		x9, vabits_user
+	sub		x9, xzr, x9
+	add		x9, x9, #64
+#else
+	ldr_l		x9, idmap_t0sz
+#endif
+	tcr_set_t0sz	x10, x9
 
 	/*
 	 * Set the IPS bits in TCR_EL1.
-- 
2.11.0

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

* [PATCH V2 4/4] arm64: mm: introduce 52-bit userspace support
@ 2018-10-17 16:34   ` Steve Capper
  0 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-17 16:34 UTC (permalink / raw)
  To: linux-arm-kernel

On arm64 there is optional support for a 52-bit virtual address space.
To exploit this one has to be running with a 64KB page size and be
running on hardware that supports this.

For an arm64 kernel supporting a 48 bit VA with a 64KB page size,
a few changes are needed to support a 52-bit userspace:
 * TCR_EL1.T0SZ needs to be 12 instead of 16,
 * pgd_offset needs to work with a different PTRS_PER_PGD,
 * PGD_SIZE needs to be increased,
 * TASK_SIZE needs to reflect the new size.

This patch implements the above when the support for 52-bit VAs is
detected at early boot time.

On arm64 userspace addresses translation is controlled by TTBR0_EL1. As
well as userspace, TTBR0_EL1 controls:
 * The identity mapping,
 * EFI runtime code.

It is possible to run a kernel with an identity mapping that has a
larger VA size than userspace (and for this case __cpu_set_tcr_t0sz()
would set TCR_EL1.T0SZ as appropriate). However, when the conditions for
52-bit userspace are met; it is possible to keep TCR_EL1.T0SZ fixed at
12. Thus in this patch, the TCR_EL1.T0SZ size changing logic is
disabled.

Signed-off-by: Steve Capper <steve.capper@arm.com>
---
Changed in V2: variable USER_DS limit dropped, this simplifies the
patch considerably. We check for userspace mappings with init_mm rather
than looking at the virtual address.
---
 arch/arm64/Kconfig                   |  4 ++++
 arch/arm64/include/asm/assembler.h   |  7 +++----
 arch/arm64/include/asm/mmu_context.h |  3 +++
 arch/arm64/include/asm/pgalloc.h     |  4 ++++
 arch/arm64/include/asm/pgtable.h     | 16 +++++++++++++---
 arch/arm64/include/asm/processor.h   | 13 ++++++++-----
 arch/arm64/kernel/head.S             | 13 +++++++++++++
 arch/arm64/mm/fault.c                |  2 +-
 arch/arm64/mm/mmu.c                  |  1 +
 arch/arm64/mm/proc.S                 | 10 +++++++++-
 10 files changed, 59 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1b1a0e95c751..ce6ebba101de 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -691,6 +691,10 @@ config ARM64_PA_BITS_52
 
 endchoice
 
+config ARM64_52BIT_VA
+	def_bool y
+	depends on ARM64_VA_BITS_48 && ARM64_64K_PAGES
+
 config ARM64_PA_BITS
 	int
 	default 48 if ARM64_PA_BITS_48
diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 0bcc98dbba56..8c8ed20beca9 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -343,11 +343,10 @@ alternative_endif
 	.endm
 
 /*
- * tcr_set_idmap_t0sz - update TCR.T0SZ so that we can load the ID map
+ * tcr_set_t0sz - update TCR.T0SZ so that we can load the ID map
  */
-	.macro	tcr_set_idmap_t0sz, valreg, tmpreg
-	ldr_l	\tmpreg, idmap_t0sz
-	bfi	\valreg, \tmpreg, #TCR_T0SZ_OFFSET, #TCR_TxSZ_WIDTH
+	.macro	tcr_set_t0sz, valreg, t0sz
+	bfi	\valreg, \t0sz, #TCR_T0SZ_OFFSET, #TCR_TxSZ_WIDTH
 	.endm
 
 /*
diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h
index 39ec0b8a689e..1b7408e8d794 100644
--- a/arch/arm64/include/asm/mmu_context.h
+++ b/arch/arm64/include/asm/mmu_context.h
@@ -72,6 +72,9 @@ extern u64 idmap_ptrs_per_pgd;
 
 static inline bool __cpu_uses_extended_idmap(void)
 {
+	if (IS_ENABLED(CONFIG_ARM64_52BIT_VA))
+		return false;
+
 	return unlikely(idmap_t0sz != TCR_T0SZ(VA_BITS));
 }
 
diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h
index 2e05bcd944c8..56c3ccabeffe 100644
--- a/arch/arm64/include/asm/pgalloc.h
+++ b/arch/arm64/include/asm/pgalloc.h
@@ -27,7 +27,11 @@
 #define check_pgt_cache()		do { } while (0)
 
 #define PGALLOC_GFP	(GFP_KERNEL | __GFP_ZERO)
+#ifdef CONFIG_ARM64_52BIT_VA
+#define PGD_SIZE	((1 << (52 - PGDIR_SHIFT)) * sizeof(pgd_t))
+#else
 #define PGD_SIZE	(PTRS_PER_PGD * sizeof(pgd_t))
+#endif
 
 #if CONFIG_PGTABLE_LEVELS > 2
 
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 1bdeca8918a6..b18df27b06e0 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -577,11 +577,21 @@ static inline phys_addr_t pgd_page_paddr(pgd_t pgd)
 #define pgd_ERROR(pgd)		__pgd_error(__FILE__, __LINE__, pgd_val(pgd))
 
 /* to find an entry in a page-table-directory */
-#define pgd_index(addr)		(((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
+#define pgd_index(addr, ptrs)		(((addr) >> PGDIR_SHIFT) & ((ptrs) - 1))
+#define _pgd_offset_raw(pgd, addr, ptrs) ((pgd) + pgd_index(addr, ptrs))
+#define pgd_offset_raw(pgd, addr)	(_pgd_offset_raw(pgd, addr, PTRS_PER_PGD))
 
-#define pgd_offset_raw(pgd, addr)	((pgd) + pgd_index(addr))
+static inline pgd_t *pgd_offset(const struct mm_struct *mm, unsigned long addr)
+{
+	pgd_t *ret;
+
+	if (IS_ENABLED(CONFIG_ARM64_52BIT_VA) && (mm != &init_mm))
+		ret = _pgd_offset_raw(mm->pgd, addr, 1ULL << (vabits_user - PGDIR_SHIFT));
+	else
+		ret = pgd_offset_raw(mm->pgd, addr);
 
-#define pgd_offset(mm, addr)	(pgd_offset_raw((mm)->pgd, (addr)))
+	return ret;
+}
 
 /* to find an entry in a kernel page-table-directory */
 #define pgd_offset_k(addr)	pgd_offset(&init_mm, addr)
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 5afc0c5eb1cb..886392ac38ff 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -19,13 +19,16 @@
 #ifndef __ASM_PROCESSOR_H
 #define __ASM_PROCESSOR_H
 
-#define TASK_SIZE_64		(UL(1) << VA_BITS)
-
-#define KERNEL_DS	UL(-1)
-#define USER_DS		(TASK_SIZE_64 - 1)
-
+#define KERNEL_DS		UL(-1)
+#ifdef CONFIG_ARM64_52BIT_VA
+#define USER_DS			((UL(1) << 52) - 1)
+#else
+#define USER_DS			((UL(1) << VA_BITS) - 1)
+#endif /* CONFIG_ARM64_52IT_VA */
 #ifndef __ASSEMBLY__
 
+extern u64 vabits_user;
+#define TASK_SIZE_64		(UL(1) << vabits_user)
 #define DEFAULT_MAP_WINDOW_64	(UL(1) << VA_BITS)
 
 /*
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index b0853069702f..796d119f2848 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -316,6 +316,19 @@ __create_page_tables:
 	adrp	x0, idmap_pg_dir
 	adrp	x3, __idmap_text_start		// __pa(__idmap_text_start)
 
+#ifdef CONFIG_ARM64_52BIT_VA
+	mrs_s	x6, SYS_ID_AA64MMFR2_EL1
+	and	x6, x6, #(0xf << ID_AA64MMFR2_LVA_SHIFT)
+	mov	x5, #52
+	cbnz	x6, 1f
+#endif
+	mov	x5, #VA_BITS
+1:
+	adr_l	x6, vabits_user
+	str	x5, [x6]
+	dmb	sy
+	dc	ivac, x6		// Invalidate potentially stale cache line
+
 	/*
 	 * VA_BITS may be too small to allow for an ID mapping to be created
 	 * that covers system RAM if that is located sufficiently high in the
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 50b30ff30de4..cbf14bc14aa3 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -153,7 +153,7 @@ void show_pte(unsigned long addr)
 
 	pr_alert("%s pgtable: %luk pages, %u-bit VAs, pgdp = %p\n",
 		 mm == &init_mm ? "swapper" : "user", PAGE_SIZE / SZ_1K,
-		 VA_BITS, mm->pgd);
+		 mm == &init_mm ? VA_BITS : (int) vabits_user, mm->pgd);
 	pgdp = pgd_offset(mm, addr);
 	pgd = READ_ONCE(*pgdp);
 	pr_alert("[%016lx] pgd=%016llx", addr, pgd_val(pgd));
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 8080c9f489c3..2aa9ea9bd2c2 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -52,6 +52,7 @@
 
 u64 idmap_t0sz = TCR_T0SZ(VA_BITS);
 u64 idmap_ptrs_per_pgd = PTRS_PER_PGD;
+u64 vabits_user __ro_after_init;
 
 u64 kimage_voffset __ro_after_init;
 EXPORT_SYMBOL(kimage_voffset);
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index 03646e6a2ef4..bd01506a2555 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -441,7 +441,15 @@ ENTRY(__cpu_setup)
 	ldr	x10, =TCR_TxSZ(VA_BITS) | TCR_CACHE_FLAGS | TCR_SMP_FLAGS | \
 			TCR_TG_FLAGS | TCR_KASLR_FLAGS | TCR_ASID16 | \
 			TCR_TBI0 | TCR_A1
-	tcr_set_idmap_t0sz	x10, x9
+
+#ifdef CONFIG_ARM64_52BIT_VA
+	ldr_l 		x9, vabits_user
+	sub		x9, xzr, x9
+	add		x9, x9, #64
+#else
+	ldr_l		x9, idmap_t0sz
+#endif
+	tcr_set_t0sz	x10, x9
 
 	/*
 	 * Set the IPS bits in TCR_EL1.
-- 
2.11.0

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

* Re: [PATCH V2 1/4] mm: mmap: Allow for "high" userspace addresses
  2018-10-17 16:34   ` Steve Capper
@ 2018-10-17 16:48     ` Matthew Wilcox
  -1 siblings, 0 replies; 24+ messages in thread
From: Matthew Wilcox @ 2018-10-17 16:48 UTC (permalink / raw)
  To: Steve Capper
  Cc: linux-mm, linux-arm-kernel, catalin.marinas, will.deacon,
	ard.biesheuvel, jcm

On Wed, Oct 17, 2018 at 05:34:56PM +0100, Steve Capper wrote:
> This patch adds support for "high" userspace addresses that are
> optionally supported on the system and have to be requested via a hint
> mechanism ("high" addr parameter to mmap).
> 
> Rather than duplicate the arch_get_unmapped_* stock implementations,
> this patch instead introduces two architectural helper macros and
> applies them to arch_get_unmapped_*:
>  arch_get_mmap_end(addr) - get mmap upper limit depending on addr hint
>  arch_get_mmap_base(addr, base) - get mmap_base depending on addr hint
> 
> If these macros are not defined in architectural code then they default
> to (TASK_SIZE) and (base) so should not introduce any behavioural
> changes to architectures that do not define them.

Can you explain (in the changelog) why we need to do this for arm64
when it wasn't needed for the equivalent feature on x86-64?  I think the
answer is that x86-64 already has its own arch_get_unmapped* functions and
rather than duplicating arch_get_unmapped* for arm64, you want to continue
using the generic ones with just this minor hooking.  But I'd like that
spelled out explicitly for the next person who comes along and wonders.

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

* [PATCH V2 1/4] mm: mmap: Allow for "high" userspace addresses
@ 2018-10-17 16:48     ` Matthew Wilcox
  0 siblings, 0 replies; 24+ messages in thread
From: Matthew Wilcox @ 2018-10-17 16:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 17, 2018 at 05:34:56PM +0100, Steve Capper wrote:
> This patch adds support for "high" userspace addresses that are
> optionally supported on the system and have to be requested via a hint
> mechanism ("high" addr parameter to mmap).
> 
> Rather than duplicate the arch_get_unmapped_* stock implementations,
> this patch instead introduces two architectural helper macros and
> applies them to arch_get_unmapped_*:
>  arch_get_mmap_end(addr) - get mmap upper limit depending on addr hint
>  arch_get_mmap_base(addr, base) - get mmap_base depending on addr hint
> 
> If these macros are not defined in architectural code then they default
> to (TASK_SIZE) and (base) so should not introduce any behavioural
> changes to architectures that do not define them.

Can you explain (in the changelog) why we need to do this for arm64
when it wasn't needed for the equivalent feature on x86-64?  I think the
answer is that x86-64 already has its own arch_get_unmapped* functions and
rather than duplicating arch_get_unmapped* for arm64, you want to continue
using the generic ones with just this minor hooking.  But I'd like that
spelled out explicitly for the next person who comes along and wonders.

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

* Re: [PATCH V2 2/4] arm64: mm: Introduce DEFAULT_MAP_WINDOW
  2018-10-17 16:34   ` Steve Capper
@ 2018-10-18  1:50     ` kbuild test robot
  -1 siblings, 0 replies; 24+ messages in thread
From: kbuild test robot @ 2018-10-18  1:50 UTC (permalink / raw)
  To: Steve Capper
  Cc: kbuild-all, linux-mm, linux-arm-kernel, catalin.marinas,
	will.deacon, ard.biesheuvel, jcm

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

Hi Steve,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on v4.19-rc8]
[cannot apply to next-20181017]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Steve-Capper/52-bit-userspace-VAs/20181018-061652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/cache.h:5:0,
                    from include/linux/printk.h:9,
                    from include/linux/kernel.h:14,
                    from include/asm-generic/bug.h:18,
                    from arch/arm64/include/asm/bug.h:37,
                    from include/linux/bug.h:5,
                    from include/linux/thread_info.h:12,
                    from fs//hugetlbfs/inode.c:12:
   fs//hugetlbfs/inode.c: In function 'hugetlb_get_unmapped_area':
>> arch/arm64/include/asm/processor.h:63:50: error: 'tsk' undeclared (first use in this function)
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
>> include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
>> include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
>> arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
>> arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
>> fs//hugetlbfs/inode.c:214:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
     info.low_limit = TASK_UNMAPPED_BASE;
                      ^~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/processor.h:63:50: note: each undeclared identifier is reported only once for each function it appears in
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
>> include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
>> include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
>> arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
>> arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
>> fs//hugetlbfs/inode.c:214:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
     info.low_limit = TASK_UNMAPPED_BASE;
                      ^~~~~~~~~~~~~~~~~~
--
   In file included from include/linux/cache.h:5:0,
                    from include/linux/printk.h:9,
                    from include/linux/kernel.h:14,
                    from include/asm-generic/bug.h:18,
                    from arch/arm64/include/asm/bug.h:37,
                    from include/linux/bug.h:5,
                    from include/linux/thread_info.h:12,
                    from fs/hugetlbfs/inode.c:12:
   fs/hugetlbfs/inode.c: In function 'hugetlb_get_unmapped_area':
>> arch/arm64/include/asm/processor.h:63:50: error: 'tsk' undeclared (first use in this function)
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
>> include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
>> include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
>> arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
>> arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
   fs/hugetlbfs/inode.c:214:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
     info.low_limit = TASK_UNMAPPED_BASE;
                      ^~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/processor.h:63:50: note: each undeclared identifier is reported only once for each function it appears in
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
>> include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
>> include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
>> arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
>> arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
   fs/hugetlbfs/inode.c:214:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
     info.low_limit = TASK_UNMAPPED_BASE;
                      ^~~~~~~~~~~~~~~~~~

vim +/tsk +63 arch/arm64/include/asm/processor.h

    52	
    53	/*
    54	 * TASK_SIZE - the maximum size of a user space task.
    55	 * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
    56	 */
    57	#ifdef CONFIG_COMPAT
    58	#define TASK_SIZE_32		UL(0x100000000)
    59	#define TASK_SIZE		(test_thread_flag(TIF_32BIT) ? \
    60					TASK_SIZE_32 : TASK_SIZE_64)
    61	#define TASK_SIZE_OF(tsk)	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
    62					TASK_SIZE_32 : TASK_SIZE_64)
  > 63	#define DEFAULT_MAP_WINDOW	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
    64					TASK_SIZE_32 : DEFAULT_MAP_WINDOW_64)
    65	#else
    66	#define TASK_SIZE		TASK_SIZE_64
    67	#define DEFAULT_MAP_WINDOW	DEFAULT_MAP_WINDOW_64
    68	#endif /* CONFIG_COMPAT */
    69	
  > 70	#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
    71	#define STACK_TOP_MAX		DEFAULT_MAP_WINDOW_64
    72	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 40225 bytes --]

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

* [PATCH V2 2/4] arm64: mm: Introduce DEFAULT_MAP_WINDOW
@ 2018-10-18  1:50     ` kbuild test robot
  0 siblings, 0 replies; 24+ messages in thread
From: kbuild test robot @ 2018-10-18  1:50 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Steve,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on v4.19-rc8]
[cannot apply to next-20181017]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Steve-Capper/52-bit-userspace-VAs/20181018-061652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/cache.h:5:0,
                    from include/linux/printk.h:9,
                    from include/linux/kernel.h:14,
                    from include/asm-generic/bug.h:18,
                    from arch/arm64/include/asm/bug.h:37,
                    from include/linux/bug.h:5,
                    from include/linux/thread_info.h:12,
                    from fs//hugetlbfs/inode.c:12:
   fs//hugetlbfs/inode.c: In function 'hugetlb_get_unmapped_area':
>> arch/arm64/include/asm/processor.h:63:50: error: 'tsk' undeclared (first use in this function)
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
>> include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
>> include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
>> arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
>> arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
>> fs//hugetlbfs/inode.c:214:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
     info.low_limit = TASK_UNMAPPED_BASE;
                      ^~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/processor.h:63:50: note: each undeclared identifier is reported only once for each function it appears in
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
>> include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
>> include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
>> arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
>> arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
>> fs//hugetlbfs/inode.c:214:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
     info.low_limit = TASK_UNMAPPED_BASE;
                      ^~~~~~~~~~~~~~~~~~
--
   In file included from include/linux/cache.h:5:0,
                    from include/linux/printk.h:9,
                    from include/linux/kernel.h:14,
                    from include/asm-generic/bug.h:18,
                    from arch/arm64/include/asm/bug.h:37,
                    from include/linux/bug.h:5,
                    from include/linux/thread_info.h:12,
                    from fs/hugetlbfs/inode.c:12:
   fs/hugetlbfs/inode.c: In function 'hugetlb_get_unmapped_area':
>> arch/arm64/include/asm/processor.h:63:50: error: 'tsk' undeclared (first use in this function)
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
>> include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
>> include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
>> arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
>> arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
   fs/hugetlbfs/inode.c:214:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
     info.low_limit = TASK_UNMAPPED_BASE;
                      ^~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/processor.h:63:50: note: each undeclared identifier is reported only once for each function it appears in
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
>> include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
>> include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
>> arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
>> arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
   fs/hugetlbfs/inode.c:214:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
     info.low_limit = TASK_UNMAPPED_BASE;
                      ^~~~~~~~~~~~~~~~~~

vim +/tsk +63 arch/arm64/include/asm/processor.h

    52	
    53	/*
    54	 * TASK_SIZE - the maximum size of a user space task.
    55	 * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area.
    56	 */
    57	#ifdef CONFIG_COMPAT
    58	#define TASK_SIZE_32		UL(0x100000000)
    59	#define TASK_SIZE		(test_thread_flag(TIF_32BIT) ? \
    60					TASK_SIZE_32 : TASK_SIZE_64)
    61	#define TASK_SIZE_OF(tsk)	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
    62					TASK_SIZE_32 : TASK_SIZE_64)
  > 63	#define DEFAULT_MAP_WINDOW	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
    64					TASK_SIZE_32 : DEFAULT_MAP_WINDOW_64)
    65	#else
    66	#define TASK_SIZE		TASK_SIZE_64
    67	#define DEFAULT_MAP_WINDOW	DEFAULT_MAP_WINDOW_64
    68	#endif /* CONFIG_COMPAT */
    69	
  > 70	#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
    71	#define STACK_TOP_MAX		DEFAULT_MAP_WINDOW_64
    72	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 40225 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181018/fe5209b1/attachment-0001.gz>

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

* Re: [PATCH V2 2/4] arm64: mm: Introduce DEFAULT_MAP_WINDOW
  2018-10-17 16:34   ` Steve Capper
@ 2018-10-18  2:09     ` kbuild test robot
  -1 siblings, 0 replies; 24+ messages in thread
From: kbuild test robot @ 2018-10-18  2:09 UTC (permalink / raw)
  To: Steve Capper
  Cc: kbuild-all, linux-mm, linux-arm-kernel, catalin.marinas,
	will.deacon, ard.biesheuvel, jcm

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

Hi Steve,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on v4.19-rc8]
[cannot apply to next-20181017]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Steve-Capper/52-bit-userspace-VAs/20181018-061652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/cache.h:5:0,
                    from include/linux/printk.h:9,
                    from include/linux/kernel.h:14,
                    from include/asm-generic/bug.h:18,
                    from arch/arm64/include/asm/bug.h:37,
                    from include/linux/bug.h:5,
                    from arch/arm64/include/asm/ptrace.h:90,
                    from arch/arm64/include/asm/elf.h:24,
                    from include/linux/elf.h:5,
                    from arch/arm64/mm/mmap.c:19:
   arch/arm64/mm/mmap.c: In function 'arch_pick_mmap_layout':
   arch/arm64/include/asm/processor.h:63:50: error: 'tsk' undeclared (first use in this function)
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
   include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
   include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
   arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
   arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
>> arch/arm64/mm/mmap.c:98:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
      mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
                      ^~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/processor.h:63:50: note: each undeclared identifier is reported only once for each function it appears in
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
   include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
   include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
   arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
   arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
>> arch/arm64/mm/mmap.c:98:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
      mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
                      ^~~~~~~~~~~~~~~~~~

vim +/TASK_UNMAPPED_BASE +98 arch/arm64/mm/mmap.c

1d18c47c Catalin Marinas 2012-03-05   81  
1d18c47c Catalin Marinas 2012-03-05   82  /*
1d18c47c Catalin Marinas 2012-03-05   83   * This function, called very early during the creation of a new process VM
1d18c47c Catalin Marinas 2012-03-05   84   * image, sets up which VM layout function to use:
1d18c47c Catalin Marinas 2012-03-05   85   */
8f2af155 Kees Cook       2018-04-10   86  void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
1d18c47c Catalin Marinas 2012-03-05   87  {
dd04cff1 Kees Cook       2015-04-14   88  	unsigned long random_factor = 0UL;
dd04cff1 Kees Cook       2015-04-14   89  
dd04cff1 Kees Cook       2015-04-14   90  	if (current->flags & PF_RANDOMIZE)
2b68f6ca Kees Cook       2015-04-14   91  		random_factor = arch_mmap_rnd();
dd04cff1 Kees Cook       2015-04-14   92  
1d18c47c Catalin Marinas 2012-03-05   93  	/*
1d18c47c Catalin Marinas 2012-03-05   94  	 * Fall back to the standard layout if the personality bit is set, or
1d18c47c Catalin Marinas 2012-03-05   95  	 * if the expected stack growth is unlimited:
1d18c47c Catalin Marinas 2012-03-05   96  	 */
8f2af155 Kees Cook       2018-04-10   97  	if (mmap_is_legacy(rlim_stack)) {
dd04cff1 Kees Cook       2015-04-14  @98  		mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
1d18c47c Catalin Marinas 2012-03-05   99  		mm->get_unmapped_area = arch_get_unmapped_area;
1d18c47c Catalin Marinas 2012-03-05  100  	} else {
8f2af155 Kees Cook       2018-04-10  101  		mm->mmap_base = mmap_base(random_factor, rlim_stack);
1d18c47c Catalin Marinas 2012-03-05  102  		mm->get_unmapped_area = arch_get_unmapped_area_topdown;
1d18c47c Catalin Marinas 2012-03-05  103  	}
1d18c47c Catalin Marinas 2012-03-05  104  }
1d18c47c Catalin Marinas 2012-03-05  105  

:::::: The code at line 98 was first introduced by commit
:::::: dd04cff1dceab18226853b555cf07914648a235f arm64: standardize mmap_rnd() usage

:::::: TO: Kees Cook <keescook@chromium.org>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 40225 bytes --]

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

* [PATCH V2 2/4] arm64: mm: Introduce DEFAULT_MAP_WINDOW
@ 2018-10-18  2:09     ` kbuild test robot
  0 siblings, 0 replies; 24+ messages in thread
From: kbuild test robot @ 2018-10-18  2:09 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Steve,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on v4.19-rc8]
[cannot apply to next-20181017]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Steve-Capper/52-bit-userspace-VAs/20181018-061652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/cache.h:5:0,
                    from include/linux/printk.h:9,
                    from include/linux/kernel.h:14,
                    from include/asm-generic/bug.h:18,
                    from arch/arm64/include/asm/bug.h:37,
                    from include/linux/bug.h:5,
                    from arch/arm64/include/asm/ptrace.h:90,
                    from arch/arm64/include/asm/elf.h:24,
                    from include/linux/elf.h:5,
                    from arch/arm64/mm/mmap.c:19:
   arch/arm64/mm/mmap.c: In function 'arch_pick_mmap_layout':
   arch/arm64/include/asm/processor.h:63:50: error: 'tsk' undeclared (first use in this function)
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
   include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
   include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
   arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
   arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
>> arch/arm64/mm/mmap.c:98:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
      mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
                      ^~~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/processor.h:63:50: note: each undeclared identifier is reported only once for each function it appears in
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   include/uapi/linux/kernel.h:11:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
    #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
                                            ^
   include/linux/kernel.h:58:22: note: in expansion of macro '__ALIGN_KERNEL'
    #define ALIGN(x, a)  __ALIGN_KERNEL((x), (a))
                         ^~~~~~~~~~~~~~
   include/linux/mm.h:144:26: note: in expansion of macro 'ALIGN'
    #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
                             ^~~~~
   arch/arm64/include/asm/processor.h:70:29: note: in expansion of macro 'PAGE_ALIGN'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                ^~~~~~~~~~
   arch/arm64/include/asm/processor.h:70:40: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define TASK_UNMAPPED_BASE (PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
                                           ^~~~~~~~~~~~~~~~~~
>> arch/arm64/mm/mmap.c:98:19: note: in expansion of macro 'TASK_UNMAPPED_BASE'
      mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
                      ^~~~~~~~~~~~~~~~~~

vim +/TASK_UNMAPPED_BASE +98 arch/arm64/mm/mmap.c

1d18c47c Catalin Marinas 2012-03-05   81  
1d18c47c Catalin Marinas 2012-03-05   82  /*
1d18c47c Catalin Marinas 2012-03-05   83   * This function, called very early during the creation of a new process VM
1d18c47c Catalin Marinas 2012-03-05   84   * image, sets up which VM layout function to use:
1d18c47c Catalin Marinas 2012-03-05   85   */
8f2af155 Kees Cook       2018-04-10   86  void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
1d18c47c Catalin Marinas 2012-03-05   87  {
dd04cff1 Kees Cook       2015-04-14   88  	unsigned long random_factor = 0UL;
dd04cff1 Kees Cook       2015-04-14   89  
dd04cff1 Kees Cook       2015-04-14   90  	if (current->flags & PF_RANDOMIZE)
2b68f6ca Kees Cook       2015-04-14   91  		random_factor = arch_mmap_rnd();
dd04cff1 Kees Cook       2015-04-14   92  
1d18c47c Catalin Marinas 2012-03-05   93  	/*
1d18c47c Catalin Marinas 2012-03-05   94  	 * Fall back to the standard layout if the personality bit is set, or
1d18c47c Catalin Marinas 2012-03-05   95  	 * if the expected stack growth is unlimited:
1d18c47c Catalin Marinas 2012-03-05   96  	 */
8f2af155 Kees Cook       2018-04-10   97  	if (mmap_is_legacy(rlim_stack)) {
dd04cff1 Kees Cook       2015-04-14  @98  		mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
1d18c47c Catalin Marinas 2012-03-05   99  		mm->get_unmapped_area = arch_get_unmapped_area;
1d18c47c Catalin Marinas 2012-03-05  100  	} else {
8f2af155 Kees Cook       2018-04-10  101  		mm->mmap_base = mmap_base(random_factor, rlim_stack);
1d18c47c Catalin Marinas 2012-03-05  102  		mm->get_unmapped_area = arch_get_unmapped_area_topdown;
1d18c47c Catalin Marinas 2012-03-05  103  	}
1d18c47c Catalin Marinas 2012-03-05  104  }
1d18c47c Catalin Marinas 2012-03-05  105  

:::::: The code at line 98 was first introduced by commit
:::::: dd04cff1dceab18226853b555cf07914648a235f arm64: standardize mmap_rnd() usage

:::::: TO: Kees Cook <keescook@chromium.org>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 40225 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181018/3046b2d8/attachment-0001.gz>

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

* Re: [PATCH V2 3/4] arm64: mm: Define arch_get_mmap_end, arch_get_mmap_base
  2018-10-17 16:34   ` Steve Capper
@ 2018-10-18  2:28     ` kbuild test robot
  -1 siblings, 0 replies; 24+ messages in thread
From: kbuild test robot @ 2018-10-18  2:28 UTC (permalink / raw)
  To: Steve Capper
  Cc: kbuild-all, linux-mm, linux-arm-kernel, catalin.marinas,
	will.deacon, ard.biesheuvel, jcm

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

Hi Steve,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on v4.19-rc8]
[cannot apply to next-20181017]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Steve-Capper/52-bit-userspace-VAs/20181018-061652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm64 

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/qrwlock.h:23:0,
                    from ./arch/arm64/include/generated/asm/qrwlock.h:1,
                    from arch/arm64/include/asm/spinlock.h:19,
                    from include/linux/spinlock.h:88,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/slab.h:15,
                    from mm/mmap.c:12:
   mm/mmap.c: In function 'arch_get_unmapped_area':
   arch/arm64/include/asm/processor.h:63:50: error: 'tsk' undeclared (first use in this function)
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   arch/arm64/include/asm/processor.h:81:42: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\
                                             ^~~~~~~~~~~~~~~~~~
>> mm/mmap.c:2073:33: note: in expansion of macro 'arch_get_mmap_end'
     const unsigned long mmap_end = arch_get_mmap_end(addr);
                                    ^~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/processor.h:63:50: note: each undeclared identifier is reported only once for each function it appears in
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   arch/arm64/include/asm/processor.h:81:42: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\
                                             ^~~~~~~~~~~~~~~~~~
>> mm/mmap.c:2073:33: note: in expansion of macro 'arch_get_mmap_end'
     const unsigned long mmap_end = arch_get_mmap_end(addr);
                                    ^~~~~~~~~~~~~~~~~
   mm/mmap.c: In function 'arch_get_unmapped_area_topdown':
   arch/arm64/include/asm/processor.h:63:50: error: 'tsk' undeclared (first use in this function)
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   arch/arm64/include/asm/processor.h:81:42: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\
                                             ^~~~~~~~~~~~~~~~~~
   mm/mmap.c:2113:33: note: in expansion of macro 'arch_get_mmap_end'
     const unsigned long mmap_end = arch_get_mmap_end(addr);
                                    ^~~~~~~~~~~~~~~~~

vim +/arch_get_mmap_end +2073 mm/mmap.c

d5d60952 Steve Capper           2018-10-17  2053  
^1da177e Linus Torvalds         2005-04-16  2054  /* Get an address range which is currently unmapped.
^1da177e Linus Torvalds         2005-04-16  2055   * For shmat() with addr=0.
^1da177e Linus Torvalds         2005-04-16  2056   *
^1da177e Linus Torvalds         2005-04-16  2057   * Ugly calling convention alert:
^1da177e Linus Torvalds         2005-04-16  2058   * Return value with the low bits set means error value,
^1da177e Linus Torvalds         2005-04-16  2059   * ie
^1da177e Linus Torvalds         2005-04-16  2060   *	if (ret & ~PAGE_MASK)
^1da177e Linus Torvalds         2005-04-16  2061   *		error = ret;
^1da177e Linus Torvalds         2005-04-16  2062   *
^1da177e Linus Torvalds         2005-04-16  2063   * This function "knows" that -ENOMEM has the bits set.
^1da177e Linus Torvalds         2005-04-16  2064   */
^1da177e Linus Torvalds         2005-04-16  2065  #ifndef HAVE_ARCH_UNMAPPED_AREA
^1da177e Linus Torvalds         2005-04-16  2066  unsigned long
^1da177e Linus Torvalds         2005-04-16  2067  arch_get_unmapped_area(struct file *filp, unsigned long addr,
^1da177e Linus Torvalds         2005-04-16  2068  		unsigned long len, unsigned long pgoff, unsigned long flags)
^1da177e Linus Torvalds         2005-04-16  2069  {
^1da177e Linus Torvalds         2005-04-16  2070  	struct mm_struct *mm = current->mm;
1be7107f Hugh Dickins           2017-06-19  2071  	struct vm_area_struct *vma, *prev;
db4fbfb9 Michel Lespinasse      2012-12-11  2072  	struct vm_unmapped_area_info info;
d5d60952 Steve Capper           2018-10-17 @2073  	const unsigned long mmap_end = arch_get_mmap_end(addr);
^1da177e Linus Torvalds         2005-04-16  2074  
d5d60952 Steve Capper           2018-10-17  2075  	if (len > mmap_end - mmap_min_addr)
^1da177e Linus Torvalds         2005-04-16  2076  		return -ENOMEM;
^1da177e Linus Torvalds         2005-04-16  2077  
06abdfb4 Benjamin Herrenschmidt 2007-05-06  2078  	if (flags & MAP_FIXED)
06abdfb4 Benjamin Herrenschmidt 2007-05-06  2079  		return addr;
06abdfb4 Benjamin Herrenschmidt 2007-05-06  2080  
^1da177e Linus Torvalds         2005-04-16  2081  	if (addr) {
^1da177e Linus Torvalds         2005-04-16  2082  		addr = PAGE_ALIGN(addr);
1be7107f Hugh Dickins           2017-06-19  2083  		vma = find_vma_prev(mm, addr, &prev);
d5d60952 Steve Capper           2018-10-17  2084  		if (mmap_end - len >= addr && addr >= mmap_min_addr &&
1be7107f Hugh Dickins           2017-06-19  2085  		    (!vma || addr + len <= vm_start_gap(vma)) &&
1be7107f Hugh Dickins           2017-06-19  2086  		    (!prev || addr >= vm_end_gap(prev)))
^1da177e Linus Torvalds         2005-04-16  2087  			return addr;
^1da177e Linus Torvalds         2005-04-16  2088  	}
^1da177e Linus Torvalds         2005-04-16  2089  
db4fbfb9 Michel Lespinasse      2012-12-11  2090  	info.flags = 0;
db4fbfb9 Michel Lespinasse      2012-12-11  2091  	info.length = len;
4e99b021 Heiko Carstens         2013-11-12  2092  	info.low_limit = mm->mmap_base;
d5d60952 Steve Capper           2018-10-17  2093  	info.high_limit = mmap_end;
db4fbfb9 Michel Lespinasse      2012-12-11  2094  	info.align_mask = 0;
db4fbfb9 Michel Lespinasse      2012-12-11  2095  	return vm_unmapped_area(&info);
^1da177e Linus Torvalds         2005-04-16  2096  }
^1da177e Linus Torvalds         2005-04-16  2097  #endif
^1da177e Linus Torvalds         2005-04-16  2098  

:::::: The code at line 2073 was first introduced by commit
:::::: d5d60952691e93644f4e7692baffbef33c93f91a mm: mmap: Allow for "high" userspace addresses

:::::: TO: Steve Capper <steve.capper@arm.com>
:::::: CC: 0day robot <lkp@intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 40225 bytes --]

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

* [PATCH V2 3/4] arm64: mm: Define arch_get_mmap_end, arch_get_mmap_base
@ 2018-10-18  2:28     ` kbuild test robot
  0 siblings, 0 replies; 24+ messages in thread
From: kbuild test robot @ 2018-10-18  2:28 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Steve,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on v4.19-rc8]
[cannot apply to next-20181017]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Steve-Capper/52-bit-userspace-VAs/20181018-061652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm64 

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/qrwlock.h:23:0,
                    from ./arch/arm64/include/generated/asm/qrwlock.h:1,
                    from arch/arm64/include/asm/spinlock.h:19,
                    from include/linux/spinlock.h:88,
                    from include/linux/mmzone.h:8,
                    from include/linux/gfp.h:6,
                    from include/linux/slab.h:15,
                    from mm/mmap.c:12:
   mm/mmap.c: In function 'arch_get_unmapped_area':
   arch/arm64/include/asm/processor.h:63:50: error: 'tsk' undeclared (first use in this function)
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   arch/arm64/include/asm/processor.h:81:42: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\
                                             ^~~~~~~~~~~~~~~~~~
>> mm/mmap.c:2073:33: note: in expansion of macro 'arch_get_mmap_end'
     const unsigned long mmap_end = arch_get_mmap_end(addr);
                                    ^~~~~~~~~~~~~~~~~
   arch/arm64/include/asm/processor.h:63:50: note: each undeclared identifier is reported only once for each function it appears in
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   arch/arm64/include/asm/processor.h:81:42: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\
                                             ^~~~~~~~~~~~~~~~~~
>> mm/mmap.c:2073:33: note: in expansion of macro 'arch_get_mmap_end'
     const unsigned long mmap_end = arch_get_mmap_end(addr);
                                    ^~~~~~~~~~~~~~~~~
   mm/mmap.c: In function 'arch_get_unmapped_area_topdown':
   arch/arm64/include/asm/processor.h:63:50: error: 'tsk' undeclared (first use in this function)
    #define DEFAULT_MAP_WINDOW (test_tsk_thread_flag(tsk, TIF_32BIT) ? \
                                                     ^
   arch/arm64/include/asm/processor.h:81:42: note: in expansion of macro 'DEFAULT_MAP_WINDOW'
    #define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\
                                             ^~~~~~~~~~~~~~~~~~
   mm/mmap.c:2113:33: note: in expansion of macro 'arch_get_mmap_end'
     const unsigned long mmap_end = arch_get_mmap_end(addr);
                                    ^~~~~~~~~~~~~~~~~

vim +/arch_get_mmap_end +2073 mm/mmap.c

d5d60952 Steve Capper           2018-10-17  2053  
^1da177e Linus Torvalds         2005-04-16  2054  /* Get an address range which is currently unmapped.
^1da177e Linus Torvalds         2005-04-16  2055   * For shmat() with addr=0.
^1da177e Linus Torvalds         2005-04-16  2056   *
^1da177e Linus Torvalds         2005-04-16  2057   * Ugly calling convention alert:
^1da177e Linus Torvalds         2005-04-16  2058   * Return value with the low bits set means error value,
^1da177e Linus Torvalds         2005-04-16  2059   * ie
^1da177e Linus Torvalds         2005-04-16  2060   *	if (ret & ~PAGE_MASK)
^1da177e Linus Torvalds         2005-04-16  2061   *		error = ret;
^1da177e Linus Torvalds         2005-04-16  2062   *
^1da177e Linus Torvalds         2005-04-16  2063   * This function "knows" that -ENOMEM has the bits set.
^1da177e Linus Torvalds         2005-04-16  2064   */
^1da177e Linus Torvalds         2005-04-16  2065  #ifndef HAVE_ARCH_UNMAPPED_AREA
^1da177e Linus Torvalds         2005-04-16  2066  unsigned long
^1da177e Linus Torvalds         2005-04-16  2067  arch_get_unmapped_area(struct file *filp, unsigned long addr,
^1da177e Linus Torvalds         2005-04-16  2068  		unsigned long len, unsigned long pgoff, unsigned long flags)
^1da177e Linus Torvalds         2005-04-16  2069  {
^1da177e Linus Torvalds         2005-04-16  2070  	struct mm_struct *mm = current->mm;
1be7107f Hugh Dickins           2017-06-19  2071  	struct vm_area_struct *vma, *prev;
db4fbfb9 Michel Lespinasse      2012-12-11  2072  	struct vm_unmapped_area_info info;
d5d60952 Steve Capper           2018-10-17 @2073  	const unsigned long mmap_end = arch_get_mmap_end(addr);
^1da177e Linus Torvalds         2005-04-16  2074  
d5d60952 Steve Capper           2018-10-17  2075  	if (len > mmap_end - mmap_min_addr)
^1da177e Linus Torvalds         2005-04-16  2076  		return -ENOMEM;
^1da177e Linus Torvalds         2005-04-16  2077  
06abdfb4 Benjamin Herrenschmidt 2007-05-06  2078  	if (flags & MAP_FIXED)
06abdfb4 Benjamin Herrenschmidt 2007-05-06  2079  		return addr;
06abdfb4 Benjamin Herrenschmidt 2007-05-06  2080  
^1da177e Linus Torvalds         2005-04-16  2081  	if (addr) {
^1da177e Linus Torvalds         2005-04-16  2082  		addr = PAGE_ALIGN(addr);
1be7107f Hugh Dickins           2017-06-19  2083  		vma = find_vma_prev(mm, addr, &prev);
d5d60952 Steve Capper           2018-10-17  2084  		if (mmap_end - len >= addr && addr >= mmap_min_addr &&
1be7107f Hugh Dickins           2017-06-19  2085  		    (!vma || addr + len <= vm_start_gap(vma)) &&
1be7107f Hugh Dickins           2017-06-19  2086  		    (!prev || addr >= vm_end_gap(prev)))
^1da177e Linus Torvalds         2005-04-16  2087  			return addr;
^1da177e Linus Torvalds         2005-04-16  2088  	}
^1da177e Linus Torvalds         2005-04-16  2089  
db4fbfb9 Michel Lespinasse      2012-12-11  2090  	info.flags = 0;
db4fbfb9 Michel Lespinasse      2012-12-11  2091  	info.length = len;
4e99b021 Heiko Carstens         2013-11-12  2092  	info.low_limit = mm->mmap_base;
d5d60952 Steve Capper           2018-10-17  2093  	info.high_limit = mmap_end;
db4fbfb9 Michel Lespinasse      2012-12-11  2094  	info.align_mask = 0;
db4fbfb9 Michel Lespinasse      2012-12-11  2095  	return vm_unmapped_area(&info);
^1da177e Linus Torvalds         2005-04-16  2096  }
^1da177e Linus Torvalds         2005-04-16  2097  #endif
^1da177e Linus Torvalds         2005-04-16  2098  

:::::: The code at line 2073 was first introduced by commit
:::::: d5d60952691e93644f4e7692baffbef33c93f91a mm: mmap: Allow for "high" userspace addresses

:::::: TO: Steve Capper <steve.capper@arm.com>
:::::: CC: 0day robot <lkp@intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 40225 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181018/3b851d8b/attachment-0001.gz>

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

* Re: [PATCH V2 4/4] arm64: mm: introduce 52-bit userspace support
  2018-10-17 16:34   ` Steve Capper
@ 2018-10-18  2:44     ` kbuild test robot
  -1 siblings, 0 replies; 24+ messages in thread
From: kbuild test robot @ 2018-10-18  2:44 UTC (permalink / raw)
  To: Steve Capper
  Cc: kbuild-all, linux-mm, linux-arm-kernel, catalin.marinas,
	will.deacon, ard.biesheuvel, jcm

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

Hi Steve,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on v4.19-rc8]
[cannot apply to next-20181017]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Steve-Capper/52-bit-userspace-VAs/20181018-061652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/export.h:45:0,
                    from include/linux/linkage.h:7,
                    from include/linux/kernel.h:7,
                    from arch/arm64/mm/init.c:20:
   arch/arm64/mm/init.c: In function 'mem_init':
>> include/linux/compiler.h:358:38: error: call to '__compiletime_assert_613' declared with attribute error: BUILD_BUG_ON failed: TASK_SIZE_32 > TASK_SIZE_64
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                         ^
   include/linux/compiler.h:338:4: note: in definition of macro '__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler.h:358:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:45:37: note: in expansion of macro 'compiletime_assert'
    #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                        ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:69:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
     BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
     ^~~~~~~~~~~~~~~~
>> arch/arm64/mm/init.c:613:2: note: in expansion of macro 'BUILD_BUG_ON'
     BUILD_BUG_ON(TASK_SIZE_32   > TASK_SIZE_64);
     ^~~~~~~~~~~~

vim +/__compiletime_assert_613 +358 include/linux/compiler.h

9a8ab1c3 Daniel Santos 2013-02-21  344  
9a8ab1c3 Daniel Santos 2013-02-21  345  #define _compiletime_assert(condition, msg, prefix, suffix) \
9a8ab1c3 Daniel Santos 2013-02-21  346  	__compiletime_assert(condition, msg, prefix, suffix)
9a8ab1c3 Daniel Santos 2013-02-21  347  
9a8ab1c3 Daniel Santos 2013-02-21  348  /**
9a8ab1c3 Daniel Santos 2013-02-21  349   * compiletime_assert - break build and emit msg if condition is false
9a8ab1c3 Daniel Santos 2013-02-21  350   * @condition: a compile-time constant condition to check
9a8ab1c3 Daniel Santos 2013-02-21  351   * @msg:       a message to emit if condition is false
9a8ab1c3 Daniel Santos 2013-02-21  352   *
9a8ab1c3 Daniel Santos 2013-02-21  353   * In tradition of POSIX assert, this macro will break the build if the
9a8ab1c3 Daniel Santos 2013-02-21  354   * supplied condition is *false*, emitting the supplied error message if the
9a8ab1c3 Daniel Santos 2013-02-21  355   * compiler has support to do so.
9a8ab1c3 Daniel Santos 2013-02-21  356   */
9a8ab1c3 Daniel Santos 2013-02-21  357  #define compiletime_assert(condition, msg) \
9a8ab1c3 Daniel Santos 2013-02-21 @358  	_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
9a8ab1c3 Daniel Santos 2013-02-21  359  

:::::: The code at line 358 was first introduced by commit
:::::: 9a8ab1c39970a4938a72d94e6fd13be88a797590 bug.h, compiler.h: introduce compiletime_assert & BUILD_BUG_ON_MSG

:::::: TO: Daniel Santos <daniel.santos@pobox.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 40225 bytes --]

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

* [PATCH V2 4/4] arm64: mm: introduce 52-bit userspace support
@ 2018-10-18  2:44     ` kbuild test robot
  0 siblings, 0 replies; 24+ messages in thread
From: kbuild test robot @ 2018-10-18  2:44 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Steve,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on v4.19-rc8]
[cannot apply to next-20181017]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Steve-Capper/52-bit-userspace-VAs/20181018-061652
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/export.h:45:0,
                    from include/linux/linkage.h:7,
                    from include/linux/kernel.h:7,
                    from arch/arm64/mm/init.c:20:
   arch/arm64/mm/init.c: In function 'mem_init':
>> include/linux/compiler.h:358:38: error: call to '__compiletime_assert_613' declared with attribute error: BUILD_BUG_ON failed: TASK_SIZE_32 > TASK_SIZE_64
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                         ^
   include/linux/compiler.h:338:4: note: in definition of macro '__compiletime_assert'
       prefix ## suffix();    \
       ^~~~~~
   include/linux/compiler.h:358:2: note: in expansion of macro '_compiletime_assert'
     _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
     ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:45:37: note: in expansion of macro 'compiletime_assert'
    #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                        ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:69:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
     BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
     ^~~~~~~~~~~~~~~~
>> arch/arm64/mm/init.c:613:2: note: in expansion of macro 'BUILD_BUG_ON'
     BUILD_BUG_ON(TASK_SIZE_32   > TASK_SIZE_64);
     ^~~~~~~~~~~~

vim +/__compiletime_assert_613 +358 include/linux/compiler.h

9a8ab1c3 Daniel Santos 2013-02-21  344  
9a8ab1c3 Daniel Santos 2013-02-21  345  #define _compiletime_assert(condition, msg, prefix, suffix) \
9a8ab1c3 Daniel Santos 2013-02-21  346  	__compiletime_assert(condition, msg, prefix, suffix)
9a8ab1c3 Daniel Santos 2013-02-21  347  
9a8ab1c3 Daniel Santos 2013-02-21  348  /**
9a8ab1c3 Daniel Santos 2013-02-21  349   * compiletime_assert - break build and emit msg if condition is false
9a8ab1c3 Daniel Santos 2013-02-21  350   * @condition: a compile-time constant condition to check
9a8ab1c3 Daniel Santos 2013-02-21  351   * @msg:       a message to emit if condition is false
9a8ab1c3 Daniel Santos 2013-02-21  352   *
9a8ab1c3 Daniel Santos 2013-02-21  353   * In tradition of POSIX assert, this macro will break the build if the
9a8ab1c3 Daniel Santos 2013-02-21  354   * supplied condition is *false*, emitting the supplied error message if the
9a8ab1c3 Daniel Santos 2013-02-21  355   * compiler has support to do so.
9a8ab1c3 Daniel Santos 2013-02-21  356   */
9a8ab1c3 Daniel Santos 2013-02-21  357  #define compiletime_assert(condition, msg) \
9a8ab1c3 Daniel Santos 2013-02-21 @358  	_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
9a8ab1c3 Daniel Santos 2013-02-21  359  

:::::: The code at line 358 was first introduced by commit
:::::: 9a8ab1c39970a4938a72d94e6fd13be88a797590 bug.h, compiler.h: introduce compiletime_assert & BUILD_BUG_ON_MSG

:::::: TO: Daniel Santos <daniel.santos@pobox.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 40225 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181018/4ba01138/attachment-0001.gz>

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

* Re: [PATCH V2 1/4] mm: mmap: Allow for "high" userspace addresses
  2018-10-17 16:48     ` Matthew Wilcox
@ 2018-10-18 10:35       ` Steve Capper
  -1 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-18 10:35 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-mm, linux-arm-kernel, Catalin Marinas, Will Deacon,
	ard.biesheuvel, jcm, nd

On Wed, Oct 17, 2018 at 09:48:15AM -0700, Matthew Wilcox wrote:
> On Wed, Oct 17, 2018 at 05:34:56PM +0100, Steve Capper wrote:
> > This patch adds support for "high" userspace addresses that are
> > optionally supported on the system and have to be requested via a hint
> > mechanism ("high" addr parameter to mmap).
> > 
> > Rather than duplicate the arch_get_unmapped_* stock implementations,
> > this patch instead introduces two architectural helper macros and
> > applies them to arch_get_unmapped_*:
> >  arch_get_mmap_end(addr) - get mmap upper limit depending on addr hint
> >  arch_get_mmap_base(addr, base) - get mmap_base depending on addr hint
> > 
> > If these macros are not defined in architectural code then they default
> > to (TASK_SIZE) and (base) so should not introduce any behavioural
> > changes to architectures that do not define them.
> 
> Can you explain (in the changelog) why we need to do this for arm64
> when it wasn't needed for the equivalent feature on x86-64?  I think the
> answer is that x86-64 already has its own arch_get_unmapped* functions and
> rather than duplicating arch_get_unmapped* for arm64, you want to continue
> using the generic ones with just this minor hooking.  But I'd like that
> spelled out explicitly for the next person who comes along and wonders.
>

Thanks Matthew,
Yes we thought it better to make an unobtrusive change to the generic
code rather than copy it over to arm64 (whilst x86 already had an
architecture specific version that was patched).

I will make the commit log a lot clearer.

Cheers,
-- 
Steve

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

* [PATCH V2 1/4] mm: mmap: Allow for "high" userspace addresses
@ 2018-10-18 10:35       ` Steve Capper
  0 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-18 10:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 17, 2018 at 09:48:15AM -0700, Matthew Wilcox wrote:
> On Wed, Oct 17, 2018 at 05:34:56PM +0100, Steve Capper wrote:
> > This patch adds support for "high" userspace addresses that are
> > optionally supported on the system and have to be requested via a hint
> > mechanism ("high" addr parameter to mmap).
> > 
> > Rather than duplicate the arch_get_unmapped_* stock implementations,
> > this patch instead introduces two architectural helper macros and
> > applies them to arch_get_unmapped_*:
> >  arch_get_mmap_end(addr) - get mmap upper limit depending on addr hint
> >  arch_get_mmap_base(addr, base) - get mmap_base depending on addr hint
> > 
> > If these macros are not defined in architectural code then they default
> > to (TASK_SIZE) and (base) so should not introduce any behavioural
> > changes to architectures that do not define them.
> 
> Can you explain (in the changelog) why we need to do this for arm64
> when it wasn't needed for the equivalent feature on x86-64?  I think the
> answer is that x86-64 already has its own arch_get_unmapped* functions and
> rather than duplicating arch_get_unmapped* for arm64, you want to continue
> using the generic ones with just this minor hooking.  But I'd like that
> spelled out explicitly for the next person who comes along and wonders.
>

Thanks Matthew,
Yes we thought it better to make an unobtrusive change to the generic
code rather than copy it over to arm64 (whilst x86 already had an
architecture specific version that was patched).

I will make the commit log a lot clearer.

Cheers,
-- 
Steve

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

* Re: [PATCH V2 2/4] arm64: mm: Introduce DEFAULT_MAP_WINDOW
  2018-10-17 16:34   ` Steve Capper
@ 2018-10-18 10:47     ` Steve Capper
  -1 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-18 10:47 UTC (permalink / raw)
  To: linux-mm, linux-arm-kernel
  Cc: Catalin Marinas, Will Deacon, ard.biesheuvel, jcm, nd

On Wed, Oct 17, 2018 at 05:34:57PM +0100, Steve Capper wrote:
> We wish to introduce a 52-bit virtual address space for userspace but
> maintain compatibility with software that assumes the maximum VA space
> size is 48 bit.
> 
> In order to achieve this, on 52-bit VA systems, we make mmap behave as
> if it were running on a 48-bit VA system (unless userspace explicitly
> requests a VA where addr[51:48] != 0).
> 
> On a system running a 52-bit userspace we need TASK_SIZE to represent
> the 52-bit limit as it is used in various places to distinguish between
> kernelspace and userspace addresses.
> 
> Thus we need a new limit for mmap, stack, ELF loader and EFI (which uses
> TTBR0) to represent the non-extended VA space.
> 
> This patch introduces DEFAULT_MAP_WINDOW and DEFAULT_MAP_WINDOW_64 and
> switches the appropriate logic to use that instead of TASK_SIZE.
> 
> Signed-off-by: Steve Capper <steve.capper@arm.com>

Whilst testing this series I inadvertantly dropped CONFIG_COMPAT which
has led to some kbuild errors with defconfig.

I will make the following changes to this patch.

[...]
> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
> index 79657ad91397..46c9d9ff028c 100644
> --- a/arch/arm64/include/asm/processor.h
> +++ b/arch/arm64/include/asm/processor.h
> @@ -26,6 +26,8 @@
>  
>  #ifndef __ASSEMBLY__
>  
> +#define DEFAULT_MAP_WINDOW_64	(UL(1) << VA_BITS)
> +
>  /*
>   * Default implementation of macro that returns current
>   * instruction pointer ("program counter").
> @@ -58,13 +60,16 @@
>  				TASK_SIZE_32 : TASK_SIZE_64)
>  #define TASK_SIZE_OF(tsk)	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
>  				TASK_SIZE_32 : TASK_SIZE_64)
> +#define DEFAULT_MAP_WINDOW	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
> +				TASK_SIZE_32 : DEFAULT_MAP_WINDOW_64)

Instead of test_tsk_thread_flag I will use test_thread_flag for
DEFAULT_MAP_WINDOW.

>  #else
>  #define TASK_SIZE		TASK_SIZE_64
> +#define DEFAULT_MAP_WINDOW	DEFAULT_MAP_WINDOW_64
>  #endif /* CONFIG_COMPAT */
>  
> -#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(TASK_SIZE / 4))
> +#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
> +#define STACK_TOP_MAX		DEFAULT_MAP_WINDOW_64
>  
> -#define STACK_TOP_MAX		TASK_SIZE_64
>  #ifdef CONFIG_COMPAT
>  #define AARCH32_VECTORS_BASE	0xffff0000
>  #define STACK_TOP		(test_thread_flag(TIF_32BIT) ? \
> diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
> index 922cfb813109..952cec5b611a 100644
> --- a/drivers/firmware/efi/arm-runtime.c
> +++ b/drivers/firmware/efi/arm-runtime.c
> @@ -38,7 +38,7 @@ static struct ptdump_info efi_ptdump_info = {
>  	.mm		= &efi_mm,
>  	.markers	= (struct addr_marker[]){
>  		{ 0,		"UEFI runtime start" },
> -		{ TASK_SIZE_64,	"UEFI runtime end" }
> +		{ DEFAULT_MAP_WINDOW_64, "UEFI runtime end" }
>  	},
>  	.base_addr	= 0,
>  };
[...]

Also I will modify arch/arm64/mm/init.c:615 to be:
BUILD_BUG_ON(TASK_SIZE_32 > DEFAULT_MAP_WINDOW_64);

The above give me a working kernel with defconig. I will perform more tests
on COMPAT before sending a revised series out.

Cheers,
-- 
Steve

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

* [PATCH V2 2/4] arm64: mm: Introduce DEFAULT_MAP_WINDOW
@ 2018-10-18 10:47     ` Steve Capper
  0 siblings, 0 replies; 24+ messages in thread
From: Steve Capper @ 2018-10-18 10:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Oct 17, 2018 at 05:34:57PM +0100, Steve Capper wrote:
> We wish to introduce a 52-bit virtual address space for userspace but
> maintain compatibility with software that assumes the maximum VA space
> size is 48 bit.
> 
> In order to achieve this, on 52-bit VA systems, we make mmap behave as
> if it were running on a 48-bit VA system (unless userspace explicitly
> requests a VA where addr[51:48] != 0).
> 
> On a system running a 52-bit userspace we need TASK_SIZE to represent
> the 52-bit limit as it is used in various places to distinguish between
> kernelspace and userspace addresses.
> 
> Thus we need a new limit for mmap, stack, ELF loader and EFI (which uses
> TTBR0) to represent the non-extended VA space.
> 
> This patch introduces DEFAULT_MAP_WINDOW and DEFAULT_MAP_WINDOW_64 and
> switches the appropriate logic to use that instead of TASK_SIZE.
> 
> Signed-off-by: Steve Capper <steve.capper@arm.com>

Whilst testing this series I inadvertantly dropped CONFIG_COMPAT which
has led to some kbuild errors with defconfig.

I will make the following changes to this patch.

[...]
> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
> index 79657ad91397..46c9d9ff028c 100644
> --- a/arch/arm64/include/asm/processor.h
> +++ b/arch/arm64/include/asm/processor.h
> @@ -26,6 +26,8 @@
>  
>  #ifndef __ASSEMBLY__
>  
> +#define DEFAULT_MAP_WINDOW_64	(UL(1) << VA_BITS)
> +
>  /*
>   * Default implementation of macro that returns current
>   * instruction pointer ("program counter").
> @@ -58,13 +60,16 @@
>  				TASK_SIZE_32 : TASK_SIZE_64)
>  #define TASK_SIZE_OF(tsk)	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
>  				TASK_SIZE_32 : TASK_SIZE_64)
> +#define DEFAULT_MAP_WINDOW	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
> +				TASK_SIZE_32 : DEFAULT_MAP_WINDOW_64)

Instead of test_tsk_thread_flag I will use test_thread_flag for
DEFAULT_MAP_WINDOW.

>  #else
>  #define TASK_SIZE		TASK_SIZE_64
> +#define DEFAULT_MAP_WINDOW	DEFAULT_MAP_WINDOW_64
>  #endif /* CONFIG_COMPAT */
>  
> -#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(TASK_SIZE / 4))
> +#define TASK_UNMAPPED_BASE	(PAGE_ALIGN(DEFAULT_MAP_WINDOW / 4))
> +#define STACK_TOP_MAX		DEFAULT_MAP_WINDOW_64
>  
> -#define STACK_TOP_MAX		TASK_SIZE_64
>  #ifdef CONFIG_COMPAT
>  #define AARCH32_VECTORS_BASE	0xffff0000
>  #define STACK_TOP		(test_thread_flag(TIF_32BIT) ? \
> diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
> index 922cfb813109..952cec5b611a 100644
> --- a/drivers/firmware/efi/arm-runtime.c
> +++ b/drivers/firmware/efi/arm-runtime.c
> @@ -38,7 +38,7 @@ static struct ptdump_info efi_ptdump_info = {
>  	.mm		= &efi_mm,
>  	.markers	= (struct addr_marker[]){
>  		{ 0,		"UEFI runtime start" },
> -		{ TASK_SIZE_64,	"UEFI runtime end" }
> +		{ DEFAULT_MAP_WINDOW_64, "UEFI runtime end" }
>  	},
>  	.base_addr	= 0,
>  };
[...]

Also I will modify arch/arm64/mm/init.c:615 to be:
BUILD_BUG_ON(TASK_SIZE_32 > DEFAULT_MAP_WINDOW_64);

The above give me a working kernel with defconig. I will perform more tests
on COMPAT before sending a revised series out.

Cheers,
-- 
Steve

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

end of thread, other threads:[~2018-10-18 10:47 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-17 16:34 [PATCH V2 0/4] 52-bit userspace VAs Steve Capper
2018-10-17 16:34 ` Steve Capper
2018-10-17 16:34 ` [PATCH V2 1/4] mm: mmap: Allow for "high" userspace addresses Steve Capper
2018-10-17 16:34   ` Steve Capper
2018-10-17 16:48   ` Matthew Wilcox
2018-10-17 16:48     ` Matthew Wilcox
2018-10-18 10:35     ` Steve Capper
2018-10-18 10:35       ` Steve Capper
2018-10-17 16:34 ` [PATCH V2 2/4] arm64: mm: Introduce DEFAULT_MAP_WINDOW Steve Capper
2018-10-17 16:34   ` Steve Capper
2018-10-18  1:50   ` kbuild test robot
2018-10-18  1:50     ` kbuild test robot
2018-10-18  2:09   ` kbuild test robot
2018-10-18  2:09     ` kbuild test robot
2018-10-18 10:47   ` Steve Capper
2018-10-18 10:47     ` Steve Capper
2018-10-17 16:34 ` [PATCH V2 3/4] arm64: mm: Define arch_get_mmap_end, arch_get_mmap_base Steve Capper
2018-10-17 16:34   ` Steve Capper
2018-10-18  2:28   ` kbuild test robot
2018-10-18  2:28     ` kbuild test robot
2018-10-17 16:34 ` [PATCH V2 4/4] arm64: mm: introduce 52-bit userspace support Steve Capper
2018-10-17 16:34   ` Steve Capper
2018-10-18  2:44   ` kbuild test robot
2018-10-18  2:44     ` kbuild test robot

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.