master
h 65 lines 1.59 KB
Raw
1 /*
2 * x86_64 sysarch() syscall emulation
3 *
4 * Copyright (c) 2013 Stacey D. Son
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8 #ifndef TARGET_ARCH_SYSARCH_H
9 #define TARGET_ARCH_SYSARCH_H
10
11 #include "target_syscall.h"
12
13 static inline abi_long do_freebsd_arch_sysarch(CPUX86State *env, int op,
14 abi_ulong parms)
15 {
16 abi_long ret = 0;
17 abi_ulong val;
18 int idx;
19
20 switch (op) {
21 case TARGET_FREEBSD_AMD64_SET_GSBASE:
22 case TARGET_FREEBSD_AMD64_SET_FSBASE:
23 if (op == TARGET_FREEBSD_AMD64_SET_GSBASE) {
24 idx = R_GS;
25 } else {
26 idx = R_FS;
27 }
28 if (get_user(val, parms, abi_ulong)) {
29 return -TARGET_EFAULT;
30 }
31 cpu_x86_load_seg(env, idx, 0);
32 env->segs[idx].base = val;
33 break;
34
35 case TARGET_FREEBSD_AMD64_GET_GSBASE:
36 case TARGET_FREEBSD_AMD64_GET_FSBASE:
37 if (op == TARGET_FREEBSD_AMD64_GET_GSBASE) {
38 idx = R_GS;
39 } else {
40 idx = R_FS;
41 }
42 val = env->segs[idx].base;
43 if (put_user(val, parms, abi_ulong)) {
44 return -TARGET_EFAULT;
45 }
46 break;
47
48 /* XXX handle the others... */
49 default:
50 ret = -TARGET_EINVAL;
51 break;
52 }
53 return ret;
54 }
55
56 static inline void do_freebsd_arch_print_sysarch(
57 const struct syscallname *name, abi_long arg1, abi_long arg2,
58 abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6)
59 {
60
61 gemu_log("%s(%d, " TARGET_ABI_FMT_lx ", " TARGET_ABI_FMT_lx ", "
62 TARGET_ABI_FMT_lx ")", name->name, (int)arg1, arg2, arg3, arg4);
63 }
64
65 #endif /* TARGET_ARCH_SYSARCH_H */