Re: [Xen-devel] [PATCH v6 08/18] vmx: Suppress posting interrupts when 'SN' is set
>>> On 06.09.15 at 04:33,wrote: >> From: Jan Beulich [mailto:jbeul...@suse.com] >> Sent: Friday, September 04, 2015 10:53 PM >> >>> On 25.08.15 at 03:57, wrote: >> > --- a/xen/arch/x86/hvm/vmx/vmx.c >> > +++ b/xen/arch/x86/hvm/vmx/vmx.c >> > @@ -1701,8 +1701,36 @@ static void vmx_deliver_posted_intr(struct vcpu >> *v, u8 vector) >> > */ >> > pi_set_on(>arch.hvm_vmx.pi_desc); >> > } >> > -else if ( !pi_test_and_set_on(>arch.hvm_vmx.pi_desc) ) >> > +else >> > { >> > +struct pi_desc old, new, prev; >> > + >> > +/* To skip over first check in the loop below. */ >> > +prev.control = 0; >> >> Why don't you just read the field instead of adding the comment? > > What do you mean by "read the field"? Could you please elaborate it? prev.control = v->arch.hvm_vmx.pi_desc.control; Jan ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v6 08/18] vmx: Suppress posting interrupts when 'SN' is set
> -Original Message- > From: Jan Beulich [mailto:jbeul...@suse.com] > Sent: Friday, September 04, 2015 10:53 PM > To: Wu, Feng > Cc: Andrew Cooper; Tian, Kevin; xen-devel@lists.xen.org; Keir Fraser > Subject: Re: [PATCH v6 08/18] vmx: Suppress posting interrupts when 'SN' is > set > > >>> On 25.08.15 at 03:57,wrote: > > --- a/xen/arch/x86/hvm/vmx/vmx.c > > +++ b/xen/arch/x86/hvm/vmx/vmx.c > > @@ -1701,8 +1701,36 @@ static void vmx_deliver_posted_intr(struct vcpu > *v, u8 vector) > > */ > > pi_set_on(>arch.hvm_vmx.pi_desc); > > } > > -else if ( !pi_test_and_set_on(>arch.hvm_vmx.pi_desc) ) > > +else > > { > > +struct pi_desc old, new, prev; > > + > > +/* To skip over first check in the loop below. */ > > +prev.control = 0; > > Why don't you just read the field instead of adding the comment? What do you mean by "read the field"? Could you please elaborate it? Thanks, Feng ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v6 08/18] vmx: Suppress posting interrupts when 'SN' is set
>>> On 25.08.15 at 03:57,wrote: > --- a/xen/arch/x86/hvm/vmx/vmx.c > +++ b/xen/arch/x86/hvm/vmx/vmx.c > @@ -1701,8 +1701,36 @@ static void vmx_deliver_posted_intr(struct vcpu *v, u8 > vector) > */ > pi_set_on(>arch.hvm_vmx.pi_desc); > } > -else if ( !pi_test_and_set_on(>arch.hvm_vmx.pi_desc) ) > +else > { > +struct pi_desc old, new, prev; > + > +/* To skip over first check in the loop below. */ > +prev.control = 0; Why don't you just read the field instead of adding the comment? > +do { > +/* > + * Currently, we don't support urgent interrupt, all > + * interrupts are recognized as non-urgent interrupt, > + * so we cannot send posted-interrupt when 'SN' is set. > + * Besides that, if 'ON' is already set, we cannot set > + * posted-interrupts as well. > + */ > +if ( pi_test_sn() || pi_test_on() ) > +{ > +vcpu_kick(v); > +return; > +} > + > +old.control = v->arch.hvm_vmx.pi_desc.control & > + ~( 1 << POSTED_INTR_ON | 1 << POSTED_INTR_SN ); > +new.control = v->arch.hvm_vmx.pi_desc.control | > + 1 << POSTED_INTR_ON; Missing parentheses around the shifts. In the former case there are also stray blanks inside the parentheses. Jan ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
[Xen-devel] [PATCH v6 08/18] vmx: Suppress posting interrupts when 'SN' is set
Currently, we don't support urgent interrupt, all interrupts are recognized as non-urgent interrupt, so we cannot send posted-interrupt when 'SN' is set. CC: Kevin Tian kevin.t...@intel.com CC: Keir Fraser k...@xen.org CC: Jan Beulich jbeul...@suse.com CC: Andrew Cooper andrew.coop...@citrix.com Signed-off-by: Feng Wu feng...@intel.com Reviewed-by: Konrad Rzeszutek Wilk konrad.w...@oracle.com --- v6: - Add some comments v5: - keep the vcpu_kick() at the end of vmx_deliver_posted_intr() - Keep the 'return' after calling __vmx_deliver_posted_interrupt() v4: - Coding style. - V3 removes a vcpu_kick() from the eoi_exitmap_changed path incorrectly, fix it. v3: - use cmpxchg to test SN/ON and set ON xen/arch/x86/hvm/vmx/vmx.c | 30 +- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index c32d863..2c1c770 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1701,8 +1701,36 @@ static void vmx_deliver_posted_intr(struct vcpu *v, u8 vector) */ pi_set_on(v-arch.hvm_vmx.pi_desc); } -else if ( !pi_test_and_set_on(v-arch.hvm_vmx.pi_desc) ) +else { +struct pi_desc old, new, prev; + +/* To skip over first check in the loop below. */ +prev.control = 0; + +do { +/* + * Currently, we don't support urgent interrupt, all + * interrupts are recognized as non-urgent interrupt, + * so we cannot send posted-interrupt when 'SN' is set. + * Besides that, if 'ON' is already set, we cannot set + * posted-interrupts as well. + */ +if ( pi_test_sn(prev) || pi_test_on(prev) ) +{ +vcpu_kick(v); +return; +} + +old.control = v-arch.hvm_vmx.pi_desc.control + ~( 1 POSTED_INTR_ON | 1 POSTED_INTR_SN ); +new.control = v-arch.hvm_vmx.pi_desc.control | + 1 POSTED_INTR_ON; + +prev.control = cmpxchg(v-arch.hvm_vmx.pi_desc.control, + old.control, new.control); +} while ( prev.control != old.control ); + __vmx_deliver_posted_interrupt(v); return; } -- 2.1.0 ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel