public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Avi Kivity <avi@redhat.com>
Cc: "Yang, Sheng" <sheng.yang@intel.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	kvm-devel <kvm@vger.kernel.org>
Subject: [PATCH v2] external modules: Fix pre-2.6.18 kernels
Date: Wed, 04 Feb 2009 19:10:04 +0100	[thread overview]
Message-ID: <4989D9FC.1010507@siemens.com> (raw)

pci_dev.msi_enabled was introduced in 2.6.18, thus building against
older kernels now fails. Fix via a compat wrapper that reads directly
from the PCI config space.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

 kernel/external-module-compat-comm.h |   13 +++++++++++++
 kernel/external-module-compat.c      |   21 +++++++++++++++++++++
 kernel/x86/hack-module.awk           |    2 ++
 3 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/kernel/external-module-compat-comm.h b/kernel/external-module-compat-comm.h
index 239590e..4a9ad4c 100644
--- a/kernel/external-module-compat-comm.h
+++ b/kernel/external-module-compat-comm.h
@@ -729,3 +729,16 @@ static inline void cpumask_clear_cpu(int cpu, cpumask_var_t mask)
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
 #define marker_synchronize_unregister() synchronize_sched()
 #endif
+
+/* pci_dev.msi_enable was introduced in 2.6.18 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+
+struct pci_dev;
+
+int kvm_pcidev_msi_enabled(struct pci_dev *dev);
+
+#else
+
+#define kvm_pcidev_msi_enabled(dev)	(dev)->msi_enabled
+
+#endif
diff --git a/kernel/external-module-compat.c b/kernel/external-module-compat.c
index 823ce82..f425e08 100644
--- a/kernel/external-module-compat.c
+++ b/kernel/external-module-compat.c
@@ -313,3 +313,24 @@ struct rchan *kvm_relay_open(const char *base_filename,
 }
 
 #endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+
+#include <linux/pci.h>
+
+int kvm_pcidev_msi_enabled(struct pci_dev *dev)
+{
+	int pos;
+	u16 control;
+
+	if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSI)))
+		return 0;
+
+	pci_read_config_word(dev, pos + PCI_MSI_FLAGS, &control);
+	if (control & PCI_MSI_FLAGS_ENABLE)
+		return 1;
+
+	return 0;
+}
+
+#endif
diff --git a/kernel/x86/hack-module.awk b/kernel/x86/hack-module.awk
index deb68f4..a05c0c3 100644
--- a/kernel/x86/hack-module.awk
+++ b/kernel/x86/hack-module.awk
@@ -29,6 +29,8 @@ BEGIN { split("INIT_WORK tsc_khz desc_struct ldttss_desc64 desc_ptr " \
     printf("MODULE_INFO(version, \"%s\");\n", version)
 }
 
+{ sub(/match->dev->msi_enabled/, "kvm_pcidev_msi_enabled(match->dev)") }
+
 /^static void __vmx_load_host_state/ {
     vmx_load_host_state = 1
 }


             reply	other threads:[~2009-02-04 18:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-04 18:10 Jan Kiszka [this message]
2009-02-05 12:48 ` [PATCH v2] external modules: Fix pre-2.6.18 kernels Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4989D9FC.1010507@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=sheng.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox