Thanks Antti. Here's the new patchset.

Best regards

El 13/06/15 a les 19:37, Antti Kantee ha escrit:
On 12/06/15 21:25, Robert Millan wrote:
El 08/06/15 a les 07:53, Antti Kantee ha escrit:
 >> +int rumpcomp_pci_init(int, int *);
 >
 > Now that rumpcomp_userfeatures_pci.h is available, that signature can
be simplified.

That'd be "int rumpcomp_pci_init(void);" ?

No, that'd be e.g.

#ifdef rumpcomp_pci_initiopl
     rumpcomp_pci_initiopl();
#endif

El 08/06/15 a les 23:20, Antti Kantee ha escrit:
I'm just worried that your print will look too much like an error when
it is not necessary so.  Perhaps there's a way to make the print
softer, something to indicate that some features are missing most
likely because the program is not being run as root or with
CAP_SYS_RAWIO.  In other words, treat EPERM as the common case error.

Also, the print and the call doesn't match: pci_init() vs. "iopl failed".

How about "pci: initialization returned %d, some features may be
unavailable" ?

See above.

Finally, commenting on the hypercall side of the patch, you should not
return the return value of iopl(), but rather the translated errno.

Are there any facilities and/or standard way of doing this? Or should I
just use an ad-hoc switch/case with possible iopl() errnos?

See <rump/rumpuser_component.h>


--
Robert Millan
Index: rumpkernel-0~20150607/pci-userspace/src-linux-uio/pci_user-uio_linux.c
===================================================================
--- rumpkernel-0~20150607.orig/pci-userspace/src-linux-uio/pci_user-uio_linux.c	2015-06-13 22:46:57.477209607 +0200
+++ rumpkernel-0~20150607/pci-userspace/src-linux-uio/pci_user-uio_linux.c	2015-06-14 13:28:17.113381216 +0200
@@ -26,6 +26,7 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/queue.h>
+#include <sys/io.h>
 
 #include <assert.h>
 #include <err.h>
@@ -348,3 +349,12 @@
 
 	return paddr;
 }
+
+int
+rumpcomp_pci_initiopl(void)
+{
+	if (iopl(3) == -1)
+		return rumpuser_component_errtrans(errno);
+
+	return 0;
+}
Index: rumpkernel-0~20150607/pci-userspace/src-linux-uio/rumpcomp_userfeatures_pci.h
===================================================================
--- rumpkernel-0~20150607.orig/pci-userspace/src-linux-uio/rumpcomp_userfeatures_pci.h	2015-06-13 22:46:57.477209607 +0200
+++ rumpkernel-0~20150607/pci-userspace/src-linux-uio/rumpcomp_userfeatures_pci.h	2015-06-13 22:49:04.444965496 +0200
@@ -1 +1,2 @@
 #define rumpcomp_pci_free rumpcomp_pci_free
+#define rumpcomp_pci_initiopl rumpcomp_pci_initiopl
Index: rumpkernel-0~20150607/buildrump.sh/src/sys/rump/dev/lib/libpci/pci_at_mainbus.c
===================================================================
--- rumpkernel-0~20150607.orig/buildrump.sh/src/sys/rump/dev/lib/libpci/pci_at_mainbus.c	2015-06-13 22:44:46.001460644 +0200
+++ rumpkernel-0~20150607/buildrump.sh/src/sys/rump/dev/lib/libpci/pci_at_mainbus.c	2015-06-13 22:46:08.981302413 +0200
@@ -43,6 +43,8 @@
 #include "rump_private.h"
 #include "rump_vfs_private.h"
 
+#include "pci_user.h"
+
 RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 {
 	extern const struct cdevsw pci_cdevsw;
@@ -68,6 +70,9 @@
 {
 	struct pcibus_attach_args pba;
 	device_t mainbus;
+#if defined(RUMP_PCI_IOSPACE) && defined(rumpcomp_pci_initiopl)
+	int error;
+#endif
 
 	/* XXX: attach args should come from elsewhere */
 	memset(&pba, 0, sizeof(pba));
@@ -81,7 +86,14 @@
 	pba.pba_flags = PCI_FLAGS_MEM_OKAY |
 	    PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;;
 #ifdef RUMP_PCI_IOSPACE
-	pba.pba_flags |= PCI_FLAGS_IO_OKAY;
+#ifdef rumpcomp_pci_initiopl
+	error = rumpcomp_pci_initiopl();
+	if (error == 0) {
+		pba.pba_flags |= PCI_FLAGS_IO_OKAY;
+	} else {
+		aprint_error("pci: unable to raise I/O privilege level (error %d), direct I/O will be unavailable\n", error);
+	}
+#endif
 #endif
 
 	mainbus = device_find_by_driver_unit("mainbus", 0);
Index: rumpkernel-0~20150607/buildrump.sh/src/sys/rump/dev/lib/libpci/pci_user.h
===================================================================
--- rumpkernel-0~20150607.orig/buildrump.sh/src/sys/rump/dev/lib/libpci/pci_user.h	2015-06-13 22:44:46.001460644 +0200
+++ rumpkernel-0~20150607/buildrump.sh/src/sys/rump/dev/lib/libpci/pci_user.h	2015-06-13 22:46:08.981302413 +0200
@@ -22,3 +22,7 @@
 			    void **);
 
 unsigned long rumpcomp_pci_virt_to_mach(void *);
+
+#ifdef rumpcomp_pci_initiopl
+int rumpcomp_pci_initiopl(void);
+#endif

Reply via email to