mm_context.h 1.6 KB

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