From owner-freebsd-virtualization@freebsd.org Tue Jun 30 09:58:13 2015 Return-Path: Delivered-To: freebsd-virtualization@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4448F98CDE7 for ; Tue, 30 Jun 2015 09:58:13 +0000 (UTC) (envelope-from stefanogarzarella@gmail.com) Received: from mail-wi0-x22e.google.com (mail-wi0-x22e.google.com [IPv6:2a00:1450:400c:c05::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DECAB15F6; Tue, 30 Jun 2015 09:58:09 +0000 (UTC) (envelope-from stefanogarzarella@gmail.com) Received: by wibdq8 with SMTP id dq8so11380532wib.1; Tue, 30 Jun 2015 02:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:cc:content-type; bh=TpExZ4dS2fqHFaRR0t11wKbp9F5EZJGJ2LewNv4M+rA=; b=Wa02hbXHEJFVMMLKF564ink05bnXEcU6FhErRKzI/z+EtoiPA4c4AbZnOuuL43ozRa RhwfQrvreyMm4VYmH2Q+Ryn/62EbMAXeSoT1XAKJeYQ04XjoNe4V2jG5UENXv6eEQgkj VuQk7NP3MzUm9bksJvk0qkcuHP9lc6/6neaYWXXhQjIQSI7IaT1fZ3iQW74nGfDxe6/G 1Siva2/ijz0PaixCNkeMab27RiFzHe9+DHRXaTjnpR6NdYAq6BiWDKBbZ0yQ27l435BK bAyF63oIn2I4cgHIlqMQUyfxdcQo+xOImaZaM/1ClI/sZu8iUpIvlpU3Romw03FuxWRy yQMw== X-Received: by 10.194.7.97 with SMTP id i1mr37897459wja.107.1435658287287; Tue, 30 Jun 2015 02:58:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.27.39.135 with HTTP; Tue, 30 Jun 2015 02:57:47 -0700 (PDT) From: Stefano Garzarella Date: Tue, 30 Jun 2015 11:57:47 +0200 Message-ID: Subject: bhyve - map user-space buffer in the VM To: freebsd-virtualization@freebsd.org Cc: Luigi Rizzo , Peter Grehan , Neel Natu , stefano@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2015 09:58:13 -0000 Hi all, I'm working on bhyve to support ptnetmap (netmap passthrough) for my GSoC. http://wiki.freebsd.org/SummerOfCode2015/ptnetmapOnBhyve I've already implemented it on QEMU/KVM and, to expose the netmap memory in the VM, I used a PCI BAR and I mapped the netmap memory (the buffer returned by mmap() on netmap fd in the user space) on the BAR in the VM through KVM API. In bhyve I able to create a PCI BAR but I only found vm_map_pptdev_mmio() API to map physical host page into the VM. I saw that this IOCTL is implemented in the kernel module with sglist_append_phys() to populate a scatter/gather list, than it is mapped in VM. I would like to add a new function in the API to map a user buffer in the VM: int vm_map_user_buf(struct vmctx *ctx, vm_paddr_t gpa, size_t len, void *host_buf) I would implement it adding a new IOCTL and I would create, in the kernel module, a new function like vmm_mmio_alloc() (sys/amd64/vmm/vmm_mem.c) but using sglist_append_user() instead of sglist_append_phys(). What do you think about it? There is another way to map an user-space buffer in the VM? Thanks, Stefano