[PATCH] uml: eliminate anonymous union and clean up symlink lossage

This gives a name to the anonymous union introduced in skas-hold-own-ldt,
allowing to build on a wider range of gccs.

It also removes ldt.h, which somehow became real, and replaces it with a
symlink, and creates ldt-x86_64.h as a copy of ldt-i386.h for now.

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Jeff Dike and committed by Linus Torvalds e23181de 39d730ab

+22 -24
+1 -1
arch/um/Makefile
··· 17 18 # Have to precede the include because the included Makefiles reference them. 19 SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \ 20 - module.h vm-flags.h elf.h 21 SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header)) 22 23 # XXX: The "os" symlink is only used by arch/um/include/os.h, which includes
··· 17 18 # Have to precede the include because the included Makefiles reference them. 19 SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \ 20 + module.h vm-flags.h elf.h ldt.h 21 SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header)) 22 23 # XXX: The "os" symlink is only used by arch/um/include/os.h, which includes
+19 -16
arch/um/sys-i386/ldt.c
··· 228 size = LDT_ENTRY_SIZE*LDT_DIRECT_ENTRIES; 229 if(size > bytecount) 230 size = bytecount; 231 - if(copy_to_user(ptr, ldt->entries, size)) 232 err = -EFAULT; 233 bytecount -= size; 234 ptr += size; ··· 239 size = PAGE_SIZE; 240 if(size > bytecount) 241 size = bytecount; 242 - if(copy_to_user(ptr, ldt->pages[i], size)){ 243 err = -EFAULT; 244 break; 245 } ··· 321 i*LDT_ENTRIES_PER_PAGE <= ldt_info.entry_number; 322 i++){ 323 if(i == 0) 324 - memcpy(&entry0, ldt->entries, sizeof(entry0)); 325 - ldt->pages[i] = (struct ldt_entry *) 326 - __get_free_page(GFP_KERNEL|__GFP_ZERO); 327 - if(!ldt->pages[i]){ 328 err = -ENOMEM; 329 /* Undo the change in host */ 330 memset(&ldt_info, 0, sizeof(ldt_info)); ··· 333 goto out_unlock; 334 } 335 if(i == 0) { 336 - memcpy(ldt->pages[0], &entry0, sizeof(entry0)); 337 - memcpy(ldt->pages[0]+1, ldt->entries+1, 338 sizeof(entry0)*(LDT_DIRECT_ENTRIES-1)); 339 } 340 ldt->entry_count = (i + 1) * LDT_ENTRIES_PER_PAGE; ··· 345 ldt->entry_count = ldt_info.entry_number + 1; 346 347 if(ldt->entry_count <= LDT_DIRECT_ENTRIES) 348 - ldt_p = ldt->entries + ldt_info.entry_number; 349 else 350 - ldt_p = ldt->pages[ldt_info.entry_number/LDT_ENTRIES_PER_PAGE] + 351 ldt_info.entry_number%LDT_ENTRIES_PER_PAGE; 352 353 if(ldt_info.base_addr == 0 && ldt_info.limit == 0 && ··· 503 */ 504 down(&from_mm->ldt.semaphore); 505 if(from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES){ 506 - memcpy(new_mm->ldt.entries, from_mm->ldt.entries, 507 - sizeof(new_mm->ldt.entries)); 508 } 509 else{ 510 i = from_mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; ··· 514 err = -ENOMEM; 515 break; 516 } 517 - new_mm->ldt.pages[i] = (struct ldt_entry*)page; 518 - memcpy(new_mm->ldt.pages[i], 519 - from_mm->ldt.pages[i], PAGE_SIZE); 520 } 521 } 522 new_mm->ldt.entry_count = from_mm->ldt.entry_count; ··· 535 if(!ptrace_ldt && mm->ldt.entry_count > LDT_DIRECT_ENTRIES){ 536 i = mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; 537 while(i-- > 0){ 538 - free_page((long )mm->ldt.pages[i]); 539 } 540 } 541 mm->ldt.entry_count = 0;
··· 228 size = LDT_ENTRY_SIZE*LDT_DIRECT_ENTRIES; 229 if(size > bytecount) 230 size = bytecount; 231 + if(copy_to_user(ptr, ldt->u.entries, size)) 232 err = -EFAULT; 233 bytecount -= size; 234 ptr += size; ··· 239 size = PAGE_SIZE; 240 if(size > bytecount) 241 size = bytecount; 242 + if(copy_to_user(ptr, ldt->u.pages[i], size)){ 243 err = -EFAULT; 244 break; 245 } ··· 321 i*LDT_ENTRIES_PER_PAGE <= ldt_info.entry_number; 322 i++){ 323 if(i == 0) 324 + memcpy(&entry0, ldt->u.entries, 325 + sizeof(entry0)); 326 + ldt->u.pages[i] = (struct ldt_entry *) 327 + __get_free_page(GFP_KERNEL|__GFP_ZERO); 328 + if(!ldt->u.pages[i]){ 329 err = -ENOMEM; 330 /* Undo the change in host */ 331 memset(&ldt_info, 0, sizeof(ldt_info)); ··· 332 goto out_unlock; 333 } 334 if(i == 0) { 335 + memcpy(ldt->u.pages[0], &entry0, 336 + sizeof(entry0)); 337 + memcpy(ldt->u.pages[0]+1, ldt->u.entries+1, 338 sizeof(entry0)*(LDT_DIRECT_ENTRIES-1)); 339 } 340 ldt->entry_count = (i + 1) * LDT_ENTRIES_PER_PAGE; ··· 343 ldt->entry_count = ldt_info.entry_number + 1; 344 345 if(ldt->entry_count <= LDT_DIRECT_ENTRIES) 346 + ldt_p = ldt->u.entries + ldt_info.entry_number; 347 else 348 + ldt_p = ldt->u.pages[ldt_info.entry_number/LDT_ENTRIES_PER_PAGE] + 349 ldt_info.entry_number%LDT_ENTRIES_PER_PAGE; 350 351 if(ldt_info.base_addr == 0 && ldt_info.limit == 0 && ··· 501 */ 502 down(&from_mm->ldt.semaphore); 503 if(from_mm->ldt.entry_count <= LDT_DIRECT_ENTRIES){ 504 + memcpy(new_mm->ldt.u.entries, from_mm->ldt.u.entries, 505 + sizeof(new_mm->ldt.u.entries)); 506 } 507 else{ 508 i = from_mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; ··· 512 err = -ENOMEM; 513 break; 514 } 515 + new_mm->ldt.u.pages[i] = 516 + (struct ldt_entry *) page; 517 + memcpy(new_mm->ldt.u.pages[i], 518 + from_mm->ldt.u.pages[i], PAGE_SIZE); 519 } 520 } 521 new_mm->ldt.entry_count = from_mm->ldt.entry_count; ··· 532 if(!ptrace_ldt && mm->ldt.entry_count > LDT_DIRECT_ENTRIES){ 533 i = mm->ldt.entry_count / LDT_ENTRIES_PER_PAGE; 534 while(i-- > 0){ 535 + free_page((long )mm->ldt.u.pages[i]); 536 } 537 } 538 mm->ldt.entry_count = 0;
+1 -1
include/asm-um/ldt-i386.h
··· 35 union { 36 struct ldt_entry * pages[LDT_PAGES_MAX]; 37 struct ldt_entry entries[LDT_DIRECT_ENTRIES]; 38 - }; 39 } uml_ldt_t; 40 41 /*
··· 35 union { 36 struct ldt_entry * pages[LDT_PAGES_MAX]; 37 struct ldt_entry entries[LDT_DIRECT_ENTRIES]; 38 + } u; 39 } uml_ldt_t; 40 41 /*
+1 -6
include/asm-um/ldt.h include/asm-um/ldt-x86_64.h
··· 35 union { 36 struct ldt_entry * pages[LDT_PAGES_MAX]; 37 struct ldt_entry entries[LDT_DIRECT_ENTRIES]; 38 - }; 39 } uml_ldt_t; 40 41 /* ··· 66 (info)->seg_not_present == 1 && \ 67 (info)->useable == 0 ) 68 69 - #endif 70 - #ifndef __UM_LDT_H 71 - #define __UM_LDT_H 72 - 73 - #include "asm/arch/ldt.h" 74 #endif
··· 35 union { 36 struct ldt_entry * pages[LDT_PAGES_MAX]; 37 struct ldt_entry entries[LDT_DIRECT_ENTRIES]; 38 + } u; 39 } uml_ldt_t; 40 41 /* ··· 66 (info)->seg_not_present == 1 && \ 67 (info)->useable == 0 ) 68 69 #endif