diff mbox series

target/loongarch: fix alignment error in tci.

Message ID 20241118133243.291769-1-guoguangyao18@mails.ucas.ac.cn (mailing list archive)
State New
Headers show
Series target/loongarch: fix alignment error in tci. | expand

Commit Message

guoguangyao Nov. 18, 2024, 1:32 p.m. UTC
Add alignment and check for fpr in
CPUArchState, fix alignment error in
tcg interpreter when executing LASX.

Signed-off-by: guoguangyao <guoguangyao18@mails.ucas.ac.cn>
---
 target/loongarch/cpu.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Richard Henderson Nov. 18, 2024, 6:08 p.m. UTC | #1
On 11/18/24 05:32, guoguangyao wrote:
> Add alignment and check for fpr in
> CPUArchState, fix alignment error in
> tcg interpreter when executing LASX.
> 
> Signed-off-by: guoguangyao <guoguangyao18@mails.ucas.ac.cn>
> ---
>   target/loongarch/cpu.h | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
> index 86c86c6c95..f955f9f618 100644
> --- a/target/loongarch/cpu.h
> +++ b/target/loongarch/cpu.h
> @@ -302,7 +302,7 @@ typedef struct CPUArchState {
>       uint64_t gpr[32];
>       uint64_t pc;
>   
> -    fpr_t fpr[32];
> +    fpr_t fpr[32] QEMU_ALIGNED(16);
>       bool cf[8];
>       uint32_t fcsr0;
>       lbt_t  lbt;

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

r~

> @@ -487,6 +487,7 @@ static inline void cpu_get_tb_cpu_state(CPULoongArchState *env, vaddr *pc,
>   
>   #define CPU_RESOLVING_TYPE TYPE_LOONGARCH_CPU
>   
> +QEMU_BUILD_BUG_ON((offsetof(CPULoongArchState, fpr[0]) & (15)) != 0);
>   void loongarch_cpu_post_init(Object *obj);
>   
>   #endif /* LOONGARCH_CPU_H */
Philippe Mathieu-Daudé Nov. 18, 2024, 8:52 p.m. UTC | #2
On 18/11/24 14:32, guoguangyao wrote:
> Add alignment and check for fpr in
> CPUArchState, fix alignment error in
> tcg interpreter when executing LASX.
> 
> Signed-off-by: guoguangyao <guoguangyao18@mails.ucas.ac.cn>
> ---
>   target/loongarch/cpu.h | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff mbox series

Patch

diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index 86c86c6c95..f955f9f618 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -302,7 +302,7 @@  typedef struct CPUArchState {
     uint64_t gpr[32];
     uint64_t pc;
 
-    fpr_t fpr[32];
+    fpr_t fpr[32] QEMU_ALIGNED(16);
     bool cf[8];
     uint32_t fcsr0;
     lbt_t  lbt;
@@ -487,6 +487,7 @@  static inline void cpu_get_tb_cpu_state(CPULoongArchState *env, vaddr *pc,
 
 #define CPU_RESOLVING_TYPE TYPE_LOONGARCH_CPU
 
+QEMU_BUILD_BUG_ON((offsetof(CPULoongArchState, fpr[0]) & (15)) != 0);
 void loongarch_cpu_post_init(Object *obj);
 
 #endif /* LOONGARCH_CPU_H */