diff options
author | Jan Beulich <jbeulich@suse.com> | 2013-03-04 10:16:04 +0100 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2013-03-04 10:16:04 +0100 |
commit | 7ffc9779aa5120c5098d938cb88f69a1dda9a0fe (patch) | |
tree | 14fafc8697f4eccf496d2592990da17e6080ca71 /xen/common/compat | |
parent | 53decd322157e922cac2988e07da6d39538c8033 (diff) | |
download | xen-7ffc9779aa5120c5098d938cb88f69a1dda9a0fe.tar.gz xen-7ffc9779aa5120c5098d938cb88f69a1dda9a0fe.tar.bz2 xen-7ffc9779aa5120c5098d938cb88f69a1dda9a0fe.zip |
x86: make certain memory sub-ops return valid values
When a domain's shared info field "max_pfn" is zero,
domain_get_maximum_gpfn() so far returned ULONG_MAX, which
do_memory_op() in turn converted to -1 (i.e. -EPERM). Make the former
always return a sensible number (i.e. zero if the field was zero) and
have the latter no longer truncate return values.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
Diffstat (limited to 'xen/common/compat')
-rw-r--r-- | xen/common/compat/memory.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/xen/common/compat/memory.c b/xen/common/compat/memory.c index caa24ccbe6..ba7e6eb0b9 100644 --- a/xen/common/compat/memory.c +++ b/xen/common/compat/memory.c @@ -15,7 +15,8 @@ CHECK_TYPE(domid); int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) { - int rc, split, op = cmd & MEMOP_CMD_MASK; + int split, op = cmd & MEMOP_CMD_MASK; + long rc; unsigned int start_extent = cmd >> MEMOP_EXTENT_SHIFT; do @@ -204,7 +205,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) rc = do_memory_op(cmd, nat.hnd); if ( rc < 0 ) - return rc; + break; cmd = 0; if ( hypercall_xlat_continuation(&cmd, 0x02, nat.hnd, compat) ) @@ -326,5 +327,11 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) compat) __HYPERVISOR_memory_op, "ih", cmd, compat); } while ( split > 0 ); + if ( unlikely(rc > INT_MAX) ) + return INT_MAX; + + if ( unlikely(rc < INT_MIN) ) + return INT_MIN; + return rc; } |