Magellan Linux

Contents of /trunk/kernel26-xen/patches-2.6.25-r1/1087-2.6.25-xen-64-xen_iret-use-iretq-directly-if-returning-t.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 606 - (show annotations) (download)
Thu May 22 23:13:13 2008 UTC (15 years, 11 months ago) by niro
File size: 2568 byte(s)
-ver bump to 2.6.25-magellan-r1:
- linux-2.6.25.4
- fbcondecor-0.9.4
- squashfs-3.3
- unionfs-2.3.3
- tuxonice-3.0-rc7
- linux-phc-0.3.0
- acpi-dstd-0.9a
- reiser4
- xen-3.2.0
. ipw3945-1.2.2

1 From 22cc94bb97f4c9ae3fcd3d3c751db935c8c594a2 Mon Sep 17 00:00:00 2001
2 From: Eduardo Habkost <ehabkost@redhat.com>
3 Date: Fri, 4 Jan 2008 11:54:37 -0200
4 Subject: [PATCH] xen-64: xen_iret() use iretq directly if returning to kernel-space
5
6 Optimization pulled from upstream Xen.
7
8 Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
9 ---
10 arch/x86/xen/xen-asm.S | 5 ++++
11 arch/x86/xen/xen-asm_64.S | 49 +++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 54 insertions(+), 0 deletions(-)
13
14 diff --git a/arch/x86/xen/xen-asm.S b/arch/x86/xen/xen-asm.S
15 index 1c3c0ac..c7356c0 100644
16 --- a/arch/x86/xen/xen-asm.S
17 +++ b/arch/x86/xen/xen-asm.S
18 @@ -21,6 +21,11 @@
19 #include <asm/asm-hack.h>
20
21 #include <xen/interface/xen.h>
22 +#include <xen/interface/features.h>
23 +
24 +#include <asm/calling.h>
25 +#include <asm/processor-flags.h>
26 +
27
28 #define RELOC(x, v) .globl x##_reloc; x##_reloc=v
29 #define ENDPATCH(x) .globl x##_end; x##_end=.
30 diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
31 index 8f28a91..85c235c 100644
32 --- a/arch/x86/xen/xen-asm_64.S
33 +++ b/arch/x86/xen/xen-asm_64.S
34 @@ -7,7 +7,56 @@ ENTRY(xen_iret_direct)
35 /*FIXME: implement me! */
36 ud2a
37
38 +//FIXME: move to calling.h?
39 +#define IRETOFFSET RIP
40 +
41 ENTRY(xen_iret)
42 + /* Are we returning to kernel space? */
43 + testb $3,CS-IRETOFFSET(%rsp)
44 + jnz xen_iret_slow
45 +
46 +#if 0
47 + /*FIXME: handle NMI callbacks */
48 + testl $NMI_MASK,EFLAGS-IRETOFFSET(%rsp)
49 + jnz xen_iret_slow
50 +#endif
51 +
52 + /* If we are going to restore interrupts, we need to
53 + * return through the hypervisor, too.
54 + *
55 + * We may set evtchn_upcall_mask ourselves, but things get complicated
56 + * because we would need to avoid a stack overflow if we get
57 + * interrupts between upcall_mask being cleared and iret being
58 + * executed.
59 + */
60 + testl $X86_EFLAGS_IF,EFLAGS-IRETOFFSET(%rsp)
61 + jnz xen_iret_slow
62 +
63 +
64 +
65 + /* Returning to kernel (RING0).
66 + * Use direct iret to kernel space after correcting CS and SS
67 + */
68 +
69 + cmpb $0,(xen_features+XENFEAT_supervisor_mode_kernel)(%rip)
70 + /* supervisor_mode_kernel -> no need to correct CS and SS */
71 + jne xen_iretq
72 +
73 + /* Direct iret to kernel space. Correct CS and SS. */
74 + orl $3,CS-IRETOFFSET(%rsp)
75 + orl $3,SS-IRETOFFSET(%rsp)
76 +xen_iretq:
77 + iretq
78 +
79 +xen_iret_slow:
80 + /* Slow iret via hypervisor */
81 +
82 +#if 0
83 + /*FIXME: handle NMI callbacks */
84 + andl $~NMI_MASK, 2*8(%rsp)
85 +#endif
86 +
87 + /* Xen has an additional value in the stack for iret */
88 /*FIXME: the VGCF_in_syscall flag need to be handled here */
89 pushq $0
90 jmp hypercall_page + (__HYPERVISOR_iret * 32)
91 --
92 1.5.4.1
93