ia64/xen-unstable
changeset 17440:115a1720e976
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>
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>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Fri Apr 11 09:10:58 2008 +0100 (2008-04-11) |
parents | bde269270d9a |
children | 1ce8b4e51911 |
files | xen/common/compat/grant_table.c |
line diff
1.1 --- a/xen/common/compat/grant_table.c Fri Apr 11 09:07:58 2008 +0100 1.2 +++ b/xen/common/compat/grant_table.c Fri Apr 11 09:10:58 2008 +0100 1.3 @@ -109,12 +109,24 @@ int compat_grant_table_op(unsigned int c 1.4 rc = -EFAULT; 1.5 else 1.6 { 1.7 - BUG_ON((COMPAT_ARG_XLAT_SIZE - sizeof(*nat.setup)) / sizeof(*nat.setup->frame_list.p) < max_nr_grant_frames); 1.8 + unsigned int max_frame_list_size_in_page = 1.9 + (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.setup)) / 1.10 + sizeof(*nat.setup->frame_list.p); 1.11 + if ( max_frame_list_size_in_page < max_nr_grant_frames ) 1.12 + { 1.13 + gdprintk(XENLOG_WARNING, 1.14 + "max_nr_grant_frames is too large (%u,%u)\n", 1.15 + max_nr_grant_frames, max_frame_list_size_in_page); 1.16 + rc = -EINVAL; 1.17 + } 1.18 + else 1.19 + { 1.20 #define XLAT_gnttab_setup_table_HNDL_frame_list(_d_, _s_) \ 1.21 - set_xen_guest_handle((_d_)->frame_list, (unsigned long *)(nat.setup + 1)) 1.22 - XLAT_gnttab_setup_table(nat.setup, &cmp.setup); 1.23 + set_xen_guest_handle((_d_)->frame_list, (unsigned long *)(nat.setup + 1)) 1.24 + XLAT_gnttab_setup_table(nat.setup, &cmp.setup); 1.25 #undef XLAT_gnttab_setup_table_HNDL_frame_list 1.26 - rc = gnttab_setup_table(guest_handle_cast(nat.uop, gnttab_setup_table_t), 1); 1.27 + rc = gnttab_setup_table(guest_handle_cast(nat.uop, gnttab_setup_table_t), 1); 1.28 + } 1.29 } 1.30 if ( rc == 0 ) 1.31 {