| Bodo Stroesser | 858259c | 2005-11-07 00:58:55 -0800 | [diff] [blame] | 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 |  | 
| Paolo 'Blaisorblade' Giarrusso | 0c19585 | 2006-02-01 03:06:24 -0800 | [diff] [blame] | 8 | #ifndef __ASM_LDT_X86_64_H | 
 | 9 | #define __ASM_LDT_X86_64_H | 
| Bodo Stroesser | 858259c | 2005-11-07 00:58:55 -0800 | [diff] [blame] | 10 |  | 
 | 11 | #include "asm/semaphore.h" | 
 | 12 | #include "asm/arch/ldt.h" | 
 | 13 |  | 
 | 14 | struct mmu_context_skas; | 
 | 15 | extern void ldt_host_info(void); | 
 | 16 | extern long init_new_ldt(struct mmu_context_skas * to_mm, | 
 | 17 | 			 struct mmu_context_skas * from_mm); | 
 | 18 | extern void free_ldt(struct mmu_context_skas * mm); | 
 | 19 |  | 
 | 20 | #define LDT_PAGES_MAX \ | 
 | 21 | 	((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE) | 
 | 22 | #define LDT_ENTRIES_PER_PAGE \ | 
 | 23 | 	(PAGE_SIZE/LDT_ENTRY_SIZE) | 
 | 24 | #define LDT_DIRECT_ENTRIES \ | 
 | 25 | 	((LDT_PAGES_MAX*sizeof(void *))/LDT_ENTRY_SIZE) | 
 | 26 |  | 
 | 27 | struct ldt_entry { | 
 | 28 | 	__u32 a; | 
 | 29 | 	__u32 b; | 
 | 30 | }; | 
 | 31 |  | 
 | 32 | typedef struct uml_ldt { | 
 | 33 | 	int entry_count; | 
 | 34 | 	struct semaphore semaphore; | 
 | 35 | 	union { | 
 | 36 | 		struct ldt_entry * pages[LDT_PAGES_MAX]; | 
 | 37 | 		struct ldt_entry entries[LDT_DIRECT_ENTRIES]; | 
| Jeff Dike | e23181d | 2005-11-21 21:32:08 -0800 | [diff] [blame] | 38 | 	} u; | 
| Bodo Stroesser | 858259c | 2005-11-07 00:58:55 -0800 | [diff] [blame] | 39 | } uml_ldt_t; | 
 | 40 |  | 
 | 41 | /* | 
| Paolo 'Blaisorblade' Giarrusso | 4cd7ed9 | 2006-02-01 03:06:28 -0800 | [diff] [blame] | 42 |  * macros stolen from include/asm-x86_64/desc.h | 
| Bodo Stroesser | 858259c | 2005-11-07 00:58:55 -0800 | [diff] [blame] | 43 |  */ | 
 | 44 | #define LDT_entry_a(info) \ | 
 | 45 | 	((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) | 
 | 46 |  | 
| Paolo 'Blaisorblade' Giarrusso | 4cd7ed9 | 2006-02-01 03:06:28 -0800 | [diff] [blame] | 47 | /* Don't allow setting of the lm bit. It is useless anyways because | 
 | 48 |  * 64bit system calls require __USER_CS. */ | 
| Bodo Stroesser | 858259c | 2005-11-07 00:58:55 -0800 | [diff] [blame] | 49 | #define LDT_entry_b(info) \ | 
 | 50 | 	(((info)->base_addr & 0xff000000) | \ | 
 | 51 | 	(((info)->base_addr & 0x00ff0000) >> 16) | \ | 
 | 52 | 	((info)->limit & 0xf0000) | \ | 
 | 53 | 	(((info)->read_exec_only ^ 1) << 9) | \ | 
 | 54 | 	((info)->contents << 10) | \ | 
 | 55 | 	(((info)->seg_not_present ^ 1) << 15) | \ | 
 | 56 | 	((info)->seg_32bit << 22) | \ | 
 | 57 | 	((info)->limit_in_pages << 23) | \ | 
 | 58 | 	((info)->useable << 20) | \ | 
| Paolo 'Blaisorblade' Giarrusso | 4cd7ed9 | 2006-02-01 03:06:28 -0800 | [diff] [blame] | 59 | 	/* ((info)->lm << 21) | */ \ | 
| Bodo Stroesser | 858259c | 2005-11-07 00:58:55 -0800 | [diff] [blame] | 60 | 	0x7000) | 
 | 61 |  | 
 | 62 | #define LDT_empty(info) (\ | 
 | 63 | 	(info)->base_addr	== 0	&& \ | 
 | 64 | 	(info)->limit		== 0	&& \ | 
 | 65 | 	(info)->contents	== 0	&& \ | 
 | 66 | 	(info)->read_exec_only	== 1	&& \ | 
 | 67 | 	(info)->seg_32bit	== 0	&& \ | 
 | 68 | 	(info)->limit_in_pages	== 0	&& \ | 
 | 69 | 	(info)->seg_not_present	== 1	&& \ | 
| Paolo 'Blaisorblade' Giarrusso | 4cd7ed9 | 2006-02-01 03:06:28 -0800 | [diff] [blame] | 70 | 	(info)->useable		== 0	&& \ | 
 | 71 | 	(info)->lm              == 0) | 
| Bodo Stroesser | 858259c | 2005-11-07 00:58:55 -0800 | [diff] [blame] | 72 |  | 
 | 73 | #endif |