[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] mem_event: fix regression affecting CR3, CR4 memory events



On Mon, Sep 10, 2012 at 5:03 PM, Steven Maresca <steve@xxxxxxxxxxxx> wrote:
> This is a patch repairing a regression in code previously functional in 
> 4.1.x. It appears that, during some refactoring work, calls to 
> hvm_memory_event_cr3 and hvm_memory_event_cr4 were lost.
>
> These functions were originally called in mov_to_cr() of vmx.c, but the 
> commit  http://xenbits.xen.org/hg/xen-unstable.hg/rev/1276926e3795 abstracted 
> the original code into generic functions up a level in hvm.c, dropping these 
> calls in the process.
>
> Signed-off-by: Steven Maresca <steve@xxxxxxxxxxxx>
>
> diff -r a64f4e107951 -r 4d31c1c86418 xen/arch/x86/hvm/hvm.c
> --- a/xen/arch/x86/hvm/hvm.c    Fri Sep 07 11:09:46 2012 +0100
> +++ b/xen/arch/x86/hvm/hvm.c    Mon Sep 10 16:48:15 2012 -0400
> @@ -1758,6 +1758,7 @@ int hvm_set_cr3(unsigned long value)
>  {
>      struct vcpu *v = current;
>      struct page_info *page;
> +    unsigned long old;
>
>      if ( hvm_paging_enabled(v) && !paging_mode_hap(v->domain) &&
>           (value != v->arch.hvm_vcpu.guest_cr[3]) )
> @@ -1775,8 +1776,10 @@ int hvm_set_cr3(unsigned long value)
>          HVM_DBG_LOG(DBG_LEVEL_VMMU, "Update CR3 value = %lx", value);
>      }
>
> +    old=v->arch.hvm_vcpu.guest_cr[3];
>      v->arch.hvm_vcpu.guest_cr[3] = value;
>      paging_update_cr3(v);
> +    hvm_memory_event_cr3(value, old);
>      return X86EMUL_OKAY;
>
>   bad_cr3:
> @@ -1818,6 +1821,7 @@ int hvm_set_cr4(unsigned long value)
>
>      v->arch.hvm_vcpu.guest_cr[4] = value;
>      hvm_update_guest_cr(v, 4);
> +    hvm_memory_event_cr4(value, old_cr);
>
>      /*
>       * Modifying CR4.{PSE,PAE,PGE,SMEP}, or clearing CR4.PCIDE

Given the refactoring in the commit related to the regression
http://xenbits.xen.org/hg/xen-unstable.hg/rev/1276926e3795, it seemed
(to me anyway) that inserting calls as shown in the patch would be
cleaner, but I can definitely come up with some drawbacks.  However, I
wanted to get this fixed for 4.2 if at all possible, so I wanted to
send regardless.

In terms of drawbacks, this will require some ifdefs for x86_64, for example.

Any suggestions for the cleanest means of achieving the same in vmx.c?

Steve

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.