[PATCH 4/6] powerpc/vas: Fix __pa() handling in init_winctx_regs()

Michael Ellerman mpe at ellerman.id.au
Thu Apr 7 00:58:00 AEST 2022


In init_winctx_regs() we call __pa() on winctx->rx_fifo, but some
callers pass a real adress which causes errors with DEBUG_VIRTUAL
enabled.

So check first if we have a virtual address, and otherwise leave the
address unchanged.

Signed-off-by: Michael Ellerman <mpe at ellerman.id.au>
---
 arch/powerpc/platforms/powernv/vas-window.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c
index 0f8d39fbf2b2..25324390e292 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -404,7 +404,13 @@ static void init_winctx_regs(struct pnv_vas_window *window,
 	 *
 	 * See also: Design note in function header.
 	 */
-	val = __pa(winctx->rx_fifo);
+
+	// Some callers pass virtual addresses, others pass real
+	if (virt_addr_valid(winctx->rx_fifo))
+		val = virt_to_phys(winctx->rx_fifo);
+	else
+		val = (u64)winctx->rx_fifo;
+
 	val = SET_FIELD(VAS_PAGE_MIGRATION_SELECT, val, 0);
 	write_hvwc_reg(window, VREG(LFIFO_BAR), val);
 
-- 
2.34.1



More information about the Linuxppc-dev mailing list