[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [RFC 0 PATCH 1/3] PVH dom0: create domctl_memory_mapping() function



>>> On 25.09.13 at 23:03, Mukesh Rathor <mukesh.rathor@xxxxxxxxxx> wrote:
> +static long domctl_memory_mapping(struct domain *d, unsigned long gfn,
> +                           unsigned long mfn, unsigned long nr_mfns,
> +                           bool_t add)
> +{
> +    unsigned long i;
> +    long ret;
> +
> +    if ( (mfn + nr_mfns - 1) < mfn || /* wrap? */
> +         ((mfn | (mfn + nr_mfns - 1)) >> (paddr_bits - PAGE_SHIFT)) ||
> +         (gfn + nr_mfns - 1) < gfn ) /* wrap? */
> +        return -EINVAL;
> +
> +    ret = xsm_iomem_mapping(XSM_HOOK, d, mfn, mfn + nr_mfns - 1, add);
> +    if ( ret )
> +        return ret;

Sigh - I said this more than once before: The order of the checks
in the original code _is_ relevant. You can't move the first and
third checks here, but leave the second one there. The way you
use it in the later patch, the function is mis-named, and the
checks aren't needed for that other case anyway (maybe the
XSM one ought to be done, but that's the last check, so can be
moved here if necessary). Hence just leave them in the caller
(and thus retain their proper order).

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.