All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: Fixed __debug_virt_addr_valid()
@ 2022-07-07 21:52 Florian Fainelli
  2022-07-08 11:58 ` Serge Semin
  2022-07-11  8:38 ` Thomas Bogendoerfer
  0 siblings, 2 replies; 10+ messages in thread
From: Florian Fainelli @ 2022-07-07 21:52 UTC (permalink / raw)
  To: linux-mips
  Cc: gerg, fancer.lancer, Florian Fainelli, Thomas Bogendoerfer, open list

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;
 }
 
 phys_addr_t __virt_to_phys(volatile const void *x)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-07-13  7:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 21:52 [PATCH] MIPS: Fixed __debug_virt_addr_valid() Florian Fainelli
2022-07-08 11:58 ` Serge Semin
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

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.