public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3] ARM: zImage: perform cache maintenance after relocating code (was: ARM: zImage: add DSB and ISB barriers after relocating code)
Date: Tue, 12 Aug 2014 10:34:10 +0100	[thread overview]
Message-ID: <20140812093410.GH30401@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1407803747-21379-1-git-send-email-marc.ceeeee@gmail.com>

On Mon, Aug 11, 2014 at 05:35:47PM -0700, Marc Carino wrote:
> The zImage loader will relocate the kernel image if it determines that
> decompression will overwrite its current location. Since the act of relocation
> is a form of code self-modification, we need to ensure that the CPU fetches
> the updated instruction stream.
> 
> Instead of conditionally executing cache maintenance, this commit ensures that
> cache maintenance is performed in all cases. Besides ensuring coherency with
> the caches and main memory, performing cache maintenance ensures that any
> potentially stale instructions are flushed from the instruction pipeline.

This is not a good idea.  It means that if we fail to create the page
table, we could end up doing some rather expensive cache flushing when
it's not required.

It is simple enough to add a new call into the cache handling code -

cache_barrier:
		mov	r3, #20
		b	call_cache_fn

change PROC_ENTRY_SIZE:

#define PROC_ENTRY_SIZE (5*5)

and then add to each of the proc_types table a new pointer at the bottom
of each entry to do the right thing - you can even set it to point at the
barriers at the end of the cache flushing code for the CPUs which require
it, so it doesn't mean that you have to write lots of new code.

Then you just need to add a call to cache_barrier at the appropriate
point.

-- 
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.

      parent reply	other threads:[~2014-08-12  9:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12  0:35 [PATCH v3] ARM: zImage: perform cache maintenance after relocating code (was: ARM: zImage: add DSB and ISB barriers after relocating code) Marc Carino
2014-08-12  2:33 ` Nicolas Pitre
2014-08-12  9:34 ` Russell King - ARM Linux [this message]

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=20140812093410.GH30401@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox