From 6e270b5f8cd4a7195c5e6b9e74f84d7d7185ccdf Mon Sep 17 00:00:00 2001 From: John Davis Date: Wed, 11 Mar 2026 19:44:03 -0500 Subject: [PATCH] hyperv: Add mmio_size attribute to device nodes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some devices such as graphics and PCI passthrough bridges require MMIO space. Add this as a device node attribute if present. Change-Id: Id374ff61c29c1ccad10e3a7f3f7053c14d02aa5e Reviewed-on: https://review.haiku-os.org/c/haiku/+/10483 Tested-by: Commit checker robot Reviewed-by: Jérôme Duval --- headers/private/hyperv/hyperv.h | 1 + src/add-ons/kernel/bus_managers/hyperv/VMBus.cpp | 14 +++++++++++++- .../kernel/bus_managers/hyperv/VMBusPrivate.h | 5 +++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/headers/private/hyperv/hyperv.h b/headers/private/hyperv/hyperv.h index 4f223e58c4..4067dae4ed 100644 --- a/headers/private/hyperv/hyperv.h +++ b/headers/private/hyperv/hyperv.h @@ -17,6 +17,7 @@ #define HYPERV_CHANNEL_ID_ITEM "hyperv/channel" #define HYPERV_DEVICE_TYPE_STRING_ITEM "hyperv/type_string" #define HYPERV_INSTANCE_ID_ITEM "hyperv/instance" +#define HYPERV_MMIO_SIZE_ITEM "hyperv/mmio_size" #define HYPERV_PRETTYNAME_VMBUS "Hyper-V Virtual Machine Bus" #define HYPERV_PRETTYNAME_VMBUS_DEVICE_FMT "Hyper-V Channel %u" diff --git a/src/add-ons/kernel/bus_managers/hyperv/VMBus.cpp b/src/add-ons/kernel/bus_managers/hyperv/VMBus.cpp index 98cdc88179..267b80bbd4 100644 --- a/src/add-ons/kernel/bus_managers/hyperv/VMBus.cpp +++ b/src/add-ons/kernel/bus_managers/hyperv/VMBus.cpp @@ -697,6 +697,7 @@ VMBus::_ProcessPendingMessage(int32_t cpu) channel->dedicated_int = offerMessage->dedicated_int != 0; channel->connection_id = offerMessage->connection_id; } + channel->mmio_size = static_cast(offerMessage->mmio_size_mb) * 1024 * 1024; // Add new channel to offer queue and signal the channel handler thread MutexLocker locker(fChannelQueueLock); @@ -1093,7 +1094,7 @@ VMBus::_RegisterChannel(VMBusChannel* channel) snprintf(prettyName, sizeof(prettyName), HYPERV_PRETTYNAME_VMBUS_DEVICE_FMT, channel->channel_id); - device_attr attributes[] = { + device_attr attributes[10] = { { B_DEVICE_BUS, B_STRING_TYPE, { .string = HYPERV_BUS_NAME }}, { B_DEVICE_PRETTY_NAME, B_STRING_TYPE, @@ -1107,6 +1108,17 @@ VMBus::_RegisterChannel(VMBusChannel* channel) { NULL } }; + uint32 attributeCount = 5; + + // Add MMIO attribute if present (typically PCI passthrough and graphics) + if (channel->mmio_size > 0) { + attributes[attributeCount] = { + HYPERV_MMIO_SIZE_ITEM, B_UINT32_TYPE, + { .ui32 = channel->mmio_size } + }; + attributeCount++; + } + // Add to active channel list InterruptsSpinLocker spinLocker(fChannelsSpinlock); if (fHighestChannelID < channel->channel_id) diff --git a/src/add-ons/kernel/bus_managers/hyperv/VMBusPrivate.h b/src/add-ons/kernel/bus_managers/hyperv/VMBusPrivate.h index b87197b0a9..4de75a5400 100644 --- a/src/add-ons/kernel/bus_managers/hyperv/VMBusPrivate.h +++ b/src/add-ons/kernel/bus_managers/hyperv/VMBusPrivate.h @@ -90,11 +90,12 @@ struct VMBusChannel : DoublyLinkedListLinkImpl { mutex_destroy(&lock); } - uint32_t channel_id; + uint32 channel_id; vmbus_guid_t type_id; vmbus_guid_t instance_id; bool dedicated_int; - uint32_t connection_id; + uint32 connection_id; + uint32 mmio_size; mutex lock; device_node* node;