Magellan Linux

Contents of /trunk/kernel26-xen/patches-2.6.25-r1/1002-2.6.25-xen-execshield-Add-xen-specific-load_user_cs_desc.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: 4383 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 01e03d706ed94a6510f1db7b349248fc1482cd9b Mon Sep 17 00:00:00 2001
2 From: Stephen Tweedie <sct@redhat.com>
3 Date: Tue, 11 Mar 2008 18:05:30 +0000
4 Subject: [PATCH] xen execshield: Add xen-specific load_user_cs_desc()
5
6 x86 32-bit execshield uses load_user_cs_desc() to setup the user CS
7 descriptor, but the Xen version needs to do this via a hypercall.
8
9 Add this via a new pv_cpu_ops->load_user_cs_desc pv_ops indirection
10 so that it can be selected appropriately at run-time.
11
12 Signed-off-by: Stephen Tweedie <sct@redhat.com>
13 ---
14 arch/x86/kernel/paravirt.c | 1 +
15 arch/x86/xen/enlighten.c | 17 +++++++++++++++++
16 include/asm-x86/desc.h | 8 ++++++--
17 include/asm-x86/paravirt.h | 6 ++++++
18 4 files changed, 30 insertions(+), 2 deletions(-)
19
20 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21 index 075962c..d59db07 100644
22 --- a/arch/x86/kernel/paravirt.c
23 +++ b/arch/x86/kernel/paravirt.c
24 @@ -331,6 +331,7 @@ struct pv_cpu_ops pv_cpu_ops = {
25 .read_tscp = native_read_tscp,
26 .load_tr_desc = native_load_tr_desc,
27 .set_ldt = native_set_ldt,
28 + .load_user_cs_desc = native_load_user_cs_desc,
29 .load_gdt = native_load_gdt,
30 .load_idt = native_load_idt,
31 .store_gdt = native_store_gdt,
32 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33 index 27ee26a..66ffdb2 100644
34 --- a/arch/x86/xen/enlighten.c
35 +++ b/arch/x86/xen/enlighten.c
36 @@ -290,6 +290,22 @@ static void xen_set_ldt(const void *addr, unsigned entries)
37 xen_mc_issue(PARAVIRT_LAZY_CPU);
38 }
39
40 +static inline void xen_load_user_cs_desc(int cpu, struct mm_struct *mm)
41 +{
42 + void *gdt;
43 + xmaddr_t mgdt;
44 + u64 descriptor;
45 + struct desc_struct user_cs;
46 +
47 + gdt = &get_cpu_gdt_table(cpu)[GDT_ENTRY_DEFAULT_USER_CS];
48 + mgdt = virt_to_machine(gdt);
49 +
50 + user_cs = mm->context.user_cs;
51 + descriptor = (u64) user_cs.a | ((u64) user_cs.b) << 32;
52 +
53 + HYPERVISOR_update_descriptor(mgdt.maddr, descriptor);
54 +}
55 +
56 static void xen_load_gdt(const struct desc_ptr *dtr)
57 {
58 unsigned long *frames;
59 @@ -998,6 +1014,7 @@ static const struct pv_cpu_ops xen_cpu_ops __initdata = {
60
61 .load_tr_desc = paravirt_nop,
62 .set_ldt = xen_set_ldt,
63 + .load_user_cs_desc = xen_load_user_cs_desc,
64 .load_gdt = xen_load_gdt,
65 .load_idt = xen_load_idt,
66 .load_tls = xen_load_tls,
67 diff --git a/include/asm-x86/desc.h b/include/asm-x86/desc.h
68 index 7ad80b9..ec3a84a 100644
69 --- a/include/asm-x86/desc.h
70 +++ b/include/asm-x86/desc.h
71 @@ -6,6 +6,7 @@
72 #include <asm/ldt.h>
73 #include <asm/mmu.h>
74 #include <linux/smp.h>
75 +#include <linux/mm_types.h>
76
77 static inline void fill_ldt(struct desc_struct *desc,
78 const struct user_desc *info)
79 @@ -94,6 +95,7 @@ static inline int desc_empty(const void *ptr)
80
81 #define load_TLS(t, cpu) native_load_tls(t, cpu)
82 #define set_ldt native_set_ldt
83 +#define load_user_cs_desc native_load_user_cs_desc
84
85 #define write_ldt_entry(dt, entry, desc) \
86 native_write_ldt_entry(dt, entry, desc)
87 @@ -360,8 +362,10 @@ static inline void set_user_cs(struct desc_struct *desc, unsigned long limit)
88 desc->b = (limit & 0xf0000) | 0x00c0fb00;
89 }
90
91 -#define load_user_cs_desc(cpu, mm) \
92 - get_cpu_gdt_table(cpu)[GDT_ENTRY_DEFAULT_USER_CS] = (mm)->context.user_cs
93 +static inline void native_load_user_cs_desc(int cpu, struct mm_struct *mm)
94 +{
95 + get_cpu_gdt_table(cpu)[GDT_ENTRY_DEFAULT_USER_CS] = mm->context.user_cs;
96 +}
97
98 #ifdef CONFIG_X86_32
99 extern void arch_add_exec_range(struct mm_struct *mm, unsigned long limit);
100 diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
101 index d6236eb..ff8d218 100644
102 --- a/include/asm-x86/paravirt.h
103 +++ b/include/asm-x86/paravirt.h
104 @@ -113,6 +113,7 @@ struct pv_cpu_ops {
105 void (*store_gdt)(struct desc_ptr *);
106 void (*store_idt)(struct desc_ptr *);
107 void (*set_ldt)(const void *desc, unsigned entries);
108 + void (*load_user_cs_desc)(int cpu, struct mm_struct *mm);
109 unsigned long (*store_tr)(void);
110 void (*load_tls)(struct thread_struct *t, unsigned int cpu);
111 void (*write_ldt_entry)(struct desc_struct *ldt, int entrynum,
112 @@ -754,6 +755,11 @@ static inline void set_ldt(const void *addr, unsigned entries)
113 {
114 PVOP_VCALL2(pv_cpu_ops.set_ldt, addr, entries);
115 }
116 +static inline void load_user_cs_desc(unsigned int cpu,
117 + struct mm_struct *mm)
118 +{
119 + PVOP_VCALL2(pv_cpu_ops.load_user_cs_desc, cpu, mm);
120 +}
121 static inline void store_gdt(struct desc_ptr *dtr)
122 {
123 PVOP_VCALL1(pv_cpu_ops.store_gdt, dtr);
124 --
125 1.5.4.1
126