[PATCH] target/loongarch: fix alignment error in tci.

guoguangyao posted 1 patch 5 days, 1 hour ago
target/loongarch/cpu.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] target/loongarch: fix alignment error in tci.
Posted by guoguangyao 5 days, 1 hour ago
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;
@@ -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 */
-- 
2.34.1
Re: [PATCH] target/loongarch: fix alignment error in tci.
Posted by Philippe Mathieu-Daudé 4 days, 18 hours ago
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>


Re: [PATCH] target/loongarch: fix alignment error in tci.
Posted by Richard Henderson 4 days, 21 hours ago
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 */