Patchwork [qtestfix,for-1.5] libqos: Convert fw_cfg values to host endianness

login
register
mail settings
Submitter Andreas Färber
Date April 28, 2013, 4:45 p.m.
Message ID <1367167547-19931-1-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/240262/
State New
Headers show

Comments

Andreas Färber - April 28, 2013, 4:45 p.m.
The fw_cfg ABI is Little Endian, so byte-swap the generically read
byte array to host endianness.

This unbreaks the fw_cfg tests on ppc.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 tests/libqos/fw_cfg.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Anthony Liguori - April 29, 2013, 10:04 p.m.
Applied.  Thanks.

Regards,

Anthony Liguori

Patch

diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c
index 799139e..e386ff7 100644
--- a/tests/libqos/fw_cfg.c
+++ b/tests/libqos/fw_cfg.c
@@ -11,6 +11,7 @@ 
  */
 
 #include "libqos/fw_cfg.h"
+#include "qemu/bswap.h"
 
 void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
 {
@@ -32,20 +33,20 @@  uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key)
 {
     uint16_t value;
     qfw_cfg_get(fw_cfg, key, &value, sizeof(value));
-    return value;
+    return le16_to_cpu(value);
 }
 
 uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key)
 {
     uint32_t value;
     qfw_cfg_get(fw_cfg, key, &value, sizeof(value));
-    return value;
+    return le32_to_cpu(value);
 }
 
 uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key)
 {
     uint64_t value;
     qfw_cfg_get(fw_cfg, key, &value, sizeof(value));
-    return value;
+    return le64_to_cpu(value);
 }