Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1532673 > unrolled thread

[PATCHv4 00/10] CONFIG_DEBUG_VIRTUAL for arm64

Started byLaura Abbott <labbott@redhat.com>
First post2016-11-29 20:00 +0100
Last post2016-12-07 07:20 +0100
Articles 7 on this page of 27 — 7 participants

Back to article view | Back to linux.kernel


Contents

  [PATCHv4 00/10] CONFIG_DEBUG_VIRTUAL for arm64 Laura Abbott <labbott@redhat.com> - 2016-11-29 20:00 +0100
    [PATCHv4 09/10] mm/usercopy: Switch to using lm_alias Laura Abbott <labbott@redhat.com> - 2016-11-29 20:00 +0100
      Re: [PATCHv4 09/10] mm/usercopy: Switch to using lm_alias Kees Cook <keescook@chromium.org> - 2016-11-29 20:40 +0100
        Re: [PATCHv4 09/10] mm/usercopy: Switch to using lm_alias Mark Rutland <mark.rutland@arm.com> - 2016-12-06 19:20 +0100
          Re: [PATCHv4 09/10] mm/usercopy: Switch to using lm_alias Kees Cook <keescook@chromium.org> - 2016-12-06 21:20 +0100
            Re: [PATCHv4 09/10] mm/usercopy: Switch to using lm_alias Mark Rutland <mark.rutland@arm.com> - 2016-12-07 15:00 +0100
      Re: [PATCHv4 09/10] mm/usercopy: Switch to using lm_alias Mark Rutland <mark.rutland@arm.com> - 2016-12-06 19:30 +0100
    [PATCHv4 10/10] arm64: Add support for CONFIG_DEBUG_VIRTUAL Laura Abbott <labbott@redhat.com> - 2016-11-29 20:00 +0100
      Re: [PATCHv4 10/10] arm64: Add support for CONFIG_DEBUG_VIRTUAL Mark Rutland <mark.rutland@arm.com> - 2016-12-06 20:00 +0100
    [PATCHv4 08/10] mm/kasan: Switch to using __pa_symbol and lm_alias Laura Abbott <labbott@redhat.com> - 2016-11-29 20:00 +0100
      Re: [PATCHv4 08/10] mm/kasan: Switch to using __pa_symbol and  lm_alias Laura Abbott <labbott@redhat.com> - 2016-12-01 20:20 +0100
      Re: [PATCHv4 08/10] mm/kasan: Switch to using __pa_symbol and  lm_alias Mark Rutland <mark.rutland@arm.com> - 2016-12-06 18:30 +0100
      Re: [PATCHv4 08/10] mm/kasan: Switch to using __pa_symbol and  lm_alias Mark Rutland <mark.rutland@arm.com> - 2016-12-06 18:50 +0100
      Re: [PATCHv4 08/10] mm/kasan: Switch to using __pa_symbol and  lm_alias Mark Rutland <mark.rutland@arm.com> - 2016-12-06 20:30 +0100
    [PATCHv4 06/10] xen: Switch to using __pa_symbol Laura Abbott <labbott@redhat.com> - 2016-11-29 20:00 +0100
      Re: [PATCHv4 06/10] xen: Switch to using __pa_symbol Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2016-11-29 23:30 +0100
        Re: [PATCHv4 06/10] xen: Switch to using __pa_symbol Laura Abbott <labbott@redhat.com> - 2016-11-29 23:50 +0100
    [PATCH 0/3] ARM: Add support for CONFIG_DEBUG_VIRTUAL Florian Fainelli <f.fainelli@gmail.com> - 2016-12-06 21:00 +0100
      [PATCH 3/3] ARM: Add support for CONFIG_DEBUG_VIRTUAL Florian Fainelli <f.fainelli@gmail.com> - 2016-12-06 21:00 +0100
        Re: [PATCH 3/3] ARM: Add support for CONFIG_DEBUG_VIRTUAL Florian Fainelli <f.fainelli@gmail.com> - 2016-12-06 21:50 +0100
        Re: [PATCH 3/3] ARM: Add support for CONFIG_DEBUG_VIRTUAL Laura Abbott <labbott@redhat.com> - 2016-12-07 03:10 +0100
          Re: [PATCH 3/3] ARM: Add support for CONFIG_DEBUG_VIRTUAL Florian Fainelli <f.fainelli@gmail.com> - 2016-12-07 03:30 +0100
      [PATCH 2/3] ARM: Utilize __pa_symbol in lieu of __pa Florian Fainelli <f.fainelli@gmail.com> - 2016-12-06 21:00 +0100
      [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END Florian Fainelli <f.fainelli@gmail.com> - 2016-12-06 21:00 +0100
        Re: [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END Florian Fainelli <f.fainelli@gmail.com> - 2016-12-06 23:50 +0100
        RE: [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END Chris Brandt <Chris.Brandt@renesas.com> - 2016-12-06 23:50 +0100
        Re: [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END kbuild test robot <lkp@intel.com> - 2016-12-07 07:20 +0100

Page 2 of 2 — ← Prev page 1 [2]


#1537420 — Re: [PATCH 3/3] ARM: Add support for CONFIG_DEBUG_VIRTUAL

FromLaura Abbott <labbott@redhat.com>
Date2016-12-07 03:10 +0100
SubjectRe: [PATCH 3/3] ARM: Add support for CONFIG_DEBUG_VIRTUAL
Message-ID<sLzQe-1LR-7@gated-at.bofh.it>
In reply to#1537250
On 12/06/2016 11:53 AM, Florian Fainelli wrote:
> x86 has an option: CONFIG_DEBUG_VIRTUAL to do additional checks on
> virt_to_phys calls. The goal is to catch users who are calling
> virt_to_phys on non-linear addresses immediately. This includes caller
> using __virt_to_phys() on image addresses instead of __pa_symbol(). This
> is a generally useful debug feature to spot bad code (particulary in
> drivers).
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  arch/arm/Kconfig              |  1 +
>  arch/arm/include/asm/memory.h | 16 ++++++++++++--
>  arch/arm/mm/Makefile          |  1 +
>  arch/arm/mm/physaddr.c        | 51 +++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 67 insertions(+), 2 deletions(-)
>  create mode 100644 arch/arm/mm/physaddr.c
> 
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index b5d529fdffab..5e66173c5787 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -2,6 +2,7 @@ config ARM
>  	bool
>  	default y
>  	select ARCH_CLOCKSOURCE_DATA
> +	select ARCH_HAS_DEBUG_VIRTUAL
>  	select ARCH_HAS_DEVMEM_IS_ALLOWED
>  	select ARCH_HAS_ELF_RANDOMIZE
>  	select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index bee7511c5098..46f192218be7 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -213,7 +213,7 @@ extern const void *__pv_table_begin, *__pv_table_end;
>  	: "r" (x), "I" (__PV_BITS_31_24)		\
>  	: "cc")
>  
> -static inline phys_addr_t __virt_to_phys(unsigned long x)
> +static inline phys_addr_t __virt_to_phys_nodebug(unsigned long x)
>  {
>  	phys_addr_t t;
>  
> @@ -245,7 +245,7 @@ static inline unsigned long __phys_to_virt(phys_addr_t x)
>  #define PHYS_OFFSET	PLAT_PHYS_OFFSET
>  #define PHYS_PFN_OFFSET	((unsigned long)(PHYS_OFFSET >> PAGE_SHIFT))
>  
> -static inline phys_addr_t __virt_to_phys(unsigned long x)
> +static inline phys_addr_t __virt_to_phys_nodebug(unsigned long x)
>  {
>  	return (phys_addr_t)x - PAGE_OFFSET + PHYS_OFFSET;
>  }
> @@ -261,6 +261,16 @@ static inline unsigned long __phys_to_virt(phys_addr_t x)
>  	((((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT) + \
>  	 PHYS_PFN_OFFSET)
>  
> +#define __pa_symbol_nodebug(x)	((x) - (unsigned long)KERNEL_START)

On arm64 the kernel image lives in a separate linear offset. arm doesn't
do anything like that so __phys_addr_symbol should just be the regular
__virt_to_phys

> +
> +#ifdef CONFIG_DEBUG_VIRTUAL
> +extern phys_addr_t __virt_to_phys(unsigned long x);
> +extern phys_addr_t __phys_addr_symbol(unsigned long x);
> +#else
> +#define __virt_to_phys(x)	__virt_to_phys_nodebug(x)
> +#define __phys_addr_symbol(x)	__pa_symbol_nodebug(x)
> +#endif
> +
>  /*
>   * These are *only* valid on the kernel direct mapped RAM memory.
>   * Note: Drivers should NOT use these.  They are the wrong
> @@ -283,9 +293,11 @@ static inline void *phys_to_virt(phys_addr_t x)
>   * Drivers should NOT use these either.
>   */
>  #define __pa(x)			__virt_to_phys((unsigned long)(x))
> +#define __pa_symbol(x)		__phys_addr_symbol(RELOC_HIDE((unsigned long)(x), 0))
>  #define __va(x)			((void *)__phys_to_virt((phys_addr_t)(x)))
>  #define pfn_to_kaddr(pfn)	__va((phys_addr_t)(pfn) << PAGE_SHIFT)
>  
> +
>  extern long long arch_phys_to_idmap_offset;
>  
>  /*
> diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile
> index e8698241ece9..b3dea80715b4 100644
> --- a/arch/arm/mm/Makefile
> +++ b/arch/arm/mm/Makefile
> @@ -14,6 +14,7 @@ endif
>  
>  obj-$(CONFIG_ARM_PTDUMP)	+= dump.o
>  obj-$(CONFIG_MODULES)		+= proc-syms.o
> +obj-$(CONFIG_DEBUG_VIRTUAL)	+= physaddr.o
>  
>  obj-$(CONFIG_ALIGNMENT_TRAP)	+= alignment.o
>  obj-$(CONFIG_HIGHMEM)		+= highmem.o
> diff --git a/arch/arm/mm/physaddr.c b/arch/arm/mm/physaddr.c
> new file mode 100644
> index 000000000000..00f6dcffab8b
> --- /dev/null
> +++ b/arch/arm/mm/physaddr.c
> @@ -0,0 +1,51 @@
> +#include <linux/bug.h>
> +#include <linux/export.h>
> +#include <linux/types.h>
> +#include <linux/mmdebug.h>
> +#include <linux/mm.h>
> +
> +#include <asm/sections.h>
> +#include <asm/memory.h>
> +#include <asm/fixmap.h>
> +
> +#include "mm.h"
> +
> +static inline bool __virt_addr_valid(unsigned long x)
> +{
> +	if (x < PAGE_OFFSET)
> +		return false;
> +	if (arm_lowmem_limit && is_vmalloc_or_module_addr((void *)x))
> +		return false;
> +	if (x >= FIXADDR_START && x < FIXADDR_END)
> +		return false;
> +	return true;
> +}

I'd rather see this return true for only the linear range and
reject everything else. asm/memory.h already has

#define virt_addr_valid(kaddr)  (((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) \
                                        && pfn_valid(virt_to_pfn(kaddr)))

So we can make the check x >= PAGE_OFFSET && x < high_memory

> +
> +phys_addr_t __virt_to_phys(unsigned long x)
> +{
> +	WARN(!__virt_addr_valid(x),
> +	     "virt_to_phys used for non-linear address :%pK\n", (void *)x);
> +
> +	return __virt_to_phys_nodebug(x);
> +}
> +EXPORT_SYMBOL(__virt_to_phys);
> +
> +static inline bool __phys_addr_valid(unsigned long x)
> +{
> +	/* This is bounds checking against the kernel image only.
> +	 * __pa_symbol should only be used on kernel symbol addresses.
> +	 */
> +	if (x < (unsigned long)KERNEL_START ||
> +	    x > (unsigned long)KERNEL_END)
> +		return false;
> +
> +	return true;
> +}

This is a confusing name for this function, it's not checking if
a physical address is valid, it's checking if a virtual address
corresponding to a kernel symbol is valid.

> +
> +phys_addr_t __phys_addr_symbol(unsigned long x)
> +{
> +	VIRTUAL_BUG_ON(!__phys_addr_valid(x));
> +
> +	return __pa_symbol_nodebug(x);
> +}
> +EXPORT_SYMBOL(__phys_addr_symbol);
> 

Thanks,
Laura

[toc] | [prev] | [next] | [standalone]


#1537431 — Re: [PATCH 3/3] ARM: Add support for CONFIG_DEBUG_VIRTUAL

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2016-12-07 03:30 +0100
SubjectRe: [PATCH 3/3] ARM: Add support for CONFIG_DEBUG_VIRTUAL
Message-ID<sLA9A-1Ws-13@gated-at.bofh.it>
In reply to#1537420
On 12/06/2016 06:00 PM, Laura Abbott wrote:
>> @@ -261,6 +261,16 @@ static inline unsigned long __phys_to_virt(phys_addr_t x)
>>  	((((unsigned long)(kaddr) - PAGE_OFFSET) >> PAGE_SHIFT) + \
>>  	 PHYS_PFN_OFFSET)
>>  
>> +#define __pa_symbol_nodebug(x)	((x) - (unsigned long)KERNEL_START)
> 
> On arm64 the kernel image lives in a separate linear offset. arm doesn't
> do anything like that so __phys_addr_symbol should just be the regular
> __virt_to_phys

Yep, which is what I have queued locally now too, thanks!


>> +static inline bool __virt_addr_valid(unsigned long x)
>> +{
>> +	if (x < PAGE_OFFSET)
>> +		return false;
>> +	if (arm_lowmem_limit && is_vmalloc_or_module_addr((void *)x))
>> +		return false;
>> +	if (x >= FIXADDR_START && x < FIXADDR_END)
>> +		return false;
>> +	return true;
>> +}
> 
> I'd rather see this return true for only the linear range and
> reject everything else. asm/memory.h already has
> 
> #define virt_addr_valid(kaddr)  (((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) \
>                                         && pfn_valid(virt_to_pfn(kaddr)))
> 
> So we can make the check x >= PAGE_OFFSET && x < high_memory

OK that's simpler indeed. I did the check this way because we have early
callers of __pa() from drivers/of/fdt.c, in particular MIN_MEMBLOCK_ADDR
there, and we also have pcpu_dfl_fc_alloc which uses DMA_MAX_ADDR (which
is 0xffff_ffff on my platform).

>> +static inline bool __phys_addr_valid(unsigned long x)
>> +{
>> +	/* This is bounds checking against the kernel image only.
>> +	 * __pa_symbol should only be used on kernel symbol addresses.
>> +	 */
>> +	if (x < (unsigned long)KERNEL_START ||
>> +	    x > (unsigned long)KERNEL_END)
>> +		return false;
>> +
>> +	return true;
>> +}
> 
> This is a confusing name for this function, it's not checking if
> a physical address is valid, it's checking if a virtual address
> corresponding to a kernel symbol is valid.

I have removed it and just moved the check within VIRTUAL_BUG_ON().

Thanks!
-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1537253 — [PATCH 2/3] ARM: Utilize __pa_symbol in lieu of __pa

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2016-12-06 21:00 +0100
Subject[PATCH 2/3] ARM: Utilize __pa_symbol in lieu of __pa
Message-ID<sLu4a-6lz-23@gated-at.bofh.it>
In reply to#1537248
Unfold pmd_populate_kernel() to make us use __pa_symbol() instead of
__pa(), pre-requisite to turning on CONFIG_DEBUG_VIRTUAL.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 arch/arm/mm/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 18ef688a796e..ab7e82085df9 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -394,7 +394,7 @@ void __init early_fixmap_init(void)
 		     != FIXADDR_TOP >> PMD_SHIFT);
 
 	pmd = fixmap_pmd(FIXADDR_TOP);
-	pmd_populate_kernel(&init_mm, pmd, bm_pte);
+	__pmd_populate(pmd, __pa_symbol(bm_pte), _PAGE_KERNEL_TABLE);
 
 	pte_offset_fixmap = pte_offset_early_fixmap;
 }
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1537254 — [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2016-12-06 21:00 +0100
Subject[PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END
Message-ID<sLu49-6lz-19@gated-at.bofh.it>
In reply to#1537248
In preparation for adding CONFIG_DEBUG_VIRTUAL support, define a set of
common constants: KERNEL_START and KERNEL_END which abstract
CONFIG_XIP_KERNEL vs. !CONFIG_XIP_KERNEL. Update the code where
relevant.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 arch/arm/include/asm/memory.h | 7 +++++++
 arch/arm/mm/init.c            | 7 ++-----
 arch/arm/mm/mmu.c             | 8 ++------
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 76cbd9c674df..bee7511c5098 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -111,6 +111,13 @@
 
 #endif /* !CONFIG_MMU */
 
+#ifdef CONFIG_XIP_KERNEL
+#define KERNEL_START		_sdata
+#else
+#define KERNEL_START		_stext
+#endif
+#define KERNEL_END		_end
+
 /*
  * We fix the TCM memories max 32 KiB ITCM resp DTCM at these
  * locations
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 370581aeb871..c87d0d5b65f2 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -230,11 +230,8 @@ phys_addr_t __init arm_memblock_steal(phys_addr_t size, phys_addr_t align)
 void __init arm_memblock_init(const struct machine_desc *mdesc)
 {
 	/* Register the kernel text, kernel data and initrd with memblock. */
-#ifdef CONFIG_XIP_KERNEL
-	memblock_reserve(__pa(_sdata), _end - _sdata);
-#else
-	memblock_reserve(__pa(_stext), _end - _stext);
-#endif
+	memblock_reserve(__pa(KERNEL_START), _end - KERNEL_START);
+
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* FDT scan will populate initrd_start */
 	if (initrd_start && !phys_initrd_size) {
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 4001dd15818d..18ef688a796e 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1437,12 +1437,8 @@ static void __init kmap_init(void)
 static void __init map_lowmem(void)
 {
 	struct memblock_region *reg;
-#ifdef CONFIG_XIP_KERNEL
-	phys_addr_t kernel_x_start = round_down(__pa(_sdata), SECTION_SIZE);
-#else
-	phys_addr_t kernel_x_start = round_down(__pa(_stext), SECTION_SIZE);
-#endif
-	phys_addr_t kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
+	phys_addr_t kernel_x_start = round_down(__pa(KERNEL_START), SECTION_SIZE);
+	phys_addr_t kernel_x_end = round_down(__pa(_end), SECTION_SIZE);
 
 	/* Map all the lowmem memory banks. */
 	for_each_memblock(memory, reg) {
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1537304 — Re: [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2016-12-06 23:50 +0100
SubjectRe: [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END
Message-ID<sLwIF-898-17@gated-at.bofh.it>
In reply to#1537254
On 12/06/2016 02:43 PM, Chris Brandt wrote:
> On 12/6/2016, Florian Fainelli wrote:
>> diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
>> index 4001dd15818d..18ef688a796e 100644
>> --- a/arch/arm/mm/mmu.c
>> +++ b/arch/arm/mm/mmu.c
>> @@ -1437,12 +1437,8 @@ static void __init kmap_init(void)
>>  static void __init map_lowmem(void)
>>  {
>>  	struct memblock_region *reg;
>> -#ifdef CONFIG_XIP_KERNEL
>> -	phys_addr_t kernel_x_start = round_down(__pa(_sdata), SECTION_SIZE);
>> -#else
>> -	phys_addr_t kernel_x_start = round_down(__pa(_stext), SECTION_SIZE);
>> -#endif
>> -	phys_addr_t kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
>> +	phys_addr_t kernel_x_start = round_down(__pa(KERNEL_START),
>> SECTION_SIZE);
>> +	phys_addr_t kernel_x_end = round_down(__pa(_end), SECTION_SIZE);
> 
> Why are you changing the end of executable kernel (hence the 'x' in
> kernel_x_end) from __init_end to _end which basically maps the entire
> kernel image including text and data?

That's a typo, was not intentional thanks for spotting it.
-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1537306 — RE: [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END

FromChris Brandt <Chris.Brandt@renesas.com>
Date2016-12-06 23:50 +0100
SubjectRE: [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END
Message-ID<sLwIF-898-19@gated-at.bofh.it>
In reply to#1537254
On 12/6/2016, Florian Fainelli wrote:
> diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
> index 4001dd15818d..18ef688a796e 100644
> --- a/arch/arm/mm/mmu.c
> +++ b/arch/arm/mm/mmu.c
> @@ -1437,12 +1437,8 @@ static void __init kmap_init(void)
>  static void __init map_lowmem(void)
>  {
>  	struct memblock_region *reg;
> -#ifdef CONFIG_XIP_KERNEL
> -	phys_addr_t kernel_x_start = round_down(__pa(_sdata), SECTION_SIZE);
> -#else
> -	phys_addr_t kernel_x_start = round_down(__pa(_stext), SECTION_SIZE);
> -#endif
> -	phys_addr_t kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
> +	phys_addr_t kernel_x_start = round_down(__pa(KERNEL_START),
> SECTION_SIZE);
> +	phys_addr_t kernel_x_end = round_down(__pa(_end), SECTION_SIZE);

Why are you changing the end of executable kernel (hence the 'x' in
kernel_x_end) from __init_end to _end which basically maps the entire
kernel image including text and data?

Doing so would then change data from MT_MEMORY_RW into MT_MEMORY_RWX.

I would think it would create some type of security risk to allow
data to be executable.

[toc] | [prev] | [next] | [standalone]


#1537510 — Re: [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END

Fromkbuild test robot <lkp@intel.com>
Date2016-12-07 07:20 +0100
SubjectRe: [PATCH 1/3] ARM: Define KERNEL_START and KERNEL_END
Message-ID<sLDK9-4JP-11@gated-at.bofh.it>
In reply to#1537254

[Multipart message — attachments visible in raw view] — view raw

Hi Florian,

[auto build test WARNING on linus/master]
[also build test WARNING on v4.9-rc8 next-20161206]
[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/Florian-Fainelli/ARM-Add-support-for-CONFIG_DEBUG_VIRTUAL/20161207-071442
config: arm-lart_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

All warnings (new ones prefixed by >>):

>> drivers/mtd/devices/lart.c:83:0: warning: "KERNEL_START" redefined
    #define KERNEL_START  (BLOB_START + BLOB_LEN)
    
   In file included from arch/arm/include/asm/page.h:163:0,
                    from arch/arm/include/asm/thread_info.h:17,
                    from include/linux/thread_info.h:58,
                    from include/asm-generic/preempt.h:4,
                    from ./arch/arm/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:59,
                    from include/linux/spinlock.h:50,
                    from include/linux/seqlock.h:35,
                    from include/linux/time.h:5,
                    from include/linux/stat.h:18,
                    from include/linux/module.h:10,
                    from drivers/mtd/devices/lart.c:38:
   arch/arm/include/asm/memory.h:117:0: note: this is the location of the previous definition
    #define KERNEL_START  _stext
    

vim +/KERNEL_START +83 drivers/mtd/devices/lart.c

^1da177e Linus Torvalds 2005-04-16  67  
^1da177e Linus Torvalds 2005-04-16  68  /*
^1da177e Linus Torvalds 2005-04-16  69   * These values are specific to LART
^1da177e Linus Torvalds 2005-04-16  70   */
^1da177e Linus Torvalds 2005-04-16  71  
^1da177e Linus Torvalds 2005-04-16  72  /* general */
^1da177e Linus Torvalds 2005-04-16  73  #define BUSWIDTH			4				/* don't change this - a lot of the code _will_ break if you change this */
^1da177e Linus Torvalds 2005-04-16  74  #define FLASH_OFFSET		0xe8000000		/* see linux/arch/arm/mach-sa1100/lart.c */
^1da177e Linus Torvalds 2005-04-16  75  
^1da177e Linus Torvalds 2005-04-16  76  /* blob */
^1da177e Linus Torvalds 2005-04-16  77  #define NUM_BLOB_BLOCKS		FLASH_NUMBLOCKS_16m_PARAM
^1da177e Linus Torvalds 2005-04-16  78  #define BLOB_START			0x00000000
^1da177e Linus Torvalds 2005-04-16  79  #define BLOB_LEN			(NUM_BLOB_BLOCKS * FLASH_BLOCKSIZE_PARAM)
^1da177e Linus Torvalds 2005-04-16  80  
^1da177e Linus Torvalds 2005-04-16  81  /* kernel */
^1da177e Linus Torvalds 2005-04-16  82  #define NUM_KERNEL_BLOCKS	7
^1da177e Linus Torvalds 2005-04-16 @83  #define KERNEL_START		(BLOB_START + BLOB_LEN)
^1da177e Linus Torvalds 2005-04-16  84  #define KERNEL_LEN			(NUM_KERNEL_BLOCKS * FLASH_BLOCKSIZE_MAIN)
^1da177e Linus Torvalds 2005-04-16  85  
^1da177e Linus Torvalds 2005-04-16  86  /* initial ramdisk */
^1da177e Linus Torvalds 2005-04-16  87  #define NUM_INITRD_BLOCKS	24
^1da177e Linus Torvalds 2005-04-16  88  #define INITRD_START		(KERNEL_START + KERNEL_LEN)
^1da177e Linus Torvalds 2005-04-16  89  #define INITRD_LEN			(NUM_INITRD_BLOCKS * FLASH_BLOCKSIZE_MAIN)
^1da177e Linus Torvalds 2005-04-16  90  
^1da177e Linus Torvalds 2005-04-16  91  /*

:::::: The code at line 83 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

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

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | linux.kernel


csiph-web