xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL
@ 2016-04-09  5:54 Razvan Cojocaru
  2016-04-29 16:12 ` Razvan Cojocaru
  0 siblings, 1 reply; 6+ messages in thread
From: Razvan Cojocaru @ 2016-04-09  5:54 UTC (permalink / raw)
  To: xen-devel; +Cc: andrew.cooper3, keir, Razvan Cojocaru, jbeulich

It is meaningless (and potentially dangerous - see hvmemul_virtual_to_linear())
to set mem_access_emulate_each_rep before xc_monitor_enable() (which allocates
vcpu->arch.vm_event) has been called, so return an error from the
XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP hypercall when that is the case.

Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citirx.com>

---
Changes since V2:
 - Updated the if() condition as recommended by Andrew Cooper.
 - Added Andrew Cooper's Reviewed-by.
---
 xen/include/asm-x86/monitor.h | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h
index 0954b59..d367099 100644
--- a/xen/include/asm-x86/monitor.h
+++ b/xen/include/asm-x86/monitor.h
@@ -32,19 +32,29 @@
 static inline
 int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop)
 {
+    int rc = 0;
+
     switch ( mop->op )
     {
     case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP:
         domain_pause(d);
-        d->arch.mem_access_emulate_each_rep = !!mop->event;
+        /*
+         * Enabling mem_access_emulate_each_rep without a vm_event subscriber
+         * is meaningless.
+         */
+        if ( d->max_vcpus && d->vcpu[0] && d->vcpu[0]->arch.vm_event )
+            d->arch.mem_access_emulate_each_rep = !!mop->event;
+        else
+            rc = -EINVAL;
+
         domain_unpause(d);
         break;
 
     default:
-        return -EOPNOTSUPP;
+        rc = -EOPNOTSUPP;
     }
 
-    return 0;
+    return rc;
 }
 
 int arch_monitor_domctl_event(struct domain *d,
-- 
1.9.1


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH V3] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL
  2016-04-09  5:54 [PATCH V3] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL Razvan Cojocaru
@ 2016-04-29 16:12 ` Razvan Cojocaru
  2016-05-02 10:26   ` Wei Liu
  2016-05-03  8:14   ` Jan Beulich
  0 siblings, 2 replies; 6+ messages in thread
From: Razvan Cojocaru @ 2016-04-29 16:12 UTC (permalink / raw)
  To: xen-devel; +Cc: andrew.cooper3, keir, wei.liu2@citrix.com, jbeulich

On 04/09/16 08:54, Razvan Cojocaru wrote:
> It is meaningless (and potentially dangerous - see hvmemul_virtual_to_linear())
> to set mem_access_emulate_each_rep before xc_monitor_enable() (which allocates
> vcpu->arch.vm_event) has been called, so return an error from the
> XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP hypercall when that is the case.
> 
> Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citirx.com>
> 
> ---
> Changes since V2:
>  - Updated the if() condition as recommended by Andrew Cooper.
>  - Added Andrew Cooper's Reviewed-by.
> ---
>  xen/include/asm-x86/monitor.h | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h
> index 0954b59..d367099 100644
> --- a/xen/include/asm-x86/monitor.h
> +++ b/xen/include/asm-x86/monitor.h
> @@ -32,19 +32,29 @@
>  static inline
>  int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop)
>  {
> +    int rc = 0;
> +
>      switch ( mop->op )
>      {
>      case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP:
>          domain_pause(d);
> -        d->arch.mem_access_emulate_each_rep = !!mop->event;
> +        /*
> +         * Enabling mem_access_emulate_each_rep without a vm_event subscriber
> +         * is meaningless.
> +         */
> +        if ( d->max_vcpus && d->vcpu[0] && d->vcpu[0]->arch.vm_event )
> +            d->arch.mem_access_emulate_each_rep = !!mop->event;
> +        else
> +            rc = -EINVAL;
> +
>          domain_unpause(d);
>          break;
>  
>      default:
> -        return -EOPNOTSUPP;
> +        rc = -EOPNOTSUPP;
>      }
>  
> -    return 0;
> +    return rc;
>  }
>  
>  int arch_monitor_domctl_event(struct domain *d,

Hello,

According to the previous list discussion with Andrew Cooper, this fix
might be considered for the 4.7 release, so CC-ing Wei for a release
ack, as suggested.


Thanks,
Razvan

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V3] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL
  2016-04-29 16:12 ` Razvan Cojocaru
@ 2016-05-02 10:26   ` Wei Liu
  2016-05-03  8:14   ` Jan Beulich
  1 sibling, 0 replies; 6+ messages in thread
From: Wei Liu @ 2016-05-02 10:26 UTC (permalink / raw)
  To: Razvan Cojocaru
  Cc: andrew.cooper3, keir, wei.liu2@citrix.com, jbeulich, xen-devel

On Fri, Apr 29, 2016 at 07:12:47PM +0300, Razvan Cojocaru wrote:
> On 04/09/16 08:54, Razvan Cojocaru wrote:
> > It is meaningless (and potentially dangerous - see hvmemul_virtual_to_linear())
> > to set mem_access_emulate_each_rep before xc_monitor_enable() (which allocates
> > vcpu->arch.vm_event) has been called, so return an error from the
> > XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP hypercall when that is the case.
> > 
> > Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
> > Reviewed-by: Andrew Cooper <andrew.cooper3@citirx.com>

Release-acked-by: Wei Liu <wei.liu2@citrix.com>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V3] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL
  2016-04-29 16:12 ` Razvan Cojocaru
  2016-05-02 10:26   ` Wei Liu
@ 2016-05-03  8:14   ` Jan Beulich
  2016-05-03  8:18     ` Razvan Cojocaru
  1 sibling, 1 reply; 6+ messages in thread
From: Jan Beulich @ 2016-05-03  8:14 UTC (permalink / raw)
  To: Razvan Cojocaru
  Cc: andrew.cooper3, keir, tamas, wei.liu2@citrix.com, xen-devel

>>> On 29.04.16 at 18:12, <rcojocaru@bitdefender.com> wrote:
> On 04/09/16 08:54, Razvan Cojocaru wrote:
>> It is meaningless (and potentially dangerous - see hvmemul_virtual_to_linear())
>> to set mem_access_emulate_each_rep before xc_monitor_enable() (which allocates
>> vcpu->arch.vm_event) has been called, so return an error from the
>> XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP hypercall when that is the case.
>> 
>> Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
>> Reviewed-by: Andrew Cooper <andrew.cooper3@citirx.com>
>> 
>> ---
>> Changes since V2:
>>  - Updated the if() condition as recommended by Andrew Cooper.
>>  - Added Andrew Cooper's Reviewed-by.
>> ---
>>  xen/include/asm-x86/monitor.h | 16 +++++++++++++---
>>  1 file changed, 13 insertions(+), 3 deletions(-)
>> 
>> diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h
>> index 0954b59..d367099 100644
>> --- a/xen/include/asm-x86/monitor.h
>> +++ b/xen/include/asm-x86/monitor.h
>> @@ -32,19 +32,29 @@
>>  static inline
>>  int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop)
>>  {
>> +    int rc = 0;
>> +
>>      switch ( mop->op )
>>      {
>>      case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP:
>>          domain_pause(d);
>> -        d->arch.mem_access_emulate_each_rep = !!mop->event;
>> +        /*
>> +         * Enabling mem_access_emulate_each_rep without a vm_event subscriber
>> +         * is meaningless.
>> +         */
>> +        if ( d->max_vcpus && d->vcpu[0] && d->vcpu[0]->arch.vm_event )
>> +            d->arch.mem_access_emulate_each_rep = !!mop->event;
>> +        else
>> +            rc = -EINVAL;
>> +
>>          domain_unpause(d);
>>          break;
>>  
>>      default:
>> -        return -EOPNOTSUPP;
>> +        rc = -EOPNOTSUPP;
>>      }
>>  
>> -    return 0;
>> +    return rc;
>>  }
>>  
>>  int arch_monitor_domctl_event(struct domain *d,
> 
> According to the previous list discussion with Andrew Cooper, this fix
> might be considered for the 4.7 release, so CC-ing Wei for a release
> ack, as suggested.

Even if - without the pending ./MAINTAINERS adjustment - not
formally required, I don't understand why you didn't Cc Tamas on
this patch. I don't think this should go in without his ack.

Jan


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V3] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL
  2016-05-03  8:14   ` Jan Beulich
@ 2016-05-03  8:18     ` Razvan Cojocaru
  2016-05-03 18:28       ` Tamas K Lengyel
  0 siblings, 1 reply; 6+ messages in thread
From: Razvan Cojocaru @ 2016-05-03  8:18 UTC (permalink / raw)
  To: Jan Beulich; +Cc: andrew.cooper3, keir, tamas, wei.liu2@citrix.com, xen-devel

On 05/03/2016 11:14 AM, Jan Beulich wrote:
>>>> On 29.04.16 at 18:12, <rcojocaru@bitdefender.com> wrote:
>> On 04/09/16 08:54, Razvan Cojocaru wrote:
>>> It is meaningless (and potentially dangerous - see hvmemul_virtual_to_linear())
>>> to set mem_access_emulate_each_rep before xc_monitor_enable() (which allocates
>>> vcpu->arch.vm_event) has been called, so return an error from the
>>> XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP hypercall when that is the case.
>>>
>>> Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
>>> Reviewed-by: Andrew Cooper <andrew.cooper3@citirx.com>
>>>
>>> ---
>>> Changes since V2:
>>>  - Updated the if() condition as recommended by Andrew Cooper.
>>>  - Added Andrew Cooper's Reviewed-by.
>>> ---
>>>  xen/include/asm-x86/monitor.h | 16 +++++++++++++---
>>>  1 file changed, 13 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h
>>> index 0954b59..d367099 100644
>>> --- a/xen/include/asm-x86/monitor.h
>>> +++ b/xen/include/asm-x86/monitor.h
>>> @@ -32,19 +32,29 @@
>>>  static inline
>>>  int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop)
>>>  {
>>> +    int rc = 0;
>>> +
>>>      switch ( mop->op )
>>>      {
>>>      case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP:
>>>          domain_pause(d);
>>> -        d->arch.mem_access_emulate_each_rep = !!mop->event;
>>> +        /*
>>> +         * Enabling mem_access_emulate_each_rep without a vm_event subscriber
>>> +         * is meaningless.
>>> +         */
>>> +        if ( d->max_vcpus && d->vcpu[0] && d->vcpu[0]->arch.vm_event )
>>> +            d->arch.mem_access_emulate_each_rep = !!mop->event;
>>> +        else
>>> +            rc = -EINVAL;
>>> +
>>>          domain_unpause(d);
>>>          break;
>>>  
>>>      default:
>>> -        return -EOPNOTSUPP;
>>> +        rc = -EOPNOTSUPP;
>>>      }
>>>  
>>> -    return 0;
>>> +    return rc;
>>>  }
>>>  
>>>  int arch_monitor_domctl_event(struct domain *d,
>>
>> According to the previous list discussion with Andrew Cooper, this fix
>> might be considered for the 4.7 release, so CC-ing Wei for a release
>> ack, as suggested.
> 
> Even if - without the pending ./MAINTAINERS adjustment - not
> formally required, I don't understand why you didn't Cc Tamas on
> this patch. I don't think this should go in without his ack.

Of course, I was under the impression that he was in the recipients list
(I let scripts/maintaners.pl do the work and didn't pay much attention
to its output).

By all means.


Thanks,
Razvan

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V3] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL
  2016-05-03  8:18     ` Razvan Cojocaru
@ 2016-05-03 18:28       ` Tamas K Lengyel
  0 siblings, 0 replies; 6+ messages in thread
From: Tamas K Lengyel @ 2016-05-03 18:28 UTC (permalink / raw)
  To: Razvan Cojocaru
  Cc: Andrew Cooper, Keir Fraser, wei.liu2@citrix.com, Jan Beulich, Xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 2916 bytes --]

On Tue, May 3, 2016 at 2:18 AM, Razvan Cojocaru <rcojocaru@bitdefender.com>
wrote:

> On 05/03/2016 11:14 AM, Jan Beulich wrote:
> >>>> On 29.04.16 at 18:12, <rcojocaru@bitdefender.com> wrote:
> >> On 04/09/16 08:54, Razvan Cojocaru wrote:
> >>> It is meaningless (and potentially dangerous - see
> hvmemul_virtual_to_linear())
> >>> to set mem_access_emulate_each_rep before xc_monitor_enable() (which
> allocates
> >>> vcpu->arch.vm_event) has been called, so return an error from the
> >>> XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP hypercall when that is the case.
> >>>
> >>> Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
> >>> Reviewed-by: Andrew Cooper <andrew.cooper3@citirx.com>
> >>>
> >>> ---
> >>> Changes since V2:
> >>>  - Updated the if() condition as recommended by Andrew Cooper.
> >>>  - Added Andrew Cooper's Reviewed-by.
> >>> ---
> >>>  xen/include/asm-x86/monitor.h | 16 +++++++++++++---
> >>>  1 file changed, 13 insertions(+), 3 deletions(-)
> >>>
> >>> diff --git a/xen/include/asm-x86/monitor.h
> b/xen/include/asm-x86/monitor.h
> >>> index 0954b59..d367099 100644
> >>> --- a/xen/include/asm-x86/monitor.h
> >>> +++ b/xen/include/asm-x86/monitor.h
> >>> @@ -32,19 +32,29 @@
> >>>  static inline
> >>>  int arch_monitor_domctl_op(struct domain *d, struct
> xen_domctl_monitor_op *mop)
> >>>  {
> >>> +    int rc = 0;
> >>> +
> >>>      switch ( mop->op )
> >>>      {
> >>>      case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP:
> >>>          domain_pause(d);
> >>> -        d->arch.mem_access_emulate_each_rep = !!mop->event;
> >>> +        /*
> >>> +         * Enabling mem_access_emulate_each_rep without a vm_event
> subscriber
> >>> +         * is meaningless.
> >>> +         */
> >>> +        if ( d->max_vcpus && d->vcpu[0] && d->vcpu[0]->arch.vm_event )
> >>> +            d->arch.mem_access_emulate_each_rep = !!mop->event;
> >>> +        else
> >>> +            rc = -EINVAL;
> >>> +
> >>>          domain_unpause(d);
> >>>          break;
> >>>
> >>>      default:
> >>> -        return -EOPNOTSUPP;
> >>> +        rc = -EOPNOTSUPP;
> >>>      }
> >>>
> >>> -    return 0;
> >>> +    return rc;
> >>>  }
> >>>
> >>>  int arch_monitor_domctl_event(struct domain *d,
> >>
> >> According to the previous list discussion with Andrew Cooper, this fix
> >> might be considered for the 4.7 release, so CC-ing Wei for a release
> >> ack, as suggested.
> >
> > Even if - without the pending ./MAINTAINERS adjustment - not
> > formally required, I don't understand why you didn't Cc Tamas on
> > this patch. I don't think this should go in without his ack.
>
> Of course, I was under the impression that he was in the recipients list
> (I let scripts/maintaners.pl do the work and didn't pay much attention
> to its output).
>
> By all means.
>

The maintainers file wasn't covering this header properly. Fixed in my
other patch-set.

Acked-by: Tamas K Lengyel <tamas@tklengyel.com>

[-- Attachment #1.2: Type: text/html, Size: 4481 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-05-03 18:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-09  5:54 [PATCH V3] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL Razvan Cojocaru
2016-04-29 16:12 ` Razvan Cojocaru
2016-05-02 10:26   ` Wei Liu
2016-05-03  8:14   ` Jan Beulich
2016-05-03  8:18     ` Razvan Cojocaru
2016-05-03 18:28       ` Tamas K Lengyel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).