* [PATCH] enhancement for unmaskable MSI and two cosmetic fixes.
@ 2010-01-26 14:10 Zhang, Xiantao
2010-01-26 14:26 ` Keir Fraser
0 siblings, 1 reply; 5+ messages in thread
From: Zhang, Xiantao @ 2010-01-26 14:10 UTC (permalink / raw)
To: xen-devel@lists.xensource.com, Keir Fraser
[-- Attachment #1: Type: text/plain, Size: 268 bytes --]
0001: Revert 20334, since it doesn't solve the race for all corner cases.
0002: Fixed unmaskable MSI's IRQ migration.
0003: Reduce eoi stack's size to save per-cpu area.
0004: polarity-switch method for EOI message is only used for non-directed-eoi case.
Xiantao
[-- Attachment #2: 0004-polarity-switch-method-only-used-for-non-directed-eoi-case.patch --]
[-- Type: application/octet-stream, Size: 842 bytes --]
# HG changeset patch
# User Xiantao Zhang <xiantao.zhang@intel.com>
# Date 1264506216 -28800
# Node ID 0713e6dddf2a9803ef3511bc9c91012711466a05
# Parent 52f817e38e164520554b6c77f4398ab50f69b8ed
x86: Polarity-switch method only effective in non-directed EOI case.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
diff -r 52f817e38e16 -r 0713e6dddf2a xen/arch/x86/io_apic.c
--- a/xen/arch/x86/io_apic.c Tue Jan 26 19:31:03 2010 +0800
+++ b/xen/arch/x86/io_apic.c Tue Jan 26 19:43:36 2010 +0800
@@ -1529,7 +1529,7 @@ static void mask_and_ack_level_ioapic_ir
!io_apic_level_ack_pending(irq))
move_native_irq(irq);
- if (!(v & (1 << (i & 0x1f)))) {
+ if (!directed_eoi_enabled && !(v & (1 << (i & 0x1f)))) {
atomic_inc(&irq_mis_count);
spin_lock(&ioapic_lock);
__edge_IO_APIC_irq(irq);
[-- Attachment #3: 0003-reduce-eoi-stack-size-in-percpu-area.patch --]
[-- Type: application/octet-stream, Size: 1115 bytes --]
x86: reduce EOI stack's size in per-cpu area.
Only dynamic vectors uses EOI stack, so the size
can be safely reducd to NR_DYNAMIC_VECTORS.
Signed-off-by : Xiantao Zhang <xiantao.zhang@intel.com>
diff -r 0713e6dddf2a xen/arch/x86/irq.c
--- a/xen/arch/x86/irq.c Tue Jan 26 19:43:36 2010 +0800
+++ b/xen/arch/x86/irq.c Tue Jan 26 19:48:27 2010 +0800
@@ -753,8 +753,8 @@ struct pending_eoi {
u32 vector:8; /* vector awaiting EOI */
};
-static DEFINE_PER_CPU(struct pending_eoi, pending_eoi[NR_VECTORS]);
-#define pending_eoi_sp(p) ((p)[NR_VECTORS-1].vector)
+static DEFINE_PER_CPU(struct pending_eoi, pending_eoi[NR_DYNAMIC_VECTORS]);
+#define pending_eoi_sp(p) ((p)[NR_DYNAMIC_VECTORS-1].vector)
static inline void set_pirq_eoi(struct domain *d, unsigned int irq)
{
@@ -816,7 +816,7 @@ static void __do_IRQ_guest(int irq)
{
sp = pending_eoi_sp(peoi);
ASSERT((sp == 0) || (peoi[sp-1].vector < vector));
- ASSERT(sp < (NR_VECTORS-1));
+ ASSERT(sp < (NR_DYNAMIC_VECTORS-1));
peoi[sp].irq = irq;
peoi[sp].vector = vector;
peoi[sp].ready = 0;
[-- Attachment #4: 0002-direct-clear-eoi-once-guest-irq-migration.patch --]
[-- Type: application/octet-stream, Size: 1347 bytes --]
# HG changeset patch
# User Xiantao Zhang <xiantao.zhang@intel.com>
# Date 1264505463 -28800
# Node ID 52f817e38e164520554b6c77f4398ab50f69b8ed
# Parent 416778b574301cd50e376f3e48b5e45384f02621
x86: Directly clear all pending EOIs once MSI info changed
As to unmaskable MSI, its deferred EOI policy only targets
for avoiding IRQ storm. It should be safe to clear pending
EOIs in advance when guest irq migration occurs, because next
interrupt's EOI write is still deferred, and also can avoid
storm.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
diff -r 416778b57430 -r 52f817e38e16 xen/drivers/passthrough/io.c
--- a/xen/drivers/passthrough/io.c Tue Jan 26 19:06:03 2010 +0800
+++ b/xen/drivers/passthrough/io.c Tue Jan 26 19:31:03 2010 +0800
@@ -197,6 +197,8 @@ int pt_irq_create_bind_vtd(
/* if pirq is already mapped as vmsi, update the guest data/addr */
if ( hvm_irq_dpci->mirq[pirq].gmsi.gvec != pt_irq_bind->u.msi.gvec ||
hvm_irq_dpci->mirq[pirq].gmsi.gflags != pt_irq_bind->u.msi.gflags) {
+ /* Directly clear pending EOIs before enabling new MSI info. */
+ pirq_guest_eoi(d, pirq);
hvm_irq_dpci->mirq[pirq].gmsi.gvec = pt_irq_bind->u.msi.gvec;
hvm_irq_dpci->mirq[pirq].gmsi.gflags = pt_irq_bind->u.msi.gflags;
[-- Attachment #5: 0001-revert-cset-20334.patch --]
[-- Type: application/octet-stream, Size: 5559 bytes --]
# HG changeset patch
# User Xiantao Zhang <xiantao.zhang@intel.com>
# Date 1264503963 -28800
# Node ID 416778b574301cd50e376f3e48b5e45384f02621
# Parent 712fa94aaf173ba842f3df3b8138f68d73b9ec1c
x86: Revert Cset #20334
Recording old MSI info doesn't solve all the corner cases
when guest's irq migration occurs.
Signed-off-by : Xiantao Zhang <xiantao.zhang@intel.com>
diff -r 712fa94aaf17 -r 416778b57430 xen/arch/x86/hvm/vmsi.c
--- a/xen/arch/x86/hvm/vmsi.c Tue Jan 26 19:04:15 2010 +0800
+++ b/xen/arch/x86/hvm/vmsi.c Tue Jan 26 19:06:03 2010 +0800
@@ -92,11 +92,8 @@ int vmsi_deliver(struct domain *d, int p
case dest_LowestPrio:
{
target = vlapic_lowest_prio(d, NULL, 0, dest, dest_mode);
- if ( target != NULL ) {
+ if ( target != NULL )
vmsi_inj_irq(d, target, vector, trig_mode, delivery_mode);
- hvm_irq_dpci->mirq[pirq].gmsi.old_gvec =
- hvm_irq_dpci->mirq[pirq].gmsi.gvec;
- }
else
HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "null round robin: "
"vector=%x delivery_mode=%x\n",
@@ -109,12 +106,9 @@ int vmsi_deliver(struct domain *d, int p
{
for_each_vcpu ( d, v )
if ( vlapic_match_dest(vcpu_vlapic(v), NULL,
- 0, dest, dest_mode) ) {
+ 0, dest, dest_mode) )
vmsi_inj_irq(d, vcpu_vlapic(v),
vector, trig_mode, delivery_mode);
- hvm_irq_dpci->mirq[pirq].gmsi.old_gvec =
- hvm_irq_dpci->mirq[pirq].gmsi.gvec;
- }
break;
}
diff -r 712fa94aaf17 -r 416778b57430 xen/drivers/passthrough/io.c
--- a/xen/drivers/passthrough/io.c Tue Jan 26 19:04:15 2010 +0800
+++ b/xen/drivers/passthrough/io.c Tue Jan 26 19:06:03 2010 +0800
@@ -164,9 +164,7 @@ int pt_irq_create_bind_vtd(
{
hvm_irq_dpci->mirq[pirq].flags = HVM_IRQ_DPCI_MACH_MSI |
HVM_IRQ_DPCI_GUEST_MSI;
- hvm_irq_dpci->mirq[pirq].gmsi.old_gvec = pt_irq_bind->u.msi.gvec;
hvm_irq_dpci->mirq[pirq].gmsi.gvec = pt_irq_bind->u.msi.gvec;
- hvm_irq_dpci->mirq[pirq].gmsi.old_gflags = pt_irq_bind->u.msi.gflags;
hvm_irq_dpci->mirq[pirq].gmsi.gflags = pt_irq_bind->u.msi.gflags;
/* bind after hvm_irq_dpci is setup to avoid race with irq handler*/
rc = pirq_guest_bind(d->vcpu[0], pirq, 0);
@@ -180,8 +178,6 @@ int pt_irq_create_bind_vtd(
{
hvm_irq_dpci->mirq[pirq].gmsi.gflags = 0;
hvm_irq_dpci->mirq[pirq].gmsi.gvec = 0;
- hvm_irq_dpci->mirq[pirq].gmsi.old_gvec = 0;
- hvm_irq_dpci->mirq[pirq].gmsi.old_gflags = 0;
hvm_irq_dpci->mirq[pirq].flags = 0;
clear_bit(pirq, hvm_irq_dpci->mapping);
spin_unlock(&d->event_lock);
@@ -200,11 +196,8 @@ int pt_irq_create_bind_vtd(
/* if pirq is already mapped as vmsi, update the guest data/addr */
if ( hvm_irq_dpci->mirq[pirq].gmsi.gvec != pt_irq_bind->u.msi.gvec ||
- hvm_irq_dpci->mirq[pirq].gmsi.gflags != pt_irq_bind->u.msi.gflags) {
- hvm_irq_dpci->mirq[pirq].gmsi.old_gvec =
- hvm_irq_dpci->mirq[pirq].gmsi.gvec;
- hvm_irq_dpci->mirq[pirq].gmsi.old_gflags =
- hvm_irq_dpci->mirq[pirq].gmsi.gflags;
+ hvm_irq_dpci->mirq[pirq].gmsi.gflags != pt_irq_bind->u.msi.gflags) {
+
hvm_irq_dpci->mirq[pirq].gmsi.gvec = pt_irq_bind->u.msi.gvec;
hvm_irq_dpci->mirq[pirq].gmsi.gflags = pt_irq_bind->u.msi.gflags;
}
@@ -435,21 +428,14 @@ void hvm_dpci_msi_eoi(struct domain *d,
pirq = find_next_bit(hvm_irq_dpci->mapping, d->nr_pirqs, pirq + 1) )
{
if ( (!(hvm_irq_dpci->mirq[pirq].flags & HVM_IRQ_DPCI_MACH_MSI)) ||
- (hvm_irq_dpci->mirq[pirq].gmsi.gvec != vector &&
- hvm_irq_dpci->mirq[pirq].gmsi.old_gvec != vector) )
+ (hvm_irq_dpci->mirq[pirq].gmsi.gvec != vector) )
continue;
- if ( hvm_irq_dpci->mirq[pirq].gmsi.gvec == vector ) {
- dest = hvm_irq_dpci->mirq[pirq].gmsi.gflags & VMSI_DEST_ID_MASK;
- dest_mode = !!(hvm_irq_dpci->mirq[pirq].gmsi.gflags & VMSI_DM_MASK);
- } else {
- dest = hvm_irq_dpci->mirq[pirq].gmsi.old_gflags & VMSI_DEST_ID_MASK;
- dest_mode = !!(hvm_irq_dpci->mirq[pirq].gmsi.old_gflags & VMSI_DM_MASK);
- }
+ dest = hvm_irq_dpci->mirq[pirq].gmsi.gflags & VMSI_DEST_ID_MASK;
+ dest_mode = !!(hvm_irq_dpci->mirq[pirq].gmsi.gflags & VMSI_DM_MASK);
if ( vlapic_match_dest(vcpu_vlapic(current), NULL, 0, dest, dest_mode) )
break;
}
-
if ( pirq < d->nr_pirqs )
__msi_pirq_eoi(d, pirq);
spin_unlock(&d->event_lock);
diff -r 712fa94aaf17 -r 416778b57430 xen/include/xen/hvm/irq.h
--- a/xen/include/xen/hvm/irq.h Tue Jan 26 19:04:15 2010 +0800
+++ b/xen/include/xen/hvm/irq.h Tue Jan 26 19:06:03 2010 +0800
@@ -58,10 +58,8 @@ struct dev_intx_gsi_link {
#define GLFAGS_SHIFT_TRG_MODE 15
struct hvm_gmsi_info {
- uint16_t gvec;
- uint16_t old_gvec;
+ uint32_t gvec;
uint32_t gflags;
- uint32_t old_gflags;
int dest_vcpu_id; /* -1 :multi-dest, non-negative: dest_vcpu_id */
};
[-- Attachment #6: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] enhancement for unmaskable MSI and two cosmetic fixes.
2010-01-26 14:10 [PATCH] enhancement for unmaskable MSI and two cosmetic fixes Zhang, Xiantao
@ 2010-01-26 14:26 ` Keir Fraser
2010-01-26 14:35 ` Zhang, Xiantao
0 siblings, 1 reply; 5+ messages in thread
From: Keir Fraser @ 2010-01-26 14:26 UTC (permalink / raw)
To: Zhang, Xiantao, xen-devel@lists.xensource.com
Are these essential for 4.0.0? I've just tagged -rc2, so they've missed
that.
-- Keir
On 26/01/2010 14:10, "Zhang, Xiantao" <xiantao.zhang@intel.com> wrote:
> 0001: Revert 20334, since it doesn't solve the race for all corner cases.
> 0002: Fixed unmaskable MSI's IRQ migration.
> 0003: Reduce eoi stack's size to save per-cpu area.
> 0004: polarity-switch method for EOI message is only used for non-directed-eoi
> case.
> Xiantao
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] enhancement for unmaskable MSI and two cosmetic fixes.
2010-01-26 14:26 ` Keir Fraser
@ 2010-01-26 14:35 ` Zhang, Xiantao
2010-01-26 15:01 ` Keir Fraser
0 siblings, 1 reply; 5+ messages in thread
From: Zhang, Xiantao @ 2010-01-26 14:35 UTC (permalink / raw)
To: Keir Fraser, xen-devel@lists.xensource.com
Yeah, at least we have to apply the first two to fix a bug related to unmaskable MSI.
Xiantao
-----Original Message-----
From: Keir Fraser [mailto:keir.fraser@eu.citrix.com]
Sent: Tuesday, January 26, 2010 10:26 PM
To: Zhang, Xiantao; xen-devel@lists.xensource.com
Subject: Re: [PATCH] enhancement for unmaskable MSI and two cosmetic fixes.
Are these essential for 4.0.0? I've just tagged -rc2, so they've missed
that.
-- Keir
On 26/01/2010 14:10, "Zhang, Xiantao" <xiantao.zhang@intel.com> wrote:
> 0001: Revert 20334, since it doesn't solve the race for all corner cases.
> 0002: Fixed unmaskable MSI's IRQ migration.
> 0003: Reduce eoi stack's size to save per-cpu area.
> 0004: polarity-switch method for EOI message is only used for non-directed-eoi
> case.
> Xiantao
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] enhancement for unmaskable MSI and two cosmetic fixes.
2010-01-26 14:35 ` Zhang, Xiantao
@ 2010-01-26 15:01 ` Keir Fraser
2010-01-26 15:23 ` Zhang, Xiantao
0 siblings, 1 reply; 5+ messages in thread
From: Keir Fraser @ 2010-01-26 15:01 UTC (permalink / raw)
To: Zhang, Xiantao, xen-devel@lists.xensource.com
Is patch #3 even safe? Looks like if a CPU somehow got all dynamic vectors
stacked up, it would overflow into the stackpointer at the end of the array.
-- Keir
On 26/01/2010 14:35, "Zhang, Xiantao" <xiantao.zhang@intel.com> wrote:
> Yeah, at least we have to apply the first two to fix a bug related to
> unmaskable MSI.
> Xiantao
>
> -----Original Message-----
> From: Keir Fraser [mailto:keir.fraser@eu.citrix.com]
> Sent: Tuesday, January 26, 2010 10:26 PM
> To: Zhang, Xiantao; xen-devel@lists.xensource.com
> Subject: Re: [PATCH] enhancement for unmaskable MSI and two cosmetic fixes.
>
> Are these essential for 4.0.0? I've just tagged -rc2, so they've missed
> that.
>
> -- Keir
>
> On 26/01/2010 14:10, "Zhang, Xiantao" <xiantao.zhang@intel.com> wrote:
>
>> 0001: Revert 20334, since it doesn't solve the race for all corner cases.
>> 0002: Fixed unmaskable MSI's IRQ migration.
>> 0003: Reduce eoi stack's size to save per-cpu area.
>> 0004: polarity-switch method for EOI message is only used for
>> non-directed-eoi
>> case.
>> Xiantao
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] enhancement for unmaskable MSI and two cosmetic fixes.
2010-01-26 15:01 ` Keir Fraser
@ 2010-01-26 15:23 ` Zhang, Xiantao
0 siblings, 0 replies; 5+ messages in thread
From: Zhang, Xiantao @ 2010-01-26 15:23 UTC (permalink / raw)
To: Keir Fraser, xen-devel@lists.xensource.com
No, it is also safe even so .The dynamic vector IRQ_MOVE_CLEANUP_VECTOR is used for cleanup vector when IRQ migration and its EOI is never stacked, so only NR_DYNAMIC_VECTORS -1 is really used, and the last array cell is always safe to store stack pointer.
Xiantao
-----Original Message-----
From: Keir Fraser [mailto:keir.fraser@eu.citrix.com]
Sent: Tuesday, January 26, 2010 11:02 PM
To: Zhang, Xiantao; xen-devel@lists.xensource.com
Subject: Re: [PATCH] enhancement for unmaskable MSI and two cosmetic fixes.
Is patch #3 even safe? Looks like if a CPU somehow got all dynamic vectors
stacked up, it would overflow into the stackpointer at the end of the array.
-- Keir
On 26/01/2010 14:35, "Zhang, Xiantao" <xiantao.zhang@intel.com> wrote:
> Yeah, at least we have to apply the first two to fix a bug related to
> unmaskable MSI.
> Xiantao
>
> -----Original Message-----
> From: Keir Fraser [mailto:keir.fraser@eu.citrix.com]
> Sent: Tuesday, January 26, 2010 10:26 PM
> To: Zhang, Xiantao; xen-devel@lists.xensource.com
> Subject: Re: [PATCH] enhancement for unmaskable MSI and two cosmetic fixes.
>
> Are these essential for 4.0.0? I've just tagged -rc2, so they've missed
> that.
>
> -- Keir
>
> On 26/01/2010 14:10, "Zhang, Xiantao" <xiantao.zhang@intel.com> wrote:
>
>> 0001: Revert 20334, since it doesn't solve the race for all corner cases.
>> 0002: Fixed unmaskable MSI's IRQ migration.
>> 0003: Reduce eoi stack's size to save per-cpu area.
>> 0004: polarity-switch method for EOI message is only used for
>> non-directed-eoi
>> case.
>> Xiantao
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-01-26 15:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-26 14:10 [PATCH] enhancement for unmaskable MSI and two cosmetic fixes Zhang, Xiantao
2010-01-26 14:26 ` Keir Fraser
2010-01-26 14:35 ` Zhang, Xiantao
2010-01-26 15:01 ` Keir Fraser
2010-01-26 15:23 ` Zhang, Xiantao
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.