Skip to contentSkip to conversation

x86: Convert shadow-paging to Kconfig

PATCH In review Andrew Cooper 5 participants 15 messages Jan 18, 2016 – Jan 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Convert shadow-paging to Kconfig

---
CC: Jan Beulich <[email protected]>
CC: Doug Goldstein <[email protected]>

---
 xen/arch/x86/Kconfig            | 14 ++++++++++++++
 xen/arch/x86/Rules.mk           |  4 ----
 xen/arch/x86/mm/shadow/Makefile |  2 +-
 3 files changed, 15 insertions(+), 5 deletions(-)
xen/arch/x86/Kconfig +14 -0
index 4781b34..9869630 100644
@@ -27,6 +27,20 @@ menu "Architecture Features"
 
 source "arch/Kconfig"
 
+config SHADOW_PAGING
+        bool "Shadow Paging"
+        default y
+        ---help---
+          Shadow paging is a software alternative to hardware paging support
+          (Intel EPT, AMD NPT) for use with HVM guests.
+
+          It is required to run HVM guests for first-generation hardware
+          virtualisation (Intel VT-x, AMD SVM) which did not include hardware
+          paging support.  Under a small number of specific workloads, shadow
+          paging may also be deliberately used as a performance improvement.
+
+          If unsure, say Y.
+
 config BIGMEM
 	bool "big memory support"
 	default n
xen/arch/x86/Rules.mk +0 -4
index a108d24..a1cdae0 100644
@@ -22,13 +22,9 @@ $(call as-insn-check,CFLAGS,CC,".equ \"x\"$$(comma)1", \
                      -U__OBJECT_LABEL__ -DHAVE_GAS_QUOTED_SYM \
                      '-D__OBJECT_LABEL__=$(subst $(BASEDIR)/,,$(CURDIR))/$$@')
 
-shadow-paging ?= y
-
 CFLAGS += -mno-red-zone -mno-sse -fpic
 CFLAGS += -fno-asynchronous-unwind-tables
 # -fvisibility=hidden reduces -fpic cost, if it's available
 ifneq ($(call cc-option,$(CC),-fvisibility=hidden,n),n)
 CFLAGS += -DGCC_HAS_VISIBILITY_ATTRIBUTE
 endif
-
-CFLAGS-$(shadow-paging) += -DCONFIG_SHADOW_PAGING
xen/arch/x86/mm/shadow/Makefile +1 -1
index a07bc0c..df194ad 100644
@@ -1,4 +1,4 @@
-ifeq ($(shadow-paging),y)
+ifdef CONFIG_SHADOW_PAGING
 obj-y += common.o guest_2.o guest_3.o guest_4.o
 else
 obj-y += none.o
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Andrew Cooper
Quoted 63 lines

---
CC: Jan Beulich <[email protected]>
CC: Doug Goldstein <[email protected]>

---
 xen/arch/x86/Kconfig            | 14 ++++++++++++++
 xen/arch/x86/Rules.mk           |  4 ----
 xen/arch/x86/mm/shadow/Makefile |  2 +-
 3 files changed, 15 insertions(+), 5 deletions(-)
xen/arch/x86/Kconfig +14 -0
index 4781b34..9869630 100644
@@ -27,6 +27,20 @@ menu "Architecture Features"
 
 source "arch/Kconfig"
 
+config SHADOW_PAGING
+        bool "Shadow Paging"
+        default y
+        ---help---
+          Shadow paging is a software alternative to hardware paging support
+          (Intel EPT, AMD NPT) for use with HVM guests.
+
+          It is required to run HVM guests for first-generation hardware
+          virtualisation (Intel VT-x, AMD SVM) which did not include hardware
+          paging support.  Under a small number of specific workloads, shadow
+          paging may also be deliberately used as a performance improvement.
+
+          If unsure, say Y.
+
 config BIGMEM
 	bool "big memory support"
 	default n
xen/arch/x86/Rules.mk +0 -4
index a108d24..a1cdae0 100644
@@ -22,13 +22,9 @@ $(call as-insn-check,CFLAGS,CC,".equ \"x\"$$(comma)1", \
                      -U__OBJECT_LABEL__ -DHAVE_GAS_QUOTED_SYM \
                      '-D__OBJECT_LABEL__=$(subst $(BASEDIR)/,,$(CURDIR))/$$@')
 
-shadow-paging ?= y
-
 CFLAGS += -mno-red-zone -mno-sse -fpic
 CFLAGS += -fno-asynchronous-unwind-tables
 # -fvisibility=hidden reduces -fpic cost, if it's available
 ifneq ($(call cc-option,$(CC),-fvisibility=hidden,n),n)
 CFLAGS += -DGCC_HAS_VISIBILITY_ATTRIBUTE
 endif
-
-CFLAGS-$(shadow-paging) += -DCONFIG_SHADOW_PAGING
xen/arch/x86/mm/shadow/Makefile +1 -1
index a07bc0c..df194ad 100644
@@ -1,4 +1,4 @@
-ifeq ($(shadow-paging),y)
+ifdef CONFIG_SHADOW_PAGING
 obj-y += common.o guest_2.o guest_3.o guest_4.o
 else
 obj-y += none.o
Signature · 1 line
Doug Goldstein

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
In reply to Andrew Cooper
Quoted 1 line · Andrew Cooper

Does this have any impact on migration of either PV or HVM guests? What about nested virt?

Are things which are defined in xen/arch/*/Rules.mk in this way overrideable from the old top-level .config or does one need to dive deeper to modify them? If it's not configurable from top-level .config today then I think it either needs a "depends EXPERT" or for the changelog to make a convincing argument why this should be made user selectable.

Lastly, Tim is maintainer of the shadow code and should have been CC-d, also George as maintainer of the mm stuff might have an interest. Both CC-s added.

Quoted 66 lines

---
CC: Jan Beulich <[email protected]>
CC: Doug Goldstein <[email protected]>
---
 xen/arch/x86/Kconfig            | 14 ++++++++++++++ xen/arch/x86/Rules.mk           |  4 ---- xen/arch/x86/mm/shadow/Makefile |  2 +-

 3 files changed, 15 insertions(+), 5 deletions(-)
xen/arch/x86/Kconfig +0 -0
index 4781b34..9869630 100644
@@ -27,6 +27,20 @@ menu "Architecture Features"


 source "arch/Kconfig"

+config SHADOW_PAGING
+        bool "Shadow Paging"
+        default y
+        ---help---
+          Shadow paging is a software alternative to hardware paging support
+          (Intel EPT, AMD NPT) for use with HVM guests.
+
+          It is required to run HVM guests for first-generation hardware +          virtualisation (Intel VT-x, AMD SVM) which did not include hardware
+          paging support.  Under a small number of specific workloads, shadow
+          paging may also be deliberately used as a performance improvement.

xen/arch/x86/Kconfig +3 -0
+
+          If unsure, say Y.
+

 config BIGMEM
  bool "big memory support"
  default n

xen/arch/x86/Rules.mk +0 -0
index a108d24..a1cdae0 100644
@@ -22,13 +22,9 @@ $(call as-insn-check,CFLAGS,CC,".equ \"x\"$$(comma)1",
 \
                       -U__OBJECT_LABEL__ -DHAVE_GAS_QUOTED_SYM \

                      '-D__OBJECT_LABEL__=$(subst
$(BASEDIR)/,,$(CURDIR))/$$@')

xen/arch/x86/Rules.mk +0 -2
-shadow-paging ?= y
-

 CFLAGS += -mno-red-zone -mno-sse -fpic
 CFLAGS += -fno-asynchronous-unwind-tables
 # -fvisibility=hidden reduces -fpic cost, if it's available ifneq ($(call cc-option,$(CC),-fvisibility=hidden,n),n) CFLAGS += -DGCC_HAS_VISIBILITY_ATTRIBUTE
 endif

xen/arch/x86/Rules.mk +0 -2
-
-CFLAGS-$(shadow-paging) += -DCONFIG_SHADOW_PAGING
xen/arch/x86/mm/shadow/Makefile +1 -1
index a07bc0c..df194ad 100644
@@ -1,4 +1,4 @@
-ifeq ($(shadow-paging),y)
+ifdef CONFIG_SHADOW_PAGING
Quoted 3 lines

 obj-y += common.o guest_2.o guest_3.o guest_4.o
 else
 obj-y += none.o

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 19.01.16 at 10:46, <[email protected]> wrote:
Quoted 1 line · Andrew Cooper

Does this have any impact on migration of either PV or HVM guests? What about nested virt?

At least PV guests won't be migratable anymore when there's no shadow mode.

Quoted 3 lines

Are things which are defined in xen/arch/*/Rules.mk in this way overrideable from the old top-level .config or does one need to dive deeper to modify them?

Overriding these in the old top-level .config is how I have been regularly build testing this and the bigmem features since their introduction.

Jan

#4 lore raw
Quoted 7 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 19.01.16 at 10:46, <[email protected]> wrote:
Quoted 1 line · Andrew Cooper

Does this have any impact on migration of either PV or HVM guests? What about nested virt?

At least PV guests won't be migratable anymore when there's no shadow mode.

What? Shadow mode (or lack thereof) has no impact whatsoever on migration.

Quoted 7 lines
Quoted 4 lines

Are things which are defined in xen/arch/*/Rules.mk in this way overrideable from the old top-level .config or does one need to dive deeper to modify them?

Overriding these in the old top-level .config is how I have been regularly build testing this and the bigmem features since their introduction.

This patch matches the bigmem patch in its behaviour.

~Andrew

#5 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 19.01.16 at 14:30, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 19.01.16 at 10:46, <[email protected]> wrote:
Quoted 1 line · Andrew Cooper

Does this have any impact on migration of either PV or HVM guests? What about nested virt?

At least PV guests won't be migratable anymore when there's no shadow mode.

What? Shadow mode (or lack thereof) has no impact whatsoever on migration.

So how would log-dirty mode work for a PV guest without shadow code?

Jan

#6 lore raw
Quoted 4 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 19.01.16 at 14:30, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 19.01.16 at 10:46, <[email protected]> wrote:

On Mon, 2016-01-18 at 18:40 +0000, Andrew Cooper wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Does this have any impact on migration of either PV or HVM guests? What about nested virt?

At least PV guests won't be migratable anymore when there's no shadow mode.

What? Shadow mode (or lack thereof) has no impact whatsoever on migration.

So how would log-dirty mode work for a PV guest without shadow code?

Oops yes. I am confusing the fact that logdirty and vram tracking are independent, rather than logdiry and shadow. (we have far too many modes)

I should update the text to talk about migration.

~Andrew

#7 lore raw
In reply to Ian Campbell
Quoted 3 lines · Ian Campbell
Quoted 1 line · Andrew Cooper

Does this have any impact on migration of either PV or HVM guests?

Not in the slightest.

Quoted 1 line

What about nested virt?

Nested virt is completely broken with respect to migration.

At no point has anyone considered wiring architectural nesting state into the migration stream. Currently, the VM resumes on the far side with all of its nested setup missing.

Quoted 4 lines

Are things which are defined in xen/arch/*/Rules.mk in this way overrideable from the old top-level .config or does one need to dive deeper to modify them?

Absolutely everything anywhere in the build system is/was configurable from the top .config

Quoted 3 lines

If it's not configurable from top-level .config today then
I think it either needs a "depends EXPERT" or for the changelog to make a convincing argument why this should be made user selectable.

This patch matches the bigmem patch which has already been accepted (c/s 165f36d). These two options should match, whatever the outcome of this discussion is.

Quoted 3 lines

Lastly, Tim is maintainer of the shadow code and should have been CC-d, also George as maintainer of the mm stuff might have an interest. Both CC-s added.

Oops yes, although this is an entirely mechanical alteration to an option which already existed.

~Andrew

#8 lore raw
Quoted 10 lines · Andrew Cooper
Quoted 3 lines · Ian Campbell
Quoted 1 line · Andrew Cooper

Does this have any impact on migration of either PV or HVM guests?

Not in the slightest.

Quoted 1 line

What about nested virt?

Nested virt is completely broken with respect to migration.

Sorry, I meant impact (generally) on nested, not WRT migration. AIUI shadow is required for either L1 or L2 (not sure which).

Quoted 7 lines
Quoted 4 lines

Are things which are defined in xen/arch/*/Rules.mk in this way overrideable from the old top-level .config or does one need to dive deeper
to modify them?

Absolutely everything anywhere in the build system is/was configurable from the top .config

OK, good, so no change here, that's fine then.

Quoted 9 lines
Quoted 4 lines

Lastly, Tim is maintainer of the shadow code and should have been CC-d, also George as maintainer of the mm stuff might have an interest. Both CC-s
added.

Oops yes, although this is an entirely mechanical alteration to an option which already existed.

~Andrew

#9 lore raw
Quoted 5 lines · Ian Campbell
Quoted 3 lines
Quoted 2 lines

What about nested virt?

Nested virt is completely broken with respect to migration.

Sorry, I meant impact (generally) on nested, not WRT migration. AIUI shadow is required for either L1 or L2 (not sure which).

There is no requirement one way or another. It function in any combination you care to pick.

However, if you don't have HAP all the way down, Xen falls over very quickly with spinlock contention if a guest actually starts doing some real work.

~Andrew

#10 lore raw
In reply to Ian Campbell
Quoted 5 lines · Ian Campbell
Quoted 1 line · Andrew Cooper

Does this have any impact on migration of either PV or HVM guests? What about nested virt?

Without shadow paging you can't do live migration of PV guests. That should go in the kconfig description.

AFAICT nested virt depends on HAP rather than shadow.

Quoted 5 lines

Are things which are defined in xen/arch/*/Rules.mk in this way overrideable from the old top-level .config or does one need to dive deeper to modify them? If it's not configurable from top-level .config today then I think it either needs a "depends EXPERT" or for the changelog to make a convincing argument why this should be made user selectable.

I'm all in favour of making this selectable -- people who don't need the feature can avoid 7k LOC that way. :) If it's not going to be 'EXPERT' maybe we could have some console logging, either in the none.c stubs or just at boot time, to make it more obvious why the user's live migration/non-HAP guest doesn't work.

Cheers,

Tim.

#11 lore raw
Quoted 9 lines · Tim Deegan
Quoted 4 lines · Ian Campbell
Quoted 1 line · Andrew Cooper

Does this have any impact on migration of either PV or HVM guests? What about nested virt?

Without shadow paging you can't do live migration of PV guests. That should go in the kconfig description.

AFAICT nested virt depends on HAP rather than shadow.

Nothing currently enforces this. Xen dies particularly quickly with spinlock contention if a shadow HVM guest tries to use nested-virt.

(Just another item on the long list of tasks requires before nested-virt becomes anything other than experimental.)

~Andrew

#12 lore raw
In reply to Andrew Cooper

xen/arch/x86/mm/shadow/Makefile line 4

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 18.01.16 at 19:40, <[email protected]> wrote:
xen/arch/x86/mm/shadow/Makefile +1 -1
@@ -1,4 +1,4 @@
-ifeq ($(shadow-paging),y)
+ifdef CONFIG_SHADOW_PAGING
 obj-y += common.o guest_2.o guest_3.o guest_4.o
 else
 obj-y += none.o

Why didn't you retain the ifeq? The way it's now, accidental definition of the macro elsewhere would alter behavior. In fact I think the better thing here would be to change this to purely list model:

obj-y := none.o
obj-$(CONFIG_SHADOW_PAGING) := common.o guest_2.o guest_3.o guest_4.o

Not sure why I didn't do that right when making this configurable...

Jan

#13 lore raw
Quoted 14 lines · Jan Beulich

xen/arch/x86/mm/shadow/Makefile line 4

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 18.01.16 at 19:40, <[email protected]> wrote:
xen/arch/x86/mm/shadow/Makefile +1 -1
@@ -1,4 +1,4 @@
-ifeq ($(shadow-paging),y)
+ifdef CONFIG_SHADOW_PAGING
 obj-y += common.o guest_2.o guest_3.o guest_4.o
 else
 obj-y += none.o

Why didn't you retain the ifeq? The way it's now, accidental definition of the macro elsewhere would alter behavior. In fact I think the better thing here would be to change this to purely list model:

Quoted 4 lines

obj-y := none.o
obj-$(CONFIG_SHADOW_PAGING) := common.o guest_2.o guest_3.o guest_4.o

Not sure why I didn't do that right when making this configurable...

none.o must not be linked if !CONFIG_SHADOW_PAGING.

It was cleanest to retain the existing structure.

~Andrew

#14 lore raw
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 19.01.16 at 14:33, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich

xen/arch/x86/mm/shadow/Makefile line 4

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 18.01.16 at 19:40, <[email protected]> wrote:
xen/arch/x86/mm/shadow/Makefile +1 -1
@@ -1,4 +1,4 @@
-ifeq ($(shadow-paging),y)
+ifdef CONFIG_SHADOW_PAGING
 obj-y += common.o guest_2.o guest_3.o guest_4.o
 else
 obj-y += none.o

Why didn't you retain the ifeq? The way it's now, accidental definition of the macro elsewhere would alter behavior. In fact I think the better thing here would be to change this to purely list model:

Quoted 6 lines
Quoted 4 lines

obj-y := none.o
obj-$(CONFIG_SHADOW_PAGING) := common.o guest_2.o guest_3.o guest_4.o

Not sure why I didn't do that right when making this configurable...

none.o must not be linked if !CONFIG_SHADOW_PAGING.

And it wouldn't be, due to using ":=" (instead of "+=").

Jan