qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH qemu ] hw/acpi: Fix big endian host creation of Generic Port Affinity Structures
@ 2024-06-05 18:04 Jonathan Cameron via
  2024-06-05 23:38 ` Michael S. Tsirkin
  2024-06-06 14:06 ` Igor Mammedov
  0 siblings, 2 replies; 11+ messages in thread
From: Jonathan Cameron via @ 2024-06-05 18:04 UTC (permalink / raw)
  To: mst, Markus Armbruster, qemu-devel, ankita, philmd,
	Richard Henderson
  Cc: Dave Jiang, Huang Ying, Paolo Bonzini, eduardo, imammedo,
	linux-cxl, linuxarm, Michael Roth, Ani Sinha

Treating the HID as an integer caused it to get bit reversed
on big endian hosts running little endian guests.  Treat it
as a character array instead.

Fixes hw/acpi: Generic Port Affinity Structure Support
Tested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

---
Richard ran the version posted in the thread on an s390 instance.
Thanks for the help!

Difference from version in thread:
- Instantiate i in the for loop.

Sending out now so Michael can decide whether to fold this in, or
drop the GP series for now from his pull request (in which case
I'll do an updated version with this and Markus' docs feedback
folded in.)

---
 include/hw/acpi/acpi_generic_initiator.h | 2 +-
 hw/acpi/acpi_generic_initiator.c         | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/hw/acpi/acpi_generic_initiator.h b/include/hw/acpi/acpi_generic_initiator.h
index 1a899af30f..5baefda33a 100644
--- a/include/hw/acpi/acpi_generic_initiator.h
+++ b/include/hw/acpi/acpi_generic_initiator.h
@@ -61,7 +61,7 @@ typedef struct PCIDeviceHandle {
             uint16_t bdf;
         };
         struct {
-            uint64_t hid;
+            char hid[8];
             uint32_t uid;
         };
     };
diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initiator.c
index 78b80dcf08..f064753b67 100644
--- a/hw/acpi/acpi_generic_initiator.c
+++ b/hw/acpi/acpi_generic_initiator.c
@@ -151,7 +151,9 @@ build_srat_generic_node_affinity(GArray *table_data, int node,
         build_append_int_noprefix(table_data, 0, 12);
     } else {
         /* Device Handle - ACPI */
-        build_append_int_noprefix(table_data, handle->hid, 8);
+        for (int i = 0; i < sizeof(handle->hid); i++) {
+            build_append_int_noprefix(table_data, handle->hid[i], 1);
+        }
         build_append_int_noprefix(table_data, handle->uid, 4);
         build_append_int_noprefix(table_data, 0, 4);
     }
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-06-18 12:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 18:04 [PATCH qemu ] hw/acpi: Fix big endian host creation of Generic Port Affinity Structures Jonathan Cameron via
2024-06-05 23:38 ` Michael S. Tsirkin
2024-06-06  9:27   ` Jonathan Cameron via
2024-06-06 14:06 ` Igor Mammedov
2024-06-06 17:47   ` Jonathan Cameron via
2024-06-10 17:47     ` Jonathan Cameron via
2024-06-14 10:57     ` Igor Mammedov
2024-06-14 14:08       ` Jonathan Cameron via
2024-06-17 10:49         ` Igor Mammedov
2024-06-17 12:05         ` Jonathan Cameron via
2024-06-18 12:23           ` Igor Mammedov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).