From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965403AbcKLBtT (ORCPT ); Fri, 11 Nov 2016 20:49:19 -0500 Received: from mail-qt0-f181.google.com ([209.85.216.181]:36037 "EHLO mail-qt0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936373AbcKLBtQ (ORCPT ); Fri, 11 Nov 2016 20:49:16 -0500 Date: Fri, 11 Nov 2016 20:49:13 -0500 (EST) From: Nicolas Pitre To: Florian Fainelli cc: linux-kernel@vger.kernel.org, Russell King , Catalin Marinas , Will Deacon , Arnd Bergmann , Chris Brandt , Pratyush Anand , Ard Biesheuvel , Mark Rutland , James Morse , Neeraj Upadhyay , Laura Abbott , Andrew Morton , Vlastimil Babka , Michal Hocko , "Kirill A. Shutemov" , Jerome Marchand , Konstantin Khlebnikov , Joonsoo Kim , "moderated list:ARM PORT" , "open list:GENERIC INCLUDE/ASM HEADER FILES" , "open list:MEMORY MANAGEMENT" Subject: Re: [PATCH RFC] mm: Add debug_virt_to_phys() In-Reply-To: <20161112004449.30566-1-f.fainelli@gmail.com> Message-ID: References: <20161112004449.30566-1-f.fainelli@gmail.com> User-Agent: Alpine 2.20 (LFD 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 11 Nov 2016, Florian Fainelli wrote: > When CONFIG_DEBUG_VM is turned on, virt_to_phys() maps to > debug_virt_to_phys() which helps catch vmalloc space addresses being > passed. This is helpful in debugging bogus drivers that just assume > linear mappings all over the place. > > For ARM, ARM64, Unicore32 and Microblaze, the architectures define > __virt_to_phys() as being the functional implementation of the address > translation, so we special case the debug stub to call into > __virt_to_phys directly. > > Signed-off-by: Florian Fainelli > --- > arch/arm/include/asm/memory.h | 4 ++++ > arch/arm64/include/asm/memory.h | 4 ++++ > include/asm-generic/memory_model.h | 4 ++++ > mm/debug.c | 15 +++++++++++++++ > 4 files changed, 27 insertions(+) > > diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h > index 76cbd9c674df..448dec9b8b00 100644 > --- a/arch/arm/include/asm/memory.h > +++ b/arch/arm/include/asm/memory.h > @@ -260,11 +260,15 @@ static inline unsigned long __phys_to_virt(phys_addr_t x) > * translation for translating DMA addresses. Use the driver > * DMA support - see dma-mapping.h. > */ > +#ifndef CONFIG_DEBUG_VM > #define virt_to_phys virt_to_phys > static inline phys_addr_t virt_to_phys(const volatile void *x) > { > return __virt_to_phys((unsigned long)(x)); > } > +#else > +#define virt_to_phys debug_virt_to_phys > +#endif [...] Why don't you do something more like: static inline phys_addr_t virt_to_phys(const volatile void *x) { + debug_virt_to_phys(x); return __virt_to_phys((unsigned long)(x)); } [...] static inline void debug_virt_to_phys(const void *address) { #ifdef CONFIG_DEBUG_VM BUG_ON(is_vmalloc_addr(address)); #endif } ? Nicolas From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Pitre Subject: Re: [PATCH RFC] mm: Add debug_virt_to_phys() Date: Fri, 11 Nov 2016 20:49:13 -0500 (EST) Message-ID: References: <20161112004449.30566-1-f.fainelli@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <20161112004449.30566-1-f.fainelli@gmail.com> Sender: owner-linux-mm@kvack.org To: Florian Fainelli Cc: linux-kernel@vger.kernel.org, Russell King , Catalin Marinas , Will Deacon , Arnd Bergmann , Chris Brandt , Pratyush Anand , Ard Biesheuvel , Mark Rutland , James Morse , Neeraj Upadhyay , Laura Abbott , Andrew Morton , Vlastimil Babka , Michal Hocko , "Kirill A. Shutemov" , Jerome Marchand , Konstantin Khlebnikov , Joonsoo Kim , "moderated list:ARM PORT" , open list:GENERIC List-Id: linux-arch.vger.kernel.org On Fri, 11 Nov 2016, Florian Fainelli wrote: > When CONFIG_DEBUG_VM is turned on, virt_to_phys() maps to > debug_virt_to_phys() which helps catch vmalloc space addresses being > passed. This is helpful in debugging bogus drivers that just assume > linear mappings all over the place. > > For ARM, ARM64, Unicore32 and Microblaze, the architectures define > __virt_to_phys() as being the functional implementation of the address > translation, so we special case the debug stub to call into > __virt_to_phys directly. > > Signed-off-by: Florian Fainelli > --- > arch/arm/include/asm/memory.h | 4 ++++ > arch/arm64/include/asm/memory.h | 4 ++++ > include/asm-generic/memory_model.h | 4 ++++ > mm/debug.c | 15 +++++++++++++++ > 4 files changed, 27 insertions(+) > > diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h > index 76cbd9c674df..448dec9b8b00 100644 > --- a/arch/arm/include/asm/memory.h > +++ b/arch/arm/include/asm/memory.h > @@ -260,11 +260,15 @@ static inline unsigned long __phys_to_virt(phys_addr_t x) > * translation for translating DMA addresses. Use the driver > * DMA support - see dma-mapping.h. > */ > +#ifndef CONFIG_DEBUG_VM > #define virt_to_phys virt_to_phys > static inline phys_addr_t virt_to_phys(const volatile void *x) > { > return __virt_to_phys((unsigned long)(x)); > } > +#else > +#define virt_to_phys debug_virt_to_phys > +#endif [...] Why don't you do something more like: static inline phys_addr_t virt_to_phys(const volatile void *x) { + debug_virt_to_phys(x); return __virt_to_phys((unsigned long)(x)); } [...] static inline void debug_virt_to_phys(const void *address) { #ifdef CONFIG_DEBUG_VM BUG_ON(is_vmalloc_addr(address)); #endif } ? Nicolas -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt0-f171.google.com ([209.85.216.171]:34756 "EHLO mail-qt0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934854AbcKLBtQ (ORCPT ); Fri, 11 Nov 2016 20:49:16 -0500 Received: by mail-qt0-f171.google.com with SMTP id n6so19877529qtd.1 for ; Fri, 11 Nov 2016 17:49:16 -0800 (PST) Date: Fri, 11 Nov 2016 20:49:13 -0500 (EST) From: Nicolas Pitre Subject: Re: [PATCH RFC] mm: Add debug_virt_to_phys() In-Reply-To: <20161112004449.30566-1-f.fainelli@gmail.com> Message-ID: References: <20161112004449.30566-1-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-arch-owner@vger.kernel.org List-ID: To: Florian Fainelli Cc: linux-kernel@vger.kernel.org, Russell King , Catalin Marinas , Will Deacon , Arnd Bergmann , Chris Brandt , Pratyush Anand , Ard Biesheuvel , Mark Rutland , James Morse , Neeraj Upadhyay , Laura Abbott , Andrew Morton , Vlastimil Babka , Michal Hocko , "Kirill A. Shutemov" , Jerome Marchand , Konstantin Khlebnikov , Joonsoo Kim , "moderated list:ARM PORT" , "open list:GENERIC INCLUDE/ASM HEADER FILES" , "open list:MEMORY MANAGEMENT" Message-ID: <20161112014913.1viBvhg6QZWgpWK6JcklWfc-OPBlUbSUc2GdeI1aS_0@z> On Fri, 11 Nov 2016, Florian Fainelli wrote: > When CONFIG_DEBUG_VM is turned on, virt_to_phys() maps to > debug_virt_to_phys() which helps catch vmalloc space addresses being > passed. This is helpful in debugging bogus drivers that just assume > linear mappings all over the place. > > For ARM, ARM64, Unicore32 and Microblaze, the architectures define > __virt_to_phys() as being the functional implementation of the address > translation, so we special case the debug stub to call into > __virt_to_phys directly. > > Signed-off-by: Florian Fainelli > --- > arch/arm/include/asm/memory.h | 4 ++++ > arch/arm64/include/asm/memory.h | 4 ++++ > include/asm-generic/memory_model.h | 4 ++++ > mm/debug.c | 15 +++++++++++++++ > 4 files changed, 27 insertions(+) > > diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h > index 76cbd9c674df..448dec9b8b00 100644 > --- a/arch/arm/include/asm/memory.h > +++ b/arch/arm/include/asm/memory.h > @@ -260,11 +260,15 @@ static inline unsigned long __phys_to_virt(phys_addr_t x) > * translation for translating DMA addresses. Use the driver > * DMA support - see dma-mapping.h. > */ > +#ifndef CONFIG_DEBUG_VM > #define virt_to_phys virt_to_phys > static inline phys_addr_t virt_to_phys(const volatile void *x) > { > return __virt_to_phys((unsigned long)(x)); > } > +#else > +#define virt_to_phys debug_virt_to_phys > +#endif [...] Why don't you do something more like: static inline phys_addr_t virt_to_phys(const volatile void *x) { + debug_virt_to_phys(x); return __virt_to_phys((unsigned long)(x)); } [...] static inline void debug_virt_to_phys(const void *address) { #ifdef CONFIG_DEBUG_VM BUG_ON(is_vmalloc_addr(address)); #endif } ? Nicolas From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by kanga.kvack.org (Postfix) with ESMTP id 8D74A280282 for ; Fri, 11 Nov 2016 20:49:16 -0500 (EST) Received: by mail-qk0-f199.google.com with SMTP id y205so30409526qkb.4 for ; Fri, 11 Nov 2016 17:49:16 -0800 (PST) Received: from mail-qt0-x234.google.com (mail-qt0-x234.google.com. [2607:f8b0:400d:c0d::234]) by mx.google.com with ESMTPS id c14si7851414qtc.42.2016.11.11.17.49.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Nov 2016 17:49:15 -0800 (PST) Received: by mail-qt0-x234.google.com with SMTP id p16so19841290qta.0 for ; Fri, 11 Nov 2016 17:49:15 -0800 (PST) Date: Fri, 11 Nov 2016 20:49:13 -0500 (EST) From: Nicolas Pitre Subject: Re: [PATCH RFC] mm: Add debug_virt_to_phys() In-Reply-To: <20161112004449.30566-1-f.fainelli@gmail.com> Message-ID: References: <20161112004449.30566-1-f.fainelli@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: owner-linux-mm@kvack.org List-ID: To: Florian Fainelli Cc: linux-kernel@vger.kernel.org, Russell King , Catalin Marinas , Will Deacon , Arnd Bergmann , Chris Brandt , Pratyush Anand , Ard Biesheuvel , Mark Rutland , James Morse , Neeraj Upadhyay , Laura Abbott , Andrew Morton , Vlastimil Babka , Michal Hocko , "Kirill A. Shutemov" , Jerome Marchand , Konstantin Khlebnikov , Joonsoo Kim , "moderated list:ARM PORT" , "open list:GENERIC INCLUDE/ASM HEADER FILES" , "open list:MEMORY MANAGEMENT" On Fri, 11 Nov 2016, Florian Fainelli wrote: > When CONFIG_DEBUG_VM is turned on, virt_to_phys() maps to > debug_virt_to_phys() which helps catch vmalloc space addresses being > passed. This is helpful in debugging bogus drivers that just assume > linear mappings all over the place. > > For ARM, ARM64, Unicore32 and Microblaze, the architectures define > __virt_to_phys() as being the functional implementation of the address > translation, so we special case the debug stub to call into > __virt_to_phys directly. > > Signed-off-by: Florian Fainelli > --- > arch/arm/include/asm/memory.h | 4 ++++ > arch/arm64/include/asm/memory.h | 4 ++++ > include/asm-generic/memory_model.h | 4 ++++ > mm/debug.c | 15 +++++++++++++++ > 4 files changed, 27 insertions(+) > > diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h > index 76cbd9c674df..448dec9b8b00 100644 > --- a/arch/arm/include/asm/memory.h > +++ b/arch/arm/include/asm/memory.h > @@ -260,11 +260,15 @@ static inline unsigned long __phys_to_virt(phys_addr_t x) > * translation for translating DMA addresses. Use the driver > * DMA support - see dma-mapping.h. > */ > +#ifndef CONFIG_DEBUG_VM > #define virt_to_phys virt_to_phys > static inline phys_addr_t virt_to_phys(const volatile void *x) > { > return __virt_to_phys((unsigned long)(x)); > } > +#else > +#define virt_to_phys debug_virt_to_phys > +#endif [...] Why don't you do something more like: static inline phys_addr_t virt_to_phys(const volatile void *x) { + debug_virt_to_phys(x); return __virt_to_phys((unsigned long)(x)); } [...] static inline void debug_virt_to_phys(const void *address) { #ifdef CONFIG_DEBUG_VM BUG_ON(is_vmalloc_addr(address)); #endif } ? Nicolas -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: nicolas.pitre@linaro.org (Nicolas Pitre) Date: Fri, 11 Nov 2016 20:49:13 -0500 (EST) Subject: [PATCH RFC] mm: Add debug_virt_to_phys() In-Reply-To: <20161112004449.30566-1-f.fainelli@gmail.com> References: <20161112004449.30566-1-f.fainelli@gmail.com> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Fri, 11 Nov 2016, Florian Fainelli wrote: > When CONFIG_DEBUG_VM is turned on, virt_to_phys() maps to > debug_virt_to_phys() which helps catch vmalloc space addresses being > passed. This is helpful in debugging bogus drivers that just assume > linear mappings all over the place. > > For ARM, ARM64, Unicore32 and Microblaze, the architectures define > __virt_to_phys() as being the functional implementation of the address > translation, so we special case the debug stub to call into > __virt_to_phys directly. > > Signed-off-by: Florian Fainelli > --- > arch/arm/include/asm/memory.h | 4 ++++ > arch/arm64/include/asm/memory.h | 4 ++++ > include/asm-generic/memory_model.h | 4 ++++ > mm/debug.c | 15 +++++++++++++++ > 4 files changed, 27 insertions(+) > > diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h > index 76cbd9c674df..448dec9b8b00 100644 > --- a/arch/arm/include/asm/memory.h > +++ b/arch/arm/include/asm/memory.h > @@ -260,11 +260,15 @@ static inline unsigned long __phys_to_virt(phys_addr_t x) > * translation for translating DMA addresses. Use the driver > * DMA support - see dma-mapping.h. > */ > +#ifndef CONFIG_DEBUG_VM > #define virt_to_phys virt_to_phys > static inline phys_addr_t virt_to_phys(const volatile void *x) > { > return __virt_to_phys((unsigned long)(x)); > } > +#else > +#define virt_to_phys debug_virt_to_phys > +#endif [...] Why don't you do something more like: static inline phys_addr_t virt_to_phys(const volatile void *x) { + debug_virt_to_phys(x); return __virt_to_phys((unsigned long)(x)); } [...] static inline void debug_virt_to_phys(const void *address) { #ifdef CONFIG_DEBUG_VM BUG_ON(is_vmalloc_addr(address)); #endif } ? Nicolas