/* caller must hold write lock */
static int gnttab_get_status_frame_mfn(struct domain *d,
- unsigned long idx, mfn_t *mfn)
+ unsigned int idx, mfn_t *mfn)
{
const struct grant_table *gt = d->grant_table;
if ( idx >= nr_status_frames(gt) )
{
- unsigned long nr_status;
- unsigned long nr_grant;
+ unsigned int nr_status;
+ unsigned int nr_grant;
nr_status = idx + 1; /* sufficient frames to make idx valid */
/* caller must hold write lock */
static int gnttab_get_shared_frame_mfn(struct domain *d,
- unsigned long idx, mfn_t *mfn)
+ unsigned int idx, mfn_t *mfn)
{
const struct grant_table *gt = d->grant_table;
if ( idx >= nr_grant_frames(gt) )
{
- unsigned long nr_grant;
+ unsigned int nr_grant;
nr_grant = idx + 1; /* sufficient frames to make idx valid */
return rc;
}
-int gnttab_get_shared_frame(struct domain *d, unsigned long idx,
+int gnttab_get_shared_frame(struct domain *d, unsigned int idx,
mfn_t *mfn)
{
struct grant_table *gt = d->grant_table;
return rc;
}
-int gnttab_get_status_frame(struct domain *d, unsigned long idx,
+int gnttab_get_status_frame(struct domain *d, unsigned int idx,
mfn_t *mfn)
{
struct grant_table *gt = d->grant_table;
}
int ioreq_server_get_frame(struct domain *d, ioservid_t id,
- unsigned long idx, mfn_t *mfn)
+ unsigned int idx, mfn_t *mfn)
{
struct ioreq_server *s;
int rc;
}
static int acquire_grant_table(struct domain *d, unsigned int id,
- unsigned long frame,
+ unsigned int frame,
unsigned int nr_frames,
xen_pfn_t mfn_list[])
{
static int acquire_ioreq_server(struct domain *d,
unsigned int id,
- unsigned long frame,
+ unsigned int frame,
unsigned int nr_frames,
xen_pfn_t mfn_list[])
{
if ( xmar.nr_frames > ARRAY_SIZE(mfn_list) )
return -E2BIG;
+ /*
+ * The ABI is rather unfortunate. nr_frames (and therefore the total size
+ * of the resource) is 32bit, while frame (the offset within the resource
+ * we'd like to start at) is 64bit.
+ *
+ * Reject values oustide the of the range of nr_frames, as well as
+ * combinations of frame and nr_frame which overflow, to simplify the rest
+ * of the logic.
+ */
+ if ( (xmar.frame >> 32) ||
+ ((xmar.frame + xmar.nr_frames) >> 32) )
+ return -EINVAL;
+
rc = rcu_lock_remote_domain_by_id(xmar.domid, &d);
if ( rc )
return rc;
int gnttab_map_frame(struct domain *d, unsigned long idx, gfn_t gfn,
mfn_t *mfn);
-int gnttab_get_shared_frame(struct domain *d, unsigned long idx,
+int gnttab_get_shared_frame(struct domain *d, unsigned int idx,
mfn_t *mfn);
-int gnttab_get_status_frame(struct domain *d, unsigned long idx,
+int gnttab_get_status_frame(struct domain *d, unsigned int idx,
mfn_t *mfn);
#else
return -EINVAL;
}
-static inline int gnttab_get_shared_frame(struct domain *d, unsigned long idx,
+static inline int gnttab_get_shared_frame(struct domain *d, unsigned int idx,
mfn_t *mfn)
{
return -EINVAL;
}
-static inline int gnttab_get_status_frame(struct domain *d, unsigned long idx,
+static inline int gnttab_get_status_frame(struct domain *d, unsigned int idx,
mfn_t *mfn)
{
return -EINVAL;
bool is_ioreq_server_page(struct domain *d, const struct page_info *page);
int ioreq_server_get_frame(struct domain *d, ioservid_t id,
- unsigned long idx, mfn_t *mfn);
+ unsigned int idx, mfn_t *mfn);
int ioreq_server_map_mem_type(struct domain *d, ioservid_t id,
uint32_t type, uint32_t flags);