Re: [Xen-devel] [PATCH v2 4/4] hvm/svm: Enable CR events

2018-02-09 Thread George Dunlap
On Fri, Feb 9, 2018 at 1:10 PM, Alexandru Stefan ISAILA
 wrote:
> On Jo, 2018-02-08 at 11:06 -0700, Tamas K Lengyel wrote:
>> On Thu, Feb 8, 2018 at 8:25 AM, Alexandru Isaila
>>  wrote:
>> >
>> > This commit enables controlregister events for svm.
>> So this patch enables the event to trigger but where is it being
>> handled and forwarded to the monitor ring?
> Hi Tamas,
>
> If I've understand your question right, this is handled, like on the
> vmx side, on a special case on CR0. If this is not what you are looking
> for can you please clarify the question.

So I forgot #4 in my list, "4. Anything else necessary to understand the patch".

Probably a useful thing to add to the commit message would be something like:

"We just need to enable the SVM intercept; hvm_mov_to_cr() will
forward the event on to the monitor when appropriate."

 -George

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v2 4/4] hvm/svm: Enable CR events

2018-02-09 Thread Tamas K Lengyel
On Thu, Feb 8, 2018 at 8:25 AM, Alexandru Isaila
 wrote:
> This commit enables controlregister events for svm.
>
> Signed-off-by: Alexandru Isaila 

Acked-by: Tamas K Lengyel 

> ---
>  xen/arch/x86/hvm/svm/svm.c| 11 +++
>  xen/include/asm-x86/monitor.h |  6 +++---
>  2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
> index 1eadab4..311902f 100644
> --- a/xen/arch/x86/hvm/svm/svm.c
> +++ b/xen/arch/x86/hvm/svm/svm.c
> @@ -60,6 +60,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  void svm_asm_do_resume(void);
> @@ -560,6 +561,16 @@ void svm_update_guest_cr(struct vcpu *v, unsigned int cr)
>  svm_fpu_enter(v);
>  }
>
> +if ( paging_mode_hap(v->domain) )
> +{
> +uint32_t intercepts = vmcb_get_cr_intercepts(vmcb);
> +
> +/* Trap CR3 updates if CR3 memory events are enabled. */
> +if ( v->domain->arch.monitor.write_ctrlreg_enabled &
> + monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) )
> +   vmcb_set_cr_intercepts(vmcb, intercepts | 
> CR_INTERCEPT_CR3_WRITE);
> +}
> +
>  value = v->arch.hvm_vcpu.guest_cr[0] | hw_cr0_mask;
>  if ( !paging_mode_hap(v->domain) )
>  value |= X86_CR0_PG | X86_CR0_WP;
> diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h
> index 138c463..b80d217 100644
> --- a/xen/include/asm-x86/monitor.h
> +++ b/xen/include/asm-x86/monitor.h
> @@ -79,8 +79,7 @@ static inline uint32_t arch_monitor_get_capabilities(struct 
> domain *d)
>
>  if( cpu_has_vmx )
>  {
> -capabilities = (1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG) |
> -   (1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
> +capabilities = (1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
> (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) |
> (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) |
> (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED);
> @@ -92,7 +91,8 @@ static inline uint32_t arch_monitor_get_capabilities(struct 
> domain *d)
>
>  capabilities |= ((1U << XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST) |
>  (1U << XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT) |
> -(1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR));
> +(1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR) |
> +(1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG));
>
>  if ( hvm_funcs.set_descriptor_access_exiting )
>  capabilities |= (1U << XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS);
> --
> 2.7.4

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v2 4/4] hvm/svm: Enable CR events

2018-02-09 Thread Tamas K Lengyel
On Fri, Feb 9, 2018 at 6:10 AM, Alexandru Stefan ISAILA
 wrote:
> On Jo, 2018-02-08 at 11:06 -0700, Tamas K Lengyel wrote:
>> On Thu, Feb 8, 2018 at 8:25 AM, Alexandru Isaila
>>  wrote:
>> >
>> > This commit enables controlregister events for svm.
>> So this patch enables the event to trigger but where is it being
>> handled and forwarded to the monitor ring?
> Hi Tamas,
>
> If I've understand your question right, this is handled, like on the
> vmx side, on a special case on CR0. If this is not what you are looking
> for can you please clarify the question.

I'm sorry, I was looking for seeing a call to hvm_mov_to_crX but I
realized the whole thing is abstracted already under hvm_mov_to_cr in
the hvm layer.

Tamas

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v2 4/4] hvm/svm: Enable CR events

2018-02-09 Thread Alexandru Stefan ISAILA
On Jo, 2018-02-08 at 11:06 -0700, Tamas K Lengyel wrote:
> On Thu, Feb 8, 2018 at 8:25 AM, Alexandru Isaila
>  wrote:
> >
> > This commit enables controlregister events for svm.
> So this patch enables the event to trigger but where is it being
> handled and forwarded to the monitor ring?
Hi Tamas,

If I've understand your question right, this is handled, like on the
vmx side, on a special case on CR0. If this is not what you are looking
for can you please clarify the question.

Alex
>
> >
> >
> > Signed-off-by: Alexandru Isaila 
> > ---
> >  xen/arch/x86/hvm/svm/svm.c| 11 +++
> >  xen/include/asm-x86/monitor.h |  6 +++---
> >  2 files changed, 14 insertions(+), 3 deletions(-)
> >
> > diff --git a/xen/arch/x86/hvm/svm/svm.c
> > b/xen/arch/x86/hvm/svm/svm.c
> > index 1eadab4..311902f 100644
> > --- a/xen/arch/x86/hvm/svm/svm.c
> > +++ b/xen/arch/x86/hvm/svm/svm.c
> > @@ -60,6 +60,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >
> >  void svm_asm_do_resume(void);
> > @@ -560,6 +561,16 @@ void svm_update_guest_cr(struct vcpu *v,
> > unsigned int cr)
> >  svm_fpu_enter(v);
> >  }
> >
> > +if ( paging_mode_hap(v->domain) )
> > +{
> > +uint32_t intercepts = vmcb_get_cr_intercepts(vmcb);
> > +
> > +/* Trap CR3 updates if CR3 memory events are enabled.
> > */
> > +if ( v->domain->arch.monitor.write_ctrlreg_enabled &
> > + monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) )
> > +   vmcb_set_cr_intercepts(vmcb, intercepts |
> > CR_INTERCEPT_CR3_WRITE);
> > +}
> > +
> >  value = v->arch.hvm_vcpu.guest_cr[0] | hw_cr0_mask;
> >  if ( !paging_mode_hap(v->domain) )
> >  value |= X86_CR0_PG | X86_CR0_WP;
> > diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-
> > x86/monitor.h
> > index 138c463..b80d217 100644
> > --- a/xen/include/asm-x86/monitor.h
> > +++ b/xen/include/asm-x86/monitor.h
> > @@ -79,8 +79,7 @@ static inline uint32_t
> > arch_monitor_get_capabilities(struct domain *d)
> >
> >  if( cpu_has_vmx )
> >  {
> > -capabilities = (1U <<
> > XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG) |
> > -   (1U <<
> > XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
> > +capabilities = (1U <<
> > XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
> > (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) |
> > (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT)
> > |
> > (1U <<
> > XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED);
> > @@ -92,7 +91,8 @@ static inline uint32_t
> > arch_monitor_get_capabilities(struct domain *d)
> >
> >  capabilities |= ((1U <<
> > XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST) |
> >  (1U <<
> > XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT) |
> > -(1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR));
> > +(1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR) |
> > +(1U <<
> > XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG));
> >
> >  if ( hvm_funcs.set_descriptor_access_exiting )
> >  capabilities |= (1U <<
> > XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS);
> > --
> > 2.7.4


This email was scanned by Bitdefender
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v2 4/4] hvm/svm: Enable CR events

2018-02-08 Thread Tamas K Lengyel
On Thu, Feb 8, 2018 at 8:25 AM, Alexandru Isaila
 wrote:
> This commit enables controlregister events for svm.

So this patch enables the event to trigger but where is it being
handled and forwarded to the monitor ring?

>
> Signed-off-by: Alexandru Isaila 
> ---
>  xen/arch/x86/hvm/svm/svm.c| 11 +++
>  xen/include/asm-x86/monitor.h |  6 +++---
>  2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
> index 1eadab4..311902f 100644
> --- a/xen/arch/x86/hvm/svm/svm.c
> +++ b/xen/arch/x86/hvm/svm/svm.c
> @@ -60,6 +60,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  void svm_asm_do_resume(void);
> @@ -560,6 +561,16 @@ void svm_update_guest_cr(struct vcpu *v, unsigned int cr)
>  svm_fpu_enter(v);
>  }
>
> +if ( paging_mode_hap(v->domain) )
> +{
> +uint32_t intercepts = vmcb_get_cr_intercepts(vmcb);
> +
> +/* Trap CR3 updates if CR3 memory events are enabled. */
> +if ( v->domain->arch.monitor.write_ctrlreg_enabled &
> + monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) )
> +   vmcb_set_cr_intercepts(vmcb, intercepts | 
> CR_INTERCEPT_CR3_WRITE);
> +}
> +
>  value = v->arch.hvm_vcpu.guest_cr[0] | hw_cr0_mask;
>  if ( !paging_mode_hap(v->domain) )
>  value |= X86_CR0_PG | X86_CR0_WP;
> diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h
> index 138c463..b80d217 100644
> --- a/xen/include/asm-x86/monitor.h
> +++ b/xen/include/asm-x86/monitor.h
> @@ -79,8 +79,7 @@ static inline uint32_t arch_monitor_get_capabilities(struct 
> domain *d)
>
>  if( cpu_has_vmx )
>  {
> -capabilities = (1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG) |
> -   (1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
> +capabilities = (1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
> (1U << XEN_DOMCTL_MONITOR_EVENT_CPUID) |
> (1U << XEN_DOMCTL_MONITOR_EVENT_INTERRUPT) |
> (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED);
> @@ -92,7 +91,8 @@ static inline uint32_t arch_monitor_get_capabilities(struct 
> domain *d)
>
>  capabilities |= ((1U << XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST) |
>  (1U << XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT) |
> -(1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR));
> +(1U << XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR) |
> +(1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG));
>
>  if ( hvm_funcs.set_descriptor_access_exiting )
>  capabilities |= (1U << XEN_DOMCTL_MONITOR_EVENT_DESC_ACCESS);
> --
> 2.7.4

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel