Skip to contentSkip to conversation

pvhvm emul unplug fixes

PATCH Superseded Ian Campbell 5 participants 18 messages Aug 19, 2010 – Aug 20, 2010

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover pvhvm emul unplug fixes

Jeremy, Stefano,

These patches make it possible to inhibit the unplug on the kernel command line (mostly "Just In Case") and rename xen_emul_unplug=ignore to the (IMHO) clearer xen_emul_unplug=unnecessary. The third patch is just a cleanup to platform_pci.h.

I think the first two should be targeting 2.6.36 since they change command line arguments. The last one could easily wait until 2.6.37.

If you agree with this and want me to I can take care of sending them upstream (direct to Linus I guess?).

The following changes since commit da5cabf80e2433131bf0ed8993abc0f7ea618c73:
Linus Torvalds (1):

        Linux 2.6.36-rc1

are available in the git repository at:

git://xenbits.xensource.com/people/ianc/linux-2.6.git for-upstream/pvhvm

Ian Campbell (3):
xen: pvhvm: allow user to request no emulated device unplug
xen: pvhvm: rename xen_emul_unplug=ignore to =unnnecessary
xen: pvhvm: make it clearer that XEN_UNPLUG_* individual bits

 Documentation/kernel-parameters.txt |    6 ++++--
 arch/x86/xen/platform-pci-unplug.c  |   25 +++++++++++++++++--------
 drivers/block/xen-blkfront.c        |    2 +-
 include/xen/platform_pci.h          |   13 ++++++++-----
 4 files changed, 30 insertions(+), 16 deletions(-)
#1 lore raw

PATCH 1/3 xen: pvhvm: allow user to request no emulated device unplug

this allows the user to disable pvhvm and revert to emulated devices in case of a system misconfiguration (e.g. initramfs with only emulated drivers in it).

---
 Documentation/kernel-parameters.txt |    1 +
 arch/x86/xen/platform-pci-unplug.c  |   12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
Documentation/kernel-parameters.txt +1 -0
index 2c85c06..8bbe83b 100644
@@ -2631,6 +2631,7 @@ and is between 256 and 4096 characters. It is defined in the file
 			all -- unplug all emulated devices (NICs and IDE disks)
 			ignore -- continue loading the Xen platform PCI driver even
 				if the version check failed
+			never -- do not unplug even if version check succeeds
 
 	xirc2ps_cs=	[NET,PCMCIA]
 			Format:
arch/x86/xen/platform-pci-unplug.c +10 -2
index 554c002..c82ce1e 100644
@@ -33,7 +33,7 @@
 int xen_platform_pci_unplug;
 EXPORT_SYMBOL_GPL(xen_platform_pci_unplug);
 #ifdef CONFIG_XEN_PVHVM
-static int xen_emul_unplug;
+static int xen_emul_unplug = -1;
 
 static int __init check_platform_magic(void)
 {
@@ -72,18 +72,23 @@ void __init xen_unplug_emulated_devices(void)
 {
 	int r;
 
+	/* user explicitly requested no unplug */
+	if (xen_emul_unplug == 0)
+		return;
 	/* check the version of the xen platform PCI device */
 	r = check_platform_magic();
 	/* If the version matches enable the Xen platform PCI driver.
 	 * Also enable the Xen platform PCI driver if the version is really old
 	 * and the user told us to ignore it. */
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
+			(xen_emul_unplug != -1) &&
 			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))
 		return;
 	/* Set the default value of xen_emul_unplug depending on whether or
 	 * not the Xen PV frontends and the Xen platform PCI driver have
 	 * been compiled for this kernel (modules or built-in are both OK). */
-	if (!xen_emul_unplug) {
+	if (xen_emul_unplug == -1) {
+		xen_emul_unplug = 0;
 		if (xen_must_unplug_nics()) {
 			printk(KERN_INFO "Netfront and the Xen platform PCI driver have "
 					"been compiled for this kernel: unplug emulated NICs.\n");
@@ -109,6 +114,7 @@ static int __init parse_xen_emul_unplug(char *arg)
 	char *p, *q;
 	int l;
 
+	xen_emul_unplug = 0;
 	for (p = arg; p; p = q) {
 		q = strchr(p, ',');
 		if (q) {
@@ -127,6 +133,8 @@ static int __init parse_xen_emul_unplug(char *arg)
 			xen_emul_unplug |= XEN_UNPLUG_ALL_NICS;
 		else if (!strncmp(p, "ignore", l))
 			xen_emul_unplug |= XEN_UNPLUG_IGNORE;
+		else if (!strncmp(p, "never", l))
+			/* Nothing to do. xen_emul_unplug = 0 above */;
 		else
 			printk(KERN_WARNING "unrecognised option '%s' "
 				 "in parameter 'xen_emul_unplug'\n", p);
Signature · 1 line
1.5.6.5
#2 lore raw

Re: [PATCH 1/3] xen: pvhvm: allow user to request no emulated device unplug

Quoted 4 lines · Ian Campbell

this allows the user to disable pvhvm and revert to emulated devices in case of a system misconfiguration (e.g. initramfs with only emulated drivers in it).

I think this option might be a good thing to have, expecially to debug qemu-xen emulated devices.

Quoted 36 lines
---
 Documentation/kernel-parameters.txt |    1 +
 arch/x86/xen/platform-pci-unplug.c  |   12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)
Documentation/kernel-parameters.txt +1 -0
index 2c85c06..8bbe83b 100644
@@ -2631,6 +2631,7 @@ and is between 256 and 4096 characters. It is defined in the file
 			all -- unplug all emulated devices (NICs and IDE disks)
 			ignore -- continue loading the Xen platform PCI driver even
 				if the version check failed
+			never -- do not unplug even if version check succeeds
 
 	xirc2ps_cs=	[NET,PCMCIA]
 			Format:
arch/x86/xen/platform-pci-unplug.c +2 -1
index 554c002..c82ce1e 100644
@@ -33,7 +33,7 @@
 int xen_platform_pci_unplug;
 EXPORT_SYMBOL_GPL(xen_platform_pci_unplug);
 #ifdef CONFIG_XEN_PVHVM
-static int xen_emul_unplug;
+static int xen_emul_unplug = -1;
 
 static int __init check_platform_magic(void)
 {
@@ -72,18 +72,23 @@ void __init xen_unplug_emulated_devices(void)
 {
 	int r;
 
+	/* user explicitly requested no unplug */

arch/x86/xen/platform-pci-unplug.c void __init xen_unplug_emulated_devices(void) · line 85

Quoted 10 lines
arch/x86/xen/platform-pci-unplug.c +3 -0
+	if (xen_emul_unplug == 0)
+		return;
 	/* check the version of the xen platform PCI device */
 	r = check_platform_magic();
 	/* If the version matches enable the Xen platform PCI driver.
 	 * Also enable the Xen platform PCI driver if the version is really old
 	 * and the user told us to ignore it. */
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
+			(xen_emul_unplug != -1) &&
 			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))

I wouldn't add xen_emul_unplug != -1 because it should be clear that xen_emul_unplug & XEN_UNPLUG_IGNORE always implies xen_emul_unplug != -1.

The other two patches look fine to me.

#3 lore raw

Re: [PATCH 1/3] xen: pvhvm: allow user to request no emulated device unplug

Quoted 7 lines · Stefano Stabellini

arch/x86/xen/platform-pci-unplug.c void __init xen_unplug_emulated_devices(void) · line 85

Quoted 3 lines · Ian Campbell
arch/x86/xen/platform-pci-unplug.c +1 -0
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
+			(xen_emul_unplug != -1) &&
 			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))

I wouldn't add xen_emul_unplug != -1 because it should be clear that xen_emul_unplug & XEN_UNPLUG_IGNORE always implies xen_emul_unplug != -1.

That's not correct since -1 is all 1s. So you can get a false positive for "xen_emul_unplug & XEN_UNPLUG_IGNORE" if xen_emul_unplug == -1.

Ian.

#4 lore raw

Re: Re: [PATCH 1/3] xen: pvhvm: allow user to request no emulated device unplug

Quoted 11 lines · Ian Campbell
Quoted 7 lines · Stefano Stabellini

arch/x86/xen/platform-pci-unplug.c void __init xen_unplug_emulated_devices(void) · line 85

Quoted 3 lines · Ian Campbell
arch/x86/xen/platform-pci-unplug.c +1 -0
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
+			(xen_emul_unplug != -1) &&
 			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))

I wouldn't add xen_emul_unplug != -1 because it should be clear that xen_emul_unplug & XEN_UNPLUG_IGNORE always implies xen_emul_unplug != -1.

That's not correct since -1 is all 1s. So you can get a false positive for "xen_emul_unplug & XEN_UNPLUG_IGNORE" if xen_emul_unplug == -1.

IOW if we were to rewrite the test to use less boolean logic the patch might look like:

	if (r) {
		if (r != XEN_PLATFORM_ERR_MAGIC)
			return;
+		if (xen_emul_unplug == -1)
+			return;
		if (!(xen_emul_unplug & XEN_UNPLUG_IGNORE))
			return;
	}

Perhaps this refactoring is worthwhile in any case? It certainly makes my head hurt less ;-)

Ian.

#5 lore raw

Re: Re: [PATCH 1/3] xen: pvhvm: allow user to request no emulated device unplug

Quoted 25 lines · Ian Campbell
Quoted 11 lines · Ian Campbell
Quoted 7 lines · Stefano Stabellini

arch/x86/xen/platform-pci-unplug.c void __init xen_unplug_emulated_devices(void) · line 85

Quoted 3 lines · Ian Campbell
arch/x86/xen/platform-pci-unplug.c +1 -0
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
+			(xen_emul_unplug != -1) &&
 			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))

I wouldn't add xen_emul_unplug != -1 because it should be clear that xen_emul_unplug & XEN_UNPLUG_IGNORE always implies xen_emul_unplug != -1.

That's not correct since -1 is all 1s. So you can get a false positive for "xen_emul_unplug & XEN_UNPLUG_IGNORE" if xen_emul_unplug == -1.

IOW if we were to rewrite the test to use less boolean logic the patch might look like:

	if (r) {
		if (r != XEN_PLATFORM_ERR_MAGIC)
			return;
(quoted diff) +2 -0
+		if (xen_emul_unplug == -1)
+			return;
		if (!(xen_emul_unplug & XEN_UNPLUG_IGNORE))
			return;
	}
Quoted 3 lines

Perhaps this refactoring is worthwhile in any case? It certainly makes my head hurt less ;-)

Yeah, it is probably worth it anyway :)

#6 lore raw

Re: Re: [PATCH 1/3] xen: pvhvm: allow user to request no emulated device unplug

Quoted 23 lines · Stefano Stabellini
Quoted 22 lines · Ian Campbell
Quoted 9 lines · Ian Campbell
Quoted 6 lines · Stefano Stabellini

arch/x86/xen/platform-pci-unplug.c void __init xen_unplug_emulated_devices(void) · line 85

Quoted 3 lines · Ian Campbell
arch/x86/xen/platform-pci-unplug.c +1 -0
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
+			(xen_emul_unplug != -1) &&
 			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))

I wouldn't add xen_emul_unplug != -1 because it should be clear that xen_emul_unplug & XEN_UNPLUG_IGNORE always implies xen_emul_unplug != -1.

That's not correct since -1 is all 1s. So you can get a false positive for "xen_emul_unplug & XEN_UNPLUG_IGNORE" if xen_emul_unplug == -1.

IOW if we were to rewrite the test to use less boolean logic the patch might look like:

	if (r) {
		if (r != XEN_PLATFORM_ERR_MAGIC)
			return;
(quoted diff) +2 -0
+		if (xen_emul_unplug == -1)
+			return;
		if (!(xen_emul_unplug & XEN_UNPLUG_IGNORE))
			return;
	}
Quoted 5 lines
Quoted 3 lines

Perhaps this refactoring is worthwhile in any case? It certainly makes my head hurt less ;-)

Yeah, it is probably worth it anyway :)

Treating a variable as an integer and a bitfield seems like a bad idea.

J

#7 lore raw

Re: Re: [PATCH 1/3] xen: pvhvm: allow user to request no emulated device unplug

Quoted 24 lines · Jeremy Fitzhardinge
Quoted 23 lines · Stefano Stabellini
Quoted 22 lines · Ian Campbell
Quoted 9 lines · Ian Campbell
Quoted 6 lines · Stefano Stabellini

arch/x86/xen/platform-pci-unplug.c void __init xen_unplug_emulated_devices(void) · line 85

Quoted 3 lines · Ian Campbell
arch/x86/xen/platform-pci-unplug.c +1 -0
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
+			(xen_emul_unplug != -1) &&
 			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))

I wouldn't add xen_emul_unplug != -1 because it should be clear that xen_emul_unplug & XEN_UNPLUG_IGNORE always implies xen_emul_unplug != -1.

That's not correct since -1 is all 1s. So you can get a false positive for "xen_emul_unplug & XEN_UNPLUG_IGNORE" if xen_emul_unplug == -1.

IOW if we were to rewrite the test to use less boolean logic the patch might look like:

	if (r) {
		if (r != XEN_PLATFORM_ERR_MAGIC)
			return;
(quoted diff) +2 -0
+		if (xen_emul_unplug == -1)
+			return;
		if (!(xen_emul_unplug & XEN_UNPLUG_IGNORE))
			return;
	}
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Perhaps this refactoring is worthwhile in any case? It certainly makes my head hurt less ;-)

Yeah, it is probably worth it anyway :)

Treating a variable as an integer and a bitfield seems like a bad idea.

Should be fine? I'd just #define XEN_UNPLUG_ALL_THE_BITS ~0U for the sake of cosmetics...

#8 lore raw

Re: Re: [PATCH 1/3] xen: pvhvm: allow user to request no emulated device unplug

Quoted 25 lines · Gianni Tedesco
Quoted 24 lines · Jeremy Fitzhardinge
Quoted 23 lines · Stefano Stabellini
Quoted 22 lines · Ian Campbell
Quoted 9 lines · Ian Campbell
Quoted 6 lines · Stefano Stabellini

Review

Quoted 3 lines · Ian Campbell
(quoted diff) +1 -0
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
+			(xen_emul_unplug != -1) &&
 			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))

I wouldn't add xen_emul_unplug != -1 because it should be clear that xen_emul_unplug & XEN_UNPLUG_IGNORE always implies xen_emul_unplug != -1.

That's not correct since -1 is all 1s. So you can get a false positive for "xen_emul_unplug & XEN_UNPLUG_IGNORE" if xen_emul_unplug == -1.

IOW if we were to rewrite the test to use less boolean logic the patch might look like:

	if (r) {
		if (r != XEN_PLATFORM_ERR_MAGIC)
			return;
(quoted diff) +2 -0
+		if (xen_emul_unplug == -1)
+			return;
		if (!(xen_emul_unplug & XEN_UNPLUG_IGNORE))
			return;
	}
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

Perhaps this refactoring is worthwhile in any case? It certainly makes my head hurt less ;-)

Yeah, it is probably worth it anyway :)

Treating a variable as an integer and a bitfield seems like a bad idea.

Should be fine? I'd just #define XEN_UNPLUG_ALL_THE_BITS ~0U for the sake of cosmetics...

In a bitfield the bits are typically independent, whereas in an integer you interpret all the bits to get a value. Making "all bits set" mean something other than all the bitfield bits are set is just asking for something bad to happen to you.

Why not define a bit to mean whatever "-1" currently means?

J

#9 lore raw

Re: Re: [PATCH 1/3] xen: pvhvm: allow user to request no emulated device unplug

Quoted 35 lines · Jeremy Fitzhardinge
Quoted 25 lines · Gianni Tedesco
Quoted 24 lines · Jeremy Fitzhardinge
Quoted 23 lines · Stefano Stabellini
Quoted 22 lines · Ian Campbell
Quoted 9 lines · Ian Campbell
Quoted 6 lines · Stefano Stabellini

Review

Quoted 3 lines · Ian Campbell
(quoted diff) +1 -0
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
+			(xen_emul_unplug != -1) &&
 			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))

I wouldn't add xen_emul_unplug != -1 because it should be clear that xen_emul_unplug & XEN_UNPLUG_IGNORE always implies xen_emul_unplug != -1.

That's not correct since -1 is all 1s. So you can get a false positive for "xen_emul_unplug & XEN_UNPLUG_IGNORE" if xen_emul_unplug == -1.

IOW if we were to rewrite the test to use less boolean logic the patch might look like:

	if (r) {
		if (r != XEN_PLATFORM_ERR_MAGIC)
			return;
(quoted diff) +2 -0
+		if (xen_emul_unplug == -1)
+			return;
		if (!(xen_emul_unplug & XEN_UNPLUG_IGNORE))
			return;
	}
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

Perhaps this refactoring is worthwhile in any case? It certainly makes my head hurt less ;-)

Yeah, it is probably worth it anyway :)

Treating a variable as an integer and a bitfield seems like a bad idea.

Should be fine? I'd just #define XEN_UNPLUG_ALL_THE_BITS ~0U for the sake of cosmetics...

Quoted 6 lines

In a bitfield the bits are typically independent, whereas in an integer you interpret all the bits to get a value. Making "all bits set" mean something other than all the bitfield bits are set is just asking for something bad to happen to you.

Why not define a bit to mean whatever "-1" currently means?

I'll add an explicit XEN_UNPLUG_NEVER instead.

Ian.

#10 lore raw

v2 cover pvhvm emul unplug fixes

Quoted 1 line · Ian Campbell

I'll add an explicit XEN_UNPLUG_NEVER instead.

Here we go.

Assuming everyone is happy with this round I'll send the first two to upstream (see the for-upstream/pvhvm branch at the same location). Or maybe I should just send all three to Linus? since the third really is rather trivial.

The following changes since commit da5cabf80e2433131bf0ed8993abc0f7ea618c73:
Linus Torvalds (1):

        Linux 2.6.36-rc1

are available in the git repository at:

git://xenbits.xensource.com/people/ianc/linux-2.6.git for-jeremy/pvhvm

Ian Campbell (3):
xen: pvhvm: allow user to request no emulated device unplug
xen: pvhvm: rename xen_emul_unplug=ignore to =unnnecessary
xen: pvhvm: make it clearer that XEN_UNPLUG_* define bits in a bitfield

 Documentation/kernel-parameters.txt |    6 ++++--
 arch/x86/xen/platform-pci-unplug.c  |   18 ++++++++++++------
 drivers/block/xen-blkfront.c        |    2 +-
 include/xen/platform_pci.h          |   14 +++++++++-----
 4 files changed, 26 insertions(+), 14 deletions(-)
#11 lore raw

PATCH 1/3 xen: pvhvm: allow user to request no emulated device unplug

this allows the user to disable pvhvm and revert to emulated devices in case of a system misconfiguration (e.g. initramfs with only emulated drivers in it).

---
 Documentation/kernel-parameters.txt |    1 +
 arch/x86/xen/platform-pci-unplug.c  |    5 +++++
 include/xen/platform_pci.h          |    1 +
 3 files changed, 7 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +1 -0
index 2c85c06..8bbe83b 100644
@@ -2631,6 +2631,7 @@ and is between 256 and 4096 characters. It is defined in the file
 			all -- unplug all emulated devices (NICs and IDE disks)
 			ignore -- continue loading the Xen platform PCI driver even
 				if the version check failed
+			never -- do not unplug even if version check succeeds
 
 	xirc2ps_cs=	[NET,PCMCIA]
 			Format:
arch/x86/xen/platform-pci-unplug.c +5 -0
index 554c002..070dfa0 100644
@@ -72,6 +72,9 @@ void __init xen_unplug_emulated_devices(void)
 {
 	int r;
 
+	/* user explicitly requested no unplug */
+	if (xen_emul_unplug & XEN_UNPLUG_NEVER)
+		return;
 	/* check the version of the xen platform PCI device */
 	r = check_platform_magic();
 	/* If the version matches enable the Xen platform PCI driver.
@@ -127,6 +130,8 @@ static int __init parse_xen_emul_unplug(char *arg)
 			xen_emul_unplug |= XEN_UNPLUG_ALL_NICS;
 		else if (!strncmp(p, "ignore", l))
 			xen_emul_unplug |= XEN_UNPLUG_IGNORE;
+		else if (!strncmp(p, "never", l))
+			xen_emul_unplug |= XEN_UNPLUG_NEVER;
 		else
 			printk(KERN_WARNING "unrecognised option '%s' "
 				 "in parameter 'xen_emul_unplug'\n", p);
include/xen/platform_pci.h +1 -0
index ce9d671..123b775 100644
@@ -21,6 +21,7 @@
 #define XEN_UNPLUG_AUX_IDE_DISKS 4
 #define XEN_UNPLUG_ALL 7
 #define XEN_UNPLUG_IGNORE 8
+#define XEN_UNPLUG_NEVER 16
 
 static inline int xen_must_unplug_nics(void) {
 #if (defined(CONFIG_XEN_NETDEV_FRONTEND) || \
Signature · 1 line
1.5.6.5
#12 lore raw

PATCH 2/3 xen: pvhvm: rename xen_emul_unplug=ignore to =unnnecessary

In reply to Ian Campbell

It is not immediately clear what this option causes to become ignored. The actual meaning is that it is not necessary to unplug the emulated devices to safely use the PV ones, even if the platform does not support the unplug protocol. (pressumably the user will only add this option if they have ensured that their domain configuration is safe).

I think xen_emul_unplug=unnecessary better captures this.

---
 Documentation/kernel-parameters.txt |    5 +++--
 arch/x86/xen/platform-pci-unplug.c  |   13 +++++++------
 drivers/block/xen-blkfront.c        |    2 +-
 include/xen/platform_pci.h          |    2 +-
 4 files changed, 12 insertions(+), 10 deletions(-)
Documentation/kernel-parameters.txt +3 -2
index 8bbe83b..f084af0 100644
@@ -2629,8 +2629,9 @@ and is between 256 and 4096 characters. It is defined in the file
 			aux-ide-disks -- unplug non-primary-master IDE devices
 			nics -- unplug network devices
 			all -- unplug all emulated devices (NICs and IDE disks)
-			ignore -- continue loading the Xen platform PCI driver even
-				if the version check failed
+			unnecessary -- unplugging emulated devices is
+				unnecessary even if the host did not respond to
+				the unplug protocol
 			never -- do not unplug even if version check succeeds
 
 	xirc2ps_cs=	[NET,PCMCIA]
arch/x86/xen/platform-pci-unplug.c +7 -6
index 070dfa0..0f45638 100644
@@ -78,10 +78,11 @@ void __init xen_unplug_emulated_devices(void)
 	/* check the version of the xen platform PCI device */
 	r = check_platform_magic();
 	/* If the version matches enable the Xen platform PCI driver.
-	 * Also enable the Xen platform PCI driver if the version is really old
-	 * and the user told us to ignore it. */
+	 * Also enable the Xen platform PCI driver if the host does
+	 * not support the unplug protocol (XEN_PLATFORM_ERR_MAGIC)
+	 * but the user told us that unplugging is unnecessary. */
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
-			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))
+			(xen_emul_unplug & XEN_UNPLUG_UNNECESSARY)))
 		return;
 	/* Set the default value of xen_emul_unplug depending on whether or
 	 * not the Xen PV frontends and the Xen platform PCI driver have
@@ -102,7 +103,7 @@ void __init xen_unplug_emulated_devices(void)
 		}
 	}
 	/* Now unplug the emulated devices */
-	if (!(xen_emul_unplug & XEN_UNPLUG_IGNORE))
+	if (!(xen_emul_unplug & XEN_UNPLUG_UNNECESSARY))
 		outw(xen_emul_unplug, XEN_IOPORT_UNPLUG);
 	xen_platform_pci_unplug = xen_emul_unplug;
 }
@@ -128,8 +129,8 @@ static int __init parse_xen_emul_unplug(char *arg)
 			xen_emul_unplug |= XEN_UNPLUG_AUX_IDE_DISKS;
 		else if (!strncmp(p, "nics", l))
 			xen_emul_unplug |= XEN_UNPLUG_ALL_NICS;
-		else if (!strncmp(p, "ignore", l))
-			xen_emul_unplug |= XEN_UNPLUG_IGNORE;
+		else if (!strncmp(p, "unnecessary", l))
+			xen_emul_unplug |= XEN_UNPLUG_UNNECESSARY;
 		else if (!strncmp(p, "never", l))
 			xen_emul_unplug |= XEN_UNPLUG_NEVER;
 		else
drivers/block/xen-blkfront.c +1 -1
index ac1b682..ab735a6 100644
@@ -834,7 +834,7 @@ static int blkfront_probe(struct xenbus_device *dev,
 		char *type;
 		int len;
 		/* no unplug has been done: do not hook devices != xen vbds */
-		if (xen_platform_pci_unplug & XEN_UNPLUG_IGNORE) {
+		if (xen_platform_pci_unplug & XEN_UNPLUG_UNNECESSARY) {
 			int major;
 
 			if (!VDEV_IS_EXTENDED(vdevice))
include/xen/platform_pci.h +1 -1
index 123b775..590ccfd 100644
@@ -20,7 +20,7 @@
 #define XEN_UNPLUG_ALL_NICS 2
 #define XEN_UNPLUG_AUX_IDE_DISKS 4
 #define XEN_UNPLUG_ALL 7
-#define XEN_UNPLUG_IGNORE 8
+#define XEN_UNPLUG_UNNECESSARY 8
 #define XEN_UNPLUG_NEVER 16
 
 static inline int xen_must_unplug_nics(void) {
Signature · 1 line
1.5.6.5
#13 lore raw

PATCH 3/3 xen: pvhvm: make it clearer that XEN_UNPLUG_* define bits in a bitfield

In reply to Ian Campbell

Make this clear by defining in terms of (1<<N)

XEN_UNPLUG_UNNECESSARY is only used within the kernel and is not defined as a bit on the unplug IO port. Therefore use a bit which is outside the potentially valid range of the 16 bit IO port.

---
 include/xen/platform_pci.h |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
include/xen/platform_pci.h +9 -6
index 590ccfd..a785a3b 100644
@@ -16,12 +16,15 @@
 #define XEN_IOPORT_PROTOVER	(XEN_IOPORT_BASE + 2) /* 1 byte access (R) */
 #define XEN_IOPORT_PRODNUM	(XEN_IOPORT_BASE + 2) /* 2 byte access (W) */
 
-#define XEN_UNPLUG_ALL_IDE_DISKS 1
-#define XEN_UNPLUG_ALL_NICS 2
-#define XEN_UNPLUG_AUX_IDE_DISKS 4
-#define XEN_UNPLUG_ALL 7
-#define XEN_UNPLUG_UNNECESSARY 8
-#define XEN_UNPLUG_NEVER 16
+#define XEN_UNPLUG_ALL_IDE_DISKS	(1<<0)
+#define XEN_UNPLUG_ALL_NICS		(1<<1)
+#define XEN_UNPLUG_AUX_IDE_DISKS	(1<<2)
+#define XEN_UNPLUG_ALL			(XEN_UNPLUG_ALL_IDE_DISKS|\
+					 XEN_UNPLUG_ALL_NICS|\
+					 XEN_UNPLUG_AUX_IDE_DISKS)
+
+#define XEN_UNPLUG_UNNECESSARY 		(1<<16)
+#define XEN_UNPLUG_NEVER	 		(1<<17)
 
 static inline int xen_must_unplug_nics(void) {
 #if (defined(CONFIG_XEN_NETDEV_FRONTEND) || \
Signature · 1 line
1.5.6.5
#14 lore raw
In reply to Ian Campbell
Quoted 23 lines · Ian Campbell
Quoted 1 line · Ian Campbell

I'll add an explicit XEN_UNPLUG_NEVER instead.

Here we go.

Assuming everyone is happy with this round I'll send the first two to upstream (see the for-upstream/pvhvm branch at the same location). Or maybe I should just send all three to Linus? since the third really is rather trivial.

The following changes since commit da5cabf80e2433131bf0ed8993abc0f7ea618c73:
Linus Torvalds (1):

        Linux 2.6.36-rc1

are available in the git repository at:

git://xenbits.xensource.com/people/ianc/linux-2.6.git for-jeremy/pvhvm

Ian Campbell (3):
xen: pvhvm: allow user to request no emulated device unplug
xen: pvhvm: rename xen_emul_unplug=ignore to =unnnecessary
xen: pvhvm: make it clearer that XEN_UNPLUG_* define bits in a bitfield

Quoted 7 lines
 Documentation/kernel-parameters.txt |    6 ++++--
 arch/x86/xen/platform-pci-unplug.c  |   18 ++++++++++++------
 drivers/block/xen-blkfront.c        |    2 +-
 include/xen/platform_pci.h          |   14 +++++++++-----
 4 files changed, 26 insertions(+), 14 deletions(-)

they are all fine by me

#15 lore raw
In reply to Ian Campbell
Quoted 8 lines · Ian Campbell
Quoted 1 line · Ian Campbell

I'll add an explicit XEN_UNPLUG_NEVER instead.

Here we go.

Assuming everyone is happy with this round I'll send the first two to upstream (see the for-upstream/pvhvm branch at the same location). Or maybe I should just send all three to Linus? since the third really is rather trivial.

Yep.

All Acked-by: Jeremy Fitzhardinge <[email protected]>

J

Quoted 20 lines

The following changes since commit da5cabf80e2433131bf0ed8993abc0f7ea618c73:
Linus Torvalds (1):

        Linux 2.6.36-rc1

are available in the git repository at:

git://xenbits.xensource.com/people/ianc/linux-2.6.git for-jeremy/pvhvm

Ian Campbell (3):
xen: pvhvm: allow user to request no emulated device unplug
xen: pvhvm: rename xen_emul_unplug=ignore to =unnnecessary
xen: pvhvm: make it clearer that XEN_UNPLUG_* define bits in a bitfield

 Documentation/kernel-parameters.txt |    6 ++++--
 arch/x86/xen/platform-pci-unplug.c  |   18 ++++++++++++------
 drivers/block/xen-blkfront.c        |    2 +-
 include/xen/platform_pci.h          |   14 +++++++++-----
 4 files changed, 26 insertions(+), 14 deletions(-)
#16 lore raw

PATCH 2/3 xen: pvhvm: rename xen_emul_unplug=ignore to =unnnecessary

In reply to Ian Campbell

It is not immediately clear what this option causes to become ignored. The actual meaning is that it is not necessary to unplug the emulated devices to safely use the PV ones, even if the platform does not support the unplug protocol. (pressumably the user will only add this option if they have ensured that their domain configuration is safe).

I think xen_emul_unplug=unnecessary better captures this.

---
 Documentation/kernel-parameters.txt |    5 +++--
 arch/x86/xen/platform-pci-unplug.c  |   13 +++++++------
 drivers/block/xen-blkfront.c        |    2 +-
 include/xen/platform_pci.h          |    2 +-
 4 files changed, 12 insertions(+), 10 deletions(-)
Documentation/kernel-parameters.txt +3 -2
index 8bbe83b..338f469 100644
@@ -2629,8 +2629,9 @@ and is between 256 and 4096 characters. It is defined in the file
 			aux-ide-disks -- unplug non-primary-master IDE devices
 			nics -- unplug network devices
 			all -- unplug all emulated devices (NICs and IDE disks)
-			ignore -- continue loading the Xen platform PCI driver even
-				if the version check failed
+			unnecessary -- unplugging emulated devices is 
+				unnecessary even if the host did not respond to
+				the unplug protocol
 			never -- do not unplug even if version check succeeds
 
 	xirc2ps_cs=	[NET,PCMCIA]
arch/x86/xen/platform-pci-unplug.c +7 -6
index c82ce1e..d696e37 100644
@@ -78,11 +78,12 @@ void __init xen_unplug_emulated_devices(void)
 	/* check the version of the xen platform PCI device */
 	r = check_platform_magic();
 	/* If the version matches enable the Xen platform PCI driver.
-	 * Also enable the Xen platform PCI driver if the version is really old
-	 * and the user told us to ignore it. */
+	 * Also enable the Xen platform PCI driver if the host does
+	 * not support the unplug protocol (XEN_PLATFORM_ERR_MAGIC)
+	 * but the user told us that unplugging is unnecessary. */
 	if (r && !(r == XEN_PLATFORM_ERR_MAGIC &&
 			(xen_emul_unplug != -1) &&
-			(xen_emul_unplug & XEN_UNPLUG_IGNORE)))
+			(xen_emul_unplug & XEN_UNPLUG_UNNECESSARY)))
 		return;
 	/* Set the default value of xen_emul_unplug depending on whether or
 	 * not the Xen PV frontends and the Xen platform PCI driver have
@@ -104,7 +105,7 @@ void __init xen_unplug_emulated_devices(void)
 		}
 	}
 	/* Now unplug the emulated devices */
-	if (!(xen_emul_unplug & XEN_UNPLUG_IGNORE))
+	if (!(xen_emul_unplug & XEN_UNPLUG_UNNECESSARY))
 		outw(xen_emul_unplug, XEN_IOPORT_UNPLUG);
 	xen_platform_pci_unplug = xen_emul_unplug;
 }
@@ -131,8 +132,8 @@ static int __init parse_xen_emul_unplug(char *arg)
 			xen_emul_unplug |= XEN_UNPLUG_AUX_IDE_DISKS;
 		else if (!strncmp(p, "nics", l))
 			xen_emul_unplug |= XEN_UNPLUG_ALL_NICS;
-		else if (!strncmp(p, "ignore", l))
-			xen_emul_unplug |= XEN_UNPLUG_IGNORE;
+		else if (!strncmp(p, "unnecessary", l))
+			xen_emul_unplug |= XEN_UNPLUG_UNNECESSARY;
 		else if (!strncmp(p, "never", l))
 			/* Nothing to do. xen_emul_unplug = 0 above */;
 		else
drivers/block/xen-blkfront.c +1 -1
index ac1b682..ab735a6 100644
@@ -834,7 +834,7 @@ static int blkfront_probe(struct xenbus_device *dev,
 		char *type;
 		int len;
 		/* no unplug has been done: do not hook devices != xen vbds */
-		if (xen_platform_pci_unplug & XEN_UNPLUG_IGNORE) {
+		if (xen_platform_pci_unplug & XEN_UNPLUG_UNNECESSARY) {
 			int major;
 
 			if (!VDEV_IS_EXTENDED(vdevice))
include/xen/platform_pci.h +1 -1
index ce9d671..b0dca21 100644
@@ -20,7 +20,7 @@
 #define XEN_UNPLUG_ALL_NICS 2
 #define XEN_UNPLUG_AUX_IDE_DISKS 4
 #define XEN_UNPLUG_ALL 7
-#define XEN_UNPLUG_IGNORE 8
+#define XEN_UNPLUG_UNNECESSARY 8
 
 static inline int xen_must_unplug_nics(void) {
 #if (defined(CONFIG_XEN_NETDEV_FRONTEND) || \
Signature · 1 line
1.5.6.5
#17 lore raw

PATCH 3/3 xen: pvhvm: make it clearer that XEN_UNPLUG_* individual bits

In reply to Ian Campbell

Make this clear by defining in terms of (1<<N)

XEN_UNPLUG_UNNECESSARY is only used within the kernel and is not defined as a bit on the unplug IO port. Therefore use a bit which is outside the potentially valid range of the 16 bit IO port.

---
 include/xen/platform_pci.h |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
include/xen/platform_pci.h +8 -5
index b0dca21..dba26dd 100644
@@ -16,11 +16,14 @@
 #define XEN_IOPORT_PROTOVER	(XEN_IOPORT_BASE + 2) /* 1 byte access (R) */
 #define XEN_IOPORT_PRODNUM	(XEN_IOPORT_BASE + 2) /* 2 byte access (W) */
 
-#define XEN_UNPLUG_ALL_IDE_DISKS 1
-#define XEN_UNPLUG_ALL_NICS 2
-#define XEN_UNPLUG_AUX_IDE_DISKS 4
-#define XEN_UNPLUG_ALL 7
-#define XEN_UNPLUG_UNNECESSARY 8
+#define XEN_UNPLUG_ALL_IDE_DISKS	(1<<0)
+#define XEN_UNPLUG_ALL_NICS		(1<<1)
+#define XEN_UNPLUG_AUX_IDE_DISKS	(1<<2)
+#define XEN_UNPLUG_ALL			(XEN_UNPLUG_ALL_IDE_DISKS|\
+					 XEN_UNPLUG_ALL_NICS|\
+					 XEN_UNPLUG_AUX_IDE_DISKS)
+
+#define XEN_UNPLUG_UNNECESSARY 		(1<<16)
 
 static inline int xen_must_unplug_nics(void) {
 #if (defined(CONFIG_XEN_NETDEV_FRONTEND) || \
Signature · 1 line
1.5.6.5