Re: [PATCH 3/3] xen/vm_event: Add safe to disable vm_event

2020-05-20 Thread Tamas K Lengyel
On Wed, May 20, 2020 at 7:45 AM Jan Beulich  wrote:
>
> On 15.05.2020 18:53, Tamas K Lengyel wrote:
> > --- a/xen/arch/x86/hvm/hvm.c
> > +++ b/xen/arch/x86/hvm/hvm.c
> > @@ -563,15 +563,41 @@ void hvm_do_resume(struct vcpu *v)
> >  v->arch.hvm.inject_event.vector = HVM_EVENT_VECTOR_UNSET;
> >  }
> >
> > -if ( unlikely(v->arch.vm_event) && 
> > v->arch.monitor.next_interrupt_enabled )
> > +if ( unlikely(v->arch.vm_event) )
> >  {
> > -struct x86_event info;
> > +struct domain *d = v->domain;
>
> const

This can't be const, we disable the safe_to_disable option below after
sending the one-shot async event.

Tamas



Re: [PATCH 3/3] xen/vm_event: Add safe to disable vm_event

2020-05-20 Thread Tamas K Lengyel
On Wed, May 20, 2020 at 7:45 AM Jan Beulich  wrote:
>
> On 15.05.2020 18:53, Tamas K Lengyel wrote:
> > --- a/xen/arch/x86/hvm/hvm.c
> > +++ b/xen/arch/x86/hvm/hvm.c
> > @@ -563,15 +563,41 @@ void hvm_do_resume(struct vcpu *v)
> >  v->arch.hvm.inject_event.vector = HVM_EVENT_VECTOR_UNSET;
> >  }
> >
> > -if ( unlikely(v->arch.vm_event) && 
> > v->arch.monitor.next_interrupt_enabled )
> > +if ( unlikely(v->arch.vm_event) )
> >  {
> > -struct x86_event info;
> > +struct domain *d = v->domain;
>
> const
>
> > +if ( v->arch.monitor.next_interrupt_enabled )
> > +{
> > +struct x86_event info;
> > +
> > +if ( hvm_get_pending_event(v, ) )
> > +{
> > +hvm_monitor_interrupt(info.vector, info.type, 
> > info.error_code,
> > +  info.cr2);
> > +v->arch.monitor.next_interrupt_enabled = false;
> > +}
> > +}
> >
> > -if ( hvm_get_pending_event(v, ) )
> > +if ( d->arch.monitor.safe_to_disable )
> >  {
> > -hvm_monitor_interrupt(info.vector, info.type, info.error_code,
> > -  info.cr2);
> > -v->arch.monitor.next_interrupt_enabled = false;
> > +struct vcpu *check_vcpu;
>
> const again, requiring a respective adjustment to patch 2.
>
> > +bool pending_op = false;
> > +
> > +for_each_vcpu ( d, check_vcpu )
> > +{
> > +if ( vm_event_check_pending_op(check_vcpu) )
> > +{
> > +pending_op = true;
> > +break;
> > +}
> > +}
> > +
> > +if ( !pending_op )
> > +{
> > +hvm_monitor_safe_to_disable();
>
> This new function returns bool without the caller caring about the
> return value.

Yea, there is actually nothing to be done if the event can't be sent
for whatever reason, I guess I'll just turn it to void.

Tamas



Re: [PATCH 3/3] xen/vm_event: Add safe to disable vm_event

2020-05-20 Thread Jan Beulich
On 15.05.2020 18:53, Tamas K Lengyel wrote:
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -563,15 +563,41 @@ void hvm_do_resume(struct vcpu *v)
>  v->arch.hvm.inject_event.vector = HVM_EVENT_VECTOR_UNSET;
>  }
>  
> -if ( unlikely(v->arch.vm_event) && 
> v->arch.monitor.next_interrupt_enabled )
> +if ( unlikely(v->arch.vm_event) )
>  {
> -struct x86_event info;
> +struct domain *d = v->domain;

const

> +if ( v->arch.monitor.next_interrupt_enabled )
> +{
> +struct x86_event info;
> +
> +if ( hvm_get_pending_event(v, ) )
> +{
> +hvm_monitor_interrupt(info.vector, info.type, 
> info.error_code,
> +  info.cr2);
> +v->arch.monitor.next_interrupt_enabled = false;
> +}
> +}
>  
> -if ( hvm_get_pending_event(v, ) )
> +if ( d->arch.monitor.safe_to_disable )
>  {
> -hvm_monitor_interrupt(info.vector, info.type, info.error_code,
> -  info.cr2);
> -v->arch.monitor.next_interrupt_enabled = false;
> +struct vcpu *check_vcpu;

const again, requiring a respective adjustment to patch 2.

> +bool pending_op = false;
> +
> +for_each_vcpu ( d, check_vcpu )
> +{
> +if ( vm_event_check_pending_op(check_vcpu) )
> +{
> +pending_op = true;
> +break;
> +}
> +}
> +
> +if ( !pending_op )
> +{
> +hvm_monitor_safe_to_disable();

This new function returns bool without the caller caring about the
return value.

Jan