[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a6d8fc0f-38bd-6afe-ef45-42ce3ee6c136@gmail.com>
Date: Tue, 12 Jul 2022 09:28:02 -0700
From: Florian Fainelli <f.fainelli@...il.com>
To: Serge Semin <fancer.lancer@...il.com>
Cc: linux-mips@...r.kernel.org, gerg@...nel.org,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] MIPS: Fixed __debug_virt_addr_valid()
On 7/8/22 04:58, Serge Semin wrote:
> On Thu, Jul 07, 2022 at 02:52:36PM -0700, Florian Fainelli wrote:
>> It is permissible for kernel code to call virt_to_phys() against virtual
>> addresses that are in KSEG0 or KSEG1 and we need to be dealing with both
>> types. Add a final condition that ensures that the virtual address is
>> below KSEG2.
>>
>> Fixes: dfad83cb7193 ("MIPS: Add support for CONFIG_DEBUG_VIRTUAL")
>> Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
>> ---
>> arch/mips/mm/physaddr.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/mips/mm/physaddr.c b/arch/mips/mm/physaddr.c
>> index a1ced5e44951..a82f8f57a652 100644
>> --- a/arch/mips/mm/physaddr.c
>> +++ b/arch/mips/mm/physaddr.c
>> @@ -5,6 +5,7 @@
>> #include <linux/mmdebug.h>
>> #include <linux/mm.h>
>>
>> +#include <asm/addrspace.h>
>> #include <asm/sections.h>
>> #include <asm/io.h>
>> #include <asm/page.h>
>> @@ -30,7 +31,7 @@ static inline bool __debug_virt_addr_valid(unsigned long x)
>> if (x == MAX_DMA_ADDRESS)
>> return true;
>>
>
>> - return false;
>> + return KSEGX(x) < KSEG2;
>
> With this do we really need the high_memory-based conditionals in this
> method?
>
> If the line above is the only way to take the uncached segment into
> account then can we reduce the whole method to:
> static inline bool __debug_virt_addr_valid {
> return x >= PAGE_OFFSET && KSEGX(x) < KSEG2;
> }
> ?
>
> Though this still may be invalid for EVA systems, like malta (see
> arch/mips/include/asm/mach-malta/spaces.h).
>
> Note AFAICS if EVA is enabled, highmem is implied to be disabled (see
> the CPU_MIPS32_3_5_EVA config utilization and HIGHMEM config
> dependencies). Thus all the memory is supposed to be linearly mapped
> in that case.
OK, so if all of the memory is linearly mapped, then I am not too sure
what we will be able to check, which is in essence pretty similar to
what happens on MIPS64, right?
Maybe DEBUG_VIRTUAL should depend on !EVA as well?
--
Florian
Powered by blists - more mailing lists