Skip to contentSkip to conversation

libxc: fix HVM core dump

PATCH Superseded Wei Liu 2 participants 3 messages Mar 19, 2019 – Mar 20, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 libxc: fix HVM core dump

f969bc9fc96 forbid get_address_size call on HVM guests, because that didn't make sense. It broke core dump functionality on HVM because libxc unconditionally asked for guest width.

Only issue the call when necessary in libxc.

---
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: Igor Druzhinin <[email protected]>
Cc: Juergen Gross <[email protected]>

Juergen, this is probably too late for 4.12, but you can at least add a release note somewhere.

Ian, please backport this to 4.12.

---
 tools/libxc/xc_core.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
tools/libxc/xc_core.c +11 -7
index e581905ba9..c825b5b0a0 100644
@@ -459,12 +459,6 @@ xc_domain_dumpcore_via_callback(xc_interface *xch,
     struct xc_core_section_headers *sheaders = NULL;
     Elf64_Shdr *shdr;
  
-    if ( xc_domain_get_guest_width(xch, domid, &dinfo->guest_width) != 0 )
-    {
-        PERROR("Could not get address size for domain");
-        return sts;
-    }
-
     xc_core_arch_context_init(&arch_ctxt);
     if ( (dump_mem_start = malloc(DUMP_INCREMENT*PAGE_SIZE)) == NULL )
     {
@@ -487,6 +481,13 @@ xc_domain_dumpcore_via_callback(xc_interface *xch,
     }
     auto_translated_physmap = xc_core_arch_auto_translated_physmap(&info);
 
+    if ( !auto_translated_physmap &&
+         xc_domain_get_guest_width(xch, domid, &dinfo->guest_width) != 0 )
+    {
+        PERROR("Could not get address size for domain");
+        goto out;
+    }
+
     if ( domid != info.domid )
     {
         PERROR("Domain %d does not exist", domid);
@@ -742,7 +743,10 @@ xc_domain_dumpcore_via_callback(xc_interface *xch,
         goto out;
 
     /* elf note section: xen version */
-    sts = elfnote_dump_xen_version(xch, args, dump_rtn, dinfo->guest_width);
+    sts = elfnote_dump_xen_version(xch, args, dump_rtn,
+                                   auto_translated_physmap ?
+                                   sizeof(unsigned long):
+                                   dinfo->guest_width);
     if ( sts != 0 )
         goto out;
 
Signature · 7 lines
2.20.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

Wei Liu writes ("[PATCH] libxc: fix HVM core dump"):

Quoted 3 lines

f969bc9fc96 forbid get_address_size call on HVM guests, because that didn't make sense. It broke core dump functionality on HVM because libxc unconditionally asked for guest width.

...

tools/libxc/xc_core.c xc_domain_dumpcore_via_callback(xc_interface *xch, · line 489

Quoted 6 lines
tools/libxc/xc_core.c +6 -0
+    if ( !auto_translated_physmap &&
+         xc_domain_get_guest_width(xch, domid, &dinfo->guest_width) != 0 )
+    {
+        PERROR("Could not get address size for domain");
+        goto out;
+    }

Did you consider and reject the option of writing:

    if ( auto_translated_physmap ) {
         ... xc_domain_get_guest_width(,,&dinfo->guest_width,,) ...
    } else {
         dinfo->guest_width = sizeof(unsigned long)
    }

This is perhaps less likely to leave dinfo->guest_width as an uninitialised hazard.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#2 lore raw
Quoted 14 lines · Ian Jackson

Wei Liu writes ("[PATCH] libxc: fix HVM core dump"):

Quoted 3 lines

f969bc9fc96 forbid get_address_size call on HVM guests, because that didn't make sense. It broke core dump functionality on HVM because libxc unconditionally asked for guest width.

...

tools/libxc/xc_core.c xc_domain_dumpcore_via_callback(xc_interface *xch, · line 489

Quoted 6 lines
tools/libxc/xc_core.c +6 -0
+    if ( !auto_translated_physmap &&
+         xc_domain_get_guest_width(xch, domid, &dinfo->guest_width) != 0 )
+    {
+        PERROR("Could not get address size for domain");
+        goto out;
+    }

Did you consider and reject the option of writing:

Quoted 8 lines
    if ( auto_translated_physmap ) {
         ... xc_domain_get_guest_width(,,&dinfo->guest_width,,) ...
    } else {
         dinfo->guest_width = sizeof(unsigned long)
    }

This is perhaps less likely to leave dinfo->guest_width as an uninitialised hazard.

Works for me too.

Wei.

Quoted 2 lines

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel