Hi Juergen,
On 13/09/17 16:46, Juergen Gross wrote:
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index 00ff075bd9..a462ea7905 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -3608,6 +3608,44 @@ int mem_sharing_gref_to_gfn(struct grant_table *gt,
grant_ref_t ref,
}
#endif
+int gnttab_map_frame(struct domain *d, unsigned long idx, gfn_t gfn,
+ mfn_t *mfn)
+{
+ int rc = 0;
+ struct grant_table *gt = d->grant_table;
+
+ grant_write_lock(gt);
+
+ if ( gt->gt_version == 0 )
+ gt->gt_version = 1;
+
+ if ( gt->gt_version == 2 &&
+ (idx & XENMAPIDX_grant_table_status) )
+ {
+ idx &= ~XENMAPIDX_grant_table_status;
+ if ( idx < nr_status_frames(gt) )
+ *mfn = _mfn(virt_to_mfn(gt->status[idx]));
+ else
+ rc = -EINVAL;
+ }
+ else
+ {
+ if ( (idx >= nr_grant_frames(gt)) && (idx < max_grant_frames) )
+ gnttab_grow_table(d, idx + 1);
+
+ if ( idx < nr_grant_frames(gt) )
+ *mfn = _mfn(virt_to_mfn(gt->shared_raw[idx]));
+ else
+ rc = -EINVAL;
+ }
+
+ gnttab_set_frame_gfn(d, idx, gfn);
This code is slightly different compare to the ARM implementation. The
gfn is now set even if the rc is non-zero (i.e invalid MFN on the ARM
implementation).
So I think you need to protect gnttab_set_frame_gfn with if ( !rc ).
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel