Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

um: take ldt.h to arch/x86/um/asm/mm_context.h

it's x86-only and we have no business playing with it in asm/mmu.h; make
the latter have
struct uml_arch_mm_context arch;
instead of
struct uml_ldt ldt;
and let arch/<subarch>/um/asm/mm_context.h decide what'll be in there.
While we are at it, kill host_ldt.h - it's not needed in part of places
that include it (we want asm/ldt.h in those) and it can be trivially
expanded into the single remaining one.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Al Viro and committed by
Richard Weinberger
b3ee571e f67aa2ff

+58 -61
+2 -2
arch/um/include/asm/mmu.h
··· 7 7 #define __ARCH_UM_MMU_H 8 8 9 9 #include "mm_id.h" 10 - #include "ldt.h" 10 + #include <asm/mm_context.h> 11 11 12 12 typedef struct mm_context { 13 13 struct mm_id id; 14 - struct uml_ldt ldt; 14 + struct uml_arch_mm_context arch; 15 15 struct page **stub_pages; 16 16 } mm_context_t; 17 17
-37
arch/um/include/shared/ldt.h
··· 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 - 14 - extern 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 - 23 - struct ldt_entry { 24 - __u32 a; 25 - __u32 b; 26 - }; 27 - 28 - typedef 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
+1 -1
arch/x86/um/asm/processor_32.h
··· 7 7 #define __UM_PROCESSOR_I386_H 8 8 9 9 #include <linux/string.h> 10 - #include <sysdep/host_ldt.h> 11 10 #include <asm/segment.h> 11 + #include <asm/ldt.h> 12 12 13 13 extern int host_has_cmov; 14 14
+18 -18
arch/x86/um/ldt.c
··· 137 137 { 138 138 int i, err = 0; 139 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 142 if (!ldt->entry_count) 143 143 goto out; ··· 205 205 206 206 static 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 209 struct mm_id * mm_idp = &current->mm->context.id; 210 210 int i, err; 211 211 struct user_desc ldt_info; ··· 397 397 398 398 399 399 if (!ptrace_ldt) 400 - mutex_init(&new_mm->ldt.lock); 400 + mutex_init(&new_mm->arch.ldt.lock); 401 401 402 402 if (!from_mm) { 403 403 memset(&desc, 0, sizeof(desc)); ··· 429 429 break; 430 430 } 431 431 } 432 - new_mm->ldt.entry_count = 0; 432 + new_mm->arch.ldt.entry_count = 0; 433 433 434 434 goto out; 435 435 } ··· 457 457 * i.e., we have to use the stub for modify_ldt, which 458 458 * can't handle the big read buffer of up to 64kB. 459 459 */ 460 - mutex_lock(&from_mm->ldt.lock); 461 - if (from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES) 462 - memcpy(new_mm->ldt.u.entries, from_mm->ldt.u.entries, 463 - sizeof(new_mm->ldt.u.entries)); 460 + mutex_lock(&from_mm->arch.ldt.lock); 461 + if (from_mm->arch.ldt.entry_count <= LDT_DIRECT_ENTRIES) 462 + memcpy(new_mm->arch.ldt.u.entries, from_mm->arch.ldt.u.entries, 463 + sizeof(new_mm->arch.ldt.u.entries)); 464 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 466 while (i-->0) { 467 467 page = __get_free_page(GFP_KERNEL|__GFP_ZERO); 468 468 if (!page) { 469 469 err = -ENOMEM; 470 470 break; 471 471 } 472 - new_mm->ldt.u.pages[i] = 472 + new_mm->arch.ldt.u.pages[i] = 473 473 (struct ldt_entry *) page; 474 - memcpy(new_mm->ldt.u.pages[i], 475 - from_mm->ldt.u.pages[i], PAGE_SIZE); 474 + memcpy(new_mm->arch.ldt.u.pages[i], 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; 479 - mutex_unlock(&from_mm->ldt.lock); 478 + new_mm->arch.ldt.entry_count = from_mm->arch.ldt.entry_count; 479 + mutex_unlock(&from_mm->arch.ldt.lock); 480 480 } 481 481 482 482 out: ··· 488 488 { 489 489 int i; 490 490 491 - if (!ptrace_ldt && mm->ldt.entry_count > LDT_DIRECT_ENTRIES) { 492 - i = mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; 491 + if (!ptrace_ldt && mm->arch.ldt.entry_count > LDT_DIRECT_ENTRIES) { 492 + i = mm->arch.ldt.entry_count / LDT_ENTRIES_PER_PAGE; 493 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 499 499 int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
+37 -2
arch/x86/um/shared/sysdep/host_ldt.h arch/x86/um/asm/mm_context.h
··· 1 - #ifndef __ASM_HOST_LDT_H 2 - #define __ASM_HOST_LDT_H 1 + /* 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 12 #include <asm/ldt.h> 13 + 14 + extern 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 + 23 + struct ldt_entry { 24 + __u32 a; 25 + __u32 b; 26 + }; 27 + 28 + typedef 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; 5 36 6 37 #define LDT_entry_a(info) \ 7 38 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) ··· 64 33 #else 65 34 #define LDT_empty(info) (_LDT_empty(info)) 66 35 #endif 36 + 37 + struct uml_arch_mm_context { 38 + uml_ldt_t ldt; 39 + }; 67 40 68 41 #endif
-1
arch/x86/um/shared/sysdep/tls.h
··· 24 24 25 25 # else /* __KERNEL__ */ 26 26 27 - # include <ldt.h> 28 27 typedef struct user_desc user_desc_t; 29 28 30 29 # endif /* __KERNEL__ */