diff mbox series

[11/14] bsd-user/sysarch: Move to using do_freebsd_arch_sysarch interface

Message ID 20210922061438.27645-12-imp@bsdimp.com
State New
Headers show
Series bsd-user: misc cleanup for aarch64 import | expand

Commit Message

Warner Losh Sept. 22, 2021, 6:14 a.m. UTC
Convert the #ifdef'd i386 code to calling the i386 sysarch code we have
living in i386,x86_64/target_arch_sysarch.h do_freebsd_arch_sysarch
rather than having a separate copy. This is in preparation to remove it
entirely.

Signed-Off-By: Warner Losh <imp@bsdimp.com>
---
 bsd-user/syscall.c | 45 +--------------------------------------------
 1 file changed, 1 insertion(+), 44 deletions(-)

Comments

Richard Henderson Sept. 23, 2021, 6:07 p.m. UTC | #1
On 9/21/21 11:14 PM, Warner Losh wrote:
> Convert the #ifdef'd i386 code to calling the i386 sysarch code we have
> living in i386,x86_64/target_arch_sysarch.h do_freebsd_arch_sysarch
> rather than having a separate copy. This is in preparation to remove it
> entirely.
> 
> Signed-Off-By: Warner Losh<imp@bsdimp.com>
> ---
>   bsd-user/syscall.c | 45 +--------------------------------------------
>   1 file changed, 1 insertion(+), 44 deletions(-)

It wasn't clear to me that this target_arch_sysarch.h file already exists, and is already 
populated with the code being (re)"moved" here.  Perhaps the wording here can be improved?

Anyway,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
Warner Losh Sept. 24, 2021, 3:25 p.m. UTC | #2
On Fri, Sep 24, 2021 at 6:00 AM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 9/21/21 11:14 PM, Warner Losh wrote:
> > Convert the #ifdef'd i386 code to calling the i386 sysarch code we have
> > living in i386,x86_64/target_arch_sysarch.h do_freebsd_arch_sysarch
> > rather than having a separate copy. This is in preparation to remove it
> > entirely.
> >
> > Signed-Off-By: Warner Losh<imp@bsdimp.com>
> > ---
> >   bsd-user/syscall.c | 45 +--------------------------------------------
> >   1 file changed, 1 insertion(+), 44 deletions(-)
>
> It wasn't clear to me that this target_arch_sysarch.h file already exists,
> and is already
> populated with the code being (re)"moved" here.  Perhaps the wording here
> can be improved?
>

Will do. Good suggestion.


> Anyway,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>

Thanks

Warner


>
> r~
>
diff mbox series

Patch

diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
index a579d52ede..9bc72501b2 100644
--- a/bsd-user/syscall.c
+++ b/bsd-user/syscall.c
@@ -91,50 +91,7 @@  static abi_long do_obreak(abi_ulong new_brk)
 #if defined(TARGET_I386)
 static abi_long do_freebsd_sysarch(CPUX86State *env, int op, abi_ulong parms)
 {
-    abi_long ret = 0;
-    abi_ulong val;
-    int idx;
-
-    switch (op) {
-#ifdef TARGET_ABI32
-    case TARGET_FREEBSD_I386_SET_GSBASE:
-    case TARGET_FREEBSD_I386_SET_FSBASE:
-        if (op == TARGET_FREEBSD_I386_SET_GSBASE)
-#else
-    case TARGET_FREEBSD_AMD64_SET_GSBASE:
-    case TARGET_FREEBSD_AMD64_SET_FSBASE:
-        if (op == TARGET_FREEBSD_AMD64_SET_GSBASE)
-#endif
-            idx = R_GS;
-        else
-            idx = R_FS;
-        if (get_user(val, parms, abi_ulong))
-            return -TARGET_EFAULT;
-        cpu_x86_load_seg(env, idx, 0);
-        env->segs[idx].base = val;
-        break;
-#ifdef TARGET_ABI32
-    case TARGET_FREEBSD_I386_GET_GSBASE:
-    case TARGET_FREEBSD_I386_GET_FSBASE:
-        if (op == TARGET_FREEBSD_I386_GET_GSBASE)
-#else
-    case TARGET_FREEBSD_AMD64_GET_GSBASE:
-    case TARGET_FREEBSD_AMD64_GET_FSBASE:
-        if (op == TARGET_FREEBSD_AMD64_GET_GSBASE)
-#endif
-            idx = R_GS;
-        else
-            idx = R_FS;
-        val = env->segs[idx].base;
-        if (put_user(val, parms, abi_ulong))
-            return -TARGET_EFAULT;
-        break;
-    /* XXX handle the others... */
-    default:
-        ret = -TARGET_EINVAL;
-        break;
-    }
-    return ret;
+    do_freebsd_arch_sysarch(env, op, parms);
 }
 #endif