Re: [Xen-devel] [Patch RFC 07/13] vt-d: If the qi_flag is Set, the domain's vCPUs are not allowed to

2015-09-16 Thread Julien Grall

Hi Quan,

On 16/09/2015 14:24, Quan Xu wrote:

diff --git a/xen/arch/x86/x86_64/asm-offsets.c 
b/xen/arch/x86/x86_64/asm-offsets.c
index 447c650..d26b026 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -116,6 +116,7 @@ void __dummy__(void)
  BLANK();

  OFFSET(DOMAIN_is_32bit_pv, struct domain, arch.is_32bit_pv);
+OFFSET(QI_flag, struct domain, arch.hvm_domain.hvm_iommu.qi_flag);
  BLANK();

  OFFSET(VMCB_rax, struct vmcb_struct, rax);
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 1b9fcfc..1f62e3b 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1479,6 +1479,11 @@ int continue_hypercall_on_cpu(
  return 0;
  }

+void do_qi_flushing(struct domain *d)
+{
+do_sched_op(SCHEDOP_yield, guest_handle_from_ptr(NULL, void));


SCHEDOP_yield is as wrapper to vcpu_yield() to would be called by the guest.

It would be simpler to use the latter. You may even be able to call it 
directly from the assembly code rather than introducing is a wrapper.


If not, this function should go in x86 specific code (maybe 
arch/x86/domain.c ?)




+}
+
  /*
   * Local variables:
   * mode: C
diff --git a/xen/include/xen/hvm/iommu.h b/xen/include/xen/hvm/iommu.h
index e838905..e40fc7b 100644
--- a/xen/include/xen/hvm/iommu.h
+++ b/xen/include/xen/hvm/iommu.h
@@ -57,6 +57,8 @@ struct hvm_iommu {
  DECLARE_BITMAP(features, IOMMU_FEAT_count);
  };

+void do_qi_flushing(struct domain *d);
+


If you declare the function in file.c you should add the prototype in 
file.h.


I.e as you defined the function in common/domain.c, the prototype should 
go in xen/domain.h.



  #define iommu_set_feature(d, f)   set_bit((f), domain_hvm_iommu(d)->features)
  #define iommu_clear_feature(d, f) clear_bit((f), 
domain_hvm_iommu(d)->features)




Regards,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [Patch RFC 07/13] vt-d: If the qi_flag is Set, the domain's vCPUs are not allowed to

2015-09-16 Thread Xu, Quan


> -Original Message-
> From: Julien Grall [mailto:julien.gr...@citrix.com]
> Sent: Wednesday, September 16, 2015 5:44 PM
> To: Xu, Quan; andrew.coop...@citrix.com; Dong, Eddie; ian.campb...@citrix.com;
> ian.jack...@eu.citrix.com; jbeul...@suse.com; Nakajima, Jun; k...@xen.org;
> Tian, Kevin; t...@xen.org; Zhang, Yang Z; george.dun...@eu.citrix.com
> Cc: xen-devel@lists.xen.org
> Subject: Re: [Xen-devel] [Patch RFC 07/13] vt-d: If the qi_flag is Set, the 
> domain's
> vCPUs are not allowed to
> 
> Hi Quan,
> 
> On 16/09/2015 14:24, Quan Xu wrote:
> > diff --git a/xen/arch/x86/x86_64/asm-offsets.c
> > b/xen/arch/x86/x86_64/asm-offsets.c
> > index 447c650..d26b026 100644
> > --- a/xen/arch/x86/x86_64/asm-offsets.c
> > +++ b/xen/arch/x86/x86_64/asm-offsets.c
> > @@ -116,6 +116,7 @@ void __dummy__(void)
> >   BLANK();
> >
> >   OFFSET(DOMAIN_is_32bit_pv, struct domain, arch.is_32bit_pv);
> > +OFFSET(QI_flag, struct domain,
> > + arch.hvm_domain.hvm_iommu.qi_flag);
> >   BLANK();
> >
> >   OFFSET(VMCB_rax, struct vmcb_struct, rax); diff --git
> > a/xen/common/domain.c b/xen/common/domain.c index 1b9fcfc..1f62e3b
> > 100644
> > --- a/xen/common/domain.c
> > +++ b/xen/common/domain.c
> > @@ -1479,6 +1479,11 @@ int continue_hypercall_on_cpu(
> >   return 0;
> >   }
> >
> > +void do_qi_flushing(struct domain *d) {
> > +do_sched_op(SCHEDOP_yield, guest_handle_from_ptr(NULL, void));
> 
> SCHEDOP_yield is as wrapper to vcpu_yield() to would be called by the guest.
> 
> It would be simpler to use the latter. You may even be able to call it 
> directly from
> the assembly code rather than introducing is a wrapper.
> 

Agreed.
I will test it. if it is working, I will modify it in next version. 


> If not, this function should go in x86 specific code (maybe arch/x86/domain.c 
> ?)
> 
> 
> > +}
> > +
> >   /*
> >* Local variables:
> >* mode: C
> > diff --git a/xen/include/xen/hvm/iommu.h b/xen/include/xen/hvm/iommu.h
> > index e838905..e40fc7b 100644
> > --- a/xen/include/xen/hvm/iommu.h
> > +++ b/xen/include/xen/hvm/iommu.h
> > @@ -57,6 +57,8 @@ struct hvm_iommu {
> >   DECLARE_BITMAP(features, IOMMU_FEAT_count);
> >   };
> >
> > +void do_qi_flushing(struct domain *d);
> > +
> 
> If you declare the function in file.c you should add the prototype in
> file.h.
> 
> I.e as you defined the function in common/domain.c, the prototype should
> go in xen/domain.h.

In general, I should define these function/macro for x86 only.. 
Thanks Julien.

Quan

> 
> >   #define iommu_set_feature(d, f)   set_bit((f),
> domain_hvm_iommu(d)->features)
> >   #define iommu_clear_feature(d, f) clear_bit((f),
> domain_hvm_iommu(d)->features)
> >
> >
> 
> Regards,
> 
> --
> Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch RFC 07/13] vt-d: If the qi_flag is Set, the domain's vCPUs are not allowed to

2015-09-15 Thread Quan Xu
entry guest mode and put into the SCHEDOP_yield list.

Signed-off-by: Quan Xu 
---
 xen/arch/x86/hvm/vmx/entry.S  | 10 ++
 xen/arch/x86/x86_64/asm-offsets.c |  1 +
 xen/common/domain.c   |  5 +
 xen/include/xen/hvm/iommu.h   |  2 ++
 4 files changed, 18 insertions(+)

diff --git a/xen/arch/x86/hvm/vmx/entry.S b/xen/arch/x86/hvm/vmx/entry.S
index 2a4ed57..53a4c58 100644
--- a/xen/arch/x86/hvm/vmx/entry.S
+++ b/xen/arch/x86/hvm/vmx/entry.S
@@ -66,6 +66,10 @@ ENTRY(vmx_asm_vmexit_handler)
 cmp  %ecx,(%rdx,%rax,1)
 jnz  .Lvmx_process_softirqs
 
+mov  VCPU_domain(%rbx),%rax
+cmp  $0,QI_flag(%rax)
+jne  .Lqi_flushing
+
 cmp  %cl,VCPU_vmx_emulate(%rbx)
 jne .Lvmx_goto_emulator
 cmp  %cl,VCPU_vmx_realmode(%rbx)
@@ -125,3 +129,9 @@ ENTRY(vmx_asm_do_vmentry)
 sti
 call do_softirq
 jmp  .Lvmx_do_vmentry
+
+.Lqi_flushing:
+sti
+mov %rax,%rdi
+call do_qi_flushing
+jmp  .Lvmx_do_vmentry
diff --git a/xen/arch/x86/x86_64/asm-offsets.c 
b/xen/arch/x86/x86_64/asm-offsets.c
index 447c650..d26b026 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -116,6 +116,7 @@ void __dummy__(void)
 BLANK();
 
 OFFSET(DOMAIN_is_32bit_pv, struct domain, arch.is_32bit_pv);
+OFFSET(QI_flag, struct domain, arch.hvm_domain.hvm_iommu.qi_flag);
 BLANK();
 
 OFFSET(VMCB_rax, struct vmcb_struct, rax);
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 1b9fcfc..1f62e3b 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -1479,6 +1479,11 @@ int continue_hypercall_on_cpu(
 return 0;
 }
 
+void do_qi_flushing(struct domain *d)
+{
+do_sched_op(SCHEDOP_yield, guest_handle_from_ptr(NULL, void));
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/xen/hvm/iommu.h b/xen/include/xen/hvm/iommu.h
index e838905..e40fc7b 100644
--- a/xen/include/xen/hvm/iommu.h
+++ b/xen/include/xen/hvm/iommu.h
@@ -57,6 +57,8 @@ struct hvm_iommu {
 DECLARE_BITMAP(features, IOMMU_FEAT_count);
 };
 
+void do_qi_flushing(struct domain *d);
+
 #define iommu_set_feature(d, f)   set_bit((f), domain_hvm_iommu(d)->features)
 #define iommu_clear_feature(d, f) clear_bit((f), domain_hvm_iommu(d)->features)
 
-- 
1.8.3.2


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel