Message ID | 20211015041053.2769193-31-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | user-only: Cleanup SIGSEGV and SIGBUS handling | expand |
On Thu, Oct 14, 2021 at 10:11 PM Richard Henderson < richard.henderson@linaro.org> wrote: > The fallback code in cpu_loop_exit_sigsegv is sufficient > for mips linux-user. > > This means we can remove tcg/user/tlb_helper.c entirely. > Remove the code from cpu_loop that raised SIGSEGV. > > Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/mips/tcg/tcg-internal.h | 7 ++-- > linux-user/mips/cpu_loop.c | 11 ------ > target/mips/cpu.c | 2 +- > target/mips/tcg/user/tlb_helper.c | 59 ------------------------------- > target/mips/tcg/meson.build | 3 -- > target/mips/tcg/user/meson.build | 3 -- > 6 files changed, 5 insertions(+), 80 deletions(-) > delete mode 100644 target/mips/tcg/user/tlb_helper.c > delete mode 100644 target/mips/tcg/user/meson.build > Reviewed-by: Warner Losh <imp@bsdimp.com> We do have mips support in bsd-user fork, but it's unclear how long we'll continue that support, though. This seems like it won't present a big problem for us should we continue that support, though (at least for FreeBSD). The usual $(OTHER)BSD caveats apply. Warner > diff --git a/target/mips/tcg/tcg-internal.h > b/target/mips/tcg/tcg-internal.h > index bad3deb611..466768aec4 100644 > --- a/target/mips/tcg/tcg-internal.h > +++ b/target/mips/tcg/tcg-internal.h > @@ -18,9 +18,6 @@ > void mips_tcg_init(void); > > void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock > *tb); > -bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, > - MMUAccessType access_type, int mmu_idx, > - bool probe, uintptr_t retaddr); > void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, > MMUAccessType access_type, int mmu_idx, > uintptr_t retaddr) QEMU_NORETURN; > @@ -60,6 +57,10 @@ void mips_cpu_do_transaction_failed(CPUState *cs, > hwaddr physaddr, > MemTxResult response, uintptr_t > retaddr); > void cpu_mips_tlb_flush(CPUMIPSState *env); > > +bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, > + MMUAccessType access_type, int mmu_idx, > + bool probe, uintptr_t retaddr); > + > #endif /* !CONFIG_USER_ONLY */ > > #endif > diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c > index cb03fb066b..b735c99a24 100644 > --- a/linux-user/mips/cpu_loop.c > +++ b/linux-user/mips/cpu_loop.c > @@ -158,17 +158,6 @@ done_syscall: > } > env->active_tc.gpr[2] = ret; > break; > - case EXCP_TLBL: > - case EXCP_TLBS: > - case EXCP_AdEL: > - case EXCP_AdES: > - info.si_signo = TARGET_SIGSEGV; > - info.si_errno = 0; > - /* XXX: check env->error_code */ > - info.si_code = TARGET_SEGV_MAPERR; > - info._sifields._sigfault._addr = env->CP0_BadVAddr; > - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); > - break; > case EXCP_CpU: > case EXCP_RI: > info.si_signo = TARGET_SIGILL; > diff --git a/target/mips/cpu.c b/target/mips/cpu.c > index 00e0c55d0e..4aae23934b 100644 > --- a/target/mips/cpu.c > +++ b/target/mips/cpu.c > @@ -539,9 +539,9 @@ static const struct SysemuCPUOps mips_sysemu_ops = { > static const struct TCGCPUOps mips_tcg_ops = { > .initialize = mips_tcg_init, > .synchronize_from_tb = mips_cpu_synchronize_from_tb, > - .tlb_fill = mips_cpu_tlb_fill, > > #if !defined(CONFIG_USER_ONLY) > + .tlb_fill = mips_cpu_tlb_fill, > .cpu_exec_interrupt = mips_cpu_exec_interrupt, > .do_interrupt = mips_cpu_do_interrupt, > .do_transaction_failed = mips_cpu_do_transaction_failed, > diff --git a/target/mips/tcg/user/tlb_helper.c > b/target/mips/tcg/user/tlb_helper.c > deleted file mode 100644 > index 210c6d529e..0000000000 > --- a/target/mips/tcg/user/tlb_helper.c > +++ /dev/null > @@ -1,59 +0,0 @@ > -/* > - * MIPS TLB (Translation lookaside buffer) helpers. > - * > - * Copyright (c) 2004-2005 Jocelyn Mayer > - * > - * This library is free software; you can redistribute it and/or > - * modify it under the terms of the GNU Lesser General Public > - * License as published by the Free Software Foundation; either > - * version 2.1 of the License, or (at your option) any later version. > - * > - * This library is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - * Lesser General Public License for more details. > - * > - * You should have received a copy of the GNU Lesser General Public > - * License along with this library; if not, see < > http://www.gnu.org/licenses/>. > - */ > -#include "qemu/osdep.h" > - > -#include "cpu.h" > -#include "exec/exec-all.h" > -#include "internal.h" > - > -static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, > - MMUAccessType access_type) > -{ > - CPUState *cs = env_cpu(env); > - > - env->error_code = 0; > - if (access_type == MMU_INST_FETCH) { > - env->error_code |= EXCP_INST_NOTAVAIL; > - } > - > - /* Reference to kernel address from user mode or supervisor mode */ > - /* Reference to supervisor address from user mode */ > - if (access_type == MMU_DATA_STORE) { > - cs->exception_index = EXCP_AdES; > - } else { > - cs->exception_index = EXCP_AdEL; > - } > - > - /* Raise exception */ > - if (!(env->hflags & MIPS_HFLAG_DM)) { > - env->CP0_BadVAddr = address; > - } > -} > - > -bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, > - MMUAccessType access_type, int mmu_idx, > - bool probe, uintptr_t retaddr) > -{ > - MIPSCPU *cpu = MIPS_CPU(cs); > - CPUMIPSState *env = &cpu->env; > - > - /* data access */ > - raise_mmu_exception(env, address, access_type); > - do_raise_exception_err(env, cs->exception_index, env->error_code, > retaddr); > -} > diff --git a/target/mips/tcg/meson.build b/target/mips/tcg/meson.build > index 8f6f7508b6..98003779ae 100644 > --- a/target/mips/tcg/meson.build > +++ b/target/mips/tcg/meson.build > @@ -28,9 +28,6 @@ mips_ss.add(when: 'TARGET_MIPS64', if_true: files( > 'mxu_translate.c', > )) > > -if have_user > - subdir('user') > -endif > if have_system > subdir('sysemu') > endif > diff --git a/target/mips/tcg/user/meson.build > b/target/mips/tcg/user/meson.build > deleted file mode 100644 > index 79badcd321..0000000000 > --- a/target/mips/tcg/user/meson.build > +++ /dev/null > @@ -1,3 +0,0 @@ > -mips_user_ss.add(files( > - 'tlb_helper.c', > -)) > -- > 2.25.1 > > <div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 14, 2021 at 10:11 PM Richard Henderson <<a href="mailto:richard.henderson@linaro.org">richard.henderson@linaro.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The fallback code in cpu_loop_exit_sigsegv is sufficient<br> for mips linux-user.<br> <br> This means we can remove tcg/user/tlb_helper.c entirely.<br> Remove the code from cpu_loop that raised SIGSEGV.<br> <br> Reviewed-by: Philippe Mathieu-Daudé <<a href="mailto:f4bug@amsat.org" target="_blank">f4bug@amsat.org</a>><br> Signed-off-by: Richard Henderson <<a href="mailto:richard.henderson@linaro.org" target="_blank">richard.henderson@linaro.org</a>><br> ---<br> target/mips/tcg/tcg-internal.h | 7 ++--<br> linux-user/mips/cpu_loop.c | 11 ------<br> target/mips/cpu.c | 2 +-<br> target/mips/tcg/user/tlb_helper.c | 59 -------------------------------<br> target/mips/tcg/meson.build | 3 --<br> target/mips/tcg/user/meson.build | 3 --<br> 6 files changed, 5 insertions(+), 80 deletions(-)<br> delete mode 100644 target/mips/tcg/user/tlb_helper.c<br> delete mode 100644 target/mips/tcg/user/meson.build<br></blockquote><div><br></div><div><div>Reviewed-by: Warner Losh <<a href="mailto:imp@bsdimp.com">imp@bsdimp.com</a>></div><br class="gmail-Apple-interchange-newline"></div><div>We do have mips support in bsd-user fork, but it's unclear how long we'll continue</div><div>that support, though. This seems like it won't present a big problem for us should</div><div>we continue that support, though (at least for FreeBSD). The usual $(OTHER)BSD</div><div>caveats apply.</div><div><br></div><div>Warner</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> diff --git a/target/mips/tcg/tcg-internal.h b/target/mips/tcg/tcg-internal.h<br> index bad3deb611..466768aec4 100644<br> --- a/target/mips/tcg/tcg-internal.h<br> +++ b/target/mips/tcg/tcg-internal.h<br> @@ -18,9 +18,6 @@<br> void mips_tcg_init(void);<br> <br> void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb);<br> -bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size,<br> - MMUAccessType access_type, int mmu_idx,<br> - bool probe, uintptr_t retaddr);<br> void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,<br> MMUAccessType access_type, int mmu_idx,<br> uintptr_t retaddr) QEMU_NORETURN;<br> @@ -60,6 +57,10 @@ void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,<br> MemTxResult response, uintptr_t retaddr);<br> void cpu_mips_tlb_flush(CPUMIPSState *env);<br> <br> +bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size,<br> + MMUAccessType access_type, int mmu_idx,<br> + bool probe, uintptr_t retaddr);<br> +<br> #endif /* !CONFIG_USER_ONLY */<br> <br> #endif<br> diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c<br> index cb03fb066b..b735c99a24 100644<br> --- a/linux-user/mips/cpu_loop.c<br> +++ b/linux-user/mips/cpu_loop.c<br> @@ -158,17 +158,6 @@ done_syscall:<br> }<br> env->active_tc.gpr[2] = ret;<br> break;<br> - case EXCP_TLBL:<br> - case EXCP_TLBS:<br> - case EXCP_AdEL:<br> - case EXCP_AdES:<br> - info.si_signo = TARGET_SIGSEGV;<br> - info.si_errno = 0;<br> - /* XXX: check env->error_code */<br> - info.si_code = TARGET_SEGV_MAPERR;<br> - info._sifields._sigfault._addr = env->CP0_BadVAddr;<br> - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);<br> - break;<br> case EXCP_CpU:<br> case EXCP_RI:<br> info.si_signo = TARGET_SIGILL;<br> diff --git a/target/mips/cpu.c b/target/mips/cpu.c<br> index 00e0c55d0e..4aae23934b 100644<br> --- a/target/mips/cpu.c<br> +++ b/target/mips/cpu.c<br> @@ -539,9 +539,9 @@ static const struct SysemuCPUOps mips_sysemu_ops = {<br> static const struct TCGCPUOps mips_tcg_ops = {<br> .initialize = mips_tcg_init,<br> .synchronize_from_tb = mips_cpu_synchronize_from_tb,<br> - .tlb_fill = mips_cpu_tlb_fill,<br> <br> #if !defined(CONFIG_USER_ONLY)<br> + .tlb_fill = mips_cpu_tlb_fill,<br> .cpu_exec_interrupt = mips_cpu_exec_interrupt,<br> .do_interrupt = mips_cpu_do_interrupt,<br> .do_transaction_failed = mips_cpu_do_transaction_failed,<br> diff --git a/target/mips/tcg/user/tlb_helper.c b/target/mips/tcg/user/tlb_helper.c<br> deleted file mode 100644<br> index 210c6d529e..0000000000<br> --- a/target/mips/tcg/user/tlb_helper.c<br> +++ /dev/null<br> @@ -1,59 +0,0 @@<br> -/*<br> - * MIPS TLB (Translation lookaside buffer) helpers.<br> - *<br> - * Copyright (c) 2004-2005 Jocelyn Mayer<br> - *<br> - * This library is free software; you can redistribute it and/or<br> - * modify it under the terms of the GNU Lesser General Public<br> - * License as published by the Free Software Foundation; either<br> - * version 2.1 of the License, or (at your option) any later version.<br> - *<br> - * This library is distributed in the hope that it will be useful,<br> - * but WITHOUT ANY WARRANTY; without even the implied warranty of<br> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br> - * Lesser General Public License for more details.<br> - *<br> - * You should have received a copy of the GNU Lesser General Public<br> - * License along with this library; if not, see <<a href="http://www.gnu.org/licenses/" rel="noreferrer" target="_blank">http://www.gnu.org/licenses/</a>>.<br> - */<br> -#include "qemu/osdep.h"<br> -<br> -#include "cpu.h"<br> -#include "exec/exec-all.h"<br> -#include "internal.h"<br> -<br> -static void raise_mmu_exception(CPUMIPSState *env, target_ulong address,<br> - MMUAccessType access_type)<br> -{<br> - CPUState *cs = env_cpu(env);<br> -<br> - env->error_code = 0;<br> - if (access_type == MMU_INST_FETCH) {<br> - env->error_code |= EXCP_INST_NOTAVAIL;<br> - }<br> -<br> - /* Reference to kernel address from user mode or supervisor mode */<br> - /* Reference to supervisor address from user mode */<br> - if (access_type == MMU_DATA_STORE) {<br> - cs->exception_index = EXCP_AdES;<br> - } else {<br> - cs->exception_index = EXCP_AdEL;<br> - }<br> -<br> - /* Raise exception */<br> - if (!(env->hflags & MIPS_HFLAG_DM)) {<br> - env->CP0_BadVAddr = address;<br> - }<br> -}<br> -<br> -bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size,<br> - MMUAccessType access_type, int mmu_idx,<br> - bool probe, uintptr_t retaddr)<br> -{<br> - MIPSCPU *cpu = MIPS_CPU(cs);<br> - CPUMIPSState *env = &cpu->env;<br> -<br> - /* data access */<br> - raise_mmu_exception(env, address, access_type);<br> - do_raise_exception_err(env, cs->exception_index, env->error_code, retaddr);<br> -}<br> diff --git a/target/mips/tcg/meson.build b/target/mips/tcg/meson.build<br> index 8f6f7508b6..98003779ae 100644<br> --- a/target/mips/tcg/meson.build<br> +++ b/target/mips/tcg/meson.build<br> @@ -28,9 +28,6 @@ mips_ss.add(when: 'TARGET_MIPS64', if_true: files(<br> 'mxu_translate.c',<br> ))<br> <br> -if have_user<br> - subdir('user')<br> -endif<br> if have_system<br> subdir('sysemu')<br> endif<br> diff --git a/target/mips/tcg/user/meson.build b/target/mips/tcg/user/meson.build<br> deleted file mode 100644<br> index 79badcd321..0000000000<br> --- a/target/mips/tcg/user/meson.build<br> +++ /dev/null<br> @@ -1,3 +0,0 @@<br> -mips_user_ss.add(files(<br> - 'tlb_helper.c',<br> -))<br> -- <br> 2.25.1<br> <br> </blockquote></div></div>
diff --git a/target/mips/tcg/tcg-internal.h b/target/mips/tcg/tcg-internal.h index bad3deb611..466768aec4 100644 --- a/target/mips/tcg/tcg-internal.h +++ b/target/mips/tcg/tcg-internal.h @@ -18,9 +18,6 @@ void mips_tcg_init(void); void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); -bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) QEMU_NORETURN; @@ -60,6 +57,10 @@ void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, MemTxResult response, uintptr_t retaddr); void cpu_mips_tlb_flush(CPUMIPSState *env); +bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); + #endif /* !CONFIG_USER_ONLY */ #endif diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index cb03fb066b..b735c99a24 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -158,17 +158,6 @@ done_syscall: } env->active_tc.gpr[2] = ret; break; - case EXCP_TLBL: - case EXCP_TLBS: - case EXCP_AdEL: - case EXCP_AdES: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->CP0_BadVAddr; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case EXCP_CpU: case EXCP_RI: info.si_signo = TARGET_SIGILL; diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 00e0c55d0e..4aae23934b 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -539,9 +539,9 @@ static const struct SysemuCPUOps mips_sysemu_ops = { static const struct TCGCPUOps mips_tcg_ops = { .initialize = mips_tcg_init, .synchronize_from_tb = mips_cpu_synchronize_from_tb, - .tlb_fill = mips_cpu_tlb_fill, #if !defined(CONFIG_USER_ONLY) + .tlb_fill = mips_cpu_tlb_fill, .cpu_exec_interrupt = mips_cpu_exec_interrupt, .do_interrupt = mips_cpu_do_interrupt, .do_transaction_failed = mips_cpu_do_transaction_failed, diff --git a/target/mips/tcg/user/tlb_helper.c b/target/mips/tcg/user/tlb_helper.c deleted file mode 100644 index 210c6d529e..0000000000 --- a/target/mips/tcg/user/tlb_helper.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIPS TLB (Translation lookaside buffer) helpers. - * - * Copyright (c) 2004-2005 Jocelyn Mayer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see <http://www.gnu.org/licenses/>. - */ -#include "qemu/osdep.h" - -#include "cpu.h" -#include "exec/exec-all.h" -#include "internal.h" - -static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, - MMUAccessType access_type) -{ - CPUState *cs = env_cpu(env); - - env->error_code = 0; - if (access_type == MMU_INST_FETCH) { - env->error_code |= EXCP_INST_NOTAVAIL; - } - - /* Reference to kernel address from user mode or supervisor mode */ - /* Reference to supervisor address from user mode */ - if (access_type == MMU_DATA_STORE) { - cs->exception_index = EXCP_AdES; - } else { - cs->exception_index = EXCP_AdEL; - } - - /* Raise exception */ - if (!(env->hflags & MIPS_HFLAG_DM)) { - env->CP0_BadVAddr = address; - } -} - -bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) -{ - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; - - /* data access */ - raise_mmu_exception(env, address, access_type); - do_raise_exception_err(env, cs->exception_index, env->error_code, retaddr); -} diff --git a/target/mips/tcg/meson.build b/target/mips/tcg/meson.build index 8f6f7508b6..98003779ae 100644 --- a/target/mips/tcg/meson.build +++ b/target/mips/tcg/meson.build @@ -28,9 +28,6 @@ mips_ss.add(when: 'TARGET_MIPS64', if_true: files( 'mxu_translate.c', )) -if have_user - subdir('user') -endif if have_system subdir('sysemu') endif diff --git a/target/mips/tcg/user/meson.build b/target/mips/tcg/user/meson.build deleted file mode 100644 index 79badcd321..0000000000 --- a/target/mips/tcg/user/meson.build +++ /dev/null @@ -1,3 +0,0 @@ -mips_user_ss.add(files( - 'tlb_helper.c', -))