From: "Jan Beulich" Subject: [PATCH 2/4] VMX: move various uses of UD2 out of fast paths Date: Fri, 23 Aug 2013 15:02:36 +0100 Message-ID: <5217879D02000078000EE07B@nat28.tlf.novell.com> References: <521786A002000078000EE064@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part2A19626C.1__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VCrwm-0000D3-Fl for xen-devel@lists.xenproject.org; Fri, 23 Aug 2013 14:02:40 +0000 In-Reply-To: <521786A002000078000EE064@nat28.tlf.novell.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: xen-devel Cc: Keir Fraser , Eddie Dong , Jun Nakajima List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part2A19626C.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... at once making conditional forward jumps, which are statically predicted to be not taken, only used for the unlikely (error) cases. Signed-off-by: Jan Beulich --- a/xen/include/asm-x86/asm_defns.h +++ b/xen/include/asm-x86/asm_defns.h @@ -67,6 +67,30 @@ void ret_from_intr(void); #define ASSERT_NOT_IN_ATOMIC #endif =20 +#else + +#ifdef __clang__ /* clang's builtin assember can't do .subsection */ + +#define UNLIKELY_START_SECTION ".pushsection .fixup,\"ax\"" +#define UNLIKELY_END_SECTION ".popsection" + +#else + +#define UNLIKELY_START_SECTION ".subsection 1" +#define UNLIKELY_END_SECTION ".subsection 0" + +#endif + +#define UNLIKELY_START(cond, tag) \ + "j" #cond " .Lunlikely%=3D.tag;\n\t" \ + UNLIKELY_START_SECTION "\n" \ + ".Lunlikely%=3D.tag:" + +#define UNLIKELY_END(tag) \ + "jmp .Llikely%=3D.tag;\n\t" \ + UNLIKELY_END_SECTION "\n" \ + ".Llikely%=3D.tag:" + #endif =20 #endif /* __X86_ASM_DEFNS_H__ */ --- a/xen/include/asm-x86/hvm/vmx/vmx.h +++ b/xen/include/asm-x86/hvm/vmx/vmx.h @@ -285,7 +285,9 @@ static inline void __vmptrld(u64 addr) asm volatile ( VMPTRLD_OPCODE MODRM_EAX_06 /* CF=3D=3D1 or ZF=3D=3D1 --> crash (ud2) */ - "ja 1f ; ud2 ; 1:\n" + UNLIKELY_START(be, vmptrld) + "\tud2\n" + UNLIKELY_END_SECTION : : "a" (&addr) : "memory"); @@ -296,7 +298,9 @@ static inline void __vmpclear(u64 addr) asm volatile ( VMCLEAR_OPCODE MODRM_EAX_06 /* CF=3D=3D1 or ZF=3D=3D1 --> crash (ud2) */ - "ja 1f ; ud2 ; 1:\n" + UNLIKELY_START(be, vmclear) + "\tud2\n" + UNLIKELY_END_SECTION : : "a" (&addr) : "memory"); @@ -309,7 +313,9 @@ static inline unsigned long __vmread(uns asm volatile ( VMREAD_OPCODE MODRM_EAX_ECX /* CF=3D=3D1 or ZF=3D=3D1 --> crash (ud2) */ - "ja 1f ; ud2 ; 1:\n" + UNLIKELY_START(be, vmread) + "\tud2\n" + UNLIKELY_END_SECTION : "=3Dc" (ecx) : "a" (field) : "memory"); @@ -322,7 +328,9 @@ static inline void __vmwrite(unsigned lo asm volatile ( VMWRITE_OPCODE MODRM_EAX_ECX /* CF=3D=3D1 or ZF=3D=3D1 --> crash (ud2) */ - "ja 1f ; ud2 ; 1:\n" + UNLIKELY_START(be, vmwrite) + "\tud2\n" + UNLIKELY_END_SECTION :=20 : "a" (field) , "c" (value) : "memory"); @@ -360,7 +368,9 @@ static inline void __invept(int type, u6 asm volatile ( INVEPT_OPCODE MODRM_EAX_08 /* CF=3D=3D1 or ZF=3D=3D1 --> crash (ud2) */ - "ja 1f ; ud2 ; 1:\n" + UNLIKELY_START(be, invept) + "\tud2\n" + UNLIKELY_END_SECTION : : "a" (&operand), "c" (type) : "memory" ); @@ -377,7 +387,9 @@ static inline void __invvpid(int type, u /* Fix up #UD exceptions which occur when TLBs are flushed before = VMXON. */ asm volatile ( "1: " INVVPID_OPCODE MODRM_EAX_08 /* CF=3D=3D1 or ZF=3D=3D1 --> crash (ud2) */ - "ja 2f ; ud2 ; 2:\n" + "2: " UNLIKELY_START(be, invvpid) + "\tud2\n" + UNLIKELY_END_SECTION "\n" _ASM_EXTABLE(1b, 2b) : : "a" (&operand), "c" (type) --=__Part2A19626C.1__= Content-Type: text/plain; name="VMX-ud2-out-of-line.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="VMX-ud2-out-of-line.patch" VMX: move various uses of UD2 out of fast paths=0A=0A... at once making = conditional forward jumps, which are statically=0Apredicted to be not = taken, only used for the unlikely (error) cases.=0A=0ASigned-off-by: Jan = Beulich =0A=0A--- a/xen/include/asm-x86/asm_defns.h=0A++= + b/xen/include/asm-x86/asm_defns.h=0A@@ -67,6 +67,30 @@ void ret_from_intr= (void);=0A #define ASSERT_NOT_IN_ATOMIC=0A #endif=0A =0A+#else=0A+=0A+#ifde= f __clang__ /* clang's builtin assember can't do .subsection */=0A+=0A+#def= ine UNLIKELY_START_SECTION ".pushsection .fixup,\"ax\""=0A+#define = UNLIKELY_END_SECTION ".popsection"=0A+=0A+#else=0A+=0A+#define UNLIKELY_S= TART_SECTION ".subsection 1"=0A+#define UNLIKELY_END_SECTION ".subsection= 0"=0A+=0A+#endif=0A+=0A+#define UNLIKELY_START(cond, tag) \=0A+ = "j" #cond " .Lunlikely%=3D.tag;\n\t" \=0A+ UNLIKELY_START_SECT= ION "\n" \=0A+ ".Lunlikely%=3D.tag:"=0A+=0A+#define = UNLIKELY_END(tag) \=0A+ "jmp .Llikely%=3D.tag;\n\t"= \=0A+ UNLIKELY_END_SECTION "\n" \=0A+ = ".Llikely%=3D.tag:"=0A+=0A #endif=0A =0A #endif /* __X86_ASM_DEFNS_H__ = */=0A--- a/xen/include/asm-x86/hvm/vmx/vmx.h=0A+++ b/xen/include/asm-x86/hv= m/vmx/vmx.h=0A@@ -285,7 +285,9 @@ static inline void __vmptrld(u64 = addr)=0A asm volatile ( VMPTRLD_OPCODE=0A MODRM_EAX_= 06=0A /* CF=3D=3D1 or ZF=3D=3D1 --> crash (ud2) */=0A- = "ja 1f ; ud2 ; 1:\n"=0A+ UNLIKELY_START(= be, vmptrld)=0A+ "\tud2\n"=0A+ = UNLIKELY_END_SECTION=0A :=0A : "a" = (&addr)=0A : "memory");=0A@@ -296,7 +298,9 @@ static = inline void __vmpclear(u64 addr)=0A asm volatile ( VMCLEAR_OPCODE=0A = MODRM_EAX_06=0A /* CF=3D=3D1 or = ZF=3D=3D1 --> crash (ud2) */=0A- "ja 1f ; ud2 ; = 1:\n"=0A+ UNLIKELY_START(be, vmclear)=0A+ = "\tud2\n"=0A+ UNLIKELY_END_SECTION=0A = :=0A : "a" (&addr)=0A : "memory");= =0A@@ -309,7 +313,9 @@ static inline unsigned long __vmread(uns=0A asm = volatile ( VMREAD_OPCODE=0A MODRM_EAX_ECX=0A = /* CF=3D=3D1 or ZF=3D=3D1 --> crash (ud2) */=0A- = "ja 1f ; ud2 ; 1:\n"=0A+ UNLIKELY_START(be, vmread)=0A+ = "\tud2\n"=0A+ UNLIKELY_END_SECTION=0A = : "=3Dc" (ecx)=0A : "a" (field)=0A = : "memory");=0A@@ -322,7 +328,9 @@ static inline void = __vmwrite(unsigned lo=0A asm volatile ( VMWRITE_OPCODE=0A = MODRM_EAX_ECX=0A /* CF=3D=3D1 or ZF=3D=3D1 --> = crash (ud2) */=0A- "ja 1f ; ud2 ; 1:\n"=0A+ = UNLIKELY_START(be, vmwrite)=0A+ "\tud2\n"=0A+ = UNLIKELY_END_SECTION=0A : =0A = : "a" (field) , "c" (value)=0A : "memory");=0A@@ = -360,7 +368,9 @@ static inline void __invept(int type, u6=0A asm = volatile ( INVEPT_OPCODE=0A MODRM_EAX_08=0A = /* CF=3D=3D1 or ZF=3D=3D1 --> crash (ud2) */=0A- = "ja 1f ; ud2 ; 1:\n"=0A+ UNLIKELY_START(be, invept)=0A+ = "\tud2\n"=0A+ UNLIKELY_END_SECTION=0A = :=0A : "a" (&operand), "c" (type)=0A = : "memory" );=0A@@ -377,7 +387,9 @@ static inline void = __invvpid(int type, u=0A /* Fix up #UD exceptions which occur when = TLBs are flushed before VMXON. */=0A asm volatile ( "1: " INVVPID_OPCOD= E MODRM_EAX_08=0A /* CF=3D=3D1 or ZF=3D=3D1 --> crash = (ud2) */=0A- "ja 2f ; ud2 ; 2:\n"=0A+ = "2: " UNLIKELY_START(be, invvpid)=0A+ "\tud2\n"=0A+ = UNLIKELY_END_SECTION "\n"=0A _ASM_EXTABLE(1= b, 2b)=0A :=0A : "a" (&operand), "c" = (type)=0A --=__Part2A19626C.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part2A19626C.1__=--