From: santosh.shilimkar@oracle.com (santosh shilimkar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/6] ARM: re-implement physical address space switching
Date: Mon, 13 Apr 2015 12:11:44 -0700 [thread overview]
Message-ID: <552C14F0.7020006@oracle.com> (raw)
In-Reply-To: <20150408175533.GN12732@n2100.arm.linux.org.uk>
On 4/8/2015 10:55 AM, Russell King - ARM Linux wrote:
> On Wed, Apr 08, 2015 at 06:36:56PM +0100, Mark Rutland wrote:
>> Hi Russell,
>>
>> On Wed, Apr 08, 2015 at 10:45:30AM +0100, Russell King wrote:
>>> - /*
>>> - * Ensure that the above updates are flushed out of the cache.
>>> - * This is not strictly correct; on a system where the caches
>>> - * are coherent with each other, but the MMU page table walks
>>> - * may not be coherent, flush_cache_all() may be a no-op, and
>>> - * this will fail.
>>> + * We changing not only the virtual to physical mapping, but
>>> + * also the physical addresses used to access memory. We need
>>> + * to flush all levels of cache in the system with caching
>>> + * disabled to ensure that all data is written back. We do this
>>> + * with caching and write buffering disabled to ensure that
>>> + * nothing is speculatively prefetched.
>>> */
>>> + cr = get_cr();
>>> + set_cr(cr & ~(CR_I | CR_C | CR_W));
>>
>> SCTLR[3] (CR_W) is RAO/SBOP in VMSAv7. I don't think we should clear it
>> here for ARMv7.
>
> I was in two minds about that - I guess as we're expecting to only run
> this on ARMv7 CPUs, we can omit clearing the CR_W, but I'd need to add
> a comment saying that it's ARMv7 only.
>
Yep. We can do away without the CR_W change.
>> To the best of my knowledge, the page table walkers aren't affected by
>> SCTLR.C, and use the attributes in TTBR{0,1} or TTBCR when translation
>> is active (i.e. when SCTLR.M is set). So at this point they can make
>> cacheable accesses to the page tables (and allocate into the caches) in
>> the background...
>
> We had better clear those bits too then.
>
>> I think that the cache flush needs to be performed after both
>> SCTLR.{C,M} are cleared in lpae_pgtables_remap_asm, just before the page
>> table updates. So long as the relevant pieces of kernel text are
>> initially clean to the PoC, we shouldn't need to flush anything
>> beforehand.
>
> To that I say... no bloody way in hell, even once hell has frozen
> over. It took almost a _day_ to get this much working, much of it
> was attempting to use cache flushing functions after the MMU had
> been turned off.
>
> If it was possible to make it work, I'd have done so. It isn't, so
> please forget the idea.
>
I fully agree. I gone through the same pane while incorporating Will's
comment on similar lines last time.
>>> +ENTRY(lpae_pgtables_remap_asm)
>>> + stmfd sp!, {r4-r8, lr}
>>> +
>>> + mrc p15, 0, r8, c1, c0, 0 @ read control reg
>>> + bic ip, r8, #CR_M @ disable caches and MMU
>>> + mcr p15, 0, ip, c1, c0, 0
>>> + dsb
>>> + isb
>>
>> Shouldn't the DSB be between the STMFD and the MCR (given the SP doesn't
>> point to an idmap/physical address)?
>>
>> I don't see why we need a DSB after the write to the SCTLR.
>>
dsb can be moved up after stmfd but leaving as above should be fine
as well.
>> [...]
>>
>>> + dsb
>>> + isb
>>> +
>>> + mcr p15, 0, r8, c1, c0, 0 @ re-enable MMU
>>> + dsb
>>> + isb
>>
>> Similarly, isn't the last DSB redundant?
>
This dsb probably can be dropped but I leave that to Russell
to decide. That one extra instruction doesn't hurt much.
Regards,
Santosh
> I've really no idea. All I know is that the above works. I'm rather
> sick of trying to read the ARM ARM and not understanding exactly what
> ISB and DSB actually do.
>
next prev parent reply other threads:[~2015-04-13 19:11 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 9:44 [PATCH 0/7] Fix Keystone 2 physical address switch Russell King - ARM Linux
2015-04-08 9:45 ` [PATCH 1/6] ARM: keystone2: move platform notifier initialisation into platform init Russell King
2015-04-13 18:57 ` santosh shilimkar
2015-04-08 9:45 ` [PATCH 2/6] ARM: keystone2: move update of the phys-to-virt constants into generic code Russell King
2015-04-08 14:56 ` Grygorii.Strashko@linaro.org
2015-04-08 18:00 ` Russell King - ARM Linux
2015-04-09 14:51 ` Grygorii.Strashko@linaro.org
2015-04-09 15:49 ` Russell King - ARM Linux
2015-04-09 16:15 ` Grygorii.Strashko@linaro.org
2015-04-08 19:19 ` Russell King - ARM Linux
2015-04-13 19:02 ` santosh shilimkar
2015-04-08 9:45 ` [PATCH 3/6] ARM: keystone2: move address space switch printk to " Russell King
2015-04-13 19:02 ` santosh shilimkar
2015-04-08 9:45 ` [PATCH 4/6] ARM: keystone2: rename init_meminfo to pv_fixup Russell King
2015-04-13 19:03 ` santosh shilimkar
2015-04-08 9:45 ` [PATCH 5/6] ARM: re-implement physical address space switching Russell King
2015-04-08 14:34 ` Thomas Petazzoni
2015-04-08 17:27 ` santosh shilimkar
2015-04-08 18:10 ` Russell King - ARM Linux
2015-04-08 17:36 ` Mark Rutland
2015-04-08 17:55 ` Russell King - ARM Linux
2015-04-13 19:11 ` santosh shilimkar [this message]
2015-04-15 12:07 ` Mark Rutland
2015-04-15 17:27 ` santosh shilimkar
2015-04-23 11:24 ` Mark Rutland
2015-05-06 10:18 ` Russell King - ARM Linux
2015-05-06 10:37 ` Mark Rutland
2015-05-06 11:33 ` Russell King - ARM Linux
2015-05-06 15:33 ` Mark Rutland
2015-05-06 15:50 ` Russell King - ARM Linux
2015-05-06 16:14 ` Mark Rutland
2015-05-06 16:24 ` Will Deacon
2015-04-08 9:45 ` [PATCH 6/6] ARM: cleanup early_paging_init() calling Russell King
2015-04-13 19:13 ` santosh shilimkar
2015-04-08 17:21 ` [PATCH 0/7] Fix Keystone 2 physical address switch santosh shilimkar
2015-04-09 16:21 ` Russell King - ARM Linux
2015-04-09 16:35 ` santosh shilimkar
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=552C14F0.7020006@oracle.com \
--to=santosh.shilimkar@oracle.com \
--cc=linux-arm-kernel@lists.infradead.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 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.