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


Groups > linux.kernel > #1537431

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

From Florian Fainelli <f.fainelli@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH 3/3] ARM: Add support for CONFIG_DEBUG_VIRTUAL
Date 2016-12-07 03:30 +0100
Message-ID <sLA9A-1Ws-13@gated-at.bofh.it> (permalink)
References <sIVNf-3Mq-3@gated-at.bofh.it> <sLu49-6lz-1@gated-at.bofh.it> <sLu49-6lz-3@gated-at.bofh.it> <sLzQe-1LR-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[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

csiph-web