xref: /openbmc/linux/arch/x86/um/asm/mm_context.h (revision ded1ffea)
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 <asm/ldt.h>
13 
14 #define LDT_PAGES_MAX \
15 	((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE)
16 #define LDT_ENTRIES_PER_PAGE \
17 	(PAGE_SIZE/LDT_ENTRY_SIZE)
18 #define LDT_DIRECT_ENTRIES \
19 	((LDT_PAGES_MAX*sizeof(void *))/LDT_ENTRY_SIZE)
20 
21 struct ldt_entry {
22 	__u32 a;
23 	__u32 b;
24 };
25 
26 typedef struct uml_ldt {
27 	int entry_count;
28 	struct mutex lock;
29 	union {
30 		struct ldt_entry * pages[LDT_PAGES_MAX];
31 		struct ldt_entry entries[LDT_DIRECT_ENTRIES];
32 	} u;
33 } uml_ldt_t;
34 
35 #define LDT_entry_a(info) \
36 	((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
37 
38 #define LDT_entry_b(info) \
39 	(((info)->base_addr & 0xff000000) | \
40 	(((info)->base_addr & 0x00ff0000) >> 16) | \
41 	((info)->limit & 0xf0000) | \
42 	(((info)->read_exec_only ^ 1) << 9) | \
43 	((info)->contents << 10) | \
44 	(((info)->seg_not_present ^ 1) << 15) | \
45 	((info)->seg_32bit << 22) | \
46 	((info)->limit_in_pages << 23) | \
47 	((info)->useable << 20) | \
48 	0x7000)
49 
50 #define _LDT_empty(info) (\
51 	(info)->base_addr	== 0	&& \
52 	(info)->limit		== 0	&& \
53 	(info)->contents	== 0	&& \
54 	(info)->read_exec_only	== 1	&& \
55 	(info)->seg_32bit	== 0	&& \
56 	(info)->limit_in_pages	== 0	&& \
57 	(info)->seg_not_present	== 1	&& \
58 	(info)->useable		== 0	)
59 
60 #ifdef CONFIG_X86_64
61 #define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0))
62 #else
63 #define LDT_empty(info) (_LDT_empty(info))
64 #endif
65 
66 struct uml_arch_mm_context {
67 	uml_ldt_t ldt;
68 };
69 
70 #endif
71