Hi Philippe,
On 2025/12/27 06:45, Philippe Mathieu-Daudé wrote:
On 24/12/25 04:46, Tao Tang wrote:
Move register definitions, command enums, and Stream Table Entry (STE) /
Context Descriptor (CD) structure definitions from the internal header
hw/arm/smmuv3-internal.h to a new common header
include/hw/arm/smmuv3-common.h.
This allows other components, such as generic SMMUv3 tests or test
devices,
to utilize these definitions without including the specific SMMUv3
device
internal state.
Signed-off-by: Tao Tang <[email protected]>
Reviewed-by: Pierrick Bouvier <[email protected]>
---
hw/arm/smmuv3-internal.h | 255 +------------------------------
include/hw/arm/smmuv3-common.h | 268 +++++++++++++++++++++++++++++++++
2 files changed, 269 insertions(+), 254 deletions(-)
create mode 100644 include/hw/arm/smmuv3-common.h
--- /dev/null
+++ b/include/hw/arm/smmuv3-common.h
@@ -0,0 +1,268 @@
+/*
+ * ARM SMMUv3 support - Common API
+ *
+ * Copyright (C) 2014-2016 Broadcom Corporation
+ * Copyright (c) 2017 Red Hat, Inc.
+ * Written by Prem Mallappa, Eric Auger
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HW_ARM_SMMUV3_COMMON_H
+#define HW_ARM_SMMUV3_COMMON_H
+
+/* Configuration Data */
+
+/* STE Level 1 Descriptor */
+typedef struct STEDesc {
+ uint32_t word[2];
+} STEDesc;
+
+/* CD Level 1 Descriptor */
+typedef struct CDDesc {
+ uint32_t word[2];
+} CDDesc;
+
+/* Stream Table Entry(STE) */
+typedef struct STE {
+ uint32_t word[16];
+} STE;
+
+/* Context Descriptor(CD) */
+typedef struct CD {
+ uint32_t word[16];
+} CD;
Pre-existing: should these be QEMU_PACKED?
Thanks for the feedback.
I tried adding QEMU_PACKED to STEDesc/CDDesc/STE/CD in smmuv3-common.h,
but that means some call sites need updates.
For example, with packed structs, this triggers
-Waddress-of-packed-member (and becomes a build failure with -Werror):
le32_to_cpus(&buf->word[i]); // smmu_get_ste function in
hw/arm/smmuv3.c
It needs to be changed to something like:
buf->word[i] = le32_to_cpu(buf->word[i]);
Do you prefer that I send an extra commit to fix all affected call sites
and keep QEMU_PACKED, or should we instead drop QEMU_PACKED and add
compile-time size checks, e.g.:
QEMU_BUILD_BUG_ON(sizeof(STEDesc) != 8);
QEMU_BUILD_BUG_ON(sizeof(CDDesc) != 8);
QEMU_BUILD_BUG_ON(sizeof(STE) != 64);
QEMU_BUILD_BUG_ON(sizeof(CD) != 64);
Best regards,
Tao