Skip to contentSkip to conversation

xen: kconfig changes

RFC In review Luis R. Rodriguez 6 participants 47 messages Feb 12, 2015 – Feb 26, 2015

Subsystems (12)
Network drivers x86 SCSI Block layer +8 more subsystems
lore
Share & tools
lore
#0 lore raw

cover xen: kconfig changes

From: "Luis R. Rodriguez" <[email protected]>

Here's the first shot at the Kconfig changes for Xen as discussed on the mailing list a little while ago [0]. Let me know if you spot any issues or if you'd like things split differently. I tried to make things as atomic as possible, but not being too rediculous on the atomicity of the changes, for instance the HVC changes were reasonable to just fold into the other change it touched.

Haven't gone to war with testing the Kconfig changes yet given this is just the first RFC. If things look good please look for major issues and let me know.

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

Luis R. Rodriguez (8):
xen: make dom0 specific changes depend on XEN_DOM0
xen: x86: make XEN_MAX_DOMAIN_MEMORY depend on XEN_HAVE_PVMMU
xen: drivers: add XEN_FRONTEND and fold front end drivers under them
xen: x86: make XEN_PVH select XEN_PVHVM
xen: x86: add XEN_PV
xen: x86: make XEN_PV* stuff depend on PARAVIRT and PARAVIRT_CLOCK
xen: unwrap XEN_BACKEND from XEN_DOM0
xen: x86: remove CONFIG_XEN dependency PARAVIRT and PARAVIRT_CLOCK

 arch/x86/xen/Kconfig        | 26 +++++++++++++++++++-------
 drivers/block/Kconfig       |  3 +--
 drivers/input/misc/Kconfig  |  3 +--
 drivers/net/Kconfig         |  3 +--
 drivers/pci/Kconfig         |  3 +--
 drivers/scsi/Kconfig        |  3 +--
 drivers/tty/hvc/Kconfig     |  4 ++--
 drivers/video/fbdev/Kconfig |  3 +--
 drivers/watchdog/Kconfig    |  2 +-
 drivers/xen/Kconfig         | 18 +++++++++++++++---
 10 files changed, 43 insertions(+), 25 deletions(-)
Signature · 1 line
2.2.2
#1 lore raw

RFC 1/8 xen: make dom0 specific changes depend on XEN_DOM0

From: "Luis R. Rodriguez" <[email protected]>

These are Kconfig options which are known to only make sense with Xen dom0 support. This is as per the agreed upon changes to Xen's kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig     | 4 ++--
 drivers/watchdog/Kconfig | 2 +-
 drivers/xen/Kconfig      | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/xen/Kconfig +2 -2
index 6f615a3..490e43e 100644
@@ -35,13 +35,13 @@ config XEN_MAX_DOMAIN_MEMORY
 
 config XEN_SAVE_RESTORE
        bool
-       depends on XEN
+       depends on XEN_DOM0
        select HIBERNATE_CALLBACKS
        default y
 
 config XEN_DEBUG_FS
 	bool "Enable Xen debug and tuning parameters in debugfs"
-	depends on XEN && DEBUG_FS
+	depends on XEN_DOM0 && DEBUG_FS
 	default n
 	help
 	  Enable statistics output and various tuning options in debugfs.
drivers/watchdog/Kconfig +1 -1
index 08f41ad..34af197 100644
@@ -1409,7 +1409,7 @@ config WATCHDOG_RIO
 
 config XEN_WDT
 	tristate "Xen Watchdog support"
-	depends on XEN
+	depends on XEN_DOM0
 	help
 	  Say Y here to support the hypervisor watchdog capability provided
 	  by Xen 4.0 and newer.  The watchdog timeout period is normally one
drivers/xen/Kconfig +1 -1
index b812462..9350de02 100644
@@ -222,7 +222,7 @@ config XEN_ACPI_HOTPLUG_CPU
 
 config XEN_ACPI_PROCESSOR
 	tristate "Xen ACPI processor"
-	depends on XEN && X86 && ACPI_PROCESSOR && CPU_FREQ
+	depends on XEN_DOM0 && X86 && ACPI_PROCESSOR && CPU_FREQ
 	default m
 	help
           This ACPI processor uploads Power Management information to the Xen
Signature · 1 line
2.2.2
#2 lore raw

Re: [RFC v1 1/8] xen: make dom0 specific changes depend on XEN_DOM0

Quoted 5 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

These are Kconfig options which are known to only make sense with Xen dom0 support. This is as per the agreed upon changes to Xen's kconfig changes [0].

[...]

arch/x86/xen/Kconfig config XEN_MAX_DOMAIN_MEMORY · line 40

Quoted 10 lines
arch/x86/xen/Kconfig +1 -1
@@ -35,13 +35,13 @@ config XEN_MAX_DOMAIN_MEMORY
 
 config XEN_SAVE_RESTORE
        bool
-       depends on XEN
+       depends on XEN_DOM0
        select HIBERNATE_CALLBACKS
        default y

This breaks save/restore of domUs.

arch/x86/xen/Kconfig config XEN_MAX_DOMAIN_MEMORY · line 47

Quoted 7 lines
arch/x86/xen/Kconfig +1 -1
 config XEN_DEBUG_FS
 	bool "Enable Xen debug and tuning parameters in debugfs"
-	depends on XEN && DEBUG_FS
+	depends on XEN_DOM0 && DEBUG_FS
 	default n
 	help
 	  Enable statistics output and various tuning options in debugfs.

This is useful for domUs.

drivers/watchdog/Kconfig config WATCHDOG_RIO · line 1415

Quoted 13 lines
drivers/watchdog/Kconfig +1 -1
index 08f41ad..34af197 100644
@@ -1409,7 +1409,7 @@ config WATCHDOG_RIO
 
 config XEN_WDT
 	tristate "Xen Watchdog support"
-	depends on XEN
+	depends on XEN_DOM0
 	help
 	  Say Y here to support the hypervisor watchdog capability provided
 	  by Xen 4.0 and newer.  The watchdog timeout period is normally one

Again, useful for domUs.

David

#3 lore raw

Re: [RFC v1 1/8] xen: make dom0 specific changes depend on XEN_DOM0

Quoted 36 lines · David Vrabel
Quoted 5 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

These are Kconfig options which are known to only make sense with Xen dom0 support. This is as per the agreed upon changes to Xen's kconfig changes [0].

[...]

arch/x86/xen/Kconfig config XEN_MAX_DOMAIN_MEMORY · line 40

Quoted 10 lines
arch/x86/xen/Kconfig +1 -1
@@ -35,13 +35,13 @@ config XEN_MAX_DOMAIN_MEMORY
 
 config XEN_SAVE_RESTORE
        bool
-       depends on XEN
+       depends on XEN_DOM0
        select HIBERNATE_CALLBACKS
        default y

This breaks save/restore of domUs.

arch/x86/xen/Kconfig config XEN_MAX_DOMAIN_MEMORY · line 47

Quoted 7 lines
arch/x86/xen/Kconfig +1 -1
 config XEN_DEBUG_FS
 	bool "Enable Xen debug and tuning parameters in debugfs"
-	depends on XEN && DEBUG_FS
+	depends on XEN_DOM0 && DEBUG_FS
 	default n
 	help
 	  Enable statistics output and various tuning options in debugfs.

This is useful for domUs.

Quoted 6 lines
drivers/watchdog/Kconfig +0 -0
index 08f41ad..34af197 100644
@@ -1409,7 +1409,7 @@ config WATCHDOG_RIO
 
Quoted 9 lines

drivers/watchdog/Kconfig config WATCHDOG_RIO · line 1415

Quoted 7 lines
drivers/watchdog/Kconfig +1 -1
 config XEN_WDT
 	tristate "Xen Watchdog support"
-	depends on XEN
+	depends on XEN_DOM0
 	help
 	  Say Y here to support the hypervisor watchdog capability provided
 	  by Xen 4.0 and newer.  The watchdog timeout period is normally one

Again, useful for domUs.

OK that leaves only XEN_ACPI_PROCESSOR for the patch. Fixed.

Luis

#4 lore raw

RFC 2/8 xen: x86: make XEN_MAX_DOMAIN_MEMORY depend on XEN_HAVE_PVMMU

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Although XEN currently selects XEN_HAVE_PVMMU that will not be the case in the near future so select this requirement explicitly as per the agreed upon Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/Kconfig +1 -1
index 490e43e..4d3db19 100644
@@ -28,7 +28,7 @@ config XEN_MAX_DOMAIN_MEMORY
        int
        default 500 if X86_64
        default 64 if X86_32
-       depends on XEN
+       depends on XEN && XEN_HAVE_PVMMU
        help
          This only affects the sizing of some bss arrays, the unused
          portions of which are freed.
Signature · 1 line
2.2.2
#5 lore raw

Re: [RFC v1 2/8] xen: x86: make XEN_MAX_DOMAIN_MEMORY depend on XEN_HAVE_PVMMU

Quoted 5 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Although XEN currently selects XEN_HAVE_PVMMU that will not be the case in the near future so select this requirement explicitly as per the agreed upon Kconfig changes [0].

[...]

arch/x86/xen/Kconfig config XEN_MAX_DOMAIN_MEMORY · line 31

Quoted 8 lines
arch/x86/xen/Kconfig +1 -1
@@ -28,7 +28,7 @@ config XEN_MAX_DOMAIN_MEMORY
        int
        default 500 if X86_64
        default 64 if X86_32
-       depends on XEN
+       depends on XEN && XEN_HAVE_PVMMU

This can be just

depends on XEN_HAVE_PVMMU

David

#6 lore raw

Re: [RFC v1 2/8] xen: x86: make XEN_MAX_DOMAIN_MEMORY depend on XEN_HAVE_PVMMU

Quoted 18 lines · David Vrabel
Quoted 5 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Although XEN currently selects XEN_HAVE_PVMMU that will not be the case in the near future so select this requirement explicitly as per the agreed upon Kconfig changes [0].

[...]

arch/x86/xen/Kconfig config XEN_MAX_DOMAIN_MEMORY · line 31

Quoted 8 lines
arch/x86/xen/Kconfig +1 -1
@@ -28,7 +28,7 @@ config XEN_MAX_DOMAIN_MEMORY
        int
        default 500 if X86_64
        default 64 if X86_32
-       depends on XEN
+       depends on XEN && XEN_HAVE_PVMMU

This can be just

Quoted 1 line

depends on XEN_HAVE_PVMMU

Fixed.

Luis

#7 lore raw

RFC 3/8 xen: drivers: add XEN_FRONTEND and fold front end drivers under them

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Fold Xen front end drivers under their own Kconfig entry. You may want to for example only enable domU guests with pv-drivers.

While at it make HVC_XEN_FRONTEND select HVC_XEN.

This is a per the agreed upon Kconfig changes for Xen [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 drivers/block/Kconfig       |  3 +--
 drivers/input/misc/Kconfig  |  3 +--
 drivers/net/Kconfig         |  3 +--
 drivers/pci/Kconfig         |  3 +--
 drivers/scsi/Kconfig        |  3 +--
 drivers/tty/hvc/Kconfig     |  4 ++--
 drivers/video/fbdev/Kconfig |  3 +--
 drivers/xen/Kconfig         | 10 ++++++++++
 8 files changed, 18 insertions(+), 14 deletions(-)
drivers/block/Kconfig +1 -2
index 014a1cf..8259879 100644
@@ -482,9 +482,8 @@ config XILINX_SYSACE
 
 config XEN_BLKDEV_FRONTEND
 	tristate "Xen virtual block device support"
-	depends on XEN
+	depends on XEN_FRONTEND
 	default y
-	select XEN_XENBUS_FRONTEND
 	help
 	  This driver implements the front-end of the Xen virtual
 	  block device driver.  It communicates with a back-end driver
drivers/input/misc/Kconfig +1 -2
index 23297ab..71a736b 100644
@@ -656,9 +656,8 @@ config INPUT_CMA3000_I2C
 
 config INPUT_XEN_KBDDEV_FRONTEND
 	tristate "Xen virtual keyboard and mouse support"
-	depends on XEN
+	depends on XEN_FRONTEND
 	default y
-	select XEN_XENBUS_FRONTEND
 	help
 	  This driver implements the front-end of the Xen virtual
 	  keyboard and mouse device driver.  It communicates with a back-end
drivers/net/Kconfig +1 -2
index d6607ee..0ae5cbc 100644
@@ -333,8 +333,7 @@ source "drivers/net/ieee802154/Kconfig"
 
 config XEN_NETDEV_FRONTEND
 	tristate "Xen network device frontend driver"
-	depends on XEN
-	select XEN_XENBUS_FRONTEND
+	depends on XEN_FRONTEND
 	default y
 	help
 	  This driver provides support for Xen paravirtual network
drivers/pci/Kconfig +1 -2
index 7a8f1c5..0120499 100644
@@ -56,9 +56,8 @@ config PCI_STUB
 
 config XEN_PCIDEV_FRONTEND
         tristate "Xen PCI Frontend"
-        depends on PCI && X86 && XEN
+        depends on PCI && X86 && XEN_FRONTEND
         select PCI_XEN
-	select XEN_XENBUS_FRONTEND
         default y
         help
           The PCI device frontend driver allows the kernel to import arbitrary
drivers/scsi/Kconfig +1 -2
index 9c92f41..e369f0b 100644
@@ -588,8 +588,7 @@ config VMWARE_PVSCSI
 
 config XEN_SCSI_FRONTEND
 	tristate "XEN SCSI frontend driver"
-	depends on SCSI && XEN
-	select XEN_XENBUS_FRONTEND
+	depends on SCSI && XEN_FRONTEND
 	help
 	  The XEN SCSI frontend driver allows the kernel to access SCSI Devices
 	  within another guest OS (usually Dom0).
drivers/tty/hvc/Kconfig +2 -2
index 8902f9b..b9dec5f 100644
@@ -70,8 +70,8 @@ config HVC_XEN
 
 config HVC_XEN_FRONTEND
 	bool "Xen Hypervisor Multiple Consoles support"
-	depends on HVC_XEN
-	select XEN_XENBUS_FRONTEND
+	depends on XEN_FRONTEND
+	select HVC_XEN
 	default y
 	help
 	  Xen driver for secondary virtual consoles
drivers/video/fbdev/Kconfig +1 -2
index 4916c97..e0149d1 100644
@@ -2243,14 +2243,13 @@ config FB_VIRTUAL
 
 config XEN_FBDEV_FRONTEND
 	tristate "Xen virtual frame buffer support"
-	depends on FB && XEN
+	depends on FB && XEN_FRONTEND
 	select FB_SYS_FILLRECT
 	select FB_SYS_COPYAREA
 	select FB_SYS_IMAGEBLIT
 	select FB_SYS_FOPS
 	select FB_DEFERRED_IO
 	select INPUT_XEN_KBDDEV_FRONTEND if INPUT_MISC
-	select XEN_XENBUS_FRONTEND
 	default y
 	help
 	  This driver implements the front-end of the Xen virtual
drivers/xen/Kconfig +10 -0
index 9350de02..2af6f69 100644
@@ -83,6 +83,16 @@ config XEN_BACKEND
 	  Support for backend device drivers that provide I/O services
 	  to other virtual machines.
 
+config XEN_FRONTEND
+	bool "Frontend driver support"
+	select XEN
+	select XEN_XENBUS_FRONTEND
+	default y
+	help
+	  Support for frontend device drivers for Xen. You want to enable
+	  this if you want to run Xen guests. You can for instance enable
+	  domU guests with pv-drivers.
+
 config XENFS
 	tristate "Xen filesystem"
 	select XEN_PRIVCMD
Signature · 1 line
2.2.2
#8 lore raw

Re: [RFC v1 3/8] xen: drivers: add XEN_FRONTEND and fold front end drivers under them

Quoted 7 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Fold Xen front end drivers under their own Kconfig entry. You may want to for example only enable domU guests with pv-drivers.

While at it make HVC_XEN_FRONTEND select HVC_XEN.

[...]

Quoted 5 lines
drivers/xen/Kconfig +0 -0
@@ -83,6 +83,16 @@ config XEN_BACKEND
 	  Support for backend device drivers that provide I/O services
 	  to other virtual machines.

drivers/xen/Kconfig config XEN_BACKEND · line 94

Quoted 10 lines
drivers/xen/Kconfig +9 -0
 
+config XEN_FRONTEND
+	bool "Frontend driver support"
+	select XEN
+	select XEN_XENBUS_FRONTEND
+	default y
+	help
+	  Support for frontend device drivers for Xen. You want to enable
+	  this if you want to run Xen guests. You can for instance enable
+	  domU guests with pv-drivers.

XEN_FRONTEND should appear before XEN_BACKEND.

David

#9 lore raw

Re: [RFC v1 3/8] xen: drivers: add XEN_FRONTEND and fold front end drivers under them

Quoted 15 lines · David Vrabel
Quoted 7 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Fold Xen front end drivers under their own Kconfig entry. You may want to for example only enable domU guests with pv-drivers.

While at it make HVC_XEN_FRONTEND select HVC_XEN.

[...]

Quoted 6 lines
drivers/xen/Kconfig +0 -0
@@ -83,6 +83,16 @@ config XEN_BACKEND
 	  Support for backend device drivers that provide I/O services
 	  to other virtual machines.
 
Quoted 11 lines

drivers/xen/Kconfig config XEN_BACKEND · line 94

Quoted 9 lines
drivers/xen/Kconfig +9 -0
+config XEN_FRONTEND
+	bool "Frontend driver support"
+	select XEN
+	select XEN_XENBUS_FRONTEND
+	default y
+	help
+	  Support for frontend device drivers for Xen. You want to enable
+	  this if you want to run Xen guests. You can for instance enable
+	  domU guests with pv-drivers.

XEN_FRONTEND should appear before XEN_BACKEND.

Fixed.

Luis

#10 lore raw

RFC 4/8 xen: x86: make XEN_PVH select XEN_PVHVM

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This lets us expose XEN_PVH and set what is required for it. This only exists on the x86 universe. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/xen/Kconfig +2 -1
index 4d3db19..b675e14 100644
@@ -49,5 +49,6 @@ config XEN_DEBUG_FS
 
 config XEN_PVH
 	bool "Support for running as a PVH guest"
-	depends on X86_64 && XEN && XEN_PVHVM
+	depends on X86_64 && XEN
+	select XEN_PVHVM
 	def_bool n
Signature · 1 line
2.2.2
#11 lore raw

Re: [RFC v1 4/8] xen: x86: make XEN_PVH select XEN_PVHVM

Quoted 18 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This lets us expose XEN_PVH and set what is required for it. This only exists on the x86 universe. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/xen/Kconfig +0 -0
index 4d3db19..b675e14 100644

arch/x86/xen/Kconfig config XEN_DEBUG_FS · line 54

Quoted 7 lines
arch/x86/xen/Kconfig +2 -1
@@ -49,5 +49,6 @@ config XEN_DEBUG_FS
 
 config XEN_PVH
 	bool "Support for running as a PVH guest"
-	depends on X86_64 && XEN && XEN_PVHVM
+	depends on X86_64 && XEN
+	select XEN_PVHVM
 	def_bool n

As I wrote here [email protected] I think we should remove XEN_PVHVM as it is not adding much on top of XEN_FRONTEND.

#12 lore raw

Re: [RFC v1 4/8] xen: x86: make XEN_PVH select XEN_PVHVM

Quoted 20 lines · Stefano Stabellini
Quoted 19 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This lets us expose XEN_PVH and set what is required for it. This only exists on the x86 universe. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/xen/Kconfig +0 -0
index 4d3db19..b675e14 100644
@@ -49,5 +49,6 @@ config XEN_DEBUG_FS
 
Quoted 10 lines

arch/x86/xen/Kconfig config XEN_DEBUG_FS · line 54

Quoted 6 lines
arch/x86/xen/Kconfig +2 -1
 config XEN_PVH
 	bool "Support for running as a PVH guest"
-	depends on X86_64 && XEN && XEN_PVHVM
+	depends on X86_64 && XEN
+	select XEN_PVHVM
 	def_bool n

As I wrote here [email protected] I think we should remove XEN_PVHVM as it is not adding much on top of XEN_FRONTEND.

Sure, so long as folks grep XEN_PVHVM and see no issues with a wide change for it, it works nicely so far for the goals discussed on my end.

Luis

#13 lore raw

RFC 5/8 xen: x86: add XEN_PV

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This lets us rip out under the general XEN config the XEN_HAVE_PVMMU dependency. This only exists on the x86 universe. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 7 ++++++-
 drivers/xen/Kconfig  | 3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)
arch/x86/xen/Kconfig +6 -1
index b675e14..9e0442f 100644
@@ -7,7 +7,6 @@ config XEN
 	depends on PARAVIRT
 	select PARAVIRT_CLOCK
 	select PARAVIRT_MMU
-	select XEN_HAVE_PVMMU
 	depends on X86_64 || (X86_32 && X86_PAE)
 	depends on X86_TSC
 	help
@@ -52,3 +51,9 @@ config XEN_PVH
 	depends on X86_64 && XEN
 	select XEN_PVHVM
 	def_bool n
+
+config XEN_PV
+	bool "Support for running as a PV guest"
+	depends on XEN && X86
+	select XEN_HAVE_PVMMU
+	def_bool n
drivers/xen/Kconfig +2 -1
index 2af6f69..31391bc 100644
@@ -257,7 +257,8 @@ config XEN_MCE_LOG
 	  converting it into Linux mcelog format for mcelog tools
 
 config XEN_HAVE_PVMMU
-       bool
+	bool
+	depends on XEN_PV
 
 config XEN_EFI
 	def_bool y
Signature · 1 line
2.2.2
#14 lore raw

Re: [RFC v1 5/8] xen: x86: add XEN_PV

Quoted 6 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This lets us rip out under the general XEN config the XEN_HAVE_PVMMU dependency. This only exists on the x86 universe. This is as per the agreed upon Xen Kconfig changes [0].

[...]

arch/x86/xen/Kconfig config XEN_PVH · line 59

Quoted 10 lines
arch/x86/xen/Kconfig +6 -0
@@ -52,3 +51,9 @@ config XEN_PVH
 	depends on X86_64 && XEN
 	select XEN_PVHVM
 	def_bool n
+
+config XEN_PV
+	bool "Support for running as a PV guest"
+	depends on XEN && X86
+	select XEN_HAVE_PVMMU
+	def_bool n

These options should be in this order: XEN_PV, XEN_PVHVM, XEN_PVH.

David

#15 lore raw

Re: [RFC v1 5/8] xen: x86: add XEN_PV

Quoted 8 lines · David Vrabel
Quoted 6 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This lets us rip out under the general XEN config the XEN_HAVE_PVMMU dependency. This only exists on the x86 universe. This is as per the agreed upon Xen Kconfig changes [0].

[...]

Quoted 12 lines

arch/x86/xen/Kconfig config XEN_PVH · line 59

Quoted 10 lines
arch/x86/xen/Kconfig +6 -0
@@ -52,3 +51,9 @@ config XEN_PVH
 	depends on X86_64 && XEN
 	select XEN_PVHVM
 	def_bool n
+
+config XEN_PV
+	bool "Support for running as a PV guest"
+	depends on XEN && X86
+	select XEN_HAVE_PVMMU
+	def_bool n

These options should be in this order: XEN_PV, XEN_PVHVM, XEN_PVH.

OK I'll move them in order and also add a descrition to both XEN_PV and XEN_PVH, I cannot describe XEN_PVHVM as its a def_bool and the user does not get to select it or review it.

Luis

#16 lore raw

RFC 6/8 xen: x86: make XEN_PV* stuff depend on PARAVIRT and PARAVIRT_CLOCK

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This will later more easily let us unfold PARAVIRT and PARAVIRT_CLOCK from under CONFIG_XEN. All the XEN_PV* stuff is under the x86 universe. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/xen/Kconfig +6 -0
index 9e0442f..50e2fb4 100644
@@ -21,6 +21,8 @@ config XEN_DOM0
 
 config XEN_PVHVM
 	def_bool y
+	select PARAVIRT
+	select PARAVIRT_CLOCK
 	depends on XEN && PCI && X86_LOCAL_APIC
 
 config XEN_MAX_DOMAIN_MEMORY
@@ -49,11 +51,15 @@ config XEN_DEBUG_FS
 config XEN_PVH
 	bool "Support for running as a PVH guest"
 	depends on X86_64 && XEN
+	select PARAVIRT
+	select PARAVIRT_CLOCK
 	select XEN_PVHVM
 	def_bool n
 
 config XEN_PV
 	bool "Support for running as a PV guest"
 	depends on XEN && X86
+	select PARAVIRT
+	select PARAVIRT_CLOCK
 	select XEN_HAVE_PVMMU
 	def_bool n
Signature · 1 line
2.2.2
#17 lore raw

Re: [RFC v1 6/8] xen: x86: make XEN_PV* stuff depend on PARAVIRT and PARAVIRT_CLOCK

Quoted 32 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This will later more easily let us unfold PARAVIRT and PARAVIRT_CLOCK from under CONFIG_XEN. All the XEN_PV* stuff is under the x86 universe. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/xen/Kconfig +4 -0
index 9e0442f..50e2fb4 100644
@@ -21,6 +21,8 @@ config XEN_DOM0
 
 config XEN_PVHVM
 	def_bool y
+	select PARAVIRT
+	select PARAVIRT_CLOCK
 	depends on XEN && PCI && X86_LOCAL_APIC
 
 config XEN_MAX_DOMAIN_MEMORY
@@ -49,11 +51,15 @@ config XEN_DEBUG_FS
 config XEN_PVH
 	bool "Support for running as a PVH guest"
 	depends on X86_64 && XEN
+	select PARAVIRT
+	select PARAVIRT_CLOCK

arch/x86/xen/Kconfig config XEN_DEBUG_FS · line 65

Quoted 10 lines
arch/x86/xen/Kconfig +2 -0
 	select XEN_PVHVM
 	def_bool n
 
 config XEN_PV
 	bool "Support for running as a PV guest"
 	depends on XEN && X86
+	select PARAVIRT
+	select PARAVIRT_CLOCK
 	select XEN_HAVE_PVMMU
 	def_bool n

Given that all select PARAVIRT and PARAVIRT_CLOCK, shouldn't we just move them under config XEN?

#18 lore raw

Re: [RFC v1 6/8] xen: x86: make XEN_PV* stuff depend on PARAVIRT and PARAVIRT_CLOCK

Quoted 36 lines · Stefano Stabellini
Quoted 35 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This will later more easily let us unfold PARAVIRT and PARAVIRT_CLOCK from under CONFIG_XEN. All the XEN_PV* stuff is under the x86 universe. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)
arch/x86/xen/Kconfig +4 -0
index 9e0442f..50e2fb4 100644
@@ -21,6 +21,8 @@ config XEN_DOM0
 
 config XEN_PVHVM
 	def_bool y
+	select PARAVIRT
+	select PARAVIRT_CLOCK
 	depends on XEN && PCI && X86_LOCAL_APIC
 
 config XEN_MAX_DOMAIN_MEMORY
@@ -49,11 +51,15 @@ config XEN_DEBUG_FS
 config XEN_PVH
 	bool "Support for running as a PVH guest"
 	depends on X86_64 && XEN
+	select PARAVIRT
+	select PARAVIRT_CLOCK
 	select XEN_PVHVM
 	def_bool n
 
Quoted 10 lines

arch/x86/xen/Kconfig config XEN_DEBUG_FS · line 65

Quoted 7 lines
arch/x86/xen/Kconfig +2 -0
 config XEN_PV
 	bool "Support for running as a PV guest"
 	depends on XEN && X86
+	select PARAVIRT
+	select PARAVIRT_CLOCK
 	select XEN_HAVE_PVMMU
 	def_bool n

Given that all select PARAVIRT and PARAVIRT_CLOCK, shouldn't we just move them under config XEN?

I believe this makes sense given that XEN_FRONTEND will now also select it if we remove XEN_PVHVM and instead fold what it provides under XEN_FRONTEND. I'll send a v4 kconfig changes as things look so far.

Luis

#19 lore raw

RFC 7/8 xen: unwrap XEN_BACKEND from XEN_DOM0

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This unwraps XEN_BACKEND from depending on XEN_DOM0, it instead makes it depend on the possible x86 backends and under what scenerios its allowed under ARM. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 2 ++
 drivers/xen/Kconfig  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
arch/x86/xen/Kconfig +2 -0
index 50e2fb4..9298eb3 100644
@@ -16,8 +16,10 @@ config XEN
 
 config XEN_DOM0
 	def_bool y
+	select XEN_BACKEND
 	depends on XEN && PCI_XEN && SWIOTLB_XEN
 	depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
+	depends on XEN_PV || XEN_PVH
 
 config XEN_PVHVM
 	def_bool y
drivers/xen/Kconfig +2 -1
index 31391bc..d8bd3f6 100644
@@ -77,7 +77,8 @@ config XEN_DEV_EVTCHN
 
 config XEN_BACKEND
 	bool "Backend driver support"
-	depends on XEN_DOM0
+	depends on ARM || ARM64 || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))
+	select SWIOTLB_XEN if ARM || ARM64
 	default y
 	help
 	  Support for backend device drivers that provide I/O services
Signature · 1 line
2.2.2
#20 lore raw

Re: [RFC v1 7/8] xen: unwrap XEN_BACKEND from XEN_DOM0

Quoted 6 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This unwraps XEN_BACKEND from depending on XEN_DOM0, it instead makes it depend on the possible x86 backends and under what scenerios its allowed under ARM. This is as per the agreed upon Xen Kconfig changes [0].

[...]

drivers/xen/Kconfig config XEN_DEV_EVTCHN · line 80

Quoted 8 lines
drivers/xen/Kconfig +1 -1
@@ -77,7 +77,8 @@ config XEN_DEV_EVTCHN
 
 config XEN_BACKEND
 	bool "Backend driver support"
-	depends on XEN_DOM0
+	depends on ARM || ARM64 || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))

You don't need X86 here. Just XEN_PV etc. is fine.

David

#21 lore raw

Re: [RFC v1 7/8] xen: unwrap XEN_BACKEND from XEN_DOM0

Quoted 12 lines · David Vrabel
Quoted 6 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This unwraps XEN_BACKEND from depending on XEN_DOM0, it instead makes it depend on the possible x86 backends and under what scenerios its allowed under ARM. This is as per the agreed upon Xen Kconfig changes [0].

[...]

Quoted 4 lines
drivers/xen/Kconfig +0 -0
@@ -77,7 +77,8 @@ config XEN_DEV_EVTCHN
 
Quoted 6 lines

drivers/xen/Kconfig config XEN_DEV_EVTCHN · line 80

Quoted 4 lines
drivers/xen/Kconfig +1 -1
 config XEN_BACKEND
 	bool "Backend driver support"
-	depends on XEN_DOM0
+	depends on ARM || ARM64 || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))

You don't need X86 here. Just XEN_PV etc. is fine.

Fixed.

Luis

#22 lore raw

Re: [RFC v1 7/8] xen: unwrap XEN_BACKEND from XEN_DOM0

In reply to Luis R. Rodriguez
Quoted 35 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This unwraps XEN_BACKEND from depending on XEN_DOM0, it instead makes it depend on the possible x86 backends and under what scenerios its allowed under ARM. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 2 ++
 drivers/xen/Kconfig  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
arch/x86/xen/Kconfig +2 -0
index 50e2fb4..9298eb3 100644
@@ -16,8 +16,10 @@ config XEN
 
 config XEN_DOM0
 	def_bool y
+	select XEN_BACKEND
 	depends on XEN && PCI_XEN && SWIOTLB_XEN
 	depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
+	depends on XEN_PV || XEN_PVH
 
 config XEN_PVHVM
 	def_bool y
drivers/xen/Kconfig +0 -0
index 31391bc..d8bd3f6 100644

drivers/xen/Kconfig config XEN_DEV_EVTCHN · line 84

Quoted 9 lines
drivers/xen/Kconfig +2 -1
@@ -77,7 +77,8 @@ config XEN_DEV_EVTCHN
 
 config XEN_BACKEND
 	bool "Backend driver support"
-	depends on XEN_DOM0
+	depends on ARM || ARM64 || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))
+	select SWIOTLB_XEN if ARM || ARM64
 	default y
 	help
 	  Support for backend device drivers that provide I/O services

If you do this people could enable XEN_BACKEND without XEN on ARM. I think it needs to be:

depends on (XEN && (ARM || ARM64)) || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))

#23 lore raw

Re: [RFC v1 7/8] xen: unwrap XEN_BACKEND from XEN_DOM0

Quoted 49 lines · Stefano Stabellini
Quoted 35 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This unwraps XEN_BACKEND from depending on XEN_DOM0, it instead makes it depend on the possible x86 backends and under what scenerios its allowed under ARM. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 2 ++
 drivers/xen/Kconfig  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
arch/x86/xen/Kconfig +2 -0
index 50e2fb4..9298eb3 100644
@@ -16,8 +16,10 @@ config XEN
 
 config XEN_DOM0
 	def_bool y
+	select XEN_BACKEND
 	depends on XEN && PCI_XEN && SWIOTLB_XEN
 	depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
+	depends on XEN_PV || XEN_PVH
 
 config XEN_PVHVM
 	def_bool y
drivers/xen/Kconfig +0 -0
index 31391bc..d8bd3f6 100644

drivers/xen/Kconfig config XEN_DEV_EVTCHN · line 84

Quoted 9 lines
drivers/xen/Kconfig +2 -1
@@ -77,7 +77,8 @@ config XEN_DEV_EVTCHN
 
 config XEN_BACKEND
 	bool "Backend driver support"
-	depends on XEN_DOM0
+	depends on ARM || ARM64 || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))
+	select SWIOTLB_XEN if ARM || ARM64
 	default y
 	help
 	  Support for backend device drivers that provide I/O services

If you do this people could enable XEN_BACKEND without XEN on ARM. I think it needs to be:

Quoted 1 line

depends on (XEN && (ARM || ARM64)) || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))

It's this more sufficiently:

depends on XEN ?

David

#24 lore raw

Re: [RFC v1 7/8] xen: unwrap XEN_BACKEND from XEN_DOM0

Quoted 50 lines · David Vrabel
Quoted 49 lines · Stefano Stabellini
Quoted 35 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This unwraps XEN_BACKEND from depending on XEN_DOM0, it instead makes it depend on the possible x86 backends and under what scenerios its allowed under ARM. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 2 ++
 drivers/xen/Kconfig  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
arch/x86/xen/Kconfig +2 -0
index 50e2fb4..9298eb3 100644
@@ -16,8 +16,10 @@ config XEN
 
 config XEN_DOM0
 	def_bool y
+	select XEN_BACKEND
 	depends on XEN && PCI_XEN && SWIOTLB_XEN
 	depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
+	depends on XEN_PV || XEN_PVH
 
 config XEN_PVHVM
 	def_bool y
drivers/xen/Kconfig +0 -0
index 31391bc..d8bd3f6 100644

drivers/xen/Kconfig config XEN_DEV_EVTCHN · line 84

Quoted 9 lines
drivers/xen/Kconfig +2 -1
@@ -77,7 +77,8 @@ config XEN_DEV_EVTCHN
 
 config XEN_BACKEND
 	bool "Backend driver support"
-	depends on XEN_DOM0
+	depends on ARM || ARM64 || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))
+	select SWIOTLB_XEN if ARM || ARM64
 	default y
 	help
 	  Support for backend device drivers that provide I/O services

If you do this people could enable XEN_BACKEND without XEN on ARM. I think it needs to be:

Quoted 5 lines
Quoted 1 line

depends on (XEN && (ARM || ARM64)) || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))

It's this more sufficiently:

depends on XEN ?

Yeah :-)

#25 lore raw

Re: [RFC v1 7/8] xen: unwrap XEN_BACKEND from XEN_DOM0

Quoted 51 lines · Stefano Stabellini
Quoted 50 lines · David Vrabel
Quoted 49 lines · Stefano Stabellini
Quoted 35 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

This unwraps XEN_BACKEND from depending on XEN_DOM0, it instead makes it depend on the possible x86 backends and under what scenerios its allowed under ARM. This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 2 ++
 drivers/xen/Kconfig  | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
arch/x86/xen/Kconfig +2 -0
index 50e2fb4..9298eb3 100644
@@ -16,8 +16,10 @@ config XEN
 
 config XEN_DOM0
 	def_bool y
+	select XEN_BACKEND
 	depends on XEN && PCI_XEN && SWIOTLB_XEN
 	depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
+	depends on XEN_PV || XEN_PVH
 
 config XEN_PVHVM
 	def_bool y
drivers/xen/Kconfig +0 -0
index 31391bc..d8bd3f6 100644

drivers/xen/Kconfig config XEN_DEV_EVTCHN · line 84

Quoted 9 lines
drivers/xen/Kconfig +2 -1
@@ -77,7 +77,8 @@ config XEN_DEV_EVTCHN
 
 config XEN_BACKEND
 	bool "Backend driver support"
-	depends on XEN_DOM0
+	depends on ARM || ARM64 || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))
+	select SWIOTLB_XEN if ARM || ARM64
 	default y
 	help
 	  Support for backend device drivers that provide I/O services

If you do this people could enable XEN_BACKEND without XEN on ARM. I think it needs to be:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

depends on (XEN && (ARM || ARM64)) || (X86 && (XEN_PV || XEN_PVH || XEN_PVHVM))

It's this more sufficiently:

depends on XEN ?

Yeah :-)

We already only expose this option on the top of the Kconfig file with 'if XEN' language, folding XEN_PVHVM under XEN_FRONTEND might not suffice to ensure everything builds fine here given CONFIG_XEN does not implicate XEN_FRONTEND. Because of this I think the above is still required.

Let me know though, I'll send a v4 of what things look like (no code changes) right now before moving on again.

Luis

#26 lore raw

RFC 8/8 xen: x86: remove CONFIG_XEN dependency PARAVIRT and PARAVIRT_CLOCK

In reply to Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Now that the respective PV modes have the specific requirements selectable just remove this from CONFIG_XEN This is as per the agreed upon Xen Kconfig changes [0].

[0] http://comments.gmane.org/gmane.comp.emulators.xen.devel/231579

---
 arch/x86/xen/Kconfig | 2 --
 1 file changed, 2 deletions(-)
arch/x86/xen/Kconfig +0 -2
index 9298eb3..19b2d3d 100644
@@ -4,8 +4,6 @@
 
 config XEN
 	bool "Xen guest support"
-	depends on PARAVIRT
-	select PARAVIRT_CLOCK
 	select PARAVIRT_MMU
 	depends on X86_64 || (X86_32 && X86_PAE)
 	depends on X86_TSC
Signature · 1 line
2.2.2
#27 lore raw
In reply to Luis R. Rodriguez
Quoted 9 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Here's the first shot at the Kconfig changes for Xen as discussed on the mailing list a little while ago [0]. Let me know if you spot any issues or if you'd like things split differently. I tried to make things as atomic as possible, but not being too rediculous on the atomicity of the changes, for instance the HVC changes were reasonable to just fold into the other change it touched.

Quoted 3 lines

Haven't gone to war with testing the Kconfig changes yet given this is just the first RFC. If things look good please look for major issues and let me know.#

Can you spin a v2 and make a git branch available, please? I would like people to be able to easily try out the changes rather than looking at the diffs.

If I haven't comment on a specific patch it's because I thought it looked ok.

David

#28 lore raw
Quoted 14 lines · David Vrabel
Quoted 9 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Here's the first shot at the Kconfig changes for Xen as discussed on the mailing list a little while ago [0]. Let me know if you spot any issues or if you'd like things split differently. I tried to make things as atomic as possible, but not being too rediculous on the atomicity of the changes, for instance the HVC changes were reasonable to just fold into the other change it touched.

Quoted 3 lines

Haven't gone to war with testing the Kconfig changes yet given this is just the first RFC. If things look good please look for major issues and let me know.#

Quoted 6 lines

Can you spin a v2 and make a git branch available, please? I would like people to be able to easily try out the changes rather than looking at the diffs.

If I haven't comment on a specific patch it's because I thought it looked ok.

Sure thing, before that I should address now what I have found as issues with the Kconfig changes and what we need. What I see so far:

1) due to a recursive dependency it seems we should consider having XEN_DOM0 select SWIOTLB_XEN instead of depend on it? That fixes it:

arch/x86/xen/Kconfig +2 -1
index d930574..c25e12b 100644
@@ -14,7 +14,8 @@ config XEN
 config XEN_DOM0
        def_bool y
        select XEN_BACKEND
-       depends on XEN && PCI_XEN && SWIOTLB_XEN
+       select SWIOTLB_XEN
+       depends on XEN && PCI_XEN
        depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
        depends on XEN_PV || XEN_PVH
 

2) due to a recursive-dependency it doesn't seem we should have XEN_FRONTEND select on CONFIG_XEN -- with that in place we end up with:

arch/x86/xen/Kconfig:5:error: recursive dependency detected! arch/x86/xen/Kconfig:5: symbol XEN is selected by XEN_FRONTEND drivers/xen/Kconfig:82: symbol XEN_FRONTEND depends on XEN

If we remove the select XEN from XEN_FRONTEND that fixes it. Not sure what is ideal here though.

XEN_FRONTEND does not depend on XEN but the select seems to imply it.

3) The simple memory setup build issue:

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time at arch/x86/xen/enlighten.c on xen_start_kernel() here:

        if (xen_feature(XENFEAT_auto_translated_physmap))
                x86_init.resources.memory_setup = xen_auto_xlated_memory_setup;
        else
                x86_init.resources.memory_setup = xen_memory_setup;

The reason is that XENFEAT_auto_translated_physmap is statically set only if XEN_PVH is enabled. If you do not enable XEN_PVH then we have to call xen_memory_setup() and that routine requires CONFIG_XEN_MAX_DOMAIN_MEMORY defined which we only define when the XEN_PV is enabled now. A simple obvious fix is to enable XENFEAT_auto_translated_physmap when XEN_PVHVM is enabled but there are other features here to consider so its not clear to me which are PVH specific and which are desirable only for XEN_PVH.

Now, at least for XENFEAT_auto_translated_physmap since it its a static flag set upon build time depending on whether or not XENPVHVM is enabled it means we can fold all of xen_memory_setup() code into its own file from setup.c. This file can then be built with a new defbool:

+config XEN_BUILD_SIMPLE_MEMORY_SETUP
+ def_bool y if !XEN_PVHVM
+

And we'd build it:

+obj-$(CONFIG_XEN_BUILD_SIMPLE_MEMORY_SETUP) += simple_mem_setup.o

That cleans up setup.c pretty nicely and shoves all the simple memory setup stuff into its own file. That raises a few other questions about a few other routines we may want to review to in light of this that are only enabled when PVH is enabled upon init. This diff highlights the things to consider so far:

arch/x86/xen/enlighten.c +8 -0
index 78a881b..736dc65 100644
@@ -1511,24 +1511,29 @@ void __ref xen_pvh_secondary_vcpu_init(int cpu)
     xen_pvh_set_cr_flags(cpu);
 }
 
+/* this may need to be split up between XEN_PVHVM and XEN_PVH ? */
 static void __init xen_pvh_early_guest_init(void)
 {
     if (!xen_feature(XENFEAT_auto_translated_physmap))
         return;
+    /* XXX  */
 
     if (!xen_feature(XENFEAT_hvm_callback_vector))
         return;
 
+    /* which are XEN_PVH and which are XEN_PVHM specific */
     xen_have_vector_callback = 1;
 
     xen_pvh_early_cpu_init(0, false);
     xen_pvh_set_cr_flags(0);
 
+    /* XXX  */
 #ifdef CONFIG_X86_32
     BUG(); /* PVH: Implement proper support. */
 #endif
 }
 #endif    /* CONFIG_XEN_PVH */
+/* XXX  */
 
 /* First C function to be called on Xen boot */
 asmlinkage __visible void __init xen_start_kernel(void)
@@ -1543,6 +1548,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
     xen_domain_type = XEN_PV_DOMAIN;
 
     xen_setup_features();
+    /* this may need to be split up between XEN_PVHVM and XEN_PVH ? */
 #ifdef CONFIG_XEN_PVH
     xen_pvh_early_guest_init();
 #endif
@@ -1560,8 +1566,10 @@ asmlinkage __visible void __init xen_start_kernel(void)
 
     if (xen_feature(XENFEAT_auto_translated_physmap))
         x86_init.resources.memory_setup = xen_auto_xlated_memory_setup;
+#ifdef CONFIG_XEN_BUILD_SIMPLE_MEMORY_SETUP
     else
         x86_init.resources.memory_setup = xen_memory_setup;
+#endif
     x86_init.oem.arch_setup = xen_arch_setup;
     x86_init.oem.banner = xen_banner;
 
arch/x86/xen/mmu.c +2 -0
index adca9e2..34ee8fd 100644
@@ -1187,9 +1187,11 @@ static void __init xen_pagetable_init(void)
     /* Allocate and initialize top and mid mfn levels for p2m structure */
     xen_build_mfn_list_list();
 
+#ifdef CONFIG_XEN_BUILD_SIMPLE_MEMORY_SETUP
     /* Remap memory freed due to conflicts with E820 map */
     if (!xen_feature(XENFEAT_auto_translated_physmap))
         xen_remap_memory();
+#endif
 
     xen_setup_shared_info();
 }
arch/x86/xen/setup.c +0 -313

322 lines not on this page · raw message

remapping identity pages\n");
- xen_set_identity_and_release_chunk(cur_pfn,
- cur_pfn + left, nr_pages, released);
- break;

-        }
-        /* Adjust size to fit in current e820 RAM region */
-        if (size > remap_range_size)

- size = remap_range_size;
-
- xen_do_set_identity_and_remap_chunk(cur_pfn, size, remap_pfn);
-

-        /* Update variables to reflect new mappings. */
-        i += size;
-        remap_pfn += size;
-        *remapped += size;
-    }
-
-    /*
-     * If the PFNs are currently mapped, the VA mapping also needs
-     * to be updated to be 1:1.
-     */

- for (pfn = start_pfn; pfn <= max_pfn_mapped && pfn < end_pfn; pfn++)
- (void)HYPERVISOR_update_va_mapping(
- (unsigned long)__va(pfn << PAGE_SHIFT),
- mfn_pte(pfn, PAGE_KERNEL_IO), 0);
-
- return remap_pfn;
-}
-
-static void __init xen_set_identity_and_remap(
- const struct e820entry *list, size_t map_size, unsigned long nr_pages,
- unsigned long *released, unsigned long *remapped)
-{

-    phys_addr_t start = 0;
-    unsigned long last_pfn = nr_pages;
-    const struct e820entry *entry;
-    unsigned long num_released = 0;
-    unsigned long num_remapped = 0;
-    int i;
-
-    /*
-     * Combine non-RAM regions and gaps until a RAM region (or the
-     * end of the map) is reached, then set the 1:1 map and
-     * remap the memory in those non-RAM regions.
-     *
-     * The combined non-RAM regions are rounded to a whole number
-     * of pages so any partial pages are accessible via the 1:1
-     * mapping.  This is needed for some BIOSes that put (for
-     * example) the DMI tables in a reserved region that begins on
-     * a non-page boundary.
-     */

- for (i = 0, entry = list; i < map_size; i++, entry++) {
- phys_addr_t end = entry->addr + entry->size;
- if (entry->type == E820_RAM || i == map_size - 1) {
- unsigned long start_pfn = PFN_DOWN(start);
- unsigned long end_pfn = PFN_UP(end);
-
- if (entry->type == E820_RAM)
- end_pfn = PFN_UP(entry->addr);
-
- if (start_pfn < end_pfn)
- last_pfn = xen_set_identity_and_remap_chunk(

-                        list, map_size, start_pfn,
-                        end_pfn, nr_pages, last_pfn,
-                        &num_released, &num_remapped);

- start = end;
- }
- }
-
- *released = num_released;
- *remapped = num_remapped;
-
- pr_info("Released %ld page(s)\n", num_released);
-}
-
-/*
- * Remap the memory prepared in xen_do_set_identity_and_remap_chunk().
- * The remap information (which mfn remap to which pfn) is contained in the
- * to be remapped memory itself in a linked list anchored at xen_remap_mfn.
- * This scheme allows to remap the different chunks in arbitrary order while
- * the resulting mapping will be independant from the order.
- */
-void __init xen_remap_memory(void)
-{

-    unsigned long buf = (unsigned long)&xen_remap_buf;
-    unsigned long mfn_save, mfn, pfn;
-    unsigned long remapped = 0;
-    unsigned int i;
-    unsigned long pfn_s = ~0UL;
-    unsigned long len = 0;

-
- mfn_save = virt_to_mfn(buf);
-
- while (xen_remap_mfn != INVALID_P2M_ENTRY) {
- /* Map the remap information */
- set_pte_mfn(buf, xen_remap_mfn, PAGE_KERNEL);
-
- BUG_ON(xen_remap_mfn != xen_remap_buf.mfns[0]);
-
- pfn = xen_remap_buf.target_pfn;
- for (i = 0; i < xen_remap_buf.size; i++) {

-            mfn = xen_remap_buf.mfns[i];
-            xen_update_mem_tables(pfn, mfn);
-            remapped++;
-            pfn++;

- }
- if (pfn_s == ~0UL || pfn == pfn_s) {
- pfn_s = xen_remap_buf.target_pfn;
- len += xen_remap_buf.size;
- } else if (pfn_s + len == xen_remap_buf.target_pfn) {
- len += xen_remap_buf.size;
- } else {

-            xen_del_extra_mem(PFN_PHYS(pfn_s), PFN_PHYS(len));
-            pfn_s = xen_remap_buf.target_pfn;
-            len = xen_remap_buf.size;

- }
-
- mfn = xen_remap_mfn;
- xen_remap_mfn = xen_remap_buf.next_area_mfn;
- }
-
- if (pfn_s != ~0UL && len)
- xen_del_extra_mem(PFN_PHYS(pfn_s), PFN_PHYS(len));
-
- set_pte_mfn(buf, mfn_save, PAGE_KERNEL);
-
- pr_info("Remapped %ld page(s)\n", remapped);
-}
-
-static unsigned long __init xen_get_max_pages(void) -{

-    unsigned long max_pages = MAX_DOMAIN_PAGES;
-    domid_t domid = DOMID_SELF;
-    int ret;
-
-    /*
-     * For the initial domain we use the maximum reservation as
-     * the maximum page.
-     *
-     * For guest domains the current maximum reservation reflects
-     * the current maximum rather than the static maximum. In this
-     * case the e820 map provided to us will cover the static
-     * maximum region.
-     */

- if (xen_initial_domain()) {
- ret = HYPERVISOR_memory_op(XENMEM_maximum_reservation, &domid);
- if (ret > 0)
- max_pages = ret;
- }
-
- return min(max_pages, MAX_DOMAIN_PAGES);
-}
-
-static void __init xen_align_and_add_e820_region(phys_addr_t start,
- phys_addr_t size, int type)
-{
- phys_addr_t end = start + size;
-
- /* Align RAM regions to page boundaries. */
- if (type == E820_RAM) {
- start = PAGE_ALIGN(start);
- end &= ~((phys_addr_t)PAGE_SIZE - 1);
- }
-
- e820_add_region(start, end - start, type);
-}
-
-static void __init xen_ignore_unusable(struct e820entry *list, size_t map_size) -{
- struct e820entry *entry;
- unsigned int i;
-
- for (i = 0, entry = list; i < map_size; i++, entry++) {
- if (entry->type == E820_UNUSABLE)
- entry->type = E820_RAM;
- }
-}
-
-/**
- * machine_specific_memory_setup - Hook for machine specific memory setup.
- **/
-char * __init xen_memory_setup(void)
-{
- static struct e820entry map[E820MAX] __initdata;
-

-    unsigned long max_pfn = xen_start_info->nr_pages;
-    phys_addr_t mem_end;
-    int rc;
-    struct xen_memory_map memmap;
-    unsigned long max_pages;
-    unsigned long extra_pages = 0;
-    unsigned long remapped_pages;
-    int i;
-    int op;

-
- max_pfn = min(MAX_DOMAIN_PAGES, max_pfn);
- mem_end = PFN_PHYS(max_pfn);
-
- memmap.nr_entries = E820MAX;
- set_xen_guest_handle(memmap.buffer, map);
-
- op = xen_initial_domain() ?
- XENMEM_machine_memory_map :
- XENMEM_memory_map;
- rc = HYPERVISOR_memory_op(op, &memmap);
- if (rc == -ENOSYS) {

-        BUG_ON(xen_initial_domain());
-        memmap.nr_entries = 1;
-        map[0].addr = 0ULL;
-        map[0].size = mem_end;
-        /* 8MB slack (to balance backend allocations). */
-        map[0].size += 8ULL << 20;
-        map[0].type = E820_RAM;
-        rc = 0;
-    }
-    BUG_ON(rc);
-    BUG_ON(memmap.nr_entries == 0);
-
-    /*
-     * Xen won't allow a 1:1 mapping to be created to UNUSABLE
-     * regions, so if we're using the machine memory map leave the
-     * region as RAM as it is in the pseudo-physical map.
-     *
-     * UNUSABLE regions in domUs are not handled and will need
-     * a patch in the future.
-     */

- if (xen_initial_domain())
- xen_ignore_unusable(map, memmap.nr_entries);
-
- /* Make sure the Xen-supplied memory map is well-ordered. */
- sanitize_e820_map(map, memmap.nr_entries, &memmap.nr_entries);
-
- max_pages = xen_get_max_pages();
- if (max_pages > max_pfn)
- extra_pages += max_pages - max_pfn;
-
- /*

-     * Set identity map on non-RAM pages and prepare remapping the
-     * underlying RAM.
-     */

- xen_set_identity_and_remap(map, memmap.nr_entries, max_pfn,
- &xen_released_pages, &remapped_pages);
-
- extra_pages += xen_released_pages;
- extra_pages += remapped_pages;
-
- /*

-     * Clamp the amount of extra memory to a EXTRA_MEM_RATIO
-     * factor the base size.  On non-highmem systems, the base
-     * size is the full initial memory allocation; on highmem it
-     * is limited to the max size of lowmem, so that it doesn't
-     * get completely filled.
-     *
-     * In principle there could be a problem in lowmem systems if
-     * the initial memory is also very large with respect to
-     * lowmem, but we won't try to deal with that here.
-     */

- extra_pages = min(EXTRA_MEM_RATIO * min(max_pfn, PFN_DOWN(MAXMEM)),
- extra_pages);
- i = 0;
- while (i < memmap.nr_entries) {

-        phys_addr_t addr = map[i].addr;
-        phys_addr_t size = map[i].size;
-        u32 type = map[i].type;

-
- if (type == E820_RAM) {
- if (addr < mem_end) {
- size = min(size, mem_end - addr);
- } else if (extra_pages) {

-                size = min(size, PFN_PHYS(extra_pages));
-                extra_pages -= PFN_DOWN(size);
-                xen_add_extra_mem(addr, size);
-                xen_max_p2m_pfn = PFN_DOWN(addr + size);

- } else
- type = E820_UNUSABLE;
- }
-
- xen_align_and_add_e820_region(addr, size, type);
-

-        map[i].addr += size;
-        map[i].size -= size;
-        if (map[i].size == 0)

- i++;
- }
-
- /*

-     * Set the rest as identity mapped, in case PCI BARs are
-     * located here.
-     *
-     * PFNs above MAX_P2M_PFN are considered identity mapped as
-     * well.
-     */
-    set_phys_range_identity(map[i-1].addr / PAGE_SIZE, ~0ul);
-
-    /*
-     * In domU, the ISA region is normal, usable memory, but we
-     * reserve ISA memory anyway because too many things poke
-     * about in there.
-     */

- e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS,
- E820_RESERVED);
-
- /*

-     * Reserve Xen bits:
-     *  - mfn_list
-     *  - xen_start_info
-     * See comment above "struct start_info" in <xen/interface/xen.h>
-     * We tried to make the the memblock_reserve more selective so
-     * that it would be clear what region is reserved. Sadly we ran
-     * in the problem wherein on a 64-bit hypervisor with a 32-bit
-     * initial domain, the pt_base has the cr3 value which is not
-     * neccessarily where the pagetable starts! As Jan put it: "
-     * Actually, the adjustment turns out to be correct: The page
-     * tables for a 32-on-64 dom0 get allocated in the order "first L1",
-     * "first L2", "first L3", so the offset to the page table base is
-     * indeed 2. When reading xen/include/public/xen.h's comment
-     * very strictly, this is not a violation (since there nothing is said
-     * that the first thing in the page table space is pointed to by
-     * pt_base; I admit that this seems to be implied though, namely
-     * do I think that it is implied that the page table space is the
-     * range [pt_base, pt_base + nt_pt_frames), whereas that
-     * range here indeed is [pt_base - 2, pt_base - 2 + nt_pt_frames),
-     * which - without a priori knowledge - the kernel would have
-     * difficulty to figure out)." - so lets just fall back to the
-     * easy way and reserve the whole region.
-     */

- memblock_reserve(__pa(xen_start_info->mfn_list),
- xen_start_info->pt_base - xen_start_info->mfn_list);
-
- sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
-
- return "Xen";
-}
-
-/*
* Machine specific memory setup for auto-translated guests. */
char * __init xen_auto_xlated_memory_setup(void)

arch/x86/xen/simple_mem_setup.c new file +249 -0

249 lines not on this page · raw message

remapping identity pages\n");
+ xen_set_identity_and_release_chunk(cur_pfn,
+ cur_pfn + left, nr_pages, released);
+ break;

+        }
+        /* Adjust size to fit in current e820 RAM region */
+        if (size > remap_range_size)

+ size = remap_range_size;
+
+ xen_do_set_identity_and_remap_chunk(cur_pfn, size, remap_pfn);
+

+        /* Update variables to reflect new mappings. */
+        i += size;
+        remap_pfn += size;
+        *remapped += size;
+    }
+
+    /*
+     * If the PFNs are currently mapped, the VA mapping also needs
+     * to be updated to be 1:1.
+     */

+ for (pfn = start_pfn; pfn <= max_pfn_mapped && pfn < end_pfn; pfn++)
+ (void)HYPERVISOR_update_va_mapping(
+ (unsigned long)__va(pfn << PAGE_SHIFT),
+ mfn_pte(pfn, PAGE_KERNEL_IO), 0);
+
+ return remap_pfn;
+}
+
+static void __init xen_set_identity_and_remap(
+ const struct e820entry *list, size_t map_size, unsigned long nr_pages,
+ unsigned long *released, unsigned long *remapped)
+{

+    phys_addr_t start = 0;
+    unsigned long last_pfn = nr_pages;
+    const struct e820entry *entry;
+    unsigned long num_released = 0;
+    unsigned long num_remapped = 0;
+    int i;
+
+    /*
+     * Combine non-RAM regions and gaps until a RAM region (or the
+     * end of the map) is reached, then set the 1:1 map and
+     * remap the memory in those non-RAM regions.
+     *
+     * The combined non-RAM regions are rounded to a whole number
+     * of pages so any partial pages are accessible via the 1:1
+     * mapping.  This is needed for some BIOSes that put (for
+     * example) the DMI tables in a reserved region that begins on
+     * a non-page boundary.
+     */

+ for (i = 0, entry = list; i < map_size; i++, entry++) {
+ phys_addr_t end = entry->addr + entry->size;
+ if (entry->type == E820_RAM || i == map_size - 1) {
+ unsigned long start_pfn = PFN_DOWN(start);
+ unsigned long end_pfn = PFN_UP(end);
+
+ if (entry->type == E820_RAM)
+ end_pfn = PFN_UP(entry->addr);
+
+ if (start_pfn < end_pfn)
+ last_pfn = xen_set_identity_and_remap_chunk(

+                        list, map_size, start_pfn,
+                        end_pfn, nr_pages, last_pfn,
+                        &num_released, &num_remapped);

+ start = end;
+ }
+ }
+
+ *released = num_released;
+ *remapped = num_remapped;
+
+ pr_info("Released %ld page(s)\n", num_released);
+}
+
+
+static unsigned long __init xen_get_max_pages(void) +{

+    unsigned long max_pages = MAX_DOMAIN_PAGES;
+    domid_t domid = DOMID_SELF;
+    int ret;
+
+    /*
+     * For the initial domain we use the maximum reservation as
+     * the maximum page.
+     *
+     * For guest domains the current maximum reservation reflects
+     * the current maximum rather than the static maximum. In this
+     * case the e820 map provided to us will cover the static
+     * maximum region.
+     */

+ if (xen_initial_domain()) {
+ ret = HYPERVISOR_memory_op(XENMEM_maximum_reservation, &domid);
+ if (ret > 0)
+ max_pages = ret;
+ }
+
+ return min(max_pages, MAX_DOMAIN_PAGES);
+}
+
+static void __init xen_align_and_add_e820_region(phys_addr_t start,
+ phys_addr_t size, int type)
+{
+ phys_addr_t end = start + size;
+
+ /* Align RAM regions to page boundaries. */
+ if (type == E820_RAM) {
+ start = PAGE_ALIGN(start);
+ end &= ~((phys_addr_t)PAGE_SIZE - 1);
+ }
+
+ e820_add_region(start, end - start, type);
+}
+
+static void __init xen_ignore_unusable(struct e820entry *list, size_t map_size) +{
+ struct e820entry *entry;
+ unsigned int i;
+
+ for (i = 0, entry = list; i < map_size; i++, entry++) {
+ if (entry->type == E820_UNUSABLE)
+ entry->type = E820_RAM;
+ }
+}
+
+static void __init xen_add_extra_mem(phys_addr_t start, phys_addr_t size) +{
+ int i;
+
+ for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
+ /* Add new region. */
+ if (xen_extra_mem[i].size == 0) {

+            xen_extra_mem[i].start = start;
+            xen_extra_mem[i].size  = size;
+            break;
+        }
+        /* Append to existing region. */
+        if (xen_extra_mem[i].start + xen_extra_mem[i].size == start) {

+ xen_extra_mem[i].size += size;
+ break;
+ }
+ }
+ if (i == XEN_EXTRA_MEM_MAX_REGIONS)
+ printk(KERN_WARNING "Warning: not enough extra memory regions\n");
+
+ memblock_reserve(start, size);
+}
+
+/**
+ * machine_specific_memory_setup - Hook for machine specific memory setup.
+ **/
+char * __init xen_memory_setup(void)
+{
+ static struct e820entry map[E820MAX] __initdata;
+

+    unsigned long max_pfn = xen_start_info->nr_pages;
+    phys_addr_t mem_end;
+    int rc;
+    struct xen_memory_map memmap;
+    unsigned long max_pages;
+    unsigned long extra_pages = 0;
+    unsigned long remapped_pages;
+    int i;
+    int op;

+
+ max_pfn = min(MAX_DOMAIN_PAGES, max_pfn);
+ mem_end = PFN_PHYS(max_pfn);
+
+ memmap.nr_entries = E820MAX;
+ set_xen_guest_handle(memmap.buffer, map);
+
+ op = xen_initial_domain() ?
+ XENMEM_machine_memory_map :
+ XENMEM_memory_map;
+ rc = HYPERVISOR_memory_op(op, &memmap);
+ if (rc == -ENOSYS) {

+        BUG_ON(xen_initial_domain());
+        memmap.nr_entries = 1;
+        map[0].addr = 0ULL;
+        map[0].size = mem_end;
+        /* 8MB slack (to balance backend allocations). */
+        map[0].size += 8ULL << 20;
+        map[0].type = E820_RAM;
+        rc = 0;
+    }
+    BUG_ON(rc);
+    BUG_ON(memmap.nr_entries == 0);
+
+    /*
+     * Xen won't allow a 1:1 mapping to be created to UNUSABLE
+     * regions, so if we're using the machine memory map leave the
+     * region as RAM as it is in the pseudo-physical map.
+     *
+     * UNUSABLE regions in domUs are not handled and will need
+     * a patch in the future.
+     */

+ if (xen_initial_domain())
+ xen_ignore_unusable(map, memmap.nr_entries);
+
+ /* Make sure the Xen-supplied memory map is well-ordered. */
+ sanitize_e820_map(map, memmap.nr_entries, &memmap.nr_entries);
+
+ max_pages = xen_get_max_pages();
+ if (max_pages > max_pfn)
+ extra_pages += max_pages - max_pfn;
+
+ /*

+     * Set identity map on non-RAM pages and prepare remapping the
+     * underlying RAM.
+     */

+ xen_set_identity_and_remap(map, memmap.nr_entries, max_pfn,
+ &xen_released_pages, &remapped_pages);
+
+ extra_pages += xen_released_pages;
+ extra_pages += remapped_pages;
+
+ /*

+     * Clamp the amount of extra memory to a EXTRA_MEM_RATIO
+     * factor the base size.  On non-highmem systems, the base
+     * size is the full initial memory allocation; on highmem it
+     * is limited to the max size of lowmem, so that it doesn't
+     * get completely filled.
+     *
+     * In principle there could be a problem in lowmem systems if
+     * the initial memory is also very large with respect to
+     * lowmem, but we won't try to deal with that here.
+     */

+ extra_pages = min(EXTRA_MEM_RATIO * min(max_pfn, PFN_DOWN(MAXMEM)),
+ extra_pages);
+ i = 0;
+ while (i < memmap.nr_entries) {

+        phys_addr_t addr = map[i].addr;
+        phys_addr_t size = map[i].size;
+        u32 type = map[i].type;

+
+ if (type == E820_RAM) {
+ if (addr < mem_end) {
+ size = min(size, mem_end - addr);
+ } else if (extra_pages) {

+                size = min(size, PFN_PHYS(extra_pages));
+                extra_pages -= PFN_DOWN(size);
+                xen_add_extra_mem(addr, size);
+                xen_max_p2m_pfn = PFN_DOWN(addr + size);

+ } else
+ type = E820_UNUSABLE;
+ }
+
+ xen_align_and_add_e820_region(addr, size, type);
+

+        map[i].addr += size;
+        map[i].size -= size;
+        if (map[i].size == 0)

+ i++;
+ }
+
+ /*

+     * Set the rest as identity mapped, in case PCI BARs are
+     * located here.
+     *
+     * PFNs above MAX_P2M_PFN are considered identity mapped as
+     * well.
+     */
+    set_phys_range_identity(map[i-1].addr / PAGE_SIZE, ~0ul);
+
+    /*
+     * In domU, the ISA region is normal, usable memory, but we
+     * reserve ISA memory anyway because too many things poke
+     * about in there.
+     */

+ e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS,
+ E820_RESERVED);
+
+ /*

+     * Reserve Xen bits:
+     *  - mfn_list
+     *  - xen_start_info
+     * See comment above "struct start_info" in <xen/interface/xen.h>
+     * We tried to make the the memblock_reserve more selective so
+     * that it would be clear what region is reserved. Sadly we ran
+     * in the problem wherein on a 64-bit hypervisor with a 32-bit
+     * initial domain, the pt_base has the cr3 value which is not
+     * neccessarily where the pagetable starts! As Jan put it: "
+     * Actually, the adjustment turns out to be correct: The page
+     * tables for a 32-on-64 dom0 get allocated in the order "first L1",
+     * "first L2", "first L3", so the offset to the page table base is
+     * indeed 2. When reading xen/include/public/xen.h's comment
+     * very strictly, this is not a violation (since there nothing is said
+     * that the first thing in the page table space is pointed to by
+     * pt_base; I admit that this seems to be implied though, namely
+     * do I think that it is implied that the page table space is the
+     * range [pt_base, pt_base + nt_pt_frames), whereas that
+     * range here indeed is [pt_base - 2, pt_base - 2 + nt_pt_frames),
+     * which - without a priori knowledge - the kernel would have
+     * difficulty to figure out)." - so lets just fall back to the
+     * easy way and reserve the whole region.
+     */

+ memblock_reserve(__pa(xen_start_info->mfn_list),
+ xen_start_info->pt_base - xen_start_info->mfn_list);
+
+ sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
+
+ return "Xen";
+}
+
+static void __init xen_del_extra_mem(phys_addr_t start, phys_addr_t size) +{
+ int i;
+ phys_addr_t start_r, size_r;
+
+ for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
+ start_r = xen_extra_mem[i].start;
+ size_r = xen_extra_mem[i].size;
+
+ /* Start of region. */
+ if (start_r == start) {

+            BUG_ON(size > size_r);
+            xen_extra_mem[i].start += size;
+            xen_extra_mem[i].size -= size;
+            break;
+        }
+        /* End of region. */
+        if (start_r + size_r == start + size) {
+            BUG_ON(size > size_r);
+            xen_extra_mem[i].size -= size;
+            break;
+        }
+        /* Mid of region. */
+        if (start > start_r && start < start_r + size_r) {
+            BUG_ON(start + size > start_r + size_r);
+            xen_extra_mem[i].size = start - start_r;
+            /* Calling memblock_reserve() again is okay. */
+            xen_add_extra_mem(start + size, start_r + size_r -

+ (start + size));
+ break;
+ }
+ }
+ memblock_free(start, size);
+}
+
+/*
+ * Helper function to update the p2m and m2p tables and kernel mapping.
+ */
+static void __init xen_update_mem_tables(unsigned long pfn, unsigned long mfn) +{
+ struct mmu_update update = {
+ .ptr = ((uint64_t)mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE,
+ .val = pfn
+ };
+
+ /* Update p2m */
+ if (!set_phys_to_machine(pfn, mfn)) {
+ WARN(1, "Failed to set p2m mapping for pfn=%ld mfn=%ld\n",
+ pfn, mfn);
+ BUG();
+ }
+
+ /* Update m2p */
+ if (HYPERVISOR_mmu_update(&update, 1, NULL, DOMID_SELF) < 0) {
+ WARN(1, "Failed to set m2p mapping for mfn=%ld pfn=%ld\n",
+ mfn, pfn);
+ BUG();
+ }
+
+ /* Update kernel mapping, but not for highmem. */
+ if (pfn >= PFN_UP(__pa(high_memory - 1)))
+ return;
+
+ if (HYPERVISOR_update_va_mapping((unsigned long)__va(pfn << PAGE_SHIFT),
+ mfn_pte(mfn, PAGE_KERNEL), 0)) {
+ WARN(1, "Failed to update kernel mapping for mfn=%ld pfn=%ld\n",
+ mfn, pfn);
+ BUG();
+ }
+}
+
+
+/*
+ * Remap the memory prepared in xen_do_set_identity_and_remap_chunk().
+ * The remap information (which mfn remap to which pfn) is contained in the
+ * to be remapped memory itself in a linked list anchored at xen_remap_mfn.
+ * This scheme allows to remap the different chunks in arbitrary order while
+ * the resulting mapping will be independant from the order.
+ */
+void __init xen_remap_memory(void)
+{

+    unsigned long buf = (unsigned long)&xen_remap_buf;
+    unsigned long mfn_save, mfn, pfn;
+    unsigned long remapped = 0;
+    unsigned int i;
+    unsigned long pfn_s = ~0UL;
+    unsigned long len = 0;

+
+ mfn_save = virt_to_mfn(buf);
+
+ while (xen_remap_mfn != INVALID_P2M_ENTRY) {
+ /* Map the remap information */
+ set_pte_mfn(buf, xen_remap_mfn, PAGE_KERNEL);
+
+ BUG_ON(xen_remap_mfn != xen_remap_buf.mfns[0]);
+
+ pfn = xen_remap_buf.target_pfn;
+ for (i = 0; i < xen_remap_buf.size; i++) {

+            mfn = xen_remap_buf.mfns[i];
+            xen_update_mem_tables(pfn, mfn);
+            remapped++;
+            pfn++;

+ }
+ if (pfn_s == ~0UL || pfn == pfn_s) {
+ pfn_s = xen_remap_buf.target_pfn;
+ len += xen_remap_buf.size;
+ } else if (pfn_s + len == xen_remap_buf.target_pfn) {
+ len += xen_remap_buf.size;
+ } else {

+            xen_del_extra_mem(PFN_PHYS(pfn_s), PFN_PHYS(len));
+            pfn_s = xen_remap_buf.target_pfn;
+            len = xen_remap_buf.size;

+ }
+
+ mfn = xen_remap_mfn;
+ xen_remap_mfn = xen_remap_buf.next_area_mfn;
+ }
+
+ if (pfn_s != ~0UL && len)
+ xen_del_extra_mem(PFN_PHYS(pfn_s), PFN_PHYS(len));
+
+ set_pte_mfn(buf, mfn_save, PAGE_KERNEL);
+
+ pr_info("Remapped %ld page(s)\n", remapped);
+}

arch/x86/xen/xen-head.S +1 -0
index 674b2225..ab4d07c 100644
@@ -14,25 +14,36 @@
 #include <xen/interface/features.h>
 #include <asm/xen/interface.h>
 
+/* These are statically set */
 #ifdef CONFIG_XEN_PVH
 #define PVH_FEATURES_STR

"|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel"
/* Note the lack of 'hvm_callback_vector'. Older hypervisor will
* balk at this being part of XEN_ELFNOTE_FEATURES, so we put it in
* XEN_ELFNOTE_SUPPORTED_FEATURES which older hypervisors will ignore. */
+/* the XEN_PVH features */

 #define PVH_FEATURES ((1 << XENFEAT_writable_page_tables) | \
               (1 << XENFEAT_auto_translated_physmap) | \
               (1 << XENFEAT_supervisor_mode_kernel) | \
               (1 << XENFEAT_hvm_callback_vector))

+
/* The XENFEAT_writable_page_tables is not stricly neccessary as we set that
* up regardless whether this CONFIG option is enabled or not, but it
* clarifies what the right flags need to be.
*/
#else
+
+/* what else? */
+#ifdef CONFIG_XEN_PVHVM
+#define PVH_FEATURES_STR "|auto_translated_physmap"
+#define PVH_FEATURES (1 << XENFEAT_auto_translated_physmap) +#else
#define PVH_FEATURES_STR ""
#define PVH_FEATURES (0)
#endif

+#endif
+

     __INIT

ENTRY(startup_xen)
cld

#29 lore raw
Quoted 3 lines · Luis R. Rodriguez

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time

And this also raises the question of whether or not we should make XEN_PVHVM a user selectable option, right now it is a def_bool and is therefore not human selectable. You can implicitly disable it by disabling PCI for example though. If we want that to be exposed to the user we can then enable some description of what that means, and the user will then be able to read / select / enable XEN_PV., XEN_PVHVM, XEN_PVH. Right now they'd only be able to select XEN_PV and/or XEN_PVH, XEN_PVHVM is implicit.

Luis

maintainer
#30 lore raw
Quoted 6 lines · Luis R. Rodriguez
Quoted 3 lines · Luis R. Rodriguez

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time

Quoted 8 lines

And this also raises the question of whether or not we should make XEN_PVHVM a user selectable option, right now it is a def_bool and is therefore not human selectable. You can implicitly disable it by disabling PCI for example though. If we want that to be exposed to the user we can then enable some description of what that means, and the user will then be able to read / select / enable XEN_PV., XEN_PVHVM, XEN_PVH. Right now they'd only be able to select XEN_PV and/or XEN_PVH, XEN_PVHVM is implicit.

I think making XEN_PVHVM user selectable is okay.

Juergen

#31 lore raw
Quoted 20 lines · Juergen Gross
Quoted 9 lines · Luis R. Rodriguez
Quoted 4 lines · Luis R. Rodriguez

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time

Quoted 8 lines

And this also raises the question of whether or not we should make XEN_PVHVM a user selectable option, right now it is a def_bool and is therefore not human selectable. You can implicitly disable it by disabling PCI for example though. If we want that to be exposed to the user we can then enable some description of what that means, and the user will then be able to read / select / enable XEN_PV., XEN_PVHVM, XEN_PVH. Right now they'd only be able to select XEN_PV and/or XEN_PVH, XEN_PVHVM is implicit.

Quoted 1 line

I think making XEN_PVHVM user selectable is okay.

OK I'll enable this then.

Luis

#32 lore raw
Quoted 21 lines · Luis R. Rodriguez
Quoted 20 lines · Juergen Gross
Quoted 17 lines · Luis R. Rodriguez
Quoted 4 lines · Luis R. Rodriguez

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time

And this also raises the question of whether or not we should make XEN_PVHVM a user selectable option, right now it is a def_bool and is therefore not human selectable. You can implicitly disable it by disabling PCI for example though. If we want that to be exposed to the user we can then enable some description of what that means, and the user will then be able to read / select / enable XEN_PV., XEN_PVHVM, XEN_PVH. Right now they'd only be able to select XEN_PV and/or XEN_PVH, XEN_PVHVM is implicit.

Quoted 3 lines
Quoted 1 line

I think making XEN_PVHVM user selectable is okay.

OK I'll enable this then.

Please don't. We had bugs in the past because distros did not select it (they made it an module) and the PV drivers were not loaded.

There should be an history in the git tree behind the desire to make it non selectable.

#33 lore raw
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 21 lines · Luis R. Rodriguez
Quoted 20 lines · Juergen Gross
Quoted 17 lines · Luis R. Rodriguez
Quoted 4 lines · Luis R. Rodriguez

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time

And this also raises the question of whether or not we should make XEN_PVHVM a user selectable option, right now it is a def_bool and is therefore not human selectable. You can implicitly disable it by disabling PCI for example though. If we want that to be exposed to the user we can then enable some description of what that means, and the user will then be able to read / select / enable XEN_PV., XEN_PVHVM, XEN_PVH. Right now they'd only be able to select XEN_PV and/or XEN_PVH, XEN_PVHVM is implicit.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I think making XEN_PVHVM user selectable is okay.

OK I'll enable this then.

Please don't. We had bugs in the past because distros did not select it (they made it an module) and the PV drivers were not loaded.

Oy vey.

Quoted 2 lines

There should be an history in the git tree behind the desire to make it non selectable.

OK how about we enable the user selection only under CONFIG_EXPERT, otherwise make it hidden.

Luis

#34 lore raw
Quoted 31 lines · Luis R. Rodriguez
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 21 lines · Luis R. Rodriguez
Quoted 20 lines · Juergen Gross
Quoted 17 lines · Luis R. Rodriguez
Quoted 4 lines · Luis R. Rodriguez

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time

And this also raises the question of whether or not we should make XEN_PVHVM a user selectable option, right now it is a def_bool and is therefore not human selectable. You can implicitly disable it by disabling PCI for example though. If we want that to be exposed to the user we can then enable some description of what that means, and the user will then be able to read / select / enable XEN_PV., XEN_PVHVM, XEN_PVH. Right now they'd only be able to select XEN_PV and/or XEN_PVH, XEN_PVHVM is implicit.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I think making XEN_PVHVM user selectable is okay.

OK I'll enable this then.

Please don't. We had bugs in the past because distros did not select it (they made it an module) and the PV drivers were not loaded.

Quoted 7 lines

Oy vey.

Quoted 2 lines

There should be an history in the git tree behind the desire to make it non selectable.

OK how about we enable the user selection only under CONFIG_EXPERT, otherwise make it hidden.

The CONFIG_EXPERT is gone from the kernel..

Quoted 2 lines

Luis

#35 lore raw
Quoted 34 lines · Konrad Rzeszutek Wilk
Quoted 33 lines · Luis R. Rodriguez
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 21 lines · Luis R. Rodriguez
Quoted 20 lines · Juergen Gross
Quoted 17 lines · Luis R. Rodriguez
Quoted 4 lines · Luis R. Rodriguez

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time

And this also raises the question of whether or not we should make XEN_PVHVM a user selectable option, right now it is a def_bool and is therefore not human selectable. You can implicitly disable it by disabling PCI for example though. If we want that to be exposed to the user we can then enable some description of what that means, and the user will then be able to read / select / enable XEN_PV., XEN_PVHVM, XEN_PVH. Right now they'd only be able to select XEN_PV and/or XEN_PVH, XEN_PVHVM is implicit.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I think making XEN_PVHVM user selectable is okay.

OK I'll enable this then.

Please don't. We had bugs in the past because distros did not select it (they made it an module) and the PV drivers were not loaded.

Oy vey.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

There should be an history in the git tree behind the desire to make it non selectable.

OK how about we enable the user selection only under CONFIG_EXPERT, otherwise make it hidden.

The CONFIG_EXPERT is gone from the kernel..

I see it as of next-20150218, is there a proposal to remove it?

Luis

#36 lore raw
Quoted 39 lines · Luis R. Rodriguez
Quoted 37 lines · Konrad Rzeszutek Wilk
Quoted 36 lines · Luis R. Rodriguez
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 21 lines · Luis R. Rodriguez
Quoted 20 lines · Juergen Gross
Quoted 17 lines · Luis R. Rodriguez
Quoted 4 lines · Luis R. Rodriguez

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time

And this also raises the question of whether or not we should make XEN_PVHVM a user selectable option, right now it is a def_bool and is therefore not human selectable. You can implicitly disable it by disabling PCI for example though. If we want that to be exposed to the user we can then enable some description of what that means, and the user will then be able to read / select / enable XEN_PV., XEN_PVHVM, XEN_PVH. Right now they'd only be able to select XEN_PV and/or XEN_PVH, XEN_PVHVM is implicit.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I think making XEN_PVHVM user selectable is okay.

OK I'll enable this then.

Please don't. We had bugs in the past because distros did not select it (they made it an module) and the PV drivers were not loaded.

Oy vey.

Quoted 2 lines

There should be an history in the git tree behind the desire to make it non selectable.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

OK how about we enable the user selection only under CONFIG_EXPERT, otherwise make it hidden.

The CONFIG_EXPERT is gone from the kernel..

I see it as of next-20150218, is there a proposal to remove it?

I am misremembering what was . AH, http://lwn.net/Articles/421304/
CONFIG_EMBEDDED!

Sorry about the noise.
Hm, maybe I m

Quoted 2 lines

Luis

#37 lore raw
Quoted 43 lines · Konrad Rzeszutek Wilk
Quoted 42 lines · Luis R. Rodriguez
Quoted 40 lines · Konrad Rzeszutek Wilk
Quoted 38 lines · Luis R. Rodriguez
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 21 lines · Luis R. Rodriguez
Quoted 20 lines · Juergen Gross
Quoted 17 lines · Luis R. Rodriguez
Quoted 4 lines · Luis R. Rodriguez

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time

And this also raises the question of whether or not we should make XEN_PVHVM a user selectable option, right now it is a def_bool and is therefore not human selectable. You can implicitly disable it by disabling PCI for example though. If we want that to be exposed to the user we can then enable some description of what that means, and the user will then be able to read / select / enable XEN_PV., XEN_PVHVM, XEN_PVH. Right now they'd only be able to select XEN_PV and/or XEN_PVH, XEN_PVHVM is implicit.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I think making XEN_PVHVM user selectable is okay.

OK I'll enable this then.

Please don't. We had bugs in the past because distros did not select it (they made it an module) and the PV drivers were not loaded.

Oy vey.

Quoted 2 lines

There should be an history in the git tree behind the desire to make it non selectable.

OK how about we enable the user selection only under CONFIG_EXPERT, otherwise make it hidden.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

The CONFIG_EXPERT is gone from the kernel..

I see it as of next-20150218, is there a proposal to remove it?

I am misremembering what was . AH, http://lwn.net/Articles/421304/
CONFIG_EMBEDDED!

Sorry about the noise.

So whatyda think? If that is not enough to prevent *stupid* from doing something dumb by adding own CONFIG_XEN_BUILD_EXPERT which will depend on EXPERT but default to n. That will prevent folks that typically enable EXPERT from going on venturing to disable what is visible unless they *really* want it.

Luis

#38 lore raw
Quoted 52 lines · Luis R. Rodriguez
Quoted 50 lines · Konrad Rzeszutek Wilk
Quoted 39 lines · Luis R. Rodriguez
Quoted 37 lines · Konrad Rzeszutek Wilk
Quoted 36 lines · Luis R. Rodriguez
Quoted 22 lines · Konrad Rzeszutek Wilk
Quoted 21 lines · Luis R. Rodriguez
Quoted 20 lines · Juergen Gross
Quoted 17 lines · Luis R. Rodriguez
Quoted 4 lines · Luis R. Rodriguez

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time

And this also raises the question of whether or not we should make XEN_PVHVM a user selectable option, right now it is a def_bool and is therefore not human selectable. You can implicitly disable it by disabling PCI for example though. If we want that to be exposed to the user we can then enable some description of what that means, and the user will then be able to read / select / enable XEN_PV., XEN_PVHVM, XEN_PVH. Right now they'd only be able to select XEN_PV and/or XEN_PVH, XEN_PVHVM is implicit.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I think making XEN_PVHVM user selectable is okay.

OK I'll enable this then.

Please don't. We had bugs in the past because distros did not select it (they made it an module) and the PV drivers were not loaded.

Oy vey.

Quoted 2 lines

There should be an history in the git tree behind the desire to make it non selectable.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

OK how about we enable the user selection only under CONFIG_EXPERT, otherwise make it hidden.

The CONFIG_EXPERT is gone from the kernel..

I see it as of next-20150218, is there a proposal to remove it?

I am misremembering what was . AH, http://lwn.net/Articles/421304/
CONFIG_EMBEDDED!

Quoted 7 lines
Quoted 1 line

Sorry about the noise.

So whatyda think? If that is not enough to prevent *stupid* from doing something dumb by adding own CONFIG_XEN_BUILD_EXPERT which will depend on EXPERT but default to n. That will prevent folks that typically enable EXPERT from going on venturing to disable what is visible unless they *really* want it.

I can't think of a reason somebody would want this disabled - they already have enabled CONFIG_HYPERVISOR so obviously they want PV drivers.

And if one really really wants the PV drivers disabled there is an boot line command to disable it all.

Quoted 2 lines

Luis

maintainer
#39 lore raw
In reply to Luis R. Rodriguez
Quoted 33 lines · Luis R. Rodriguez
Quoted 14 lines · David Vrabel
Quoted 9 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Here's the first shot at the Kconfig changes for Xen as discussed on the mailing list a little while ago [0]. Let me know if you spot any issues or if you'd like things split differently. I tried to make things as atomic as possible, but not being too rediculous on the atomicity of the changes, for instance the HVC changes were reasonable to just fold into the other change it touched.

Quoted 3 lines

Haven't gone to war with testing the Kconfig changes yet given this is just the first RFC. If things look good please look for major issues and let me know.#

Quoted 6 lines

Can you spin a v2 and make a git branch available, please? I would like people to be able to easily try out the changes rather than looking at the diffs.

If I haven't comment on a specific patch it's because I thought it looked ok.

Sure thing, before that I should address now what I have found as issues with the Kconfig changes and what we need. What I see so far:

1) due to a recursive dependency it seems we should consider having XEN_DOM0 select SWIOTLB_XEN instead of depend on it? That fixes it:

arch/x86/xen/Kconfig +0 -0
index d930574..c25e12b 100644

arch/x86/xen/Kconfig config XEN · line 20

Quoted 8 lines
arch/x86/xen/Kconfig +2 -1
@@ -14,7 +14,8 @@ config XEN
  config XEN_DOM0
         def_bool y
         select XEN_BACKEND
-       depends on XEN && PCI_XEN && SWIOTLB_XEN
+       select SWIOTLB_XEN
+       depends on XEN && PCI_XEN
         depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
         depends on XEN_PV || XEN_PVH

I'm fine with this.

Quoted 20 lines

2) due to a recursive-dependency it doesn't seem we should have XEN_FRONTEND select on CONFIG_XEN -- with that in place we end up with:

arch/x86/xen/Kconfig:5:error: recursive dependency detected! arch/x86/xen/Kconfig:5: symbol XEN is selected by XEN_FRONTEND drivers/xen/Kconfig:82: symbol XEN_FRONTEND depends on XEN

If we remove the select XEN from XEN_FRONTEND that fixes it. Not sure what is ideal here though.

XEN_FRONTEND does not depend on XEN but the select seems to imply it.

3) The simple memory setup build issue:

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time at arch/x86/xen/enlighten.c on xen_start_kernel() here:

Quoted 4 lines
         if (xen_feature(XENFEAT_auto_translated_physmap))
                 x86_init.resources.memory_setup = xen_auto_xlated_memory_setup;
         else
                 x86_init.resources.memory_setup = xen_memory_setup;

If we have neither XEN_PV nor XEN_PVH set, why do we have to build enlighten.c? It will never be used. Same should apply to several other files in arch/x86/xen.

Juergen

#40 lore raw
Quoted 35 lines · Juergen Gross
Quoted 34 lines · Luis R. Rodriguez
Quoted 17 lines · David Vrabel
Quoted 10 lines · Luis R. Rodriguez

From: "Luis R. Rodriguez" <[email protected]>

Here's the first shot at the Kconfig changes for Xen as discussed on the mailing list a little while ago [0]. Let me know if you spot any issues or if you'd like things split differently. I tried to make things as atomic as possible, but not being too rediculous on the atomicity of the changes, for instance the HVC changes were reasonable to just fold into the other change it touched.

Quoted 3 lines

Haven't gone to war with testing the Kconfig changes yet given this is just the first RFC. If things look good please look for major issues and let me know.#

Quoted 6 lines

Can you spin a v2 and make a git branch available, please? I would like people to be able to easily try out the changes rather than looking at the diffs.

If I haven't comment on a specific patch it's because I thought it looked ok.

Sure thing, before that I should address now what I have found as issues with the Kconfig changes and what we need. What I see so far:

1) due to a recursive dependency it seems we should consider having XEN_DOM0 select SWIOTLB_XEN instead of depend on it? That fixes it:

Quoted 16 lines

arch/x86/xen/Kconfig config XEN · line 20

Quoted 13 lines
arch/x86/xen/Kconfig +2 -1
index d930574..c25e12b 100644
@@ -14,7 +14,8 @@ config XEN
  config XEN_DOM0
         def_bool y
         select XEN_BACKEND
-       depends on XEN && PCI_XEN && SWIOTLB_XEN
+       select SWIOTLB_XEN
+       depends on XEN && PCI_XEN
         depends on X86_LOCAL_APIC && X86_IO_APIC && ACPI && PCI
         depends on XEN_PV || XEN_PVH

I'm fine with this.

OK I'll roll in this change.

Quoted 4 lines
Quoted 4 lines

2) due to a recursive-dependency it doesn't seem we should have XEN_FRONTEND select on CONFIG_XEN -- with that in place we end up with:

Quoted 8 lines
Quoted 8 lines

arch/x86/xen/Kconfig:5:error: recursive dependency detected! arch/x86/xen/Kconfig:5: symbol XEN is selected by XEN_FRONTEND drivers/xen/Kconfig:82: symbol XEN_FRONTEND depends on XEN

If we remove the select XEN from XEN_FRONTEND that fixes it. Not sure what is ideal here though.

XEN_FRONTEND does not depend on XEN but the select seems to imply it.

This was caused for a few reasons for this, firstly because HVC_XEN depends on XEN and also the entire file drivers/xen/Kconfig is wrapped with "if XEN" so obviously dropping in XEN_FRONTEND there will make it depend on XEN. This means we need to expose XEN_FRONTEND outside of the "if XEN", but likewise we also need to do the same for XEN_BUS_FRONTEND.

So although we can test building front end drivers without CONFIG_XEN right now I'd prefer to not do this as it doesn't work in the first place right now and just doing these changes:

* Make HVC_XEN select XEN
* Take out both XEN_XENBUS_FRONTEND and XEN_FRONTEND from "if XEN"
roll on the Kconfig file. We upkeep the "select XEN" on XEN_FRONTEND, but users will still be able to see XEN_FRONTEND even if XEN hasn't been selected at least.

I'll test building all front end drivers with this but so far am running into issues with just building XEN_FRONTEND so it seems there are other things that we need to address. The issues seem to be related to the item 3) below.

Quoted 14 lines
Quoted 7 lines

3) The simple memory setup build issue:

As it is per our agreed upon changes we can in theory enable a XEN_PVHVM system without XEN_PV or XEN_PVH. If this is indeed desirable this poses an issue at build time at arch/x86/xen/enlighten.c on xen_start_kernel() here:

Quoted 5 lines

if (xen_feature(XENFEAT_auto_translated_physmap))
x86_init.resources.memory_setup =

xen_auto_xlated_memory_setup;
         else
                 x86_init.resources.memory_setup = xen_memory_setup;
Quoted 3 lines

If we have neither XEN_PV nor XEN_PVH set, why do we have to build enlighten.c? It will never be used. Same should apply to several other files in arch/x86/xen.

OK I'll keep xen_memory_setup() and its requirements then only if XEN_PV is enabled but not XEN_PVH. As for the rest of enlighten.c and friends -- this is just collateral. What files should we just need for just XEN_PVHVM when XEN_PV and XEN_PVH are both disabled?

Luis

#41 lore raw
Quoted 4 lines · Luis R. Rodriguez

OK I'll keep xen_memory_setup() and its requirements then only if XEN_PV is enabled but not XEN_PVH. As for the rest of enlighten.c and friends -- this is just collateral. What files should we just need for just XEN_PVHVM when XEN_PV and XEN_PVH are both disabled?

I see we need x86_hyper_xen_hvm, I also see init_hvm_pv_info() uses hypercall_page so that needs at least the hypercall page set up. That means arch/x86/xen/xen-head.S needs some love in terms of enablement when XEN_PVHVM is enabled but not XEN_PV or XEN_PVH, also enlighten.c, time.c needs the XEN_PVHVM stuff split out and some common stuff set out for both. That's what I'm up to at least.

Let me know if this seems right.

Luis

#42 lore raw
In reply to Juergen Gross
Quoted 4 lines · Juergen Gross

If we have neither XEN_PV nor XEN_PVH set, why do we have to build enlighten.c? It will never be used. Same should apply to several other files in arch/x86/xen.

Can we limit this series to only Kconfig changes? I don't really like scope-creep in patch series.

David

maintainer
#43 lore raw
Quoted 8 lines · David Vrabel
Quoted 4 lines · Juergen Gross

If we have neither XEN_PV nor XEN_PVH set, why do we have to build enlighten.c? It will never be used. Same should apply to several other files in arch/x86/xen.

Can we limit this series to only Kconfig changes? I don't really like scope-creep in patch series.

Are you sure this is possible? XEN will be configured in more cases as
today: this is the result of being able to build pv-drivers for hvm domains.

BTW: it was you who wanted XEN_PVHVM to be implying XEN.

So today the complete directory arch/x86/xen isn't built for non-pv kernels. Do you really want to change this? I don't think this is acceptable.

Juergen

#44 lore raw
Quoted 10 lines · Juergen Gross
Quoted 9 lines · David Vrabel
Quoted 5 lines · Juergen Gross

If we have neither XEN_PV nor XEN_PVH set, why do we have to build enlighten.c? It will never be used. Same should apply to several other files in arch/x86/xen.

Quoted 5 lines
Quoted 2 lines

Can we limit this series to only Kconfig changes? I don't really like scope-creep in patch series.

Are you sure this is possible?

I do not think so. We can only do the smaller cleanups, the frontend stuff and the backend stuff however will remain constrained due to existing relationships being assumed under the big CONFIG_XEN. More details on this below.

Quoted 9 lines

XEN will be configured in more cases as
today: this is the result of being able to build pv-drivers for hvm domains.

BTW: it was you who wanted XEN_PVHVM to be implying XEN.

So today the complete directory arch/x86/xen isn't built for non-pv kernels. Do you really want to change this? I don't think this is acceptable.

A simple issue example to think about:

The arch/x86/kernel/head_[64|32].S file includes arch/x86/xen/xen-head.S. Now this file is #ifdef's over CONFIG_XEN. As per our agreed upon changes the frontend drivers depend on CONFIG_XEN but without CONFIG_XEN_PV and CONFIG_XEN_PVH this won't build correctly after the other changes we've discussed.

What I can do, if folks like, is to pursue the split only as expected RFCs only as evaluation just to get a better idea of what changes are really required for what we discussed, I am not sure the required code changes had been scoped out before.

Luis

#45 lore raw
In reply to Juergen Gross
Quoted 7 lines · Juergen Gross
Quoted 6 lines · David Vrabel
Quoted 4 lines · Juergen Gross

If we have neither XEN_PV nor XEN_PVH set, why do we have to build enlighten.c? It will never be used. Same should apply to several other files in arch/x86/xen.

Quoted 6 lines
Quoted 2 lines

Can we limit this series to only Kconfig changes? I don't really like scope-creep in patch series.

Are you sure this is possible? XEN will be configured in more cases as
today: this is the result of being able to build pv-drivers for hvm domains.

I mean there should be the minimum set of changes need for the Kconfig refactor to work, but any additional improvements to the build etc. should be via a different series.

David

#46 lore raw
Quoted 11 lines · David Vrabel
Quoted 10 lines · Juergen Gross
Quoted 8 lines · David Vrabel
Quoted 4 lines · Juergen Gross

If we have neither XEN_PV nor XEN_PVH set, why do we have to build enlighten.c? It will never be used. Same should apply to several other files in arch/x86/xen.

Can we limit this series to only Kconfig changes? I don't really like scope-creep in patch series.

Quoted 7 lines
Quoted 3 lines

Are you sure this is possible? XEN will be configured in more cases as
today: this is the result of being able to build pv-drivers for hvm domains.

I mean there should be the minimum set of changes need for the Kconfig refactor to work, but any additional improvements to the build etc. should be via a different series.

OK I can break down things into two series, one which deals with only Kconfig stuff first, and if that goes well a second one which starts to address some required code changes. Would that be a good step forward? Feedback on the other threads would also be useful.

Luis