You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.
CAMLprim value
stub_gntshr_grant_access(value v_ref, value v_iopage, value v_domid, value v_wri
table)
{
grant_ref_t ref = Int_val(v_ref);
void *page = base_page_of(v_iopage);
gntshr_grant_access(ref, page, Int_val(v_domid), !Bool_val(v_writable));
return Val_unit;
}
where base_page_of looks up the data pointer of the Caml_ba_array_val. This means that to share a contiguous batch of pages we need to use Io_page.get_n (allocating a large page-aligned bigarray) and then use Io_page.to_pages to chop the buffer into separate pages, via Bigarray.Array1.sub.
It would be better to call Io_page.(to_cstruct (get_n ...)) and then to chop the Cstruct into pages since Cstruct.sub is cheaper than Bigarray.Array1.sub. We would modify the stub to take a Cstruct and compute the real page pointer by adding the buffer.Cstruct.off field.
Our code is using a mixture of Io_page.t and Cstruct.t which is a bit confusing. I think we sometimes use Io_page.t to guarantee alignment but this means we end up doing Bigarray.Array1.sub more often than we should and, if we don't do that and use Cstruct.sub instead, we have hard-to-find bugs where the wrong page is granted because of base_page_of.
The text was updated successfully, but these errors were encountered:
The stub does this:
where
base_page_of
looks up thedata
pointer of theCaml_ba_array_val
. This means that to share a contiguous batch of pages we need to useIo_page.get_n
(allocating a large page-aligned bigarray) and then useIo_page.to_pages
to chop the buffer into separate pages, viaBigarray.Array1.sub
.It would be better to call
Io_page.(to_cstruct (get_n ...))
and then to chop the Cstruct into pages sinceCstruct.sub
is cheaper thanBigarray.Array1.sub
. We would modify the stub to take a Cstruct and compute the real page pointer by adding thebuffer.Cstruct.off
field.Our code is using a mixture of
Io_page.t
andCstruct.t
which is a bit confusing. I think we sometimes useIo_page.t
to guarantee alignment but this means we end up doingBigarray.Array1.sub
more often than we should and, if we don't do that and useCstruct.sub
instead, we have hard-to-find bugs where the wrong page is granted because ofbase_page_of
.The text was updated successfully, but these errors were encountered: