===================================================================
@@ -809,6 +809,16 @@ static int assign_device(AssignedDevice
struct kvm_assigned_pci_dev assigned_dev_data;
int r;
+#ifdef KVM_CAP_PCI_SEGMENT
+ /* Only pass non-zero PCI segment to capable module */
+ if (!kvm_check_extension(kvm_state, KVM_CAP_PCI_SEGMENT) &&
+ dev->h_segnr) {
+ fprintf(stderr, "Can't assign device inside non-zero PCI segment "
+ "as this KVM module doesn't support it.\n");
+ return -ENODEV;
+ }
+#endif
+
memset(&assigned_dev_data, 0, sizeof(assigned_dev_data));
assigned_dev_data.assigned_dev_id =
calc_assigned_dev_id(dev->h_segnr, dev->h_busnr, dev->h_devfn);
===================================================================
@@ -498,6 +498,8 @@ struct kvm_ioeventfd {
#define KVM_CAP_S390_PSW 42
#define KVM_CAP_PPC_SEGSTATE 43
+#define KVM_CAP_PCI_SEGMENT 47
+
#ifdef KVM_CAP_IRQ_ROUTING
struct kvm_irq_routing_irqchip {
===================================================================
@@ -500,6 +500,7 @@ struct kvm_ioeventfd {
#define KVM_CAP_HYPERV 44
#define KVM_CAP_HYPERV_VAPIC 45
#define KVM_CAP_HYPERV_SPIN 46
+#define KVM_CAP_PCI_SEGMENT 47
#ifdef KVM_CAP_IRQ_ROUTING
===================================================================
@@ -1569,6 +1569,7 @@ int kvm_dev_ioctl_check_extension(long e
case KVM_CAP_HYPERV:
case KVM_CAP_HYPERV_VAPIC:
case KVM_CAP_HYPERV_SPIN:
+ case KVM_CAP_PCI_SEGMENT:
r = 1;
break;
case KVM_CAP_COALESCED_MMIO: