target-arm: Priority masking with basepri on v7m
PATCH 1/1 target-arm: Priority masking with basepri on v7m
On armv7m mcus, the BASEPRI register can be set to mask interrupts above a certain priority.
This changeset implements that functionality by way of the NVIC which ultimately sets the interrupt mask in the GIC.
--- hw/intc/arm_gic.c | 2 +- hw/intc/armv7m_nvic.c | 11 +++++++++++ hw/intc/gic_internal.h | 4 ++++ target-arm/cpu.h | 1 + target-arm/helper.c | 2 ++ 5 files changed, 19 insertions(+), 1 deletion(-)
hw/intc/arm_gic.c +1 -1
@@ -399,7 +399,7 @@ static uint32_t gic_get_priority(GICState *s, int cpu, int irq,return prio; } -static void gic_set_priority_mask (GICState *s,int cpu,uint8_t pmask, +void gic_set_priority_mask (GICState *s,int cpu,uint8_t pmask,MemTxAttrs attrs) {if (s->security_extn && !attrs.secure) {
hw/intc/armv7m_nvic.c +11 -0
@@ -148,6 +148,17 @@ void armv7m_nvic_complete_irq(void *opaque, int irq)gic_complete_irq (&s->gic,0 , irq,MEMTXATTRS_UNSPECIFIED ); } + +void armv7m_nvic_set_priority_mask (void *opaque,uint16_t mask) +{ +nvic_state *s = (nvic_state *)opaque; +if (mask ==0 ) { +/* 0 is used to disable the priority mask */ + mask =0x100 ; + } +gic_set_priority_mask (&s->gic,0 , mask,MEMTXATTRS_UNSPECIFIED ); +} +static uint32_t nvic_readl (nvic_state *s,uint32_t offset) {ARMCPU *cpu;
hw/intc/gic_internal.h +4 -0
@@ -84,6 +84,10 @@ void gic_update(GICState *s);void gic_init_irqs_and_distributor (GICState *s);void gic_set_priority (GICState *s,int cpu,int irq,uint8_t val,MemTxAttrs attrs); +void gic_set_priority_mask (GICState *s, +int cpu, +uint8_t pmask, +MemTxAttrs attrs);static inline bool gic_test_pending (GICState *s,int irq,int cm) {
target-arm/cpu.h +1 -0
@@ -1034,6 +1034,7 @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,void armv7m_nvic_set_pending (void *opaque,int irq);int armv7m_nvic_acknowledge_irq (void *opaque);void armv7m_nvic_complete_irq (void *opaque,int irq); +void armv7m_nvic_set_priority_mask (void *opaque,uint16_t mask);/* Interface for defining coprocessor registers. * Registers are defined in tables of arm_cp_reginfo structs
target-arm/helper.c +2 -0
@@ -7449,11 +7449,13 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val)break ;case 17 :/* BASEPRI */ env->v7m.basepri = val &0xff ; +armv7m_nvic_set_priority_mask (env->nvic, env->v7m.basepri);break ;case 18 :/* BASEPRI_MAX */ val &=0xff ;if (val !=0 && (val < env->v7m.basepri || env->v7m.basepri ==0 )) env->v7m.basepri = val; +armv7m_nvic_set_priority_mask (env->nvic, env->v7m.basepri);break ;case 19 :/* FAULTMASK */ if (val &1 ) {
Signature · 1 line
2.4.0
Quoted 7 lines · François Baldassari
On armv7m mcus, the BASEPRI register can be set to mask interrupts above a certain priority.
This changeset implements that functionality by way of the NVIC which ultimately sets the interrupt mask in the GIC.
Signed-off-by François Baldassari <[email protected]>
There are a lot of problems with our NVIC priority handling right now. You might like to take a look at the patch set that Michael Davidsaver sent out earlier this month:
https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg01542.html
That has some problems but I think it's probably the way we're going to go to fix up the NVIC.
thanks
-- PMM
Thanks for the swift reply.
Michael's changes look very good indeed. Thank you for pointing them out.
No need to consider this any further then.
Cheers,
François.
Quoted 21 lines · Peter Maydell
Quoted 7 lines · François Baldassari
On armv7m mcus, the BASEPRI register can be set to mask interrupts above a certain priority.
This changeset implements that functionality by way of the NVIC which ultimately sets the interrupt mask in the GIC.
Signed-off-by François Baldassari <[email protected]>There are a lot of problems with our NVIC priority handling right now. You might like to take a look at the patch set that Michael Davidsaver sent out earlier this month:
https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg01542.htmlThat has some problems but I think it's probably the way we're going to go to fix up the NVIC.
thanks
-- PMM
Quoted 4 lines · Francois Baldassari
Thanks for the swift reply.
Michael's changes look very good indeed. Thank you for pointing them out.
If you have tested them as working and fixing a problem for you, you should contribute a tested-by tag to the series.
Regards,
Peter
Quoted 31 lines
No need to consider this any further then.
Cheers,
François.
Quoted 21 lines · Peter Maydell
Quoted 7 lines · François Baldassari
On armv7m mcus, the BASEPRI register can be set to mask interrupts above a certain priority.
This changeset implements that functionality by way of the NVIC which ultimately sets the interrupt mask in the GIC.
Signed-off-by François Baldassari <[email protected]>There are a lot of problems with our NVIC priority handling right now. You might like to take a look at the patch set that Michael Davidsaver sent out earlier this month:
https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg01542.htmlThat has some problems but I think it's probably the way we're going to go to fix up the NVIC.
thanks
-- PMM
Hi Peter,
I must be missing something obvious, but I do not have the original email thread (I was not subscribed at the time) and thus am finding it exceedingly difficult to apply the patches using git-am.
I would happily test the patches otherwise.
Any guidance here?
François
Quoted 44 lines · Peter Crosthwaite
Quoted 4 lines · Francois Baldassari
Thanks for the swift reply.
Michael's changes look very good indeed. Thank you for pointing them out.
If you have tested them as working and fixing a problem for you, you should contribute a tested-by tag to the series.
Regards,
PeterQuoted 31 lines
No need to consider this any further then.
Cheers,
François.
Quoted 21 lines · Peter Maydell
Quoted 7 lines · François Baldassari
On armv7m mcus, the BASEPRI register can be set to mask interrupts above a certain priority.
This changeset implements that functionality by way of the NVIC which ultimately sets the interrupt mask in the GIC.
Signed-off-by François Baldassari <[email protected]>There are a lot of problems with our NVIC priority handling right now. You might like to take a look at the patch set that Michael Davidsaver sent out earlier this month:
https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg01542.htmlThat has some problems but I think it's probably the way we're going to go to fix up the NVIC.
thanks
-- PMM
On 18 November 2015 at 20:30, Francois Baldassari <[email protected]> wrote:
[regarding Michael's M profile NVIC patchset]
Quoted 5 lines
I must be missing something obvious, but I do not have the original email thread (I was not subscribed at the time) and thus am finding it exceedingly difficult to apply the patches using git-am.
I would happily test the patches otherwise.
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).
Otherwise there are a couple of tools: you can use patchwork:
http://patchwork.ozlabs.org/project/qemu-devel/list/
(you need to search for the relevant patches and download the 'mbox' files for them to 'git am' one at a time; unfortunately patchwork doesn't yet know about patch series to let you download a series all at once). Or you can use the 'patches' tool:
https://github.com/aliguori/patches
That needs to be installed locally, but it does know about patch series and it can directly apply a whole series to your local git tree.
For a one-off use the patchwork website is easier, since there's no need to install anything locally. (It's also more forgiving of misformatted patch emails.) If you're going to make a habit of applying patches from the mailing list, the patches tool is easier to use and will repay the up-front effort of downloading it and figuring out its UI.
thanks
-- PMM
Quoted 3 lines · Peter Maydell
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
This branch also has more recent changesets which weren't posted. Some of this will be posted in future (MPU stuff), and some should just be ignored (qtest fumbling).