From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] vm_event: consolidate hvm_event_fill_regs and p2m_vm_event_fill_regs Date: Thu, 11 Feb 2016 21:35:42 +0000 Message-ID: <56BCFEAE.8070608@citrix.com> References: <1455224749-2120-1-git-send-email-tlengyel@novetta.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTytt-0008TT-4L for xen-devel@lists.xenproject.org; Thu, 11 Feb 2016 21:35:45 +0000 In-Reply-To: <1455224749-2120-1-git-send-email-tlengyel@novetta.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tamas K Lengyel , xen-devel@lists.xenproject.org Cc: George Dunlap , Keir Fraser , Jan Beulich , Razvan Cojocaru List-Id: xen-devel@lists.xenproject.org On 11/02/2016 21:05, Tamas K Lengyel wrote: > diff --git a/xen/arch/x86/vm_event.c b/xen/arch/x86/vm_event.c > index 08d678a..fa5d154 100644 > --- a/xen/arch/x86/vm_event.c > +++ b/xen/arch/x86/vm_event.c > @@ -122,6 +122,64 @@ void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp) > v->arch.user_regs.eip = rsp->data.regs.x86.rip; > } > > +void vm_event_fill_regs(vm_event_request_t *req) > +{ > + const struct cpu_user_regs *regs = guest_cpu_user_regs(); > + struct segment_register seg; > + struct hvm_hw_cpu ctxt; > + struct vcpu *curr = current; > + > + req->data.regs.x86.rax = regs->eax; > + req->data.regs.x86.rcx = regs->ecx; > + req->data.regs.x86.rdx = regs->edx; > + req->data.regs.x86.rbx = regs->ebx; > + req->data.regs.x86.rsp = regs->esp; > + req->data.regs.x86.rbp = regs->ebp; > + req->data.regs.x86.rsi = regs->esi; > + req->data.regs.x86.rdi = regs->edi; > + > + req->data.regs.x86.r8 = regs->r8; > + req->data.regs.x86.r9 = regs->r9; > + req->data.regs.x86.r10 = regs->r10; > + req->data.regs.x86.r11 = regs->r11; > + req->data.regs.x86.r12 = regs->r12; > + req->data.regs.x86.r13 = regs->r13; > + req->data.regs.x86.r14 = regs->r14; > + req->data.regs.x86.r15 = regs->r15; > + > + req->data.regs.x86.rflags = regs->eflags; > + req->data.regs.x86.rip = regs->eip; > + req->data.regs.x86.dr7 = curr->arch.debugreg[7]; I think there is a %dr7 handling issue here. For an HVM guests, this field is only valid when you are not in the context of the guest, as it lives in the vmcs/vmcs. (PV guests keep it synchronously up to date) Normally, the vcpu context switch code takes care of calling {vmx,svm}_{save,restore}_dr(), which is why migration works fine (not permitted in the context of the guest), you are now introducing a new path. I think you need to modify {vmx,svm}_{vmcb,vmcs}_save() to do a selective {vmx,svm}_save_dr() if v == current. ~Andrew