Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | |
| 3 | #if defined I386 || defined X86_64 || defined X32 |
| 4 | |
| 5 | # include <asm/ldt.h> |
| 6 | |
| 7 | void |
Dmitry V. Levin | 79a4594 | 2015-07-20 00:10:35 +0000 | [diff] [blame] | 8 | print_user_desc(struct tcb *tcp, const long addr) |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 9 | { |
| 10 | struct user_desc desc; |
| 11 | |
Dmitry V. Levin | 79a4594 | 2015-07-20 00:10:35 +0000 | [diff] [blame] | 12 | if (umove_or_printaddr(tcp, addr, &desc)) |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 13 | return; |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 14 | |
| 15 | tprintf("{entry_number:%d, " |
| 16 | "base_addr:%#08x, " |
| 17 | "limit:%d, " |
| 18 | "seg_32bit:%d, " |
| 19 | "contents:%d, " |
| 20 | "read_exec_only:%d, " |
| 21 | "limit_in_pages:%d, " |
| 22 | "seg_not_present:%d, " |
| 23 | "useable:%d}", |
| 24 | desc.entry_number, |
| 25 | desc.base_addr, |
| 26 | desc.limit, |
| 27 | desc.seg_32bit, |
| 28 | desc.contents, |
| 29 | desc.read_exec_only, |
| 30 | desc.limit_in_pages, |
| 31 | desc.seg_not_present, |
| 32 | desc.useable); |
| 33 | } |
| 34 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 35 | SYS_FUNC(modify_ldt) |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 36 | { |
Dmitry V. Levin | 583526e | 2015-07-20 00:19:09 +0000 | [diff] [blame] | 37 | tprintf("%ld, ", tcp->u_arg[0]); |
| 38 | if (tcp->u_arg[2] != sizeof(struct user_desc)) |
| 39 | printaddr(tcp->u_arg[1]); |
| 40 | else |
| 41 | print_user_desc(tcp, tcp->u_arg[1]); |
| 42 | tprintf(", %lu", tcp->u_arg[2]); |
| 43 | |
| 44 | return RVAL_DECODED; |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 47 | SYS_FUNC(set_thread_area) |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 48 | { |
| 49 | if (entering(tcp)) { |
| 50 | print_user_desc(tcp, tcp->u_arg[0]); |
| 51 | } else { |
| 52 | struct user_desc desc; |
| 53 | |
Dmitry V. Levin | 79a4594 | 2015-07-20 00:10:35 +0000 | [diff] [blame] | 54 | if (!verbose(tcp) || syserror(tcp) || |
| 55 | umove(tcp, tcp->u_arg[0], &desc) < 0) { |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 56 | /* returned entry_number is not available */ |
| 57 | } else { |
| 58 | static char outstr[32]; |
| 59 | |
| 60 | sprintf(outstr, "entry_number:%d", desc.entry_number); |
| 61 | tcp->auxstr = outstr; |
| 62 | return RVAL_STR; |
| 63 | } |
| 64 | } |
| 65 | return 0; |
| 66 | } |
| 67 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 68 | SYS_FUNC(get_thread_area) |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 69 | { |
Dmitry V. Levin | 79a4594 | 2015-07-20 00:10:35 +0000 | [diff] [blame] | 70 | if (exiting(tcp)) |
| 71 | print_user_desc(tcp, tcp->u_arg[0]); |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | #endif /* I386 || X86_64 || X32 */ |
| 76 | |
| 77 | #if defined(M68K) || defined(MIPS) |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 78 | SYS_FUNC(set_thread_area) |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 79 | { |
Dmitry V. Levin | 583526e | 2015-07-20 00:19:09 +0000 | [diff] [blame] | 80 | printaddr(tcp->u_arg[0]); |
| 81 | |
| 82 | return RVAL_DECODED; |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 83 | |
| 84 | } |
| 85 | #endif |
| 86 | |
| 87 | #if defined(M68K) |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 88 | SYS_FUNC(get_thread_area) |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 89 | { |
Dmitry V. Levin | 583526e | 2015-07-20 00:19:09 +0000 | [diff] [blame] | 90 | return RVAL_DECODED | RVAL_HEX; |
Dmitry V. Levin | 99a0544 | 2014-04-10 14:10:17 +0000 | [diff] [blame] | 91 | } |
| 92 | #endif |