All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Why invalidate d-cache if MMU and d-cache are disabled by rule?
       [not found] <CA+aKwRRi36GzjEPeaZCLrbjTyKPWTQyo4wkD9j-pid9p0cZEtQ@mail.gmail.com>
@ 2020-08-10  9:49 ` Catalin Marinas
  0 siblings, 0 replies; only message in thread
From: Catalin Marinas @ 2020-08-10  9:49 UTC (permalink / raw)
  To: Jason Mielke; +Cc: linux-arm-kernel, linux-arm

(adding linux-arm-kernel for kernel questions)

On Sun, Aug 09, 2020 at 05:08:01PM +0200, Jason Mielke wrote:
> Trying to understand the
> 
> preserve_boot_args
> 
> function in
> 
>  arch/arm64/kernel/head.S
> 
> The function has a call to invalidate the 32 bytes of dcache area
> 
> SYM_CODE_START_LOCAL(preserve_boot_args)
>     mov x21, x0             // x21=FDT
> 
>     adr_l   x0, boot_args           // record the contents of
>     stp x21, x1, [x0]           // x0 .. x3 at kernel entry
>     stp x2, x3, [x0, #16]
> 
>     dmb sy              // needed before dc ivac with
>                         // MMU off
> 
>     mov x1, #0x20           // 4 x 8 bytes
>     b   __inval_dcache_area     // tail call
> SYM_CODE_END(preserve_boot_args)
> 
> This even though the MMU and d-cache must be disabled

That's because when the MMU will be enabled, the cache may contain stale
data for this address and a subsequent load may not see what was
actually written with the MMU/caches disabled.

Some examples:

- the CPU on reset does not guarantee that the cache won't contain stale
  information

- a boot-loader may have turned the MMU on, before Linux and caches were
  populated

- if running as a guest, the hypervisor probably already maps large
  chunks of memory as cacheable with the MMU enabled

So in all the above examples, the cache may have stale entries prior to
the store with the MMU disabled.

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-10  9:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CA+aKwRRi36GzjEPeaZCLrbjTyKPWTQyo4wkD9j-pid9p0cZEtQ@mail.gmail.com>
2020-08-10  9:49 ` Why invalidate d-cache if MMU and d-cache are disabled by rule? Catalin Marinas

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.