xen/arm: implement GICD_ICACTIVER read/write
PATCH 1/1 xen/arm: implement GICD_ICACTIVER read/write
Implement GICD_ICACTIVER and GICD_ISACTIVER reads by looking for the GIC_IRQ_GUEST_ACTIVE bit in the relevant struct pending_irq. However given that the pending to active transaction for irqs in LRs in done in hardware, the GIC_IRQ_GUEST_ACTIVE bit might be out of date. We'll have to live with that.
Implement GICD_ICACTIVER writes by checking the state of the irq in our
queues: if the irq is present in an LR, remove the hardware ACTIVE bit. If the irq is present in an LR of another vcpu, send an IPI. Set the GIC_IRQ_GUEST_DEACTIVATE bit to tell the receiving vcpu that the active bit needs to be deactivated.
--- xen/arch/arm/gic.c | 40 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic-v2.c | 45 ++++++++++++++++++++++++++++++++++++++------ xen/arch/arm/vgic-v3.c | 44 ++++++++++++++++++++++++++++++++++++++----- xen/include/asm-arm/gic.h | 1 + xen/include/asm-arm/vgic.h | 4 ++++ 5 files changed, 123 insertions(+), 11 deletions(-)
xen/arch/arm/gic.c +40 -0
@@ -414,6 +414,15 @@ static void gic_update_one_lr(struct vcpu *v, int i) gic_hw_ops->read_lr (i, &lr_val); irq = lr_val.virq; p =irq_to_pending (v, irq); + +if (test_and_clear_bit (GIC_IRQ_GUEST_DEACTIVATE , &p->status) && + (lr_val.state &GICH_LR_ACTIVE ) ) + { +clear_bit (GIC_IRQ_GUEST_ACTIVE , &p->status); + lr_val.state &= ~GICH_LR_ACTIVE ; + gic_hw_ops->write_lr (i, &lr_val); + } +if ( lr_val.state &GICH_LR_ACTIVE ) {set_bit (GIC_IRQ_GUEST_ACTIVE , &p->status);
@@ -489,6 +498,37 @@ void gic_clear_lrs(struct vcpu *v)spin_unlock_irqrestore (&v->arch.vgic.lock, flags); } +/* called with rank lock held */ +void gic_deactivate_irq (struct vcpu *v,unsigned int irq) +{ +unsigned long flags; +struct pending_irq *p; +struct vcpu *v_target = v->domain->arch.vgic.handler->get_target_vcpu (v, irq); + +spin_lock_irqsave (&v_target->arch.vgic.lock, flags); + + p =irq_to_pending (v_target, irq); +/* the interrupt is not even in an LR */ +if (list_empty (&p->inflight) || !list_empty (&p->lr_queue) ) + { +spin_unlock_irqrestore (&v_target->arch.vgic.lock, flags); +return ; + } + +/* it is in an LR, let's check */ +set_bit (GIC_IRQ_GUEST_DEACTIVATE , &p->status); +if ( v_target == current ) + { +gic_update_one_lr (v_target, p->lr); +spin_unlock_irqrestore (&v_target->arch.vgic.lock, flags); + }else { +spin_unlock_irqrestore (&v_target->arch.vgic.lock, flags); +vcpu_unblock (v_target); +if (v_target->is_running ) +smp_send_event_check_mask (cpumask_of (v_target->processor)); + } +} +static void gic_restore_pending_irqs (struct vcpu *v) {int lr =0 ;
xen/arch/arm/vgic-v2.c +39 -6
58 lines not on this page · raw message
xen/arch/arm/vgic-v3.c +39 -5
57 lines not on this page · raw message
xen/include/asm-arm/gic.h +1 -0
@@ -287,6 +287,7 @@ extern unsigned int gic_number_lines(void);int gic_irq_xlate (const u32 *intspec,unsigned int intsize,unsigned int *out_hwirq,unsigned int *out_type);void gic_clear_lrs (struct vcpu *v); +void gic_deactivate_irq (struct vcpu *v,unsigned int irq);struct gic_info {/* GIC version */
xen/include/asm-arm/vgic.h +4 -0
@@ -59,12 +59,16 @@ struct pending_irq* vcpu while it is still inflight and on an GICH_LR register on the * old vcpu. * +* GIC_IRQ_GUEST_DEACTIVATE: an explicit deactivation request has +* been made by the guest (for example writing to GICD_ICACTIVER). +* */ #define GIC_IRQ_GUEST_QUEUED 0#define GIC_IRQ_GUEST_ACTIVE 1#define GIC_IRQ_GUEST_VISIBLE 2#define GIC_IRQ_GUEST_ENABLED 3#define GIC_IRQ_GUEST_MIGRATING 4 +#define GIC_IRQ_GUEST_DEACTIVATE 5unsigned long status;struct irq_desc *desc;/* only set it the irq corresponds to a physical irq */ unsigned int irq;
Signature · 1 line
1.7.10.4
Quoted 6 lines · Stefano Stabellini
Implement
GICD_ICACTIVERandGICD_ISACTIVERreads by looking for theGIC_IRQ_GUEST_ACTIVEbit in the relevant structpending_irq. However given that the pending to active transaction for irqs in LRs in done in hardware, theGIC_IRQ_GUEST_ACTIVEbit might be out of date. We'll have to live with that.
Quoted 7 lines
Implement
GICD_ICACTIVERwrites by checking the state of the irq in our
queues: if the irq is present in an LR, remove the hardware ACTIVE bit. If the irq is present in an LR of another vcpu, send an IPI. Set theGIC_IRQ_GUEST_DEACTIVATEbit to tell the receiving vcpu that the active bit needs to be deactivated.Signed-off-by Stefano Stabellini <[email protected]>
Quoted 227 lines
--- xen/arch/arm/gic.c | 40 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic-v2.c | 45 ++++++++++++++++++++++++++++++++++++++------ xen/arch/arm/vgic-v3.c | 44 ++++++++++++++++++++++++++++++++++++++----- xen/include/asm-arm/gic.h | 1 + xen/include/asm-arm/vgic.h | 4 ++++ 5 files changed, 123 insertions(+), 11 deletions(-)xen/arch/arm/gic.c +40
-0@@ -414,6 +414,15 @@ static void gic_update_one_lr(struct vcpu *v, int i) gic_hw_ops->read_lr (i, &lr_val); irq = lr_val.virq; p =irq_to_pending (v, irq); + +if (test_and_clear_bit (GIC_IRQ_GUEST_DEACTIVATE , &p->status) && + (lr_val.state &GICH_LR_ACTIVE ) ) + { +clear_bit (GIC_IRQ_GUEST_ACTIVE , &p->status); + lr_val.state &= ~GICH_LR_ACTIVE ; + gic_hw_ops->write_lr (i, &lr_val); + } +if ( lr_val.state &GICH_LR_ACTIVE ) {set_bit (GIC_IRQ_GUEST_ACTIVE , &p->status);@@ -489,6 +498,37 @@ void gic_clear_lrs(struct vcpu *v)spin_unlock_irqrestore (&v->arch.vgic.lock, flags); } +/* called with rank lock held */ +void gic_deactivate_irq (struct vcpu *v,unsigned int irq) +{ +unsigned long flags; +struct pending_irq *p; +struct vcpu *v_target = v->domain->arch.vgic.handler->get_target_vcpu (v, irq); + +spin_lock_irqsave (&v_target->arch.vgic.lock, flags); + + p =irq_to_pending (v_target, irq); +/* the interrupt is not even in an LR */ +if (list_empty (&p->inflight) || !list_empty (&p->lr_queue) ) + { +spin_unlock_irqrestore (&v_target->arch.vgic.lock, flags); +return ; + } + +/* it is in an LR, let's check */ +set_bit (GIC_IRQ_GUEST_DEACTIVATE , &p->status); +if ( v_target == current ) + { +gic_update_one_lr (v_target, p->lr); +spin_unlock_irqrestore (&v_target->arch.vgic.lock, flags); + }else { +spin_unlock_irqrestore (&v_target->arch.vgic.lock, flags); +vcpu_unblock (v_target); +if (v_target->is_running ) +smp_send_event_check_mask (cpumask_of (v_target->processor)); + } +} +static void gic_restore_pending_irqs (struct vcpu *v) {int lr =0 ;xen/arch/arm/vgic-v2.c +39
-6@@ -126,8 +126,31 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info,/* Read the active status of an IRQ via GICD is not supported */ case GICD_ISACTIVER ... GICD_ISACTIVERN: case GICD_ICACTIVER ... GICD_ICACTIVERN: - goto read_as_zero; - + { +unsigned int i =0 , irq =0 ; +struct pending_irq *p; +if ( dabt.size !=DABT_WORD ) goto bad_width; + rank =vgic_rank_offset (v,1 , gicd_reg -GICD_ICACTIVER ,DABT_WORD ); +if ( rank ==NULL ) goto read_as_zero; +vgic_lock_rank (v, rank, flags); + *r =0 ; + irq = (gicd_reg -GICD_ICACTIVER ) <<3 ; +for (i =0 ; i <32 ; i++) + { + p =irq_to_pending (v, i + irq); +/* +* This information is likely out of date because we don't +* actually know which interrupts have become ACTIVE from +* PENDING in the LRs of other processors at it happens +* transparently in hardware. We would have to interrupt +* all other running vcpus to get an accurate snapshot. +* Let's not do that. +*/ + *r |=test_bit (GIC_IRQ_GUEST_ACTIVE , &p->status) ? (1 << i) :0 ; + } +vgic_unlock_rank (v, rank, flags); +return 1 ; + } case GICD_ITARGETSR ... GICD_ITARGETSRN:if ( dabt.size !=DABT_BYTE && dabt.size !=DABT_WORD ) goto bad_width; rank =vgic_rank_offset (v,8 , gicd_reg -GICD_ITARGETSR ,DABT_WORD );@@ -332,11 +355,21 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info,return 0 ; case GICD_ICACTIVER ... GICD_ICACTIVERN: + { +unsigned int i =0 , irq;if ( dabt.size !=DABT_WORD ) goto bad_width; -printk (XENLOG_G_ERR -"%pv: vGICD: unhandled word write %#" PRIregister" to ICACTIVER%d\n" , - v, r, gicd_reg -GICD_ICACTIVER ); -return 0 ; + rank =vgic_rank_offset (v,1 , gicd_reg -GICD_ICACTIVER ,DABT_WORD ); +if ( rank ==NULL ) goto write_ignore; +vgic_lock_rank (v, rank, flags); + irq = (gicd_reg -GICD_ICACTIVER ) <<3 ; +while ( (i =find_next_bit (&r,32 , i)) <32 ) + { +gic_deactivate_irq (v, i + irq); + i++; + } +vgic_unlock_rank (v, rank, flags); +return 1 ; + } case GICD_ITARGETSR ... GICD_ITARGETSR + 7:/* SGI/PPI target is read only */ xen/arch/arm/vgic-v3.c +39
-5@@ -325,7 +325,31 @@ static int __vgic_v3_distr_common_mmio_read(const char *name, struct vcpu *v,/* Read the active status of an IRQ via GICD/GICR is not supported */ case GICD_ISACTIVER ... GICD_ISACTIVERN: case GICD_ICACTIVER ... GICD_ICACTIVERN: - goto read_as_zero; + { +unsigned int i =0 , irq =0 ; +struct pending_irq *p; +if ( dabt.size !=DABT_WORD ) goto bad_width; + rank =vgic_rank_offset (v,1 , reg -GICD_ICACTIVER ,DABT_WORD ); +if ( rank ==NULL ) goto read_as_zero; +vgic_lock_rank (v, rank, flags); + *r =0 ; + irq = (reg -GICD_ICACTIVER ) <<3 ; +for (i =0 ; i <32 ; i++) + { + p =irq_to_pending (v, i + irq); +/* +* This information is likely out of date because we don't +* actually know which interrupts have become ACTIVE from +* PENDING in the LRs of other processors at it happens +* transparently in hardware. We would have to interrupt +* all other running vcpus to get an accurate snapshot. +* Let's not do that. +*/ + *r |=test_bit (GIC_IRQ_GUEST_ACTIVE , &p->status) ? (1 << i) :0 ; + } +vgic_unlock_rank (v, rank, flags); +return 1 ; + } case GICD_IPRIORITYR ... GICD_IPRIORITYRN:if ( dabt.size !=DABT_BYTE && dabt.size !=DABT_WORD ) goto bad_width;@@ -421,11 +445,21 @@ static int __vgic_v3_distr_common_mmio_write(const char *name, struct vcpu *v,return 0 ; case GICD_ICACTIVER ... GICD_ICACTIVERN: + { +unsigned int i =0 , irq;if ( dabt.size !=DABT_WORD ) goto bad_width; -printk (XENLOG_G_ERR -"%pv: %s: unhandled word write %#" PRIregister" to ICACTIVER%d\n" , - v, name, r, reg -GICD_ICACTIVER ); -return 0 ; + rank =vgic_rank_offset (v,1 , reg -GICD_ICACTIVER ,DABT_WORD ); +if ( rank ==NULL ) goto write_ignore; +vgic_lock_rank (v, rank, flags); + irq = (reg -GICD_ICACTIVER ) <<3 ; +while ( (i =find_next_bit (&r,32 , i)) <32 ) + { +gic_deactivate_irq (v, i + irq); + i++; + } +vgic_unlock_rank (v, rank, flags); +return 1 ; + } case GICD_IPRIORITYR ... GICD_IPRIORITYRN:if ( dabt.size !=DABT_BYTE && dabt.size !=DABT_WORD ) goto bad_width;xen/include/asm-arm/gic.h +1
-0@@ -287,6 +287,7 @@ extern unsigned int gic_number_lines(void);int gic_irq_xlate (const u32 *intspec,unsigned int intsize,unsigned int *out_hwirq,unsigned int *out_type);void gic_clear_lrs (struct vcpu *v); +void gic_deactivate_irq (struct vcpu *v,unsigned int irq);struct gic_info {/* GIC version */ xen/include/asm-arm/vgic.h +4
-0@@ -59,12 +59,16 @@ struct pending_irq* vcpu while it is still inflight and on an GICH_LR register on the * old vcpu. * +* GIC_IRQ_GUEST_DEACTIVATE: an explicit deactivation request has +* been made by the guest (for example writing to GICD_ICACTIVER). +* */ #define GIC_IRQ_GUEST_QUEUED 0#define GIC_IRQ_GUEST_ACTIVE 1#define GIC_IRQ_GUEST_VISIBLE 2#define GIC_IRQ_GUEST_ENABLED 3#define GIC_IRQ_GUEST_MIGRATING 4 +#define GIC_IRQ_GUEST_DEACTIVATE 5unsigned long status;struct irq_desc *desc;/* only set it the irq corresponds to a physical irq */ unsigned int irq;
Signature · 1 line
Shannon
Hi Stefano,
Quoted 5 lines · Stefano Stabellini
Implement
GICD_ICACTIVERandGICD_ISACTIVERreads by looking for theGIC_IRQ_GUEST_ACTIVEbit in the relevant structpending_irq. However given that the pending to active transaction for irqs in LRs in done in hardware, theGIC_IRQ_GUEST_ACTIVEbit might be out of date. We'll have to live with that.
Is it acceptable? The guest may rely on it to save the active state of an IRQ.
Quoted 5 lines
Implement
GICD_ICACTIVERwrites by checking the state of the irq in our
queues: if the irq is present in an LR, remove the hardware ACTIVE bit. If the irq is present in an LR of another vcpu, send an IPI. Set theGIC_IRQ_GUEST_DEACTIVATEbit to tell the receiving vcpu that the active bit needs to be deactivated.
I would explain that the write bits of GICD_IACTIVER is left unimplemented.
Quoted 14 lines
Signed-off-by Stefano Stabellini <[email protected]>--- xen/arch/arm/gic.c | 40 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic-v2.c | 45 ++++++++++++++++++++++++++++++++++++++------ xen/arch/arm/vgic-v3.c | 44 ++++++++++++++++++++++++++++++++++++++----- xen/include/asm-arm/gic.h | 1 + xen/include/asm-arm/vgic.h | 4 ++++ 5 files changed, 123 insertions(+), 11 deletions(-)xen/arch/arm/gic.c +0
-0
xen/arch/arm/gic.c static void gic_update_one_lr(struct vcpu *v, int i) · line 423
Quoted 10 lines
xen/arch/arm/gic.c +7
-0@@ -414,6 +414,15 @@ static void gic_update_one_lr(struct vcpu *v, int i) gic_hw_ops->read_lr (i, &lr_val); irq = lr_val.virq; p =irq_to_pending (v, irq); + +if (test_and_clear_bit (GIC_IRQ_GUEST_DEACTIVATE , &p->status) && + (lr_val.state &GICH_LR_ACTIVE ) ) + { +clear_bit (GIC_IRQ_GUEST_ACTIVE , &p->status); + lr_val.state &= ~GICH_LR_ACTIVE ; + gic_hw_ops->write_lr (i, &lr_val);
You also have to handle the deactivation of an hardware IRQ route to a guest.
xen/arch/arm/gic.c void gic_clear_lrs(struct vcpu *v) · line 501
Quoted 10 lines
xen/arch/arm/gic.c +3
-0+ } +if ( lr_val.state &GICH_LR_ACTIVE ) {set_bit (GIC_IRQ_GUEST_ACTIVE , &p->status);@@ -489,6 +498,37 @@ void gic_clear_lrs(struct vcpu *v)spin_unlock_irqrestore (&v->arch.vgic.lock, flags); } +/* called with rank lock held */
Please add an ASSERT in the code to check this assumption.
xen/arch/arm/gic.c void gic_clear_lrs(struct vcpu *v) · line 512
Quoted 11 lines
xen/arch/arm/gic.c +11
-0+void gic_deactivate_irq (struct vcpu *v,unsigned int irq) +{ +unsigned long flags; +struct pending_irq *p; +struct vcpu *v_target = v->domain->arch.vgic.handler->get_target_vcpu (v, irq); + +spin_lock_irqsave (&v_target->arch.vgic.lock, flags); + + p =irq_to_pending (v_target, irq); +/* the interrupt is not even in an LR */ +if (list_empty (&p->inflight) || !list_empty (&p->lr_queue) )
I think this can be simplified by testing p->lr == GIC_INVALID_LR
Quoted 4 lines
xen/arch/arm/gic.c +4
-0+ { +spin_unlock_irqrestore (&v_target->arch.vgic.lock, flags); +return ; + }
xen/arch/arm/gic.c void gic_clear_lrs(struct vcpu *v) · line 526
Quoted 10 lines
xen/arch/arm/gic.c +10
-0+ +/* it is in an LR, let's check */ +set_bit (GIC_IRQ_GUEST_DEACTIVATE , &p->status); +if ( v_target == current ) + { +gic_update_one_lr (v_target, p->lr); +spin_unlock_irqrestore (&v_target->arch.vgic.lock, flags); + }else { +spin_unlock_irqrestore (&v_target->arch.vgic.lock, flags); +vcpu_unblock (v_target);
Why do you need to unblock the vCPU?
Quoted 30 lines
xen/arch/arm/gic.c +5
-0+if (v_target->is_running ) +smp_send_event_check_mask (cpumask_of (v_target->processor)); + } +} +static void gic_restore_pending_irqs (struct vcpu *v) {int lr =0 ;xen/arch/arm/vgic-v2.c +12
-2@@ -126,8 +126,31 @@ static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info,/* Read the active status of an IRQ via GICD is not supported */ case GICD_ISACTIVER ... GICD_ISACTIVERN: case GICD_ICACTIVER ... GICD_ICACTIVERN: - goto read_as_zero; - + { +unsigned int i =0 , irq =0 ; +struct pending_irq *p; +if ( dabt.size !=DABT_WORD ) goto bad_width; + rank =vgic_rank_offset (v,1 , gicd_reg -GICD_ICACTIVER ,DABT_WORD ); +if ( rank ==NULL ) goto read_as_zero; +vgic_lock_rank (v, rank, flags); + *r =0 ; + irq = (gicd_reg -GICD_ICACTIVER ) <<3 ; +for (i =0 ; i <32 ; i++) + { + p =irq_to_pending (v, i + irq);
xen/arch/arm/vgic-v2.c static int vgic_v2_distr_mmio_read(struct vcpu *v, mmio_info_t *info, · line 150
Quoted 10 lines
xen/arch/arm/vgic-v2.c +10
-0+/* +* This information is likely out of date because we don't +* actually know which interrupts have become ACTIVE from +* PENDING in the LRs of other processors at it happens +* transparently in hardware. We would have to interrupt +* all other running vcpus to get an accurate snapshot. +* Let's not do that. +*/ + *r |=test_bit (GIC_IRQ_GUEST_ACTIVE , &p->status) ? (1 << i) :0 ; + }
Rather than duplicating the code twice (vgic-v2 and vgic-v3), could you create a stub function to fetch the value. See vgic_fetch_itargetsr for instance.
Quoted 16 lines
xen/arch/arm/vgic-v2.c +5
-3+vgic_unlock_rank (v, rank, flags); +return 1 ; + } case GICD_ITARGETSR ... GICD_ITARGETSRN:if ( dabt.size !=DABT_BYTE && dabt.size !=DABT_WORD ) goto bad_width; rank =vgic_rank_offset (v,8 , gicd_reg -GICD_ITARGETSR ,DABT_WORD );@@ -332,11 +355,21 @@ static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info,return 0 ; case GICD_ICACTIVER ... GICD_ICACTIVERN: + { +unsigned int i =0 , irq;if ( dabt.size !=DABT_WORD ) goto bad_width; -printk (XENLOG_G_ERR -"%pv: vGICD: unhandled word write %#" PRIregister" to ICACTIVER%d\n" , - v, r, gicd_reg -GICD_ICACTIVER );
xen/arch/arm/vgic-v2.c static int vgic_v2_distr_mmio_write(struct vcpu *v, mmio_info_t *info, · line 369
Quoted 10 lines
xen/arch/arm/vgic-v2.c +9
-1-return 0 ; + rank =vgic_rank_offset (v,1 , gicd_reg -GICD_ICACTIVER ,DABT_WORD ); +if ( rank ==NULL ) goto write_ignore; +vgic_lock_rank (v, rank, flags); + irq = (gicd_reg -GICD_ICACTIVER ) <<3 ; +while ( (i =find_next_bit (&r,32 , i)) <32 ) + { +gic_deactivate_irq (v, i + irq); + i++; + }
Ditto.
Quoted 59 lines
xen/arch/arm/vgic-v2.c +3
-0+vgic_unlock_rank (v, rank, flags); +return 1 ; + } case GICD_ITARGETSR ... GICD_ITARGETSR + 7:/* SGI/PPI target is read only */ xen/arch/arm/vgic-v3.c +32
-5@@ -325,7 +325,31 @@ static int __vgic_v3_distr_common_mmio_read(const char *name, struct vcpu *v,/* Read the active status of an IRQ via GICD/GICR is not supported */ case GICD_ISACTIVER ... GICD_ISACTIVERN: case GICD_ICACTIVER ... GICD_ICACTIVERN: - goto read_as_zero; + { +unsigned int i =0 , irq =0 ; +struct pending_irq *p; +if ( dabt.size !=DABT_WORD ) goto bad_width; + rank =vgic_rank_offset (v,1 , reg -GICD_ICACTIVER ,DABT_WORD ); +if ( rank ==NULL ) goto read_as_zero; +vgic_lock_rank (v, rank, flags); + *r =0 ; + irq = (reg -GICD_ICACTIVER ) <<3 ; +for (i =0 ; i <32 ; i++) + { + p =irq_to_pending (v, i + irq); +/* +* This information is likely out of date because we don't +* actually know which interrupts have become ACTIVE from +* PENDING in the LRs of other processors at it happens +* transparently in hardware. We would have to interrupt +* all other running vcpus to get an accurate snapshot. +* Let's not do that. +*/ + *r |=test_bit (GIC_IRQ_GUEST_ACTIVE , &p->status) ? (1 << i) :0 ; + } +vgic_unlock_rank (v, rank, flags); +return 1 ; + } case GICD_IPRIORITYR ... GICD_IPRIORITYRN:if ( dabt.size !=DABT_BYTE && dabt.size !=DABT_WORD ) goto bad_width;@@ -421,11 +445,21 @@ static int __vgic_v3_distr_common_mmio_write(const char *name, struct vcpu *v,return 0 ; case GICD_ICACTIVER ... GICD_ICACTIVERN: + { +unsigned int i =0 , irq;if ( dabt.size !=DABT_WORD ) goto bad_width; -printk (XENLOG_G_ERR -"%pv: %s: unhandled word write %#" PRIregister" to ICACTIVER%d\n" , - v, name, r, reg -GICD_ICACTIVER ); -return 0 ; + rank =vgic_rank_offset (v,1 , reg -GICD_ICACTIVER ,DABT_WORD ); +if ( rank ==NULL ) goto write_ignore; +vgic_lock_rank (v, rank, flags); + irq = (reg -GICD_ICACTIVER ) <<3 ; +while ( (i =find_next_bit (&r,32 , i)) <32 )
xen/arch/arm/vgic-v3.c static int __vgic_v3_distr_common_mmio_write(const char *name, struct vcpu *v, · line 465
Quoted 10 lines
xen/arch/arm/vgic-v3.c +7
-0+ { +gic_deactivate_irq (v, i + irq); + i++; + } +vgic_unlock_rank (v, rank, flags); +return 1 ; + } case GICD_IPRIORITYR ... GICD_IPRIORITYRN:if ( dabt.size !=DABT_BYTE && dabt.size !=DABT_WORD ) goto bad_width;
Regards,
Signature · 1 line
Julien Grall
Hi Stefano,
Quoted 5 lines · Stefano Stabellini
Implement
GICD_ICACTIVERandGICD_ISACTIVERreads by looking for theGIC_IRQ_GUEST_ACTIVEbit in the relevant structpending_irq. However given that the pending to active transaction for irqs in LRs in done in hardware, theGIC_IRQ_GUEST_ACTIVEbit might be out of date. We'll have to live with that.
Looking to the Linux tree again, I found this commit:
commit 1c7d4dd46ee048afe19e1294634df6fa66862519
Author: Marc Zyngier <[email protected]> Date: Mon Nov 16 19:13:28 2015 +0000
irqchip/gic: Add save/restore of the active state
When using EOImode==1, we may mark interrupts as being forwarded to a virtual machine. In that case, the interrupt is left active while being passed to the VM.
If we suspend the system before the VM has deactivated the interrupt, the active state will be lost (which may be very annoying, as this may result in spurious interrupts and a confused guest).
To avoid this, save and restore the active state together with the rest of the GIC registers.
Link:
http://lkml.kernel.org/r/[email protected]
So, we have to handle properly active/deactivate in order to get suspend/resume working correctly.
Regards,
Signature · 1 line
Julien Grall
Quoted 32 lines · Julien Grall
Hi Stefano,
Quoted 5 lines · Stefano Stabellini
Implement
GICD_ICACTIVERandGICD_ISACTIVERreads by looking for theGIC_IRQ_GUEST_ACTIVEbit in the relevant structpending_irq. However given that the pending to active transaction for irqs in LRs in done in hardware, theGIC_IRQ_GUEST_ACTIVEbit might be out of date. We'll have to live with that.Looking to the Linux tree again, I found this commit:
commit
1c7d4dd46ee048afe19e1294634df6fa66862519Author: Marc Zyngier <[email protected]> Date: Mon Nov 16 19:13:28 2015 +0000irqchip/gic: Add save/restore of the active state
When using EOImode==1, we may mark interrupts as being forwarded to a virtual machine. In that case, the interrupt is left active while being passed to the VM.
If we suspend the system before the VM has deactivated the interrupt, the active state will be lost (which may be very annoying, as this may result in spurious interrupts and a confused guest).
To avoid this, save and restore the active state together with the rest of the GIC registers.
Signed-off-by Marc Zyngier <[email protected]>Cc <[email protected]>Cc Jason Cooper <[email protected]>Cc Russell King <[email protected]>
Quoted 6 lines
Link:
http://lkml.kernel.org/r/[email protected]Signed-off-by Thomas Gleixner <[email protected]>So, we have to handle properly active/deactivate in order to get suspend/resume working correctly.
We won't have any active interrupts: suspending the guest is done in cooperation with the guest kernel (see drivers/xen/manage.c), which will deactive the interrupts. In any case we only have evtchn_irq and the timers.