VMX: Properly handle pi descriptor and per-cpu blocking list
v12 cover VMX: Properly handle pi descriptor and per-cpu blocking list
The current VT-d PI related code may operate incorrectly in the following scenarios:
1. When VT-d PI is enabled, needn't migrate pirq which is using VT-d PI during vCPU migration. Patch [1/7] solves this by introducing a new flag to indicate that the pt-irq is delivered through VT-d PI.
2. Patch [2/7] is to make io.h self-contained. It avoids compile errors after including hvm/vmx/vmcs.h in asm-x86/msi.h and asm-x86/iommu.h. It is a preparation for Patch [3/7].
2. msi_msg_to_remap_entry() is buggy when the live IRTE is in posted format. It wrongly inherits the 'im' field from the live IRTE but updates all the other fileds to remapping format. Patch [3/7] handles this.
3. [4/7] is a cleanup patch
4. When a pCPU is unplugged, and there might be vCPUs on its list. Since the pCPU is offline, those vCPUs might not be woken up again. [5/7] addresses it.
5. IRTE is updated through structure assigment which is unsafe in some cases. To resolve this, Patch [6/7] provides two variants, atomic and non-atomic, to update IRTE. And a bug is raised when we can't meet the caller's atomic requirement.
6. We didn't change the IRTE to remapping format when pt-irq is configurated to have multi-destination vCPUs. Patch [7/7] resolves this problem.
Chao Gao (5):
passthrough: don't migrate pirq when it is delivered through VT-d PI x86/hvm: make io.h self-contained
VT-d: Introduce new fields in msi_desc to track binding with guest
interrupt
VT-d: introduce update_irte to update irte safely passthrough/io: Fall back to remapping interrupt when we can't use
VT-d PI
Feng Wu (2):
VT-d: Some cleanups
VMX: Fixup PI descriptor when cpu is offline
xen/arch/x86/hvm/hvm.c | 3 + xen/arch/x86/hvm/vmx/vmcs.c | 1 + xen/arch/x86/hvm/vmx/vmx.c | 70 +++++++++++ xen/arch/x86/msi.c | 2 + xen/drivers/passthrough/io.c | 73 +++-------- xen/drivers/passthrough/vtd/intremap.c | 220 ++++++++++++++------------------- xen/include/asm-x86/hvm/io.h | 1 + xen/include/asm-x86/hvm/vmx/vmx.h | 1 + xen/include/asm-x86/iommu.h | 4 +- xen/include/asm-x86/msi.h | 5 + xen/include/xen/hvm/irq.h | 1 + 11 files changed, 195 insertions(+), 186 deletions(-)
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v12 1/7 passthrough: don't migrate pirq when it is delivered through VT-d PI
When a vCPU was migrated to another pCPU, pt irqs binded to this vCPU might also need migration as a optimization to reduce IPI between pCPUs. When VT-d PI is enabled, interrupt vector will be recorded to a main memory resident data-structure and a notification whose destination is decided by NDST is generated. NDST is properly adjusted during vCPU migration so pirq directly injected to guest needn't be migrated.
This patch adds a indicator, @posted, to show whether the pt irq is delivered through VT-d PI. Also this patch fixes a bug that hvm_migrate_pirq() accesses pirq_dpci->gmsi.dest_vcpu_id without checking the pirq_dpci's type.
---
v12:
- fix a logic error in fixed delivery case.
v11:
- rename the indicator to 'posted'
- move setting 'posted' field to event lock un-locked region.
v10:
- Newly added.
xen/arch/x86/hvm/hvm.c | 3 +++ xen/drivers/passthrough/io.c | 63 +++++++++----------------------------------- xen/include/xen/hvm/irq.h | 1 + 3 files changed, 17 insertions(+), 50 deletions(-)
xen/arch/x86/hvm/hvm.c +3 -0
@@ -438,6 +438,9 @@ static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci,struct vcpu *v = arg;if ( (pirq_dpci->flags &HVM_IRQ_DPCI_MACH_MSI ) && + (pirq_dpci->flags &HVM_IRQ_DPCI_GUEST_MSI ) && +/* Needn't migrate pirq if this pirq is delivered to guest directly.*/ + (!pirq_dpci->gmsi.posted) && (pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) ) { struct irq_desc *desc =
xen/drivers/passthrough/io.c +13 -50
88 lines not on this page · raw message
xen/include/xen/hvm/irq.h +1 -0
@@ -63,6 +63,7 @@ struct hvm_gmsi_info {uint32_t gvec;uint32_t gflags;int dest_vcpu_id;/* -1 :multi-dest, non-negative: dest_vcpu_id */ +bool posted;/* directly deliver to guest via VT-d PI? */ };struct hvm_girq_dpci_mapping {
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v12 1/7] passthrough: don't migrate pirq when it is delivered through VT-d PI
xen/arch/x86/hvm/hvm.c static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci, · line 445
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +3
-0@@ -438,6 +438,9 @@ static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci,struct vcpu *v = arg;if ( (pirq_dpci->flags &HVM_IRQ_DPCI_MACH_MSI ) && + (pirq_dpci->flags &HVM_IRQ_DPCI_GUEST_MSI ) && +/* Needn't migrate pirq if this pirq is delivered to guest directly.*/ + (!pirq_dpci->gmsi.posted) && (pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) ) {
I don't think I've seen you address Kevin's comment on this for v11, and like Kevin I can't immediately see why the above addition would be correct. Do you perhaps mean
if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) &&
/* Needn't migrate pirq if this pirq is delivered to guest directly.*/
(!pirq_dpci->gmsi.posted ||
<whatever is appropriate here, if anything>) &&
(pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) )Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v12 1/7] passthrough: don't migrate pirq when it is delivered through VT-d PI
Quoted 17 lines · Jan Beulich
xen/arch/x86/hvm/hvm.c static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci, · line 445
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +3
-0@@ -438,6 +438,9 @@ static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci,struct vcpu *v = arg;if ( (pirq_dpci->flags &HVM_IRQ_DPCI_MACH_MSI ) && + (pirq_dpci->flags &HVM_IRQ_DPCI_GUEST_MSI ) && +/* Needn't migrate pirq if this pirq is delivered to guest directly.*/ + (!pirq_dpci->gmsi.posted) && (pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) ) {I don't think I've seen you address Kevin's comment on this for v11, and like Kevin I can't immediately see why the above addition would be correct. Do you perhaps mean
Quoted 5 lines
if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) &&
/* Needn't migrate pirq if this pirq is delivered to guest directly.*/
(!pirq_dpci->gmsi.posted ||
<whatever is appropriate here, if anything>) &&
(pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) )Sorry to Kevin. And thanks to point it out.
But I thought we had discussed this in https://lists.xenproject.org/archives/html/xen-devel/2017-03/msg04383.html. I did think you agreed with me. gmsi is invalid when pirq_dpci is not GUEST_MSI, is there something I have
ignored?
Thanks
Chao
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v12 1/7] passthrough: don't migrate pirq when it is delivered through VT-d PI
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 07.04.17 at 06:07, <[email protected]> wrote:
Cc kevinQuoted 4 lines · Jan Beulich
xen/arch/x86/hvm/hvm.c static int hvm_migrate_pirq(struct domain *d, struct
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +0
-0@@ -438,6 +438,9 @@ static int hvm_migrate_pirq(struct domain *d, struct
hvm_pirq_dpci*pirq_dpci,Quoted 5 lines
xen/arch/x86/hvm/hvm.c static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci,
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +2
-0struct vcpu *v = arg; if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) && + (pirq_dpci->flags & HVM_IRQ_DPCI_GUEST_MSI) && +/* Needn't migrate pirq if this pirq is delivered to guest directly.*/
Quoted 8 lines
xen/arch/x86/hvm/hvm.c static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci, · line 445
Quoted 3 lines
xen/arch/x86/hvm/hvm.c +1
-0+ (!pirq_dpci->gmsi.posted) && (pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) ) {I don't think I've seen you address Kevin's comment on this for v11, and like Kevin I can't immediately see why the above addition would be correct. Do you perhaps mean
Quoted 5 lines
if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) && /* Needn't migrate pirq if this pirq is delivered to guest directly.*/ (!pirq_dpci->gmsi.posted || <whatever is appropriate here, if anything>) && (pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) )
Quoted 6 lines
Sorry to Kevin. And thanks to point it out.
But I thought we had discussed this in
https://lists.xenproject.org/archives/html/xen-devel/2017-03/msg04383.html. I did think you agreed with me.
gmsi is invalid whenpirq_dpciis notGUEST_MSI, is there something I have ignored?
You've been talking about GUEST_PCI there, which I did (and do) agree we can't handle here. So for the purposes of your series, simply adding the gmsi.posted check would be the right thing imo. I don't think I see anything wrong with the ->gmsi accesses here:
The GUEST_PCI code simply doesn't set them, so dest_vcpu_id will still be -1 (from pt_pirq_init()). So I don't see any bug being fixed here with the extra other check you add. If you agree, I can take that line and the commit message sentence out while committing.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v12 1/7] passthrough: don't migrate pirq when it is delivered through VT-d PI
Quoted 36 lines · Jan Beulich
Quoted 29 lines
Quoted 1 line
Quoted 1 line · On 07.04.17 at 06:07, <[email protected]> wrote:
Cc kevinQuoted 4 lines · Jan Beulich
xen/arch/x86/hvm/hvm.c static int hvm_migrate_pirq(struct domain *d, struct
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +0
-0@@ -438,6 +438,9 @@ static int hvm_migrate_pirq(struct domain *d, struct
hvm_pirq_dpci*pirq_dpci,Quoted 5 lines
xen/arch/x86/hvm/hvm.c static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci,
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +2
-0struct vcpu *v = arg; if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) && + (pirq_dpci->flags & HVM_IRQ_DPCI_GUEST_MSI) && +/* Needn't migrate pirq if this pirq is delivered to guest directly.*/
Quoted 8 lines
xen/arch/x86/hvm/hvm.c static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci, · line 445
Quoted 3 lines
xen/arch/x86/hvm/hvm.c +1
-0+ (!pirq_dpci->gmsi.posted) && (pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) ) {I don't think I've seen you address Kevin's comment on this for v11, and like Kevin I can't immediately see why the above addition would be correct. Do you perhaps mean
Quoted 5 lines
if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) && /* Needn't migrate pirq if this pirq is delivered to guest directly.*/ (!pirq_dpci->gmsi.posted || <whatever is appropriate here, if anything>) && (pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) )Quoted 6 lines
Sorry to Kevin. And thanks to point it out.
But I thought we had discussed this in
https://lists.xenproject.org/archives/html/xen-devel/2017-03/msg04383.html. I did think you agreed with me.
gmsi is invalid whenpirq_dpciis notGUEST_MSI, is there something I have ignored?
Quoted 9 lines
You've been talking about
GUEST_PCIthere, which I did (and do) agree we can't handle here. So for the purposes of your series, simply adding the gmsi.posted check would be the right thing imo. I don't think I see anything wrong with the ->gmsi accesses here:
TheGUEST_PCIcode simply doesn't set them, sodest_vcpu_idwill still be -1 (frompt_pirq_init()). So I don't see any bug being fixed here with the extra other check you add. If you agree, I can take that line and the commit message sentence out while committing.
Ok. I admit I said it's bug is wrong. feel free to do what you want.
Thanks
Chao
Quoted 3 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v12 1/7] passthrough: don't migrate pirq when it is delivered through VT-d PI
Quoted 49 lines
Quoted 1 line
Quoted 1 line · On 07.04.17 at 09:23, <[email protected]> wrote:
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 07.04.17 at 06:07, <[email protected]> wrote:
Cc kevinQuoted 4 lines · Jan Beulich
xen/arch/x86/hvm/hvm.c static int hvm_migrate_pirq(struct domain *d, struct
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +0
-0@@ -438,6 +438,9 @@ static int hvm_migrate_pirq(struct domain *d, struct
hvm_pirq_dpci*pirq_dpci,Quoted 5 lines
xen/arch/x86/hvm/hvm.c static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci,
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +2
-0struct vcpu *v = arg; if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) && + (pirq_dpci->flags & HVM_IRQ_DPCI_GUEST_MSI) && +/* Needn't migrate pirq if this pirq is delivered to guest directly.*/
Quoted 4 lines
Quoted 3 lines
xen/arch/x86/hvm/hvm.c +1
-0+ (!pirq_dpci->gmsi.posted) && (pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) ) {Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
I don't think I've seen you address Kevin's comment on this for v11, and like Kevin I can't immediately see why the above addition would be correct. Do you perhaps mean
if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) && /* Needn't migrate pirq if this pirq is delivered to guestdirectly.*/
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
(!pirq_dpci->gmsi.posted || <whatever is appropriate here, if anything>) && (pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) )Sorry to Kevin. And thanks to point it out.
But I thought we had discussed this in
https://lists.xenproject.org/archives/html/xen-devel/2017-03/msg04383.html. I did think you agreed with me.
gmsi is invalid whenpirq_dpciis notGUEST_MSI, is there something I have ignored?Quoted 9 lines
You've been talking about
GUEST_PCIthere, which I did (and do) agree we can't handle here. So for the purposes of your series, simply adding the gmsi.posted check would be the right thing imo. I don't think I see anything wrong with the ->gmsi accesses here:
TheGUEST_PCIcode simply doesn't set them, sodest_vcpu_idwill still be -1 (frompt_pirq_init()). So I don't see any bug being fixed here with the extra other check you add. If you agree, I can take that line and the commit message sentence out while committing.
Quoted 1 line
Ok. I admit I said it's bug is wrong. feel free to do what you want.
Well, looks like I forgot to adjust the commit message. -ETOOMUCHSTUFFGOINGONTODAY.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v12 2/7 x86/hvm: make io.h self-contained
In reply to Chao Gaoio.h uses structure npfec without including the file xen/mm.h where the structure is defined.
--- xen/include/asm-x86/hvm/io.h | 1 + 1 file changed, 1 insertion(+)
xen/include/asm-x86/hvm/io.h +1 -0
@@ -19,6 +19,7 @@#ifndef __ASM_X86_HVM_IO_H__#define __ASM_X86_HVM_IO_H__ +#include <xen/mm.h> #include <asm/hvm/vpic.h> #include <asm/hvm/vioapic.h> #include <public/hvm/ioreq.h>
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v12 2/7] x86/hvm: make io.h self-contained
Quoted 9 lines
-----Original Message-----
From: Chao Gao [mailto:[email protected]]
Sent: 05 April 2017 20:30
To: [email protected]
Cc: Chao Gao <[email protected]>; Paul Durrant <[email protected]>; Jan Beulich <[email protected]>; Andrew Cooper <[email protected]>
Subject: [PATCH v12 2/7] x86/hvm: makeio.hself-contained
Quoted 3 lines
io.huses structure npfec without including the filexen/mm.hwhere the structure is defined.
Quoted 18 lines
Signed-off-by Chao Gao <[email protected]>--- xen/include/asm-x86/hvm/io.h | 1 + 1 file changed, 1 insertion(+)xen/include/asm-x86/hvm/io.h +1
-1@@ -19,6 +19,7 @@#ifndef __ASM_X86_HVM_IO_H__#define __ASM_X86_HVM_IO_H__ +#include <xen/mm.h> #include <asm/hvm/vpic.h> #include <asm/hvm/vioapic.h> #include <public/hvm/ioreq.h> --
Quoted 1 line
1.8.3.1
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v12 3/7 VT-d: Introduce new fields in msi_desc to track binding with guest interrupt
In reply to Chao Gaomsi_msg_to_remap_entry() is buggy when the live IRTE is in posted format. It wrongly inherits the 'im' field meaning the IRTE is in posted format but updates all the other fields to remapping format.
There are also two situations that lead to the above issue. One is some callers really want to change the IRTE to remapped format. The other is some callers only want to update msi message (e.g. set msi affinity) for they don't aware that this msi is binded with a guest interrupt. We should suppress update in the second situation. To distinguish them, straightforwardly, we can let caller specify which format of IRTE they want update to. It isn't feasible for making all callers be aware of the binding with guest interrupt will cause a far more complicated change (including the interfaces exposed to IOAPIC and MSI). Also some callings happen in interrupt context where we can't acquire d->event_lock to read struct hvm_pirq_dpci.
This patch introduces two new fields in msi_desc to track binding with a guest interrupt such that msi_msg_to_remap_entry() can get the binding and update IRTE accordingly. After that change, pi_update_irte() can utilize msi_msg_to_remap_entry() to update IRTE to posted format.
---
v12:
- pass const struct pi_desc * to pi_update_irte() other than struct vcpu
- rearrage new fields in msi_desc to avoid more holes in this structure
- change the condition we call pi_update_irte in pt_irq_destroy_bind()
v11:
- Commit message changes.
- Add code to clear the two new fields introduced in this patch.
v10:
- Newly added.
xen/arch/x86/msi.c | 1 + xen/drivers/passthrough/io.c | 5 +- xen/drivers/passthrough/vtd/intremap.c | 151 +++++++-------------------------- xen/include/asm-x86/iommu.h | 4 +- xen/include/asm-x86/msi.h | 4 + 5 files changed, 43 insertions(+), 122 deletions(-)
xen/arch/x86/msi.c +1 -0
@@ -578,6 +578,7 @@ static struct msi_desc *alloc_msi_entry(unsigned int nr) entry[nr].dev =NULL ; entry[nr].irq =-1 ; entry[nr].remap_index =-1 ; + entry[nr].pi_desc =NULL ; }return entry;
xen/drivers/passthrough/io.c +4 -1
@@ -415,7 +415,8 @@ int pt_irq_create_bind(if ( iommu_intpost ) {if ( vcpu ) -pi_update_irte (vcpu, info, pirq_dpci->gmsi.gvec); +pi_update_irte (&vcpu->arch.hvm_vmx.pi_desc, info, + pirq_dpci->gmsi.gvec);else dprintk(XENLOG_G_INFO, "%pv: deliver interrupt in remapping mode,gvec:%02x\n",
@@ -619,6 +620,8 @@ int pt_irq_destroy_bind(else what ="bogus" ; } +else if ( pirq_dpci && pirq_dpci->gmsi.posted ) +pi_update_irte (NULL , pirq,0 );if ( pirq_dpci && (pirq_dpci->flags &HVM_IRQ_DPCI_MAPPED ) &&list_empty (&pirq_dpci->digl_list) )
xen/drivers/passthrough/vtd/intremap.c +31 -120
196 lines not on this page · raw message
xen/include/asm-x86/iommu.h +3 -1
@@ -18,6 +18,7 @@#include <xen/list.h> #include <xen/spinlock.h> #include <asm/processor.h> +#include <asm/hvm/vmx/vmcs.h> #define DEFAULT_DOMAIN_ADDRESS_WIDTH 48#define MAX_IOMMUS 32
@@ -92,7 +93,8 @@ bool_t iommu_supports_eim(void);int iommu_enable_x2apic_IR (void );void iommu_disable_x2apic_IR (void ); -int pi_update_irte (const struct vcpu *v,const struct pirq *pirq,const uint8_t gvec); +int pi_update_irte (const struct pi_desc *pi_desc,const struct pirq *pirq, +const uint8_t gvec);#endif /* !__ARCH_X86_IOMMU_H__ */ /*
xen/include/asm-x86/msi.h +4 -0
@@ -4,6 +4,7 @@#include <xen/cpumask.h> #include <xen/pci.h> #include <asm/byteorder.h> +#include <asm/hvm/vmx/vmcs.h> /* * Constants for Intel APIC based MSI messages.
@@ -102,6 +103,9 @@ struct msi_desc {__u16 entry_nr;/* specific enabled entry */ } msi_attrib; +uint8_t gvec;/* guest vector. valid when pi_desc isn't NULL */ +const struct pi_desc *pi_desc;/* pointer to posted descriptor */ +struct list_head list;union {
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v12 3/7] VT-d: Introduce new fields in msi_desc to track binding with guest interrupt
Quoted 26 lines
From: Gao, Chao
Sent: Thursday, April 6, 2017 8:30 AM
msi_msg_to_remap_entry()is buggy when the live IRTE is in posted format. It wrongly inherits the 'im' field meaning the IRTE is in posted format but updates all the other fields to remapping format.There are also two situations that lead to the above issue. One is some callers
really want to change the IRTE to remapped format. The other is some callers only want to update msi message (e.g. set msi affinity) for they don't aware that this msi is binded with a guest interrupt. We should suppress update in the second situation. To distinguish them, straightforwardly, we can let caller specify which format of IRTE they want update to. It isn't feasible for making all callers be aware of the binding with guest interrupt will cause a far more complicated change (including the interfaces exposed to IOAPIC and MSI). Also some callings happen in interrupt context where we can't acquired->event_lockto read structhvm_pirq_dpci.This patch introduces two new fields in
msi_descto track binding with a guest
interrupt such thatmsi_msg_to_remap_entry()can get the binding and update
IRTE accordingly. After that change,pi_update_irte()can utilizemsi_msg_to_remap_entry()to update IRTE to posted format.
Quoted 2 lines
Signed-off-by Feng Wu <[email protected]>Signed-off-by Chao Gao <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v12 3/7] VT-d: Introduce new fields in msi_desc to track binding with guest interrupt
In reply to Chao GaoQuoted 16 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
msi_msg_to_remap_entry()is buggy when the live IRTE is in posted format. It wrongly inherits the 'im' field meaning the IRTE is in posted format but updates all the other fields to remapping format.There are also two situations that lead to the above issue. One is some callers really want to change the IRTE to remapped format. The other is some callers only want to update msi message (e.g. set msi affinity) for they don't aware that this msi is binded with a guest interrupt. We should suppress update in the second situation. To distinguish them, straightforwardly, we can let caller specify which format of IRTE they want update to. It isn't feasible for making all callers be aware of the binding with guest interrupt will cause a far more complicated change (including the interfaces exposed to IOAPIC and MSI). Also some callings happen in interrupt context where we can't acquire
d->event_lockto read structhvm_pirq_dpci.
Quoted 7 lines
This patch introduces two new fields in
msi_descto track binding with a guest interrupt such thatmsi_msg_to_remap_entry()can get the binding and update IRTE accordingly. After that change,pi_update_irte()can utilizemsi_msg_to_remap_entry()to update IRTE to posted format.Signed-off-by Feng Wu <[email protected]>Signed-off-by Chao Gao <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v12 4/7 VT-d: Some cleanups
In reply to Chao GaoFrom: Feng Wu <[email protected]>
Use type-safe structure assignment instead of memcpy() Use sizeof(*iremap_entry).
---
v10:
- Added several lines for patch [1/6] has been reworked.
v9:
- Delete several lines for patch [5/8] has been reworked.
v7:
- Remove a useless cleanup
v6:
- More descripion about the patch
xen/drivers/passthrough/vtd/intremap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
xen/drivers/passthrough/vtd/intremap.c +7 -7
@@ -183,8 +183,8 @@ static void free_remap_entry(struct iommu *iommu, int index)GET_IREMAP_ENTRY (ir_ctrl->iremap_maddr, index, iremap_entries, iremap_entry); -memset (iremap_entry,0 ,sizeof (struct iremap_entry )); -iommu_flush_cache_entry (iremap_entry,sizeof (struct iremap_entry )); +memset (iremap_entry,0 ,sizeof (*iremap_entry)); +iommu_flush_cache_entry (iremap_entry,sizeof (*iremap_entry));iommu_flush_iec_index (iommu,0 , index);unmap_vtd_domain_page (iremap_entries);
@@ -310,7 +310,7 @@ static int ioapic_rte_to_remap_entry(struct iommu *iommu,GET_IREMAP_ENTRY (ir_ctrl->iremap_maddr, index, iremap_entries, iremap_entry); -memcpy (&new_ire, iremap_entry,sizeof (struct iremap_entry )); + new_ire = *iremap_entry;if ( rte_upper ) {
@@ -353,8 +353,8 @@ static int ioapic_rte_to_remap_entry(struct iommu *iommu, remap_rte->format =1 ;/* indicate remap format */ } -memcpy (iremap_entry, &new_ire,sizeof (struct iremap_entry )); -iommu_flush_cache_entry (iremap_entry,sizeof (struct iremap_entry )); + *iremap_entry = new_ire; +iommu_flush_cache_entry (iremap_entry,sizeof (*iremap_entry));iommu_flush_iec_index (iommu,0 , index);unmap_vtd_domain_page (iremap_entries);
@@ -639,8 +639,8 @@ static int msi_msg_to_remap_entry( remap_rte->address_hi =0 ; remap_rte->data = index - i; -memcpy (iremap_entry, &new_ire,sizeof (struct iremap_entry )); -iommu_flush_cache_entry (iremap_entry,sizeof (struct iremap_entry )); + *iremap_entry = new_ire; +iommu_flush_cache_entry (iremap_entry,sizeof (*iremap_entry));iommu_flush_iec_index (iommu,0 , index);unmap_vtd_domain_page (iremap_entries);
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v12 5/7 VMX: Fixup PI descriptor when cpu is offline
In reply to Chao GaoFrom: Feng Wu <[email protected]>
When cpu is offline, we need to move all the vcpus in its blocking list to another online cpu, this patch handles it.
--- xen/arch/x86/hvm/vmx/vmcs.c | 1 + xen/arch/x86/hvm/vmx/vmx.c | 70 +++++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/hvm/vmx/vmx.h | 1 + 3 files changed, 72 insertions(+)
xen/arch/x86/hvm/vmx/vmcs.c +1 -0
@@ -591,6 +591,7 @@ void vmx_cpu_dead(unsigned int cpu)vmx_free_vmcs (per_cpu (vmxon_region, cpu));per_cpu (vmxon_region, cpu) =0 ;nvmx_cpu_dead (cpu); +vmx_pi_desc_fixup (cpu); }int vmx_cpu_up (void )
xen/arch/x86/hvm/vmx/vmx.c +70 -0
76 lines not on this page · raw message
xen/include/asm-x86/hvm/vmx/vmx.h +1 -0
@@ -597,6 +597,7 @@ void free_p2m_hap_data(struct p2m_domain *p2m);void p2m_init_hap_data (struct p2m_domain *p2m);void vmx_pi_per_cpu_init (unsigned int cpu); +void vmx_pi_desc_fixup (unsigned int cpu);void vmx_pi_hooks_assign (struct domain *d);void vmx_pi_hooks_deassign (struct domain *d);
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v12 6/7 VT-d: introduce update_irte to update irte safely
In reply to Chao GaoWe used structure assignment to update irte which was non-atomic when the whole IRTE was to be updated. It is unsafe when a interrupt happened during update. Furthermore, no bug or warning would be reported when this happened.
This patch introduces two variants, atomic and non-atomic, to update irte. For initialization and release case, the non-atomic variant will be used. for other cases (such as reprogramming to set irq affinity), the atomic variant will be used. If the caller requests a atomic update but we can't meet it, we raise a bug.
---
v12:
- use write_atomic in update_irte
- add description to explain why no one won't change the IRTE entry which is using in update_irte(). Also add assertion to verify it.
- rename the new flag in msi_desc to irte_initialized
- remove two helper function update_irte_{atomic/nonatomic}
v11:
- Add two variant function to update IRTE. Call the non-atomic one for init and clear operations. Call the atomic one for other cases.
- Add a new field to indicate the remap_entry associated with msi_desc is initialized or not.
v10:
- rename copy_irte_to_irt to update_irte
- remove copy_from_to_irt
- change commmit message and add some comments to illustrate on which condition update_irte() is safe.
xen/arch/x86/msi.c | 1 + xen/drivers/passthrough/vtd/intremap.c | 61 +++++++++++++++++++++++++++++++--- xen/include/asm-x86/msi.h | 1 + 3 files changed, 59 insertions(+), 4 deletions(-)
xen/arch/x86/msi.c +1 -0
@@ -579,6 +579,7 @@ static struct msi_desc *alloc_msi_entry(unsigned int nr) entry[nr].irq =-1 ; entry[nr].remap_index =-1 ; entry[nr].pi_desc =NULL ; + entry[nr].irte_initialized = false; }return entry;
xen/drivers/passthrough/vtd/intremap.c +57 -4
107 lines not on this page · raw message
xen/include/asm-x86/msi.h +1 -0
@@ -103,6 +103,7 @@ struct msi_desc {__u16 entry_nr;/* specific enabled entry */ } msi_attrib; +bool irte_initialized;uint8_t gvec;/* guest vector. valid when pi_desc isn't NULL */ const struct pi_desc *pi_desc;/* pointer to posted descriptor */
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v12 6/7] VT-d: introduce update_irte to update irte safely
Quoted 10 lines
From: Gao, Chao
Sent: Thursday, April 6, 2017 8:30 AMWe used structure assignment to update irte which was non-atomic when the
whole IRTE was to be updated. It is unsafe when a interrupt happened during
update. Furthermore, no bug or warning would be reported when this happened.
Quoted 4 lines
This patch introduces two variants, atomic and non-atomic, to update irte. For initialization and release case, the non-atomic variant will be used. for other cases (such as reprogramming to set irq affinity), the atomic variant will be used. If the caller requests a atomic update but we can't meet it, we
'a'->'an'. I thought whether above should be updated since two helpers are removed now. But possibly still OK based on purpose of 'atomic' parameter in update_irte. :-)
Quoted 75 lines
raise a bug.
Signed-off-by Chao Gao <[email protected]>---
v12:
- usewrite_atomicinupdate_irte
- add description to explain why no one won't change the IRTE entry which is using inupdate_irte(). Also add assertion to verify it.
- rename the new flag inmsi_desctoirte_initialized
- remove two helper function update_irte_{atomic/nonatomic}v11:
- Add two variant function to update IRTE. Call the non-atomic one for init and clear operations. Call the atomic one for other cases.
- Add a new field to indicate theremap_entryassociated withmsi_descis initialized or not.v10:
- renamecopy_irte_to_irttoupdate_irte
- removecopy_from_to_irt
- change commmit message and add some comments to illustrate on which conditionupdate_irte()is safe.xen/arch/x86/msi.c | 1 + xen/drivers/passthrough/vtd/intremap.c | 61 +++++++++++++++++++++++++++++++--- xen/include/asm-x86/msi.h | 1 + 3 files changed, 59 insertions(+), 4 deletions(-)xen/arch/x86/msi.c +1
-0@@ -579,6 +579,7 @@ static struct msi_desc *alloc_msi_entry(unsigned int nr) entry[nr].irq = -1; entry[nr].remap_index =-1 ; entry[nr].pi_desc =NULL ; + entry[nr].irte_initialized = false; }return entry;xen/drivers/passthrough/vtd/intremap.c +2
-0@@ -169,10 +169,55 @@ bool_t __init iommu_supports_eim(void)return 1 ; } +/* +* Assume iremap_lock has been acquired. It is to make sure software will not
+ * change the same IRTE behind us. With this assumption, if only high qword or
+ * low qword in IRTE is to be updated, this function's atomic variant can
+ * present an atomic update to VT-d hardware even when cmpxchg16b
+ * instruction is not supported.
+ */xen/drivers/passthrough/vtd/intremap.c +15
-0+static void update_irte (struct iommu *iommu,struct iremap_entry *entry, +const struct iremap_entry *new_ire,bool atomic) +{ +ASSERT (spin_is_locked (&iommu_ir_ctrl (iommu)->iremap_lock)); + +if ( cpu_has_cx16 ) + { +__uint128_t ret; +struct iremap_entry old_ire; + + old_ire = *entry; + ret =cmpxchg16b (entry, &old_ire, new_ire); + +/* +* In the above, we use cmpxchg16 to atomically update the 128-bit
xen/drivers/passthrough/vtd/intremap.c bool_t __init iommu_supports_eim(void) · line 203
Quoted 10 lines
xen/drivers/passthrough/vtd/intremap.c +10
-0+* IRTE, and the hardware cannot update the IRTE behind us, so +* the return value of cmpxchg16 should be the same as old_ire. +* This ASSERT validate it. +*/ +ASSERT (ret == old_ire.val); + } +else + { +/* +* If the caller requests a atomic update but we can't meet it,
'a'->'an'
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v12 6/7] VT-d: introduce update_irte to update irte safely
In reply to Chao GaoQuoted 40 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
xen/drivers/passthrough/vtd/intremap.c +33
-0@@ -169,10 +169,55 @@ bool_t __init iommu_supports_eim(void)return 1 ; } +/* +* Assume iremap_lock has been acquired. It is to make sure software will not +* change the same IRTE behind us. With this assumption, if only high qword or +* low qword in IRTE is to be updated, this function's atomic variant can +* present an atomic update to VT-d hardware even when cmpxchg16b +* instruction is not supported. +*/ +static void update_irte (struct iommu *iommu,struct iremap_entry *entry, +const struct iremap_entry *new_ire,bool atomic) +{ +ASSERT (spin_is_locked (&iommu_ir_ctrl (iommu)->iremap_lock)); + +if ( cpu_has_cx16 ) + { +__uint128_t ret; +struct iremap_entry old_ire; + + old_ire = *entry; + ret =cmpxchg16b (entry, &old_ire, new_ire); + +/* +* In the above, we use cmpxchg16 to atomically update the 128-bit +* IRTE, and the hardware cannot update the IRTE behind us, so +* the return value of cmpxchg16 should be the same as old_ire. +* This ASSERT validate it. +*/ +ASSERT (ret == old_ire.val); + } +else + { +/* +* If the caller requests a atomic update but we can't meet it, +* a bug will be raised.
xen/drivers/passthrough/vtd/intremap.c bool_t __init iommu_supports_eim(void) · line 214
Quoted 10 lines
xen/drivers/passthrough/vtd/intremap.c +10
-0+*/ +if ( entry->lo == new_ire->lo ) +write_atomic (&entry->hi, new_ire->hi); +else if ( entry->hi == new_ire->hi ) +write_atomic (&entry->lo, new_ire->lo); +else if ( !atomic ) + *entry = *new_ire; +else +BUG (); + }
Sadly the comment still uses the word atomic, and there's still no mention of whether (and if so, how) the hardware may update an IRTE behind your back. But since Kevin gave his R-b, I guess I'll have to give up on this.
xen/drivers/passthrough/vtd/intremap.c static int msi_msg_to_remap_entry( · line 694
Quoted 8 lines
xen/drivers/passthrough/vtd/intremap.c +3
-1@@ -639,7 +689,10 @@ static int msi_msg_to_remap_entry( remap_rte->address_hi =0 ; remap_rte->data = index - i; - *iremap_entry = new_ire; +update_irte (iommu, iremap_entry, &new_ire, msi_desc->irte_initialized); +if ( !msi_desc->irte_initialized ) + msi_desc->irte_initialized = true;
I don't see the point of the conditional, and I guess I'll take the liberty to remove it, should I end up committing this patch.
x86 parts
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v12 6/7] VT-d: introduce update_irte to update irte safely
Quoted 47 lines · Jan Beulich
Quoted 47 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
xen/drivers/passthrough/vtd/intremap.c +40
-0@@ -169,10 +169,55 @@ bool_t __init iommu_supports_eim(void)return 1 ; } +/* +* Assume iremap_lock has been acquired. It is to make sure software will not +* change the same IRTE behind us. With this assumption, if only high qword or +* low qword in IRTE is to be updated, this function's atomic variant can +* present an atomic update to VT-d hardware even when cmpxchg16b +* instruction is not supported. +*/ +static void update_irte (struct iommu *iommu,struct iremap_entry *entry, +const struct iremap_entry *new_ire,bool atomic) +{ +ASSERT (spin_is_locked (&iommu_ir_ctrl (iommu)->iremap_lock)); + +if ( cpu_has_cx16 ) + { +__uint128_t ret; +struct iremap_entry old_ire; + + old_ire = *entry; + ret =cmpxchg16b (entry, &old_ire, new_ire); + +/* +* In the above, we use cmpxchg16 to atomically update the 128-bit +* IRTE, and the hardware cannot update the IRTE behind us, so +* the return value of cmpxchg16 should be the same as old_ire. +* This ASSERT validate it. +*/ +ASSERT (ret == old_ire.val); + } +else + { +/* +* If the caller requests a atomic update but we can't meet it, +* a bug will be raised. +*/ +if ( entry->lo == new_ire->lo ) +write_atomic (&entry->hi, new_ire->hi); +else if ( entry->hi == new_ire->hi ) +write_atomic (&entry->lo, new_ire->lo); +else if ( !atomic ) + *entry = *new_ire;
Quoted 8 lines
xen/drivers/passthrough/vtd/intremap.c bool_t __init iommu_supports_eim(void) · line 214
Quoted 3 lines
xen/drivers/passthrough/vtd/intremap.c +3
-0+else +BUG (); + }Sadly the comment still uses the word atomic, and there's still no mention of whether (and if so, how) the hardware may update an IRTE behind your back. But since Kevin gave his R-b, I guess I'll have to give up on this.
To make it clearer, the comment you mentioned is the comment in the else() branch or the comment before this function (or both)? I will fix it in a new patch.
Quoted 5 lines
Quoted 5 lines
xen/drivers/passthrough/vtd/intremap.c +0
-0@@ -639,7 +689,10 @@ static int msi_msg_to_remap_entry( remap_rte->address_hi =0 ; remap_rte->data = index - i;
Quoted 7 lines
xen/drivers/passthrough/vtd/intremap.c static int msi_msg_to_remap_entry( · line 694
Quoted 4 lines
xen/drivers/passthrough/vtd/intremap.c +3
-1- *iremap_entry = new_ire; +update_irte (iommu, iremap_entry, &new_ire, msi_desc->irte_initialized); +if ( !msi_desc->irte_initialized ) + msi_desc->irte_initialized = true;I don't see the point of the conditional, and I guess I'll take the liberty to remove it, should I end up committing this patch.
Yes, please.
Thanks
Chao
Quoted 6 lines
x86 parts
Acked-by Jan Beulich <[email protected]>Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v12 6/7] VT-d: introduce update_irte to update irte safely
Quoted 58 lines
Quoted 1 line
Quoted 1 line · On 07.04.17 at 09:51, <[email protected]> wrote:
Quoted 47 lines · Jan Beulich
Quoted 47 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
xen/drivers/passthrough/vtd/intremap.c +40
-0@@ -169,10 +169,55 @@ bool_t __init iommu_supports_eim(void)return 1 ; } +/* +* Assume iremap_lock has been acquired. It is to make sure software will not +* change the same IRTE behind us. With this assumption, if only high qword or +* low qword in IRTE is to be updated, this function's atomic variant can +* present an atomic update to VT-d hardware even when cmpxchg16b +* instruction is not supported. +*/ +static void update_irte (struct iommu *iommu,struct iremap_entry *entry, +const struct iremap_entry *new_ire,bool atomic) +{ +ASSERT (spin_is_locked (&iommu_ir_ctrl (iommu)->iremap_lock)); + +if ( cpu_has_cx16 ) + { +__uint128_t ret; +struct iremap_entry old_ire; + + old_ire = *entry; + ret =cmpxchg16b (entry, &old_ire, new_ire); + +/* +* In the above, we use cmpxchg16 to atomically update the 128-bit +* IRTE, and the hardware cannot update the IRTE behind us, so +* the return value of cmpxchg16 should be the same as old_ire. +* This ASSERT validate it. +*/ +ASSERT (ret == old_ire.val); + } +else + { +/* +* If the caller requests a atomic update but we can't meet it, +* a bug will be raised. +*/ +if ( entry->lo == new_ire->lo ) +write_atomic (&entry->hi, new_ire->hi); +else if ( entry->hi == new_ire->hi ) +write_atomic (&entry->lo, new_ire->lo); +else if ( !atomic ) + *entry = *new_ire;Quoted 8 lines
xen/drivers/passthrough/vtd/intremap.c bool_t __init iommu_supports_eim(void) · line 214
Quoted 3 lines
xen/drivers/passthrough/vtd/intremap.c +3
-0+else +BUG (); + }Sadly the comment still uses the word atomic, and there's still no mention of whether (and if so, how) the hardware may update an IRTE behind your back. But since Kevin gave his R-b, I guess I'll have to give up on this.
Quoted 3 lines
To make it clearer, the comment you mentioned is the comment in the
else()branch or the comment before this function (or both)? I will fix it in a new patch.
Specifically the one in the else branch.
Quoted 12 lines
Quoted 11 lines
xen/drivers/passthrough/vtd/intremap.c static int msi_msg_to_remap_entry( · line 694
Quoted 8 lines
xen/drivers/passthrough/vtd/intremap.c +3
-1@@ -639,7 +689,10 @@ static int msi_msg_to_remap_entry( remap_rte->address_hi =0 ; remap_rte->data = index - i; - *iremap_entry = new_ire; +update_irte (iommu, iremap_entry, &new_ire, msi_desc->irte_initialized); +if ( !msi_desc->irte_initialized ) + msi_desc->irte_initialized = true;I don't see the point of the conditional, and I guess I'll take the liberty to remove it, should I end up committing this patch.
Quoted 1 line
Yes, please.
And that's another thing I've already noticed I forgot.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v12 7/7 passthrough/io: Fall back to remapping interrupt when we can't use VT-d PI
In reply to Chao GaoThe current logic of using VT-d pi is when guest configurates the pirq's destination vcpu to a single vcpu, the according IRTE is updated to posted format. If the destination of the pirq is multiple vcpus, we will stay in posted format. Obviously, we should fall back to remapping interrupt when guest wrongly configurate destination of pirq or makes it have multi-destination vcpus.
---
v11:
- move the code (one line) that allow the parameter 'vcpu' of pi_update_irte() can be NULL to Patch [2/6].
v10:
- Newly added
xen/drivers/passthrough/io.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
xen/drivers/passthrough/io.c +2 -9
@@ -413,15 +413,8 @@ int pt_irq_create_bind(/* Use interrupt posting if it is supported. */ if ( iommu_intpost ) - { -if ( vcpu ) -pi_update_irte (&vcpu->arch.hvm_vmx.pi_desc, info, - pirq_dpci->gmsi.gvec); -else -dprintk (XENLOG_G_INFO , -"%pv: deliver interrupt in remapping mode,gvec:%02x\n" , - vcpu, pirq_dpci->gmsi.gvec); - } +pi_update_irte (&vcpu->arch.hvm_vmx.pi_desc, info, + pirq_dpci->gmsi.gvec);break ; }
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v12 7/7] passthrough/io: Fall back to remapping interrupt when we can't use VT-d PI
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
The current logic of using VT-d pi is when guest configurates the pirq's destination vcpu to a single vcpu, the according IRTE is updated to posted format. If the destination of the pirq is multiple vcpus, we will stay in posted format. Obviously, we should fall back to remapping interrupt when guest wrongly configurate destination of pirq or makes it have multi-destination vcpus.
Quoted 7 lines
Signed-off-by Chao Gao <[email protected]>Reviewed-by Jan Beulich <[email protected]>Reviewed-by Kevin Tian <[email protected]>---
v11:
- move the code (one line) that allow the parameter 'vcpu' ofpi_update_irte()can be NULL to Patch [2/6].
There was a change in v12 too, and I'm afraid it's buggy:
Quoted 7 lines
xen/drivers/passthrough/io.c +0
-1@@ -413,15 +413,8 @@ int pt_irq_create_bind(/* Use interrupt posting if it is supported. */ if ( iommu_intpost ) - {
xen/drivers/passthrough/io.c int pt_irq_create_bind( · line 417
Quoted 10 lines
xen/drivers/passthrough/io.c +2
-8-if ( vcpu ) -pi_update_irte (&vcpu->arch.hvm_vmx.pi_desc, info, - pirq_dpci->gmsi.gvec); -else -dprintk (XENLOG_G_INFO , -"%pv: deliver interrupt in remapping mode,gvec:%02x\n" , - vcpu, pirq_dpci->gmsi.gvec); - } +pi_update_irte (&vcpu->arch.hvm_vmx.pi_desc, info, + pirq_dpci->gmsi.gvec);
pi_update_irte() tolerates a NULL first argument, but if vcpu is NULL you don't pass NULL here. I'll fix this up while committing.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v12 7/7] passthrough/io: Fall back to remapping interrupt when we can't use VT-d PI
Quoted 16 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 06.04.17 at 02:30, <[email protected]> wrote:
The current logic of using VT-d pi is when guest configurates the pirq's destination vcpu to a single vcpu, the according IRTE is updated to posted format. If the destination of the pirq is multiple vcpus, we will stay in posted format. Obviously, we should fall back to remapping interrupt when guest wrongly configurate destination of pirq or makes it have multi-destination vcpus.
Quoted 7 lines
Signed-off-by Chao Gao <[email protected]>Reviewed-by Jan Beulich <[email protected]>Reviewed-by Kevin Tian <[email protected]>---
v11:
- move the code (one line) that allow the parameter 'vcpu' ofpi_update_irte()can be NULL to Patch [2/6].
Quoted 1 line
There was a change in v12 too, and I'm afraid it's buggy:
Indeed.
Quoted 5 lines
Quoted 5 lines
xen/drivers/passthrough/io.c +0
-0@@ -413,15 +413,8 @@ int pt_irq_create_bind(
Quoted 17 lines
xen/drivers/passthrough/io.c int pt_irq_create_bind( · line 417
Quoted 13 lines
xen/drivers/passthrough/io.c +2
-9/* Use interrupt posting if it is supported. */ if ( iommu_intpost ) - { -if ( vcpu ) -pi_update_irte (&vcpu->arch.hvm_vmx.pi_desc, info, - pirq_dpci->gmsi.gvec); -else -dprintk (XENLOG_G_INFO , -"%pv: deliver interrupt in remapping mode,gvec:%02x\n" , - vcpu, pirq_dpci->gmsi.gvec); - } +pi_update_irte (&vcpu->arch.hvm_vmx.pi_desc, info, + pirq_dpci->gmsi.gvec);
pi_update_irte()tolerates a NULL first argument, but if vcpu is NULL you don't pass NULL here. I'll fix this up while committing.
Thanks for your kind help.
Chao
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel