Skip to contentSkip to conversation

xc_resume: fix modify_returncode when PV guest width != host width

PATCH In review Brendan Cully 2 participants 4 messages Nov 4, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xc_resume: fix modify_returncode when PV guest width != host width

It seems that xm save -c breaks PV guests when their address width does not match that of domain 0. It looks to me like modify_returncode is treating the guest VCPU context as native format, but honestly I don't quite understand the purpose of vcpu_guest_context_any_t.c.

I suspect I'm missing something obvious about how the compat code is supposed to work, but at any rate, the attached patch fixes things for me.

# HG changeset patch
# User Brendan Cully <[email protected]>
# Date 1257367775 28800
# Node ID 75290c8f350642326b8716f36451bc3f2c67ea10
# Parent a78569c6a570468dc1cdd888b8ef8259fcceaf22
xc_resume: fix modify_returncode when host width != guest width

tools/libxc/xc_resume.c +19 -3
@@ -17,6 +17,7 @@
     xc_dominfo_t info;
     xen_capabilities_info_t caps;
     int rc;
+    int guest_address_size = 0;
 
     if ( xc_domain_getinfo(xc_handle, domid, 1, &info) != 1 )
     {
@@ -32,6 +33,18 @@
         if ( !irq )
             return 0;
     }
+    else
+    {
+	DECLARE_DOMCTL;
+	domctl.domain = domid;
+	domctl.cmd = XEN_DOMCTL_get_address_size;
+	if (xc_domctl(xc_handle, &domctl) != 0)
+	{
+	    PERROR("Could not get guest address size");
+	    return -1;
+	}
+	guest_address_size = domctl.u.address_size.size;
+    }
 
     if ( xc_version(xc_handle, XENVER_capabilities, &caps) != 0 )
     {
@@ -42,9 +55,12 @@
     if ( (rc = xc_vcpu_getcontext(xc_handle, domid, 0, &ctxt)) != 0 )
         return rc;
 
-    if ( !info.hvm )
-        ctxt.c.user_regs.eax = 1;
-    else if ( strstr(caps, "x86_64") )
+    if ( !info.hvm ) {
+	if (guest_address_size == 32)
+	    ctxt.x32.user_regs.eax = 1;
+	else
+	    ctxt.x64.user_regs.eax = 1;
+    } else if ( strstr(caps, "x86_64") )
         ctxt.x64.user_regs.eax = 1;
     else
         ctxt.x32.user_regs.eax = 1;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 8 lines · Brendan Cully

It seems that xm save -c breaks PV guests when their address width does not match that of domain 0. It looks to me like modify_returncode is treating the guest VCPU context as native format, but honestly I don't quite understand the purpose of vcpu_guest_context_any_t.c.

I suspect I'm missing something obvious about how the compat code is supposed to work, but at any rate, the attached patch fixes things for me.

No, the code's just stupid and broken. There's a similar bug in xc_domain_resume_any(), accessing ctxt.c.user_regs.edx. I will fix both.

Thanks,
Keir

#2 lore raw
Quoted 6 lines · Keir Fraser
Quoted 3 lines

I suspect I'm missing something obvious about how the compat code is supposed to work, but at any rate, the attached patch fixes things for me.

No, the code's just stupid and broken. There's a similar bug in xc_domain_resume_any(), accessing ctxt.c.user_regs.edx. I will fix both.

See c/s 20399.

-- Keir

#3 lore raw
Quoted 10 lines · Keir Fraser
Quoted 6 lines · Keir Fraser
Quoted 3 lines

I suspect I'm missing something obvious about how the compat code is supposed to work, but at any rate, the attached patch fixes things for me.

No, the code's just stupid and broken. There's a similar bug in xc_domain_resume_any(), accessing ctxt.c.user_regs.edx. I will fix both.

See c/s 20399.

Works great, thanks!