All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephanos Ioannidis <root@stephanos.io>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	"open list:ARM TCG CPUs" <qemu-arm@nongnu.org>,
	Stephanos Ioannidis <root@stephanos.io>,
	"open list:All patches CC here" <qemu-devel@nongnu.org>
Subject: [PATCH v2 2/2] hw/arm/armv7m: Downgrade CPU reset handler priority
Date: Thu, 27 Feb 2020 11:51:28 +0000	[thread overview]
Message-ID: <20200227115005.66349-3-root@stephanos.io> (raw)
In-Reply-To: <20200227115005.66349-1-root@stephanos.io>

The ARMv7-M CPU reset handler, which loads the initial SP and PC
register values from the vector table, is currently executed before
the ROM reset handler (rom_reset), and this causes the devices that
alias low memory region (e.g. STM32F405 that aliases the flash memory
located at 0x8000000 to 0x0) to load an invalid reset vector of 0 when
the kernel image is linked to be loaded at the high memory address.

For instance, it is norm for the STM32F405 firmware ELF image to have
the text and rodata sections linked at 0x8000000, as this facilitates
proper image loading by the firmware burning utility, and the processor
can execute in place from the high flash memory address region as well.

In order to resolve this issue, this commit downgrades the ARMCPU reset
handler invocation priority level to -1 such that it is always executed
after the ROM reset handler, which has a priority level of 0.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
---
 hw/arm/armv7m.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 7531b97ccd..8b7c4b12a6 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -352,7 +352,8 @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size)
      * way A-profile does it. Note that this means that every M profile
      * board must call this function!
      */
-    qemu_register_reset(armv7m_reset, cpu);
+    qemu_register_reset_with_priority(
+        QEMU_RESET_PRIORITY_LEVEL(-1), armv7m_reset, cpu);
 }
 
 static Property bitband_properties[] = {
-- 
2.17.1



  parent reply	other threads:[~2020-02-27 11:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200227115005.66349-1-root@stephanos.io>
2020-02-27 11:51 ` [PATCH v2 1/2] hw/core: Support device reset handler priority Stephanos Ioannidis
2020-02-27 11:51 ` Stephanos Ioannidis [this message]
2020-02-27 13:31   ` [PATCH v2 2/2] hw/arm/armv7m: Downgrade CPU " Philippe Mathieu-Daudé
2020-02-27 21:30     ` Alistair Francis
2020-02-27 21:44       ` Peter Maydell
2020-02-27 21:41         ` Alistair Francis
2020-02-27 11:58 ` [PATCH v2 0/2] Support device reset handler priority configuration Stephanos Ioannidis

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=20200227115005.66349-3-root@stephanos.io \
    --to=root@stephanos.io \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.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.