Message ID | 1455209282-9596-4-git-send-email-ard.biesheuvel@linaro.org |
---|---|
State | New |
Headers | show |
On Thu, Feb 11, 2016 at 05:48:02PM +0100, Ard Biesheuvel wrote: > Just a hack to check whether all early __va() calls are gone. > --- > arch/arm64/include/asm/memory.h | 10 +++++++++- > arch/arm64/mm/init.c | 2 +- > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > index 083361531a61..0d4d1b3b9695 100644 > --- a/arch/arm64/include/asm/memory.h > +++ b/arch/arm64/include/asm/memory.h > @@ -90,7 +90,9 @@ > __x >= PAGE_OFFSET ? (__x - PAGE_OFFSET + PHYS_OFFSET) : \ > (__x - kimage_voffset); }) > > -#define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET + PAGE_OFFSET)) > +#define __phys_to_virt(x) ({ \ > + assert_memstart_addr_assigned(); \ > + (unsigned long)((x) - PHYS_OFFSET + PAGE_OFFSET); }) > #define __phys_to_kimg(x) ((unsigned long)((x) + kimage_voffset)) > > /* > @@ -133,6 +135,12 @@ extern u64 kimage_vaddr; > /* the offset between the kernel virtual and physical mappings */ > extern u64 kimage_voffset; > > +static inline void assert_memstart_addr_assigned(void) > +{ > + if (unlikely(memstart_addr == (phys_addr_t)-1)) > + asm("brk #%0" :: "I"(0x800)); Ok, I'll bite! Why isn't this just a BUG_ON? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On 12 February 2016 at 12:49, Will Deacon <will.deacon@arm.com> wrote: > On Thu, Feb 11, 2016 at 05:48:02PM +0100, Ard Biesheuvel wrote: >> Just a hack to check whether all early __va() calls are gone. >> --- >> arch/arm64/include/asm/memory.h | 10 +++++++++- >> arch/arm64/mm/init.c | 2 +- >> 2 files changed, 10 insertions(+), 2 deletions(-) >> >> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h >> index 083361531a61..0d4d1b3b9695 100644 >> --- a/arch/arm64/include/asm/memory.h >> +++ b/arch/arm64/include/asm/memory.h >> @@ -90,7 +90,9 @@ >> __x >= PAGE_OFFSET ? (__x - PAGE_OFFSET + PHYS_OFFSET) : \ >> (__x - kimage_voffset); }) >> >> -#define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET + PAGE_OFFSET)) >> +#define __phys_to_virt(x) ({ \ >> + assert_memstart_addr_assigned(); \ >> + (unsigned long)((x) - PHYS_OFFSET + PAGE_OFFSET); }) >> #define __phys_to_kimg(x) ((unsigned long)((x) + kimage_voffset)) >> >> /* >> @@ -133,6 +135,12 @@ extern u64 kimage_vaddr; >> /* the offset between the kernel virtual and physical mappings */ >> extern u64 kimage_voffset; >> >> +static inline void assert_memstart_addr_assigned(void) >> +{ >> + if (unlikely(memstart_addr == (phys_addr_t)-1)) >> + asm("brk #%0" :: "I"(0x800)); > > Ok, I'll bite! Why isn't this just a BUG_ON? > Because circular header dependencies prevent BUG_ON() from being used here, and I was reluctant to move this function into a .c file. Note that I am not necessarily suggesting that this patch be merged, but I included it since it's the code I used to confirm that no other early instance of __va() remain. I can try and clean it up if we want to keep it. -- Ard. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Friday 12 February 2016 12:51:40 Ard Biesheuvel wrote: > >> @@ -133,6 +135,12 @@ extern u64 kimage_vaddr; > >> /* the offset between the kernel virtual and physical mappings */ > >> extern u64 kimage_voffset; > >> > >> +static inline void assert_memstart_addr_assigned(void) > >> +{ > >> + if (unlikely(memstart_addr == (phys_addr_t)-1)) > >> + asm("brk #%0" :: "I"(0x800)); > > > > Ok, I'll bite! Why isn't this just a BUG_ON? > > > > Because circular header dependencies prevent BUG_ON() from being used > here, and I was reluctant to move this function into a .c file. Maybe it works if you make assert_memstart_addr_assigned() a macro as well? Arnd _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 083361531a61..0d4d1b3b9695 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -90,7 +90,9 @@ __x >= PAGE_OFFSET ? (__x - PAGE_OFFSET + PHYS_OFFSET) : \ (__x - kimage_voffset); }) -#define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET + PAGE_OFFSET)) +#define __phys_to_virt(x) ({ \ + assert_memstart_addr_assigned(); \ + (unsigned long)((x) - PHYS_OFFSET + PAGE_OFFSET); }) #define __phys_to_kimg(x) ((unsigned long)((x) + kimage_voffset)) /* @@ -133,6 +135,12 @@ extern u64 kimage_vaddr; /* the offset between the kernel virtual and physical mappings */ extern u64 kimage_voffset; +static inline void assert_memstart_addr_assigned(void) +{ + if (unlikely(memstart_addr == (phys_addr_t)-1)) + asm("brk #%0" :: "I"(0x800)); +} + /* * Allow all memory at the discovery stage. We will clip it later. */ diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index eff4751f8761..e88db8acd181 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -48,7 +48,7 @@ #include "mm.h" -phys_addr_t memstart_addr __read_mostly = 0; +phys_addr_t memstart_addr __read_mostly = (phys_addr_t)-1; phys_addr_t arm64_dma_phys_limit __read_mostly; #ifdef CONFIG_BLK_DEV_INITRD