[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 05/11] tools/foreignmem: Support querying the size of a resource
- To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <amc96@xxxxxxxxx>
- Date: Fri, 8 Jan 2021 17:52:36 +0000
- Autocrypt: addr=amc96@xxxxxxxxx; keydata= mQINBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABtB9BbmRyZXcgQ29v cGVyIDxhbWM5NkBjYW0uYWMudWs+iQI4BBMBAgAiBQJYoP3SAhsDBgsJCAcDAgYVCAIJCgsE FgIDAQIeAQIXgAAKCRBlw/kGpdefoOqZEADETHadX+byfQTszP18AjvDxkiOmqKiSBv7JFeB +qW6Egn5mK9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>, Hubert Jasudowicz <hubert.jasudowicz@xxxxxxx>, Tamas K Lengyel <tamas@xxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Andrew Cooper <amc96@xxxxxxxxx>
- Delivery-date: Fri, 08 Jan 2021 17:53:17 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 22/09/2020 19:24, Andrew Cooper wrote:
> diff --git a/tools/libs/foreignmemory/linux.c
> b/tools/libs/foreignmemory/linux.c
> index fe73d5ab72..eec089e232 100644
> --- a/tools/libs/foreignmemory/linux.c
> +++ b/tools/libs/foreignmemory/linux.c
> @@ -339,6 +342,39 @@ int osdep_xenforeignmemory_map_resource(
> return 0;
> }
>
> +int osdep_xenforeignmemory_resource_size(
> + xenforeignmemory_handle *fmem, domid_t domid, unsigned int type,
> + unsigned int id, unsigned long *nr_frames)
> +{
> + int rc;
> + struct xen_mem_acquire_resource *xmar =
> + xencall_alloc_buffer(fmem->xcall, sizeof(*xmar));
> +
> + if ( !xmar )
> + {
> + PERROR("Could not bounce memory for acquire_resource hypercall");
> + return -1;
> + }
> +
> + *xmar = (struct xen_mem_acquire_resource){
> + .domid = domid,
> + .type = type,
> + .id = id,
> + };
> +
> + rc = xencall2(fmem->xcall, __HYPERVISOR_memory_op,
> + XENMEM_acquire_resource, (uintptr_t)xmar);
> + if ( rc )
> + goto out;
> +
> + *nr_frames = xmar->nr_frames;
> +
> + out:
> + xencall_free_buffer(fmem->xcall, xmar);
> +
> + return rc;
> +}
Having talked this through with Roger, it's broken.
In the meantime, foreignmem has gained acquire_resource on FreeBSD.
Nothing in this osdep function is linux-specific, so it oughtn't to be
osdep.
However, its also not permitted to make hypercalls like this in
restricted mode, and that isn't something we should be breaking.
Amongst other things, it will prevent us from supporting >128 cpus, as
Qemu needs updating to use this interface in due course.
The only solution (which keeps restricted mode working) is to fix
Linux's ioctl() to be able to understand size requests. This also
avoids foreignmem needing to open a xencall handle which was fugly in
the first place.
This patch (well - a subset of it) will be needed to remain, to make a
usable interface in userspace.
~Andrew
|