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

[UNIKRAFT PATCH RFCv4 00/35] Impelment virtio_mmio and pci ecam controller for arm64 kvm plat



To support virtio-* family device, we have 2 choices (virtio mmio, virtio pci)
on arm64 kvm plat. This patch series enable the support of virtio mmio and pci.
virtio pci needs pci controller ECAM mode in arm64 Unikraft.

Patch 1-5 implement the platform bus and virtio mmio skeleton.
Patch 8-10 implement the pci ecam skeleton
Patch 12-13 introduce the new probing interface for virtio mmio and pci
      on arm.
Patch 7,11,14,15,16 lib/fdt or ofw/fdt changes
Patch 17-19 split the arch specific pci bus codes into different directory
Else are the bug fixing or minor changes.

Test
====
1. The test case is a simple httpreply app.
test qemu cmdline:
a. for virtio mmio
-device virtio-net-device,id=net1,netdev=hostnet1,mac=52:54:00:09:a4:38
b. for virtio pci
-device 
virtio-net-pci,id=net0,netdev=hostnet0,mac=52:54:00:09:a4:31,disable-modern=on

2. Besides, I also tested it with nginx app which was suggested by Felipe. ping
and wget both worked. But this needs a workaround in libngix app to avoid crash
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 9fcb0eb..3afcb66 100644
@@ -1101,18 +1103,11 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void 
*conf)

     if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) {
         struct group   *grp;
-       struct passwd  *pwd;

         ngx_set_errno(0);
-       pwd = getpwnam(NGX_USER);
-       if (pwd == NULL) {
-           ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
-                         "getpwnam(\"" NGX_USER "\") failed");
-           return NGX_CONF_ERROR;
-       }

         ccf->username = NGX_USER;
-       ccf->user = pwd->pw_uid;
+       ccf->user = 0;

         ngx_set_errno(0);
         grp = getgrnam(NGX_GROUP);
@@ -1193,7 +1188,6 @@ ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void 
*conf)
     ngx_core_conf_t  *ccf = conf;

     char            *group;
-    struct passwd    *pwd;
     struct group     *grp;
     ngx_str_t  *value;

@@ -1214,14 +1208,8 @@ ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void 
*conf)
     ccf->username = (char *) value[1].data;

     ngx_set_errno(0);
-    pwd = getpwnam((const char *) value[1].data);
-    if (pwd == NULL) {
-       ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
-                          "getpwnam(\"%s\") failed", value[1].data);
-       return NGX_CONF_ERROR;
-    }

-    ccf->user = pwd->pw_uid;
+    ccf->user = 0;

     group = (char *) ((cf->args->nelts == 2) ? value[1].data : value[2].data);

Besides, to avoid crashing, the lib posix-user also needs the workaround:
diff --git a/lib/posix-user/user.c b/lib/posix-user/user.c
index 6809d41..c899517 100644
--- a/lib/posix-user/user.c
+++ b/lib/posix-user/user.c
@@ -131,6 +131,7 @@ char *getlogin(void)
 
 void setpwent(void)
 {
+       return;
        iter = UK_SLIST_FIRST(&passwds);
 }
 
@@ -180,6 +181,8 @@ struct passwd *getpwent(void)
 {
        struct passwd *pwd;
 
+       return NULL;
+
        if (iter == NULL)
                return NULL;

This posix-user workaround doesn't need in v3,which might be newly introduced
from v3. This might not be relevant to this patch series itself.

Notes:
======
 - There might be many redundant macro definitions btw arm and x86 in
   pci_bus.h. I will fix it in the future.
 - patch 11 fdt_node_offset_idx_by_compatible_list is also needed in
   Jianyong Wu's rtc patch series. He had posted it, but I still list
   it here for review.

Changes:
========
v4: Add patch 33 and 34. Insert patch 18.
    Rebase the lastest code (patch 17 is significantly changed)
v3: Fix bugs in virtio 9p and arm exception handler to make nginx work
v2: Address the comments from felipe
  - fix the compilation warnings
  - change the better memory barriar for virtio communication
  - fix a bug in virtio-9p
  - make it compilable for individual patch
v1: 
https://lists.xenproject.org/archives/html/minios-devel/2020-03/msg00056.html

---
Jia He (35):
  plat/virtio: Introduce several helpers for virtio ring
  plat/platform: Introduce new platform bus
  plat/virtio: Support virtio_cread/cwrite on arm64
  plat/virtio: Add new virtio_mmio device/driver on arm64
  build: Enable the platform bus and virtio_mmio device on arm64
  plat/kvm: arm64: Fix arm64 memory layout for pcie ecam
  plat/ofw: Export fdt_find_irq_parent_offset
  plat/pci_ecam: Introduce pci/pci_ecam.h
  plat/pci_ecam: Introduce pci ecam skeleton
  lib/ukbus: Adjust default bus register priority
  plat/ofw: Add fdt_node_offset_idx_by_compatible_list
  plat/platform_bus: Add probe/match interface for platform devices
  plat/virtio_mmio: Implement platform probe for virtio_mmio
  plat/ofw: Support completed ranges mapping
  lib/fdt: Fix fdt_address_cell and fdt_size_cell
  plat/ofw: Add fdt_prop_read_bool
  plat/pci_bus: Split specific code into different files
  plat/pci_bus: Pass memory allocation parameter to arch_pci_probe
  plat/pci_bus: arm64: Implement add/probe interfaces on arm64
  build: Make KVM_PCI default enable on arm64
  plat/pci_bus: Change pci_device.base from u16 to unsigned long
  build: Enable pci library on arm64
  plat/pci_ecam: Fix a lot compilation warnings in pci_ecam
  plat/virtio: Fix virtio net device mac negotiation
  plat/virtio: Change irq,base from u16 to u64 on arm64
  plat/virtio: Use better iormb/iowmb on arm64
  plat/platform_bus,virtio_mmio: Avoid useless log storm
  plat/kvm/arm: Add a memory hole at the beginning 128M
  plat/arm: Make sure fpsimd sysregs writing take effects
  plat/virtio_9p: Remove excessive check for max virtqueue size
  plat/virtio_mmio: Fix virtqueue size for virtio 9p device
  plat/arm/generic_timer: Fix assert in ns_to_ticks
  plat/kvm/arm: Fix x19 corruption by interrupt handler
  lib/posix-user: Export several posix-user interfaces
  plat/virtio: Fix the return value check for virtio_cread_bytes_many()

 lib/fdt/exportsyms.uk                       |   1 +
 lib/fdt/fdt_addresses.c                     |  57 +-
 lib/posix-user/exportsyms.uk                |  12 +-
 lib/ukbus/include/uk/bus.h                  |  16 +-
 plat/common/arm/generic_timer.c             |   4 +-
 plat/common/arm/pci_bus_arm64.c             | 201 +++++++
 plat/common/include/arm/arm64/cpu.h         |   6 +
 plat/common/include/arm/arm64/cpu_defs.h    |   3 +
 plat/common/include/pci/pci_bus.h           | 121 ++++-
 plat/common/include/pci/pci_ecam.h          | 101 ++++
 plat/common/include/platform_bus.h          | 116 +++++
 plat/common/pci_bus.c                       | 247 +--------
 plat/common/pci_ecam.c                      | 524 +++++++++++++++++++
 plat/common/platform_bus.c                  | 236 +++++++++
 plat/common/x86/pci_bus_x86.c               | 241 +++++++++
 plat/drivers/include/ofw/fdt.h              |  74 +++
 plat/drivers/include/virtio/virtio_config.h |  73 ++-
 plat/drivers/include/virtio/virtio_mmio.h   | 137 +++++
 plat/drivers/include/virtio/virtqueue.h     |  33 ++
 plat/drivers/ofw/fdt.c                      |  81 ++-
 plat/drivers/virtio/virtio_9p.c             |   6 +-
 plat/drivers/virtio/virtio_mmio.c           | 550 ++++++++++++++++++++
 plat/drivers/virtio/virtio_net.c            |  15 +-
 plat/drivers/virtio/virtio_pci.c            |  11 +-
 plat/drivers/virtio/virtio_ring.c           |  32 ++
 plat/kvm/Config.uk                          |  14 +-
 plat/kvm/Makefile.uk                        |  29 +-
 plat/kvm/arm/exceptions.S                   |   6 +-
 plat/kvm/arm/pagetable64.S                  |  64 ++-
 plat/kvm/include/kvm-arm/arm64/mm.h         |   7 +-
 30 files changed, 2683 insertions(+), 335 deletions(-)
 create mode 100644 plat/common/arm/pci_bus_arm64.c
 create mode 100644 plat/common/include/pci/pci_ecam.h
 create mode 100644 plat/common/include/platform_bus.h
 create mode 100644 plat/common/pci_ecam.c
 create mode 100644 plat/common/platform_bus.c
 create mode 100644 plat/common/x86/pci_bus_x86.c
 create mode 100644 plat/drivers/include/virtio/virtio_mmio.h
 create mode 100644 plat/drivers/virtio/virtio_mmio.c

-- 
2.17.1




 


Rackspace

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