aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/um/include/asm/mmu.h4
-rw-r--r--arch/um/include/shared/ldt.h37
-rw-r--r--arch/x86/um/asm/mm_context.h (renamed from arch/x86/um/shared/sysdep/host_ldt.h)39
-rw-r--r--arch/x86/um/asm/processor_32.h2
-rw-r--r--arch/x86/um/ldt.c36
-rw-r--r--arch/x86/um/shared/sysdep/tls.h1
6 files changed, 58 insertions, 61 deletions
diff --git a/arch/um/include/asm/mmu.h b/arch/um/include/asm/mmu.h
index b1a7e47d1027..30509b9f37fd 100644
--- a/arch/um/include/asm/mmu.h
+++ b/arch/um/include/asm/mmu.h
@@ -7,11 +7,11 @@
7#define __ARCH_UM_MMU_H 7#define __ARCH_UM_MMU_H
8 8
9#include "mm_id.h" 9#include "mm_id.h"
10#include "ldt.h" 10#include <asm/mm_context.h>
11 11
12typedef struct mm_context { 12typedef struct mm_context {
13 struct mm_id id; 13 struct mm_id id;
14 struct uml_ldt ldt; 14 struct uml_arch_mm_context arch;
15 struct page **stub_pages; 15 struct page **stub_pages;
16} mm_context_t; 16} mm_context_t;
17 17
diff --git a/arch/um/include/shared/ldt.h b/arch/um/include/shared/ldt.h
deleted file mode 100644
index a7f999a58774..000000000000
--- a/arch/um/include/shared/ldt.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * Copyright (C) 2004 Fujitsu Siemens Computers GmbH
3 * Licensed under the GPL
4 *
5 * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
6 */
7
8#ifndef __ASM_LDT_H
9#define __ASM_LDT_H
10
11#include <linux/mutex.h>
12#include <sysdep/host_ldt.h>
13
14extern void ldt_host_info(void);
15
16#define LDT_PAGES_MAX \
17 ((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE)
18#define LDT_ENTRIES_PER_PAGE \
19 (PAGE_SIZE/LDT_ENTRY_SIZE)
20#define LDT_DIRECT_ENTRIES \
21 ((LDT_PAGES_MAX*sizeof(void *))/LDT_ENTRY_SIZE)
22
23struct ldt_entry {
24 __u32 a;
25 __u32 b;
26};
27
28typedef struct uml_ldt {
29 int entry_count;
30 struct mutex lock;
31 union {
32 struct ldt_entry * pages[LDT_PAGES_MAX];
33 struct ldt_entry entries[LDT_DIRECT_ENTRIES];
34 } u;
35} uml_ldt_t;
36
37#endif
diff --git a/arch/x86/um/shared/sysdep/host_ldt.h b/arch/x86/um/asm/mm_context.h
index 246ff7ace5e5..4a73d63e4760 100644
--- a/arch/x86/um/shared/sysdep/host_ldt.h
+++ b/arch/x86/um/asm/mm_context.h
@@ -1,8 +1,39 @@
1#ifndef __ASM_HOST_LDT_H 1/*
2#define __ASM_HOST_LDT_H 2 * Copyright (C) 2004 Fujitsu Siemens Computers GmbH
3 * Licensed under the GPL
4 *
5 * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
6 */
3 7
8#ifndef __ASM_LDT_H
9#define __ASM_LDT_H
10
11#include <linux/mutex.h>
4#include <asm/ldt.h> 12#include <asm/ldt.h>
5 13
14extern void ldt_host_info(void);
15
16#define LDT_PAGES_MAX \
17 ((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE)
18#define LDT_ENTRIES_PER_PAGE \
19 (PAGE_SIZE/LDT_ENTRY_SIZE)
20#define LDT_DIRECT_ENTRIES \
21 ((LDT_PAGES_MAX*sizeof(void *))/LDT_ENTRY_SIZE)
22
23struct ldt_entry {
24 __u32 a;
25 __u32 b;
26};
27
28typedef struct uml_ldt {
29 int entry_count;
30 struct mutex lock;
31 union {
32 struct ldt_entry * pages[LDT_PAGES_MAX];
33 struct ldt_entry entries[LDT_DIRECT_ENTRIES];
34 } u;
35} uml_ldt_t;
36
6#define LDT_entry_a(info) \ 37#define LDT_entry_a(info) \
7 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) 38 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
8 39
@@ -34,4 +65,8 @@
34#define LDT_empty(info) (_LDT_empty(info)) 65#define LDT_empty(info) (_LDT_empty(info))
35#endif 66#endif
36 67
68struct uml_arch_mm_context {
69 uml_ldt_t ldt;
70};
71
37#endif 72#endif
diff --git a/arch/x86/um/asm/processor_32.h b/arch/x86/um/asm/processor_32.h
index e5b72faea0f6..c4078b581df1 100644
--- a/arch/x86/um/asm/processor_32.h
+++ b/arch/x86/um/asm/processor_32.h
@@ -7,8 +7,8 @@
7#define __UM_PROCESSOR_I386_H 7#define __UM_PROCESSOR_I386_H
8 8
9#include <linux/string.h> 9#include <linux/string.h>
10#include <sysdep/host_ldt.h>
11#include <asm/segment.h> 10#include <asm/segment.h>
11#include <asm/ldt.h>
12 12
13extern int host_has_cmov; 13extern int host_has_cmov;
14 14
diff --git a/arch/x86/um/ldt.c b/arch/x86/um/ldt.c
index 3f2bf208d884..26b0e39d2ce9 100644
--- a/arch/x86/um/ldt.c
+++ b/arch/x86/um/ldt.c
@@ -137,7 +137,7 @@ static int read_ldt(void __user * ptr, unsigned long bytecount)
137{ 137{
138 int i, err = 0; 138 int i, err = 0;
139 unsigned long size; 139 unsigned long size;
140 uml_ldt_t * ldt = &current->mm->context.ldt; 140 uml_ldt_t *ldt = &current->mm->context.arch.ldt;
141 141
142 if (!ldt->entry_count) 142 if (!ldt->entry_count)
143 goto out; 143 goto out;
@@ -205,7 +205,7 @@ static int read_default_ldt(void __user * ptr, unsigned long bytecount)
205 205
206static int write_ldt(void __user * ptr, unsigned long bytecount, int func) 206static int write_ldt(void __user * ptr, unsigned long bytecount, int func)
207{ 207{
208 uml_ldt_t * ldt = &current->mm->context.ldt; 208 uml_ldt_t *ldt = &current->mm->context.arch.ldt;
209 struct mm_id * mm_idp = &current->mm->context.id; 209 struct mm_id * mm_idp = &current->mm->context.id;
210 int i, err; 210 int i, err;
211 struct user_desc ldt_info; 211 struct user_desc ldt_info;
@@ -397,7 +397,7 @@ long init_new_ldt(struct mm_context *new_mm, struct mm_context *from_mm)
397 397
398 398
399 if (!ptrace_ldt) 399 if (!ptrace_ldt)
400 mutex_init(&new_mm->ldt.lock); 400 mutex_init(&new_mm->arch.ldt.lock);
401 401
402 if (!from_mm) { 402 if (!from_mm) {
403 memset(&desc, 0, sizeof(desc)); 403 memset(&desc, 0, sizeof(desc));
@@ -429,7 +429,7 @@ long init_new_ldt(struct mm_context *new_mm, struct mm_context *from_mm)
429 break; 429 break;
430 } 430 }
431 } 431 }
432 new_mm->ldt.entry_count = 0; 432 new_mm->arch.ldt.entry_count = 0;
433 433
434 goto out; 434 goto out;
435 } 435 }
@@ -457,26 +457,26 @@ long init_new_ldt(struct mm_context *new_mm, struct mm_context *from_mm)
457 * i.e., we have to use the stub for modify_ldt, which 457 * i.e., we have to use the stub for modify_ldt, which
458 * can't handle the big read buffer of up to 64kB. 458 * can't handle the big read buffer of up to 64kB.
459 */ 459 */
460 mutex_lock(&from_mm->ldt.lock); 460 mutex_lock(&from_mm->arch.ldt.lock);
461 if (from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES) 461 if (from_mm->arch.ldt.entry_count <= LDT_DIRECT_ENTRIES)
462 memcpy(new_mm->ldt.u.entries, from_mm->ldt.u.entries, 462 memcpy(new_mm->arch.ldt.u.entries, from_mm->arch.ldt.u.entries,
463 sizeof(new_mm->ldt.u.entries)); 463 sizeof(new_mm->arch.ldt.u.entries));
464 else { 464 else {
465 i = from_mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; 465 i = from_mm->arch.ldt.entry_count / LDT_ENTRIES_PER_PAGE;
466 while (i-->0) { 466 while (i-->0) {
467 page = __get_free_page(GFP_KERNEL|__GFP_ZERO); 467 page = __get_free_page(GFP_KERNEL|__GFP_ZERO);
468 if (!page) { 468 if (!page) {
469 err = -ENOMEM; 469 err = -ENOMEM;
470 break; 470 break;
471 } 471 }
472 new_mm->ldt.u.pages[i] = 472 new_mm->arch.ldt.u.pages[i] =
473 (struct ldt_entry *) page; 473 (struct ldt_entry *) page;
474 memcpy(new_mm->ldt.u.pages[i], 474 memcpy(new_mm->arch.ldt.u.pages[i],
475 from_mm->ldt.u.pages[i], PAGE_SIZE); 475 from_mm->arch.ldt.u.pages[i], PAGE_SIZE);
476 } 476 }
477 } 477 }
478 new_mm->ldt.entry_count = from_mm->ldt.entry_count; 478 new_mm->arch.ldt.entry_count = from_mm->arch.ldt.entry_count;
479 mutex_unlock(&from_mm->ldt.lock); 479 mutex_unlock(&from_mm->arch.ldt.lock);
480 } 480 }
481 481
482 out: 482 out:
@@ -488,12 +488,12 @@ void free_ldt(struct mm_context *mm)
488{ 488{
489 int i; 489 int i;
490 490
491 if (!ptrace_ldt && mm->ldt.entry_count > LDT_DIRECT_ENTRIES) { 491 if (!ptrace_ldt && mm->arch.ldt.entry_count > LDT_DIRECT_ENTRIES) {
492 i = mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; 492 i = mm->arch.ldt.entry_count / LDT_ENTRIES_PER_PAGE;
493 while (i-- > 0) 493 while (i-- > 0)
494 free_page((long) mm->ldt.u.pages[i]); 494 free_page((long) mm->arch.ldt.u.pages[i]);
495 } 495 }
496 mm->ldt.entry_count = 0; 496 mm->arch.ldt.entry_count = 0;
497} 497}
498 498
499int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount) 499int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
diff --git a/arch/x86/um/shared/sysdep/tls.h b/arch/x86/um/shared/sysdep/tls.h
index f2f30bd67b9b..27cce00c6b30 100644
--- a/arch/x86/um/shared/sysdep/tls.h
+++ b/arch/x86/um/shared/sysdep/tls.h
@@ -24,7 +24,6 @@ typedef struct um_dup_user_desc {
24 24
25# else /* __KERNEL__ */ 25# else /* __KERNEL__ */
26 26
27# include <ldt.h>
28typedef struct user_desc user_desc_t; 27typedef struct user_desc user_desc_t;
29 28
30# endif /* __KERNEL__ */ 29# endif /* __KERNEL__ */