From: "Jan Beulich" Subject: Re: [PATCH 5/6] x86/hvm: Forced Emulation Prefix for debug builds of Xen Date: Tue, 23 Sep 2014 16:27:02 +0100 Message-ID: <5421AD660200007800037D4D@mail.emea.novell.com> References: <1411484611-31027-1-git-send-email-andrew.cooper3@citrix.com> <1411484611-31027-6-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1411484611-31027-6-git-send-email-andrew.cooper3@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: Kevin Tian , Suravee Suthikulpanit , Eddie Dong , Xen-devel , Aravind Gopalakrishnan , Jun Nakajima , Boris Ostrovsky List-Id: xen-devel@lists.xenproject.org >>> On 23.09.14 at 17:03, wrote: [re-ordering patch contents for a better response context] > --- a/xen/include/asm-x86/hvm/hvm.h > +++ b/xen/include/asm-x86/hvm/hvm.h > @@ -514,6 +514,11 @@ bool_t nhvm_vmcx_hap_enabled(struct vcpu *v); > /* interrupt */ > enum hvm_intblk nhvm_interrupt_blocked(struct vcpu *v); > > +#ifndef NDEBUG > +/* Permit use of the Forced Emulation Prefix in HVM guests */ > +extern bool_t opt_hvm_fep; #else #define opt_hvm_fep 0 > +#endif allowing this to be the single place of dependency on NDEBUG (in case someone wants to change the condition to some thing else) by ... > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -86,6 +86,11 @@ unsigned long __attribute__ ((__section__ (".bss.page_aligned"))) > static bool_t __initdata opt_hap_enabled = 1; > boolean_param("hap", opt_hap_enabled); > > +#ifndef NDEBUG > +bool_t opt_hvm_fep; > +boolean_param("hvm_fep", opt_hvm_fep); > +#endif ... making this #ifndef opt_hvm_fep and ... > +#ifndef NDEBUG > + if ( opt_hvm_fep ) > + { > + XEN_GUEST_HANDLE(char) guest_rip = { (char*)regs->eip }; > + char sig[5]; /* ud2; .ascii "xen" */ > + > + if ( (copy_from_guest(sig, guest_rip, sizeof(sig)) == 0) && > + (memcmp(sig, "\xf\xbxen", sizeof(sig)) == 0) ) > + { > + regs->eip += sizeof(sig); > + regs->eflags &= ~X86_EFLAGS_RF; > + } > + } > +#endif ... dropping the preprocessor conditionals both here and in the similar VMX code chunk. Apart from that I'd really like you to consider using copy_from_user_hvm() or hvm_fetch_from_guest_virt_nofault() - there's no visible benefit from using the PV-aware copy_from_guest() here. Jan