diff mbox series

[v2,07/24] accel/tcg: Validate placement of CPUNegativeOffsetState

Message ID 20230914024435.1381329-8-richard.henderson@linaro.org
State Superseded
Headers show
Series Reduce usage of CPUArchState in cputlb.c | expand

Commit Message

Richard Henderson Sept. 14, 2023, 2:44 a.m. UTC
Verify that the distance between CPUNegativeOffsetState and
CPUArchState is no greater than any alignment requirements.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu-all.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Xingtao Yao (Fujitsu)" via Sept. 14, 2023, 10:19 a.m. UTC | #1
On 9/14/23 04:44, Richard Henderson wrote:
> Verify that the distance between CPUNegativeOffsetState and
> CPUArchState is no greater than any alignment requirements.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   include/exec/cpu-all.h | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
> index c2c62160c6..86a7452b0d 100644
> --- a/include/exec/cpu-all.h
> +++ b/include/exec/cpu-all.h
> @@ -459,6 +459,12 @@ static inline CPUState *env_cpu(CPUArchState *env)
>       return &env_archcpu(env)->parent_obj;
>   }
>   
> +/*
> + * Validate placement of CPUNegativeOffsetState.
> + */
> +QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) - offsetof(ArchCPU, neg) >=
> +                  sizeof(CPUNegativeOffsetState) + __alignof(CPUArchState));
> +
>   /**
>    * env_neg(env)
>    * @env: The architecture environment
Reviewed-by: Anton Johansson <anjo@rev.ng>
diff mbox series

Patch

diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index c2c62160c6..86a7452b0d 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -459,6 +459,12 @@  static inline CPUState *env_cpu(CPUArchState *env)
     return &env_archcpu(env)->parent_obj;
 }
 
+/*
+ * Validate placement of CPUNegativeOffsetState.
+ */
+QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) - offsetof(ArchCPU, neg) >=
+                  sizeof(CPUNegativeOffsetState) + __alignof(CPUArchState));
+
 /**
  * env_neg(env)
  * @env: The architecture environment