summary refs log tree commit diff stats
path: root/include/exec/poison.h
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2025-03-21 11:25:23 +0000
committerPaolo Bonzini <pbonzini@redhat.com>2025-03-21 12:51:16 +0100
commitcc3d262aa93a42e19c38f6acb6d0f6012a71eb4b (patch)
tree84e1990458c769671d9930ddb42f1cae4db5b099 /include/exec/poison.h
parent5b87a07e76816ed61e5968eb370859a5901b8516 (diff)
downloadfocaccia-qemu-cc3d262aa93a42e19c38f6acb6d0f6012a71eb4b.tar.gz
focaccia-qemu-cc3d262aa93a42e19c38f6acb6d0f6012a71eb4b.zip
rust: pl011: Check size of state struct at compile time
The PL011 device's C implementation exposes its PL011State struct to
users of the device, and one common usage pattern is to embed that
struct into the user's own state struct.  (The internals of the
struct are technically visible to the C user of the device, but in
practice are treated as implementation details.)

This means that the Rust version of the state struct must not be
larger than the C version's struct; otherwise it will trip a runtime
assertion in object_initialize_type() when the C user attempts to
in-place initialize the type.

Add a compile-time assertion on the Rust side, so that if we
accidentally make the Rust device state larger we know immediately
that we need to expand the padding in the C version of the struct.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Link: https://lore.kernel.org/r/20250321112523.1774131-4-peter.maydell@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/exec/poison.h')
0 files changed, 0 insertions, 0 deletions