[PATCH v3] virtio: Add uvirtio driver

2020-04-30 Thread Lepton Wu
This is for testing purpose to create virtio devices from user space.
uvirtio-vga.c shows how to create a virtio-vga device.

For "simple" device like virtio 2d VGA, actually we only need to handle
one virtio request which return the resolution of VGA. We provide a
UV_DEV_EXPECT ioctl which set the expected virtio request and the prepared
reply. This can eliminate user/kernel communication. We just handle this in
the notify callback of the virtqueue.

Check samples/uvirtio/uvirtio-vga.c for example.

Currently we don't have a use case which requires user/kernel communication
so read/write API hasn't been implemented.

Signed-off-by: Lepton Wu 
---
v3:
  * Add Documentation/misc-devices/uvirtio.rst
v2:
  * Fix styles issues found by checkpatch.pl
  * Update comments and commit log
---
 Documentation/misc-devices/index.rst   |   1 +
 Documentation/misc-devices/uvirtio.rst |  56 
 drivers/virtio/Kconfig |  11 +
 drivers/virtio/Makefile|   1 +
 drivers/virtio/uvirtio.c   | 399 +
 include/linux/uvirtio.h|  16 +
 include/uapi/linux/uvirtio.h   |  50 
 samples/uvirtio/Makefile   |   9 +
 samples/uvirtio/uvirtio-vga.c  |  72 +
 9 files changed, 615 insertions(+)
 create mode 100644 Documentation/misc-devices/uvirtio.rst
 create mode 100644 drivers/virtio/uvirtio.c
 create mode 100644 include/linux/uvirtio.h
 create mode 100644 include/uapi/linux/uvirtio.h
 create mode 100644 samples/uvirtio/Makefile
 create mode 100644 samples/uvirtio/uvirtio-vga.c

diff --git a/Documentation/misc-devices/index.rst 
b/Documentation/misc-devices/index.rst
index c1dcd2628911..c87d4a8fd42b 100644
--- a/Documentation/misc-devices/index.rst
+++ b/Documentation/misc-devices/index.rst
@@ -21,4 +21,5 @@ fit into other categories.
lis3lv02d
max6875
mic/index
+   uvirtio
xilinx_sdfec
diff --git a/Documentation/misc-devices/uvirtio.rst 
b/Documentation/misc-devices/uvirtio.rst
new file mode 100644
index ..48ba81a00ce0
--- /dev/null
+++ b/Documentation/misc-devices/uvirtio.rst
@@ -0,0 +1,56 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=
+User space created virtio devices
+=
+
+:Authors: - Lepton Wu  - 30 April 2020
+
+Introduction
+
+
+Virtio devices are common in Linux VM guests. In most cases, there is a kernel 
driver in VM guest side and it communicates with VMM via virtio. To use 
specific virtio device, there should be correspond support in VMM side. But in 
some cases, there could be no support for the wanted virtio device at the VMM 
side or even no VMM at all. Uvirtio was developed for this. Instead of 
communicating with VMM, the uvirtio driver checks the virtio requests sent from 
virtio device driver and either "eats" it or replies with a "predefined" reply. 
This model works well for virtio-vga use case.
+
+The ioctl API
+=
+
+To create a virtio device from user space, open /dev/uvirtio device first, then
+call ioctl with UV_DEV_EXPECT cmd to setup expected virtio request and the 
prepared reply. This must be done before calling UV_DEV_CREATE ioctl.
+
+Here is the example to setup that we are expecting one request in control 
queue which has a size of 100 request buffer and we are expecting that the 
offset 10 of the buffer should be "ABC" and the offset 20 of the buffer should 
be "DE"  and also we are expecting the size of reply buffer should be 30. If 
all of these matches, we set the offset of  10 of the reply buffer to "FGH"::
+
+   struct uvirtio_expect expect = { };
+
+   strcpy(expect.expects[0].vq_name, "control");
+
+   struct uvirtio_block *b = [0].blocks[0];
+   b->len = 100;
+   b->flags = VRING_DESC_F_NEXT;
+   b->data = "ABCDE";
+   b->rules[0].off = 10;
+   b->rules[0].len = 3;
+   b->rules[1].off = 20;
+   b->rules[1].len = 2;
+
+   b = [0].blocks[1];
+   b->len = 30;
+   b->flags = VRING_DESC_F_WRITE;
+   b->data = "FGH";
+   b->rules[0].off = 10;
+   b->rules[0].len = 3;
+
+After calling ioctl with UV_DEV_EXPECT cmd, call ioctl with UV_DEV_CREATE cmd 
to create virtio device::
+
+   struct uvirtio_setup setup;
+   struct virtio_gpu_config config = {.num_scanouts = 1 };
+
+   setup.features = 1ULL << VIRTIO_F_VERSION_1;
+   setup.config_addr = (__u64) 
+   setup.config_len = sizeof(config);
+   setup.id = VIRTIO_ID_GPU;
+   setup.flags = 1 << UVIRTIO_DEV_FLAG_STICK;
+   ret = ioctl(fd, UV_DEV_CREATE, );
+
+By default, when the fd is closed, the created virtio device will be 
destroyed. By setting UVIRTIO_DEV_FLAG_STICK, the device won't be removed after 
the fd gets closed.
+
+See samples/uvirtio/uvirito-vga.c for a full example to create

[PATCH v2] virtio: Add uvirtio driver

2020-04-29 Thread Lepton Wu
This is for testing purpose to create virtio devices from user space.
uvirtio-vga.c shows how to create a virtio-vga device.

For "simple" device like virtio 2d VGA, actually we only need to handle
one virtio request which return the resolution of VGA. We provide a
UV_DEV_EXPECT ioctl which set the expected virtio request and the prepared
reply. This can eliminate user/kernel communication. We just handle this in
the notify callback of the virtqueue.

Check samples/uvirtio/uvirtio-vga.c for example.

Currently we don't have a use case which requires user/kernel communication so
read/write api hasn't been implemented.

Signed-off-by: Lepton Wu 
---
v2:
  * Fix styles issues found by checkpatch.pl
  * Update comments and commit log
---
 drivers/virtio/Kconfig|  11 +
 drivers/virtio/Makefile   |   1 +
 drivers/virtio/uvirtio.c  | 399 ++
 include/linux/uvirtio.h   |  16 ++
 include/uapi/linux/uvirtio.h  |  50 +
 samples/uvirtio/Makefile  |   9 +
 samples/uvirtio/uvirtio-vga.c |  72 ++
 7 files changed, 558 insertions(+)
 create mode 100644 drivers/virtio/uvirtio.c
 create mode 100644 include/linux/uvirtio.h
 create mode 100644 include/uapi/linux/uvirtio.h
 create mode 100644 samples/uvirtio/Makefile
 create mode 100644 samples/uvirtio/uvirtio-vga.c

diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index 69a32dfc318a..4686df49cac5 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -109,4 +109,15 @@ config VIRTIO_MMIO_CMDLINE_DEVICES
 
 If unsure, say 'N'.
 
+config UVIRTIO
+   tristate "UVirtio driver"
+   select VIRTIO
+   help
+This driver supports creating virtio devices from userspace.
+
+This can be used to create virtio devices from user space without
+ supports from VMM. Check samples/uvirtio for examples.
+
+If unsure, say 'N'.
+
 endif # VIRTIO_MENU
diff --git a/drivers/virtio/Makefile b/drivers/virtio/Makefile
index 29a1386ecc03..558b2f890e8c 100644
--- a/drivers/virtio/Makefile
+++ b/drivers/virtio/Makefile
@@ -7,3 +7,4 @@ virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o
 obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o
 obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o
 obj-$(CONFIG_VIRTIO_VDPA) += virtio_vdpa.o
+obj-$(CONFIG_UVIRTIO) += uvirtio.o
diff --git a/drivers/virtio/uvirtio.c b/drivers/virtio/uvirtio.c
new file mode 100644
index ..64cc9140de7a
--- /dev/null
+++ b/drivers/virtio/uvirtio.c
@@ -0,0 +1,399 @@
+// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
+/*
+ *  User level device support for virtio subsystem
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define UVIRTIO_MAX_EXPECT_DATA  (1UL << 20)
+
+struct uvirtio_device {
+   struct virtio_device vdev;
+   struct mutex mutex;
+   enum uvirtio_state state;
+   unsigned char virtio_status;
+   struct uvirtio_setup setup;
+   struct uvirtio_expect expect;
+   char *expect_data;
+};
+
+static struct miscdevice uvirtio_misc;
+
+static struct bus_type uvirtio_bus = {
+   .name = "",
+};
+
+static u64 uvirtio_get_features(struct virtio_device *dev)
+{
+   struct uvirtio_device *udev = container_of(dev, struct uvirtio_device,
+  vdev);
+   return udev->setup.features;
+}
+
+static int uvirtio_finalize_features(struct virtio_device *vdev)
+{
+   return 0;
+}
+
+static void uvirtio_get(struct virtio_device *dev, unsigned int offset,
+   void *buf, unsigned int len)
+{
+   struct uvirtio_device *udev = container_of(dev, struct uvirtio_device,
+  vdev);
+   if (WARN_ON(offset + len > udev->setup.config_len))
+   return;
+   memcpy(buf, (char *)udev->setup.config_addr + offset, len);
+}
+
+static u8 uvirtio_get_status(struct virtio_device *dev)
+{
+   struct uvirtio_device *udev = container_of(dev, struct uvirtio_device,
+  vdev);
+   return udev->virtio_status;
+}
+
+static void uvirtio_set_status(struct virtio_device *dev, u8 status)
+{
+   struct uvirtio_device *udev = container_of(dev, struct uvirtio_device,
+  vdev);
+   if (WARN_ON(!status))
+   return;
+   udev->virtio_status = status;
+}
+
+static int find_match(int write, char *buf, unsigned int len,
+ struct uvirtio_block *block, char *data)
+{
+   int i;
+   int off = 0;
+
+   for (i = 0; i < UVIRTIO_MAX_RULES; ++i) {
+   if (!block->rules[i].len)
+   break;
+   if (block->rules[i].off + block->rules[i].len > len)
+   return -1;
+   if (write) {
+   

[PATCH 1/1] virtio: Add uvirtio driver

2020-04-28 Thread Lepton Wu
This is for testing purpose to create virtio devices from user space.
uvirtio-vga.c shows how to create a virtio-vga device. Currently we
don't have a use case which requires user/kernel communication so
read/write api hasn't been implemented.

Signed-off-by: Lepton Wu 
---
 drivers/virtio/Kconfig|   8 +
 drivers/virtio/Makefile   |   1 +
 drivers/virtio/uvirtio.c  | 405 ++
 include/linux/uvirtio.h   |   8 +
 include/uapi/linux/uvirtio.h  |  69 ++
 samples/uvirtio/Makefile  |   9 +
 samples/uvirtio/uvirtio-vga.c |  63 ++
 7 files changed, 563 insertions(+)
 create mode 100644 drivers/virtio/uvirtio.c
 create mode 100644 include/linux/uvirtio.h
 create mode 100644 include/uapi/linux/uvirtio.h
 create mode 100644 samples/uvirtio/Makefile
 create mode 100644 samples/uvirtio/uvirtio-vga.c

diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig
index 69a32dfc318a..8bfb77db4efa 100644
--- a/drivers/virtio/Kconfig
+++ b/drivers/virtio/Kconfig
@@ -109,4 +109,12 @@ config VIRTIO_MMIO_CMDLINE_DEVICES
 
 If unsure, say 'N'.
 
+config UVIRTIO
+   tristate "UVirtio driver"
+   select VIRTIO
+   ---help---
+This driver supports create virtio devices from guest userspace.
+
+If unsure, say 'N'.
+
 endif # VIRTIO_MENU
diff --git a/drivers/virtio/Makefile b/drivers/virtio/Makefile
index 29a1386ecc03..558b2f890e8c 100644
--- a/drivers/virtio/Makefile
+++ b/drivers/virtio/Makefile
@@ -7,3 +7,4 @@ virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o
 obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o
 obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o
 obj-$(CONFIG_VIRTIO_VDPA) += virtio_vdpa.o
+obj-$(CONFIG_UVIRTIO) += uvirtio.o
diff --git a/drivers/virtio/uvirtio.c b/drivers/virtio/uvirtio.c
new file mode 100644
index ..a25107473dab
--- /dev/null
+++ b/drivers/virtio/uvirtio.c
@@ -0,0 +1,405 @@
+/*
+ *  User level driver support for virtio subsystem
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define UVIRTIO_MAX_EXPECT_DATA  (1UL << 20)
+
+struct uvirtio_device {
+   struct virtio_device vdev;
+   struct mutex mutex;
+   enum uvirtio_state state;
+   unsigned char virtio_status;
+   struct uvirtio_setup setup;
+   struct uvirtio_expect expect;
+   char *expect_data;
+};
+
+static struct miscdevice uvirtio_misc;
+
+static struct bus_type uvirtio_bus = {
+   .name = "",
+};
+
+static u64 uvirtio_get_features(struct virtio_device *dev)
+{
+   struct uvirtio_device *udev = container_of(dev, struct uvirtio_device,
+  vdev);
+   return udev->setup.features;
+}
+
+static int uvirtio_finalize_features(struct virtio_device *vdev)
+{
+   return 0;
+}
+
+static void uvirtio_get(struct virtio_device *dev, unsigned int offset,
+   void *buf, unsigned int len)
+{
+   struct uvirtio_device *udev = container_of(dev, struct uvirtio_device,
+  vdev);
+   if (WARN_ON(offset + len > udev->setup.config_len))
+   return;
+   memcpy(buf, (char *)udev->setup.config_addr + offset, len);
+}
+
+static u8 uvirtio_get_status(struct virtio_device *dev)
+{
+   struct uvirtio_device *udev = container_of(dev, struct uvirtio_device,
+  vdev);
+   return udev->virtio_status;
+}
+
+static void uvirtio_set_status(struct virtio_device *dev, u8 status)
+{
+   struct uvirtio_device *udev = container_of(dev, struct uvirtio_device,
+  vdev);
+   if (WARN_ON(!status))
+   return;
+   udev->virtio_status = status;
+}
+
+static int find_match(int write, char *buf, unsigned int len,
+ struct uvirtio_block *block, char *data)
+{
+   int i;
+   int off = 0;
+   for (i = 0; i < UVIRTIO_MAX_RULES; ++i) {
+   if (!block->rules[i].len)
+   break;
+   if (block->rules[i].off + block->rules[i].len > len)
+   return -1;
+   if (write) {
+   memcpy(buf + block->rules[i].off,
+  data + block->data + off, block->rules[i].len);
+   }

[PATCH 0/1] Add uvirtio for testing

2020-04-28 Thread Lepton Wu
This is a way to create virtio based devices from user space. This is the
background for this patch:

We have some images works fine under qemu, we'd like to also run the same image
on Google Cloud. Currently Google Cloud doesn't support virtio-vga. I had a 
patch to create a virtio-vga from kernel directly:
https://www.spinics.net/lists/dri-devel/msg248573.html

Then I got feedback from Gerd that maybe it's better to change that to something
like uvirtio. Since I really don't have other use cases for now, I just 
implemented the minimal stuff which work for my use case.

Lepton Wu (1):
  virtio: Add uvirtio driver

 drivers/virtio/Kconfig|   8 +
 drivers/virtio/Makefile   |   1 +
 drivers/virtio/uvirtio.c  | 405 ++
 include/linux/uvirtio.h   |   8 +
 include/uapi/linux/uvirtio.h  |  69 ++
 samples/uvirtio/Makefile  |   9 +
 samples/uvirtio/uvirtio-vga.c |  63 ++
 7 files changed, 563 insertions(+)
 create mode 100644 drivers/virtio/uvirtio.c
 create mode 100644 include/linux/uvirtio.h
 create mode 100644 include/uapi/linux/uvirtio.h
 create mode 100644 samples/uvirtio/Makefile
 create mode 100644 samples/uvirtio/uvirtio-vga.c

-- 
2.26.2.303.gf8c07b1a785-goog

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH 1/1] proof of concept for GPU forwarding

2019-04-03 Thread Lepton Wu
---
 arch/x86/configs/x86_64_defconfig  |5 +
 drivers/char/Makefile  |1 +
 drivers/char/forwarder/Makefile|8 +
 drivers/char/forwarder/forwarder.h |  103 ++
 drivers/char/forwarder/forwarder_drv.c | 2104 
 fs/open.c  |   18 +
 include/uapi/linux/virtwl.h|   64 +
 tools/forward/Makefile |2 +
 tools/forward/README   |   58 +
 tools/forward/qemu.diff| 1117 +
 tools/forward/wayland-proxy-main.c |   58 +
 tools/forward/wayland-proxy.c  |  297 
 12 files changed, 3835 insertions(+)
 create mode 100644 drivers/char/forwarder/Makefile
 create mode 100644 drivers/char/forwarder/forwarder.h
 create mode 100644 drivers/char/forwarder/forwarder_drv.c
 create mode 100644 include/uapi/linux/virtwl.h
 create mode 100644 tools/forward/Makefile
 create mode 100644 tools/forward/README
 create mode 100644 tools/forward/qemu.diff
 create mode 100644 tools/forward/wayland-proxy-main.c
 create mode 100644 tools/forward/wayland-proxy.c

diff --git a/arch/x86/configs/x86_64_defconfig 
b/arch/x86/configs/x86_64_defconfig
index 1d3badfda09e..6c6e55051d5c 100644
--- a/arch/x86/configs/x86_64_defconfig
+++ b/arch/x86/configs/x86_64_defconfig
@@ -310,3 +310,8 @@ CONFIG_SECURITY_SELINUX_DISABLE=y
 CONFIG_EFI_STUB=y
 CONFIG_EFI_MIXED=y
 CONFIG_ACPI_BGRT=y
+CONFIG_VIRTIO=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_VSOCKETS=y
+CONFIG_VIRTIO_VSOCKETS=y
+CONFIG_VIRTIO_VSOCKETS_COMMON=y
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index fbea7dd12932..af406b6e3e91 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -54,3 +54,4 @@ js-rtc-y = rtc.o
 obj-$(CONFIG_XILLYBUS) += xillybus/
 obj-$(CONFIG_POWERNV_OP_PANEL) += powernv-op-panel.o
 obj-$(CONFIG_ADI)  += adi.o
+obj-y  += forwarder/
diff --git a/drivers/char/forwarder/Makefile b/drivers/char/forwarder/Makefile
new file mode 100644
index ..bc452e51494a
--- /dev/null
+++ b/drivers/char/forwarder/Makefile
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for the drm device driver.  This driver provides support for the
+# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
+
+forwarder-y := forwarder_drv.o
+
+obj-y += forwarder.o
diff --git a/drivers/char/forwarder/forwarder.h 
b/drivers/char/forwarder/forwarder.h
new file mode 100644
index ..4937cebbf7b2
--- /dev/null
+++ b/drivers/char/forwarder/forwarder.h
@@ -0,0 +1,103 @@
+enum {
+   STREAM_MAGIC = 0xbeefc1ea,
+   EVENT_MAGIC,
+   IPC_MAGIC,
+};
+struct pwrite_stream {
+   unsigned int magic;
+   int fd;
+   unsigned int handle;
+   unsigned int offset;
+   unsigned int size;
+};
+
+#define IPC_PAGE_SIZE 32768
+
+#define IPC_COUNT 4
+
+struct ipc {
+  volatile unsigned int seq;
+  unsigned int cmd;
+  union {
+  struct {
+ int arg1;
+ int arg2;
+ int arg3;
+ int pad1;
+ };
+ struct {
+ volatile int64_t ret;
+ int64_t pad2;
+ };
+ struct {
+ int fd;
+ } ioctl;
+ struct {
+ unsigned int pn_count;
+ } hostfd;
+ struct {
+ void* addr;
+ } dmabuf;
+ struct {
+ int fd;
+ unsigned int pn_off;
+ unsigned int pn_count;
+ } mmap;
+ struct {
+ unsigned int pn_off;
+ unsigned int pn_count;
+ } munmap;
+ struct {
+ int fd;
+ int whence;
+ } lseek;
+ struct {
+ int fd;
+ unsigned int len;
+ } fallocate;
+ struct {
+ int fd;
+ unsigned int len;
+ } ftruncate;
+ struct {
+ int fd;
+ uint32_t fdc;
+ uint32_t size;
+ } msg;
+  };
+  char data[0];
+};
+
+#define WL_IOCTL_BASE 'w'
+#define VIRT_WL_MAX 32
+#define WL_IO(nr)  _IO(WL_IOCTL_BASE, nr + VIRT_WL_MAX)
+
+#define WL_CMD_NEW_RENDER_FD WL_IO(0x00)
+#define WL_CMD_NEW_WL_FD WL_IO(0x01)
+#define WL_CMD_NEW_MEM_FD WL_IO(0x02)
+#define WL_CMD_NEW_SYNC_FD WL_IO(0x03)
+#define WL_CMD_RECVMSG WL_IO(0x04)
+#define WL_CMD_SENDMSG WL_IO(0x05)
+#define WL_CMD_MMAP WL_IO(0x06)
+#define WL_CMD_MUNMAP WL_IO(0x07)
+#define WL_CMD_LSEEK WL_IO(0x08)
+#define WL_CMD_CLEAR_COUNTER WL_IO(0x09)
+#define WL_CMD_SHOW_COUNTER WL_IO(0x0A)
+#define WL_CMD_NEW_DMABUF WL_IO(0x0B)
+#define WL_CMD_FALLOCATE WL_IO(0x0C)
+#define WL_CMD_FTRUNCATE WL_IO(0x0D)
+
+#define SW_SYNC_IOC_MAGIC  'W'
+
+struct sw_sync_create_fence_data {
+   unsigned intvalue;
+   charname[32];
+   int fence; /* fd of new fence */
+};
+
+#define 

Proof of concept for GPU forwarding for Linux guest on Linux host.

2019-04-03 Thread Lepton Wu
Hi,

This is a proof of concept of GPU forwarding for Linux guest on Linux host.
I'd like to get comments and suggestions from community before I put more
time on it. To summarize what it is:

1. It's a solution to bring GPU acceleration for Linux vm guest on Linux host.
It could works with different GPU although the current proof of concept only
works with Intel GPU.

2. The basic idea is: under Linux, most applications use GPU acceleration with
help of MESA library. And MESA library interacts with kernel GPU driver by
operating on some special character device file exported by kernel GPU driver.
MESA library opens some special files in system and operations on GPU are done
by ioctl/mmap system call and regular memory operations.

We just write a kernel driver for guest Linux kernel and let it exports same
interface to user space like the real Linux GPU kernel driver. So it's an API 
proxy
between host and VM guest. We just proxy API at system call level. 

3. Some nasty things was done in guest kernel as a quick dirty hack so we don't 
need
to touch user space (wayland/mesa etc) now.

4. You can check tools/forward/README for instructions.

Thanks!

Lepton Wu (1):
  proof of concept for GPU forwarding

 arch/x86/configs/x86_64_defconfig  |5 +
 drivers/char/Makefile  |1 +
 drivers/char/forwarder/Makefile|8 +
 drivers/char/forwarder/forwarder.h |  103 ++
 drivers/char/forwarder/forwarder_drv.c | 2104 
 fs/open.c  |   18 +
 include/uapi/linux/virtwl.h|   64 +
 tools/forward/Makefile |2 +
 tools/forward/README   |   58 +
 tools/forward/qemu.diff| 1117 +
 tools/forward/wayland-proxy-main.c |   58 +
 tools/forward/wayland-proxy.c  |  297 
 12 files changed, 3835 insertions(+)
 create mode 100644 drivers/char/forwarder/Makefile
 create mode 100644 drivers/char/forwarder/forwarder.h
 create mode 100644 drivers/char/forwarder/forwarder_drv.c
 create mode 100644 include/uapi/linux/virtwl.h
 create mode 100644 tools/forward/Makefile
 create mode 100644 tools/forward/README
 create mode 100644 tools/forward/qemu.diff
 create mode 100644 tools/forward/wayland-proxy-main.c
 create mode 100644 tools/forward/wayland-proxy.c

-- 
2.21.0.392.gf8f6787159e-goog

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] drm/cirrus: add create_handle support.

2017-11-22 Thread Lepton Wu
Add create_handle support to cirrus fb. Without this, screenshot tool
in chromium OS can't work.

Signed-off-by: Lepton Wu <ytht@gmail.com>
---
 drivers/gpu/drm/cirrus/cirrus_main.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c 
b/drivers/gpu/drm/cirrus/cirrus_main.c
index b5f528543956..26df1e8cd490 100644
--- a/drivers/gpu/drm/cirrus/cirrus_main.c
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c
@@ -13,6 +13,14 @@
 
 #include "cirrus_drv.h"
 
+static int cirrus_create_handle(struct drm_framebuffer *fb,
+   struct drm_file* file_priv,
+   unsigned int* handle)
+{
+   struct cirrus_framebuffer *cirrus_fb = to_cirrus_framebuffer(fb);
+
+   return drm_gem_handle_create(file_priv, cirrus_fb->obj, handle);
+}
 
 static void cirrus_user_framebuffer_destroy(struct drm_framebuffer *fb)
 {
@@ -24,6 +32,7 @@ static void cirrus_user_framebuffer_destroy(struct 
drm_framebuffer *fb)
 }
 
 static const struct drm_framebuffer_funcs cirrus_fb_funcs = {
+   .create_handle = cirrus_create_handle,
.destroy = cirrus_user_framebuffer_destroy,
 };
 
-- 
2.15.0.403.gc27cc4dac6-goog

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] drm/virtio: add create_handle support.

2017-11-22 Thread Lepton Wu
Add create_handle support to virtio fb. Without this, screenshot tool
in chromium OS can't work.

Signed-off-by: Lepton Wu <ytht@gmail.com>
---
 drivers/gpu/drm/virtio/virtgpu_display.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c 
b/drivers/gpu/drm/virtio/virtgpu_display.c
index b6d52055a11f..274b4206ca96 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -71,7 +71,19 @@ virtio_gpu_framebuffer_surface_dirty(struct drm_framebuffer 
*fb,
return virtio_gpu_surface_dirty(virtio_gpu_fb, clips, num_clips);
 }
 
+static int
+virtio_gpu_framebuffer_create_handle(struct drm_framebuffer *fb,
+struct drm_file *file_priv,
+unsigned int *handle)
+{
+   struct virtio_gpu_framebuffer *virtio_gpu_fb =
+   to_virtio_gpu_framebuffer(fb);
+
+   return drm_gem_handle_create(file_priv, virtio_gpu_fb->obj, handle);
+}
+
 static const struct drm_framebuffer_funcs virtio_gpu_fb_funcs = {
+   .create_handle = virtio_gpu_framebuffer_create_handle,
.destroy = virtio_gpu_user_framebuffer_destroy,
.dirty = virtio_gpu_framebuffer_surface_dirty,
 };
-- 
2.15.0.403.gc27cc4dac6-goog

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization