[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 3/8] x86/vm-event/monitor: relocate code-motion more appropriately
On 06/30/16 21:43, Corneliu ZUZU wrote: > For readability: > > * Add function arch_monitor_write_data (in x86/monitor.c) and separate > handling > of monitor_write_data there (previously done directly in hvm_do_resume). > > * Add function write_ctrlreg_adjust_traps (in x86/monitor.c) and relocate > enabling/disabling of CPU_BASED_CR3_LOAD_EXITING for CR3 monitor vm-events > there > (previously done through CR0 node @ vmx_update_guest_cr(v, 0)). > > Signed-off-by: Corneliu ZUZU <czuzu@xxxxxxxxxxxxxxx> > --- > xen/arch/x86/hvm/hvm.c | 48 +++++++++------------- > xen/arch/x86/hvm/vmx/vmx.c | 5 --- > xen/arch/x86/monitor.c | 94 > +++++++++++++++++++++++++++++++++++++++---- > xen/include/asm-x86/monitor.h | 2 + > 4 files changed, 107 insertions(+), 42 deletions(-) > > diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c > index c89ab6e..5481a6e 100644 > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -475,8 +475,6 @@ void hvm_do_resume(struct vcpu *v) > > if ( unlikely(v->arch.vm_event) ) > { > - struct monitor_write_data *w = &v->arch.vm_event->write_data; > - > if ( v->arch.vm_event->emulate_flags ) > { > enum emul_kind kind = EMUL_KIND_NORMAL; > @@ -493,32 +491,10 @@ void hvm_do_resume(struct vcpu *v) > > v->arch.vm_event->emulate_flags = 0; > } > - > - if ( w->do_write.msr ) > - { > - hvm_msr_write_intercept(w->msr, w->value, 0); > - w->do_write.msr = 0; > - } > - > - if ( w->do_write.cr0 ) > - { > - hvm_set_cr0(w->cr0, 0); > - w->do_write.cr0 = 0; > - } > - > - if ( w->do_write.cr4 ) > - { > - hvm_set_cr4(w->cr4, 0); > - w->do_write.cr4 = 0; > - } > - > - if ( w->do_write.cr3 ) > - { > - hvm_set_cr3(w->cr3, 0); > - w->do_write.cr3 = 0; > - } > } > > + arch_monitor_write_data(v); > + > /* Inject pending hw/sw trap */ > if ( v->arch.hvm_vcpu.inject_trap.vector != -1 ) > { > @@ -2206,7 +2182,10 @@ int hvm_set_cr0(unsigned long value, bool_t may_defer) > > if ( hvm_monitor_crX(CR0, value, old_value) ) > { > - /* The actual write will occur in hvm_do_resume(), if permitted. > */ > + /* > + * The actual write will occur in arch_monitor_write_data(), if > + * permitted. > + */ > v->arch.vm_event->write_data.do_write.cr0 = 1; > v->arch.vm_event->write_data.cr0 = value; > > @@ -2308,7 +2287,10 @@ int hvm_set_cr3(unsigned long value, bool_t may_defer) > > if ( hvm_monitor_crX(CR3, value, old) ) > { > - /* The actual write will occur in hvm_do_resume(), if permitted. > */ > + /* > + * The actual write will occur in arch_monitor_write_data(), if > + * permitted. > + */ > v->arch.vm_event->write_data.do_write.cr3 = 1; > v->arch.vm_event->write_data.cr3 = value; > > @@ -2388,7 +2370,10 @@ int hvm_set_cr4(unsigned long value, bool_t may_defer) > > if ( hvm_monitor_crX(CR4, value, old_cr) ) > { > - /* The actual write will occur in hvm_do_resume(), if permitted. > */ > + /* > + * The actual write will occur in arch_monitor_write_data(), if > + * permitted. > + */ > v->arch.vm_event->write_data.do_write.cr4 = 1; > v->arch.vm_event->write_data.cr4 = value; > > @@ -3767,7 +3752,10 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t > msr_content, > { > ASSERT(v->arch.vm_event); > > - /* The actual write will occur in hvm_do_resume() (if permitted). */ > + /* > + * The actual write will occur in arch_monitor_write_data(), if > + * permitted. > + */ > v->arch.vm_event->write_data.do_write.msr = 1; > v->arch.vm_event->write_data.msr = msr; > v->arch.vm_event->write_data.value = msr_content; > diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c > index 15c84c2..de04e6c 100644 > --- a/xen/arch/x86/hvm/vmx/vmx.c > +++ b/xen/arch/x86/hvm/vmx/vmx.c > @@ -1442,11 +1442,6 @@ static void vmx_update_guest_cr(struct vcpu *v, > unsigned int cr) > if ( !hvm_paging_enabled(v) && !vmx_unrestricted_guest(v) ) > v->arch.hvm_vmx.exec_control |= cr3_ctls; > > - /* Trap CR3 updates if CR3 memory events are enabled. */ > - if ( v->domain->arch.monitor.write_ctrlreg_enabled & > - monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) ) > - v->arch.hvm_vmx.exec_control |= CPU_BASED_CR3_LOAD_EXITING; > - > if ( old_ctls != v->arch.hvm_vmx.exec_control ) > vmx_update_cpu_exec_control(v); > } > diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c > index a271161..90e4856 100644 > --- a/xen/arch/x86/monitor.c > +++ b/xen/arch/x86/monitor.c > @@ -20,6 +20,9 @@ > */ > > #include <asm/monitor.h> > +#include <asm/paging.h> > +#include <asm/hvm/vmx/vmx.h> > +#include <asm/vm_event.h> > #include <public/vm_event.h> As previously stated, unless there's a compelling reason to do otherwise, AFAIK asm/hvm/... goes above asm/monitor.h. Otherwise, for the monitor parts: Acked-by: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx> Thanks, Razvan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |