aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/compat
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-04-11 09:10:58 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-04-11 09:10:58 +0100
commitfd1527b4d20375cd690c12b2bf88e7685aac9305 (patch)
tree747711d090ffd7c7c3da209b08f9d4fbfb5fbfa3 /xen/common/compat
parent8a7227082aab2b401a572d3438cf6e50f3fb545c (diff)
downloadxen-fd1527b4d20375cd690c12b2bf88e7685aac9305.tar.gz
xen-fd1527b4d20375cd690c12b2bf88e7685aac9305.tar.bz2
xen-fd1527b4d20375cd690c12b2bf88e7685aac9305.zip
x86/64 compat: Replace hypervisor BUG_ON() with a cleaner hypercall failure.
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. Signed-off-by: Michael Abd-El-Malek <mabdelmalek@cmu.edu>
Diffstat (limited to 'xen/common/compat')
-rw-r--r--xen/common/compat/grant_table.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/xen/common/compat/grant_table.c b/xen/common/compat/grant_table.c
index 882d435a65..8781a331cf 100644
--- a/xen/common/compat/grant_table.c
+++ b/xen/common/compat/grant_table.c
@@ -109,12 +109,24 @@ int compat_grant_table_op(unsigned int cmd,
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 )
+ {
+ gdprintk(XENLOG_WARNING,
+ "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 )
{