Skip to contentSkip to conversation

Replace hypervisor assert

PATCH New Michael Abd-El-Malek 1 participant 1 message Apr 11, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Replace hypervisor assert

While trying to run a 32-bit PV domU on a 64-bit hypervisor, I triggered an assert in the hypervisor. The assert dealt with the maximum number of grants that a domU can have. I made the hypervisor a bit more graceful by returning an error rather than asserting.

xen/common/compat/grant_table.c +11 -4
diff -r 304d4c6b3bfe -r 2a1818b9d63a xen/common/compat/grant_table.c
@@ -109,12 +109,19 @@ int compat_grant_table_op(unsigned int c
                 rc = -EFAULT;
             else
             {
-                BUG_ON((COMPAT_ARG_XLAT_SIZE - sizeof(*nat.setup)) / sizeof(*nat.setup->frame_list.p) < max_nr_grant_frames);
+                unsigned int max_frame_list_size_in_page =
+                    (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.setup)) / sizeof(*nat.setup->frame_list.p);
+                if (max_frame_list_size_in_page < max_nr_grant_frames) {
+                    printk("max_nr_grant_frames is too large (%u,%u)\n",
+                           max_nr_grant_frames, max_frame_list_size_in_page);
+                    rc = -EINVAL;
+                } else {
 #define XLAT_gnttab_setup_table_HNDL_frame_list(_d_, _s_) \
-                set_xen_guest_handle((_d_)->frame_list, (unsigned long *)(nat.setup + 1))
-                XLAT_gnttab_setup_table(nat.setup, &cmp.setup);
+                    set_xen_guest_handle((_d_)->frame_list, (unsigned long *)(nat.setup + 1))
+                    XLAT_gnttab_setup_table(nat.setup, &cmp.setup);
 #undef XLAT_gnttab_setup_table_HNDL_frame_list
-                rc = gnttab_setup_table(guest_handle_cast(nat.uop, gnttab_setup_table_t), 1);
+                    rc = gnttab_setup_table(guest_handle_cast(nat.uop, gnttab_setup_table_t), 1);
+                }
             }
             if ( rc == 0 )
             {

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