diff mbox series

[PULL,13/47] accel/tcg: Validate placement of CPUNegativeOffsetState

Message ID 20231003173052.1601813-14-richard.henderson@linaro.org
State Accepted
Commit 5d30bdcb1b72ec1d44397ee7047417617066d97a
Headers show
Series [PULL,01/47] accel: Rename accel_cpu_realizefn() -> accel_cpu_realize() | expand

Commit Message

Richard Henderson Oct. 3, 2023, 5:30 p.m. UTC
Verify that the distance between CPUNegativeOffsetState and
CPUArchState is no greater than any alignment requirements.

Reviewed-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu-all.h | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 230525ebf7..ed7747a5f1 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -457,6 +457,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