blob: 73a17e8a89ada718994a3a203e8fdd88faba5530 [file] [log] [blame]
Dmitry V. Levin99a05442014-04-10 14:10:17 +00001#include "defs.h"
2
3#if defined I386 || defined X86_64 || defined X32
4
5# include <asm/ldt.h>
6
7void
Dmitry V. Levin79a45942015-07-20 00:10:35 +00008print_user_desc(struct tcb *tcp, const long addr)
Dmitry V. Levin99a05442014-04-10 14:10:17 +00009{
10 struct user_desc desc;
11
Dmitry V. Levin79a45942015-07-20 00:10:35 +000012 if (umove_or_printaddr(tcp, addr, &desc))
Dmitry V. Levin99a05442014-04-10 14:10:17 +000013 return;
Dmitry V. Levin99a05442014-04-10 14:10:17 +000014
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. Levina0bd3742015-04-07 01:36:50 +000035SYS_FUNC(modify_ldt)
Dmitry V. Levin99a05442014-04-10 14:10:17 +000036{
Dmitry V. Levin583526e2015-07-20 00:19:09 +000037 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. Levin99a05442014-04-10 14:10:17 +000045}
46
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000047SYS_FUNC(set_thread_area)
Dmitry V. Levin99a05442014-04-10 14:10:17 +000048{
49 if (entering(tcp)) {
50 print_user_desc(tcp, tcp->u_arg[0]);
51 } else {
52 struct user_desc desc;
53
Dmitry V. Levin79a45942015-07-20 00:10:35 +000054 if (!verbose(tcp) || syserror(tcp) ||
55 umove(tcp, tcp->u_arg[0], &desc) < 0) {
Dmitry V. Levin99a05442014-04-10 14:10:17 +000056 /* 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. Levina0bd3742015-04-07 01:36:50 +000068SYS_FUNC(get_thread_area)
Dmitry V. Levin99a05442014-04-10 14:10:17 +000069{
Dmitry V. Levin79a45942015-07-20 00:10:35 +000070 if (exiting(tcp))
71 print_user_desc(tcp, tcp->u_arg[0]);
Dmitry V. Levin99a05442014-04-10 14:10:17 +000072 return 0;
73}
74
75#endif /* I386 || X86_64 || X32 */
76
77#if defined(M68K) || defined(MIPS)
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000078SYS_FUNC(set_thread_area)
Dmitry V. Levin99a05442014-04-10 14:10:17 +000079{
Dmitry V. Levin583526e2015-07-20 00:19:09 +000080 printaddr(tcp->u_arg[0]);
81
82 return RVAL_DECODED;
Dmitry V. Levin99a05442014-04-10 14:10:17 +000083
84}
85#endif
86
87#if defined(M68K)
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000088SYS_FUNC(get_thread_area)
Dmitry V. Levin99a05442014-04-10 14:10:17 +000089{
Dmitry V. Levin583526e2015-07-20 00:19:09 +000090 return RVAL_DECODED | RVAL_HEX;
Dmitry V. Levin99a05442014-04-10 14:10:17 +000091}
92#endif