[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v5 1/2] x86/XPTI: use %r12 to write zero into xen_cr3
Now that we zero all registers early on all entry paths, use that to avoid a couple of immediates here. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Tested-by: Juergen Gross <jgross@xxxxxxxx> Reviewed-by: Juergen Gross <jgross@xxxxxxxx> Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- v5: Re-base. v4: Add comments about the %r12 being zero --- We may want to consider eliminating a few more $0 this way. But especially for byte ones I'm not sure it's worth it, due to the REX prefix the use of %r12 would incur. --- a/xen/arch/x86/x86_64/compat/entry.S +++ b/xen/arch/x86/x86_64/compat/entry.S @@ -220,7 +220,8 @@ ENTRY(cstar_enter) jz .Lcstar_cr3_okay movb $0, STACK_CPUINFO_FIELD(use_pv_cr3)(%rbx) mov %rcx, %cr3 - movq $0, STACK_CPUINFO_FIELD(xen_cr3)(%rbx) + /* %r12 is still zero at this point. */ + mov %r12, STACK_CPUINFO_FIELD(xen_cr3)(%rbx) .Lcstar_cr3_okay: sti @@ -244,7 +245,8 @@ UNLIKELY_START(z, compat_syscall_gpf) movq VCPU_trap_ctxt(%rbx),%rdi movl $TRAP_gp_fault,UREGS_entry_vector(%rsp) subl $2,UREGS_rip(%rsp) - movl $0,TRAPBOUNCE_error_code(%rdx) + /* %r12 is still zero at this point. */ + mov %r12d, TRAPBOUNCE_error_code(%rdx) movl TRAP_gp_fault * TRAPINFO_sizeof + TRAPINFO_eip(%rdi),%eax movzwl TRAP_gp_fault * TRAPINFO_sizeof + TRAPINFO_cs(%rdi),%esi testb $4,TRAP_gp_fault * TRAPINFO_sizeof + TRAPINFO_flags(%rdi) --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -266,7 +266,8 @@ ENTRY(lstar_enter) jz .Llstar_cr3_okay movb $0, STACK_CPUINFO_FIELD(use_pv_cr3)(%rbx) mov %rcx, %cr3 - movq $0, STACK_CPUINFO_FIELD(xen_cr3)(%rbx) + /* %r12 is still zero at this point. */ + mov %r12, STACK_CPUINFO_FIELD(xen_cr3)(%rbx) .Llstar_cr3_okay: sti @@ -302,7 +303,8 @@ GLOBAL(sysenter_eflags_saved) jz .Lsyse_cr3_okay movb $0, STACK_CPUINFO_FIELD(use_pv_cr3)(%rbx) mov %rcx, %cr3 - movq $0, STACK_CPUINFO_FIELD(xen_cr3)(%rbx) + /* %r12 is still zero at this point. */ + mov %r12, STACK_CPUINFO_FIELD(xen_cr3)(%rbx) .Lsyse_cr3_okay: sti @@ -351,7 +353,8 @@ ENTRY(int80_direct_trap) jz .Lint80_cr3_okay movb $0, STACK_CPUINFO_FIELD(use_pv_cr3)(%rbx) mov %rcx, %cr3 - movq $0, STACK_CPUINFO_FIELD(xen_cr3)(%rbx) + /* %r12 is still zero at this point. */ + mov %r12, STACK_CPUINFO_FIELD(xen_cr3)(%rbx) .Lint80_cr3_okay: sti @@ -566,11 +569,11 @@ ENTRY(common_interrupt) jz .Lintr_cr3_okay movb $0, STACK_CPUINFO_FIELD(use_pv_cr3)(%r14) mov %rcx, %cr3 - xor %ecx, %ecx - mov %rcx, STACK_CPUINFO_FIELD(xen_cr3)(%r14) + /* %r12 is still zero at this point. */ + mov %r12, STACK_CPUINFO_FIELD(xen_cr3)(%r14) testb $3, UREGS_cs(%rsp) - cmovnz %rcx, %r15 - cmovnz %rcx, %rbx + cmovnz %r12, %r15 + cmovnz %r12d, %ebx .Lintr_cr3_okay: CR4_PV32_RESTORE @@ -598,11 +601,11 @@ GLOBAL(handle_exception) jz .Lxcpt_cr3_okay movb $0, STACK_CPUINFO_FIELD(use_pv_cr3)(%r14) mov %rcx, %cr3 - xor %ecx, %ecx - mov %rcx, STACK_CPUINFO_FIELD(xen_cr3)(%r14) + /* %r12 is still zero at this point. */ + mov %r12, STACK_CPUINFO_FIELD(xen_cr3)(%r14) testb $3, UREGS_cs(%rsp) - cmovnz %rcx, %r15 - cmovnz %rcx, %r13 + cmovnz %r12, %r15 + cmovnz %r12d, %r13d .Lxcpt_cr3_okay: handle_exception_saved: @@ -775,7 +778,8 @@ ENTRY(double_fault) jz .Ldblf_cr3_okay movb $0, STACK_CPUINFO_FIELD(use_pv_cr3)(%r14) mov %rbx, %cr3 - movq $0, STACK_CPUINFO_FIELD(xen_cr3)(%r14) + /* %r12 is still zero at this point. */ + mov %r12, STACK_CPUINFO_FIELD(xen_cr3)(%r14) .Ldblf_cr3_okay: movq %rsp,%rdi @@ -809,7 +813,8 @@ handle_ist_exception: jz .List_cr3_okay movb $0, STACK_CPUINFO_FIELD(use_pv_cr3)(%r14) mov %rcx, %cr3 - movq $0, STACK_CPUINFO_FIELD(xen_cr3)(%r14) + /* %r12 is still zero at this point. */ + mov %r12, STACK_CPUINFO_FIELD(xen_cr3)(%r14) .List_cr3_okay: CR4_PV32_RESTORE _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |