From patchwork Mon Feb 1 09:22:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhai, Edwin" X-Patchwork-Id: 76046 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o119Mqpi004551 for ; Mon, 1 Feb 2010 09:22:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751265Ab0BAJWu (ORCPT ); Mon, 1 Feb 2010 04:22:50 -0500 Received: from mga11.intel.com ([192.55.52.93]:32510 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750724Ab0BAJWt (ORCPT ); Mon, 1 Feb 2010 04:22:49 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 01 Feb 2010 01:21:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.49,382,1262592000"; d="scan'208";a="768958839" Received: from shxpwgzhai1a.ccr.corp.intel.com (HELO [10.239.48.189]) ([10.239.48.189]) by fmsmga001.fm.intel.com with ESMTP; 01 Feb 2010 01:22:44 -0800 Message-ID: <4B669D67.4080303@intel.com> Date: Mon, 01 Feb 2010 17:22:47 +0800 From: "Zhai, Edwin" User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: Chris Wright CC: Marcelo Tosatti , "kvm@vger.kernel.org" Subject: Re: [PATCH] enable PCI multiple-segments for pass-through device References: <4B628274.5020005@intel.com> <20100130000816.GL13518@sequoia.sous-sol.org> In-Reply-To: <20100130000816.GL13518@sequoia.sous-sol.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 01 Feb 2010 09:22:53 +0000 (UTC) Index: qemu-kvm/hw/device-assignment.c =================================================================== --- qemu-kvm.orig/hw/device-assignment.c +++ qemu-kvm/hw/device-assignment.c @@ -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); Index: qemu-kvm/kvm/include/linux/kvm.h =================================================================== --- qemu-kvm.orig/kvm/include/linux/kvm.h +++ qemu-kvm/kvm/include/linux/kvm.h @@ -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 { Index: linux-2.6/include/linux/kvm.h =================================================================== --- linux-2.6.orig/include/linux/kvm.h +++ linux-2.6/include/linux/kvm.h @@ -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 Index: linux-2.6/arch/x86/kvm/x86.c =================================================================== --- linux-2.6.orig/arch/x86/kvm/x86.c +++ linux-2.6/arch/x86/kvm/x86.c @@ -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: