All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek via U-Boot <u-boot@lists.u-boot-project.org>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Akshay Belsare <akshay.belsare@amd.com>,
	Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de, git@amd.com, padmarao.begari@amd.com,
	Tom Rini <trini@konsulko.com>, Anshul Dalal <anshuld@ti.com>,
	Casey Connolly <casey.connolly@linaro.org>,
	Dhruva Gole <d-gole@ti.com>, Simon Glass <sjg@chromium.org>,
	Mark Kettenis <kettenis@openbsd.org>,
	u-boot@lists.u-boot-project.org
Subject: Re: [PATCH] arm: armv8: mmu: fix DCACHE_OFF incorrectly unmapping region
Date: Tue, 21 Jul 2026 11:17:09 +0200	[thread overview]
Message-ID: <446e84b5-652f-4573-bea9-ea6488c47fb0@amd.com> (raw)
In-Reply-To: <CAC_iWjKDy8ziyMkuHwhg=-VGZ7C5HMYXFQG+ZjATXqwEDjvipQ@mail.gmail.com>

Hi Tom,

On 7/8/26 13:47, Ilias Apalodimas wrote:
> Hi Akshay
> 
> On Wed, 8 Jul 2026 at 14:17, Akshay Belsare <akshay.belsare@amd.com> wrote:
>>
>> DCACHE_OFF is defined as (0 << 2) = 0, and PTE_TYPE_FAULT is defined
>> as (0 << 0) = 0. In mmu_set_region_dcache_behaviour(), the cache
>> attribute passed to set_regions() is computed as:
>>    attrs = PMD_ATTRINDX(option >> 2)
>> For DCACHE_OFF=0 this evaluates to PMD_ATTRINDX(0) = 0, which equals
>> PTE_TYPE_FAULT.
>>
>> Commit 6468ca13ffd6f ("armv8: mmu: fix and optimise explicitly unmapping
>> regions") added an unmap path to set_one_region() that
>> triggers when attrs == PTE_TYPE_FAULT. Because DCACHE_OFF and
>> PTE_TYPE_FAULT share the same numerical value (0), any call to
>> mmu_set_region_dcache_behaviour() with DCACHE_OFF silently unmaps the
>> target region instead of changing its cache attributes to non-cached.
>>
>> The subsequent flush_dcache_range() call at the end of
>> mmu_set_region_dcache_behaviour() then crashes with a Level 3
>> translation fault because the region it tries to flush has just been
>> unmapped.
>>
>> The existing flag parameter already distinguishes the two callers:
>>   - mmu_set_region_dcache_behaviour() always passes flag=false
>>   - mmu_change_region_attr_nobreak() always passes flag=true, and is the
>>     only legitimate caller that passes PTE_TYPE_FAULT to unmap a region
>>
>> Guard the unmap path with flag so that DCACHE_OFF attribute changes
>> take the correct else branch, which ORs in the ATTRINDX bits only,
>> leaving the PTE valid.
> 
> I don't really love the 'flag' attribute that distinguishes between
> preserving or overwriting the permission bits...
> 
> However, this does fix an issue.
> 
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Can you please cherry pick this patch?

Thanks,
Michal

  reply	other threads:[~2026-07-21  9:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 11:17 [PATCH] arm: armv8: mmu: fix DCACHE_OFF incorrectly unmapping region Akshay Belsare
2026-07-08 11:47 ` Ilias Apalodimas
2026-07-21  9:17   ` Michal Simek via U-Boot [this message]
2026-07-24  1:02 ` Tom Rini

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=446e84b5-652f-4573-bea9-ea6488c47fb0@amd.com \
    --to=u-boot@lists.u-boot-project.org \
    --cc=akshay.belsare@amd.com \
    --cc=anshuld@ti.com \
    --cc=casey.connolly@linaro.org \
    --cc=d-gole@ti.com \
    --cc=git@amd.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kettenis@openbsd.org \
    --cc=michal.simek@amd.com \
    --cc=padmarao.begari@amd.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.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.