* [PATCH] hw/vmcoreinfo: make guest format endian safe
@ 2024-07-12 6:24 Ani Sinha
2024-07-12 7:02 ` Marc-André Lureau
0 siblings, 1 reply; 2+ messages in thread
From: Ani Sinha @ 2024-07-12 6:24 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: philmd, armbru, Ani Sinha, qemu-devel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] hw/vmcoreinfo: make guest format endian safe
2024-07-12 6:24 [PATCH] hw/vmcoreinfo: make guest format endian safe Ani Sinha
@ 2024-07-12 7:02 ` Marc-André Lureau
0 siblings, 0 replies; 2+ messages in thread
From: Marc-André Lureau @ 2024-07-12 7:02 UTC (permalink / raw)
To: Ani Sinha; +Cc: philmd, armbru, qemu-devel
Hi
On Fri, Jul 12, 2024 at 10:25 AM Ani Sinha <anisinha@redhat.com> wrote:
>
> 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.
>
Looks right, but that shouldn't matter since the comparison is with 0.
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> 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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-12 7:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-12 6:24 [PATCH] hw/vmcoreinfo: make guest format endian safe Ani Sinha
2024-07-12 7:02 ` Marc-André Lureau
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).