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

Re: [PATCH v2] libs/foreignmemory: Implement on NetBSD


  • To: Manuel Bouyer <bouyer@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 28 Jan 2021 10:52:39 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PZp6KBApJWLYiI/HO8K2wjBb0lBlTqCL0T9SoRbpcQA=; b=JXlu9vmcJAA0VrlROYYvNEPLRpLTc6mgMqiZbNKAW78LWDymlHuu0Yhk4puhPnscdbl44vmMR76aQZnfdBgHzUl7myI3Y1adiXYj69zELPd+X6N0LeyWfNCiLMfud2+GzrjugDclJjX6OIBojaZAxU6Otix5YPiiJJTakZT1BBY0Sfjx5nIrVEFoDFjRqSEAF/zDDSmiBHcd2QItNv573iQcBGZSxhv1NSdy/NZVs4F6ZwJUsLVHWnZhR7C6Rs+6t/xHH9Tgqi5+rQ1vSIeQorkR9xpMDvFw2et7+FfWz/0IVWd+E+63Arem2XoeTrkZoE9Yi8nLdSCwRtkKGsZdvg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wobd3wvW6P0g91yOXM7JpGMAXXYPUA8UzJkjTL1XuOZc9yYd8CwtaRnlLsR/tFx+3hIxPc7rMMSm8TQpDGPfV09KdlaR/TvPHrq4tCQZcbm7adwgNb2jLBpgUeZM7sOs5kxaSJxZv6HaW9ZvsBvc3ljgMY5iXuafmGiUFsnWwlLiXi5834imMCcscTa0KUK7/24DCC02CjYeVgja/0o5YSao1Aq8kTdF6h9T2y3QH+BeIrS8rV0vCO7sANnViqRYcHqAm4Zeie+6hUDwFyiRI1J5t8/ulf3YgmDsgTiw3JLDRi+D1Po1F0nQYgMmy9NDhPWflEMSYYgZP4Ohg4IRiA==
  • Authentication-results: esa5.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 28 Jan 2021 10:52:53 +0000
  • Ironport-sdr: MEvGA/AAhsr2tcG4lOJDhD9876rTDlU+rwqSruniW04S18qWGoG5jPYlZCX2Jmsa7GR9mX+0gu lg5MkUEriHJDGZyA//+4hAcce8IOvPEbi50X4qm5wvO5QIL4oBMtjbBR6/vF8GoVDdQcEoFz3c U1DMruTFNENdn+dfZpvpuxDU/liq2Sz3vn2uGlvqaXGy/2hUqGBl/mRjKs3j6vmnhHkOs35Vmd Foqc83+RUst67Qq8lGXrWpA6Vk9Y8bZzzgBLasDyUjKm0/7q4wR+ZZSH9gFw84ObyIFq0jjUpK oUg=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26/01/2021 22:47, Manuel Bouyer wrote:
> diff --git a/tools/libs/foreignmemory/netbsd.c 
> b/tools/libs/foreignmemory/netbsd.c
> index 54a418ebd6..a7e1d72ffc 100644
> --- a/tools/libs/foreignmemory/netbsd.c
> +++ b/tools/libs/foreignmemory/netbsd.c
> @@ -97,7 +102,48 @@ void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, 
> uint32_t dom,
>  int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
>                                   void *addr, size_t num)
>  {
> -    return munmap(addr, num*XC_PAGE_SIZE);
> +    return munmap(addr, num*PAGE_SIZE);
> +}
> +
> +int osdep_xenforeignmemory_restrict(xenforeignmemory_handle *fmem,
> +                                    domid_t domid)
> +{
> +    errno = EOPNOTSUPP;
> +    return -1;
> +}
> +
> +int osdep_xenforeignmemory_unmap_resource(
> +    xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres)
> +{
> +    return fres ? munmap(fres->addr, fres->nr_frames << PAGE_SHIFT) : 0;
> +}
> +
> +int osdep_xenforeignmemory_map_resource(
> +    xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres)
> +{
> +    privcmd_mmap_resource_t mr = {
> +        .dom = fres->domid,
> +        .type = fres->type,
> +        .id = fres->id,
> +        .idx = fres->frame,
> +        .num = fres->nr_frames,
> +    };
> +    int rc;
> +
> +    fres->addr = mmap(fres->addr, fres->nr_frames << PAGE_SHIFT,
> +                      fres->prot, fres->flags | MAP_ANON | MAP_SHARED, -1, 
> 0);
> +    if ( fres->addr == MAP_FAILED )
> +        return -1;
> +
> +    mr.addr = (uintptr_t)fres->addr;
> +
> +    rc = ioctl(fmem->fd, IOCTL_PRIVCMD_MMAP_RESOURCE, &mr);
> +    if ( rc )
> +    {
> +        PERROR("ioctl failed");

return -1;

I was rebasing my resource_size fix over this patch.

It would be easiest for me if I fix up and commit this patch, if
everyone is happy with that.

~Andrew



 


Rackspace

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