[Xen-devel] [PATCH v11 0/6] VMX: Properly handle pi descriptor and per-cpu blocking list

2017-03-29 Thread Chao Gao
n 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 [6/6] resolves this problem. Chao Gao (4): passthrough: don't migrate pirq when it is delivered through VT-d

Re: [Xen-devel] [RFC PATCH 5/23] Tools/libxc: Add viommu operations in libxc

2017-03-30 Thread Chao Gao
On Wed, Mar 29, 2017 at 09:08:06AM +, Paul Durrant wrote: >> -Original Message- >> From: Xen-devel [mailto:xen-devel-boun...@lists.xen.org] On Behalf Of >> Chao Gao >> Sent: 29 March 2017 01:40 >> To: Wei Liu >> Cc: Lan Tianyu ; Kevin Tian ; >

Re: [Xen-devel] [RFC PATCH 2/4] Xen: add a dummy vIOMMU to create/destroy vIOMMU in Xen

2017-03-30 Thread Chao Gao
On Thu, Mar 30, 2017 at 05:24:52PM +0100, Anthony PERARD wrote: >Hi, > >On Fri, Mar 17, 2017 at 07:29:15PM +0800, Lan Tianyu wrote: >> From: Chao Gao >> >> Since adding a dynamic sysbus device is forbidden, so choose TYPE_DEVICE >> as parent class. >> &g

Re: [Xen-devel] [RFC PATCH 3/4] xen-pt: bind/unbind interrupt remapping format MSI

2017-03-30 Thread Chao Gao
On Thu, Mar 30, 2017 at 05:51:45PM +0100, Anthony PERARD wrote: >On Fri, Mar 17, 2017 at 07:29:16PM +0800, Lan Tianyu wrote: >> From: Chao Gao >> >> If a vIOMMU is exposed to guest, guest will configure the msi to remapping >> format. The original code isn't s

Re: [Xen-devel] [RFC PATCH 4/4] msi: taking interrupt format into consideration during judging a pirq is binded with a event channel

2017-03-30 Thread Chao Gao
On Thu, Mar 30, 2017 at 06:29:29PM +0100, Anthony PERARD wrote: >On Fri, Mar 17, 2017 at 07:29:17PM +0800, Lan Tianyu wrote: >> From: Chao Gao >> Subject: msi: taking interrupt format into consideration during >> judging a pirq is binded with a event channel > >This is

Re: [Xen-devel] [PATCH v11 2/6] VT-d: Introduce new fields in msi_desc to track binding with guest interrupt

2017-03-30 Thread Chao Gao
On Fri, Mar 31, 2017 at 01:46:33PM +0800, Tian, Kevin wrote: >> From: Gao, Chao >> Sent: Wednesday, March 29, 2017 1:12 PM >> >> return entry; >> diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c >> index d53976c..5dbfe53 100644 >> --- a/xen/drivers/passthrough/io.c >>

Re: [Xen-devel] [PATCH v11 1/6] passthrough: don't migrate pirq when it is delivered through VT-d PI

2017-03-30 Thread Chao Gao
On Fri, Mar 31, 2017 at 01:28:02PM +0800, Tian, Kevin wrote: >> From: Chao Gao >> Sent: Wednesday, March 29, 2017 1:12 PM >> >> When a vCPU migrated to another pCPU, pt irqs binded to this vCPU also >> needed migration. When VT-d PI is enabled, interrupt vector

Re: [Xen-devel] [PATCH v11 2/6] VT-d: Introduce new fields in msi_desc to track binding with guest interrupt

2017-03-31 Thread Chao Gao
On Fri, Mar 31, 2017 at 02:11:08AM -0600, Jan Beulich wrote: On 31.03.17 at 01:01, wrote: >> On Fri, Mar 31, 2017 at 01:46:33PM +0800, Tian, Kevin wrote: From: Gao, Chao Sent: Wednesday, March 29, 2017 1:12 PM --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthroug

Re: [Xen-devel] [PATCH v11 1/6] passthrough: don't migrate pirq when it is delivered through VT-d PI

2017-03-31 Thread Chao Gao
On Fri, Mar 31, 2017 at 03:31:47AM -0600, Jan Beulich wrote: On 29.03.17 at 07:11, wrote: >> @@ -442,17 +397,24 @@ int pt_irq_create_bind( >> dest_vcpu_id = hvm_girq_dest_2_vcpu_id(d, dest, dest_mode); >> pirq_dpci->gmsi.dest_vcpu_id = dest_vcpu_id; >> spin_unlock(&

Re: [Xen-devel] [PATCH v11 1/6] passthrough: don't migrate pirq when it is delivered through VT-d PI

2017-03-31 Thread Chao Gao
On Fri, Mar 31, 2017 at 04:06:27AM -0600, Jan Beulich wrote: On 31.03.17 at 04:42, wrote: >> On Fri, Mar 31, 2017 at 03:31:47AM -0600, Jan Beulich wrote: >> On 29.03.17 at 07:11, wrote: @@ -442,17 +397,24 @@ int pt_irq_create_bind( dest_vcpu_id = hvm_girq_dest_2_vcpu_i

Re: [Xen-devel] [PATCH v11 5/6] VT-d: introduce update_irte to update irte safely

2017-04-04 Thread Chao Gao
On Fri, Mar 31, 2017 at 04:01:31AM -0600, Jan Beulich wrote: On 29.03.17 at 07:11, wrote: >> +static void update_irte(struct iremap_entry *entry, >> +const struct iremap_entry *new_ire, >> +bool atomic) >> +{ >> +if ( cpu_has_cx16 ) >> +

Re: [Xen-devel] [xen-unstable test] 106504: regressions - FAIL

2017-04-05 Thread Chao Gao
On Wed, Mar 22, 2017 at 06:47:33AM -0600, Jan Beulich wrote: On 22.03.17 at 05:53, wrote: >> I have written a xtf test case (many codes are from hvmloader) to >> trigger this assertion. The test case is in attachments. > >Thanks for doing this. > >> Bottom is the output >> of this test. This

Re: [Xen-devel] [PATCH v11 1/6] passthrough: don't migrate pirq when it is delivered through VT-d PI

2017-04-05 Thread Chao Gao
On Fri, Mar 31, 2017 at 04:38:02AM -0600, Jan Beulich wrote: On 31.03.17 at 05:27, wrote: >This then also raises the question whether the call to >hvm_girq_dest_2_vcpu_id() is actually legitimate for lowest >priority delivery mode. For lowest priority delivery mode, if

Re: [Xen-devel] [xen-unstable test] 106504: regressions - FAIL

2017-04-05 Thread Chao Gao
On Wed, Apr 05, 2017 at 01:48:22AM -0600, Jan Beulich wrote: On 05.04.17 at 01:57, wrote: >> On Wed, Mar 22, 2017 at 06:47:33AM -0600, Jan Beulich wrote: >> >> Hi, Jan. >> >> I plan to do the following changes: >> 1. get the vector set in vIRR to avoid getting a wrong interrupt vector >> I

[Xen-devel] [PATCH v12 1/7] passthrough: don't migrate pirq when it is delivered through VT-d PI

2017-04-06 Thread Chao Gao
_dpci->gmsi.dest_vcpu_id without checking the pirq_dpci's type. Signed-off-by: Chao Gao --- 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/

[Xen-devel] [PATCH v12 3/7] VT-d: Introduce new fields in msi_desc to track binding with guest interrupt

2017-04-06 Thread Chao Gao
remap_entry() to update IRTE to posted format. Signed-off-by: Feng Wu Signed-off-by: Chao Gao --- 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

[Xen-devel] [PATCH v12 0/7] VMX: Properly handle pi descriptor and per-cpu blocking list

2017-04-06 Thread Chao Gao
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 interru

[Xen-devel] [PATCH v12 7/7] passthrough/io: Fall back to remapping interrupt when we can't use VT-d PI

2017-04-06 Thread Chao Gao
when guest wrongly configurate destination of pirq or makes it have multi-destination vcpus. Signed-off-by: Chao Gao Reviewed-by: Jan Beulich Reviewed-by: Kevin Tian --- v11: - move the code (one line) that allow the parameter 'vcpu' of pi_update_irte() can be NULL to Patch [2/6]. v10

[Xen-devel] [PATCH v12 2/7] x86/hvm: make io.h self-contained

2017-04-06 Thread Chao Gao
io.h uses structure npfec without including the file xen/mm.h where the structure is defined. Signed-off-by: Chao Gao --- xen/include/asm-x86/hvm/io.h | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/include/asm-x86/hvm/io.h b/xen/include/asm-x86/hvm/io.h index d6801c1..2349f58 100644

[Xen-devel] [PATCH v12 5/7] VMX: Fixup PI descriptor when cpu is offline

2017-04-06 Thread Chao Gao
From: Feng Wu When cpu is offline, we need to move all the vcpus in its blocking list to another online cpu, this patch handles it. Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Jan Beulich Acked-by: Kevin Tian --- xen/arch/x86/hvm/vmx/vmcs.c | 1 + xen/arch/x86/hvm

[Xen-devel] [PATCH v12 6/7] VT-d: introduce update_irte to update irte safely

2017-04-06 Thread Chao Gao
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. Signed-off-by: Chao Gao --- v12:

[Xen-devel] [PATCH v12 4/7] VT-d: Some cleanups

2017-04-06 Thread Chao Gao
From: Feng Wu Use type-safe structure assignment instead of memcpy() Use sizeof(*iremap_entry). Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Konrad Rzeszutek Wilk Acked-by: Kevin Tian --- v10: - Added several lines for patch [1/6] has been reworked. v9: - Delete several

[Xen-devel] [RFC PATCH] hvm/vpt: fix inconsistent views of vIOAPIC in vmx_intr_assist()

2017-04-07 Thread Chao Gao
: Chao Gao --- xen/arch/x86/hvm/irq.c | 22 -- xen/arch/x86/hvm/svm/intr.c | 21 +++-- xen/arch/x86/hvm/vmx/intr.c | 9 + xen/arch/x86/hvm/vpic.c | 20 ++-- xen/arch/x86/hvm/vpt.c | 4 ++-- xen/include/xen/hvm/irq.h | 4

Re: [Xen-devel] [PATCH v12 1/7] passthrough: don't migrate pirq when it is delivered through VT-d PI

2017-04-07 Thread Chao Gao
Cc: kevin On Fri, Apr 07, 2017 at 04:38:00AM -0600, Jan Beulich wrote: On 06.04.17 at 02:30, wrote: >> --- a/xen/arch/x86/hvm/hvm.c >> +++ b/xen/arch/x86/hvm/hvm.c >> @@ -438,6 +438,9 @@ static int hvm_migrate_pirq(struct domain *d, struct >> hvm_pirq_dpci *pirq_dpci, >> struct vcpu *v

Re: [Xen-devel] [PATCH v12 7/7] passthrough/io: Fall back to remapping interrupt when we can't use VT-d PI

2017-04-07 Thread Chao Gao
. 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. >> >> Signed-off-by:

Re: [Xen-devel] [PATCH v12 1/7] passthrough: don't migrate pirq when it is delivered through VT-d PI

2017-04-07 Thread Chao Gao
On Fri, Apr 07, 2017 at 05:50:36AM -0600, Jan Beulich wrote: On 07.04.17 at 06:07, wrote: >> Cc: kevin >> >> On Fri, Apr 07, 2017 at 04:38:00AM -0600, Jan Beulich wrote: >> On 06.04.17 at 02:30, wrote: --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -438,6 +4

Re: [Xen-devel] [PATCH v12 6/7] VT-d: introduce update_irte to update irte safely

2017-04-07 Thread Chao Gao
On Fri, Apr 07, 2017 at 06:27:39AM -0600, Jan Beulich wrote: On 06.04.17 at 02:30, wrote: >> --- a/xen/drivers/passthrough/vtd/intremap.c >> +++ b/xen/drivers/passthrough/vtd/intremap.c >> @@ -169,10 +169,55 @@ bool_t __init iommu_supports_eim(void) >> return 1; >> } >> >> +/* >> + *

[Xen-devel] Enabling VT-d PI by default

2017-04-11 Thread Chao Gao
Hello, Jan. As you know, with VT-d PI enabled, hardware can directly deliver external interrupts to guest without any VMM intervention. It will reduces overall interrupt latency to guest and reduces overheads otherwise incurred by the VMM for virtualizing interrupts. In my mind, it's an important

Re: [Xen-devel] [RFC PATCH] hvm/vpt: fix inconsistent views of vIOAPIC in vmx_intr_assist()

2017-04-11 Thread Chao Gao
On Wed, Apr 12, 2017 at 02:45:36AM +, Xuquan (Quan Xu) wrote: >On April 07, 2017 11:24 AM, Chao Gao wrote: >>When injecting periodic timer interrupt in vmx_intr_assist(), multiple read >>operation is operated during one event delivery and incur to inconsistent >>views of

Re: [Xen-devel] [RFC PATCH] hvm/vpt: fix inconsistent views of vIOAPIC in vmx_intr_assist()

2017-04-11 Thread Chao Gao
On Wed, Apr 12, 2017 at 02:45:36AM +, Xuquan (Quan Xu) wrote: >On April 07, 2017 11:24 AM, Chao Gao wrote: >>When injecting periodic timer interrupt in vmx_intr_assist(), multiple read >>operation is operated during one event delivery and incur to inconsistent >>views of

[Xen-devel] [PATCH] VT-d: correct a comment and remove useless if() statement

2017-04-12 Thread Chao Gao
fix two flaws in the patch (93358e8e VT-d: introduce update_irte to update irte safely). Signed-off-by: Chao Gao --- xen/drivers/passthrough/vtd/intremap.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers

Re: [Xen-devel] [PATCH] VT-d: correct a comment and remove useless if() statement

2017-04-12 Thread Chao Gao
On Wed, Apr 12, 2017 at 02:57:23AM -0600, Jan Beulich wrote: On 12.04.17 at 02:04, wrote: >> --- a/xen/drivers/passthrough/vtd/intremap.c >> +++ b/xen/drivers/passthrough/vtd/intremap.c >> @@ -200,8 +200,9 @@ static void update_irte(struct iommu *iommu, struct >> iremap_entry *entry, >>

Re: [Xen-devel] [PATCH] VT-d: correct a comment and remove useless if() statement

2017-04-12 Thread Chao Gao
On Wed, Apr 12, 2017 at 04:32:06AM -0600, Jan Beulich wrote: On 12.04.17 at 04:41, wrote: >> On Wed, Apr 12, 2017 at 02:57:23AM -0600, Jan Beulich wrote: >> On 12.04.17 at 02:04, wrote: + * If a caller want an atomic update from the views of VT-d >>> >>>wants >>> >>>Also wha

[Xen-devel] [PATCH v2] VT-d: correct a comment and remove an useless if() statement

2017-04-12 Thread Chao Gao
Signed-off-by: Chao Gao --- xen/drivers/passthrough/vtd/intremap.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index 699239b..1e0317c 100644 --- a/xen/drivers/passthrough/vtd/intremap.c

Re: [Xen-devel] [PATCH v1] vmx: set 'SN' bit for the runstate transition from blocked to runnable

2017-04-12 Thread Chao Gao
On Thu, Apr 13, 2017 at 02:20:23AM +, Xuquan (Quan Xu) wrote: >From 946e7589e5a875574c7567a91943d47c38218a6f Mon Sep 17 00:00:00 2001 >From: Quan Xu >Date: Fri, 14 Apr 2017 02:11:30 +0800 >Subject: [PATCH v1] vmx: set 'SN' bit for the runstate transition from blocked > to runnable > >set 'SN'

Re: [Xen-devel] [xen-unstable test] 104131: regressions - FAIL

2017-02-08 Thread Chao Gao
On Wed, Feb 08, 2017 at 10:15:28AM +, Xuquan (Quan Xu) wrote: >On February 08, 2017 4:52 PM, Jan Beulich wrote: > On 08.02.17 at 09:27, wrote: >>> Assumed vCPU is in guest_mode.. >>> When apicv is enabled, hypervisor calls vmx_deliver_posted_intr(), >>> then >>> __vmx_deliver_posted_interr

Re: [Xen-devel] [PATCH] xen/mm: Alter is_iomem_page() to use mfn_t

2017-02-09 Thread Chao Gao
On Wed, Feb 08, 2017 at 10:05:38AM -0700, Jan Beulich wrote: On 08.02.17 at 08:31, wrote: >>> From: Jan Beulich [mailto:jbeul...@suse.com] >>> Sent: Monday, February 06, 2017 11:38 PM >>> >>> >>> On 06.02.17 at 15:48, wrote: >>> > On Mon, 2017-02-06 at 07:26 -0700, Jan Beulich wrote: >>> >

Re: [Xen-devel] [xen-unstable test] 104131: regressions - FAIL

2017-02-09 Thread Chao Gao
On Thu, Feb 09, 2017 at 08:51:46AM +, Xuquan (Quan Xu) wrote: >On February 08, 2017 4:22 PM, Chao Gao wrote: >>On Wed, Feb 08, 2017 at 10:15:28AM +, Xuquan (Quan Xu) wrote: >>>On February 08, 2017 4:52 PM, Jan Beulich wrote: >>>>>>> On 08.02.17 at

Re: [Xen-devel] [PATCH] xen/mm: Alter is_iomem_page() to use mfn_t

2017-02-09 Thread Chao Gao
On Thu, Feb 09, 2017 at 01:56:14AM -0700, Jan Beulich wrote: On 09.02.17 at 09:27, wrote: >> On Wed, Feb 08, 2017 at 10:05:38AM -0700, Jan Beulich wrote: >> On 08.02.17 at 08:31, wrote: > From: Jan Beulich [mailto:jbeul...@suse.com] > Sent: Monday, February 06, 2017 11:38 PM >>>

Re: [Xen-devel] [PATCH] x86/apicv: enhance posted-interrupt processing

2017-02-17 Thread Chao Gao
On Fri, Feb 17, 2017 at 09:37:45AM +, Xuquan (Quan Xu) wrote: >From a589074281cc22a30ed75a5bccba60e83d2312a6 Mon Sep 17 00:00:00 2001 >From: Quan Xu >Date: Sat, 18 Feb 2017 09:27:37 +0800 >Subject: [PATCH] x86/apicv: enhance posted-interrupt processing > >If guest is already in non-root mode,

Re: [Xen-devel] [PATCH] x86/apicv: enhance posted-interrupt processing

2017-02-20 Thread Chao Gao
On Mon, Feb 20, 2017 at 11:25:29AM +, Xuquan (Quan Xu) wrote: >On February 18, 2017 12:33 AM, Jan Beulich wrote: > On 17.02.17 at 09:49, wrote: >>> On Fri, Feb 17, 2017 at 09:37:45AM +, Xuquan (Quan Xu) wrote: From a589074281cc22a30ed75a5bccba60e83d2312a6 Mon Sep 17 >>00:00:00 2001

Re: [Xen-devel] [PATCH] x86/apicv: enhance posted-interrupt processing

2017-02-20 Thread Chao Gao
On Tue, Feb 21, 2017 at 04:11:53AM +, Xuquan (Quan Xu) wrote: >On February 21, 2017 11:07 AM, Tian, Kevin wrote: >>> From: Xuquan (Quan Xu) [mailto:xuqu...@huawei.com] >>> Sent: Tuesday, February 21, 2017 10:49 AM >>> >>Chao, __iiuc__, your question may be from the comments of >>> >xen/arch/x86

Re: [Xen-devel] [PATCH v8 0/7] VMX: Properly handle pi descriptor and per-cpu blocking list

2017-02-21 Thread Chao Gao
Hi, everyone. Really sorry for digging out this thread. Because feng has left Intel, I will take over this work, address some problems in his v8 patch set and send out a v9 verson later such that VT-d PI can work properly on Xen. Thanks, Chao On Fri, Nov 18, 2016 at 09:57:17AM +0800, Wu, Feng w

Re: [Xen-devel] [PATCH v8 4/7] VT-d: Use one function to update both remapped and posted IRTE

2017-02-22 Thread Chao Gao
On Tue, Nov 22, 2016 at 05:58:56PM +0800, Jan Beulich wrote: On 18.11.16 at 02:57, wrote: >> @@ -597,31 +598,50 @@ static int msi_msg_to_remap_entry( > >Considering you basically re-do most of the function, I think there's >some more adjustment necessary (or at least very desirable) here. > >

Re: [Xen-devel] [PATCH v8 4/7] VT-d: Use one function to update both remapped and posted IRTE

2017-02-22 Thread Chao Gao
On Wed, Feb 22, 2017 at 02:10:25AM -0700, Jan Beulich wrote: On 22.02.17 at 02:53, wrote: >> On Tue, Nov 22, 2016 at 05:58:56PM +0800, Jan Beulich wrote: @@ -637,7 +657,23 @@ static int msi_msg_to_remap_entry( remap_rte->address_hi = 0; remap_rte->data = index - i; >>

Re: [Xen-devel] [PATCH v8 5/7] VT-d: No need to set irq affinity for posted format IRTE

2017-02-22 Thread Chao Gao
On Tue, Nov 22, 2016 at 06:03:51PM +0800, Jan Beulich wrote: On 18.11.16 at 02:58, wrote: >> --- a/xen/drivers/passthrough/vtd/intremap.c >> +++ b/xen/drivers/passthrough/vtd/intremap.c >> @@ -600,27 +600,41 @@ static int msi_msg_to_remap_entry( >> >> if ( !pi_desc ) >> { >> -

Re: [Xen-devel] [PATCH] x86/apicv: enhance posted-interrupt processing

2017-02-23 Thread Chao Gao
On Thu, Feb 23, 2017 at 11:55:15AM +, Xuquan (Quan Xu) wrote: >On February 23, 2017 7:01 PM, Jan Beulich wrote: > On 23.02.17 at 11:53, wrote: >>> On February 23, 2017 5:59 PM, Jan Beulich wrote: >>> On 23.02.17 at 10:28, wrote: > On February 18, 2017 12:33 AM, Jan Beulich wrote:

[Xen-devel] [PATCH] libxl/libxl_pci.c: Fix reverse logic when detaching device

2017-02-23 Thread Chao Gao
Commit 20b75251d97 ("libxl/libxl_pci.c: used LOG*D functions") reverses the logic to call xc_deassign_device(). It makes the device unusable. Signed-off-by: Chao Gao --- tools/libxl/libxl_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/libxl/libxl_pci

[Xen-devel] [PATCH v9 2/8] xen/passthrough: Reject self-(de)assignment of devices

2017-02-27 Thread Chao Gao
That is to say, don't support a domain assigns a device to itself or detachs a device from itself. Signed-off-by: Chao Gao --- v9: - Newly added xen/drivers/passthrough/pci.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/xen/drivers/passthrough/pci.c b/xen/dr

[Xen-devel] [PATCH v9 0/8] VMX: Properly handle pi descriptor and per-cpu

2017-02-27 Thread Chao Gao
es are based on feng's v8 patch (https://lists.xenproject.org/archives/html/xen-devel/2016-11/msg01472.html). Most of these patches are reviewed or acked by maintainers. Patch [2/8], Patch [5/8], Patch [8/8] is added by me to address remainly issues. Chao Gao (3): xen/passthrough: Reject se

[Xen-devel] [PATCH v9 4/8] VMX: Make sure PI is in proper state before install the hooks

2017-02-27 Thread Chao Gao
not been called. So the NDST is in a proper state in vmx_vcpu_block(). Suggested-by: Jan Beulich Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Jan Beulich Acked-by: Kevin Tian --- v6: - Comments changes - Define macro 'APIC_INVALID_DEST' for '0x' v

[Xen-devel] [PATCH v9 1/8] VMX: Permanently assign PI hook vmx_pi_switch_to()

2017-02-27 Thread Chao Gao
Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Konrad Rzeszutek Wilk --- v9: - Comments changes [per Kevin's comments] v8: - Comments changes v7: - comments changes. v6: - Adjust the comments and wording. v5: - Zap "pi_switch_from" hook v4: -

[Xen-devel] [PATCH v9 3/8] VMX: Properly handle pi when all the assigned devices are removed

2017-02-27 Thread Chao Gao
. Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- v9: - Based on [v8 2/7]. Add a assertion before domain pause. v7: - Prevent the domain from pausing itself. v6: - Comments changes - Rename vmx_pi_list_remove() to vmx_pi_unblock_vcpu() v5: - Remove a no-op

[Xen-devel] [PATCH v9 7/8] VMX: Fixup PI descriptor when cpu is offline

2017-02-27 Thread Chao Gao
From: Feng Wu When cpu is offline, we need to move all the vcpus in its blocking list to another online cpu, this patch handles it. Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Jan Beulich Acked-by: Kevin Tian --- v7: - Pass unsigned int to vmx_pi_desc_fixup() v6

[Xen-devel] [PATCH v9 6/8] VT-d: Some cleanups

2017-02-27 Thread Chao Gao
From: Feng Wu Use type-safe structure assignment instead of memcpy() Use sizeof(*iremap_entry). Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Konrad Rzeszutek Wilk Acked-by: Kevin Tian --- v9: - Delete several lines for patch [5/8] has been reworked. v7: - Remove a useless

[Xen-devel] [PATCH v9 5/8] VT-d: Introduce a new function update_irte_for_msi_common

2017-02-27 Thread Chao Gao
-by: Feng Wu Signed-off-by: Chao Gao --- v9: - Newly added. xen/drivers/passthrough/vtd/intremap.c | 232 +++-- 1 file changed, 131 insertions(+), 101 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c index

[Xen-devel] [PATCH v9 8/8] VT-d: Add copy_irte_{to, from}_irt for updating irte

2017-02-27 Thread Chao Gao
intented to be changed. Signed-off-by: Chao Gao --- v9: - Newly added. xen/drivers/passthrough/vtd/intremap.c | 58 -- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrough/vtd/intremap.c

Re: [Xen-devel] [PATCH v9 1/8] VMX: Permanently assign PI hook vmx_pi_switch_to()

2017-02-28 Thread Chao Gao
On Tue, Feb 28, 2017 at 09:43:09AM -0700, Jan Beulich wrote: On 27.02.17 at 02:45, wrote: >> --- a/xen/arch/x86/hvm/vmx/vmx.c >> +++ b/xen/arch/x86/hvm/vmx/vmx.c >> @@ -260,9 +260,15 @@ void vmx_pi_hooks_deassign(struct domain *d) >> >> ASSERT(d->arch.hvm_domain.pi_ops.vcpu_block); >>

Re: [Xen-devel] [PATCH v2] x86/apicv: enhance posted-interrupt processing

2017-03-01 Thread Chao Gao
On Wed, Mar 01, 2017 at 12:38:39AM -0700, Jan Beulich wrote: On 01.03.17 at 04:23, wrote: >> On February 28, 2017 11:08 PM, Jan Beulich wrote: >> On 27.02.17 at 11:53, wrote: If guest is already in non-root mode, an posted interrupt will be directly delivered to guest (leaving

[Xen-devel] [PATCH] x86/vMsi-x: check whether the msixtbl_list has been initialized or not when accessing it

2016-07-28 Thread Chao Gao
reate_bind msixtbl_pt_register and XEN_DOMCTL_unbind_pt_irq pt_irq_destroy_bind msixtbl_pt_unregister do not check this case and will cause Xen panic consequently. Signed-off-by: Chao Gao --- xen/arch/x86/hvm/vmsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff -

[Xen-devel] [PATCH] x86/vMsi-x: check whether msixtbl_list in msixtbl_pt_register()

2016-07-29 Thread Chao Gao
reate_bind msixtbl_pt_register do not check this case. Some errors(malwares, etc.) may lead to calling XEN_DOMCTL_bind_pt_irq without a clear gtable and will cause Xen panic. Signed-off-by: Chao Gao --- xen/arch/x86/hvm/vmsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/vm

Re: [Xen-devel] [xen-unstable test] 104131: regressions - FAIL

2017-01-15 Thread Chao Gao
On Mon, Jan 16, 2017 at 06:27:23AM +, Xuquan (Quan Xu) wrote: >On January 16, 2017 1:26 PM, Tian, Kevin wrote: >>> From: Jan Beulich [mailto:jbeul...@suse.com] >>> Sent: Thursday, January 12, 2017 8:26 PM >>> >>> >>> On 12.01.17 at 13:15, wrote: >>> > On 12/01/17 12:07, Xuquan (Quan Xu) wrote:

[Xen-devel] [PATCH] X86/vmx: Dump PIR and vIRR before ASSERT()

2017-02-06 Thread Chao Gao
s/html/xen-devel/2017-01/msg01019.html). The assertion failure is hard to reproduce. In order to root cause issue, this patch is to add logs to dump PIR and vIRR when failure takes place. It should be reverted once the root cause is found. Signed-off-by: Chao Gao --- xen/arch/x86/hvm/vmx/i

Re: [Xen-devel] [PATCH] X86/vmx: Dump PIR and vIRR before ASSERT()

2017-02-07 Thread Chao Gao
On Tue, Feb 07, 2017 at 03:04:32AM -0700, Jan Beulich wrote: On 07.02.17 at 07:48, wrote: >> Some comment from QEMU/KVM code, in /arch/x86/kvm/lapic.c, >> >> int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu) >> { >> /* This may race with setting of irr in __apic_accept_irq() and >>

Re: [Xen-devel] [PATCH] X86/vmx: Dump PIR and vIRR before ASSERT()

2017-02-07 Thread Chao Gao
On Tue, Feb 07, 2017 at 06:46:16AM -0700, Jan Beulich wrote: On 07.02.17 at 07:32, wrote: >> On Tue, Feb 07, 2017 at 03:04:32AM -0700, Jan Beulich wrote: >> On 07.02.17 at 07:48, wrote: Some comment from QEMU/KVM code, in /arch/x86/kvm/lapic.c, int kvm_lapic_find_highest_

Re: [Xen-devel] [PATCH] X86/vmx: Dump PIR and vIRR before ASSERT()

2017-02-07 Thread Chao Gao
On Tue, Feb 07, 2017 at 09:18:56AM -0700, Jan Beulich wrote: On 07.02.17 at 08:28, wrote: >> On Tue, Feb 07, 2017 at 06:46:16AM -0700, Jan Beulich wrote: >> On 07.02.17 at 07:32, wrote: On Tue, Feb 07, 2017 at 03:04:32AM -0700, Jan Beulich wrote: On 07.02.17 at 07:48, wrot

Re: [Xen-devel] [PATCH] X86/vmx: Dump PIR and vIRR before ASSERT()

2017-02-08 Thread Chao Gao
On Wed, Feb 08, 2017 at 04:06:53PM +0800, Tian, Kevin wrote: >> From: Gao, Chao >> Sent: Wednesday, February 08, 2017 8:12 AM >> >> On Tue, Feb 07, 2017 at 09:18:56AM -0700, Jan Beulich wrote: >> On 07.02.17 at 08:28, wrote: >> >> On Tue, Feb 07, 2017 at 06:46:16AM -0700, Jan Beulich wrote:

Re: [Xen-devel] [PATCH v4] x86/apicv: fix RTC periodic timer and apicv issue

2016-12-21 Thread Chao Gao
Hi, xuquan. I have tested it on my skylake server. W/o this patch the inaccurate wall clock time issue only exists in Win7-32 guest. Win7-64, Win8-32, Win8-64, Win10-32 ,Win10-64 and linux-4.8.0+ guests don't have this issue. W/ this v4 patch, the issue disappears in Win7-32 guest and no wall lock

Re: [Xen-devel] [PATCH v4] x86/apicv: fix RTC periodic timer and apicv issue

2016-12-22 Thread Chao Gao
On Thu, Dec 22, 2016 at 03:48:48PM +0800, Tian, Kevin wrote: >sent too quick. I meant please add your tested-by here. :-) Yes, of course. Tested-by: Chao Gao > >> From: Tian, Kevin >> Sent: Thursday, December 22, 2016 3:48 PM >> >> Thanks a lot! >> >

Re: [Xen-devel] [xen-unstable test] 104131: regressions - FAIL

2017-01-12 Thread Chao Gao
According the code around the assert: movzbl %r14b, %esi 41 0f b6 f6 cmp %esi, %eax 39 f0 jle ... 7e 02 ud2 <0f> 0b mov %rbx, %rdi 48 89 df callq ... e8 51 20 00 00 mov $0x810, %eaxb8 10 08 00 00 so I think one is 0x38 %eax, the other is 0x

Re: [Xen-devel] [PATCH v2] x86/apicv: enhance posted-interrupt processing

2017-03-02 Thread Chao Gao
On Thu, Mar 02, 2017 at 07:42:33AM +, Xuquan (Quan Xu) wrote: >On March 01, 2017 2:24 PM, wrote: >> >>Good point. I ignore v->processor maybe change. I have thought over >> __vmx_deliver_posted_interrupt() again and want to share you my opinion. >>First of all, __vmx_deliver_posted_interrupt()

[Xen-devel] [PATCH v3] x86/apicv: Enhance posted-interrupt processing

2017-03-02 Thread Chao Gao
ugh time to upstream this fix patch. He asks me to do this. Merge another his related patch (https://lists.xenproject.org/archives/html/xen-devel/2017-02/msg02885.html). Signed-off-by: Quan Xu Signed-off-by: Chao Gao --- xen/arch/x86/hvm/vmx/vmx.c | 56 --

Re: [Xen-devel] [PATCH v3] x86/apicv: Enhance posted-interrupt processing

2017-03-02 Thread Chao Gao
On Thu, Mar 02, 2017 at 02:41:55AM -0700, Jan Beulich wrote: On 02.03.17 at 02:49, wrote: > >The patch title, btw, makes it looks like this isn't a bug fix, which is >contrary to the understanding I've gained so far. Thanks to your patience and your changing so much description for me. Also

Re: [Xen-devel] [PATCH v9 5/8] VT-d: Introduce a new function update_irte_for_msi_common

2017-03-02 Thread Chao Gao
On Thu, Mar 02, 2017 at 01:58:14AM -0700, Jan Beulich wrote: On 27.02.17 at 02:45, wrote: >> @@ -547,16 +548,116 @@ static int remap_entry_to_msi_msg( >> return 0; >> } >> >> +/* >> + * This function is a common interface to update irte for msi case. >> + * >> + * If @pi_desc != NULL

[Xen-devel] [PATCH v4] x86/apicv: Fix wrong IPI suppression during posted interrupt delivery

2017-03-03 Thread Chao Gao
ftirq is raised) regardless of VT-d PI enabled or not. The only difference is when an IPI arrives at the pCPU which is happened in non-root mode, the code will not raise a useless softirq since the IPI is consumed by hardware rather than raise a softirq unconditionally. Signed-off-by: Quan Xu Signed-o

Re: [Xen-devel] [PATCH v4] x86/apicv: Fix wrong IPI suppression during posted interrupt delivery

2017-03-05 Thread Chao Gao
On Mon, Mar 06, 2017 at 03:53:44AM +, Xuquan (Quan Xu) wrote: >On March 03, 2017 10:36 AM, Chao Gao wrote: >>+/* >>+ * Just like vcpu_kick(), nothing is needed for the following two cases: >>+ * 1. The target vCPU is not running, meaning it is blocked or runna

Re: [Xen-devel] [xen-unstable test] 106504: regressions - FAIL

2017-03-07 Thread Chao Gao
On Tue, Mar 07, 2017 at 02:16:50AM -0700, Jan Beulich wrote: On 07.03.17 at 06:52, wrote: >> flight 106504 xen-unstable real [real] >> http://logs.test-lab.xenproject.org/osstest/logs/106504/ >> >> Regressions :-( >> >> Tests which did not succeed and are blocking, >> including tests which

[Xen-devel] [PATCH v10 1/6] VT-d: Introduce new fields in msi_desc to track binding with guest interrupt

2017-03-15 Thread Chao Gao
uch 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. Signed-off-by: Feng Wu Signed-off-by: Chao Gao --- v10: - Newly added. xen/arch/x86/msi.c | 1 + xen

[Xen-devel] [PATCH v10 4/6] VT-d: introduce update_irte to update irte safely

2017-03-15 Thread Chao Gao
intented to be updated. Signed-off-by: Chao Gao --- 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/drivers/passthrough/vtd/intremap.c | 36

[Xen-devel] [PATCH v10 2/6] VT-d: Some cleanups

2017-03-15 Thread Chao Gao
From: Feng Wu Use type-safe structure assignment instead of memcpy() Use sizeof(*iremap_entry). Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Konrad Rzeszutek Wilk Acked-by: Kevin Tian --- v10: - Added several lines for patch [1/6] has been reworked. v9: - Delete several

[Xen-devel] [PATCH v10 0/6] VMX: Properly handle pi descriptor and per-cpu blocking list

2017-03-15 Thread Chao Gao
es this problem. Chao Gao (4): 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: don't migrate pirq when it is delivered through VT-d PI passthrough/io: Fall back to remapping interrupt when w

[Xen-devel] [PATCH v10 3/6] VMX: Fixup PI descriptor when cpu is offline

2017-03-15 Thread Chao Gao
From: Feng Wu When cpu is offline, we need to move all the vcpus in its blocking list to another online cpu, this patch handles it. Signed-off-by: Feng Wu Signed-off-by: Chao Gao Reviewed-by: Jan Beulich Acked-by: Kevin Tian --- v7: - Pass unsigned int to vmx_pi_desc_fixup() v6

[Xen-devel] [PATCH v10 5/6] passthrough/io: don't migrate pirq when it is delivered through VT-d PI

2017-03-15 Thread Chao Gao
migration so pirq directly injected to guest needn't be migrated. This patch adds a indicator, @via_pi, to show whether the pt irq is delivered through VT-d PI. Signed-off-by: Chao Gao --- v10: - Newly added. xen/arch/x86/hvm/hvm.c | 3 +++ xen/drivers/passthrough/io.c

[Xen-devel] [PATCH v10 6/6] passthrough/io: Fall back to remapping interrupt when we can't use VT-d PI

2017-03-15 Thread Chao Gao
when guest wrongly configurate destination of pirq or makes it have multi-destination vcpus. Signed-off-by: Chao Gao --- v10: - Newly added xen/drivers/passthrough/io.c | 9 + xen/drivers/passthrough/vtd/intremap.c | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff

Re: [Xen-devel] [PATCH v10 1/6] VT-d: Introduce new fields in msi_desc to track binding with guest interrupt

2017-03-15 Thread Chao Gao
On Wed, Mar 15, 2017 at 10:41:13AM -0600, Jan Beulich wrote: On 15.03.17 at 06:11, wrote: >> --- a/xen/drivers/passthrough/vtd/intremap.c >> +++ b/xen/drivers/passthrough/vtd/intremap.c >> @@ -552,11 +552,12 @@ static int msi_msg_to_remap_entry( >> struct msi_desc *msi_desc, struct msi_m

Re: [Xen-devel] [PATCH v10 4/6] VT-d: introduce update_irte to update irte safely

2017-03-15 Thread Chao Gao
On Wed, Mar 15, 2017 at 10:48:25AM -0600, Jan Beulich wrote: On 15.03.17 at 06:11, wrote: >> +/* >> + * The following method to update IRTE is safe on condition that >> + * only the high qword or the low qword is to be updated. >> + * If entire IRTE is to be up

Re: [Xen-devel] [PATCH v10 4/6] VT-d: introduce update_irte to update irte safely

2017-03-17 Thread Chao Gao
On Thu, Mar 16, 2017 at 04:29:29AM -0600, Jan Beulich wrote: On 15.03.17 at 23:39, wrote: >> On Wed, Mar 15, 2017 at 10:48:25AM -0600, Jan Beulich wrote: >> On 15.03.17 at 06:11, wrote: +/* + * The following method to update IRTE is safe on condition that +

Re: [Xen-devel] [PATCH v10 5/6] passthrough/io: don't migrate pirq when it is delivered through VT-d PI

2017-03-20 Thread Chao Gao
On Fri, Mar 17, 2017 at 04:43:08AM -0600, Jan Beulich wrote: On 15.03.17 at 06:11, wrote: >> @@ -441,6 +442,15 @@ int pt_irq_create_bind( >> >> dest_vcpu_id = hvm_girq_dest_2_vcpu_id(d, dest, dest_mode); >> pirq_dpci->gmsi.dest_vcpu_id = dest_vcpu_id; >> + >> +pirq

Re: [Xen-devel] [PATCH v10 5/6] passthrough/io: don't migrate pirq when it is delivered through VT-d PI

2017-03-20 Thread Chao Gao
On Mon, Mar 20, 2017 at 03:18:18AM -0600, Jan Beulich wrote: On 20.03.17 at 02:59, wrote: >> On Fri, Mar 17, 2017 at 04:43:08AM -0600, Jan Beulich wrote: >> On 15.03.17 at 06:11, wrote: +if ( iommu_intpost ) +{ +vcpu = pi_find_dest_vcpu(d, dest,

Re: [Xen-devel] [PATCH v10 5/6] passthrough/io: don't migrate pirq when it is delivered through VT-d PI

2017-03-20 Thread Chao Gao
On Mon, Mar 20, 2017 at 04:26:10AM -0600, Jan Beulich wrote: On 20.03.17 at 03:38, wrote: >> On Mon, Mar 20, 2017 at 03:18:18AM -0600, Jan Beulich wrote: >> On 20.03.17 at 02:59, wrote: On Fri, Mar 17, 2017 at 04:43:08AM -0600, Jan Beulich wrote: On 15.03.17 at 06:11, wrot

Re: [Xen-devel] [PATCH v10 5/6] passthrough/io: don't migrate pirq when it is delivered through VT-d PI

2017-03-20 Thread Chao Gao
On Mon, Mar 20, 2017 at 06:50:37AM -0600, Jan Beulich wrote: On 20.03.17 at 06:22, wrote: >> On Mon, Mar 20, 2017 at 04:26:10AM -0600, Jan Beulich wrote: >> On 20.03.17 at 03:38, wrote: On Mon, Mar 20, 2017 at 03:18:18AM -0600, Jan Beulich wrote: spin_unlock(&d->ev

Re: [Xen-devel] [PATCH v10 1/6] VT-d: Introduce new fields in msi_desc to track binding with guest interrupt

2017-03-22 Thread Chao Gao
On Wed, Mar 22, 2017 at 01:59:19PM +0800, Tian, Kevin wrote: >> From: Gao, Chao >> Sent: Wednesday, March 15, 2017 1:11 PM >> >> Currently, msi_msg_to_remap_entry is buggy when the live IRTE is in posted >> format. Straightforwardly, we can let caller specify which format of IRTE >> they >> want

Re: [Xen-devel] [xen-unstable test] 106504: regressions - FAIL

2017-03-22 Thread Chao Gao
On Tue, Mar 07, 2017 at 07:11:22AM -0700, Jan Beulich wrote: On 07.03.17 at 05:24, wrote: >> On Tue, Mar 07, 2017 at 02:16:50AM -0700, Jan Beulich wrote: >> On 07.03.17 at 06:52, wrote: flight 106504 xen-unstable real [real] http://logs.test-lab.xenproject.org/osstest/logs/1065

Re: [Xen-devel] [xen-unstable test] 106504: regressions - FAIL

2017-03-22 Thread Chao Gao
On Wed, Mar 22, 2017 at 06:47:33AM -0600, Jan Beulich wrote: On 22.03.17 at 05:53, wrote: >> I have written a xtf test case (many codes are from hvmloader) to >> trigger this assertion. The test case is in attachments. > >Thanks for doing this. > >> Bottom is the output >> of this test. This

<    1   2   3