Re: [Qemu-devel] [PATCH 2/3] armv7-m: fix non-IRQ exceptions

2015-10-11 Thread Michael Davidsaver
I'm starting to doubt my diagnosis. The bug may be in my understanding of the interrupt priorities. I'll have to do another test program. On Oct 11, 2015 11:25 AM, "Peter Crosthwaite" wrote: > On Fri, Oct 9, 2015 at 6:28 AM, Michael Davidsaver > wrote: > > Han

[Qemu-devel] [PATCH v3 2/3] armv7-m: Implement SYSRESETREQ

2015-10-11 Thread Michael Davidsaver
Implement the SYSRESETREQ bit of the AIRCR register for armv7-m (ie. cortex-m3) to trigger a GPIO out. Signed-off-by: Michael Davidsaver --- hw/intc/armv7m_nvic.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index

[Qemu-devel] [PATCH v3 3/3] stellaris: exit on external reset request

2015-10-11 Thread Michael Davidsaver
Add GPIO in for the stellaris board which calls qemu_system_reset_request() on reset request. Signed-off-by: Michael Davidsaver --- hw/arm/stellaris.c | 12 1 file changed, 12 insertions(+) diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index 82a4ad5..0114e0a 100644 --- a/hw

[Qemu-devel] [PATCH v3 1/3] armv7-m: Return DeviceState* from armv7m_init()

2015-10-11 Thread Michael Davidsaver
Change armv7m_init to return the DeviceState* for the NVIC. This allows access to all GPIO blocks, not just the IRQ inputs. Move qdev_get_gpio_in() calls out of armv7m_init() into board code for stellaris and stm32f205 boards. Signed-off-by: Michael Davidsaver --- hw/arm/armv7m.c| 9

Re: [Qemu-devel] [PATCH 3/3] armv7-m: add MPU to cortex-m3 and cortex-m4

2015-10-11 Thread Michael Davidsaver
On 10/11/2015 11:23 AM, Peter Crosthwaite wrote: > On Fri, Oct 9, 2015 at 6:28 AM, Michael Davidsaver > wrote: >> The M series MPU is almost the same as the already >> implemented R series MPU. So use the M series >> and translate as best we can. >> > There i

[Qemu-devel] [PATCH v4 1/3] armv7-m: Return DeviceState* from armv7m_init()

2015-10-31 Thread Michael Davidsaver
Change armv7m_init to return the DeviceState* for the NVIC. This allows access to all GPIO blocks, not just the IRQ inputs. Move qdev_get_gpio_in() calls out of armv7m_init() into board code for stellaris and stm32f205 boards. --- hw/arm/armv7m.c| 9 ++--- hw/arm/stellaris.c | 29

[Qemu-devel] [PATCH v4 3/3] arm: stellaris: exit on external reset request

2015-10-31 Thread Michael Davidsaver
Add GPIO in for the stellaris board which calls qemu_system_reset_request() on reset request. --- hw/arm/stellaris.c | 12 1 file changed, 12 insertions(+) diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index 82a4ad5..0114e0a 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellar

[Qemu-devel] [PATCH v4 0/3] armv7-m: exit on external reset request

2015-10-31 Thread Michael Davidsaver
board installs a handler which calls qemu_system_reset_request(). Michael Davidsaver (3): armv7-m: Return DeviceState* from armv7m_init() armv7-m: Implement SYSRESETREQ arm: stellaris: exit on external reset request hw/arm/armv7m.c| 9 ++--- hw/arm/stellaris.c | 41

[Qemu-devel] [PATCH v4 2/3] armv7-m: Implement SYSRESETREQ

2015-10-31 Thread Michael Davidsaver
Implement the SYSRESETREQ bit of the AIRCR register for armv7-m (ie. cortex-m3) to trigger a GPIO out. --- hw/intc/armv7m_nvic.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 3ec8408..6fc167e 100644 --- a/hw/intc/arm

[Qemu-devel] [PATCH 04/18] armv7m: Explicit error for bad vector table

2015-11-08 Thread Michael Davidsaver
Give an explicit error and abort when a load from VECBASE fails. Otherwise would likely jump to 0, which for v7-m holds the reset stack pointer address. Signed-off-by: Michael Davidsaver --- target-arm/helper.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a

[Qemu-devel] [PATCH 03/18] armv7m: Complain about incorrect exception table entries.

2015-11-08 Thread Michael Davidsaver
For -M These should always be thumb mode. Log a message if this is seen. Signed-off-by: Michael Davidsaver --- target-arm/helper.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index 4408100..4178400 100644 --- a/target

[Qemu-devel] [PATCH 02/18] armv7m: Undo armv7m.hack

2015-11-08 Thread Michael Davidsaver
Add CPU unassigned access handler in place of special MemoryRegion to catch exception returns. Signed-off-by: Michael Davidsaver --- hw/arm/armv7m.c | 8 target-arm/cpu.c | 18 ++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/arm/armv7m.c b/hw/arm

[Qemu-devel] [PATCH 05/18] armv7m: expand NVIC state

2015-11-08 Thread Michael Davidsaver
ector # with sub-group as per tie breaking rules. NVIC now derives directly from SysBusDevice, and struct NVICClass is eliminated. Also add DPRINTF() macro. Signed-off-by: Michael Davidsaver --- hw/intc/armv7m_nvic.c | 74 ++- target-arm/cpu.h

[Qemu-devel] [PATCH 00/18] Fix exception handling and msr/mrs access

2015-11-08 Thread Michael Davidsaver
qtest, but can't quite see how to use it given the need to execute code to test most of the exception behavior. Is something like this feasible at present? Regards, Michael Michael Davidsaver (18): armv7m: MRS/MSR handle unprivileged access armv7m: Undo armv7m.hack armv7m: Com

[Qemu-devel] [PATCH 01/18] armv7m: MRS/MSR handle unprivileged access

2015-11-08 Thread Michael Davidsaver
The MRS and MSR instruction handling isn't checking the current permission level. Signed-off-by: Michael Davidsaver --- target-arm/helper.c | 79 + 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/target-arm/helper.c b/t

[Qemu-devel] [PATCH 08/18] armv7m: fix RETTOBASE

2015-11-08 Thread Michael Davidsaver
The polarity is reversed, and it should include internal exceptions. Should be set when # of active exceptions <= 1. Signed-off-by: Michael Davidsaver --- hw/intc/armv7m_nvic.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/intc/armv7m_nvic.c b

[Qemu-devel] [PATCH 15/18] arm: gic: Remove references to NVIC

2015-11-08 Thread Michael Davidsaver
armv7m_nvic.c no longer relies on the GIC. Remove REV_NVIC and conditionals which use it. Signed-off-by: Michael Davidsaver --- hw/intc/arm_gic.c| 14 +++--- hw/intc/arm_gic_common.c | 23 --- hw/intc/gic_internal.h | 7 ++- 3 files changed, 17

[Qemu-devel] [PATCH 06/18] armv7m: new NVIC utility functions

2015-11-08 Thread Michael Davidsaver
Internal functions for operations previously done by GIC internals. nvic_irq_update() recalculates highest pending/active exceptions. armv7m_nvic_set_pending() include exception escalation logic. armv7m_nvic_acknowledge_irq() and nvic_irq_update() update ARMCPU fields. Signed-off-by: Michael

[Qemu-devel] [PATCH 09/18] armv7m: NVIC update vmstate

2015-11-08 Thread Michael Davidsaver
Signed-off-by: Michael Davidsaver --- hw/intc/armv7m_nvic.c | 64 +-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 3b10dee..c860b36 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw

[Qemu-devel] [PATCH 12/18] armv7m: simpler/faster exception start

2015-11-08 Thread Michael Davidsaver
No need to bounce through EXCP_IRQ handling for non-IRQ exceptions. just update CPU state directly. Signed-off-by: Michael Davidsaver --- target-arm/helper.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index

[Qemu-devel] [PATCH 18/18] armv7m: prevent unprivileged write to STIR

2015-11-08 Thread Michael Davidsaver
Prevent unprivileged from writing to the Software Triggered Interrupt register Signed-off-by: Michael Davidsaver --- hw/intc/armv7m_nvic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index ca8c93c..b744cd5 100644 --- a/hw

[Qemu-devel] [PATCH 07/18] armv7m: Update NVIC registers

2015-11-08 Thread Michael Davidsaver
Replace use of GIC state/functions with new NVIC. Signed-off-by: Michael Davidsaver --- hw/intc/armv7m_nvic.c | 233 -- 1 file changed, 168 insertions(+), 65 deletions(-) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index ebb4d4e

[Qemu-devel] [PATCH 11/18] armv7m: fix I and F flag handling

2015-11-08 Thread Michael Davidsaver
pending exception can interrupt execution. Signed-off-by: Michael Davidsaver --- target-arm/cpu.c | 26 +++--- target-arm/cpu.h | 27 ++- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index be026bc

[Qemu-devel] [PATCH 14/18] armv7m: auto-clear FAULTMASK

2015-11-08 Thread Michael Davidsaver
on return from all exceptions other than NMI Signed-off-by: Michael Davidsaver --- target-arm/helper.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index 5be09b8..83af528 100644 --- a/target-arm/helper.c +++ b/target-arm

[Qemu-devel] [PATCH 10/18] armv7m: NVIC initialization

2015-11-08 Thread Michael Davidsaver
Signed-off-by: Michael Davidsaver --- hw/intc/armv7m_nvic.c | 107 -- 1 file changed, 51 insertions(+), 56 deletions(-) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index c860b36..8eaf677 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw

[Qemu-devel] [PATCH 17/18] armv7m: implement CCR

2015-11-08 Thread Michael Davidsaver
Implement Configuration and Control register. Handle STACKALIGN and USERSETMPEND bits. Signed-off-by: Michael Davidsaver --- hw/intc/armv7m_nvic.c | 15 +++ target-arm/cpu.h | 1 + target-arm/helper.c | 8 +++- target-arm/machine.c | 1 + 4 files changed, 16

[Qemu-devel] [PATCH 13/18] armv7m: implement CFSR and HFSR

2015-11-08 Thread Michael Davidsaver
Add the Configurable and Hard Fault Status registers. Note undefined instructions and escalations Signed-off-by: Michael Davidsaver --- hw/intc/armv7m_nvic.c | 10 +++--- target-arm/cpu.h | 2 ++ target-arm/helper.c | 1 + target-arm/machine.c | 6 -- 4 files changed, 14

[Qemu-devel] [PATCH 16/18] armv7m: check exception return consistency

2015-11-08 Thread Michael Davidsaver
Detect use of reserved exception return codes and return to thread mode from nested exception handler. Also check consistency between NVIC and CPU wrt. the active exception. Signed-off-by: Michael Davidsaver --- hw/intc/armv7m_nvic.c | 7 +++- target-arm/cpu.h | 2 +- target-arm

Re: [Qemu-devel] [Qemu-arm] [PATCH] target-arm: Priority masking with basepri on v7m

2015-11-18 Thread Michael Davidsaver
On 11/18/2015 02:41 PM, Peter Maydell wrote: > For a big patchset like this the easiest thing is to just ask > Michael if he has a public git repo with the patches in (I've > cc'd him). https://github.com/mdavidsaver/qemu/tree/fixirq The posted patches were https://github.com/qemu/qemu/compare/c

Re: [Qemu-devel] Any progress with the Cortex-M4 emulation?

2016-04-06 Thread Michael Davidsaver
On 04/06/2016 06:23 PM, Liviu Ionescu wrote: > >> On 07 Apr 2016, at 01:04, Peter Maydell wrote: >> >> ... Somebody needs to do the necessary work to fix the >> code review issues. ... > > in this case I'll probably wait for this process to be completed and > reevaluate the situation by then.

Re: [Qemu-devel] [PATCH 00/18] Fix exception handling and msr/mrs access

2015-12-02 Thread Michael Davidsaver
On 11/20/2015 08:59 AM, Peter Maydell wrote: > I think I've now done that at least for the earlier patches. > There are probably some other finer details that I'll get to > in a later round of patch review but hopefully you have enough > to do some of the fixes and restructuring of this patchset fo

Re: [Qemu-devel] [PATCH 01/18] armv7m: MRS/MSR handle unprivileged access

2015-12-02 Thread Michael Davidsaver
On 11/17/2015 12:09 PM, Peter Maydell wrote: > On 9 November 2015 at 01:11, Michael Davidsaver wrote: >> The MRS and MSR instruction handling isn't checking >> the current permission level. >> >> Signed-off-by: Michael Davidsaver >

Re: [Qemu-devel] [PATCH 03/18] armv7m: Complain about incorrect exception table entries.

2015-12-02 Thread Michael Davidsaver
On 11/17/2015 12:20 PM, Peter Maydell wrote: > This one's not really correct, I'm afraid (though the spec-mandated > behaviour is a bit subtle). I've dropped this patch.

Re: [Qemu-devel] [PATCH 04/18] armv7m: Explicit error for bad vector table

2015-12-02 Thread Michael Davidsaver
On 11/17/2015 12:33 PM, Peter Maydell wrote: > On 9 November 2015 at 01:11, Michael Davidsaver wrote: >> Give an explicit error and abort when a load >> from VECBASE fails. Otherwise would likely >> jump to 0, which for v7-m holds the reset stack >> pointer a

Re: [Qemu-devel] [PATCH 05/18] armv7m: expand NVIC state

2015-12-02 Thread Michael Davidsaver
On 11/17/2015 01:10 PM, Peter Maydell wrote: > On 9 November 2015 at 01:11, Michael Davidsaver wrote: >> Expand the NVIC to fully support -M priorities and masking. >> Doesn't use GIC code. >> >> Move some state to ARMCPU to allow calculation of exception masking

Re: [Qemu-devel] [PATCH 06/18] armv7m: new NVIC utility functions

2015-12-02 Thread Michael Davidsaver
On 11/20/2015 08:25 AM, Peter Maydell wrote: > On 9 November 2015 at 01:11, Michael Davidsaver wrote: >> Internal functions for operations previously done >> by GIC internals. >> >> nvic_irq_update() recalculates highest pending/active >> exceptions. >&g

Re: [Qemu-devel] [PATCH 09/18] armv7m: NVIC update vmstate

2015-12-02 Thread Michael Davidsaver
On 11/17/2015 12:58 PM, Peter Maydell wrote: > On 9 November 2015 at 01:11, Michael Davidsaver wrote: >> Signed-off-by: Michael Davidsaver >> --- >> hw/intc/armv7m_nvic.c | 64 >> +-- >> 1 file chang

Re: [Qemu-devel] [PATCH 11/18] armv7m: fix I and F flag handling

2015-12-02 Thread Michael Davidsaver
On 11/20/2015 08:47 AM, Peter Maydell wrote: > On 9 November 2015 at 01:11, Michael Davidsaver wrote: >> Despite having the same notation, these bits >> have completely different meaning than -AR. >> >> Add armv7m_excp_unmasked() >> to calculate the currently run

[Qemu-devel] [PATCH v2 04/26] armv7m: additional cpu state for exception handling

2015-12-02 Thread Michael Davidsaver
Track priorities and highest active and pending exception. Also the highest pending exception for faster exception handler entry. The pending exception information will be re-calculated on load, so no additional vmstate tracking is needed. --- target-arm/cpu.c | 2 ++ target-arm/cpu.h | 3 +++ 2

[Qemu-devel] [PATCH v2 02/26] armv7m: Undo armv7m.hack

2015-12-02 Thread Michael Davidsaver
Add CPU unassigned access handler in place of special MemoryRegion to catch exception returns. The unassigned handler will signal other faults as either prefetch or data exceptions, with the FSR code 0x8 to distinguish them from memory translation faults (0xd). Future code will make use of this di

[Qemu-devel] [PATCH v2 07/26] armv7m: simpler/faster exception start

2015-12-02 Thread Michael Davidsaver
No need to bounce through EXCP_IRQ handling for non-IRQ exceptions. just update CPU state directly. --- target-arm/helper.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index 7b76f32..4490b74 100644 --- a/target-arm/he

[Qemu-devel] [PATCH v2 01/26] armv7m: MRS/MSR handle unprivileged access

2015-12-02 Thread Michael Davidsaver
The MRS and MSR instruction handling isn't checking the current permission level. Prevent privlaged from changing writing EPSR fields. Access to unknown/undefined special registers not fatal (read 0, write ignored) w/ guest error message. --- target-arm/helper.c | 79 +

[Qemu-devel] [PATCH v2 03/26] armv7m: Explicit error for bad vector table

2015-12-02 Thread Michael Davidsaver
Give an explicit error and abort when a load from VECBASE fails. Otherwise would likely jump to 0, which for v7-m holds the reset stack pointer address. --- target-arm/helper.c | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/target-arm/helper.c b/target-a

[Qemu-devel] [PATCH v2 09/26] armv7m: implement CFSR, HFSR, BFAR, and MMFAR

2015-12-02 Thread Michael Davidsaver
Add the Configurable, HardFault, BusFault and MemManage Status registers. Note undefined instructions, violations, and escalations. No BusFaults are raised at this point. --- hw/intc/armv7m_nvic.c | 28 ++-- target-arm/cpu.h | 4 target-arm/helper.c | 3 +++

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

2015-12-02 Thread Michael Davidsaver
ge 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.

[Qemu-devel] [PATCH v2 06/26] armv7m: fix I and F flag handling

2015-12-02 Thread Michael Davidsaver
Despite having the same notation, these bits have completely different meaning than -AR. Use armv7m_excp_running_prio() and the highest pending exception priority to determine if the pending exception can interrupt preempt. --- target-arm/cpu.c | 16 ++-- 1 file changed, 6 insertions(

[Qemu-devel] [PATCH v2 05/26] armv7m: add armv7m_excp_running_prio()

2015-12-02 Thread Michael Davidsaver
Implements v7m exception priority algorithm using FAULTMASK, PRIMASK, BASEPRI, and the highest priority active exception. The number returned is the current execution priority which may be in the range [-2,0x7f] when an exception is active or 0x100 when no exception is active. --- hw/intc/armv7m_

[Qemu-devel] [PATCH v2 12/26] armv7m: check exception return consistency

2015-12-02 Thread Michael Davidsaver
Detect use of reserved exception return codes and return to thread mode from nested exception handler. Also check consistency between NVIC and CPU wrt. the active exception. --- hw/intc/armv7m_nvic.c | 7 +++- target-arm/cpu.h | 2 +- target-arm/helper.c | 95

[Qemu-devel] [PATCH v2 11/26] arm: gic: Remove references to NVIC

2015-12-02 Thread Michael Davidsaver
armv7m_nvic.c no longer relies on the GIC. Remove REV_NVIC and conditionals which use it. --- hw/intc/arm_gic.c| 14 +++--- hw/intc/arm_gic_common.c | 23 --- hw/intc/gic_internal.h | 7 ++- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a

[Qemu-devel] [PATCH v2 10/26] armv7m: auto-clear FAULTMASK

2015-12-02 Thread Michael Davidsaver
on return from all exceptions other than NMI --- target-arm/helper.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index d1ca011..b6ec761 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -5379,8 +5379,13 @@ static v

[Qemu-devel] [PATCH v2 20/26] armv7m: observable initial register state

2015-12-02 Thread Michael Davidsaver
At least for TI TM4C1294. LR==-1 XPSR==0 PRIMASK, FAULTMASK, and BASEPRI all cleared so exception handlers are unmasked. STKALIGN set. --- target-arm/cpu.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 1fa1f96..8b85888 100644 ---

[Qemu-devel] [PATCH v2 18/26] armv7m: update base region policy

2015-12-02 Thread Michael Davidsaver
Update MPU background policy as per ARM. Main changes are preventing writes to ROM and no-exec for device regions. --- target-arm/helper.c | 35 +++ 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index e73f7a

[Qemu-devel] [PATCH v2 14/26] armv7m: prevent unprivileged write to STIR

2015-12-02 Thread Michael Davidsaver
Prevent unprivileged from writing to the Software Triggered Interrupt register --- hw/intc/armv7m_nvic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 0f9ca6a..5731146 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv

[Qemu-devel] [PATCH v2 08/26] armv7m: rewrite NVIC

2015-12-02 Thread Michael Davidsaver
Expand the NVIC to fully support -M priorities and masking. Doesn't use GIC code. Use PRIGROUP to configure group/sub-group split. Track group and sub-group in separate fields for quick comparison. Mix in vector # with sub-group as per tie breaking rules. NVIC now derives directly from SysBusDevi

[Qemu-devel] [PATCH v2 19/26] armv7m: mpu not allowed to map exception return codes

2015-12-02 Thread Michael Davidsaver
Always pass these through to be caught be by the unassigned handler. --- target-arm/helper.c | 9 + 1 file changed, 9 insertions(+) diff --git a/target-arm/helper.c b/target-arm/helper.c index e42f6d0..a5adf2d 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -7106,6 +7106,15

[Qemu-devel] [PATCH v2 23/26] qom: add cpu_generic_init_unrealized()

2015-12-02 Thread Michael Davidsaver
cpu_generic_init() without realized=true. Gives board code an opportunity to change CPU properties. --- include/qom/cpu.h | 12 qom/cpu.c | 23 +-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 5

[Qemu-devel] [PATCH v2 21/26] armv7m: CONTROL<1> handling

2015-12-02 Thread Michael Davidsaver
The ARM states that this bit indicates the stack being used, which in handler mode is always MSP. Further CONTROL<1>==1 in handler mode is reserved. With the TM4C always CONTROL<1>==0 in handler mode which inconveniently prevents the handler from knowing which stack thread mode was using... This

[Qemu-devel] [PATCH v2 13/26] armv7m: implement CCR

2015-12-02 Thread Michael Davidsaver
Implement Configuration and Control register. Handle STACKALIGN and USERSETMPEND bits. --- hw/intc/armv7m_nvic.c | 15 +++ target-arm/cpu.h | 1 + target-arm/helper.c | 8 +++- target-arm/machine.c | 1 + 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/hw

[Qemu-devel] [PATCH v2 25/26] armv7m: remove extra cpu_reset()

2015-12-02 Thread Michael Davidsaver
cpu_reset() is called as a side-effect of realizing the CPU. arm_cpu_reset() calls rom_ptr(0), which expects to find the image mapped. This was happening way before load_*() and was worked around with a second call to cpu_reset(). Now wait to realize until after the image is mapped. --- hw/arm/arm

[Qemu-devel] [PATCH v2 22/26] armv7m: priority field mask

2015-12-02 Thread Michael Davidsaver
Many v7m CPUs don't implement all of the 8 bits of the priority fields. Typically, only the top N bits are available. Existing practice implies that writes to unimplemented bits will be ignore, and read as zero. This allows a guest to discover the implemented bits by writing 0xff to (eg. basepri

[Qemu-devel] [PATCH v2 17/26] armv7m: mpu background miss is perm fault

2015-12-02 Thread Michael Davidsaver
Set an appropriate FSR code when an access does not match any MPU region, including the background/default. --- target-arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index da99825..e73f7a6 100644 --- a/target-arm/helper.c

[Qemu-devel] [PATCH v2 15/26] armv7m: add MPU to cortex-m3 and cortex-m4

2015-12-02 Thread Michael Davidsaver
The M series MPU is almost the same as the already implemented R series MPU. So use the M series and translate. Primary difference is that a real v7-M MPU is has much relaxed alignment and size requirements for MPU regions (32 bytes) compared with the 1K page size of the QEMU TLB which is shared

[Qemu-devel] [PATCH v2 16/26] armv7m: add some mpu debugging prints

2015-12-02 Thread Michael Davidsaver
Provide some more "-d mmu" related to the MPU translation process as an aid in debugging guest MPU configurations. Helpful since our MPU resolution is limited to the ARM7-AR page size. --- target-arm/helper.c | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/

[Qemu-devel] [PATCH v2 26/26] armv7m: decide whether faults are MemManage or BusFault

2015-12-02 Thread Michael Davidsaver
General logic is that operations stopped by the MPU are MemManage, and those which go through the MPU and are caught by the unassigned handle are BusFault. --- target-arm/helper.c | 35 +-- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/target-arm/he

[Qemu-devel] [PATCH v2 24/26] armv7m: split armv7m_init in two parts

2015-12-02 Thread Michael Davidsaver
Separate init and realize phases to allow board code the opportunity to set properties on the cpu and nvic. Assign names for cpu, nvic, and bitband regions. update stellaris and stm32 board code accordingly. --- hw/arm/armv7m.c| 42 +++--- hw/arm/stell

Re: [Qemu-devel] [PATCH v2 02/26] armv7m: Undo armv7m.hack

2015-12-27 Thread Michael Davidsaver
On 12/17/2015 10:38 AM, Peter Maydell wrote: > On 3 December 2015 at 00:18, Michael Davidsaver wrote: >> Add CPU unassigned access handler in place of special >> MemoryRegion to catch exception returns. >> >> The unassigned handler will signal other faults as either >

Re: [Qemu-devel] [PATCH v2 03/26] armv7m: Explicit error for bad vector table

2015-12-27 Thread Michael Davidsaver
On 12/17/2015 08:25 AM, Peter Maydell wrote: > On 3 December 2015 at 00:18, Michael Davidsaver wrote: >> ... >> +static >> +uint32_t arm_v7m_load_vector(ARMCPU *cpu) >> + >> +{ >> +CPUState *cs = &cpu->parent_obj; > This isn't the righ

Re: [Qemu-devel] [PATCH v2 05/26] armv7m: add armv7m_excp_running_prio()

2015-12-27 Thread Michael Davidsaver
On 12/17/2015 09:36 AM, Peter Maydell wrote: > On 3 December 2015 at 00:18, Michael Davidsaver wrote: >> Implements v7m exception priority algorithm >> using FAULTMASK, PRIMASK, BASEPRI, and the highest >> priority active exception. >> >> The number returned

Re: [Qemu-devel] [PATCH v2 02/26] armv7m: Undo armv7m.hack

2015-12-27 Thread Michael Davidsaver
On 12/17/2015 10:38 AM, Peter Maydell wrote: > We could use a comment here (a) explaining what we're doing and (b) > mentioning that this isn't architecturally correct -- ideally we should > catch these exception exits on execution of the jump insn, not by > letting the jump execute and then trappi

Re: [Qemu-devel] [PATCH v2 06/26] armv7m: fix I and F flag handling

2015-12-27 Thread Michael Davidsaver
On 12/17/2015 10:18 AM, Peter Maydell wrote: > On 17 December 2015 at 14:39, Peter Maydell wrote: >> On 3 December 2015 at 00:18, Michael Davidsaver >> wrote: >>> Despite having the same notation, these bits >>> have completely different meaning than -AR. >

Re: [Qemu-devel] [PATCH 3/9] armv7m: Rewrite NVIC to not use any GIC code

2017-02-18 Thread Michael Davidsaver
On 02/16/2017 09:11 AM, Peter Maydell wrote: > I haven't actually checked real hardware behaviour, but I think > we can fairly safely implement this as not checking the IPSR > exception field. (We might as well go with the "reads 1 in > handler mode" choice of UNKNOWN that the M3 documents, though.

Re: [Qemu-devel] [PATCH 3/9] armv7m: Rewrite NVIC to not use any GIC code

2017-02-19 Thread Michael Davidsaver
On 02/18/2017 01:38 PM, Peter Maydell wrote: > On 18 February 2017 at 17:45, Michael Davidsaver > wrote: >> On 02/16/2017 09:11 AM, Peter Maydell wrote: >>> I haven't actually checked real hardware behaviour, but I think >>> we can fairly safely impl

<    1   2