mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Magnus Lindholm <linmag7@gmail.com>
Cc: davem@davemloft.net, andreas@gaisler.com,
	sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] sparc32: honour phys_base in the viking cache flush routines
Date: Fri, 14 Aug 2026 22:43:56 +0200	[thread overview]
Message-ID: <20260814204356.GA534878@ravnborg.org> (raw)
In-Reply-To: <20260814105723.3454511-2-linmag7@gmail.com>

Hi Magnus.

On Fri, Aug 14, 2026 at 12:52:32PM +0200, Magnus Lindholm wrote:
> viking_flush_page() and viking_mxcc_flush_page() derive the physical
> address of the page they are asked to flush by subtracting PAGE_OFFSET
> from the kernel virtual address:
> 
> 	sethi	%hi(PAGE_OFFSET), %g2
> 	sub	%o0, %g2, %g3
> 
> That is only the physical address when phys_base is zero. The C side spells
> the same conversion __pa(), which adds phys_base, and every caller passes a
> kernel virtual address expecting exactly that.
> 
> With a kernel loaded away from the start of RAM the two disagree by
> phys_base. viking_flush_page() then compares cache tags against the wrong
> page and flushes nothing, and viking_mxcc_flush_page() streams a page that
> is phys_base lower than the one it was given, so the intended lines stay
> dirty in the cache while unrelated ones are pushed out.
> 
> The visible effect is that anything relying on a flush to make memory
> visible to another bus master silently keeps working from stale data. On a
> SPARCstation 20 this shows up as every SCSI transfer failing with a DMA
> error: iommu_flush_iotlb() cannot get the IOPTEs out to RAM, so the IOMMU
> walks stale entries and the ESP DMA faults.
> 
> Add phys_base, so these agree with __pa() again. No change when phys_base
> is zero, which is why this went unnoticed.
> 
> Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
Looks good, I checked and as the other variants are coherent this
should be the only place we need this.

Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

  reply	other threads:[~2026-08-14 20:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 10:52 [PATCH 0/3] sparc32: allow a kernel loaded away from the start of RAM Magnus Lindholm
2026-08-14 10:52 ` [PATCH 1/3] sparc32: honour phys_base in the viking cache flush routines Magnus Lindholm
2026-08-14 20:43   ` Sam Ravnborg [this message]
2026-08-14 10:52 ` [PATCH 2/3] sparc32: derive phys_base from the PAGE_OFFSET mapping Magnus Lindholm
2026-08-14 20:46   ` Sam Ravnborg
2026-08-14 21:58     ` Magnus Lindholm
2026-08-14 10:52 ` [PATCH 3/3] sparc32: advertise relocatable kernel with HdrS 0x0300 Magnus Lindholm
2026-08-14 20:48   ` Sam Ravnborg
2026-08-14 11:25 ` [PATCH 0/3] sparc32: allow a kernel loaded away from the start of RAM John Paul Adrian Glaubitz
2026-08-14 14:18   ` Magnus Lindholm
2026-08-14 20:53 ` Sam Ravnborg
2026-08-14 22:05   ` Magnus Lindholm

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=20260814204356.GA534878@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=andreas@gaisler.com \
    --cc=davem@davemloft.net \
    --cc=linmag7@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparclinux@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®