qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ani Sinha <anisinha@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: philmd@linaro.org, armbru@redhat.com,
	Ani Sinha <anisinha@redhat.com>,
	qemu-devel@nongnu.org
Subject: [PATCH] hw/vmcoreinfo: make guest format endian safe
Date: Fri, 12 Jul 2024 11:54:52 +0530	[thread overview]
Message-ID: <20240712062452.31457-1-anisinha@redhat.com> (raw)

Guest and host formats in struct FWCfgVMCoreInfo are written in little endian
format. However, the hypervisor host might be big endian. We need to do
appropriate conversions between the formats before comparing the values. Fix it.

Signed-off-by: Ani Sinha <anisinha@redhat.com>
---
 hw/misc/vmcoreinfo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/misc/vmcoreinfo.c b/hw/misc/vmcoreinfo.c
index 833773ade5..e00df95e29 100644
--- a/hw/misc/vmcoreinfo.c
+++ b/hw/misc/vmcoreinfo.c
@@ -21,9 +21,10 @@
 static void fw_cfg_vmci_write(void *dev, off_t offset, size_t len)
 {
     VMCoreInfoState *s = VMCOREINFO(dev);
+    uint16_t guest_format = le16_to_cpu(s->vmcoreinfo.guest_format);
 
     s->has_vmcoreinfo = offset == 0 && len == sizeof(s->vmcoreinfo)
-        && s->vmcoreinfo.guest_format != FW_CFG_VMCOREINFO_FORMAT_NONE;
+        && guest_format != FW_CFG_VMCOREINFO_FORMAT_NONE;
 }
 
 static void vmcoreinfo_reset(void *dev)
-- 
2.42.0



             reply	other threads:[~2024-07-12  6:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-12  6:24 Ani Sinha [this message]
2024-07-12  7:02 ` [PATCH] hw/vmcoreinfo: make guest format endian safe Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240712062452.31457-1-anisinha@redhat.com \
    --to=anisinha@redhat.com \
    --cc=armbru@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).