Message ID | 20211015041053.2769193-61-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | user-only: Cleanup SIGSEGV and SIGBUS handling | expand |
On Thu, Oct 14, 2021 at 10:14 PM Richard Henderson < richard.henderson@linaro.org> wrote: > To be called from tcg generated code on hosts that support > unaligned accesses natively, in response to an access that > is supposed to be aligned. > > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > include/tcg/tcg-ldst.h | 5 +++++ > accel/tcg/user-exec.c | 11 +++++++++++ > 2 files changed, 16 insertions(+) > Reviewed-by: Warner Losh <imp@bsdimp.com> > diff --git a/include/tcg/tcg-ldst.h b/include/tcg/tcg-ldst.h > index 8c86365611..bf40942de4 100644 > --- a/include/tcg/tcg-ldst.h > +++ b/include/tcg/tcg-ldst.h > @@ -70,5 +70,10 @@ void helper_be_stl_mmu(CPUArchState *env, target_ulong > addr, uint32_t val, > void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, > MemOpIdx oi, uintptr_t retaddr); > > +#else > + > +void QEMU_NORETURN helper_unaligned_ld(CPUArchState *env, target_ulong > addr); > +void QEMU_NORETURN helper_unaligned_st(CPUArchState *env, target_ulong > addr); > + > #endif /* CONFIG_SOFTMMU */ > #endif /* TCG_LDST_H */ > diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c > index 7d50dd54f6..0473ead5ab 100644 > --- a/accel/tcg/user-exec.c > +++ b/accel/tcg/user-exec.c > @@ -27,6 +27,7 @@ > #include "exec/helper-proto.h" > #include "qemu/atomic128.h" > #include "trace/trace-root.h" > +#include "tcg/tcg-ldst.h" > #include "internal.h" > > __thread uintptr_t helper_retaddr; > @@ -217,6 +218,16 @@ static void validate_memop(MemOpIdx oi, MemOp > expected) > #endif > } > > +void helper_unaligned_ld(CPUArchState *env, target_ulong addr) > +{ > + cpu_loop_exit_sigbus(env_cpu(env), addr, MMU_DATA_LOAD, GETPC()); > +} > + > +void helper_unaligned_st(CPUArchState *env, target_ulong addr) > +{ > + cpu_loop_exit_sigbus(env_cpu(env), addr, MMU_DATA_STORE, GETPC()); > +} > + > static void *cpu_mmu_lookup(CPUArchState *env, target_ulong addr, > MemOpIdx oi, uintptr_t ra, MMUAccessType type) > { > -- > 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:14 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">To be called from tcg generated code on hosts that support<br> unaligned accesses natively, in response to an access that<br> is supposed to be aligned.<br> <br> Reviewed-by: Peter Maydell <<a href="mailto:peter.maydell@linaro.org" target="_blank">peter.maydell@linaro.org</a>><br> Signed-off-by: Richard Henderson <<a href="mailto:richard.henderson@linaro.org" target="_blank">richard.henderson@linaro.org</a>><br> ---<br> include/tcg/tcg-ldst.h | 5 +++++<br> accel/tcg/user-exec.c | 11 +++++++++++<br> 2 files changed, 16 insertions(+)<br></blockquote><div><br></div><div><div>Reviewed-by: Warner Losh <<a href="mailto:imp@bsdimp.com">imp@bsdimp.com</a>></div><div><br></div></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/include/tcg/tcg-ldst.h b/include/tcg/tcg-ldst.h<br> index 8c86365611..bf40942de4 100644<br> --- a/include/tcg/tcg-ldst.h<br> +++ b/include/tcg/tcg-ldst.h<br> @@ -70,5 +70,10 @@ void helper_be_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val,<br> void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val,<br> MemOpIdx oi, uintptr_t retaddr);<br> <br> +#else<br> +<br> +void QEMU_NORETURN helper_unaligned_ld(CPUArchState *env, target_ulong addr);<br> +void QEMU_NORETURN helper_unaligned_st(CPUArchState *env, target_ulong addr);<br> +<br> #endif /* CONFIG_SOFTMMU */<br> #endif /* TCG_LDST_H */<br> diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c<br> index 7d50dd54f6..0473ead5ab 100644<br> --- a/accel/tcg/user-exec.c<br> +++ b/accel/tcg/user-exec.c<br> @@ -27,6 +27,7 @@<br> #include "exec/helper-proto.h"<br> #include "qemu/atomic128.h"<br> #include "trace/trace-root.h"<br> +#include "tcg/tcg-ldst.h"<br> #include "internal.h"<br> <br> __thread uintptr_t helper_retaddr;<br> @@ -217,6 +218,16 @@ static void validate_memop(MemOpIdx oi, MemOp expected)<br> #endif<br> }<br> <br> +void helper_unaligned_ld(CPUArchState *env, target_ulong addr)<br> +{<br> + cpu_loop_exit_sigbus(env_cpu(env), addr, MMU_DATA_LOAD, GETPC());<br> +}<br> +<br> +void helper_unaligned_st(CPUArchState *env, target_ulong addr)<br> +{<br> + cpu_loop_exit_sigbus(env_cpu(env), addr, MMU_DATA_STORE, GETPC());<br> +}<br> +<br> static void *cpu_mmu_lookup(CPUArchState *env, target_ulong addr,<br> MemOpIdx oi, uintptr_t ra, MMUAccessType type)<br> {<br> -- <br> 2.25.1<br> <br> </blockquote></div></div>
On 10/15/21 06:10, Richard Henderson wrote: > To be called from tcg generated code on hosts that support > unaligned accesses natively, in response to an access that > is supposed to be aligned. > > Reviewed-by: Peter Maydell <peter.maydell@linaro.org> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > include/tcg/tcg-ldst.h | 5 +++++ > accel/tcg/user-exec.c | 11 +++++++++++ > 2 files changed, 16 insertions(+) Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
diff --git a/include/tcg/tcg-ldst.h b/include/tcg/tcg-ldst.h index 8c86365611..bf40942de4 100644 --- a/include/tcg/tcg-ldst.h +++ b/include/tcg/tcg-ldst.h @@ -70,5 +70,10 @@ void helper_be_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, MemOpIdx oi, uintptr_t retaddr); +#else + +void QEMU_NORETURN helper_unaligned_ld(CPUArchState *env, target_ulong addr); +void QEMU_NORETURN helper_unaligned_st(CPUArchState *env, target_ulong addr); + #endif /* CONFIG_SOFTMMU */ #endif /* TCG_LDST_H */ diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 7d50dd54f6..0473ead5ab 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -27,6 +27,7 @@ #include "exec/helper-proto.h" #include "qemu/atomic128.h" #include "trace/trace-root.h" +#include "tcg/tcg-ldst.h" #include "internal.h" __thread uintptr_t helper_retaddr; @@ -217,6 +218,16 @@ static void validate_memop(MemOpIdx oi, MemOp expected) #endif } +void helper_unaligned_ld(CPUArchState *env, target_ulong addr) +{ + cpu_loop_exit_sigbus(env_cpu(env), addr, MMU_DATA_LOAD, GETPC()); +} + +void helper_unaligned_st(CPUArchState *env, target_ulong addr) +{ + cpu_loop_exit_sigbus(env_cpu(env), addr, MMU_DATA_STORE, GETPC()); +} + static void *cpu_mmu_lookup(CPUArchState *env, target_ulong addr, MemOpIdx oi, uintptr_t ra, MMUAccessType type) {