Skip to contentSkip to conversation

hyperv: VMBus implementation

PATCH Superseded Jon Doron 5 participants 26 messages Apr 3, 2020 – May 12, 2020 Kbuild

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jon Doron

author
#0 lore raw

cover hyperv: VMBus implementation

This is a rebase of the old patchset from Roman for HyperV VMBus implementation.

How to use:
-device vmbus-bridge

Later on new paravirtualized devices can be implemented on top of it (Network/SCSI/etc.)

Jon Doron (5):
hyperv: expose API to determine if synic is enabled
hyperv: SControl is optional to enable SynIc
vmbus: add vmbus protocol definitions
vmbus: vmbus implementation
i386: Hyper-V VMBus ACPI DSDT entry

 Makefile.objs                  |    1 +
 hw/Kconfig                     |    1 +
 hw/Makefile.objs               |    1 +
 hw/hyperv/hyperv.c             |  250 ++--
 hw/i386/Kconfig                |    1 +
 hw/i386/acpi-build.c           |   42 +
 hw/i386/pc_q35.c               |    2 +
 hw/vmbus/Kconfig               |    3 +
 hw/vmbus/Makefile.objs         |    1 +
 hw/vmbus/trace-events          |    8 +
 hw/vmbus/vmbus.c               | 2422 ++++++++++++++++++++++++++++++++
 include/hw/hyperv/hyperv.h     |    3 +
 include/hw/vmbus/vmbus-proto.h |  222 +++
 include/hw/vmbus/vmbus.h       |  109 ++
 target/i386/hyperv.c           |    2 +
 15 files changed, 2986 insertions(+), 82 deletions(-)
 create mode 100644 hw/vmbus/Kconfig
 create mode 100644 hw/vmbus/Makefile.objs
 create mode 100644 hw/vmbus/trace-events
 create mode 100644 hw/vmbus/vmbus.c
 create mode 100644 include/hw/vmbus/vmbus-proto.h
 create mode 100644 include/hw/vmbus/vmbus.h
Signature · 1 line
2.24.1
author
#1 lore raw

PATCH 1/5 hyperv: expose API to determine if synic is enabled

---
 hw/hyperv/hyperv.c         | 8 ++++++++
 include/hw/hyperv/hyperv.h | 1 +
 2 files changed, 9 insertions(+)
hw/hyperv/hyperv.c +8 -0
index 8ca3706f5b..ddf4f32c60 100644
@@ -37,6 +37,13 @@ typedef struct SynICState {
 #define TYPE_SYNIC "hyperv-synic"
 #define SYNIC(obj) OBJECT_CHECK(SynICState, (obj), TYPE_SYNIC)
 
+static bool synic_enabled;
+
+bool hyperv_is_synic_enabled(void)
+{
+    return synic_enabled;
+}
+
 static SynICState *get_synic(CPUState *cs)
 {
     return SYNIC(object_resolve_path_component(OBJECT(cs), "synic"));
@@ -133,6 +140,7 @@ void hyperv_synic_add(CPUState *cs)
     object_property_add_child(OBJECT(cs), "synic", obj, &error_abort);
     object_unref(obj);
     object_property_set_bool(obj, true, "realized", &error_abort);
+    synic_enabled = true;
 }
 
 void hyperv_synic_reset(CPUState *cs)
include/hw/hyperv/hyperv.h +1 -0
index 597381cb01..a63ee0003c 100644
@@ -79,5 +79,6 @@ void hyperv_synic_add(CPUState *cs);
 void hyperv_synic_reset(CPUState *cs);
 void hyperv_synic_update(CPUState *cs, bool enable,
                          hwaddr msg_page_addr, hwaddr event_page_addr);
+bool hyperv_is_synic_enabled(void);
 
 #endif
Signature · 1 line
2.24.1
author
#2 lore raw

PATCH 2/5 hyperv: SControl is optional to enable SynIc

In reply to Jon Doron

SynIc can be enabled regardless of the SControl mechanisim which can register a GSI for a given SintRoute.

This behaviour can achived by setting enabling SIMP and then the guest will poll on the message slot.

Once there is another message pending the host will set the message slot with the pending flag.
When the guest polls from the message slot, incase the pending flag is set it will write to the HV_X64_MSR_EOM indicating it has cleared the slow and we can try and push our message again.

---
 hw/hyperv/hyperv.c         | 242 ++++++++++++++++++++++++-------------
 include/hw/hyperv/hyperv.h |   2 +
 target/i386/hyperv.c       |   2 +
 3 files changed, 164 insertions(+), 82 deletions(-)
hw/hyperv/hyperv.c +160 -82
index ddf4f32c60..1dc577a0ab 100644
@@ -20,18 +20,72 @@
 #include "qemu/rcu_queue.h"
 #include "hw/hyperv/hyperv.h"
 
+/*
+ * KVM has its own message producers (SynIC timers).  To guarantee
+ * serialization with both KVM vcpu and the guest cpu, the messages are first
+ * staged in an intermediate area and then posted to the SynIC message page in
+ * the vcpu thread.
+ */
+typedef struct HvSintStagedMessage {
+    /* message content staged by hyperv_post_msg */
+    struct hyperv_message msg;
+    /* callback + data (r/o) to complete the processing in a BH */
+    HvSintMsgCb cb;
+    void *cb_data;
+    /* message posting status filled by cpu_post_msg */
+    int status;
+    /* passing the buck: */
+    enum {
+        /* initial state */
+        HV_STAGED_MSG_FREE,
+        /*
+         * hyperv_post_msg (e.g. in main loop) grabs the staged area (FREE ->
+         * BUSY), copies msg, and schedules cpu_post_msg on the assigned cpu
+         */
+        HV_STAGED_MSG_BUSY,
+        /*
+         * cpu_post_msg (vcpu thread) tries to copy staged msg to msg slot,
+         * notify the guest, records the status, marks the posting done (BUSY
+         * -> POSTED), and schedules sint_msg_bh BH
+         */
+        HV_STAGED_MSG_POSTED,
+        /*
+         * sint_msg_bh (BH) verifies that the posting is done, runs the
+         * callback, and starts over (POSTED -> FREE)
+         */
+    } state;
+} HvSintStagedMessage;
+
+struct SynICState;
+
+struct HvSintRoute {
+    uint32_t sint;
+    struct SynICState *synic;
+    int gsi;
+    EventNotifier sint_set_notifier;
+    EventNotifier sint_ack_notifier;
+
+    HvSintStagedMessage *staged_msg;
+
+    unsigned refcount;
+    QLIST_ENTRY(HvSintRoute) link;
+};
+
 typedef struct SynICState {
     DeviceState parent_obj;
 
     CPUState *cs;
 
-    bool enabled;
+    bool sctl_enabled;
     hwaddr msg_page_addr;
     hwaddr event_page_addr;
     MemoryRegion msg_page_mr;
     MemoryRegion event_page_mr;
     struct hyperv_message_page *msg_page;
     struct hyperv_event_flags_page *event_page;
+
+    QemuMutex sint_routes_mutex;
+    QLIST_HEAD(, HvSintRoute) sint_routes;
 } SynICState;
 
 #define TYPE_SYNIC "hyperv-synic"
@@ -49,11 +103,11 @@ static SynICState *get_synic(CPUState *cs)
     return SYNIC(object_resolve_path_component(OBJECT(cs), "synic"));
 }
 
-static void synic_update(SynICState *synic, bool enable,
+static void synic_update(SynICState *synic, bool sctl_enable,
                          hwaddr msg_page_addr, hwaddr event_page_addr)
 {
 
-    synic->enabled = enable;
+    synic->sctl_enabled = sctl_enable;
     if (synic->msg_page_addr != msg_page_addr) {
         if (synic->msg_page_addr) {
             memory_region_del_subregion(get_system_memory(),
@@ -78,7 +132,7 @@ static void synic_update(SynICState *synic, bool enable,
     }
 }
 
-void hyperv_synic_update(CPUState *cs, bool enable,
+void hyperv_synic_update(CPUState *cs, bool sctl_enable,
                          hwaddr msg_page_addr, hwaddr event_page_addr)
 {
     SynICState *synic = get_synic(cs);
@@ -87,7 +141,7 @@ void hyperv_synic_update(CPUState *cs, bool enable,
         return;
     }
 
-    synic_update(synic, enable, msg_page_addr, event_page_addr);
+    synic_update(synic, sctl_enable, msg_page_addr, event_page_addr);
 }
 
 static void synic_realize(DeviceState *dev, Error **errp)
@@ -108,16 +162,20 @@ static void synic_realize(DeviceState *dev, Error **errp)
                            sizeof(*synic->event_page), &error_abort);
     synic->msg_page = memory_region_get_ram_ptr(&synic->msg_page_mr);
     synic->event_page = memory_region_get_ram_ptr(&synic->event_page_mr);
+    qemu_mutex_init(&synic->sint_routes_mutex);
+    QLIST_INIT(&synic->sint_routes);
 
     g_free(msgp_name);
     g_free(eventp_name);
 }
+
 static void synic_reset(DeviceState *dev)
 {
     SynICState *synic = SYNIC(dev);
     memset(synic->msg_page, 0, sizeof(*synic->msg_page));
     memset(synic->event_page, 0, sizeof(*synic->event_page));
     synic_update(synic, false, 0, 0);
+    assert(QLIST_EMPTY(&synic->sint_routes));
 }
 
 static void synic_class_init(ObjectClass *klass, void *data)
@@ -166,54 +224,6 @@ static void synic_register_types(void)
 
 type_init(synic_register_types)
 
-/*
- * KVM has its own message producers (SynIC timers).  To guarantee
- * serialization with both KVM vcpu and the guest cpu, the messages are first
- * staged in an intermediate area and then posted to the SynIC message page in
- * the vcpu thread.
- */
-typedef struct HvSintStagedMessage {
-    /* message content staged by hyperv_post_msg */
-    struct hyperv_message msg;
-    /* callback + data (r/o) to complete the processing in a BH */
-    HvSintMsgCb cb;
-    void *cb_data;
-    /* message posting status filled by cpu_post_msg */
-    int status;
-    /* passing the buck: */
-    enum {
-        /* initial state */
-        HV_STAGED_MSG_FREE,
-        /*
-         * hyperv_post_msg (e.g. in main loop) grabs the staged area (FREE ->
-         * BUSY), copies msg, and schedules cpu_post_msg on the assigned cpu
-         */
-        HV_STAGED_MSG_BUSY,
-        /*
-         * cpu_post_msg (vcpu thread) tries to copy staged msg to msg slot,
-         * notify the guest, records the status, marks the posting done (BUSY
-         * -> POSTED), and schedules sint_msg_bh BH
-         */
-        HV_STAGED_MSG_POSTED,
-        /*
-         * sint_msg_bh (BH) verifies that the posting is done, runs the
-         * callback, and starts over (POSTED -> FREE)
-         */
-    } state;
-} HvSintStagedMessage;
-
-struct HvSintRoute {
-    uint32_t sint;
-    SynICState *synic;
-    int gsi;
-    EventNotifier sint_set_notifier;
-    EventNotifier sint_ack_notifier;
-
-    HvSintStagedMessage *staged_msg;
-
-    unsigned refcount;
-};
-
 static CPUState *hyperv_find_vcpu(uint32_t vp_index)
 {
     CPUState *cs = qemu_get_cpu(vp_index);
@@ -257,7 +267,7 @@ static void cpu_post_msg(CPUState *cs, run_on_cpu_data data)
 
     assert(staged_msg->state == HV_STAGED_MSG_BUSY);
 
-    if (!synic->enabled || !synic->msg_page_addr) {
+    if (!synic->msg_page_addr) {
         staged_msg->status = -ENXIO;
         goto posted;
     }
@@ -341,7 +351,7 @@ int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno)
     if (eventno > HV_EVENT_FLAGS_COUNT) {
         return -EINVAL;
     }
-    if (!synic->enabled || !synic->event_page_addr) {
+    if (!synic->sctl_enabled || !synic->event_page_addr) {
         return -ENXIO;
     }
 
@@ -362,11 +372,13 @@ int hyperv_set_event_flag(HvSintRoute *sint_route, unsigned eventno)
 HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
                                    HvSintMsgCb cb, void *cb_data)
 {
-    HvSintRoute *sint_route;
-    EventNotifier *ack_notifier;
+    HvSintRoute *sint_route = NULL;
+    EventNotifier *ack_notifier = NULL;
     int r, gsi;
     CPUState *cs;
     SynICState *synic;
+    bool ack_event_initialized = false, sint_notifier_initialized = false,
+         irqfd_initialized = false;
 
     cs = hyperv_find_vcpu(vp_index);
     if (!cs) {
@@ -379,57 +391,82 @@ HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint,
     }
 
     sint_route = g_new0(HvSintRoute, 1);
-    r = event_notifier_init(&sint_route->sint_set_notifier, false);
-    if (r) {
-        goto err;
+    if (!sint_route) {
+        goto cleanup_err;
     }
 
+    sint_route->gsi = 0;
+    sint_route->synic = synic;
+    sint_route->sint = sint;
+    sint_route->refcount = 1;
 
     ack_notifier = cb ? &sint_route->sint_ack_notifier : NULL;
     if (ack_notifier) {
         sint_route->staged_msg = g_new0(HvSintStagedMessage, 1);
+        if (!sint_route->staged_msg) {
+            goto cleanup_err;
+        }
         sint_route->staged_msg->cb = cb;
         sint_route->staged_msg->cb_data = cb_data;
 
         r = event_notifier_init(ack_notifier, false);
         if (r) {
-            goto err_sint_set_notifier;
+            goto cleanup_err;
         }
-
         event_notifier_set_handler(ack_notifier, sint_ack_handler);
+        ack_event_initialized = true;
+    }
+
+    /* See if we are done or we need to setup a GSI for this SintRoute */
+    if (!synic->sctl_enabled) {
+        goto cleanup;
+    }
+
+    /* We need to setup a GSI for this SintRoute */
+    r = event_notifier_init(&sint_route->sint_set_notifier, false);
+    if (r) {
+        goto cleanup_err;
     }
+    sint_notifier_initialized = true;
 
     gsi = kvm_irqchip_add_hv_sint_route(kvm_state, vp_index, sint);
     if (gsi < 0) {
-        goto err_gsi;
+        goto cleanup_err;
     }
+    irqfd_initialized = true;
 
     r = kvm_irqchip_add_irqfd_notifier_gsi(kvm_state,
                                            &sint_route->sint_set_notifier,
                                            ack_notifier, gsi);
     if (r) {
-        goto err_irqfd;
+        goto cleanup_err;
     }
     sint_route->gsi = gsi;
-    sint_route->synic = synic;
-    sint_route->sint = sint;
-    sint_route->refcount = 1;
-
+cleanup:
+    qemu_mutex_lock(&synic->sint_routes_mutex);
+    QLIST_INSERT_HEAD_RCU(&synic->sint_routes, sint_route, link);
+    qemu_mutex_unlock(&synic->sint_routes_mutex);
     return sint_route;
 
-err_irqfd:
-    kvm_irqchip_release_virq(kvm_state, gsi);
-err_gsi:
+cleanup_err:
+    if (irqfd_initialized) {
+        kvm_irqchip_release_virq(kvm_state, gsi);
+    }
+
+    if (sint_notifier_initialized) {
+        event_notifier_cleanup(&sint_route->sint_set_notifier);
+    }
+
     if (ack_notifier) {
-        event_notifier_set_handler(ack_notifier, NULL);
-        event_notifier_cleanup(ack_notifier);
+        if (ack_event_initialized) {
+            event_notifier_set_handler(ack_notifier, NULL);
+            event_notifier_cleanup(ack_notifier);
+        }
+
         g_free(sint_route->staged_msg);
     }
-err_sint_set_notifier:
-    event_notifier_cleanup(&sint_route->sint_set_notifier);
-err:
-    g_free(sint_route);
 
+    g_free(sint_route);
     return NULL;
 }
 
@@ -440,6 +477,8 @@ void hyperv_sint_route_ref(HvSintRoute *sint_route)
 
 void hyperv_sint_route_unref(HvSintRoute *sint_route)
 {
+    SynICState *synic;
+
     if (!sint_route) {
         return;
     }
@@ -450,21 +489,33 @@ void hyperv_sint_route_unref(HvSintRoute *sint_route)
         return;
     }
 
-    kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state,
-                                          &sint_route->sint_set_notifier,
-                                          sint_route->gsi);
-    kvm_irqchip_release_virq(kvm_state, sint_route->gsi);
+    synic = sint_route->synic;
+    qemu_mutex_lock(&synic->sint_routes_mutex);
+    QLIST_REMOVE_RCU(sint_route, link);
+    qemu_mutex_unlock(&synic->sint_routes_mutex);
+
+    if (sint_route->gsi) {
+        kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state,
+                                              &sint_route->sint_set_notifier,
+                                              sint_route->gsi);
+        kvm_irqchip_release_virq(kvm_state, sint_route->gsi);
+        event_notifier_cleanup(&sint_route->sint_set_notifier);
+    }
+
     if (sint_route->staged_msg) {
         event_notifier_set_handler(&sint_route->sint_ack_notifier, NULL);
         event_notifier_cleanup(&sint_route->sint_ack_notifier);
         g_free(sint_route->staged_msg);
     }
-    event_notifier_cleanup(&sint_route->sint_set_notifier);
     g_free(sint_route);
 }
 
 int hyperv_sint_route_set_sint(HvSintRoute *sint_route)
 {
+    if (!sint_route->gsi) {
+        return 0;
+    }
+
     return event_notifier_set(&sint_route->sint_set_notifier);
 }
 
@@ -528,6 +579,33 @@ unlock:
     return ret;
 }
 
+int hyperv_synic_eom(CPUState *cs)
+{
+    SynICState *synic = get_synic(cs);
+    HvSintRoute *sint_route;
+
+    if (!synic) {
+        return -1;
+    }
+
+    qemu_mutex_lock(&synic->sint_routes_mutex);
+    QLIST_FOREACH(sint_route, &synic->sint_routes, link) {
+        HvSintStagedMessage *staged_msg = sint_route->staged_msg;
+
+        /* Skip a SintRoute that has a GSI registered with it */
+        if (sint_route->gsi ||
+            atomic_read(&staged_msg->state) != HV_STAGED_MSG_POSTED) {
+            continue;
+        }
+
+        aio_bh_schedule_oneshot(qemu_get_aio_context(), sint_msg_bh,
+                                sint_route);
+    }
+    qemu_mutex_unlock(&synic->sint_routes_mutex);
+
+    return 0;
+}
+
 uint16_t hyperv_hcall_post_message(uint64_t param, bool fast)
 {
     uint16_t ret;
include/hw/hyperv/hyperv.h +2 -0
index a63ee0003c..ef9f6b6c09 100644
@@ -28,6 +28,8 @@ void hyperv_sint_route_unref(HvSintRoute *sint_route);
 
 int hyperv_sint_route_set_sint(HvSintRoute *sint_route);
 
+int hyperv_synic_eom(CPUState *cs);
+
 /*
  * Submit a message to be posted in vcpu context.  If the submission succeeds,
  * the status of posting the message is reported via the callback associated
target/i386/hyperv.c +2 -0
index 26efc1e0e6..f11268df48 100644
@@ -66,6 +66,8 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit)
         case HV_X64_MSR_SIEFP:
             env->msr_hv_synic_evt_page = exit->u.synic.evt_page;
             break;
+        case HV_X64_MSR_EOM:
+            return hyperv_synic_eom(CPU(cpu));
         default:
             return -1;
         }
Signature · 1 line
2.24.1
author
#3 lore raw

PATCH 3/5 vmbus: add vmbus protocol definitions

In reply to Jon Doron

Add a header with data structures and constants used in Hyper-V VMBus hypervisor <-> guest interactions.

Based on the respective stuff from Linux kernel.

---
 include/hw/vmbus/vmbus-proto.h | 222 +++++++++++++++++++++++++++++++++
 1 file changed, 222 insertions(+)
 create mode 100644 include/hw/vmbus/vmbus-proto.h
include/hw/vmbus/vmbus-proto.h new file +222 -0
new file mode 100644
index 0000000000..80882e4fc6
@@ -0,0 +1,222 @@
+/*
+ * QEMU Hyper-V VMBus support
+ *
+ * Copyright (c) 2017-2018 Virtuozzo International GmbH.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef VMBUS_PROTO_H
+#define VMBUS_PROTO_H
+
+#define VMBUS_VERSION_WS2008                    ((0 << 16) | (13))
+#define VMBUS_VERSION_WIN7                      ((1 << 16) | (1))
+#define VMBUS_VERSION_WIN8                      ((2 << 16) | (4))
+#define VMBUS_VERSION_WIN8_1                    ((3 << 16) | (0))
+#define VMBUS_VERSION_WIN10                     ((4 << 16) | (0))
+#define VMBUS_VERSION_INVAL                     -1
+#define VMBUS_VERSION_CURRENT                   VMBUS_VERSION_WIN10
+
+#define VMBUS_MESSAGE_CONNECTION_ID             1
+#define VMBUS_EVENT_CONNECTION_ID               2
+#define VMBUS_MONITOR_CONNECTION_ID             3
+#define VMBUS_SINT                              2
+
+#define VMBUS_MSG_INVALID               0
+#define VMBUS_MSG_OFFERCHANNEL          1
+#define VMBUS_MSG_RESCIND_CHANNELOFFER  2
+#define VMBUS_MSG_REQUESTOFFERS         3
+#define VMBUS_MSG_ALLOFFERS_DELIVERED   4
+#define VMBUS_MSG_OPENCHANNEL           5
+#define VMBUS_MSG_OPENCHANNEL_RESULT    6
+#define VMBUS_MSG_CLOSECHANNEL          7
+#define VMBUS_MSG_GPADL_HEADER          8
+#define VMBUS_MSG_GPADL_BODY            9
+#define VMBUS_MSG_GPADL_CREATED         10
+#define VMBUS_MSG_GPADL_TEARDOWN        11
+#define VMBUS_MSG_GPADL_TORNDOWN        12
+#define VMBUS_MSG_RELID_RELEASED        13
+#define VMBUS_MSG_INITIATE_CONTACT      14
+#define VMBUS_MSG_VERSION_RESPONSE      15
+#define VMBUS_MSG_UNLOAD                16
+#define VMBUS_MSG_UNLOAD_RESPONSE       17
+#define VMBUS_MSG_COUNT                 18
+
+#define VMBUS_MESSAGE_SIZE_ALIGN        sizeof(uint64_t)
+
+#define VMBUS_PACKET_INVALID                    0x0
+#define VMBUS_PACKET_SYNCH                      0x1
+#define VMBUS_PACKET_ADD_XFER_PAGESET           0x2
+#define VMBUS_PACKET_RM_XFER_PAGESET            0x3
+#define VMBUS_PACKET_ESTABLISH_GPADL            0x4
+#define VMBUS_PACKET_TEARDOWN_GPADL             0x5
+#define VMBUS_PACKET_DATA_INBAND                0x6
+#define VMBUS_PACKET_DATA_USING_XFER_PAGES      0x7
+#define VMBUS_PACKET_DATA_USING_GPADL           0x8
+#define VMBUS_PACKET_DATA_USING_GPA_DIRECT      0x9
+#define VMBUS_PACKET_CANCEL_REQUEST             0xa
+#define VMBUS_PACKET_COMP                       0xb
+#define VMBUS_PACKET_DATA_USING_ADDITIONAL_PKT  0xc
+#define VMBUS_PACKET_ADDITIONAL_DATA            0xd
+
+#define VMBUS_CHANNEL_USER_DATA_SIZE            120
+
+#define VMBUS_OFFER_MONITOR_ALLOCATED           0x1
+#define VMBUS_OFFER_INTERRUPT_DEDICATED         0x1
+
+#define VMBUS_RING_BUFFER_FEAT_PENDING_SZ       (1ul << 0)
+
+#define VMBUS_CHANNEL_ENUMERATE_DEVICE_INTERFACE      0x1
+#define VMBUS_CHANNEL_SERVER_SUPPORTS_TRANSFER_PAGES  0x2
+#define VMBUS_CHANNEL_SERVER_SUPPORTS_GPADLS          0x4
+#define VMBUS_CHANNEL_NAMED_PIPE_MODE                 0x10
+#define VMBUS_CHANNEL_LOOPBACK_OFFER                  0x100
+#define VMBUS_CHANNEL_PARENT_OFFER                    0x200
+#define VMBUS_CHANNEL_REQUEST_MONITORED_NOTIFICATION  0x400
+#define VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER            0x2000
+
+#define VMBUS_PACKET_FLAG_REQUEST_COMPLETION    1
+
+typedef struct vmbus_message_header {
+    uint32_t message_type;
+    uint32_t _padding;
+} vmbus_message_header;
+
+typedef struct vmbus_message_initiate_contact {
+    vmbus_message_header header;
+    uint32_t version_requested;
+    uint32_t target_vcpu;
+    uint64_t interrupt_page;
+    uint64_t monitor_page1;
+    uint64_t monitor_page2;
+} vmbus_message_initiate_contact;
+
+typedef struct vmbus_message_version_response {
+    vmbus_message_header header;
+    uint8_t version_supported;
+    uint8_t status;
+} vmbus_message_version_response;
+
+typedef struct vmbus_message_offer_channel {
+    vmbus_message_header header;
+    uint8_t  type_uuid[16];
+    uint8_t  instance_uuid[16];
+    uint64_t _reserved1;
+    uint64_t _reserved2;
+    uint16_t channel_flags;
+    uint16_t mmio_size_mb;
+    uint8_t  user_data[VMBUS_CHANNEL_USER_DATA_SIZE];
+    uint16_t sub_channel_index;
+    uint16_t _reserved3;
+    uint32_t child_relid;
+    uint8_t  monitor_id;
+    uint8_t  monitor_flags;      // VMBUS_OFFER_MONITOR_*
+    uint16_t interrupt_flags;    // VMBUS_OFFER_INTERRUPT_*
+    uint32_t connection_id;
+} vmbus_message_offer_channel;
+
+typedef struct vmbus_message_rescind_channel_offer {
+    vmbus_message_header header;
+    uint32_t child_relid;
+} vmbus_message_rescind_channel_offer;
+
+typedef struct vmbus_gpa_range {
+    uint32_t byte_count;
+    uint32_t byte_offset;
+    uint64_t pfn_array[0];
+} vmbus_gpa_range;
+
+typedef struct vmbus_message_gpadl_header {
+    vmbus_message_header header;
+    uint32_t child_relid;
+    uint32_t gpadl_id;
+    uint16_t range_buflen;
+    uint16_t rangecount;
+    vmbus_gpa_range range;
+} QEMU_PACKED vmbus_message_gpadl_header;
+
+typedef struct vmbus_message_gpadl_body {
+    vmbus_message_header header;
+    uint32_t message_number;
+    uint32_t gpadl_id;
+    uint64_t pfn_array[0];
+} vmbus_message_gpadl_body;
+
+typedef struct vmbus_message_gpadl_created {
+    vmbus_message_header header;
+    uint32_t child_relid;
+    uint32_t gpadl_id;
+    uint32_t status;
+} vmbus_message_gpadl_created;
+
+typedef struct vmbus_message_gpadl_teardown {
+    vmbus_message_header header;
+    uint32_t child_relid;
+    uint32_t gpadl_id;
+} vmbus_message_gpadl_teardown;
+
+typedef struct vmbus_message_gpadl_torndown {
+    vmbus_message_header header;
+    uint32_t gpadl_id;
+} vmbus_message_gpadl_torndown;
+
+typedef struct vmbus_message_open_channel {
+    vmbus_message_header header;
+    uint32_t child_relid;
+    uint32_t open_id;
+    uint32_t ring_buffer_gpadl_id;
+    uint32_t target_vp;
+    uint32_t ring_buffer_offset;
+    uint8_t  user_data[VMBUS_CHANNEL_USER_DATA_SIZE];
+} vmbus_message_open_channel;
+
+typedef struct vmbus_message_open_result {
+    vmbus_message_header header;
+    uint32_t child_relid;
+    uint32_t open_id;
+    uint32_t status;
+} vmbus_message_open_result;
+
+typedef struct vmbus_message_close_channel {
+    vmbus_message_header header;
+    uint32_t child_relid;
+} vmbus_message_close_channel;
+
+typedef struct vmbus_ring_buffer {
+    uint32_t write_index;
+    uint32_t read_index;
+    uint32_t interrupt_mask;
+    uint32_t pending_send_sz;
+    uint32_t _reserved1[12];
+    uint32_t feature_bits;     // VMBUS_RING_BUFFER_FEAT_*
+} vmbus_ring_buffer;
+
+typedef struct vmbus_packet_hdr {
+    uint16_t type;
+    uint16_t offset_qwords;
+    uint16_t len_qwords;
+    uint16_t flags;
+    uint64_t transaction_id;
+} vmbus_packet_hdr;
+
+typedef struct vmbus_pkt_gpa_direct {
+    uint32_t _reserved;
+    uint32_t rangecount;
+    vmbus_gpa_range range[0];
+} vmbus_pkt_gpa_direct;
+
+typedef struct vmbus_xferpg_range {
+    uint32_t byte_count;
+    uint32_t byte_offset;
+} vmbus_xferpg_range;
+
+typedef struct vmbus_pkt_xferpg {
+    uint16_t buffer_id;
+    uint8_t sender_owns_set;
+    uint8_t _reserved;
+    uint32_t rangecount;
+    vmbus_xferpg_range range[0];
+} vmbus_pkt_xferpg;
+
+#endif
Signature · 1 line
2.24.1
author
#4 lore raw

PATCH 4/5 vmbus: vmbus implementation

In reply to Jon Doron

Add the VMBus infrastructure -- bus, devices, root bridge, vmbus state machine, vmbus channel interactions, etc.

TODO:
- split into smaller palatable pieces
- more comments
- check and handle corner cases

Kudos to Evgeny Yakovlev (formerly [email protected]) and Andrey Smetatin (formerly [email protected]) for research and prototyping.

VMBus is a collection of technologies. At its lowest layer, it's a message passing and signaling mechanism, allowing efficient passing of messages to and from guest VMs. A layer higher, it's a mechanism for defining channels of communication, where each channel is tagged with a type (which implies a protocol) and a instance ID. A layer higher than that, it's a bus driver, serving as the basis of device enumeration within a VM, where a channel can optionally be exposed as a paravirtual device. When a server-side (paravirtual back-end) component wishes to offer a channel to a guest VM, it does so by specifying a channel type, a mode, and an instance ID. VMBus then exposes this in the guest.

More information about VMBus can be found in the file vmbuskernelmodeclientlibapi.h in Microsoft's WDK.

---
 Makefile.objs            |    1 +
 hw/Kconfig               |    1 +
 hw/Makefile.objs         |    1 +
 hw/i386/Kconfig          |    1 +
 hw/i386/pc_q35.c         |    2 +
 hw/vmbus/Kconfig         |    3 +
 hw/vmbus/Makefile.objs   |    1 +
 hw/vmbus/trace-events    |    8 +
 hw/vmbus/vmbus.c         | 2422 ++++++++++++++++++++++++++++++++++++++
 include/hw/vmbus/vmbus.h |  109 ++
 10 files changed, 2549 insertions(+)
 create mode 100644 hw/vmbus/Kconfig
 create mode 100644 hw/vmbus/Makefile.objs
 create mode 100644 hw/vmbus/trace-events
 create mode 100644 hw/vmbus/vmbus.c
 create mode 100644 include/hw/vmbus/vmbus.h
Makefile.objs +1 -0
index a7c967633a..4943e7bf73 100644
@@ -185,6 +185,7 @@ trace-events-subdirs += hw/watchdog
 trace-events-subdirs += hw/xen
 trace-events-subdirs += hw/gpio
 trace-events-subdirs += hw/riscv
+trace-events-subdirs += hw/vmbus
 trace-events-subdirs += migration
 trace-events-subdirs += net
 trace-events-subdirs += ui
hw/Kconfig +1 -0
index ecf491bf04..49ace0a4b5 100644
@@ -39,6 +39,7 @@ source usb/Kconfig
 source virtio/Kconfig
 source vfio/Kconfig
 source watchdog/Kconfig
+source vmbus/Kconfig
 
 # arch Kconfig
 source arm/Kconfig
hw/Makefile.objs +1 -0
index 660e2b4373..9037bc8095 100644
@@ -40,6 +40,7 @@ devices-dirs-$(CONFIG_MEM_DEVICE) += mem/
 devices-dirs-$(CONFIG_NUBUS) += nubus/
 devices-dirs-y += semihosting/
 devices-dirs-y += smbios/
+devices-dirs-$(CONFIG_VMBUS) += vmbus/
 endif
 
 common-obj-y += $(devices-dirs-y)
hw/i386/Kconfig +1 -0
index c93f32f657..838ec28667 100644
@@ -23,6 +23,7 @@ config PC
     imply TPM_TIS_ISA
     imply VGA_PCI
     imply VIRTIO_VGA
+    imply VMBUS
     select FDC
     select I8259
     select I8254
hw/i386/pc_q35.c +2 -0
index d37c425e22..767c137718 100644
@@ -54,6 +54,7 @@
 #include "qemu/error-report.h"
 #include "sysemu/numa.h"
 #include "hw/mem/nvdimm.h"
+#include "hw/vmbus/vmbus.h"
 
 /* ICH9 AHCI has 6 ports */
 #define MAX_SATA_PORTS     6
@@ -346,6 +347,7 @@ static void pc_q35_machine_options(MachineClass *m)
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_AMD_IOMMU_DEVICE);
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE);
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
+    machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE);
     m->max_cpus = 288;
 }
 
hw/vmbus/Kconfig new file +3 -0
new file mode 100644
index 0000000000..e925c2a9be
@@ -0,0 +1,3 @@
+config VMBUS
+    bool
+    depends on HYPERV
hw/vmbus/Makefile.objs new file +1 -0
new file mode 100644
index 0000000000..3f0708588e
@@ -0,0 +1 @@
+obj-y += vmbus.o
hw/vmbus/trace-events new file +8 -0
new file mode 100644
index 0000000000..4e1c507cb8
@@ -0,0 +1,8 @@
+# vmbus
+vmbus_initiate_contact(uint32_t version, uint32_t vcpu, uint64_t monitor_page1, uint64_t monitor_page2, uint64_t interrupt_page) "version requested %d, target vcpu %d, monitor pages 0x%"PRIx64" 0x%"PRIx64", interrupt page 0x%"PRIx64""
+vmbus_recv_message(uint32_t type, uint32_t size) "recvd message type %d, size %d"
+vmbus_signal_event(void) "vmbus event signaled"
+vmbus_signal_channel(uint32_t relid) "signaling channel id %d"
+vmbus_post_msg(uint32_t type, uint32_t size) "posting message type %d, size %d"
+vmbus_post_reply_callback(int status) "staged message status %d"
+vmbus_process_incoming_message(uint32_t message_type) "processing incoming message %d"
hw/vmbus/vmbus.c new file +2422 -0

2,422 lines not on this page · raw message

include/hw/vmbus/vmbus.h new file +109 -0

109 lines not on this page · raw message

Signature · 1 line
2.24.1
author
#5 lore raw

PATCH 5/5 i386: Hyper-V VMBus ACPI DSDT entry

In reply to Jon Doron

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel port conflicting with vmbus.

TODO: discover and use spare IRQs to avoid conflicts.

---
 hw/i386/acpi-build.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
hw/i386/acpi-build.c +42 -0
index 2a7e55bae7..6d7fdbbe9b 100644
@@ -43,6 +43,7 @@
 #include "hw/acpi/tpm.h"
 #include "hw/acpi/vmgenid.h"
 #include "hw/boards.h"
+#include "hw/vmbus/vmbus.h"
 #include "sysemu/tpm_backend.h"
 #include "hw/rtc/mc146818rtc_regs.h"
 #include "migration/vmstate.h"
@@ -1270,6 +1271,43 @@ static Aml *build_com_device_aml(uint8_t uid)
     return dev;
 }
 
+static Aml *build_vmbus_device_aml(void)
+{
+    Aml *dev;
+    Aml *method;
+    Aml *crs;
+
+    dev = aml_device("VMBS");
+    aml_append(dev, aml_name_decl("STA", aml_int(0xF)));
+    aml_append(dev, aml_name_decl("_HID", aml_string("VMBus")));
+    aml_append(dev, aml_name_decl("_UID", aml_int(0x0)));
+    aml_append(dev, aml_name_decl("_DDN", aml_string("VMBUS")));
+
+    method = aml_method("_DIS", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_and(aml_name("STA"), aml_int(0xD), NULL),
+                                     aml_name("STA")));
+    aml_append(dev, method);
+
+    method = aml_method("_PS0", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_or(aml_name("STA"), aml_int(0xF), NULL),
+                                     aml_name("STA")));
+    aml_append(dev, method);
+
+    method = aml_method("_STA", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_name("STA"), aml_local(0)));
+    aml_append(method, aml_return(aml_local(0)));
+    aml_append(dev, method);
+
+    aml_append(dev, aml_name_decl("_PS3", aml_int(0x0)));
+
+    crs = aml_resource_template();
+    aml_append(crs, aml_irq_no_flags(7));
+    aml_append(crs, aml_irq_no_flags(13));
+    aml_append(dev, aml_name_decl("_CRS", crs));
+
+    return dev;
+}
+
 static void build_isa_devices_aml(Aml *table)
 {
     ISADevice *fdc = pc_find_fdc0();
@@ -1296,6 +1334,10 @@ static void build_isa_devices_aml(Aml *table)
         build_acpi_ipmi_devices(scope, BUS(obj), "\\_SB.PCI0.ISA");
     }
 
+    if (vmbus_exists()) {
+        aml_append(scope, build_vmbus_device_aml());
+    }
+
     aml_append(table, scope);
 }
 
Signature · 1 line
2.24.1
#6 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Hi Jon,

Quoted 8 lines · Jon Doron

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel port conflicting with vmbus.

Quoted 5 lines

TODO: discover and use spare IRQs to avoid conflicts.

Nice work, thanks!

However, it seems to be based on the code version that was posted in February 2018, and not the latest version in OpenVZ qemu repository dated October 2019:
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus

This newer version has slightly different API here and there. Any particular reason for selecting that older version for porting?

I have actually rebased this latest version on the top of the current QEMU master, and it basically seems to work fine.
However, I haven't done extensive tests whether there isn't a memory leak somewhere or so on.

Maciej

author
#7 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Thank you Maciej, I based it on top of what Denis ([email protected]) gave me which was this:
https://ftp.openvz.org/virtuozzo/releases/openvz-7.0.12-288/source/SRPMS/q/qemu-kvm-vz-2.12.0-33.vz7.14.4.src.rpm

Do you think you have a more recent version I dont mind diffing and resubmitting a new version of the patchset?

Thanks,
-- Jon.

Quoted 34 lines · Maciej S. Szmigiero

Hi Jon,

Quoted 8 lines · Jon Doron

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel port conflicting with vmbus.

Quoted 5 lines

TODO: discover and use spare IRQs to avoid conflicts.

Nice work, thanks!

However, it seems to be based on the code version that was posted in February 2018, and not the latest version in OpenVZ qemu repository dated October 2019:
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus

This newer version has slightly different API here and there. Any particular reason for selecting that older version for porting?

I have actually rebased this latest version on the top of the current QEMU master, and it basically seems to work fine.
However, I haven't done extensive tests whether there isn't a memory leak somewhere or so on.

Maciej

author
#8 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Thank you Maciej it seems like your version is really ahead I'll do
the required work and merge it so i can submit a v2 with the latest patchset from Roman

Quoted 47 lines · Jon Doron

Thank you Maciej, I based it on top of what Denis ([email protected]) gave me which was this:
https://ftp.openvz.org/virtuozzo/releases/openvz-7.0.12-288/source/SRPMS/q/qemu-kvm-vz-2.12.0-33.vz7.14.4.src.rpm

Do you think you have a more recent version I dont mind diffing and resubmitting a new version of the patchset?

Thanks,
-- Jon.

Quoted 34 lines · Maciej S. Szmigiero

Hi Jon,

Quoted 8 lines · Jon Doron

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel port conflicting with vmbus.

Quoted 5 lines

TODO: discover and use spare IRQs to avoid conflicts.

Nice work, thanks!

However, it seems to be based on the code version that was posted in February 2018, and not the latest version in OpenVZ qemu repository dated October 2019:
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus

This newer version has slightly different API here and there. Any particular reason for selecting that older version for porting?

I have actually rebased this latest version on the top of the current QEMU master, and it basically seems to work fine.
However, I haven't done extensive tests whether there isn't a memory leak somewhere or so on.

Maciej

#9 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Thanks Jon,

I will push out to what I have in a moment.

Maciej

Quoted 52 lines · Jon Doron

Thank you Maciej it seems like your version is really ahead I'll do
the required work and merge it so i can submit a v2 with the latest patchset from Roman

Quoted 47 lines · Jon Doron

Thank you Maciej, I based it on top of what Denis ([email protected]) gave me which was this:
https://ftp.openvz.org/virtuozzo/releases/openvz-7.0.12-288/source/SRPMS/q/qemu-kvm-vz-2.12.0-33.vz7.14.4.src.rpm

Do you think you have a more recent version I dont mind diffing and resubmitting a new version of the patchset?

Thanks,
-- Jon.

Quoted 34 lines · Maciej S. Szmigiero

Hi Jon,

Quoted 8 lines · Jon Doron

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel port conflicting with vmbus.

Quoted 5 lines

TODO: discover and use spare IRQs to avoid conflicts.

Nice work, thanks!

However, it seems to be based on the code version that was posted in February 2018, and not the latest version in OpenVZ qemu repository dated October 2019:
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus

This newer version has slightly different API here and there. Any particular reason for selecting that older version for porting?

I have actually rebased this latest version on the top of the current QEMU master, and it basically seems to work fine.
However, I haven't done extensive tests whether there isn't a memory leak somewhere or so on.

Maciej

#10 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

In reply to Jon Doron

Hi Jon,

The patches are available here:
https://github.com/maciejsszmigiero/qemu.git in "vmbus-patches" branch.

Please note that these patches don't have Roman's "Signed-off-by:" tags, so I haven't applied mine, either.

If you are able to establish a proper SoB chain then please also add:
"Signed-off-by: Maciej S. Szmigiero <[email protected]>".

Thanks for the effort,
Maciej

Quoted 52 lines · Jon Doron

Thank you Maciej it seems like your version is really ahead I'll do
the required work and merge it so i can submit a v2 with the latest patchset from Roman

Quoted 47 lines · Jon Doron

Thank you Maciej, I based it on top of what Denis ([email protected]) gave me which was this:
https://ftp.openvz.org/virtuozzo/releases/openvz-7.0.12-288/source/SRPMS/q/qemu-kvm-vz-2.12.0-33.vz7.14.4.src.rpm

Do you think you have a more recent version I dont mind diffing and resubmitting a new version of the patchset?

Thanks,
-- Jon.

Quoted 34 lines · Maciej S. Szmigiero

Hi Jon,

Quoted 8 lines · Jon Doron

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel port conflicting with vmbus.

Quoted 5 lines

TODO: discover and use spare IRQs to avoid conflicts.

Nice work, thanks!

However, it seems to be based on the code version that was posted in February 2018, and not the latest version in OpenVZ qemu repository dated October 2019:
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus

This newer version has slightly different API here and there. Any particular reason for selecting that older version for porting?

I have actually rebased this latest version on the top of the current QEMU master, and it basically seems to work fine.
However, I haven't done extensive tests whether there isn't a memory leak somewhere or so on.

Maciej

#11 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

It seems to me that Roman might not be getting our e-mails since his new e-mail address seems to be "[email protected]".

@Roman, are you with us?

Thanks,
Maciej

Quoted 68 lines · Maciej S. Szmigiero

Hi Jon,

The patches are available here:
https://github.com/maciejsszmigiero/qemu.git in "vmbus-patches" branch.

Please note that these patches don't have Roman's "Signed-off-by:" tags, so I haven't applied mine, either.

If you are able to establish a proper SoB chain then please also add:
"Signed-off-by: Maciej S. Szmigiero <[email protected]>".

Thanks for the effort,
Maciej

Quoted 52 lines · Jon Doron

Thank you Maciej it seems like your version is really ahead I'll do
the required work and merge it so i can submit a v2 with the latest patchset from Roman

Quoted 47 lines · Jon Doron

Thank you Maciej, I based it on top of what Denis ([email protected]) gave me which was this:
https://ftp.openvz.org/virtuozzo/releases/openvz-7.0.12-288/source/SRPMS/q/qemu-kvm-vz-2.12.0-33.vz7.14.4.src.rpm

Do you think you have a more recent version I dont mind diffing and resubmitting a new version of the patchset?

Thanks,
-- Jon.

Quoted 34 lines · Maciej S. Szmigiero

Hi Jon,

Quoted 8 lines · Jon Doron

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel port conflicting with vmbus.

Quoted 5 lines

TODO: discover and use spare IRQs to avoid conflicts.

Nice work, thanks!

However, it seems to be based on the code version that was posted in February 2018, and not the latest version in OpenVZ qemu repository dated October 2019:
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus

This newer version has slightly different API here and there. Any particular reason for selecting that older version for porting?

I have actually rebased this latest version on the top of the current QEMU master, and it basically seems to work fine.
However, I haven't done extensive tests whether there isn't a memory leak somewhere or so on.

Maciej

#12 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Quoted 2 lines · Maciej S. Szmigiero

It seems to me that Roman might not be getting our e-mails since his new e-mail address seems to be "[email protected]".

Indeed. I'm subscribed with my new address to qemu-devel ML but must have missed this series.

Quoted 1 line

@Roman, are you with us?

Yes ;)

So what are your plans regarding this patchset?

Thanks,
Roman.

Quoted 70 lines · Maciej S. Szmigiero
Quoted 68 lines

Hi Jon,

The patches are available here:
https://github.com/maciejsszmigiero/qemu.git in "vmbus-patches" branch.

Please note that these patches don't have Roman's "Signed-off-by:" tags, so I haven't applied mine, either.

If you are able to establish a proper SoB chain then please also add:
"Signed-off-by: Maciej S. Szmigiero <[email protected]>".

Thanks for the effort,
Maciej

Quoted 52 lines · Jon Doron

Thank you Maciej it seems like your version is really ahead I'll do
the required work and merge it so i can submit a v2 with the latest patchset from Roman

Quoted 47 lines · Jon Doron

Thank you Maciej, I based it on top of what Denis ([email protected]) gave me which was this:
https://ftp.openvz.org/virtuozzo/releases/openvz-7.0.12-288/source/SRPMS/q/qemu-kvm-vz-2.12.0-33.vz7.14.4.src.rpm

Do you think you have a more recent version I dont mind diffing and resubmitting a new version of the patchset?

Thanks,
-- Jon.

Quoted 34 lines · Maciej S. Szmigiero

Hi Jon,

Quoted 8 lines · Jon Doron

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel port conflicting with vmbus.

Quoted 5 lines

TODO: discover and use spare IRQs to avoid conflicts.

Nice work, thanks!

However, it seems to be based on the code version that was posted in February 2018, and not the latest version in OpenVZ qemu repository dated October 2019:
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus

This newer version has slightly different API here and there. Any particular reason for selecting that older version for porting?

I have actually rebased this latest version on the top of the current QEMU master, and it basically seems to work fine.
However, I haven't done extensive tests whether there isn't a memory leak somewhere or so on.

Maciej

author
#13 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Well I want it to be merged in :-)

Quoted 95 lines · On Mon, Apr 6, 2020, 10:32 Roman Kagan <[email protected]> wrote:
Quoted 2 lines · Maciej S. Szmigiero

It seems to me that Roman might not be getting our e-mails since his new e-mail address seems to be "[email protected]".

Indeed. I'm subscribed with my new address to qemu-devel ML but must have missed this series.

Quoted 1 line

@Roman, are you with us?

Yes ;)

So what are your plans regarding this patchset?

Thanks,
Roman.

Quoted 5 lines · Maciej S. Szmigiero
Quoted 4 lines

Hi Jon,

The patches are available here:
https://github.com/maciejsszmigiero/qemu.git in "vmbus-patches"

branch.

Quoted 2 lines
Quoted 2 lines

Please note that these patches don't have Roman's "Signed-off-by:"

tags,

Quoted 8 lines
Quoted 8 lines

so I haven't applied mine, either.

If you are able to establish a proper SoB chain then please also add:
"Signed-off-by: Maciej S. Szmigiero <[email protected]>".

Thanks for the effort,
Maciej

Quoted 8 lines
Quoted 8 lines · Jon Doron
Quoted 7 lines

Thank you Maciej it seems like your version is really ahead I'll do
the required work and merge it so i can submit a v2 with the latest patchset from Roman

Quoted 2 lines · Jon Doron

Thank you Maciej, I based it on top of what Denis ([email protected])

gave me

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

which was this:

https://ftp.openvz.org/virtuozzo/releases/openvz-7.0.12-288/source/SRPMS/q/qemu-kvm-vz-2.12.0-33.vz7.14.4.src.rpm

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

Do you think you have a more recent version I dont mind diffing and resubmitting a new version of the patchset?

Thanks,
-- Jon.

Quoted 3 lines · Maciej S. Szmigiero

Hi Jon,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Jon Doron
Quoted 6 lines

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel

port

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

conflicting with vmbus.

TODO: discover and use spare IRQs to avoid conflicts.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Nice work, thanks!

However, it seems to be based on the code version that was posted in February 2018, and not the latest version in OpenVZ qemu repository dated October 2019:

https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

This newer version has slightly different API here and there. Any particular reason for selecting that older version for porting?

I have actually rebased this latest version on the top of the

current

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

QEMU master, and it basically seems to work fine. However, I haven't done extensive tests whether there isn't a

memory leak

Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

somewhere or so on.

Maciej

#14 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Quoted 1 line · Jon Doron

Well I want it to be merged in :-)

Hmm I'm curious why, it has little to offer over virtio.

Anyway the series you've posted seems to be based on a fairly old version.

The one in openvz repo is more recent. It's still in need for improvement, too, but should be testable at least.

Thanks,
Roman.

Quoted 97 lines · On Mon, Apr 6, 2020, 10:32 Roman Kagan <[email protected]> wrote:
Quoted 96 lines · Maciej S. Szmigiero
Quoted 2 lines

It seems to me that Roman might not be getting our e-mails since his new e-mail address seems to be "[email protected]".

Indeed. I'm subscribed with my new address to qemu-devel ML but must have missed this series.

Quoted 1 line

@Roman, are you with us?

Yes ;)

So what are your plans regarding this patchset?

Thanks,
Roman.

Quoted 5 lines · Maciej S. Szmigiero
Quoted 4 lines

Hi Jon,

The patches are available here:
https://github.com/maciejsszmigiero/qemu.git in "vmbus-patches"

branch.

Quoted 2 lines
Quoted 2 lines

Please note that these patches don't have Roman's "Signed-off-by:"

tags,

Quoted 8 lines
Quoted 8 lines

so I haven't applied mine, either.

If you are able to establish a proper SoB chain then please also add:
"Signed-off-by: Maciej S. Szmigiero <[email protected]>".

Thanks for the effort,
Maciej

Quoted 8 lines
Quoted 8 lines · Jon Doron
Quoted 7 lines

Thank you Maciej it seems like your version is really ahead I'll do
the required work and merge it so i can submit a v2 with the latest patchset from Roman

Quoted 2 lines · Jon Doron

Thank you Maciej, I based it on top of what Denis ([email protected])

gave me

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

which was this:

https://ftp.openvz.org/virtuozzo/releases/openvz-7.0.12-288/source/SRPMS/q/qemu-kvm-vz-2.12.0-33.vz7.14.4.src.rpm

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

Do you think you have a more recent version I dont mind diffing and resubmitting a new version of the patchset?

Thanks,
-- Jon.

Quoted 3 lines · Maciej S. Szmigiero

Hi Jon,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Jon Doron
Quoted 6 lines

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel

port

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

conflicting with vmbus.

TODO: discover and use spare IRQs to avoid conflicts.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Nice work, thanks!

However, it seems to be based on the code version that was posted in February 2018, and not the latest version in OpenVZ qemu repository dated October 2019:

https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

This newer version has slightly different API here and there. Any particular reason for selecting that older version for porting?

I have actually rebased this latest version on the top of the

current

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

QEMU master, and it basically seems to work fine. However, I haven't done extensive tests whether there isn't a

memory leak

Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

somewhere or so on.

Maciej

#15 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Quoted 10 lines · Roman Kagan
Quoted 1 line · Jon Doron

Well I want it to be merged in :-)

Hmm I'm curious why, it has little to offer over virtio.

Anyway the series you've posted seems to be based on a fairly old version.

The one in openvz repo is more recent. It's still in need for improvement, too, but should be testable at least.

Isn't the one at
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus
the latest one?

It seems to be last changed in October 2019 - is there a later one?

Quoted 2 lines

Thanks,
Roman.

Thanks,
Maciej

author
#16 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Quoted 11 lines · Maciej S. Szmigiero
Quoted 10 lines · Roman Kagan
Quoted 1 line · Jon Doron

Well I want it to be merged in :-)

Hmm I'm curious why, it has little to offer over virtio.

Anyway the series you've posted seems to be based on a fairly old version.

The one in openvz repo is more recent. It's still in need for improvement, too, but should be testable at least.

Well I have implemented the hyperv synthetic kernel debugger interface, but on Windows 10 it requires to have a working VMBus (it's not really using it, but without a function vmbus that will answer to the initiate contact then the kdnet will simply be stuck in a loop.

With the synthetic kernel debugger interface you can debug older OS (Win7 up to latest Win10). The benefit is that its much faster than all other interfaces.

In addition to that Michael Kelley from Microsoft has informed us that Microsoft might be dropped the synthetic kernel debugger interface sometime in the future, and it seems like the new mode is simply to use hvnet device for the communication (which is again much faster).

Cheers,
-- Jon.

Quoted 13 lines

Isn't the one at
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus
the latest one?

It seems to be last changed in October 2019 - is there a later one?

Quoted 2 lines

Thanks,
Roman.

Thanks,
Maciej

#17 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Quoted 10 lines · Jon Doron
Quoted 9 lines · Maciej S. Szmigiero
Quoted 8 lines · Roman Kagan
Quoted 1 line · Jon Doron

Well I want it to be merged in :-)

Hmm I'm curious why, it has little to offer over virtio.

Anyway the series you've posted seems to be based on a fairly old version.

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

The one in openvz repo is more recent. It's still in need for improvement, too, but should be testable at least.

Well I have implemented the hyperv synthetic kernel debugger interface, but on Windows 10 it requires to have a working VMBus (it's not really using it, but without a function vmbus that will answer to the initiate contact then the kdnet will simply be stuck in a loop.

I see, thanks, I've never heard of this before.

Quoted 3 lines

With the synthetic kernel debugger interface you can debug older OS (Win7 up to latest Win10). The benefit is that its much faster than all other interfaces.

I guess you compare it to debugging via serial port. I wonder where the difference comes from? I thought the transport didn't require any significant throughput, and latency-wise the (emulated) serial port was just as good as any other. Am I missing something?

Thanks,
Roman.

Quoted 20 lines

In addition to that Michael Kelley from Microsoft has informed us that Microsoft might be dropped the synthetic kernel debugger interface sometime in the future, and it seems like the new mode is simply to use hvnet device for the communication (which is again much faster).

Cheers,
-- Jon.

Quoted 13 lines

Isn't the one at
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus
the latest one?

It seems to be last changed in October 2019 - is there a later one?

Quoted 2 lines

Thanks,
Roman.

Thanks,
Maciej

author
#18 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Quoted 25 lines · Roman Kagan
Quoted 10 lines · Jon Doron
Quoted 9 lines · Maciej S. Szmigiero
Quoted 8 lines · Roman Kagan
Quoted 1 line · Jon Doron

Well I want it to be merged in :-)

Hmm I'm curious why, it has little to offer over virtio.

Anyway the series you've posted seems to be based on a fairly old version.

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

The one in openvz repo is more recent. It's still in need for improvement, too, but should be testable at least.

Well I have implemented the hyperv synthetic kernel debugger interface, but on Windows 10 it requires to have a working VMBus (it's not really using it, but without a function vmbus that will answer to the initiate contact then the kdnet will simply be stuck in a loop.

I see, thanks, I've never heard of this before.

Quoted 3 lines

With the synthetic kernel debugger interface you can debug older OS (Win7 up to latest Win10). The benefit is that its much faster than all other interfaces.

Quoted 8 lines

I guess you compare it to debugging via serial port. I wonder where the difference comes from? I thought the transport didn't require any significant throughput, and latency-wise the (emulated) serial port was just as good as any other. Am I missing something?

Thanks,
Roman.

Well kdcom is sending out UART through the virtual serial port, this results in very slow speeds (try it out if you get a chance), because of that most Windows kernel developers use VMWare with a combination of a tool called VirtualKD which implements it's own debug transport on the Windows part and patches the hypervisor (aka VMWare) to get the VMExits. This way it can transfer more and bigger blocks faster, to the debugger.

With the synthetic debugger interface in-place (which you can use since Windows 7) all these tricks are not really required, you just need to implement it :P .

Thanks,
-- Jon.

Quoted 20 lines
Quoted 20 lines

In addition to that Michael Kelley from Microsoft has informed us that Microsoft might be dropped the synthetic kernel debugger interface sometime in the future, and it seems like the new mode is simply to use hvnet device for the communication (which is again much faster).

Cheers,
-- Jon.

Quoted 13 lines

Isn't the one at
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus
the latest one?

It seems to be last changed in October 2019 - is there a later one?

Quoted 2 lines

Thanks,
Roman.

Thanks,
Maciej

#19 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Quoted 6 lines · Jon Doron
Quoted 5 lines · Roman Kagan
Quoted 4 lines · Jon Doron

Well I have implemented the hyperv synthetic kernel debugger interface, but on Windows 10 it requires to have a working VMBus (it's not really using it, but without a function vmbus that will answer to the initiate contact then the kdnet will simply be stuck in a loop.

I tried to google for this interface but the only thing I managed to find was this

https://withinrafael.com/2015/02/01/how-to-set-up-synthetic-kernel-debugging-for-hyper-v-virtual-machines/

Is this what you're trying to implement? Are there any more authoritative descriptions of the feature?

The document doesn't quite explain the inner workings of the feature, but it looks like the regular network debugging interface, except that IP is forwarded by the hypervisor app, so that the debugger has to connect to the host and avoid setting up full-fledged network connectivity to the guest. That would be essentially hv-net + slirp. OTOH you say it doesn't use VMBus so I'm confused...

Thanks,
Roman.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

In addition to that Michael Kelley from Microsoft has informed us that Microsoft might be dropped the synthetic kernel debugger interface sometime in the future, and it seems like the new mode is simply to use hvnet device for the communication (which is again much faster).

author
#20 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Quoted 23 lines · Roman Kagan
Quoted 6 lines · Jon Doron
Quoted 5 lines · Roman Kagan
Quoted 4 lines · Jon Doron

Well I have implemented the hyperv synthetic kernel debugger interface, but on Windows 10 it requires to have a working VMBus (it's not really using it, but without a function vmbus that will answer to the initiate contact then the kdnet will simply be stuck in a loop.

I tried to google for this interface but the only thing I managed to find was this

https://withinrafael.com/2015/02/01/how-to-set-up-synthetic-kernel-debugging-for-hyper-v-virtual-machines/

Is this what you're trying to implement? Are there any more authoritative descriptions of the feature?

The document doesn't quite explain the inner workings of the feature, but it looks like the regular network debugging interface, except that IP is forwarded by the hypervisor app, so that the debugger has to connect to the host and avoid setting up full-fledged network connectivity to the guest. That would be essentially hv-net + slirp. OTOH you say it doesn't use VMBus so I'm confused...

Quoted 7 lines

Thanks,
Roman.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

In addition to that Michael Kelley from Microsoft has informed us that Microsoft might be dropped the synthetic kernel debugger interface sometime in the future, and it seems like the new mode is simply to use hvnet device for the communication (which is again much faster).

Yes that's indeed the interface I have implemented this part of the patch it not full ready for commit, but I think we can keep going with the VMBUS.

Based on your previous reply it sounds like there is not a real issue with the current patch of ACPI DSDT entry, right?

Thanks,
-- Jon.

author
#21 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Quoted 32 lines · Jon Doron
Quoted 23 lines · Roman Kagan
Quoted 6 lines · Jon Doron
Quoted 5 lines · Roman Kagan
Quoted 4 lines · Jon Doron

Well I have implemented the hyperv synthetic kernel debugger interface, but on Windows 10 it requires to have a working VMBus (it's not really using it, but without a function vmbus that will answer to the initiate contact then the kdnet will simply be stuck in a loop.

I tried to google for this interface but the only thing I managed to find was this

https://withinrafael.com/2015/02/01/how-to-set-up-synthetic-kernel-debugging-for-hyper-v-virtual-machines/

Is this what you're trying to implement? Are there any more authoritative descriptions of the feature?

The document doesn't quite explain the inner workings of the feature, but it looks like the regular network debugging interface, except that IP is forwarded by the hypervisor app, so that the debugger has to connect to the host and avoid setting up full-fledged network connectivity to the guest. That would be essentially hv-net + slirp. OTOH you say it doesn't use VMBus so I'm confused...

Quoted 7 lines

Thanks,
Roman.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

In addition to that Michael Kelley from Microsoft has informed us that Microsoft might be dropped the synthetic kernel debugger interface sometime in the future, and it seems like the new mode is simply to use hvnet device for the communication (which is again much faster).

Quoted 6 lines

Yes that's indeed the interface I have implemented this part of the patch it not full ready for commit, but I think we can keep going with the VMBUS.

Based on your previous reply it sounds like there is not a real issue with the current patch of ACPI DSDT entry, right?

Thanks,
-- Jon.

I suggest referring to the KVM patches I have already submitted that Paolo said will probably get in soon.
https://patchwork.kernel.org/patch/11507663/

#22 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

In reply to Maciej S. Szmigiero
Quoted 12 lines · Maciej S. Szmigiero
Quoted 10 lines · Roman Kagan
Quoted 1 line · Jon Doron

Well I want it to be merged in :-)

Hmm I'm curious why, it has little to offer over virtio.

Anyway the series you've posted seems to be based on a fairly old version.

The one in openvz repo is more recent. It's still in need for improvement, too, but should be testable at least.

Quoted 6 lines

Isn't the one at
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus
the latest one?

It seems to be last changed in October 2019 - is there a later one?

There isn't, to the best of my knowledge. It's still sorta unfinished, though, and the demand seems to have disappeared so I couldn't find the motivation to complete it.

Thanks,
Roman.

#23 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

Quoted 17 lines · Roman Kagan
Quoted 16 lines · Maciej S. Szmigiero
Quoted 10 lines · Roman Kagan
Quoted 1 line · Jon Doron

Well I want it to be merged in :-)

Hmm I'm curious why, it has little to offer over virtio.

Anyway the series you've posted seems to be based on a fairly old version.

The one in openvz repo is more recent. It's still in need for improvement, too, but should be testable at least.

Isn't the one at
https://src.openvz.org/projects/UP/repos/qemu/commits?until=refs%2Fheads%2Fvmbus
the latest one?

Quoted 6 lines
Quoted 2 lines

It seems to be last changed in October 2019 - is there a later one?

There isn't, to the best of my knowledge. It's still sorta unfinished, though, and the demand seems to have disappeared so I couldn't find the motivation to complete it.

These patches that were posted should be based on this version, that I have ported to the current QEMU master and then provided to Jon.

BTW. I have written an e-mail to you about this porting work about a month ago, but it was sent your old Virtuozzo mailbox, because that's the email address that these commits had in their metadata.

Quoted 3 lines

Thanks,
Roman.

Thanks,
Maciej

#24 lore raw

Re: [PATCH v1 5/5] i386: Hyper-V VMBus ACPI DSDT entry

In reply to Jon Doron
Quoted 9 lines · On Fri, 3 Apr 2020 17:23:08 +0300 Jon Doron <[email protected]> wrote:

Guest OS uses ACPI to discover vmbus presence. Add a corresponding entry to DSDT in case vmbus has been enabled.

Experimentally Windows guests were found to require this entry to include two IRQ resources, so this patch adds two semi-arbitrarily chosen ones (7 and 13). This results, in particular, in parallel port conflicting with vmbus.

TODO: discover and use spare IRQs to avoid conflicts.

CCing Vitaly
as he might know whom to ping wrt 'spec' that describes vmbus and confirm with ACPI tables that native hyperv generates.

Quoted 39 lines
---
 hw/i386/acpi-build.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
hw/i386/acpi-build.c +17 -0
index 2a7e55bae7..6d7fdbbe9b 100644
@@ -43,6 +43,7 @@
 #include "hw/acpi/tpm.h"
 #include "hw/acpi/vmgenid.h"
 #include "hw/boards.h"
+#include "hw/vmbus/vmbus.h"
 #include "sysemu/tpm_backend.h"
 #include "hw/rtc/mc146818rtc_regs.h"
 #include "migration/vmstate.h"
@@ -1270,6 +1271,43 @@ static Aml *build_com_device_aml(uint8_t uid)
     return dev;
 }
 
+static Aml *build_vmbus_device_aml(void)
+{
+    Aml *dev;
+    Aml *method;
+    Aml *crs;
+
+    dev = aml_device("VMBS");
+    aml_append(dev, aml_name_decl("STA", aml_int(0xF)));
+    aml_append(dev, aml_name_decl("_HID", aml_string("VMBus")));
+    aml_append(dev, aml_name_decl("_UID", aml_int(0x0)));
+    aml_append(dev, aml_name_decl("_DDN", aml_string("VMBUS")));
+
+    method = aml_method("_DIS", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_and(aml_name("STA"), aml_int(0xD), NULL),
+                                     aml_name("STA")));
+    aml_append(dev, method);

hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1299

Quoted 10 lines
hw/i386/acpi-build.c +10 -0
+
+    method = aml_method("_PS0", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_or(aml_name("STA"), aml_int(0xF), NULL),
+                                     aml_name("STA")));
+    aml_append(dev, method);
+
+    method = aml_method("_STA", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_store(aml_name("STA"), aml_local(0)));
+    aml_append(method, aml_return(aml_local(0)));
+    aml_append(dev, method);

does it need all that complicated _STA handling? Would simple
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
work for you?

Quoted 24 lines
hw/i386/acpi-build.c +14 -0
+    aml_append(dev, aml_name_decl("_PS3", aml_int(0x0)));
+
+    crs = aml_resource_template();
+    aml_append(crs, aml_irq_no_flags(7));
+    aml_append(crs, aml_irq_no_flags(13));
+    aml_append(dev, aml_name_decl("_CRS", crs));
+
+    return dev;
+}
+
 static void build_isa_devices_aml(Aml *table)
 {
     ISADevice *fdc = pc_find_fdc0();
@@ -1296,6 +1334,10 @@ static void build_isa_devices_aml(Aml *table)
         build_acpi_ipmi_devices(scope, BUS(obj), "\\_SB.PCI0.ISA");
     }
 
+    if (vmbus_exists()) {
+        aml_append(scope, build_vmbus_device_aml());
+    }
+
     aml_append(table, scope);
 }
 
#25 lore raw
In reply to Jon Doron
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Subject: [PATCH v1 0/5] hyperv: VMBus implementation
Message-id: [email protected]
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
f79ca2e i386: Hyper-V VMBus ACPI DSDT entry d2715b7 vmbus: vmbus implementation
00f328e vmbus: add vmbus protocol definitions 8a097ec hyperv: SControl is optional to enable SynIc 2dfe4b0 hyperv: expose API to determine if synic is enabled

=== OUTPUT BEGIN ===
1/5 Checking commit 2dfe4b0090be (hyperv: expose API to determine if synic is enabled) 2/5 Checking commit 8a097ec3667f (hyperv: SControl is optional to enable SynIc) 3/5 Checking commit 00f328eb4254 (vmbus: add vmbus protocol definitions)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #17:
new file mode 100644

ERROR: do not use C99 // comments
#135: FILE: include/hw/vmbus/vmbus-proto.h:114:
+ uint8_t monitor_flags; // VMBUS_OFFER_MONITOR_*

ERROR: do not use C99 // comments
#136: FILE: include/hw/vmbus/vmbus-proto.h:115:
+ uint16_t interrupt_flags; // VMBUS_OFFER_INTERRUPT_*

ERROR: do not use C99 // comments
#213: FILE: include/hw/vmbus/vmbus-proto.h:192:
+ uint32_t feature_bits; // VMBUS_RING_BUFFER_FEAT_*

total: 3 errors, 1 warnings, 222 lines checked

Patch 3/5 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

4/5 Checking commit d2715b789821 (vmbus: vmbus implementation)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #106:
new file mode 100644

ERROR: memory barrier without comment
#645: FILE: hw/vmbus/vmbus.c:505:
+ smp_mb();

ERROR: memory barrier without comment
#706: FILE: hw/vmbus/vmbus.c:566:
+ smp_mb();

ERROR: "(foo*)" should be "(foo *)"
#1547: FILE: hw/vmbus/vmbus.c:1407:
+ vmbus_msg = (struct vmbus_message_header*)msg->payload;

ERROR: "(foo*)" should be "(foo *)"
#2036: FILE: hw/vmbus/vmbus.c:1896:
+ msg = (struct vmbus_message_header*)msgdata;

ERROR: space required before the open parenthesis '(' #2088: FILE: hw/vmbus/vmbus.c:1948:
+ switch(vmbus->state) {

WARNING: line over 80 characters
#2325: FILE: hw/vmbus/vmbus.c:2185:
+ VMSTATE_STRUCT_VARRAY_POINTER_UINT16(channels, VMBusDevice, num_channels,

ERROR: spaces required around that '*' (ctx:VxV)
#2532: FILE: hw/vmbus/vmbus.c:2392:

+    .subsections = (const VMStateDescription*[]) {
                                             ^

total: 6 errors, 2 warnings, 2585 lines checked

Patch 4/5 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

5/5 Checking commit f79ca2e47cca (i386: Hyper-V VMBus ACPI DSDT entry) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]