Skip to content

armv7m: exception handling, MPU, and more

Michael Davidsaver qemu-arm qemu-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest26 patches 29 repliesIn review
  2. v118 patches 22 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/26armv7m: MRS/MSR handle unprivileged accesstarget-arm/helper.c+37 -423 replies
2/26armv7m: Undo armv7m.hackhw/arm/armv7m.c target-arm/cpu.c+21 -195 replies
3/26armv7m: Explicit error for bad vector tabletarget-arm/helper.c+20 -13 replies
4/26armv7m: additional cpu state for exception handlingtarget-arm/cpu.c target-arm/cpu.h+5 -00 replies
5/26armv7m: add armv7m_excp_running_prio()hw/intc/armv7m_nvic.c target-arm/cpu.h+26 -03 replies
6/26armv7m: fix I and F flag handlingtarget-arm/cpu.c+6 -104 replies
7/26armv7m: simpler/faster exception starttarget-arm/helper.c+7 -61 reply
8/26armv7m: rewrite NVIChw/intc/armv7m_nvic.c target-arm/cpu.h+622 -1873 replies
9/26armv7m: implement CFSR, HFSR, BFAR, and MMFARhw/intc/armv7m_nvic.c target-arm/cpu.h target-arm/helper.c +1 more+35 -81 reply
10/26armv7m: auto-clear FAULTMASKtarget-arm/helper.c+6 -11 reply
11/26arm: gic: Remove references to NVIChw/intc/arm_gic.c hw/intc/arm_gic_common.c hw/intc/gic_internal.h+17 -271 reply
12/26armv7m: check exception return consistencyhw/intc/armv7m_nvic.c target-arm/cpu.h target-arm/helper.c+94 -101 reply
13/26armv7m: implement CCRhw/intc/armv7m_nvic.c target-arm/cpu.h target-arm/helper.c +1 more+16 -91 reply
14/26armv7m: prevent unprivileged write to STIRhw/intc/armv7m_nvic.c+3 -11 reply
15/26armv7m: add MPU to cortex-m3 and cortex-m4hw/arm/stellaris.c hw/intc/armv7m_nvic.c target-arm/cpu.c +3 more+179 -50 replies
16/26armv7m: add some mpu debugging printstarget-arm/helper.c+14 -50 replies
17/26armv7m: mpu background miss is perm faulttarget-arm/helper.c+1 -10 replies
18/26armv7m: update base region policytarget-arm/helper.c+27 -80 replies
19/26armv7m: mpu not allowed to map exception return codestarget-arm/helper.c+9 -00 replies
20/26armv7m: observable initial register statetarget-arm/cpu.c+5 -10 replies
21/26armv7m: CONTROL<1> handlingtarget-arm/cpu.h target-arm/helper.c target-arm/machine.c+10 -120 replies
22/26armv7m: priority field maskhw/intc/armv7m_nvic.c target-arm/cpu-qom.h target-arm/cpu.c +1 more+19 -20 replies
23/26qom: add cpu_generic_init_unrealized()include/qom/cpu.h qom/cpu.c+29 -60 replies
24/26armv7m: split armv7m_init in two partshw/arm/armv7m.c hw/arm/stellaris.c hw/arm/stm32f205_soc.c +1 more+38 -320 replies
25/26armv7m: remove extra cpu_reset()hw/arm/armv7m.c+5 -110 replies
26/26armv7m: decide whether faults are MemManage or BusFaulttarget-arm/helper.c+29 -60 replies

Reviews trailers per patch

3 of 26 patches have a Reviewed-by or Acked-by.

PatchPeter Maydell
1/26R-b
2/26
3/26
4/26
5/26
6/26R-b
7/26
8/26
9/26
10/26
11/26R-b
12/26
13/26
14/26
15/26
16/26
17/26
18/26
19/26
20/26
21/26
22/26
23/26
24/26
25/26
26/26

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 00/26] armv7m: exception handling, MPU, and more

All,

Second revision of ARMv7-M exception handling patchset, which now adds MPU support (as well as can be done).

Parts of this series are informed by the previous work of Alex Zuepke.

This time I have access to a EK-TM4C1294XL eval board (cortex-m4f), and have done some cross-checks using test programs of my own[1]. There are differences in some corner cases, but mostly agreement (certainly better than before).

This series attempts to fix the exception masking and priority escalation behavour, and in the process removes the dependence of the NVIC on the shared GIC code. It also fills out some of the missing fault reporting registers.

The CCR register is also added, mainly to implement the STACKALIGN bit. I've also made an attempt on USERSETMPEND. BFHFNMIGN, DIV_0_TRP, UNALIGN_TRP remain unimplemnted.

Additional checks are added to do_v7m_exception_exit() to capture the faults which should arise when the guest stack gets out of sync with the CPU's state.

In cross-checking with a real device I also found that the behavour of CONTROL bit 1 wasn't as spec'd in exception handlers.

I also "discovered" that many v7-M targets don't implement all 8 bits of the priority registers (the TM4C1294 only has 3). So I've added a Property to allow this to be set appropriately.

This led me to make some changes to allow board code to actually set this Property, which entailed splitting armv7m_init() in two parts, and associated changes to the stellaris and stm32f205 boards.

I'm not completely happy with the level of compatibility with the MPU. For my own purposes it's good enough as I can make special builds. However, the additional alignment and size restrictions imposed by the common TLB and 1024 page size will probably break most unmodified guests using the MPU. I can't see any way around this short of changes to the TLB code, or a seperate build with TARGET_PAGE_BITS==5. I'm not inclined to undertake either.

Should this part of the series be dropped?

Michael

[1] https://github.com/mdavidsaver/baremetal/tree/qemutest

Michael Davidsaver (26):
armv7m: MRS/MSR handle unprivileged access
armv7m: Undo armv7m.hack
armv7m: Explicit error for bad vector table
armv7m: additional cpu state for exception handling
armv7m: add armv7m_excp_running_prio()
armv7m: fix I and F flag handling
armv7m: simpler/faster exception start
armv7m: rewrite NVIC
armv7m: implement CFSR, HFSR, BFAR, and MMFAR
armv7m: auto-clear FAULTMASK
arm: gic: Remove references to NVIC
armv7m: check exception return consistency
armv7m: implement CCR
armv7m: prevent unprivileged write to STIR
armv7m: add MPU to cortex-m3 and cortex-m4
armv7m: add some mpu debugging prints
armv7m: mpu background miss is perm fault
armv7m: update base region policy
armv7m: mpu not allowed to map exception return codes
armv7m: observable initial register state
armv7m: CONTROL<1> handling
armv7m: priority field mask
qom: add cpu_generic_init_unrealized()
armv7m: split armv7m_init in two parts
armv7m: remove extra cpu_reset()
armv7m: decide whether faults are MemManage or BusFault

 hw/arm/armv7m.c          |   60 ++-
 hw/arm/stellaris.c       |    7 +-
 hw/arm/stm32f205_soc.c   |    6 +-
 hw/intc/arm_gic.c        |   14 +-
 hw/intc/arm_gic_common.c |   23 +-
 hw/intc/armv7m_nvic.c    | 1037 +++++++++++++++++++++++++++++++++++++---------
 hw/intc/gic_internal.h   |    7 +-
 include/hw/arm/arm.h     |    4 +-
 include/qom/cpu.h        |   12 +
 qom/cpu.c                |   23 +-
 target-arm/cpu-qom.h     |    6 +
 target-arm/cpu.c         |   61 ++-
 target-arm/cpu.h         |   17 +-
 target-arm/helper.c      |  346 ++++++++++++----
 target-arm/machine.c     |   11 +-
 15 files changed, 1252 insertions(+), 382 deletions(-)
Signature · 1 line
2.1.4