From: "Jan Beulich" Subject: [PATCH, RFC 4/5] x86: avoid unlikely taken forward branches Date: Wed, 22 Dec 2010 12:17:42 +0000 Message-ID: <4D11FA7602000078000294F1@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartAE82FF76.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" 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. --=__PartAE82FF76.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... since these get statically mis-predicted by most CPUs and increase the cache footprint. This mostly concerns hypercall tracing and vm86 mode handling. Signed-off-by: Jan Beulich --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1330,7 +1330,7 @@ asmlinkage void do_page_fault(struct cpu * during early boot (an issue was seen once, but was most likely a = hardware=20 * problem). */ -asmlinkage void do_early_page_fault(struct cpu_user_regs *regs) +asmlinkage void __init do_early_page_fault(struct cpu_user_regs *regs) { static int stuck; static unsigned long prev_eip, prev_cr2; --- a/xen/arch/x86/x86_32/entry.S +++ b/xen/arch/x86/x86_32/entry.S @@ -142,7 +142,7 @@ restore_all_xen: ENTRY(hypercall) subl $4,%esp FIXUP_RING0_GUEST_STACK - SAVE_ALL(1f,1f) + SAVE_ALL(,1f) 1: sti GET_CURRENT(%ebx) cmpl $NR_hypercalls,%eax @@ -182,12 +182,14 @@ ENTRY(hypercall) #define SHADOW_BYTES 24 /* 6 shadow parameters */ #endif cmpb $0,tb_init_done - je 1f +UNLIKELY_START(ne, trace) call trace_hypercall /* Now restore all the registers that trace_hypercall clobbered = */ movl UREGS_eax+SHADOW_BYTES(%esp),%eax /* Hypercall # */ +UNLIKELY_END(trace) + call *hypercall_table(,%eax,4) + movl %eax,UREGS_eax+SHADOW_BYTES(%esp) # save the return value #undef SHADOW_BYTES -1: call *hypercall_table(,%eax,4) addl $24,%esp # Discard the shadow parameters #ifndef NDEBUG /* Deliberately corrupt real parameter regs used by this = hypercall. */ @@ -197,13 +199,10 @@ ENTRY(hypercall) jne skip_clobber # If EIP has changed then don't clobber movzb hypercall_args_table(,%ecx,1),%ecx movl %esp,%edi - movl %eax,%esi movl $0xDEADBEEF,%eax rep stosl - movl %esi,%eax skip_clobber: #endif - movl %eax,UREGS_eax(%esp) # save the return value =20 test_all_events: xorl %ecx,%ecx @@ -293,8 +292,8 @@ create_bounce_frame: jz ring1 /* jump if returning to an existing ring-1 activation = */ movl VCPU_kernel_sp(%ebx),%esi .Lft6: mov VCPU_kernel_ss(%ebx),%gs - testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp) - jz .Lnvm86_1 + testl $X86_EFLAGS_VM,%ecx +UNLIKELY_START(nz, bounce_vm86_1) subl $16,%esi /* push ES/DS/FS/GS (VM86 stack frame) */ movl UREGS_es+4(%esp),%eax .Lft7: movl %eax,%gs:(%esi) @@ -304,7 +303,7 @@ create_bounce_frame: .Lft9: movl %eax,%gs:8(%esi) movl UREGS_gs+4(%esp),%eax .Lft10: movl %eax,%gs:12(%esi) -.Lnvm86_1: +UNLIKELY_END(bounce_vm86_1) subl $8,%esi /* push SS/ESP (inter-priv iret) */ movl UREGS_esp+4(%esp),%eax .Lft11: movl %eax,%gs:(%esi) @@ -346,17 +345,10 @@ ring1: /* obtain ss/esp from oldss/olde movl TRAPBOUNCE_error_code(%edx),%eax .Lft17: movl %eax,%gs:(%esi) 1: testb $TBF_FAILSAFE,%cl - jz 2f +UNLIKELY_START(nz, bounce_failsafe) subl $16,%esi # add DS/ES/FS/GS to failsafe stack = frame testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp) - jz .Lnvm86_2 - xorl %eax,%eax # VM86: we write zero selector = values -.Lft18: movl %eax,%gs:(%esi) -.Lft19: movl %eax,%gs:4(%esi) -.Lft20: movl %eax,%gs:8(%esi) -.Lft21: movl %eax,%gs:12(%esi) - jmp 2f -.Lnvm86_2: + jnz .Lvm86_2 movl UREGS_ds+4(%esp),%eax # non-VM86: write real selector = values .Lft22: movl %eax,%gs:(%esi) movl UREGS_es+4(%esp),%eax @@ -365,13 +357,22 @@ ring1: /* obtain ss/esp from oldss/olde .Lft24: movl %eax,%gs:8(%esi) movl UREGS_gs+4(%esp),%eax .Lft25: movl %eax,%gs:12(%esi) -2: testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp) - jz .Lnvm86_3 + jmp .Lnvm86_3 +.Lvm86_2: + xorl %eax,%eax # VM86: we write zero selector = values +.Lft18: movl %eax,%gs:(%esi) +.Lft19: movl %eax,%gs:4(%esi) +.Lft20: movl %eax,%gs:8(%esi) +.Lft21: movl %eax,%gs:12(%esi) +UNLIKELY_END(bounce_failsafe) + testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp) +UNLIKELY_START(nz, bounce_vm86_3) xorl %eax,%eax /* zero DS-GS, just as a real CPU would */ movl %eax,UREGS_ds+4(%esp) movl %eax,UREGS_es+4(%esp) movl %eax,UREGS_fs+4(%esp) movl %eax,UREGS_gs+4(%esp) +UNLIKELY_END(bounce_vm86_3) .Lnvm86_3: /* Rewrite our stack frame and return to ring 1. */ /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. = */ @@ -564,6 +565,7 @@ ENTRY(spurious_interrupt_bug) pushl $TRAP_spurious_int<<16 jmp handle_exception =20 + .pushsection .init.text, "ax", @progbits ENTRY(early_page_fault) SAVE_ALL(1f,1f) 1: movl %esp,%eax @@ -571,6 +573,7 @@ ENTRY(early_page_fault) call do_early_page_fault addl $4,%esp jmp restore_all_xen + .popsection =20 handle_nmi_mce: #ifdef CONFIG_X86_SUPERVISOR_MODE_KERNEL --- a/xen/arch/x86/x86_64/compat/entry.S +++ b/xen/arch/x86/x86_64/compat/entry.S @@ -49,7 +49,7 @@ ENTRY(compat_hypercall) #define SHADOW_BYTES 0 /* No on-stack shadow state */ #endif cmpb $0,tb_init_done(%rip) - je 1f +UNLIKELY_START(ne, compat_trace) call trace_hypercall /* Now restore all the registers that trace_hypercall clobbered = */ movl UREGS_rax+SHADOW_BYTES(%rsp),%eax /* Hypercall # */ @@ -60,7 +60,8 @@ ENTRY(compat_hypercall) movl UREGS_rdi+SHADOW_BYTES(%rsp),%r8d /* Arg 5 */ movl UREGS_rbp+SHADOW_BYTES(%rsp),%r9d /* Arg 6 */ #undef SHADOW_BYTES -1: leaq compat_hypercall_table(%rip),%r10 +UNLIKELY_END(compat_trace) + leaq compat_hypercall_table(%rip),%r10 PERFC_INCR(PERFC_hypercalls, %rax, %rbx) callq *(%r10,%rax,8) #ifndef NDEBUG @@ -295,7 +296,7 @@ compat_create_bounce_frame: .Lft8: movl %eax,%fs:(%rsi) # ERROR CODE 1: testb $TBF_FAILSAFE,%cl - jz 2f +UNLIKELY_START(nz, compat_bounce_failsafe) subl $4*4,%esi movl %gs,%eax .Lft9: movl %eax,%fs:3*4(%rsi) # GS @@ -304,7 +305,7 @@ compat_create_bounce_frame: .Lft11: movl %eax,%fs:1*4(%rsi) # ES movl %ds,%eax .Lft12: movl %eax,%fs:0*4(%rsi) # DS -2: +UNLIKELY_END(compat_bounce_failsafe) /* Rewrite our stack frame and return to guest-OS mode. */ /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. = */ andl $~(X86_EFLAGS_VM|X86_EFLAGS_RF|\ --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -148,7 +148,7 @@ ENTRY(syscall_enter) #define SHADOW_BYTES 0 /* No on-stack shadow state */ #endif cmpb $0,tb_init_done(%rip) - je 1f +UNLIKELY_START(ne, trace) call trace_hypercall /* Now restore all the registers that trace_hypercall clobbered = */ movq UREGS_rax+SHADOW_BYTES(%rsp),%rax /* Hypercall # */ @@ -159,7 +159,8 @@ ENTRY(syscall_enter) movq UREGS_r8 +SHADOW_BYTES(%rsp),%r8 /* Arg 5 */ movq UREGS_r9 +SHADOW_BYTES(%rsp),%r9 /* Arg 6 */ #undef SHADOW_BYTES -1: leaq hypercall_table(%rip),%r10 +UNLIKELY_END(trace) + leaq hypercall_table(%rip),%r10 PERFC_INCR(PERFC_hypercalls, %rax, %rbx) callq *(%r10,%rax,8) #ifndef NDEBUG @@ -341,11 +342,12 @@ create_bounce_frame: 2: andq $~0xf,%rsi # Stack frames are 16-byte = aligned. movq $HYPERVISOR_VIRT_START,%rax cmpq %rax,%rsi - jb 1f # In +ve address space? Then = okay. movq $HYPERVISOR_VIRT_END+60,%rax + sbb %ecx,%ecx # In +ve address space? Then = okay. cmpq %rax,%rsi - jb domain_crash_synchronous # Above Xen private area? Then = okay. -1: movb TRAPBOUNCE_flags(%rdx),%cl + adc %ecx,%ecx # Above Xen private area? Then = okay. + jg domain_crash_synchronous + movb TRAPBOUNCE_flags(%rdx),%cl subq $40,%rsi movq UREGS_ss+8(%rsp),%rax .Lft2: movq %rax,32(%rsi) # SS @@ -376,7 +378,7 @@ create_bounce_frame: movl TRAPBOUNCE_error_code(%rdx),%eax .Lft7: movq %rax,(%rsi) # ERROR CODE 1: testb $TBF_FAILSAFE,%cl - jz 2f +UNLIKELY_START(nz, bounce_failsafe) subq $32,%rsi movl %gs,%eax .Lft8: movq %rax,24(%rsi) # GS @@ -386,7 +388,8 @@ create_bounce_frame: .Lft10: movq %rax,8(%rsi) # ES movl %ds,%eax .Lft11: movq %rax,(%rsi) # DS -2: subq $16,%rsi +UNLIKELY_END(bounce_failsafe) + subq $16,%rsi movq UREGS_r11+8(%rsp),%rax .Lft12: movq %rax,8(%rsi) # R11 movq UREGS_rcx+8(%rsp),%rax @@ -601,11 +604,13 @@ ENTRY(double_fault) call do_double_fault ud2 =20 + .pushsection .init.text, "ax", @progbits ENTRY(early_page_fault) SAVE_ALL movq %rsp,%rdi call do_early_page_fault jmp restore_all_xen + .popsection =20 handle_ist_exception: SAVE_ALL --- a/xen/include/asm-x86/asm_defns.h +++ b/xen/include/asm-x86/asm_defns.h @@ -32,4 +32,18 @@ #define _ASM_EXTABLE(from, to) _ASM__EXTABLE(, from, to) #define _ASM_PRE_EXTABLE(from, to) _ASM__EXTABLE(.pre, from, to) =20 +#ifdef __ASSEMBLY__ + +#define UNLIKELY_START(cond, tag) \ + j##cond .Lunlikely.tag; \ + .subsection 1; \ + .Lunlikely.tag: + +#define UNLIKELY_END(tag) \ + jmp .Llikely.tag; \ + .subsection 0; \ + .Llikely.tag: + +#endif + #endif /* __X86_ASM_DEFNS_H__ */ --- a/xen/include/asm-x86/x86_32/asm_defns.h +++ b/xen/include/asm-x86/x86_32/asm_defns.h @@ -1,6 +1,7 @@ #ifndef __X86_32_ASM_DEFNS_H__ #define __X86_32_ASM_DEFNS_H__ =20 +#include #include =20 #ifdef CONFIG_FRAME_POINTER @@ -53,12 +54,14 @@ mov %es,%esi; \ mov $(__HYPERVISOR_DS),%ecx; \ jnz 86f; \ - .text 1; \ + .subsection 1; \ 86: call setup_vm86_frame; \ jmp vm86_lbl; \ .previous; \ + .ifnes __stringify(xen_lbl), ""; \ testb $3,UREGS_cs(%esp); \ jz xen_lbl; \ + .endif; \ /* \ * We are the outermost Xen context, but our \ * life is complicated by NMIs and MCEs. These \ --- /dev/null +++ b/xen/include/xen/stringify.h @@ -0,0 +1,12 @@ +#ifndef __XEN_STRINGIFY_H +#define __XEN_STRINGIFY_H + +/* Indirect stringification. Doing two levels allows the parameter to be = a + * macro itself. For example, compile with -DFOO=3Dbar, __stringify(FOO) + * converts to "bar". + */ + +#define __stringify_1(x...) #x +#define __stringify(x...) __stringify_1(x) + +#endif /* !__XEN_STRINGIFY_H */ --=__PartAE82FF76.0__= Content-Type: text/plain; name="x86-forward-branches.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-forward-branches.patch" ... since these get statically mis-predicted by most CPUs and increase=0Ath= e cache footprint. This mostly concerns hypercall tracing and vm86=0Amode = handling.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/arch/x86/traps.c=0A+++ b/xen/arch/x86/traps.c=0A@@ -1330,7 +1330,7 = @@ asmlinkage void do_page_fault(struct cpu=0A * during early boot (an = issue was seen once, but was most likely a hardware =0A * problem).=0A = */=0A-asmlinkage void do_early_page_fault(struct cpu_user_regs *regs)=0A+as= mlinkage void __init do_early_page_fault(struct cpu_user_regs *regs)=0A = {=0A static int stuck;=0A static unsigned long prev_eip, = prev_cr2;=0A--- a/xen/arch/x86/x86_32/entry.S=0A+++ b/xen/arch/x86/x86_32/e= ntry.S=0A@@ -142,7 +142,7 @@ restore_all_xen:=0A ENTRY(hypercall)=0A = subl $4,%esp=0A FIXUP_RING0_GUEST_STACK=0A- SAVE_ALL(1f,1f= )=0A+ SAVE_ALL(,1f)=0A 1: sti=0A GET_CURRENT(%ebx)=0A = cmpl $NR_hypercalls,%eax=0A@@ -182,12 +182,14 @@ ENTRY(hypercall)= =0A #define SHADOW_BYTES 24 /* 6 shadow parameters */=0A #endif=0A = cmpb $0,tb_init_done=0A- je 1f=0A+UNLIKELY_START(ne, trace)=0A = call trace_hypercall=0A /* Now restore all the registers = that trace_hypercall clobbered */=0A movl UREGS_eax+SHADOW_BYTES(%= esp),%eax /* Hypercall # */=0A+UNLIKELY_END(trace)=0A+ call = *hypercall_table(,%eax,4)=0A+ movl %eax,UREGS_eax+SHADOW_BYTES(%esp= ) # save the return value=0A #undef SHADOW_BYTES=0A-1: call *hypercall= _table(,%eax,4)=0A addl $24,%esp # Discard the shadow = parameters=0A #ifndef NDEBUG=0A /* Deliberately corrupt real = parameter regs used by this hypercall. */=0A@@ -197,13 +199,10 @@ = ENTRY(hypercall)=0A jne skip_clobber # If EIP has changed then = don't clobber=0A movzb hypercall_args_table(,%ecx,1),%ecx=0A = movl %esp,%edi=0A- movl %eax,%esi=0A movl $0xDEADBEEF,%= eax=0A rep stosl=0A- movl %esi,%eax=0A skip_clobber:=0A = #endif=0A- movl %eax,UREGS_eax(%esp) # save the return = value=0A =0A test_all_events:=0A xorl %ecx,%ecx=0A@@ -293,8 +292,8 = @@ create_bounce_frame:=0A jz ring1 /* jump if returning to an = existing ring-1 activation */=0A movl VCPU_kernel_sp(%ebx),%esi=0A = .Lft6: mov VCPU_kernel_ss(%ebx),%gs=0A- testl $X86_EFLAGS_VM,UREGS= _eflags+4(%esp)=0A- jz .Lnvm86_1=0A+ testl $X86_EFLAGS_VM,%= ecx=0A+UNLIKELY_START(nz, bounce_vm86_1)=0A subl $16,%esi /* = push ES/DS/FS/GS (VM86 stack frame) */=0A movl UREGS_es+4(%esp),%ea= x=0A .Lft7: movl %eax,%gs:(%esi)=0A@@ -304,7 +303,7 @@ create_bounce_frame= :=0A .Lft9: movl %eax,%gs:8(%esi)=0A movl UREGS_gs+4(%esp),%eax=0A= .Lft10: movl %eax,%gs:12(%esi)=0A-.Lnvm86_1:=0A+UNLIKELY_END(bounce_vm86_1= )=0A subl $8,%esi /* push SS/ESP (inter-priv iret) */=0A = movl UREGS_esp+4(%esp),%eax=0A .Lft11: movl %eax,%gs:(%esi)=0A@@ = -346,17 +345,10 @@ ring1: /* obtain ss/esp from oldss/olde=0A = movl TRAPBOUNCE_error_code(%edx),%eax=0A .Lft17: movl %eax,%gs:(%esi)=0A = 1: testb $TBF_FAILSAFE,%cl=0A- jz 2f=0A+UNLIKELY_START(nz, = bounce_failsafe)=0A subl $16,%esi # add DS/ES/FS/GS = to failsafe stack frame=0A testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp= )=0A- jz .Lnvm86_2=0A- xorl %eax,%eax # = VM86: we write zero selector values=0A-.Lft18: movl %eax,%gs:(%esi)=0A-.Lft= 19: movl %eax,%gs:4(%esi)=0A-.Lft20: movl %eax,%gs:8(%esi)=0A-.Lft21: movl = %eax,%gs:12(%esi)=0A- jmp 2f=0A-.Lnvm86_2:=0A+ jnz = .Lvm86_2=0A movl UREGS_ds+4(%esp),%eax # non-VM86: write real = selector values=0A .Lft22: movl %eax,%gs:(%esi)=0A movl UREGS_es+4(= %esp),%eax=0A@@ -365,13 +357,22 @@ ring1: /* obtain ss/esp from oldss/olde= =0A .Lft24: movl %eax,%gs:8(%esi)=0A movl UREGS_gs+4(%esp),%eax=0A = .Lft25: movl %eax,%gs:12(%esi)=0A-2: testl $X86_EFLAGS_VM,UREGS_eflags= +4(%esp)=0A- jz .Lnvm86_3=0A+ jmp .Lnvm86_3=0A+.Lvm86_2:= =0A+ xorl %eax,%eax # VM86: we write zero selector = values=0A+.Lft18: movl %eax,%gs:(%esi)=0A+.Lft19: movl %eax,%gs:4(%esi)=0A+= .Lft20: movl %eax,%gs:8(%esi)=0A+.Lft21: movl %eax,%gs:12(%esi)=0A+UNLIKELY= _END(bounce_failsafe)=0A+ testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp)= =0A+UNLIKELY_START(nz, bounce_vm86_3)=0A xorl %eax,%eax /* = zero DS-GS, just as a real CPU would */=0A movl %eax,UREGS_ds+4(%es= p)=0A movl %eax,UREGS_es+4(%esp)=0A movl %eax,UREGS_fs+4(%e= sp)=0A movl %eax,UREGS_gs+4(%esp)=0A+UNLIKELY_END(bounce_vm86_3)=0A= .Lnvm86_3:=0A /* Rewrite our stack frame and return to ring 1. = */=0A /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on = trap. */=0A@@ -564,6 +565,7 @@ ENTRY(spurious_interrupt_bug)=0A = pushl $TRAP_spurious_int<<16=0A jmp handle_exception=0A =0A+ = .pushsection .init.text, "ax", @progbits=0A ENTRY(early_page_fault)=0A = SAVE_ALL(1f,1f)=0A 1: movl %esp,%eax=0A@@ -571,6 +573,7 @@ = ENTRY(early_page_fault)=0A call do_early_page_fault=0A = addl $4,%esp=0A jmp restore_all_xen=0A+ .popsection=0A =0A = handle_nmi_mce:=0A #ifdef CONFIG_X86_SUPERVISOR_MODE_KERNEL=0A--- = a/xen/arch/x86/x86_64/compat/entry.S=0A+++ b/xen/arch/x86/x86_64/compat/ent= ry.S=0A@@ -49,7 +49,7 @@ ENTRY(compat_hypercall)=0A #define SHADOW_BYTES 0 = /* No on-stack shadow state */=0A #endif=0A cmpb $0,tb_init_done(= %rip)=0A- je 1f=0A+UNLIKELY_START(ne, compat_trace)=0A = call trace_hypercall=0A /* Now restore all the registers that = trace_hypercall clobbered */=0A movl UREGS_rax+SHADOW_BYTES(%rsp),= %eax /* Hypercall # */=0A@@ -60,7 +60,8 @@ ENTRY(compat_hypercall)=0A = movl UREGS_rdi+SHADOW_BYTES(%rsp),%r8d /* Arg 5 */=0A = movl UREGS_rbp+SHADOW_BYTES(%rsp),%r9d /* Arg 6 */=0A #undef = SHADOW_BYTES=0A-1: leaq compat_hypercall_table(%rip),%r10=0A+UNLIKELY= _END(compat_trace)=0A+ leaq compat_hypercall_table(%rip),%r10=0A = PERFC_INCR(PERFC_hypercalls, %rax, %rbx)=0A callq *(%r10,%rax= ,8)=0A #ifndef NDEBUG=0A@@ -295,7 +296,7 @@ compat_create_bounce_frame:=0A = .Lft8: movl %eax,%fs:(%rsi) # ERROR CODE=0A 1:=0A = testb $TBF_FAILSAFE,%cl=0A- jz 2f=0A+UNLIKELY_START(nz, = compat_bounce_failsafe)=0A subl $4*4,%esi=0A movl = %gs,%eax=0A .Lft9: movl %eax,%fs:3*4(%rsi) # GS=0A@@ -304,7 = +305,7 @@ compat_create_bounce_frame:=0A .Lft11: movl %eax,%fs:1*4(%rsi) = # ES=0A movl %ds,%eax=0A .Lft12: movl %eax,%fs:0*4(%rsi) = # DS=0A-2:=0A+UNLIKELY_END(compat_bounce_failsafe)=0A /* = Rewrite our stack frame and return to guest-OS mode. */=0A /* IA32 = Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. */=0A = andl $~(X86_EFLAGS_VM|X86_EFLAGS_RF|\=0A--- a/xen/arch/x86/x86_64/entry.S= =0A+++ b/xen/arch/x86/x86_64/entry.S=0A@@ -148,7 +148,7 @@ ENTRY(syscall_en= ter)=0A #define SHADOW_BYTES 0 /* No on-stack shadow state */=0A = #endif=0A cmpb $0,tb_init_done(%rip)=0A- je 1f=0A+UNLIKE= LY_START(ne, trace)=0A call trace_hypercall=0A /* Now = restore all the registers that trace_hypercall clobbered */=0A = movq UREGS_rax+SHADOW_BYTES(%rsp),%rax /* Hypercall # */=0A@@ -159,7 = +159,8 @@ ENTRY(syscall_enter)=0A movq UREGS_r8 +SHADOW_BYTES(%rsp= ),%r8 /* Arg 5 */=0A movq UREGS_r9 +SHADOW_BYTES(%rsp),%= r9 /* Arg 6 */=0A #undef SHADOW_BYTES=0A-1: leaq hypercall_= table(%rip),%r10=0A+UNLIKELY_END(trace)=0A+ leaq hypercall_table(%r= ip),%r10=0A PERFC_INCR(PERFC_hypercalls, %rax, %rbx)=0A = callq *(%r10,%rax,8)=0A #ifndef NDEBUG=0A@@ -341,11 +342,12 @@ create_bounc= e_frame:=0A 2: andq $~0xf,%rsi # Stack frames are = 16-byte aligned.=0A movq $HYPERVISOR_VIRT_START,%rax=0A = cmpq %rax,%rsi=0A- jb 1f # In +ve = address space? Then okay.=0A movq $HYPERVISOR_VIRT_END+60,%rax=0A+= sbb %ecx,%ecx # In +ve address space? Then = okay.=0A cmpq %rax,%rsi=0A- jb domain_crash_synchronous = # Above Xen private area? Then okay.=0A-1: movb TRAPBOUNCE_flags(%rd= x),%cl=0A+ adc %ecx,%ecx # Above Xen private = area? Then okay.=0A+ jg domain_crash_synchronous=0A+ movb = TRAPBOUNCE_flags(%rdx),%cl=0A subq $40,%rsi=0A movq = UREGS_ss+8(%rsp),%rax=0A .Lft2: movq %rax,32(%rsi) # SS=0A@@ = -376,7 +378,7 @@ create_bounce_frame:=0A movl TRAPBOUNCE_error_cod= e(%rdx),%eax=0A .Lft7: movq %rax,(%rsi) # ERROR CODE=0A 1: = testb $TBF_FAILSAFE,%cl=0A- jz 2f=0A+UNLIKELY_START(nz, = bounce_failsafe)=0A subq $32,%rsi=0A movl %gs,%eax=0A = .Lft8: movq %rax,24(%rsi) # GS=0A@@ -386,7 +388,8 @@ = create_bounce_frame:=0A .Lft10: movq %rax,8(%rsi) # ES=0A = movl %ds,%eax=0A .Lft11: movq %rax,(%rsi) # DS=0A-2: = subq $16,%rsi=0A+UNLIKELY_END(bounce_failsafe)=0A+ subq = $16,%rsi=0A movq UREGS_r11+8(%rsp),%rax=0A .Lft12: movq = %rax,8(%rsi) # R11=0A movq UREGS_rcx+8(%rsp),%rax=0A@= @ -601,11 +604,13 @@ ENTRY(double_fault)=0A call do_double_fault= =0A ud2=0A =0A+ .pushsection .init.text, "ax", @progbits=0A = ENTRY(early_page_fault)=0A SAVE_ALL=0A movq %rsp,%rdi=0A = call do_early_page_fault=0A jmp restore_all_xen=0A+ = .popsection=0A =0A handle_ist_exception:=0A SAVE_ALL=0A--- = a/xen/include/asm-x86/asm_defns.h=0A+++ b/xen/include/asm-x86/asm_defns.h= =0A@@ -32,4 +32,18 @@=0A #define _ASM_EXTABLE(from, to) _ASM__EXTABLE(,= from, to)=0A #define _ASM_PRE_EXTABLE(from, to) _ASM__EXTABLE(.pre, from, = to)=0A =0A+#ifdef __ASSEMBLY__=0A+=0A+#define UNLIKELY_START(cond, tag) = \=0A+ j##cond .Lunlikely.tag; \=0A+ = .subsection 1; \=0A+ .Lunlikely.tag:=0A+= =0A+#define UNLIKELY_END(tag) \=0A+ jmp = .Llikely.tag; \=0A+ .subsection 0; = \=0A+ .Llikely.tag:=0A+=0A+#endif=0A+=0A #endif /* = __X86_ASM_DEFNS_H__ */=0A--- a/xen/include/asm-x86/x86_32/asm_defns.h=0A+++= b/xen/include/asm-x86/x86_32/asm_defns.h=0A@@ -1,6 +1,7 @@=0A #ifndef = __X86_32_ASM_DEFNS_H__=0A #define __X86_32_ASM_DEFNS_H__=0A =0A+#include = =0A #include =0A =0A #ifdef CONFIG_FRAME_POI= NTER=0A@@ -53,12 +54,14 @@=0A mov %es,%esi; = \=0A mov $(__HYPERVISOR_DS),%ecx; = \=0A jnz 86f; \=0A- = .text 1; \=0A+ .subsection = 1; \=0A 86: call setup_vm86_fram= e; \=0A jmp vm86_lbl; = \=0A .previous; \=0A+ = .ifnes __stringify(xen_lbl), ""; \=0A testb = $3,UREGS_cs(%esp); \=0A jz xen_lbl; = \=0A+ .endif; = \=0A /* = \=0A * We are the outermost Xen context, but our \=0A = * life is complicated by NMIs and MCEs. These \=0A--- /dev/null=0A+++ = b/xen/include/xen/stringify.h=0A@@ -0,0 +1,12 @@=0A+#ifndef __XEN_STRINGIFY= _H=0A+#define __XEN_STRINGIFY_H=0A+=0A+/* Indirect stringification. Doing = two levels allows the parameter to be a=0A+ * macro itself. For example, = compile with -DFOO=3Dbar, __stringify(FOO)=0A+ * converts to "bar".=0A+ = */=0A+=0A+#define __stringify_1(x...) #x=0A+#define __stringify(x...) = __stringify_1(x)=0A+=0A+#endif /* !__XEN_STRINGIFY_H */=0A --=__PartAE82FF76.0__= 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.xensource.com http://lists.xensource.com/xen-devel --=__PartAE82FF76.0__=--