All of lore.kernel.org
 help / color / mirror / Atom feed
From: Serge Semin <fancer.lancer@gmail.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-mips@vger.kernel.org, gerg@kernel.org,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] MIPS: Fixed __debug_virt_addr_valid()
Date: Fri, 8 Jul 2022 14:58:51 +0300	[thread overview]
Message-ID: <20220708115851.ejsooiilxcopkoei@mobilestation> (raw)
In-Reply-To: <20220707215237.1730283-1-f.fainelli@gmail.com>

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@gmail.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.

-Sergey

>  }
>  
>  phys_addr_t __virt_to_phys(volatile const void *x)
> -- 
> 2.25.1
> 

  reply	other threads:[~2022-07-08 11:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07 21:52 [PATCH] MIPS: Fixed __debug_virt_addr_valid() Florian Fainelli
2022-07-08 11:58 ` Serge Semin [this message]
2022-07-12 16:28   ` Florian Fainelli
2022-07-13  7:01     ` Serge Semin
2022-07-11  8:38 ` Thomas Bogendoerfer
2022-07-11 10:40   ` Serge Semin
2022-07-11 11:27     ` Thomas Bogendoerfer
2022-07-11 11:29       ` Serge Semin
2022-07-12  0:02         ` Florian Fainelli
2022-07-12  7:30           ` Thomas Bogendoerfer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220708115851.ejsooiilxcopkoei@mobilestation \
    --to=fancer.lancer@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=gerg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.