From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Egger Subject: [PATCH] netbsd: pci passthrough for HVM guests Date: Fri, 8 Jun 2012 18:14:34 +0200 Message-ID: <4FD224EA.5080704@amd.com> References: <4FC8B8F5.9000102@amd.com> <20424.61304.260546.736913@mariner.uk.xensource.com> <4FCF6762.7080904@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020702070007020502010607" Return-path: In-Reply-To: <4FCF6762.7080904@amd.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson , "xen-devel@lists.xen.org" Cc: =?ISO-8859-1?Q?Roger_Pau_Monn=E9?= , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org --------------020702070007020502010607 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Implement pci passthrough for HVM guests for NetBSD Dom0. Signed-off-by: Christoph Egger From: Manuel Bouyer -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 --------------020702070007020502010607 Content-Type: text/plain; charset="us-ascii"; name="qemu_xen_traditional_pci_netbsd.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="qemu_xen_traditional_pci_netbsd.diff" Content-Description: qemu_xen_traditional_pci_netbsd.diff diff --git a/hw/pass-through.c b/hw/pass-through.c index 8581253..ca2f75a 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -84,8 +84,6 @@ */ #include "pass-through.h" -#include "pci/header.h" -#include "pci/pci.h" #include "pt-msi.h" #include "qemu-xen.h" #include "iomulti.h" diff --git a/hw/pass-through.h b/hw/pass-through.h index d7d837c..98b6f5e 100644 --- a/hw/pass-through.h +++ b/hw/pass-through.h @@ -20,8 +20,13 @@ #include "hw.h" #include "pci.h" +#ifdef __NetBSD__ +#include "pciutils/header.h" +#include "pciutils/pci.h" +#else #include "pci/header.h" #include "pci/pci.h" +#endif #include "exec-all.h" #include "sys-queue.h" #include "qemu-timer.h" diff --git a/hw/piix4acpi.c b/hw/piix4acpi.c index fb1e5c3..d8ca298 100644 --- a/hw/piix4acpi.c +++ b/hw/piix4acpi.c @@ -41,7 +41,7 @@ #define PIIX4ACPI_LOG(level, fmt, ...) do { if (level <= PIIX4ACPI_LOGLEVEL) qemu_log(fmt, ## __VA_ARGS__); } while (0) #ifdef CONFIG_PASSTHROUGH -#include +#include "pass-through.h" #endif /* PM1a_CNT bits, as defined in the ACPI specification. */ diff --git a/hw/pt-graphics.c b/hw/pt-graphics.c index c6f8869..3bbd856 100644 --- a/hw/pt-graphics.c +++ b/hw/pt-graphics.c @@ -3,8 +3,6 @@ */ #include "pass-through.h" -#include "pci/header.h" -#include "pci/pci.h" #include #include diff --git a/hw/pt-msi.c b/hw/pt-msi.c index 70c4023..0bd9446 100644 --- a/hw/pt-msi.c +++ b/hw/pt-msi.c @@ -22,6 +22,11 @@ #include "pt-msi.h" #include +#ifdef __NetBSD__ +/* MAP_LOCKED is Linux specific. MAP_WIRED is NetBSD's equivalent. */ +#define MAP_LOCKED MAP_WIRED +#endif + void msi_set_enable(struct pt_dev *dev, int en) { uint16_t val = 0; diff --git a/hw/pt-msi.h b/hw/pt-msi.h index 94e0d35..4b552dc 100644 --- a/hw/pt-msi.h +++ b/hw/pt-msi.h @@ -1,7 +1,6 @@ #ifndef _PT_MSI_H #define _PT_MSI_H -#include "pci/pci.h" #include "pass-through.h" #define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ diff --git a/xen-hooks.mak b/xen-hooks.mak index b55f45b..430c40d 100644 --- a/xen-hooks.mak +++ b/xen-hooks.mak @@ -57,8 +57,16 @@ endif ifdef CONFIG_STUBDOM CONFIG_PASSTHROUGH=1 else - ifeq (,$(wildcard /usr/include/pci)) -$(warning === pciutils-dev package not found - missing /usr/include/pci) + PCIUTILS_NetBSD=/usr/pkg/include/pciutils + PCIUTILS_Linux=/usr/include/pci + ifeq ($(CONFIG_NetBSD), y) +PCIUTILS_HEADER=$(PCIUTILS_NetBSD) + endif + ifeq ($(CONFIG_Linux), y) +PCIUTILS_HEADER=$(PCITUILS_Linux) + endif + ifeq (,$(wildcard $(PCIUTILS_HEADER))) +$(warning === pciutils-dev package not found - missing $(PCIUTILS_HEADER)) $(warning === PCI passthrough capability has been disabled) else CONFIG_PASSTHROUGH=1 @@ -67,7 +75,11 @@ endif ifdef CONFIG_PASSTHROUGH OBJS+= pass-through.o pt-msi.o pt-graphics.o +ifeq ($(CONFIG_NetBSD), y) +LIBS += -lpciutils -lpci +else LIBS += -lpci +endif CFLAGS += -DCONFIG_PASSTHROUGH $(info === PCI passthrough capability has been enabled ===) endif --------------020702070007020502010607 Content-Type: text/plain; charset="us-ascii"; name="libxl_pci_netbsd.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="libxl_pci_netbsd.diff" Content-Description: libxl_pci_netbsd.diff diff -r 88df118150e4 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Thu May 24 11:20:47 2012 +0200 +++ b/tools/libxl/libxl_internal.h Wed Jun 06 16:03:27 2012 +0200 @@ -343,8 +343,6 @@ typedef struct { #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) #define PCI_FUNC(devfn) ((devfn) & 0x07) #define AUTO_PHP_SLOT 0x100 -#define SYSFS_PCI_DEV "/sys/bus/pci/devices" -#define SYSFS_PCIBACK_DRIVER "/sys/bus/pci/drivers/pciback" #define XENSTORE_PID_FILE "/var/run/xenstored.pid" #define PROC_PCI_NUM_RESOURCES 7 diff -r 88df118150e4 tools/libxl/libxl_osdeps.h --- a/tools/libxl/libxl_osdeps.h Thu May 24 11:20:47 2012 +0200 +++ b/tools/libxl/libxl_osdeps.h Wed Jun 06 16:03:27 2012 +0200 @@ -23,14 +23,27 @@ #define _GNU_SOURCE -#if defined(__NetBSD__) || defined(__OpenBSD__) +#if defined(__NetBSD__) +#define SYSFS_PCI_DEV "/sys/bus/pci/devices" +#define SYSFS_PCIBACK_DRIVER "/kern/xen/pci" +#include +#elif defined(__OpenBSD__) #include #elif defined(__linux__) +#define SYSFS_PCI_DEV "/sys/bus/pci/devices" +#define SYSFS_PCIBACK_DRIVER "/sys/bus/pci/drivers/pciback" #include #elif defined(__sun__) #include #endif +#ifndef SYSFS_PCIBACK_DRIVER +#error define SYSFS_PCIBACK_DRIVER for your platform +#endif +#ifndef SYSFS_PCI_DEV +#error define SYSFS_PCI_DEV for your platform +#endif + #ifdef NEED_OWN_ASPRINTF #include --------------020702070007020502010607 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------020702070007020502010607--