|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] x86: enhance rsp-relative calculations
# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1348652901 -7200
# Node ID 42bacb953f6b8d2ae1df8cbe8d6347d02eaeeccb
# Parent 656662f7ea59790cd81d22c563541dc0a46b59eb
x86: enhance rsp-relative calculations
The use of "or" in GET_CPUINFO_FIELD so far wasn't ideal, as it doesn't
lend itself to folding this operation with a possibly subsequent one
(e.g. the well known mov+add=lea conversion). Split out the sub-
operations, and shorten assembly code slightly with this.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
---
diff -r 656662f7ea59 -r 42bacb953f6b xen/arch/x86/x86_64/entry.S
--- a/xen/arch/x86/x86_64/entry.S Tue Sep 25 18:45:04 2012 +0100
+++ b/xen/arch/x86/x86_64/entry.S Wed Sep 26 11:48:21 2012 +0200
@@ -445,10 +445,10 @@ domain_crash_synchronous_string:
ENTRY(domain_crash_synchronous)
# Get out of the guest-save area of the stack.
- GET_CPUINFO_FIELD(CPUINFO_guest_cpu_user_regs,%rax)
- movq %rax,%rsp
+ GET_STACK_BASE(%rax)
+ leaq STACK_CPUINFO_FIELD(guest_cpu_user_regs)(%rax),%rsp
# create_bounce_frame() temporarily clobbers CS.RPL. Fix up.
- GET_CURRENT(%rax)
+ __GET_CURRENT(%rax)
movq VCPU_domain(%rax),%rax
testb $1,DOMAIN_is_32bit_pv(%rax)
setz %al
@@ -622,7 +622,7 @@ handle_ist_exception:
testb $3,UREGS_cs(%rsp)
jz 1f
/* Interrupted guest context. Copy the context to stack bottom. */
- GET_CPUINFO_FIELD(CPUINFO_guest_cpu_user_regs,%rdi)
+ GET_CPUINFO_FIELD(guest_cpu_user_regs,%rdi)
movq %rsp,%rsi
movl $UREGS_kernel_sizeof/8,%ecx
movq %rdi,%rsp
diff -r 656662f7ea59 -r 42bacb953f6b xen/include/asm-x86/asm_defns.h
--- a/xen/include/asm-x86/asm_defns.h Tue Sep 25 18:45:04 2012 +0100
+++ b/xen/include/asm-x86/asm_defns.h Wed Sep 26 11:48:21 2012 +0200
@@ -44,6 +44,21 @@ void ret_from_intr(void);
.subsection 0; \
.Llikely.tag:
+#define STACK_CPUINFO_FIELD(field) (STACK_SIZE-CPUINFO_sizeof+CPUINFO_##field)
+#define GET_STACK_BASE(reg) \
+ movq $~(STACK_SIZE-1),reg; \
+ andq %rsp,reg
+
+#define GET_CPUINFO_FIELD(field, reg) \
+ GET_STACK_BASE(reg); \
+ addq $STACK_CPUINFO_FIELD(field),reg
+
+#define __GET_CURRENT(reg) \
+ movq STACK_CPUINFO_FIELD(current_vcpu)(reg),reg
+#define GET_CURRENT(reg) \
+ GET_STACK_BASE(reg); \
+ __GET_CURRENT(reg)
+
#endif
#endif /* __X86_ASM_DEFNS_H__ */
diff -r 656662f7ea59 -r 42bacb953f6b xen/include/asm-x86/x86_64/asm_defns.h
--- a/xen/include/asm-x86/x86_64/asm_defns.h Tue Sep 25 18:45:04 2012 +0100
+++ b/xen/include/asm-x86/x86_64/asm_defns.h Wed Sep 26 11:48:21 2012 +0200
@@ -111,14 +111,6 @@ STR(IRQ) #nr "_interrupt:\n\t"
"movl $"#nr",4(%rsp)\n\t" \
"jmp common_interrupt");
-#define GET_CPUINFO_FIELD(field,reg) \
- movq $~(STACK_SIZE-1),reg; \
- andq %rsp,reg; \
- orq $(STACK_SIZE-CPUINFO_sizeof+field),reg;
-#define GET_CURRENT(reg) \
- GET_CPUINFO_FIELD(CPUINFO_current_vcpu,reg) \
- movq (reg),reg;
-
#ifdef __ASSEMBLY__
# define _ASM_EX(p) p-.
#else
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |