hyperv: VMBus implementation
v4 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.)
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.
v4:
Decided to ditch the patch that envolves handling of EOM as there is still a discussion going on with it in the KVM mailing list.
v3:
Fixed an error asan
v2:
Rebased on top of latest patchset from Roman and Maciej
Jon Doron (6):
hyperv: expose API to determine if synic is enabled
vmbus: add vmbus protocol definitions
vmbus: vmbus implementation
i386:pc: whitelist dynamic vmbus-bridge
i386: Hyper-V VMBus ACPI DSDT entry
vmbus: add infrastructure to save/load vmbus requests
Makefile.objs | 1 + hw/hyperv/Kconfig | 5 + hw/hyperv/Makefile.objs | 1 + hw/hyperv/hyperv.c | 8 + hw/hyperv/trace-events | 18 + hw/hyperv/vmbus.c | 2778 ++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 43 + hw/i386/pc_piix.c | 2 + hw/i386/pc_q35.c | 2 + include/hw/hyperv/hyperv.h | 1 + include/hw/hyperv/vmbus-bridge.h | 35 + include/hw/hyperv/vmbus-proto.h | 222 +++ include/hw/hyperv/vmbus.h | 230 +++ 13 files changed, 3346 insertions(+) create mode 100644 hw/hyperv/trace-events create mode 100644 hw/hyperv/vmbus.c create mode 100644 include/hw/hyperv/vmbus-bridge.h create mode 100644 include/hw/hyperv/vmbus-proto.h create mode 100644 include/hw/hyperv/vmbus.h
Signature · 1 line
2.24.1
PATCH v4 1/6 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
@@ -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
@@ -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
PATCH v4 2/6 vmbus: add vmbus protocol definitions
In reply to Jon DoronAdd 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/hyperv/vmbus-proto.h | 222 ++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 include/hw/hyperv/vmbus-proto.h
include/hw/hyperv/vmbus-proto.h new file +222 -0
@@ -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 HW_HYPERV_VMBUS_PROTO_H +#define HW_HYPERV_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; +uint16_t interrupt_flags; +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[]; +}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[]; +}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 ; + +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[]; +}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[]; +}vmbus_pkt_xferpg ; + +#endif
Signature · 1 line
2.24.1
PATCH v4 3/6 vmbus: vmbus implementation
In reply to Jon DoronAdd the VMBus infrastructure -- bus, devices, root bridge, vmbus state machine, vmbus channel interactions, etc.
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.
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.
--- Makefile.objs | 1 + hw/hyperv/Kconfig | 5 + hw/hyperv/Makefile.objs | 1 + hw/hyperv/trace-events | 18 + hw/hyperv/vmbus.c | 2672 ++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus-bridge.h | 32 + include/hw/hyperv/vmbus.h | 227 +++ 7 files changed, 2956 insertions(+) create mode 100644 hw/hyperv/trace-events create mode 100644 hw/hyperv/vmbus.c create mode 100644 include/hw/hyperv/vmbus-bridge.h create mode 100644 include/hw/hyperv/vmbus.h
Makefile.objs +1 -0
@@ -151,6 +151,7 @@ trace-events-subdirs += hw/block/dataplane trace-events-subdirs += hw/char trace-events-subdirs += hw/dma trace-events-subdirs += hw/hppa +trace-events-subdirs += hw/hyperv trace-events-subdirs += hw/i2c trace-events-subdirs += hw/i386 trace-events-subdirs += hw/i386/xen
hw/hyperv/Kconfig +5 -0
@@ -6,3 +6,8 @@ config HYPERV_TESTDEV bool default y if TEST_DEVICES depends on HYPERV + +config VMBUS + bool + default y + depends on HYPERV
hw/hyperv/Makefile.objs +1 -0
@@ -1,2 +1,3 @@ obj-y += hyperv.o obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o +obj-$(CONFIG_VMBUS) += vmbus.o
hw/hyperv/trace-events new file +18 -0
@@ -0,0 +1,18 @@ +# vmbus +vmbus_recv_message(uint32_t type, uint32_t size) "type %d size %d" +vmbus_signal_event(void) "" +vmbus_channel_notify_guest(uint32_t chan_id) "channel #%d" +vmbus_post_msg(uint32_t type, uint32_t size) "type %d size %d" +vmbus_msg_cb(int status) "message status %d" +vmbus_process_incoming_message(uint32_t message_type) "type %d" +vmbus_initiate_contact(uint16_t major, uint16_t minor, uint32_t vcpu, uint64_t monitor_page1, uint64_t monitor_page2, uint64_t interrupt_page) "version %d.%d target vp %d mon pages 0x%"PRIx64",0x%"PRIx64" int page 0x%"PRIx64 +vmbus_send_offer(uint32_t chan_id, void *dev) "channel #%d dev %p" +vmbus_terminate_offers(void) "" +vmbus_gpadl_header(uint32_t gpadl_id, uint16_t num_gfns) "gpadl #%d gfns %d" +vmbus_gpadl_body(uint32_t gpadl_id) "gpadl #%d" +vmbus_gpadl_created(uint32_t gpadl_id) "gpadl #%d" +vmbus_gpadl_teardown(uint32_t gpadl_id) "gpadl #%d" +vmbus_gpadl_torndown(uint32_t gpadl_id) "gpadl #%d" +vmbus_open_channel(uint32_t chan_id, uint32_t gpadl_id, uint32_t target_vp) "channel #%d gpadl #%d target vp %d" +vmbus_channel_open(uint32_t chan_id, uint32_t status) "channel #%d status %d" +vmbus_close_channel(uint32_t chan_id) "channel #%d"
hw/hyperv/vmbus.c new file +2672 -0
2,672 lines not on this page · raw message
include/hw/hyperv/vmbus-bridge.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* QEMU Hyper-V VMBus root bridge +* +* 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 HW_HYPERV_VMBUS_BRIDGE_H +#define HW_HYPERV_VMBUS_BRIDGE_H + +#include "hw/sysbus.h" + +#define TYPE_VMBUS_BRIDGE "vmbus-bridge" + +typedef struct VMBus VMBus ; + +typedef struct VMBusBridge { +SysBusDevice parent_obj; + +VMBus *bus; +}VMBusBridge ; + +#define VMBUS_BRIDGE (obj) OBJECT_CHECK(VMBusBridge, (obj), TYPE_VMBUS_BRIDGE) + +static inline VMBusBridge *vmbus_bridge_find (void ) +{ +return VMBUS_BRIDGE (object_resolve_path_type ("" ,TYPE_VMBUS_BRIDGE ,NULL )); +} + +#endif
include/hw/hyperv/vmbus.h new file +227 -0
227 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH v4 4/6 i386:pc: whitelist dynamic vmbus-bridge
In reply to Jon DoronAs vmbus-bridge is derived from sysbus device, it has to be whitelisted to be allowed to be created with -device.
--- hw/i386/pc_piix.c | 2 ++ hw/i386/pc_q35.c | 2 ++ 2 files changed, 4 insertions(+)
hw/i386/pc_piix.c +2 -0
@@ -60,6 +60,7 @@#include "migration/global_state.h" #include "migration/misc.h" #include "sysemu/numa.h" +#include "hw/hyperv/vmbus-bridge.h" #include "hw/mem/nvdimm.h" #define MAX_IDE_BUS 2
@@ -417,6 +418,7 @@ static void pc_i440fx_machine_options(MachineClass *m) m->default_machine_opts ="firmware=bios-256k.bin" ; m->default_display ="std" ;machine_class_allow_dynamic_sysbus_dev (m,TYPE_RAMFB_DEVICE ); +machine_class_allow_dynamic_sysbus_dev (m,TYPE_VMBUS_BRIDGE ); }static void pc_i440fx_5_0_machine_options (MachineClass *m)
hw/i386/pc_q35.c +2 -0
@@ -53,6 +53,7 @@#include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/numa.h" +#include "hw/hyperv/vmbus-bridge.h" #include "hw/mem/nvdimm.h" /* ICH9 AHCI has 6 ports */
@@ -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 ; }
Signature · 1 line
2.24.1
PATCH v4 5/6 i386: Hyper-V VMBus ACPI DSDT entry
In reply to Jon DoronGuest 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. They seem to never be used but they still have to be there.
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
--- hw/hyperv/vmbus.c | 7 ++++++ hw/i386/acpi-build.c | 43 ++++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus-bridge.h | 3 +++ 3 files changed, 53 insertions(+)
hw/hyperv/vmbus.c +7 -0
@@ -2641,6 +2641,12 @@ static const VMStateDescription vmstate_vmbus_bridge = { }, }; +static Property vmbus_bridge_props[] = { +DEFINE_PROP_UINT8 ("irq0" , VMBusBridge, irq0,7 ), +DEFINE_PROP_UINT8 ("irq1" , VMBusBridge, irq1,13 ), +DEFINE_PROP_END_OF_LIST () +}; +static void vmbus_bridge_class_init (ObjectClass *klass,void *data) {DeviceClass *k =DEVICE_CLASS (klass);
@@ -2651,6 +2657,7 @@ static void vmbus_bridge_class_init(ObjectClass *klass, void *data) sk->explicit_ofw_unit_address = vmbus_bridge_ofw_unit_address;set_bit (DEVICE_CATEGORY_BRIDGE , k->categories); k->vmsd = &vmstate_vmbus_bridge; +device_class_set_props (k, vmbus_bridge_props);/* override SysBusDevice's default */ k->user_creatable = true; }
hw/i386/acpi-build.c +43 -0
64 lines not on this page · raw message
include/hw/hyperv/vmbus-bridge.h +3 -0
@@ -19,6 +19,9 @@ typedef struct VMBus VMBus;typedef struct VMBusBridge {SysBusDevice parent_obj; +uint8_t irq0; +uint8_t irq1; +VMBus *bus; }VMBusBridge ;
Signature · 1 line
2.24.1
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 9 lines · On Fri, 24 Apr 2020 15:34:43 +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. They seem to never be used but they still have to be there.
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
well, it seems that at least linux guest driver uses one IRQ, abeit not from ACPI descriptior
perhaps it's what hyperv host puts into _CRS.
Could you dump ACPI tables and check how hyperv describes vmbus in acpi?
also what if vmbus irq collides with an irq that is already taken, it would be better to initialize and consume irqs it climes to use so in case if conflict one would get a error.
Quoted 66 lines
Signed-off-by Evgeny Yakovlev <[email protected]>Signed-off-by Roman Kagan <[email protected]>Signed-off-by Maciej S. Szmigiero <[email protected]>Signed-off-by Jon Doron <[email protected]>--- hw/hyperv/vmbus.c | 7 ++++++ hw/i386/acpi-build.c | 43 ++++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus-bridge.h | 3 +++ 3 files changed, 53 insertions(+)hw/hyperv/vmbus.c +7
-0@@ -2641,6 +2641,12 @@ static const VMStateDescription vmstate_vmbus_bridge = { }, }; +static Property vmbus_bridge_props[] = { +DEFINE_PROP_UINT8 ("irq0" , VMBusBridge, irq0,7 ), +DEFINE_PROP_UINT8 ("irq1" , VMBusBridge, irq1,13 ), +DEFINE_PROP_END_OF_LIST () +}; +static void vmbus_bridge_class_init (ObjectClass *klass,void *data) {DeviceClass *k =DEVICE_CLASS (klass);@@ -2651,6 +2657,7 @@ static void vmbus_bridge_class_init(ObjectClass *klass, void *data) sk->explicit_ofw_unit_address = vmbus_bridge_ofw_unit_address;set_bit (DEVICE_CATEGORY_BRIDGE , k->categories); k->vmsd = &vmstate_vmbus_bridge; +device_class_set_props (k, vmbus_bridge_props);/* override SysBusDevice's default */ k->user_creatable = true; }hw/i386/acpi-build.c +16
-0@@ -50,6 +50,7 @@#include "hw/mem/nvdimm.h" #include "sysemu/numa.h" #include "sysemu/reset.h" +#include "hw/hyperv/vmbus-bridge.h" /* Supported chipsets: */ #include "hw/southbridge/piix.h" @@ -1270,9 +1271,47 @@ static Aml *build_com_device_aml(uint8_t uid)return dev; } +static Aml *build_vmbus_device_aml (VMBusBridge *vmbus_bridge) +{ +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" )));
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1298
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+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_return (aml_name ("STA" ))); +aml_append (dev, method);
do you reaaly need all that _STA/_DIS/_PS0,
does it work without thouse methods?
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1300
Quoted 2 lines
hw/i386/acpi-build.c +2
-0+ +aml_append (dev,aml_name_decl ("_PS3" ,aml_int (0x0 )));
should be method
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1304
Quoted 4 lines
hw/i386/acpi-build.c +4
-0+ + crs =aml_resource_template (); +aml_append (crs,aml_irq_no_flags (vmbus_bridge->irq0)); +/* FIXME: newer HyperV gets by with only one IRQ */
then why are you adding the second IRQ, does it work with 1 IRQ?
Quoted 14 lines
hw/i386/acpi-build.c +7
-0+aml_append (crs,aml_irq_no_flags (vmbus_bridge->irq1)); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +return dev; +} +static void build_isa_devices_aml (Aml *table) {ISADevice *fdc =pc_find_fdc0 (); +VMBusBridge *vmbus_bridge =vmbus_bridge_find ();bool ambiguous;Aml *scope =aml_scope ("_SB.PCI0.ISA" );
hw/i386/acpi-build.c static void build_isa_devices_aml(Aml *table) · line 1340
Quoted 6 lines
hw/i386/acpi-build.c +3
-0@@ -1296,6 +1335,10 @@ static void build_isa_devices_aml(Aml *table)build_acpi_ipmi_devices (scope,BUS (obj),"\\_SB.PCI0.ISA" ); } +if (vmbus_bridge) { +aml_append (scope,build_vmbus_device_aml (vmbus_bridge)); + }
it seems that bridge is sysbus device, why it's put under ISA bus?
Quoted 17 lines
hw/i386/acpi-build.c +0
-0aml_append (table, scope); }include/hw/hyperv/vmbus-bridge.h +3
-0@@ -19,6 +19,9 @@ typedef struct VMBus VMBus;typedef struct VMBusBridge {SysBusDevice parent_obj; +uint8_t irq0; +uint8_t irq1; +VMBus *bus; }VMBusBridge ;
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
On 05/05/2020, Igor Mammedov wrote:
I dont know what were the original intentions of the original patch authors (at this point I simply rebased it, and to be honest I did not need this patch to get where I was going to, but it was part of the original patchset).
But I'm willing to do any changes so we can keep going forward with this.
Quoted 10 lines
Quoted 7 lines · On Fri, 24 Apr 2020 15:34:43 +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. They seem to never be used but they still have to be there.
Quoted 9 lines
Quoted 2 lines
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
well, it seems that at least linux guest driver uses one IRQ, abeit not from ACPI descriptior
perhaps it's what hyperv host puts into
_CRS.
Could you dump ACPI tables and check how hyperv describes vmbus in acpi?
I can no longer get to the HyperV computer I had (in the office so hopefully if someone else has access to HyperV machine and willing to reply here with the dumped ACPI tables that would be great).
Quoted 4 lines
also what if vmbus irq collides with an irq that is already taken, it would be better to initialize and consume irqs it climes to use so in case if conflict one would get a error.
Sounds right. I tried to see if there is any place in acpi that checks if an IRQ is taken or not but could not find any, can you point me out to a place where it's done?
If not then I guess we need a function that iterates through all registered IRQs so we can find if we have a conflict.
Probably the best places to put it is where you build the acpi aml, but that would really make the code more complicated (i.e build_append_int_noprefix and aml_interrupt).
In case I have not understood you right please let me know.
Quoted 107 lines
Quoted 66 lines
Signed-off-by Evgeny Yakovlev <[email protected]>Signed-off-by Roman Kagan <[email protected]>Signed-off-by Maciej S. Szmigiero <[email protected]>Signed-off-by Jon Doron <[email protected]>--- hw/hyperv/vmbus.c | 7 ++++++ hw/i386/acpi-build.c | 43 ++++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus-bridge.h | 3 +++ 3 files changed, 53 insertions(+)hw/hyperv/vmbus.c +7
-0@@ -2641,6 +2641,12 @@ static const VMStateDescription vmstate_vmbus_bridge = { }, }; +static Property vmbus_bridge_props[] = { +DEFINE_PROP_UINT8 ("irq0" , VMBusBridge, irq0,7 ), +DEFINE_PROP_UINT8 ("irq1" , VMBusBridge, irq1,13 ), +DEFINE_PROP_END_OF_LIST () +}; +static void vmbus_bridge_class_init (ObjectClass *klass,void *data) {DeviceClass *k =DEVICE_CLASS (klass);@@ -2651,6 +2657,7 @@ static void vmbus_bridge_class_init(ObjectClass *klass, void *data) sk->explicit_ofw_unit_address = vmbus_bridge_ofw_unit_address;set_bit (DEVICE_CATEGORY_BRIDGE , k->categories); k->vmsd = &vmstate_vmbus_bridge; +device_class_set_props (k, vmbus_bridge_props);/* override SysBusDevice's default */ k->user_creatable = true; }hw/i386/acpi-build.c +16
-0@@ -50,6 +50,7 @@#include "hw/mem/nvdimm.h" #include "sysemu/numa.h" #include "sysemu/reset.h" +#include "hw/hyperv/vmbus-bridge.h" /* Supported chipsets: */ #include "hw/southbridge/piix.h" @@ -1270,9 +1271,47 @@ static Aml *build_com_device_aml(uint8_t uid)return dev; } +static Aml *build_vmbus_device_aml (VMBusBridge *vmbus_bridge) +{ +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" )));hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1298
Quoted 10 lines
hw/i386/acpi-build.c +10
-0+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_return (aml_name ("STA" ))); +aml_append (dev, method);do you reaaly need all that _STA/_DIS/_PS0,
does it work without thouse methods?hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1300
Quoted 2 lines
hw/i386/acpi-build.c +2
-0+ +aml_append (dev,aml_name_decl ("_PS3" ,aml_int (0x0 )));should be method
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1304
Quoted 4 lines
hw/i386/acpi-build.c +4
-0+ + crs =aml_resource_template (); +aml_append (crs,aml_irq_no_flags (vmbus_bridge->irq0)); +/* FIXME: newer HyperV gets by with only one IRQ */ then why are you adding the second IRQ, does it work with 1 IRQ?
Quoted 17 lines
hw/i386/acpi-build.c +7
-0+aml_append (crs,aml_irq_no_flags (vmbus_bridge->irq1)); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +return dev; +} +static void build_isa_devices_aml (Aml *table) {ISADevice *fdc =pc_find_fdc0 (); +VMBusBridge *vmbus_bridge =vmbus_bridge_find ();bool ambiguous;Aml *scope =aml_scope ("_SB.PCI0.ISA" );@@ -1296,6 +1335,10 @@ static void build_isa_devices_aml(Aml *table)build_acpi_ipmi_devices (scope,BUS (obj),"\\_SB.PCI0.ISA" ); }
Quoted 5 lines
hw/i386/acpi-build.c static void build_isa_devices_aml(Aml *table) · line 1340
Quoted 3 lines
hw/i386/acpi-build.c +3
-0+if (vmbus_bridge) { +aml_append (scope,build_vmbus_device_aml (vmbus_bridge)); + }it seems that bridge is sysbus device, why it's put under ISA bus?
That's where the original author put it, where would you prefer it will go?
Quoted 11 lines
Quoted 11 lines
hw/i386/acpi-build.c +0
-0aml_append (table, scope); }include/hw/hyperv/vmbus-bridge.h +0
-0@@ -19,6 +19,9 @@ typedef struct VMBus VMBus; typedef struct VMBusBridge { SysBusDevice parent_obj;
Quoted 7 lines
include/hw/hyperv/vmbus-bridge.h typedef struct VMBus VMBus; · line 27
Quoted 6 lines
include/hw/hyperv/vmbus-bridge.h +3
-0+uint8_t irq0; +uint8_t irq1; +VMBus *bus; } VMBusBridge;
For your other questions I have no clue like I said I have only rebased the latest revision (which was about 1-2 years old).
-- Jon.
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 21 lines · Jon Doron
On 05/05/2020, Igor Mammedov wrote:
I dont know what were the original intentions of the original patch authors (at this point I simply rebased it, and to be honest I did not need this patch to get where I was going to, but it was part of the original patchset).
But I'm willing to do any changes so we can keep going forward with this.
Quoted 15 lines
Quoted 9 lines · On Fri, 24 Apr 2020 15:34:43 +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. They seem to never be used but they still have to be there.
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
well, it seems that at least linux guest driver uses one IRQ, abeit not from ACPI descriptior
Quoted 7 lines
Quoted 4 lines
perhaps it's what hyperv host puts into
_CRS.
Could you dump ACPI tables and check how hyperv describes vmbus in acpi?I can no longer get to the HyperV computer I had (in the office so hopefully if someone else has access to HyperV machine and willing to reply here with the dumped ACPI tables that would be great).
Here is a VMBus ACPI device description from Hyper-V in Windows Server 2019:
Device (\_SB.VMOD.VMBS)
{
Name (STA, 0x0F)
Name (_ADR, Zero) // _ADR: Address
Name (_DDN, "VMBUS") // _DDN: DOS Device Name
Name (_HID, "VMBus") // _HID: Hardware ID
Name (_UID, Zero) // _UID: Unique ID
Method (_DIS, 0, NotSerialized) // _DIS: Disable Device
{
STA &= 0x0D
}
Method (_PS0, 0, NotSerialized) // _PS0: Power State 0
{
STA |= 0x0F
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
Return (STA) /* \_SB_.VMOD.VMBS.STA_ */
}
Name (_PS3, Zero) // _PS3: Power State 3
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
IRQ (Edge, ActiveHigh, Exclusive, )
{5}
})
}It seems to use just IRQ 5.
Maciej
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Thank you Maciej :)
Igor it seems like the IRQ being used is 5 and not 7 & 13 like in the current patch. Seems like it needs to reside in the _CRS like you said.
Seems like it has all those _STA/_DIS/_PS0 just like the way it's currently in the patch (unless I'm missing something).
Notice _PS3 is not a Method.
So just to summarize the changes i need to do:
1. Change from 2 IRQs to single one (and use 5 as the default)
2. IRQs needs to be under _CRS.
3. You mentioned you want under a different location than the ISA bug where would you want it to be?
Please let me know if there is anything else.
Thanks,
-- Jon.
Quoted 65 lines · Maciej S. Szmigiero
Quoted 21 lines · Jon Doron
On 05/05/2020, Igor Mammedov wrote:
I dont know what were the original intentions of the original patch authors (at this point I simply rebased it, and to be honest I did not need this patch to get where I was going to, but it was part of the original patchset).
But I'm willing to do any changes so we can keep going forward with this.
Quoted 15 lines
Quoted 9 lines · On Fri, 24 Apr 2020 15:34:43 +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. They seem to never be used but they still have to be there.
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
well, it seems that at least linux guest driver uses one IRQ, abeit not from ACPI descriptior
Quoted 7 lines
Quoted 4 lines
perhaps it's what hyperv host puts into
_CRS.
Could you dump ACPI tables and check how hyperv describes vmbus in acpi?I can no longer get to the HyperV computer I had (in the office so hopefully if someone else has access to HyperV machine and willing to reply here with the dumped ACPI tables that would be great).
Here is a VMBus ACPI device description from Hyper-V in Windows Server 2019:
Device (\_SB.VMOD.VMBS)
{ Name (STA, 0x0F) Name (_ADR, Zero) // _ADR: Address Name (_DDN, "VMBUS") // _DDN: DOS Device Name Name (_HID, "VMBus") // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID Method (_DIS, 0, NotSerialized) // _DIS: Disable Device { STA &= 0x0D } Method (_PS0, 0, NotSerialized) // _PS0: Power State 0 { STA |= 0x0F } Method (_STA, 0, NotSerialized) // _STA: Status { Return (STA) /* \_SB_.VMOD.VMBS.STA_ */ } Name (_PS3, Zero) // _PS3: Power State 3 Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings { IRQ (Edge, ActiveHigh, Exclusive, ) {5} }) }It seems to use just IRQ 5.
Maciej
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 2 lines · Jon Doron
Igor it seems like the IRQ being used is 5 and not 7 & 13 like in the current patch.
HyperV using irq 5 doesn't mean QEMU has to too. Especially so as no guest was noticed to use the irqs in ACPI. I'd rather try and test if the guest requires any those at all.
Quoted 1 line
Seems like it needs to reside in the
_CRSlike you said.
They already are there.
Quoted 2 lines
Seems like it has all those _STA/_DIS/_PS0 just like the way it's currently in the patch (unless I'm missing something).
Right, but, as you can see, they are pretty dumb, so the question is whether they are necessary or the guests can do without (Linux apparently can).
Thanks,
Roman.
Quoted 80 lines
Notice
_PS3is not a Method.So just to summarize the changes i need to do:
1. Change from 2 IRQs to single one (and use 5 as the default)
2. IRQs needs to be under_CRS.
3. You mentioned you want under a different location than the ISA bug where would you want it to be?Please let me know if there is anything else.
Thanks,
-- Jon.Quoted 65 lines · Maciej S. Szmigiero
Quoted 21 lines · Jon Doron
On 05/05/2020, Igor Mammedov wrote:
I dont know what were the original intentions of the original patch authors (at this point I simply rebased it, and to be honest I did not need this patch to get where I was going to, but it was part of the original patchset).
But I'm willing to do any changes so we can keep going forward with this.
Quoted 15 lines
Quoted 9 lines · On Fri, 24 Apr 2020 15:34:43 +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. They seem to never be used but they still have to be there.
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
well, it seems that at least linux guest driver uses one IRQ, abeit not from ACPI descriptior
Quoted 7 lines
Quoted 4 lines
perhaps it's what hyperv host puts into
_CRS.
Could you dump ACPI tables and check how hyperv describes vmbus in acpi?I can no longer get to the HyperV computer I had (in the office so hopefully if someone else has access to HyperV machine and willing to reply here with the dumped ACPI tables that would be great).
Here is a VMBus ACPI device description from Hyper-V in Windows Server 2019:
Device (\_SB.VMOD.VMBS)
{ Name (STA, 0x0F) Name (_ADR, Zero) // _ADR: Address Name (_DDN, "VMBUS") // _DDN: DOS Device Name Name (_HID, "VMBus") // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID Method (_DIS, 0, NotSerialized) // _DIS: Disable Device { STA &= 0x0D } Method (_PS0, 0, NotSerialized) // _PS0: Power State 0 { STA |= 0x0F } Method (_STA, 0, NotSerialized) // _STA: Status { Return (STA) /* \_SB_.VMOD.VMBS.STA_ */ } Name (_PS3, Zero) // _PS3: Power State 3 Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings { IRQ (Edge, ActiveHigh, Exclusive, ) {5} }) }It seems to use just IRQ 5.
Maciej
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 10 lines · On Mon, 11 May 2020 23:11:23 +0300 Roman Kagan <[email protected]> wrote:
Quoted 2 lines · Jon Doron
Igor it seems like the IRQ being used is 5 and not 7 & 13 like in the current patch.
HyperV using irq 5 doesn't mean QEMU has to too. Especially so as no guest was noticed to use the irqs in ACPI. I'd rather try and test if the guest requires any those at all.
Quoted 1 line
Seems like it needs to reside in the
_CRSlike you said.
Quoted 8 lines
They already are there.
Quoted 2 lines
Seems like it has all those _STA/_DIS/_PS0 just like the way it's currently in the patch (unless I'm missing something).
Right, but, as you can see, they are pretty dumb, so the question is whether they are necessary or the guests can do without (Linux apparently can).
Agreed with all of above,
Instead of blind copying dubious AML, we should try to figure out what's really necessary of it and throw away the rest.
Quoted 85 lines
Thanks,
Roman.Quoted 80 lines
Notice
_PS3is not a Method.So just to summarize the changes i need to do:
1. Change from 2 IRQs to single one (and use 5 as the default)
2. IRQs needs to be under_CRS.
3. You mentioned you want under a different location than the ISA bug where would you want it to be?Please let me know if there is anything else.
Thanks,
-- Jon.Quoted 65 lines · Maciej S. Szmigiero
Quoted 21 lines · Jon Doron
On 05/05/2020, Igor Mammedov wrote:
I dont know what were the original intentions of the original patch authors (at this point I simply rebased it, and to be honest I did not need this patch to get where I was going to, but it was part of the original patchset).
But I'm willing to do any changes so we can keep going forward with this.
Quoted 15 lines
Quoted 9 lines · On Fri, 24 Apr 2020 15:34:43 +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. They seem to never be used but they still have to be there.
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
well, it seems that at least linux guest driver uses one IRQ, abeit not from ACPI descriptior
Quoted 7 lines
Quoted 4 lines
perhaps it's what hyperv host puts into
_CRS.
Could you dump ACPI tables and check how hyperv describes vmbus in acpi?I can no longer get to the HyperV computer I had (in the office so hopefully if someone else has access to HyperV machine and willing to reply here with the dumped ACPI tables that would be great).
Here is a VMBus ACPI device description from Hyper-V in Windows Server 2019:
Device (\_SB.VMOD.VMBS)
{ Name (STA, 0x0F) Name (_ADR, Zero) // _ADR: Address Name (_DDN, "VMBUS") // _DDN: DOS Device Name Name (_HID, "VMBus") // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID Method (_DIS, 0, NotSerialized) // _DIS: Disable Device { STA &= 0x0D } Method (_PS0, 0, NotSerialized) // _PS0: Power State 0 { STA |= 0x0F } Method (_STA, 0, NotSerialized) // _STA: Status { Return (STA) /* \_SB_.VMOD.VMBS.STA_ */ } Name (_PS3, Zero) // _PS3: Power State 3 Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings { IRQ (Edge, ActiveHigh, Exclusive, ) {5} }) }It seems to use just IRQ 5.
Maciej
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
On 13/05/2020, Igor Mammedov wrote:
Do you guys know perhaps which module is reading the ACPI configuration for VMBus? vmbus.sys / vmbkmcl.sys / winhv.sys? is it the kernel or HAL?
I dont have any real HyperV Windows to play with...
Roman, do you remember when is this information being used? Do we need a full emulation setup (aka your hv-scsi / hv-net) patches in order to see Windows working this ACPI entry?
Thanks,
-- Jon.
Quoted 112 lines
Quoted 10 lines · On Mon, 11 May 2020 23:11:23 +0300 Roman Kagan <[email protected]> wrote:
Quoted 2 lines · Jon Doron
Igor it seems like the IRQ being used is 5 and not 7 & 13 like in the current patch.
HyperV using irq 5 doesn't mean QEMU has to too. Especially so as no guest was noticed to use the irqs in ACPI. I'd rather try and test if the guest requires any those at all.
Quoted 1 line
Seems like it needs to reside in the
_CRSlike you said.Quoted 8 lines
They already are there.
Quoted 2 lines
Seems like it has all those _STA/_DIS/_PS0 just like the way it's currently in the patch (unless I'm missing something).
Right, but, as you can see, they are pretty dumb, so the question is whether they are necessary or the guests can do without (Linux apparently can).
Agreed with all of above,
Instead of blind copying dubious AML, we should try to figure out what's really necessary of it and throw away the rest.Quoted 85 lines
Thanks,
Roman.Quoted 80 lines
Notice
_PS3is not a Method.So just to summarize the changes i need to do:
1. Change from 2 IRQs to single one (and use 5 as the default)
2. IRQs needs to be under_CRS.
3. You mentioned you want under a different location than the ISA bug where would you want it to be?Please let me know if there is anything else.
Thanks,
-- Jon.Quoted 65 lines · Maciej S. Szmigiero
Quoted 21 lines · Jon Doron
On 05/05/2020, Igor Mammedov wrote:
I dont know what were the original intentions of the original patch authors (at this point I simply rebased it, and to be honest I did not need this patch to get where I was going to, but it was part of the original patchset).
But I'm willing to do any changes so we can keep going forward with this.
Quoted 15 lines
Quoted 9 lines · On Fri, 24 Apr 2020 15:34:43 +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. They seem to never be used but they still have to be there.
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
well, it seems that at least linux guest driver uses one IRQ, abeit not from ACPI descriptior
Quoted 7 lines
Quoted 4 lines
perhaps it's what hyperv host puts into
_CRS.
Could you dump ACPI tables and check how hyperv describes vmbus in acpi?I can no longer get to the HyperV computer I had (in the office so hopefully if someone else has access to HyperV machine and willing to reply here with the dumped ACPI tables that would be great).
Here is a VMBus ACPI device description from Hyper-V in Windows Server 2019:
Device (\_SB.VMOD.VMBS)
{ Name (STA, 0x0F) Name (_ADR, Zero) // _ADR: Address Name (_DDN, "VMBUS") // _DDN: DOS Device Name Name (_HID, "VMBus") // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID Method (_DIS, 0, NotSerialized) // _DIS: Disable Device { STA &= 0x0D } Method (_PS0, 0, NotSerialized) // _PS0: Power State 0 { STA |= 0x0F } Method (_STA, 0, NotSerialized) // _STA: Status { Return (STA) /* \_SB_.VMOD.VMBS.STA_ */ } Name (_PS3, Zero) // _PS3: Power State 3 Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings { IRQ (Edge, ActiveHigh, Exclusive, ) {5} }) }It seems to use just IRQ 5.
Maciej
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 4 lines · Jon Doron
On 13/05/2020, Igor Mammedov wrote:
Do you guys know perhaps which module is reading the ACPI configuration for VMBus? vmbus.sys / vmbkmcl.sys / winhv.sys? is it the kernel or HAL?
No idea...
Quoted 5 lines
I dont have any real HyperV Windows to play with...
Roman, do you remember when is this information being used? Do we need a full emulation setup (aka your hv-scsi / hv-net) patches in order to see Windows working this ACPI entry?
I think the series you've posted should be enough to see VMBus in the DeviceManager. hv-scsi and hv-net should not further depend on ACPI. hv-pci does: it (at least in its Linux driver implementation) wants the VMBus entry or any of its ancestors to define range(s) where mmio windows can be placed. This may be worth considering when deciding where to stick the VMBus entry to.
Thanks,
Roman.
Quoted 115 lines
Thanks,
-- Jon.Quoted 112 lines
Quoted 10 lines · On Mon, 11 May 2020 23:11:23 +0300 Roman Kagan <[email protected]> wrote:
Quoted 2 lines · Jon Doron
Igor it seems like the IRQ being used is 5 and not 7 & 13 like in the current patch.
HyperV using irq 5 doesn't mean QEMU has to too. Especially so as no guest was noticed to use the irqs in ACPI. I'd rather try and test if the guest requires any those at all.
Quoted 1 line
Seems like it needs to reside in the
_CRSlike you said.Quoted 8 lines
They already are there.
Quoted 2 lines
Seems like it has all those _STA/_DIS/_PS0 just like the way it's currently in the patch (unless I'm missing something).
Right, but, as you can see, they are pretty dumb, so the question is whether they are necessary or the guests can do without (Linux apparently can).
Agreed with all of above,
Instead of blind copying dubious AML, we should try to figure out what's really necessary of it and throw away the rest.Quoted 85 lines
Thanks,
Roman.Quoted 80 lines
Notice
_PS3is not a Method.So just to summarize the changes i need to do:
1. Change from 2 IRQs to single one (and use 5 as the default)
2. IRQs needs to be under_CRS.
3. You mentioned you want under a different location than the ISA bug where would you want it to be?Please let me know if there is anything else.
Thanks,
-- Jon.Quoted 65 lines · Maciej S. Szmigiero
Quoted 21 lines · Jon Doron
On 05/05/2020, Igor Mammedov wrote:
I dont know what were the original intentions of the original patch authors (at this point I simply rebased it, and to be honest I did not need this patch to get where I was going to, but it was part of the original patchset).
But I'm willing to do any changes so we can keep going forward with this.
Quoted 15 lines
Quoted 9 lines · On Fri, 24 Apr 2020 15:34:43 +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. They seem to never be used but they still have to be there.
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
well, it seems that at least linux guest driver uses one IRQ, abeit not from ACPI descriptior
Quoted 7 lines
Quoted 4 lines
perhaps it's what hyperv host puts into
_CRS.
Could you dump ACPI tables and check how hyperv describes vmbus in acpi?I can no longer get to the HyperV computer I had (in the office so hopefully if someone else has access to HyperV machine and willing to reply here with the dumped ACPI tables that would be great).
Here is a VMBus ACPI device description from Hyper-V in Windows Server 2019:
Device (\_SB.VMOD.VMBS)
{ Name (STA, 0x0F) Name (_ADR, Zero) // _ADR: Address Name (_DDN, "VMBUS") // _DDN: DOS Device Name Name (_HID, "VMBus") // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID Method (_DIS, 0, NotSerialized) // _DIS: Disable Device { STA &= 0x0D } Method (_PS0, 0, NotSerialized) // _PS0: Power State 0 { STA |= 0x0F } Method (_STA, 0, NotSerialized) // _STA: Status { Return (STA) /* \_SB_.VMOD.VMBS.STA_ */ } Name (_PS3, Zero) // _PS3: Power State 3 Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings { IRQ (Edge, ActiveHigh, Exclusive, ) {5} }) }It seems to use just IRQ 5.
Maciej
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
In reply to Igor MammedovQuoted 6 lines · Igor Mammedov
Quoted 3 lines · On Fri, 24 Apr 2020 15:34:43 +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.
Quoted 8 lines
Quoted 6 lines
Experimentally Windows guests were found to require this entry to include two IRQ resources. They seem to never be used but they still have to be there.
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
well, it seems that at least linux guest driver uses one IRQ, abeit not from ACPI descriptior
I guess you mean synthetic interrupts. Linux doesn't seem to use ACPI-discovered IRQs.
Quoted 2 lines
perhaps it's what hyperv host puts into
_CRS.
Could you dump ACPI tables and check how hyperv describes vmbus in acpi?
Exactly, this was how this was conceived in the first place.
Quoted 3 lines
also what if vmbus irq collides with an irq that is already taken, it would be better to initialize and consume irqs it climes to use so in case if conflict one would get a error.
That was the plan initially. However, since no guest actually used those irqs, it appeared not worth the effort. Dunno what problems can arise from the conflicts.
Quoted 71 lines
Quoted 71 lines
Signed-off-by Evgeny Yakovlev <[email protected]>Signed-off-by Roman Kagan <[email protected]>Signed-off-by Maciej S. Szmigiero <[email protected]>Signed-off-by Jon Doron <[email protected]>--- hw/hyperv/vmbus.c | 7 ++++++ hw/i386/acpi-build.c | 43 ++++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus-bridge.h | 3 +++ 3 files changed, 53 insertions(+)hw/hyperv/vmbus.c +7
-0@@ -2641,6 +2641,12 @@ static const VMStateDescription vmstate_vmbus_bridge = { }, }; +static Property vmbus_bridge_props[] = { +DEFINE_PROP_UINT8 ("irq0" , VMBusBridge, irq0,7 ), +DEFINE_PROP_UINT8 ("irq1" , VMBusBridge, irq1,13 ), +DEFINE_PROP_END_OF_LIST () +}; +static void vmbus_bridge_class_init (ObjectClass *klass,void *data) {DeviceClass *k =DEVICE_CLASS (klass);@@ -2651,6 +2657,7 @@ static void vmbus_bridge_class_init(ObjectClass *klass, void *data) sk->explicit_ofw_unit_address = vmbus_bridge_ofw_unit_address;set_bit (DEVICE_CATEGORY_BRIDGE , k->categories); k->vmsd = &vmstate_vmbus_bridge; +device_class_set_props (k, vmbus_bridge_props);/* override SysBusDevice's default */ k->user_creatable = true; }hw/i386/acpi-build.c +21
-0@@ -50,6 +50,7 @@#include "hw/mem/nvdimm.h" #include "sysemu/numa.h" #include "sysemu/reset.h" +#include "hw/hyperv/vmbus-bridge.h" /* Supported chipsets: */ #include "hw/southbridge/piix.h" @@ -1270,9 +1271,47 @@ static Aml *build_com_device_aml(uint8_t uid)return dev; } +static Aml *build_vmbus_device_aml (VMBusBridge *vmbus_bridge) +{ +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" )));
Quoted 8 lines
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1298
Quoted 5 lines
hw/i386/acpi-build.c +5
-0+aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_name ("STA" ))); +aml_append (dev, method);do you reaaly need all that _STA/_DIS/_PS0,
does it work without thouse methods?
This was just copied from HyperV. It may make sense to test without.
Quoted 3 lines
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1300
Quoted 2 lines
hw/i386/acpi-build.c +2
-0+ +aml_append (dev,aml_name_decl ("_PS3" ,aml_int (0x0 )));should be method
Not our fault :) Again this was copied.
Quoted 5 lines
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1304
Quoted 4 lines
hw/i386/acpi-build.c +4
-0+ + crs =aml_resource_template (); +aml_append (crs,aml_irq_no_flags (vmbus_bridge->irq0)); +/* FIXME: newer HyperV gets by with only one IRQ */ then why are you adding the second IRQ, does it work with 1 IRQ?
This FIXME was left by me when I noticed that more recent HyperV servers only stick one IRQ there, but I didn't get around to dig further.
Quoted 17 lines
Quoted 17 lines
hw/i386/acpi-build.c +7
-0+aml_append (crs,aml_irq_no_flags (vmbus_bridge->irq1)); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +return dev; +} +static void build_isa_devices_aml (Aml *table) {ISADevice *fdc =pc_find_fdc0 (); +VMBusBridge *vmbus_bridge =vmbus_bridge_find ();bool ambiguous;Aml *scope =aml_scope ("_SB.PCI0.ISA" );@@ -1296,6 +1335,10 @@ static void build_isa_devices_aml(Aml *table)build_acpi_ipmi_devices (scope,BUS (obj),"\\_SB.PCI0.ISA" ); }
Quoted 4 lines
hw/i386/acpi-build.c static void build_isa_devices_aml(Aml *table) · line 1340
Quoted 3 lines
hw/i386/acpi-build.c +3
-0+if (vmbus_bridge) { +aml_append (scope,build_vmbus_device_aml (vmbus_bridge)); + }it seems that bridge is sysbus device, why it's put under ISA bus?
This is where it's put by HyperV in Gen1 machines. For Gen2, which has neither PCI nor ISA, it's put in a dedicated container.
Either way, the ancestor nodes are consulted for the memory windows for certain devices like vmbus-pci bridges or vmbus framebuffer, so it may be necessary to adjust this when / if we add those devices.
Thanks,
Roman.
Quoted 19 lines
Quoted 17 lines
hw/i386/acpi-build.c +0
-0aml_append (table, scope); }include/hw/hyperv/vmbus-bridge.h +3
-0@@ -19,6 +19,9 @@ typedef struct VMBus VMBus;typedef struct VMBusBridge {SysBusDevice parent_obj; +uint8_t irq0; +uint8_t irq1; +VMBus *bus; }VMBusBridge ;
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 11 lines · On Mon, 11 May 2020 21:21:56 +0300 Roman Kagan <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
Quoted 7 lines · On Fri, 24 Apr 2020 15:34:43 +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. They seem to never be used but they still have to be there.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Make IRQ numbers user-configurable via corresponding properties; use 7 and 13 by default.
well, it seems that at least linux guest driver uses one IRQ, abeit not from ACPI descriptior
I guess you mean synthetic interrupts. Linux doesn't seem to use ACPI-discovered IRQs.
indeed it doesn't, but that doesn't mean that Windows doesn't as well.
Quoted 5 lines
Quoted 2 lines
perhaps it's what hyperv host puts into
_CRS.
Could you dump ACPI tables and check how hyperv describes vmbus in acpi?Exactly, this was how this was conceived in the first place.
Quoted 7 lines
Quoted 3 lines
also what if vmbus irq collides with an irq that is already taken, it would be better to initialize and consume irqs it climes to use so in case if conflict one would get a error.
That was the plan initially. However, since no guest actually used those irqs, it appeared not worth the effort. Dunno what problems can arise from the conflicts.
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
Quoted 149 lines
Quoted 71 lines
Quoted 71 lines
Signed-off-by Evgeny Yakovlev <[email protected]>Signed-off-by Roman Kagan <[email protected]>Signed-off-by Maciej S. Szmigiero <[email protected]>Signed-off-by Jon Doron <[email protected]>--- hw/hyperv/vmbus.c | 7 ++++++ hw/i386/acpi-build.c | 43 ++++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus-bridge.h | 3 +++ 3 files changed, 53 insertions(+)hw/hyperv/vmbus.c +7
-0@@ -2641,6 +2641,12 @@ static const VMStateDescription vmstate_vmbus_bridge = { }, }; +static Property vmbus_bridge_props[] = { +DEFINE_PROP_UINT8 ("irq0" , VMBusBridge, irq0,7 ), +DEFINE_PROP_UINT8 ("irq1" , VMBusBridge, irq1,13 ), +DEFINE_PROP_END_OF_LIST () +}; +static void vmbus_bridge_class_init (ObjectClass *klass,void *data) {DeviceClass *k =DEVICE_CLASS (klass);@@ -2651,6 +2657,7 @@ static void vmbus_bridge_class_init(ObjectClass *klass, void *data) sk->explicit_ofw_unit_address = vmbus_bridge_ofw_unit_address;set_bit (DEVICE_CATEGORY_BRIDGE , k->categories); k->vmsd = &vmstate_vmbus_bridge; +device_class_set_props (k, vmbus_bridge_props);/* override SysBusDevice's default */ k->user_creatable = true; }hw/i386/acpi-build.c +21
-0@@ -50,6 +50,7 @@#include "hw/mem/nvdimm.h" #include "sysemu/numa.h" #include "sysemu/reset.h" +#include "hw/hyperv/vmbus-bridge.h" /* Supported chipsets: */ #include "hw/southbridge/piix.h" @@ -1270,9 +1271,47 @@ static Aml *build_com_device_aml(uint8_t uid)return dev; } +static Aml *build_vmbus_device_aml (VMBusBridge *vmbus_bridge) +{ +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" )));Quoted 8 lines
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1298
Quoted 5 lines
hw/i386/acpi-build.c +5
-0+aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_return (aml_name ("STA" ))); +aml_append (dev, method);do you reaaly need all that _STA/_DIS/_PS0,
does it work without thouse methods?This was just copied from HyperV. It may make sense to test without.
Quoted 3 lines
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1300
Quoted 2 lines
hw/i386/acpi-build.c +2
-0+ +aml_append (dev,aml_name_decl ("_PS3" ,aml_int (0x0 )));should be method
Not our fault :) Again this was copied.
Quoted 5 lines
hw/i386/acpi-build.c static Aml *build_com_device_aml(uint8_t uid) · line 1304
Quoted 4 lines
hw/i386/acpi-build.c +4
-0+ + crs =aml_resource_template (); +aml_append (crs,aml_irq_no_flags (vmbus_bridge->irq0)); +/* FIXME: newer HyperV gets by with only one IRQ */ then why are you adding the second IRQ, does it work with 1 IRQ?
This FIXME was left by me when I noticed that more recent HyperV servers only stick one IRQ there, but I didn't get around to dig further.
Quoted 17 lines
Quoted 17 lines
hw/i386/acpi-build.c +7
-0+aml_append (crs,aml_irq_no_flags (vmbus_bridge->irq1)); +aml_append (dev,aml_name_decl ("_CRS" , crs)); + +return dev; +} +static void build_isa_devices_aml (Aml *table) {ISADevice *fdc =pc_find_fdc0 (); +VMBusBridge *vmbus_bridge =vmbus_bridge_find ();bool ambiguous;Aml *scope =aml_scope ("_SB.PCI0.ISA" );@@ -1296,6 +1335,10 @@ static void build_isa_devices_aml(Aml *table)build_acpi_ipmi_devices (scope,BUS (obj),"\\_SB.PCI0.ISA" ); }Quoted 4 lines
hw/i386/acpi-build.c static void build_isa_devices_aml(Aml *table) · line 1340
Quoted 3 lines
hw/i386/acpi-build.c +3
-0+if (vmbus_bridge) { +aml_append (scope,build_vmbus_device_aml (vmbus_bridge)); + }it seems that bridge is sysbus device, why it's put under ISA bus?
This is where it's put by HyperV in Gen1 machines. For Gen2, which has neither PCI nor ISA, it's put in a dedicated container.
Either way, the ancestor nodes are consulted for the memory windows for certain devices like vmbus-pci bridges or vmbus framebuffer, so it may be necessary to adjust this when / if we add those devices.
Thanks,
Roman.Quoted 19 lines
Quoted 17 lines
hw/i386/acpi-build.c +0
-0aml_append (table, scope); }include/hw/hyperv/vmbus-bridge.h +3
-0@@ -19,6 +19,9 @@ typedef struct VMBus VMBus;typedef struct VMBusBridge {SysBusDevice parent_obj; +uint8_t irq0; +uint8_t irq1; +VMBus *bus; }VMBusBridge ;
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 4 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
Paolo
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 8 lines · On Thu, 21 May 2020 18:02:07 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
that I don't know that's why I'm not suggesting how to do it. The point is hard-coding in AML random IRQs is not right thing to do, (especially with the lack of 'any' spec), as minimum AML should pull it from device model and that probably should be configurable and set by board.
Other thing is:
I haven't looked at VMBus device model in detail, but DSDT part aren't matching device though (device model is not ISA device hence AML part shouldn't be on in ISA scope), where to put it is open question. There were other issues with AML code, I've commented on, so I was waiting on respin with comments addressed.
I don't think that this patch is good enough for merging.
Quoted 3 lines
Paolo
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 18 lines · Igor Mammedow
Quoted 8 lines · On Thu, 21 May 2020 18:02:07 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
that I don't know that's why I'm not suggesting how to do it. The point is hard-coding in AML random IRQs is not right thing to do, (especially with the lack of 'any' spec), as minimum AML should pull it from device model and that probably should be configurable and set by board.
Quoted 9 lines
Other thing is:
I haven't looked at VMBus device model in detail, but DSDT part aren't matching device though (device model is not ISA device hence AML part shouldn't be on in ISA scope), where to put it is open question. There were other issues with AML code, I've commented on, so I was waiting on respin with comments addressed.
I don't think that this patch is good enough for merging.
But it seems like the current patch does match what's Microsoft HyperV is publishing in it's APCI tables.
I dont think it's correct for us to "fix" Microsoft emulation even if it's wrong, since that's what Windows probably expects to see...
I tried looking where Microsoft uses the ACPI tables to identify the VMBus but without much luck in order to understand how flexible a change would be for the OS to still detect the VMBus device, but in general I think "correcting" something that is emulated 1:1 because there is no spec is the right way.
Quoted 4 lines
Quoted 3 lines
Paolo
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 29 lines · Jon Doron
Quoted 18 lines · Igor Mammedow
Quoted 8 lines · On Thu, 21 May 2020 18:02:07 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
that I don't know that's why I'm not suggesting how to do it. The point is hard-coding in AML random IRQs is not right thing to do, (especially with the lack of 'any' spec), as minimum AML should pull it from device model and that probably should be configurable and set by board.
Quoted 9 lines
Other thing is:
I haven't looked at VMBus device model in detail, but DSDT part aren't matching device though (device model is not ISA device hence AML part shouldn't be on in ISA scope), where to put it is open question. There were other issues with AML code, I've commented on, so I was waiting on respin with comments addressed.
I don't think that this patch is good enough for merging.
Quoted 6 lines
But it seems like the current patch does match what's Microsoft HyperV is publishing in it's APCI tables.
I dont think it's correct for us to "fix" Microsoft emulation even if it's wrong, since that's what Windows probably expects to see...
I tried looking where Microsoft uses the ACPI tables to identify the VMBus but without much luck in order to understand how flexible a change would be for the OS to still detect the VMBus device, but in general I think "correcting" something that is emulated 1:1 because there is no spec is the right way.
Bah sorry meant to say:
In general correcting some virtual emulated device which is current is matching 1:1 is wrong, I think the right way to handle this type of things is to copy them 1:1 and not try to "fix" or "correct" them since that's what Windows expects.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Paolo
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
In reply to Jon DoronQuoted 32 lines · On Thu, 28 May 2020 08:26:42 +0300 Jon Doron <[email protected]> wrote:
Quoted 18 lines · Igor Mammedow
Quoted 8 lines · On Thu, 21 May 2020 18:02:07 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
that I don't know that's why I'm not suggesting how to do it. The point is hard-coding in AML random IRQs is not right thing to do, (especially with the lack of 'any' spec), as minimum AML should pull it from device model and that probably should be configurable and set by board.
Quoted 9 lines
Other thing is:
I haven't looked at VMBus device model in detail, but DSDT part aren't matching device though (device model is not ISA device hence AML part shouldn't be on in ISA scope), where to put it is open question. There were other issues with AML code, I've commented on, so I was waiting on respin with comments addressed.
I don't think that this patch is good enough for merging.But it seems like the current patch does match what's Microsoft HyperV is publishing in it's APCI tables.
Quoted 8 lines
I dont think it's correct for us to "fix" Microsoft emulation even if it's wrong, since that's what Windows probably expects to see...
I tried looking where Microsoft uses the ACPI tables to identify the VMBus but without much luck in order to understand how flexible a change would be for the OS to still detect the VMBus device, but in general I think "correcting" something that is emulated 1:1 because there is no spec is the right way.
I'd agree, if removing nonsense would break VMBus detection (does it?). if something is that doesn't make sense but has to stay because it is need to make windows happy, that's fine , just add annotate is with comment, so it won't confuse anyone why that code exists there later on.
I suggest to:
1. try dropping _PS* & _STA as it doesn't actually does anything and _PS3 is plain wrong
2. drop one IRQ, newer hyper-v seems to be doing fine with only one
3. it's not ISA device, I'd suggest to move into _SB scope
4. I don't know much about IRQs but
git grep DEFINE_PROP_ | grep -i iqr
yields nothing so I'm not sure if it's acceptable. Typically it's board that assigns IRQ and not device, for Sysbus devices (see: sysbus_init_irq/sysbus_connect_irq). So I'd leave it upto Paolo or someone else to decide/comment on.
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Paolo
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 49 lines · Igor Mammedov
Quoted 32 lines · On Thu, 28 May 2020 08:26:42 +0300 Jon Doron <[email protected]> wrote:
Quoted 18 lines · Igor Mammedow
Quoted 8 lines · On Thu, 21 May 2020 18:02:07 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
that I don't know that's why I'm not suggesting how to do it. The point is hard-coding in AML random IRQs is not right thing to do, (especially with the lack of 'any' spec), as minimum AML should pull it from device model and that probably should be configurable and set by board.
Quoted 9 lines
Other thing is:
I haven't looked at VMBus device model in detail, but DSDT part aren't matching device though (device model is not ISA device hence AML part shouldn't be on in ISA scope), where to put it is open question. There were other issues with AML code, I've commented on, so I was waiting on respin with comments addressed.
I don't think that this patch is good enough for merging.But it seems like the current patch does match what's Microsoft HyperV is publishing in it's APCI tables.
Quoted 8 lines
I dont think it's correct for us to "fix" Microsoft emulation even if it's wrong, since that's what Windows probably expects to see...
I tried looking where Microsoft uses the ACPI tables to identify the VMBus but without much luck in order to understand how flexible a change would be for the OS to still detect the VMBus device, but in general I think "correcting" something that is emulated 1:1 because there is no spec is the right way.
I'd agree, if removing nonsense would break VMBus detection (does it?). if something is that doesn't make sense but has to stay because it is need to make windows happy, that's fine , just add annotate is with comment, so it won't confuse anyone why that code exists there later on.
Quoted 10 lines
I suggest to:
1. try dropping _PS* &_STAas it doesn't actually does anything and_PS3is plain wrong
2. drop one IRQ, newer hyper-v seems to be doing fine with only one
3. it's not ISA device, I'd suggest to move into_SBscope
4. I don't know much about IRQs but
git grepDEFINE_PROP_| grep -i iqr
yields nothing so I'm not sure if it's acceptable. Typically it's board that assigns IRQ and not device, for Sysbus devices (see: sysbus_init_irq/sysbus_connect_irq). So I'd leave it upto Paolo or someone else to decide/comment on.
Sounds like a plan, I'll try to come up with the test results (at least for Windows 10 guest which is what I have setup) and update this thread with the results.
-- Jon.
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Paolo
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 61 lines · Jon Doron
Quoted 49 lines · Igor Mammedov
Quoted 32 lines · On Thu, 28 May 2020 08:26:42 +0300 Jon Doron <[email protected]> wrote:
Quoted 18 lines · Igor Mammedow
Quoted 8 lines · On Thu, 21 May 2020 18:02:07 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
that I don't know that's why I'm not suggesting how to do it. The point is hard-coding in AML random IRQs is not right thing to do, (especially with the lack of 'any' spec), as minimum AML should pull it from device model and that probably should be configurable and set by board.
Quoted 9 lines
Other thing is:
I haven't looked at VMBus device model in detail, but DSDT part aren't matching device though (device model is not ISA device hence AML part shouldn't be on in ISA scope), where to put it is open question. There were other issues with AML code, I've commented on, so I was waiting on respin with comments addressed.
I don't think that this patch is good enough for merging.But it seems like the current patch does match what's Microsoft HyperV is publishing in it's APCI tables.
Quoted 8 lines
I dont think it's correct for us to "fix" Microsoft emulation even if it's wrong, since that's what Windows probably expects to see...
I tried looking where Microsoft uses the ACPI tables to identify the VMBus but without much luck in order to understand how flexible a change would be for the OS to still detect the VMBus device, but in general I think "correcting" something that is emulated 1:1 because there is no spec is the right way.
I'd agree, if removing nonsense would break VMBus detection (does it?). if something is that doesn't make sense but has to stay because it is need to make windows happy, that's fine , just add annotate is with comment, so it won't confuse anyone why that code exists there later on.
Quoted 10 lines
I suggest to:
1. try dropping _PS* &_STAas it doesn't actually does anything and_PS3is plain wrong
2. drop one IRQ, newer hyper-v seems to be doing fine with only one
3. it's not ISA device, I'd suggest to move into_SBscope
4. I don't know much about IRQs but
git grepDEFINE_PROP_| grep -i iqr
yields nothing so I'm not sure if it's acceptable. Typically it's board that assigns IRQ and not device, for Sysbus devices (see: sysbus_init_irq/sysbus_connect_irq). So I'd leave it upto Paolo or someone else to decide/comment on.
Quoted 13 lines
Sounds like a plan, I'll try to come up with the test results (at least for Windows 10 guest which is what I have setup) and update this thread with the results.
-- Jon.
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Paolo
Hi guys,
Sorry for the delay...
So first ill clarify what was the test, the test was to see the device "Microsoft Hyper-V Virtual Machine Bus" in Windows Device Manager under "System devices" with a state of "working properly".
It seems like it's ok to drop all the _PS* and _STA.
It seems to be functioning with single IRQ as well, it is worth noting that even when i dropped the entire _CRS (so no IRQs resources are required, the device was still showing that it's functioning, but I suspect this might affect the child devices like hv-net and hv-scsi).
With that said I did run into a small issue I set-up Win10 1903 (aka 19H1) and it seems like VMBus now requires to have the following features enabled:HV_VP_RUNTIME_AVAILABLEHV_TIME_REF_COUNT_AVAILABLEHV_SYNIC_AVAILABLEHV_SYNTIMERS_AVAILABLEHV_APIC_ACCESS_AVAILABLEHV_HYPERCALL_AVAILABLEHV_VP_INDEX_AVAILABLE
So notice that previously only SYNIC and VPINDEX was needed, now you need the whole thing so you need to run qemu with something like -cpu host,hv-relaxed,hv_spinlocks=0x1fff,hv_time,hv-vapic,hv-vpindex,hv-synic,hv-runtime,hv-stimer
The validation was done in winhv!WinHvpCheckPartitionPrivileges .
Paolo I noticed you have done a PULL request, would you like to wait on it and we will submit a version with a single IRQ (selectable by user property) and go with Igor's suggestion dropping _PS* and _STA (though like I said before I prefer to mimic the original HyperV with it's bugs, but I'll leave this decision to you).
Also today VMBus only verifies SYNIC is enabled I'm not sure how but I wonder if we want to some how exports from the CPU which other HV features are enabled so we can verify all the required ones are set, would appreciate if you have any suggestions here.
Cheers,
-- Jon.
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 99 lines · Jon Doron
Quoted 61 lines · Jon Doron
Quoted 49 lines · Igor Mammedov
Quoted 32 lines · On Thu, 28 May 2020 08:26:42 +0300 Jon Doron <[email protected]> wrote:
Quoted 18 lines · Igor Mammedow
Quoted 8 lines · On Thu, 21 May 2020 18:02:07 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
that I don't know that's why I'm not suggesting how to do it. The point is hard-coding in AML random IRQs is not right thing to do, (especially with the lack of 'any' spec), as minimum AML should pull it from device model and that probably should be configurable and set by board.
Quoted 9 lines
Other thing is:
I haven't looked at VMBus device model in detail, but DSDT part aren't matching device though (device model is not ISA device hence AML part shouldn't be on in ISA scope), where to put it is open question. There were other issues with AML code, I've commented on, so I was waiting on respin with comments addressed.
I don't think that this patch is good enough for merging.But it seems like the current patch does match what's Microsoft HyperV is publishing in it's APCI tables.
Quoted 8 lines
I dont think it's correct for us to "fix" Microsoft emulation even if it's wrong, since that's what Windows probably expects to see...
I tried looking where Microsoft uses the ACPI tables to identify the VMBus but without much luck in order to understand how flexible a change would be for the OS to still detect the VMBus device, but in general I think "correcting" something that is emulated 1:1 because there is no spec is the right way.
I'd agree, if removing nonsense would break VMBus detection (does it?). if something is that doesn't make sense but has to stay because it is need to make windows happy, that's fine , just add annotate is with comment, so it won't confuse anyone why that code exists there later on.
Quoted 10 lines
I suggest to:
1. try dropping _PS* &_STAas it doesn't actually does anything and_PS3is plain wrong
2. drop one IRQ, newer hyper-v seems to be doing fine with only one
3. it's not ISA device, I'd suggest to move into_SBscope
4. I don't know much about IRQs but
git grepDEFINE_PROP_| grep -i iqr
yields nothing so I'm not sure if it's acceptable. Typically it's board that assigns IRQ and not device, for Sysbus devices (see: sysbus_init_irq/sysbus_connect_irq). So I'd leave it upto Paolo or someone else to decide/comment on.Quoted 13 lines
Sounds like a plan, I'll try to come up with the test results (at least for Windows 10 guest which is what I have setup) and update this thread with the results.
-- Jon.
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Paolo
Hi guys,
Sorry for the delay...
So first ill clarify what was the test, the test was to see the device "Microsoft Hyper-V Virtual Machine Bus" in Windows Device Manager under "System devices" with a state of "working properly".
It seems like it's ok to drop all the _PS* and
_STA.It seems to be functioning with single IRQ as well, it is worth noting that even when i dropped the entire
_CRS(so no IRQs resources are required, the device was still showing that it's functioning, but I suspect this might affect the child devices like hv-net and hv-scsi).With that said I did run into a small issue I set-up Win10 1903 (aka 19H1) and it seems like VMBus now requires to have the following features enabled:
HV_VP_RUNTIME_AVAILABLEHV_TIME_REF_COUNT_AVAILABLEHV_SYNIC_AVAILABLEHV_SYNTIMERS_AVAILABLEHV_APIC_ACCESS_AVAILABLEHV_HYPERCALL_AVAILABLEHV_VP_INDEX_AVAILABLESo notice that previously only SYNIC and VPINDEX was needed, now you need the whole thing so you need to run qemu with something like -cpu host,hv-relaxed,hv_spinlocks=0x1fff,hv_time,hv-vapic,hv-vpindex,hv-synic,hv-runtime,hv-stimer
Quoted 8 lines
The validation was done in winhv!WinHvpCheckPartitionPrivileges .
Paolo I noticed you have done a PULL request, would you like to wait on it and we will submit a version with a single IRQ (selectable by user property) and go with Igor's suggestion dropping _PS* and
_STA(though like I said before I prefer to mimic the original HyperV with it's bugs, but I'll leave this decision to you).Also today VMBus only verifies SYNIC is enabled I'm not sure how but I wonder if we want to some how exports from the CPU which other HV features are enabled so we can verify all the required ones are set, would appreciate if you have any suggestions here.
Cheers,
-- Jon.
I got the latest DSDT from one of the latest builds 19041
Device (\_SB.VMOD.VMBS)
{
Name (STA, 0x0F)
Name (_ADR, Zero) // _ADR: Address
Name (_DDN, "VMBUS") // _DDN: DOS Device Name
Name (_HID, "VMBus") // _HID: Hardware ID
Name (_UID, Zero) // _UID: Unique ID
Method (_DIS, 0, NotSerialized) // _DIS: Disable Device
{
STA &= 0x0D
}
Method (_PS0, 0, NotSerialized) // _PS0: Power State 0
{
STA |= 0x0F
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
Return (STA) /* \_SB_.VMOD.VMBS.STA_ */
}
Name (_PS3, Zero) // _PS3: Power State 3
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
{
IRQ (Edge, ActiveHigh, Exclusive, )
{5}
})
}So things looks the same...
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
In reply to Jon DoronHi Jon,
Quoted 79 lines · Jon Doron
Quoted 61 lines · Jon Doron
Quoted 49 lines · Igor Mammedov
Quoted 32 lines · On Thu, 28 May 2020 08:26:42 +0300 Jon Doron <[email protected]> wrote:
Quoted 18 lines · Igor Mammedow
Quoted 8 lines · On Thu, 21 May 2020 18:02:07 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
that I don't know that's why I'm not suggesting how to do it. The point is hard-coding in AML random IRQs is not right thing to do, (especially with the lack of 'any' spec), as minimum AML should pull it from device model and that probably should be configurable and set by board.
Quoted 9 lines
Other thing is:
I haven't looked at VMBus device model in detail, but DSDT part aren't matching device though (device model is not ISA device hence AML part shouldn't be on in ISA scope), where to put it is open question. There were other issues with AML code, I've commented on, so I was waiting on respin with comments addressed.
I don't think that this patch is good enough for merging.But it seems like the current patch does match what's Microsoft HyperV is publishing in it's APCI tables.
Quoted 8 lines
I dont think it's correct for us to "fix" Microsoft emulation even if it's wrong, since that's what Windows probably expects to see...
I tried looking where Microsoft uses the ACPI tables to identify the VMBus but without much luck in order to understand how flexible a change would be for the OS to still detect the VMBus device, but in general I think "correcting" something that is emulated 1:1 because there is no spec is the right way.
I'd agree, if removing nonsense would break VMBus detection (does it?). if something is that doesn't make sense but has to stay because it is need to make windows happy, that's fine , just add annotate is with comment, so it won't confuse anyone why that code exists there later on.
Quoted 10 lines
I suggest to:
1. try dropping _PS* &_STAas it doesn't actually does anything and_PS3is plain wrong
2. drop one IRQ, newer hyper-v seems to be doing fine with only one
3. it's not ISA device, I'd suggest to move into_SBscope
4. I don't know much about IRQs but
git grepDEFINE_PROP_| grep -i iqr
yields nothing so I'm not sure if it's acceptable. Typically it's board that assigns IRQ and not device, for Sysbus devices (see: sysbus_init_irq/sysbus_connect_irq). So I'd leave it upto Paolo or someone else to decide/comment on.Quoted 13 lines
Sounds like a plan, I'll try to come up with the test results (at least for Windows 10 guest which is what I have setup) and update this thread with the results.
-- Jon.
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Paolo
Hi guys,
Sorry for the delay...
Quoted 7 lines
So first ill clarify what was the test, the test was to see the device "Microsoft Hyper-V Virtual Machine Bus" in Windows Device Manager under "System devices" with a state of "working properly".
It seems like it's ok to drop all the _PS* and
_STA.It seems to be functioning with single IRQ as well, it is worth noting that even when i dropped the entire
_CRS(so no IRQs resources are required, the device was still showing that it's functioning, but I suspect this might affect the child devices like hv-net and hv-scsi).
I guess you tested a single Windows version, correct?
It may be that requirements differ between Windows versions, just as you say below about the required enlightenments.
Quoted 9 lines
With that said I did run into a small issue I set-up Win10 1903 (aka 19H1) and it seems like VMBus now requires to have the following features enabled:
HV_VP_RUNTIME_AVAILABLEHV_TIME_REF_COUNT_AVAILABLEHV_SYNIC_AVAILABLEHV_SYNTIMERS_AVAILABLEHV_APIC_ACCESS_AVAILABLEHV_HYPERCALL_AVAILABLEHV_VP_INDEX_AVAILABLE
Quoted 6 lines
So notice that previously only SYNIC and VPINDEX was needed, now you need the whole thing so you need to run qemu with something like -cpu host,hv-relaxed,hv_spinlocks=0x1fff,hv_time,hv-vapic,hv-vpindex,hv-synic,hv-runtime,hv-stimer
The validation was done in winhv!WinHvpCheckPartitionPrivileges .
Paolo I noticed you have done a PULL request, would you like to wait on it and we will submit a version with a single IRQ (selectable by user property) and go with Igor's suggestion dropping _PS* and
_STA(though like I said before I prefer to mimic the original HyperV with it's bugs, but I'll leave this decision to you).
The code is already in the upstream QEMU tree, it's a known-working code, so I think it is better to simply work incrementally on further improving the current version rather than backing it out and merging it again later.
This way it will (hopefully) get some wider testing sooner.
Not to mention that it is less likely for some other QEMU change to accidentally break it.
Quoted 4 lines
Also today VMBus only verifies SYNIC is enabled I'm not sure how but I wonder if we want to some how exports from the CPU which other HV features are enabled so we can verify all the required ones are set, would appreciate if you have any suggestions here.
Cheers,
-- Jon.
Thanks,
Maciej
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 86 lines · Maciej S. Szmigiero
Hi Jon,
Quoted 83 lines · Jon Doron
Quoted 61 lines · Jon Doron
Quoted 49 lines · Igor Mammedov
Quoted 32 lines · On Thu, 28 May 2020 08:26:42 +0300 Jon Doron <[email protected]> wrote:
Quoted 18 lines · Igor Mammedow
Quoted 8 lines · On Thu, 21 May 2020 18:02:07 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
that I don't know that's why I'm not suggesting how to do it. The point is hard-coding in AML random IRQs is not right thing to do, (especially with the lack of 'any' spec), as minimum AML should pull it from device model and that probably should be configurable and set by board.
Quoted 9 lines
Other thing is:
I haven't looked at VMBus device model in detail, but DSDT part aren't matching device though (device model is not ISA device hence AML part shouldn't be on in ISA scope), where to put it is open question. There were other issues with AML code, I've commented on, so I was waiting on respin with comments addressed.
I don't think that this patch is good enough for merging.But it seems like the current patch does match what's Microsoft HyperV is publishing in it's APCI tables.
Quoted 8 lines
I dont think it's correct for us to "fix" Microsoft emulation even if it's wrong, since that's what Windows probably expects to see...
I tried looking where Microsoft uses the ACPI tables to identify the VMBus but without much luck in order to understand how flexible a change would be for the OS to still detect the VMBus device, but in general I think "correcting" something that is emulated 1:1 because there is no spec is the right way.
I'd agree, if removing nonsense would break VMBus detection (does it?). if something is that doesn't make sense but has to stay because it is need to make windows happy, that's fine , just add annotate is with comment, so it won't confuse anyone why that code exists there later on.
Quoted 10 lines
I suggest to:
1. try dropping _PS* &_STAas it doesn't actually does anything and_PS3is plain wrong
2. drop one IRQ, newer hyper-v seems to be doing fine with only one
3. it's not ISA device, I'd suggest to move into_SBscope
4. I don't know much about IRQs but
git grepDEFINE_PROP_| grep -i iqr
yields nothing so I'm not sure if it's acceptable. Typically it's board that assigns IRQ and not device, for Sysbus devices (see: sysbus_init_irq/sysbus_connect_irq). So I'd leave it upto Paolo or someone else to decide/comment on.Quoted 13 lines
Sounds like a plan, I'll try to come up with the test results (at least for Windows 10 guest which is what I have setup) and update this thread with the results.
-- Jon.
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Paolo
Hi guys,
Sorry for the delay...
So first ill clarify what was the test, the test was to see the device "Microsoft Hyper-V Virtual Machine Bus" in Windows Device Manager under "System devices" with a state of "working properly".
Quoted 8 lines
Quoted 3 lines
It seems like it's ok to drop all the _PS* and
_STA.It seems to be functioning with single IRQ as well, it is worth noting that even when i dropped the entire
_CRS(so no IRQs resources are required, the device was still showing that it's functioning, but I suspect this might affect the child devices like hv-net and hv-scsi).I guess you tested a single Windows version, correct?
It may be that requirements differ between Windows versions, just as you say below about the required enlightenments.
Yes I have tested only a single version, but from the looks of it there is only a single IRQ in the HyperV APCI table that I have looked at, and I believe the one you have pasted as well in the past, so that change sounds reasonable to me.
As for the enlightenments dont you prefer to have all those as mandatory for VMBus in order not to run into the issue I have encountered?
Quoted 16 lines
Quoted 9 lines
With that said I did run into a small issue I set-up Win10 1903 (aka 19H1) and it seems like VMBus now requires to have the following features enabled:
HV_VP_RUNTIME_AVAILABLEHV_TIME_REF_COUNT_AVAILABLEHV_SYNIC_AVAILABLEHV_SYNTIMERS_AVAILABLEHV_APIC_ACCESS_AVAILABLEHV_HYPERCALL_AVAILABLEHV_VP_INDEX_AVAILABLEQuoted 6 lines
So notice that previously only SYNIC and VPINDEX was needed, now you need the whole thing so you need to run qemu with something like -cpu host,hv-relaxed,hv_spinlocks=0x1fff,hv_time,hv-vapic,hv-vpindex,hv-synic,hv-runtime,hv-stimer
The validation was done in winhv!WinHvpCheckPartitionPrivileges .
Paolo I noticed you have done a PULL request, would you like to wait on it and we will submit a version with a single IRQ (selectable by user property) and go with Igor's suggestion dropping _PS* and
_STA(though like I said before I prefer to mimic the original HyperV with it's bugs, but I'll leave this decision to you).
Quoted 9 lines
The code is already in the upstream QEMU tree, it's a known-working code, so I think it is better to simply work incrementally on further improving the current version rather than backing it out and merging it again later.
This way it will (hopefully) get some wider testing sooner.
Not to mention that it is less likely for some other QEMU change to accidentally break it.
That's great I agree incrementally is the right way here, should we open another Thread to discuss all these changes or do you prefer we will keep going on this one?
Quoted 7 lines
Quoted 4 lines
Also today VMBus only verifies SYNIC is enabled I'm not sure how but I wonder if we want to some how exports from the CPU which other HV features are enabled so we can verify all the required ones are set, would appreciate if you have any suggestions here.
Cheers,
-- Jon.Thanks,
Maciej
Thanks,
-- Jon.
Re: [PATCH v4 5/6] i386: Hyper-V VMBus ACPI DSDT entry
Quoted 89 lines · Jon Doron
Quoted 88 lines · Maciej S. Szmigiero
Hi Jon,
Quoted 85 lines · Jon Doron
Quoted 61 lines · Jon Doron
Quoted 49 lines · Igor Mammedov
Quoted 32 lines · On Thu, 28 May 2020 08:26:42 +0300 Jon Doron <[email protected]> wrote:
Quoted 18 lines · Igor Mammedow
Quoted 8 lines · On Thu, 21 May 2020 18:02:07 +0200 Paolo Bonzini <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
I'd rather avoid using random IRQ numbers (considering we are dealing with black-box here). So if it's really necessary to have IRQ described here, I'd suggest to implement them in device model so they would be reserved and QEMU would error out in a sane way if IRQ conflict is detected.
We don't generally detect ISA IRQ conflicts though, do we?
that I don't know that's why I'm not suggesting how to do it. The point is hard-coding in AML random IRQs is not right thing to do, (especially with the lack of 'any' spec), as minimum AML should pull it from device model and that probably should be configurable and set by board.
Quoted 9 lines
Other thing is:
I haven't looked at VMBus device model in detail, but DSDT part aren't matching device though (device model is not ISA device hence AML part shouldn't be on in ISA scope), where to put it is open question. There were other issues with AML code, I've commented on, so I was waiting on respin with comments addressed.
I don't think that this patch is good enough for merging.But it seems like the current patch does match what's Microsoft HyperV is publishing in it's APCI tables.
Quoted 8 lines
I dont think it's correct for us to "fix" Microsoft emulation even if it's wrong, since that's what Windows probably expects to see...
I tried looking where Microsoft uses the ACPI tables to identify the VMBus but without much luck in order to understand how flexible a change would be for the OS to still detect the VMBus device, but in general I think "correcting" something that is emulated 1:1 because there is no spec is the right way.
I'd agree, if removing nonsense would break VMBus detection (does it?). if something is that doesn't make sense but has to stay because it is need to make windows happy, that's fine , just add annotate is with comment, so it won't confuse anyone why that code exists there later on.
Quoted 10 lines
I suggest to:
1. try dropping _PS* &_STAas it doesn't actually does anything and_PS3is plain wrong
2. drop one IRQ, newer hyper-v seems to be doing fine with only one
3. it's not ISA device, I'd suggest to move into_SBscope
4. I don't know much about IRQs but
git grepDEFINE_PROP_| grep -i iqr
yields nothing so I'm not sure if it's acceptable. Typically it's board that assigns IRQ and not device, for Sysbus devices (see: sysbus_init_irq/sysbus_connect_irq). So I'd leave it upto Paolo or someone else to decide/comment on.Quoted 13 lines
Sounds like a plan, I'll try to come up with the test results (at least for Windows 10 guest which is what I have setup) and update this thread with the results.
-- Jon.
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Paolo
Hi guys,
Sorry for the delay...
So first ill clarify what was the test, the test was to see the device "Microsoft Hyper-V Virtual Machine Bus" in Windows Device Manager under "System devices" with a state of "working properly".
It seems like it's ok to drop all the _PS* and
_STA.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
It seems to be functioning with single IRQ as well, it is worth noting that even when i dropped the entire
_CRS(so no IRQs resources are required, the device was still showing that it's functioning, but I suspect this might affect the child devices like hv-net and hv-scsi).I guess you tested a single Windows version, correct?
It may be that requirements differ between Windows versions, just as you say below about the required enlightenments.Yes I have tested only a single version, but from the looks of it there is only a single IRQ in the HyperV APCI table that I have looked at, and I believe the one you have pasted as well in the past, so that change sounds reasonable to me.
I meant also other changes, like dropping of some ACPI methods.
Quoted 1 line
As for the enlightenments dont you prefer to have all those as mandatory for VMBus in order not to run into the issue I have encountered?
Well, if somebody wants to run only older guests they will be content with just a limited set of enlightenments, right?
But I don't know what's the QEMU project policy is here.
Quoted 20 lines
Quoted 20 lines
Quoted 9 lines
With that said I did run into a small issue I set-up Win10 1903 (aka 19H1) and it seems like VMBus now requires to have the following features enabled:
HV_VP_RUNTIME_AVAILABLEHV_TIME_REF_COUNT_AVAILABLEHV_SYNIC_AVAILABLEHV_SYNTIMERS_AVAILABLEHV_APIC_ACCESS_AVAILABLEHV_HYPERCALL_AVAILABLEHV_VP_INDEX_AVAILABLEQuoted 6 lines
So notice that previously only SYNIC and VPINDEX was needed, now you need the whole thing so you need to run qemu with something like -cpu host,hv-relaxed,hv_spinlocks=0x1fff,hv_time,hv-vapic,hv-vpindex,hv-synic,hv-runtime,hv-stimer
The validation was done in winhv!WinHvpCheckPartitionPrivileges .
Paolo I noticed you have done a PULL request, would you like to wait on it and we will submit a version with a single IRQ (selectable by user property) and go with Igor's suggestion dropping _PS* and
_STA(though like I said before I prefer to mimic the original HyperV with it's bugs, but I'll leave this decision to you).The code is already in the upstream QEMU tree, it's a known-working code, so I think it is better to simply work incrementally on further improving the current version rather than backing it out and merging it again later.
Quoted 7 lines
Quoted 5 lines
This way it will (hopefully) get some wider testing sooner.
Not to mention that it is less likely for some other QEMU change to accidentally break it.
That's great I agree incrementally is the right way here, should we open another Thread to discuss all these changes or do you prefer we will keep going on this one?
If that's going to be an incremental change it is probably worth its own email thread.
Otherwise the existing one will grow without bounds.
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
Also today VMBus only verifies SYNIC is enabled I'm not sure how but I wonder if we want to some how exports from the CPU which other HV features are enabled so we can verify all the required ones are set, would appreciate if you have any suggestions here.
Thanks,
-- Jon.
Thanks,
Maciej
PATCH v4 6/6 vmbus: add infrastructure to save/load vmbus requests
In reply to Jon DoronThis can be allow to include controller-specific data while saving/loading in-flight scsi requests of the vmbus scsi controller.
--- hw/hyperv/vmbus.c | 99 +++++++++++++++++++++++++++++++++++++++ include/hw/hyperv/vmbus.h | 3 ++ 2 files changed, 102 insertions(+)
hw/hyperv/vmbus.c +99 -0
@@ -1272,6 +1272,105 @@ void vmbus_free_req(void *req)g_free (req); } +static const VMStateDescription vmstate_sgent = { + .name ="vmbus/sgentry" , + .version_id =0 , + .minimum_version_id =0 , + .fields = (VMStateField []) { +VMSTATE_UINT64 (base, ScatterGatherEntry), +VMSTATE_UINT64 (len, ScatterGatherEntry), +VMSTATE_END_OF_LIST () + } +}; + +typedef struct VMBusChanReqSave { +uint16_t chan_idx; +uint16_t pkt_type; +uint32_t msglen; +void *msg; +uint64_t transaction_id; +bool need_comp; +uint32_t num; +ScatterGatherEntry *sgl; +}VMBusChanReqSave ; + +static const VMStateDescription vmstate_vmbus_chan_req = { + .name ="vmbus/vmbus_chan_req" , + .version_id =0 , + .minimum_version_id =0 , + .fields = (VMStateField []) { +VMSTATE_UINT16 (chan_idx, VMBusChanReqSave), +VMSTATE_UINT16 (pkt_type, VMBusChanReqSave), +VMSTATE_UINT32 (msglen, VMBusChanReqSave), +VMSTATE_VBUFFER_ALLOC_UINT32 (msg, VMBusChanReqSave,0 ,NULL , msglen), +VMSTATE_UINT64 (transaction_id, VMBusChanReqSave), +VMSTATE_BOOL (need_comp, VMBusChanReqSave), +VMSTATE_UINT32 (num, VMBusChanReqSave), +VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (sgl, VMBusChanReqSave, num, + vmstate_sgent, ScatterGatherEntry), +VMSTATE_END_OF_LIST () + } +}; + +void vmbus_save_req (QEMUFile *f,VMBusChanReq *req) +{ +VMBusChanReqSave req_save; + + req_save.chan_idx = req->chan->subchan_idx; + req_save.pkt_type = req->pkt_type; + req_save.msglen = req->msglen; + req_save.msg = req->msg; + req_save.transaction_id = req->transaction_id; + req_save.need_comp = req->need_comp; + req_save.num = req->sgl.nsg; + req_save.sgl =g_memdup (req->sgl.sg, + req_save.num *sizeof (ScatterGatherEntry)); + +vmstate_save_state (f, &vmstate_vmbus_chan_req, &req_save,NULL ); + +g_free (req_save.sgl); +} + +void *vmbus_load_req (QEMUFile *f,VMBusDevice *dev,uint32_t size) +{ +VMBusChanReqSave req_save; +VMBusChanReq *req =NULL ; +VMBusChannel *chan =NULL ; +uint32_t i; + +vmstate_load_state (f, &vmstate_vmbus_chan_req, &req_save,0 ); + +if (req_save.chan_idx >= dev->num_channels) { +error_report ("%s: %u(chan_idx) > %u(num_channels)" , __func__, + req_save.chan_idx, dev->num_channels); + goto out; + } + chan = &dev->channels[req_save.chan_idx]; + +if (vmbus_channel_reserve (chan,0 , req_save.msglen)) { + goto out; + } + + req =vmbus_alloc_req (chan, size, req_save.pkt_type, req_save.msglen, + req_save.transaction_id, req_save.need_comp); +if (req_save.msglen) { +memcpy (req->msg, req_save.msg, req_save.msglen); + } + +for (i =0 ; i < req_save.num; i++) { +qemu_sglist_add (&req->sgl, req_save.sgl[i].base, req_save.sgl[i].len); + } + +out: +if (req_save.msglen) { +g_free (req_save.msg); + } +if (req_save.num) { +g_free (req_save.sgl); + } +return req; +} +static void channel_event_cb (EventNotifier *e) {VMBusChannel *chan =container_of (e, VMBusChannel, notifier);
include/hw/hyperv/vmbus.h +3 -0
@@ -224,4 +224,7 @@ int vmbus_map_sgl(VMBusChanReq *req, DMADirection dir, struct iovec *iov,void vmbus_unmap_sgl (VMBusChanReq *req,DMADirection dir,struct iovec *iov,unsigned iov_cnt,size_t accessed); +void vmbus_save_req (QEMUFile *f,VMBusChanReq *req); +void *vmbus_load_req (QEMUFile *f,VMBusDevice *dev,uint32_t size); +#endif
Signature · 1 line
2.24.1
Paolo Bonzini
AppliedQuoted 52 lines · Jon Doron
This is a rebase of the old patchset from Roman for HyperV VMBus implementation.
How to use:
-device vmbus-bridgeLater on new paravirtualized devices can be implemented on top of it (Network/SCSI/etc.)
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.hin Microsoft's WDK.v4:
Decided to ditch the patch that envolves handling of EOM as there is still a discussion going on with it in the KVM mailing list.v3:
Fixed an error asanv2:
Rebased on top of latest patchset from Roman and MaciejJon Doron (6):
hyperv: expose API to determine if synic is enabled
vmbus: add vmbus protocol definitions
vmbus: vmbus implementation
i386:pc: whitelist dynamic vmbus-bridge
i386: Hyper-V VMBus ACPI DSDT entry
vmbus: add infrastructure to save/load vmbus requestsMakefile.objs | 1 + hw/hyperv/Kconfig | 5 + hw/hyperv/Makefile.objs | 1 + hw/hyperv/hyperv.c | 8 + hw/hyperv/trace-events | 18 + hw/hyperv/vmbus.c | 2778 ++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 43 + hw/i386/pc_piix.c | 2 + hw/i386/pc_q35.c | 2 + include/hw/hyperv/hyperv.h | 1 + include/hw/hyperv/vmbus-bridge.h | 35 +
Quoted 9 lines
include/hw/hyperv/vmbus-proto.h | 222 +++ include/hw/hyperv/vmbus.h | 230 +++ 13 files changed, 3346 insertions(+) create mode 100644 hw/hyperv/trace-events create mode 100644 hw/hyperv/vmbus.c create mode 100644 include/hw/hyperv/vmbus-bridge.h create mode 100644 include/hw/hyperv/vmbus-proto.h create mode 100644 include/hw/hyperv/vmbus.h
Queued, thanks. I'll take a look at the EOM handling threads next.
Paolo
Quoted 63 lines · Paolo Bonzini
Quoted 52 lines · Jon Doron
This is a rebase of the old patchset from Roman for HyperV VMBus implementation.
How to use:
-device vmbus-bridgeLater on new paravirtualized devices can be implemented on top of it (Network/SCSI/etc.)
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.hin Microsoft's WDK.v4:
Decided to ditch the patch that envolves handling of EOM as there is still a discussion going on with it in the KVM mailing list.v3:
Fixed an error asanv2:
Rebased on top of latest patchset from Roman and MaciejJon Doron (6):
hyperv: expose API to determine if synic is enabled
vmbus: add vmbus protocol definitions
vmbus: vmbus implementation
i386:pc: whitelist dynamic vmbus-bridge
i386: Hyper-V VMBus ACPI DSDT entry
vmbus: add infrastructure to save/load vmbus requestsMakefile.objs | 1 + hw/hyperv/Kconfig | 5 + hw/hyperv/Makefile.objs | 1 + hw/hyperv/hyperv.c | 8 + hw/hyperv/trace-events | 18 + hw/hyperv/vmbus.c | 2778 ++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 43 + hw/i386/pc_piix.c | 2 + hw/i386/pc_q35.c | 2 + include/hw/hyperv/hyperv.h | 1 + include/hw/hyperv/vmbus-bridge.h | 35 +Quoted 9 lines
include/hw/hyperv/vmbus-proto.h | 222 +++ include/hw/hyperv/vmbus.h | 230 +++ 13 files changed, 3346 insertions(+) create mode 100644 hw/hyperv/trace-events create mode 100644 hw/hyperv/vmbus.c create mode 100644 include/hw/hyperv/vmbus-bridge.h create mode 100644 include/hw/hyperv/vmbus-proto.h create mode 100644 include/hw/hyperv/vmbus.h
Quoted 4 lines
Queued, thanks. I'll take a look at the EOM handling threads next.
Paolo
Hi Paolo, there is no need to look at the EOM, we have scraped it as you can see in v4 :)
Quoted 10 lines · Jon Doron
Quoted 7 lines
Quoted 2 lines
Queued, thanks. I'll take a look at the EOM handling threads next.
Paolo
Hi Paolo, there is no need to look at the EOM, we have scraped it as you can see in v4 :)
I mean in order to un-scrape it. :)
Paolo