Skip to contentSkip to conversation

x86/xen: untangle PV and PVHVM guest support code

PATCH Superseded Vitaly Kuznetsov 2 participants 16 messages Feb 24, 2017 – Mar 1, 2017

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover x86/xen: untangle PV and PVHVM guest support code

Hi,

it's been a while since my 'RFC' submission in November:
https://lists.xen.org/archives/html/xen-devel/2016-11/msg01044.html

I was advised to wait till PVHv2 stuff lands upstream and as this has already happened I'm sending the first non-RFC version.

Changes since RFC:
- Rebase
- Use enlighten.c, enlighten_pv.c, enlighten_hvm.c, enlighten_pvh.c (and similar for other files I split) [David Vrabel]
- Split suspend.c too to get rid of #ifdefs in C code.
- I left XEN_DOM0 intact (rename to XEN_PV_DOM0 was suggested by [Boris Ostrovsky]) as it occured to me that we may want to have all three when XEN_PVH_DOM0 comes into play. XEN_DOM0 will be used for common code than so no need to change #ifdefs twice.

Patches are known to produce checkpatch.pl WARNINGS and a couple of ERRORs, I fixed a few (mostly in _hvm* code I split) and I refrained from fixing the rest to make it easier to review. I think that we may leave PV code as it is as sooner or later it will go away.

Original description:

I have a long-standing idea to separate PV and PVHVM code in kernel and introduce Kconfig options to make it possible to enable the required parts only breaking the current 'all or nothing' approach.

Motivation:
- Xen related x86 code in kernel is rather big and it is unclear which parts of it are required for PV, for HVM or for both. With PVH coming into picture is becomes even more tangled. It makes it hard to understand/audit the code.

- In some case we may want to avoid bloating kernel by supporting Xen guests we don't need. In particular, 90% of the code in arch/x86/xen/ is required to support PV guests and one may require PVHVM support only.

- PV guests are supposed to go away one day and such code separation would help us to get ready.

This series adds XEN_PV Kconfig option and makes it possible to build PV-only and PVHVM-only kernels. It also makes it possible to disable Dom0 support.

Patches are rather big but this is mostly just moving code around, no functional changes intended. I smoke tested it with PV-only and PVHVM-only builds, booted and did save/restore test. I also tried the newly introduced PVHv2 guest, it even worked!

Vitaly Kuznetsov (5):
x86/xen: start untangling PV and PVHVM guest support code x86/xen: split smp.c for PV and PVHVM guests x86/xen: put setup.c, mmu.c and p2m.c under CONFIG_XEN_PV x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV x86/xen: split suspend.c for PV and PVHVM guests

 arch/x86/include/asm/hypervisor.h |    3 +-
 arch/x86/include/asm/xen/page.h   |   44 +-
 arch/x86/kernel/cpu/hypervisor.c  |    7 +-
 arch/x86/kernel/process_64.c      |    2 +-
 arch/x86/xen/Kconfig              |   33 +-
 arch/x86/xen/Makefile             |   18 +-
 arch/x86/xen/enlighten.c          | 1904 +------------------------
 arch/x86/xen/enlighten_hvm.c      |  210 +++
 arch/x86/xen/enlighten_pv.c       | 1561 +++++++++++++++++++++
 arch/x86/xen/enlighten_pvh.c      |  114 ++
 arch/x86/xen/mmu.c                | 2776 +------------------------------------
 arch/x86/xen/mmu_hvm.c            |   77 +
 arch/x86/xen/mmu_pv.c             | 2636 +++++++++++++++++++++++++++++++++++
 arch/x86/xen/pmu.h                |    5 +
 arch/x86/xen/smp.c                |  523 +------
 arch/x86/xen/smp.h                |   23 +
 arch/x86/xen/smp_hvm.c            |   58 +
 arch/x86/xen/smp_pv.c             |  499 +++++++
 arch/x86/xen/suspend.c            |   54 -
 arch/x86/xen/suspend_hvm.c        |   22 +
 arch/x86/xen/suspend_pv.c         |   44 +
 arch/x86/xen/xen-head.S           |    4 +
 arch/x86/xen/xen-ops.h            |   16 +
 drivers/xen/balloon.c             |   30 +-
 include/xen/xen-ops.h             |   19 +
 25 files changed, 5489 insertions(+), 5193 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_hvm.c
 create mode 100644 arch/x86/xen/enlighten_pv.c
 create mode 100644 arch/x86/xen/enlighten_pvh.c
 create mode 100644 arch/x86/xen/mmu_hvm.c
 create mode 100644 arch/x86/xen/mmu_pv.c
 create mode 100644 arch/x86/xen/smp_hvm.c
 create mode 100644 arch/x86/xen/smp_pv.c
 create mode 100644 arch/x86/xen/suspend_hvm.c
 create mode 100644 arch/x86/xen/suspend_pv.c
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/5 x86/xen: start untangling PV and PVHVM guest support code

Introduce CONFIG_XEN_PV config option and split enlighten.c into 4 files. Temporary add #ifdef CONFIG_XEN_PV to smp.c and mmu.c to not break the build and not make the patch even bigger.

xen_cpu_up_prepare*/xen_cpu_die hooks require separation to support future xen_smp_intr_init() split.

---
 arch/x86/include/asm/hypervisor.h |    3 +-
 arch/x86/kernel/cpu/hypervisor.c  |    7 +-
 arch/x86/kernel/process_64.c      |    2 +-
 arch/x86/xen/Kconfig              |   23 +-
 arch/x86/xen/Makefile             |   10 +-
 arch/x86/xen/enlighten.c          | 1904 +------------------------------------
 arch/x86/xen/enlighten_hvm.c      |  210 ++++
 arch/x86/xen/enlighten_pv.c       | 1552 ++++++++++++++++++++++++++++++
 arch/x86/xen/enlighten_pvh.c      |  114 +++
 arch/x86/xen/mmu.c                |    2 +
 arch/x86/xen/smp.c                |   40 +-
 arch/x86/xen/suspend.c            |    4 +
 arch/x86/xen/xen-head.S           |    4 +
 arch/x86/xen/xen-ops.h            |    2 +
 include/xen/xen-ops.h             |    6 +
 15 files changed, 1994 insertions(+), 1889 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_hvm.c
 create mode 100644 arch/x86/xen/enlighten_pv.c
 create mode 100644 arch/x86/xen/enlighten_pvh.c
arch/x86/include/asm/hypervisor.h +2 -1
index 67942b6..4faa12d 100644
@@ -53,7 +53,8 @@ extern const struct hypervisor_x86 *x86_hyper;
 /* Recognized hypervisors */
 extern const struct hypervisor_x86 x86_hyper_vmware;
 extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
-extern const struct hypervisor_x86 x86_hyper_xen;
+extern const struct hypervisor_x86 x86_hyper_xen_pv;
+extern const struct hypervisor_x86 x86_hyper_xen_pvhvm;
 extern const struct hypervisor_x86 x86_hyper_kvm;
 
 extern void init_hypervisor(struct cpuinfo_x86 *c);
arch/x86/kernel/cpu/hypervisor.c +5 -2
index 35691a6..dd68b03 100644
@@ -28,8 +28,11 @@
 
 static const __initconst struct hypervisor_x86 * const hypervisors[] =
 {
-#ifdef CONFIG_XEN
-	&x86_hyper_xen,
+#ifdef CONFIG_XEN_PV
+	&x86_hyper_xen_pv,
+#endif
+#ifdef CONFIG_XEN_PVHVM
+	&x86_hyper_xen_pvhvm,
 #endif
 	&x86_hyper_vmware,
 	&x86_hyper_ms_hyperv,
arch/x86/kernel/process_64.c +1 -1
index a61e141..5e8d129 100644
@@ -438,7 +438,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
 		     task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV))
 		__switch_to_xtra(prev_p, next_p, tss);
 
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PV
 	/*
 	 * On Xen PV, IOPL bits in pt_regs->flags have no effect, and
 	 * current_pt_regs()->flags may not match the current task's
arch/x86/xen/Kconfig +18 -5
index 76b6dbd..c387560 100644
@@ -6,7 +6,6 @@ config XEN
 	bool "Xen guest support"
 	depends on PARAVIRT
 	select PARAVIRT_CLOCK
-	select XEN_HAVE_PVMMU
 	select XEN_HAVE_VPMU
 	depends on X86_64 || (X86_32 && X86_PAE)
 	depends on X86_LOCAL_APIC && X86_TSC
@@ -15,18 +14,32 @@ config XEN
 	  kernel to boot in a paravirtualized environment under the
 	  Xen hypervisor.
 
+config XEN_PV
+	bool "Xen PV guest support"
+	default y
+	depends on XEN
+	help
+	  Support running as a Xen PV guest.
+
 config XEN_DOM0
-	def_bool y
-	depends on XEN && PCI_XEN && SWIOTLB_XEN
+	bool "Xen PV Dom0 support"
+	default y
+	depends on XEN_PV && PCI_XEN && SWIOTLB_XEN
 	depends on X86_IO_APIC && ACPI && PCI
+	select XEN_HAVE_PVMMU
+	help
+	  Support running as a Xen PV Dom0 guest.
 
 config XEN_PVHVM
-	def_bool y
+	bool "Xen PVHVM guest support"
+	default y
 	depends on XEN && PCI && X86_LOCAL_APIC
+	help
+	  Support running as a Xen PVHVM guest.
 
 config XEN_512GB
 	bool "Limit Xen pv-domain memory to 512GB"
-	depends on XEN && X86_64
+	depends on XEN_PV && X86_64
 	default y
 	help
 	  Limit paravirtualized user domains to 512GB of RAM.
arch/x86/xen/Makefile +7 -3
index cb0164a..750727b 100644
@@ -7,14 +7,18 @@ endif
 
 # Make sure early boot has no stackprotector
 nostackp := $(call cc-option, -fno-stack-protector)
-CFLAGS_enlighten.o		:= $(nostackp)
+CFLAGS_enlighten_pv.o		:= $(nostackp)
 CFLAGS_mmu.o			:= $(nostackp)
 
-obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
-			time.o xen-asm.o xen-asm_$(BITS).o \
+obj-y		:= enlighten.o setup.o multicalls.o \
+			mmu.o irq.o time.o xen-asm.o xen-asm_$(BITS).o \
 			grant-table.o suspend.o platform-pci-unplug.o \
 			p2m.o apic.o pmu.o
 
+obj-$(CONFIG_XEN_PV)		+= enlighten_pv.o
+obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o
+obj-$(CONFIG_XEN_PVH)		+= enlighten_pvh.o
+
 obj-$(CONFIG_EVENT_TRACING) += trace.o
 
 obj-$(CONFIG_SMP)		+= smp.o
arch/x86/xen/enlighten.c +43 -1861

1,970 lines not on this page · raw message

arch/x86/xen/enlighten_hvm.c new file +210 -0

210 lines not on this page · raw message

arch/x86/xen/enlighten_pv.c new file +1552 -0

726 lines not on this page · raw message

arch/x86/xen/enlighten_pvh.c new file +114 -0

114 lines not on this page · raw message

arch/x86/xen/mmu.c +2 -0
index f6740b5..881baac 100644

Lines of this file are not shown. View the raw message.

arch/x86/xen/smp.c +24 -16
index 0dee6f5..14fd7f3 100644

Lines of this file are not shown. View the raw message.

arch/x86/xen/suspend.c +4 -0
index 7f664c4..37f634f 100644

Lines of this file are not shown. View the raw message.

arch/x86/xen/xen-head.S +4 -0
index 37794e4..72a8e6a 100644

Lines of this file are not shown. View the raw message.

arch/x86/xen/xen-ops.h +2 -0
index f6a41c4..2b162f6 100644

Lines of this file are not shown. View the raw message.

include/xen/xen-ops.h +6 -0
index b5486e6..4e562de 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 7 lines
2.9.3


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

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH 1/5 x86/xen: start untangling PV and PVHVM guest support code

In reply to Vitaly Kuznetsov

Introduce CONFIG_XEN_PV config option and split enlighten.c into 4 files. Temporary add #ifdef CONFIG_XEN_PV to smp.c and mmu.c to not break the build and not make the patch even bigger.

xen_cpu_up_prepare*/xen_cpu_die hooks require separation to support future xen_smp_intr_init() split.

---
 arch/x86/include/asm/hypervisor.h |    3 +-
 arch/x86/kernel/cpu/hypervisor.c  |    7 +-
 arch/x86/kernel/process_64.c      |    2 +-
 arch/x86/xen/Kconfig              |   23 +-
 arch/x86/xen/Makefile             |   10 +-
 arch/x86/xen/enlighten.c          | 1904 +------------------------------------
 arch/x86/xen/enlighten_hvm.c      |  210 ++++
 arch/x86/xen/enlighten_pv.c       | 1552 ++++++++++++++++++++++++++++++
 arch/x86/xen/enlighten_pvh.c      |  114 +++
 arch/x86/xen/mmu.c                |    2 +
 arch/x86/xen/smp.c                |   40 +-
 arch/x86/xen/suspend.c            |    4 +
 arch/x86/xen/xen-head.S           |    4 +
 arch/x86/xen/xen-ops.h            |    2 +
 include/xen/xen-ops.h             |    6 +
 15 files changed, 1994 insertions(+), 1889 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_hvm.c
 create mode 100644 arch/x86/xen/enlighten_pv.c
 create mode 100644 arch/x86/xen/enlighten_pvh.c
arch/x86/include/asm/hypervisor.h +2 -1
index 67942b6..4faa12d 100644
@@ -53,7 +53,8 @@ extern const struct hypervisor_x86 *x86_hyper;
 /* Recognized hypervisors */
 extern const struct hypervisor_x86 x86_hyper_vmware;
 extern const struct hypervisor_x86 x86_hyper_ms_hyperv;
-extern const struct hypervisor_x86 x86_hyper_xen;
+extern const struct hypervisor_x86 x86_hyper_xen_pv;
+extern const struct hypervisor_x86 x86_hyper_xen_pvhvm;
 extern const struct hypervisor_x86 x86_hyper_kvm;
 
 extern void init_hypervisor(struct cpuinfo_x86 *c);
arch/x86/kernel/cpu/hypervisor.c +5 -2
index 35691a6..dd68b03 100644
@@ -28,8 +28,11 @@
 
 static const __initconst struct hypervisor_x86 * const hypervisors[] =
 {
-#ifdef CONFIG_XEN
-	&x86_hyper_xen,
+#ifdef CONFIG_XEN_PV
+	&x86_hyper_xen_pv,
+#endif
+#ifdef CONFIG_XEN_PVHVM
+	&x86_hyper_xen_pvhvm,
 #endif
 	&x86_hyper_vmware,
 	&x86_hyper_ms_hyperv,
arch/x86/kernel/process_64.c +1 -1
index a61e141..5e8d129 100644
@@ -438,7 +438,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
 		     task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV))
 		__switch_to_xtra(prev_p, next_p, tss);
 
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PV
 	/*
 	 * On Xen PV, IOPL bits in pt_regs->flags have no effect, and
 	 * current_pt_regs()->flags may not match the current task's
arch/x86/xen/Kconfig +18 -5
index 76b6dbd..c387560 100644
@@ -6,7 +6,6 @@ config XEN
 	bool "Xen guest support"
 	depends on PARAVIRT
 	select PARAVIRT_CLOCK
-	select XEN_HAVE_PVMMU
 	select XEN_HAVE_VPMU
 	depends on X86_64 || (X86_32 && X86_PAE)
 	depends on X86_LOCAL_APIC && X86_TSC
@@ -15,18 +14,32 @@ config XEN
 	  kernel to boot in a paravirtualized environment under the
 	  Xen hypervisor.
 
+config XEN_PV
+	bool "Xen PV guest support"
+	default y
+	depends on XEN
+	help
+	  Support running as a Xen PV guest.
+
 config XEN_DOM0
-	def_bool y
-	depends on XEN && PCI_XEN && SWIOTLB_XEN
+	bool "Xen PV Dom0 support"
+	default y
+	depends on XEN_PV && PCI_XEN && SWIOTLB_XEN
 	depends on X86_IO_APIC && ACPI && PCI
+	select XEN_HAVE_PVMMU
+	help
+	  Support running as a Xen PV Dom0 guest.
 
 config XEN_PVHVM
-	def_bool y
+	bool "Xen PVHVM guest support"
+	default y
 	depends on XEN && PCI && X86_LOCAL_APIC
+	help
+	  Support running as a Xen PVHVM guest.
 
 config XEN_512GB
 	bool "Limit Xen pv-domain memory to 512GB"
-	depends on XEN && X86_64
+	depends on XEN_PV && X86_64
 	default y
 	help
 	  Limit paravirtualized user domains to 512GB of RAM.
arch/x86/xen/Makefile +7 -3
index cb0164a..750727b 100644
@@ -7,14 +7,18 @@ endif
 
 # Make sure early boot has no stackprotector
 nostackp := $(call cc-option, -fno-stack-protector)
-CFLAGS_enlighten.o		:= $(nostackp)
+CFLAGS_enlighten_pv.o		:= $(nostackp)
 CFLAGS_mmu.o			:= $(nostackp)
 
-obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
-			time.o xen-asm.o xen-asm_$(BITS).o \
+obj-y		:= enlighten.o setup.o multicalls.o \
+			mmu.o irq.o time.o xen-asm.o xen-asm_$(BITS).o \
 			grant-table.o suspend.o platform-pci-unplug.o \
 			p2m.o apic.o pmu.o
 
+obj-$(CONFIG_XEN_PV)		+= enlighten_pv.o
+obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o
+obj-$(CONFIG_XEN_PVH)		+= enlighten_pvh.o
+
 obj-$(CONFIG_EVENT_TRACING) += trace.o
 
 obj-$(CONFIG_SMP)		+= smp.o
arch/x86/xen/enlighten.c +43 -1861

1,970 lines not on this page · raw message

arch/x86/xen/enlighten_hvm.c new file +210 -0

210 lines not on this page · raw message

arch/x86/xen/enlighten_pv.c new file +1552 -0

726 lines not on this page · raw message

arch/x86/xen/enlighten_pvh.c new file +114 -0

114 lines not on this page · raw message

arch/x86/xen/mmu.c +2 -0
index f6740b5..881baac 100644

Lines of this file are not shown. View the raw message.

arch/x86/xen/smp.c +24 -16
index 0dee6f5..14fd7f3 100644

Lines of this file are not shown. View the raw message.

arch/x86/xen/suspend.c +4 -0
index 7f664c4..37f634f 100644

Lines of this file are not shown. View the raw message.

arch/x86/xen/xen-head.S +4 -0
index 37794e4..72a8e6a 100644

Lines of this file are not shown. View the raw message.

arch/x86/xen/xen-ops.h +2 -0
index f6a41c4..2b162f6 100644

Lines of this file are not shown. View the raw message.

include/xen/xen-ops.h +6 -0
index b5486e6..4e562de 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.9.3

Part of the diff is not shown here. View the raw message.

maintainer
#3 lore raw

Re: [Xen-devel] [PATCH 1/5] x86/xen: start untangling PV and PVHVM guest support code

Quoted 8 lines · Vitaly Kuznetsov

Introduce CONFIG_XEN_PV config option and split enlighten.c into 4 files. Temporary add #ifdef CONFIG_XEN_PV to smp.c and mmu.c to not break the build and not make the patch even bigger.

xen_cpu_up_prepare*/xen_cpu_die hooks require separation to support future xen_smp_intr_init() split.

Could you please split pure code movement and functional changes into different patches? This would make review much easier.

So 1 patch to split up enlightenment.c and at least one patch for the rest of the changes (Kconfig, splitting of x86_hyper_xen, ...).

Juergen

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

#4 lore raw

Re: [Xen-devel] [PATCH 1/5] x86/xen: start untangling PV and PVHVM guest support code

Quoted 5 lines · Juergen Gross
Quoted 4 lines · Vitaly Kuznetsov

Introduce CONFIG_XEN_PV config option and split enlighten.c into 4 files. Temporary add #ifdef CONFIG_XEN_PV to smp.c and mmu.c to not break the build and not make the patch even bigger.

Quoted 8 lines
Quoted 4 lines

xen_cpu_up_prepare*/xen_cpu_die hooks require separation to support future xen_smp_intr_init() split.

Could you please split pure code movement and functional changes into different patches? This would make review much easier.

It's a bit hard with this series to make patches smaller and not break the build ... :-(

Quoted 2 lines

So 1 patch to split up enlightenment.c and at least one patch for the rest of the changes (Kconfig, splitting of x86_hyper_xen, ...).

This sounds doable, I'll try!

Signature · 6 lines
  Vitaly

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#5 lore raw

PATCH 2/5 x86/xen: split smp.c for PV and PVHVM guests

In reply to Vitaly Kuznetsov

More or less mechanically split smp.c into 3 files. XEN_PV_SMP and XEN_PVHVM_SMP config options added to support the change.

---
 arch/x86/xen/Kconfig        |   8 +
 arch/x86/xen/Makefile       |   3 +
 arch/x86/xen/enlighten_pv.c |   9 +
 arch/x86/xen/smp.c          | 531 +-------------------------------------------
 arch/x86/xen/smp.h          |  23 ++
 arch/x86/xen/smp_hvm.c      |  58 +++++
 arch/x86/xen/smp_pv.c       | 499 +++++++++++++++++++++++++++++++++++++++++
 7 files changed, 611 insertions(+), 520 deletions(-)
 create mode 100644 arch/x86/xen/smp_hvm.c
 create mode 100644 arch/x86/xen/smp_pv.c
arch/x86/xen/Kconfig +8 -0
index c387560..9ebfd77 100644
@@ -21,6 +21,10 @@ config XEN_PV
 	help
 	  Support running as a Xen PV guest.
 
+config XEN_PV_SMP
+	def_bool y
+	depends on XEN_PV && SMP
+
 config XEN_DOM0
 	bool "Xen PV Dom0 support"
 	default y
@@ -37,6 +41,10 @@ config XEN_PVHVM
 	help
 	  Support running as a Xen PVHVM guest.
 
+config XEN_PVHVM_SMP
+	def_bool y
+	depends on XEN_PVHVM && SMP
+
 config XEN_512GB
 	bool "Limit Xen pv-domain memory to 512GB"
 	depends on XEN_PV && X86_64
arch/x86/xen/Makefile +3 -0
index 750727b..ed6f126 100644
@@ -22,6 +22,9 @@ obj-$(CONFIG_XEN_PVH)		+= enlighten_pvh.o
 obj-$(CONFIG_EVENT_TRACING) += trace.o
 
 obj-$(CONFIG_SMP)		+= smp.o
+obj-$(CONFIG_XEN_PV_SMP)	+= smp_pv.o
+obj-$(CONFIG_XEN_PVHVM_SMP)	+= smp_hvm.o
+
 obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o
 obj-$(CONFIG_XEN_DEBUG_FS)	+= debugfs.o
 obj-$(CONFIG_XEN_DOM0)		+= vga.o
arch/x86/xen/enlighten_pv.c +9 -0
index b9ff23c..acfd896 100644
@@ -1478,12 +1478,21 @@ static int xen_cpu_up_prepare_pv(unsigned int cpu)
 		     cpu, rc);
 		return rc;
 	}
+
+	rc = xen_smp_intr_init_pv(cpu);
+	if (rc) {
+		WARN(1, "xen_smp_intr_init_pv() for CPU %d failed: %d\n",
+		     cpu, rc);
+		return rc;
+	}
+
 	return 0;
 }
 
 static int xen_cpu_dead_pv(unsigned int cpu)
 {
 	xen_smp_intr_free(cpu);
+	xen_smp_intr_free_pv(cpu);
 
 	xen_teardown_timer(cpu);
 
arch/x86/xen/smp.c +11 -520

605 lines not on this page · raw message

arch/x86/xen/smp.h +23 -0
index 9beef33..b31d43b 100644
@@ -8,9 +8,22 @@ extern void xen_send_IPI_mask_allbutself(const struct cpumask *mask,
 extern void xen_send_IPI_allbutself(int vector);
 extern void xen_send_IPI_all(int vector);
 extern void xen_send_IPI_self(int vector);
+extern void xen_send_IPI_mask(const struct cpumask *mask, int vector);
 
 extern int xen_smp_intr_init(unsigned int cpu);
 extern void xen_smp_intr_free(unsigned int cpu);
+#ifdef CONFIG_XEN_PV
+extern int xen_smp_intr_init_pv(unsigned int cpu);
+extern void xen_smp_intr_free_pv(unsigned int cpu);
+#endif
+extern void xen_smp_send_reschedule(int cpu);
+extern void xen_smp_send_call_function_ipi(const struct cpumask *mask);
+extern void xen_smp_send_call_function_single_ipi(int cpu);
+
+struct xen_common_irq {
+	int irq;
+	char *name;
+};
 
 #else /* CONFIG_SMP */
 
@@ -18,6 +31,16 @@ static inline int xen_smp_intr_init(unsigned int cpu)
 {
 	return 0;
 }
+
+#ifdef CONFIG_XEN_PV
+static inline int xen_smp_intr_init_pv(unsigned int cpu)
+{
+	return 0;
+}
+
+static inline void xen_smp_intr_free_pv(unsigned int cpu) {}
+#endif
+
 static inline void xen_smp_intr_free(unsigned int cpu) {}
 #endif /* CONFIG_SMP */
 
arch/x86/xen/smp_hvm.c new file +58 -0

58 lines not on this page · raw message

arch/x86/xen/smp_pv.c new file +499 -0

499 lines not on this page · raw message

Signature · 7 lines
2.9.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
maintainer
#6 lore raw

Re: [PATCH 2/5] x86/xen: split smp.c for PV and PVHVM guests

Quoted 4 lines · Vitaly Kuznetsov

More or less mechanically split smp.c into 3 files. XEN_PV_SMP and XEN_PVHVM_SMP config options added to support the change.

Same as in patch 1: one patch with no functional changes and one with the functional stuff, please

Juergen

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

maintainer
#7 lore raw

Re: [Xen-devel] [PATCH 2/5] x86/xen: split smp.c for PV and PVHVM guests

In reply to Vitaly Kuznetsov
Quoted 4 lines · Vitaly Kuznetsov

More or less mechanically split smp.c into 3 files. XEN_PV_SMP and XEN_PVHVM_SMP config options added to support the change.

Same as in patch 1: one patch with no functional changes and one with the functional stuff, please

Juergen

#8 lore raw

PATCH 3/5 x86/xen: put setup.c, mmu.c and p2m.c under CONFIG_XEN_PV

In reply to Vitaly Kuznetsov

These three files (mmu.c, p2m.c, setup.c) are mostly required to support PV guests, in fact p2m.c and setup.c have no code for PVHVM at all. mmu.c has some, split the file into mmu.c, mmu_pv.c and mmu_hvm.c.

Some additional changes are required:
- In the balloon driver we can't use xen_start_info, xen_released_pages and xen_extra_mem it is PV-only. Decorate it with #ifdef CONFIG_XEN_PV

- Some PV-only functions are used by drivers and for PVHVM guests these functions have 'if (xen_feature(XENFEAT_auto_translated_physmap))' check in the beginning. Create required stubs for PVHVM-only builds.

---
 arch/x86/include/asm/xen/page.h |   44 +-
 arch/x86/xen/Makefile           |   12 +-
 arch/x86/xen/mmu.c              | 2778 +--------------------------------------
 arch/x86/xen/mmu_hvm.c          |   77 ++
 arch/x86/xen/mmu_pv.c           | 2636 +++++++++++++++++++++++++++++++++++++
 drivers/xen/balloon.c           |   30 +-
 include/xen/xen-ops.h           |   13 +
 7 files changed, 2831 insertions(+), 2759 deletions(-)
 create mode 100644 arch/x86/xen/mmu_hvm.c
 create mode 100644 arch/x86/xen/mmu_pv.c
arch/x86/include/asm/xen/page.h +42 -2
index 33cbd3d..c8a347f 100644
@@ -43,9 +43,10 @@ extern unsigned long *xen_p2m_addr;
 extern unsigned long  xen_p2m_size;
 extern unsigned long  xen_max_p2m_pfn;
 
-extern int xen_alloc_p2m_entry(unsigned long pfn);
-
 extern unsigned long get_phys_to_machine(unsigned long pfn);
+
+#ifdef CONFIG_XEN_PV
+extern int xen_alloc_p2m_entry(unsigned long pfn);
 extern bool set_phys_to_machine(unsigned long pfn, unsigned long mfn);
 extern bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
 extern unsigned long __init set_phys_range_identity(unsigned long pfn_s,
@@ -57,6 +58,38 @@ extern int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
 extern int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
 				     struct gnttab_unmap_grant_ref *kunmap_ops,
 				     struct page **pages, unsigned int count);
+#else /* CONFIG_XEN_PV */
+static inline int xen_alloc_p2m_entry(unsigned long pfn)
+{
+	return 0;
+}
+
+static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
+{
+	return true;
+}
+
+static inline bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
+{
+	return true;
+}
+
+static inline int
+set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
+			struct gnttab_map_grant_ref *kmap_ops,
+			struct page **pages, unsigned int count)
+{
+	return 0;
+}
+
+static inline int
+clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
+			  struct gnttab_unmap_grant_ref *kunmap_ops,
+			  struct page **pages, unsigned int count)
+{
+	return 0;
+}
+#endif /* CONFIG_XEN_PV */
 
 /*
  * Helper functions to write or read unsigned long values to/from
@@ -82,6 +115,7 @@ static inline int xen_safe_read_ulong(unsigned long *addr, unsigned long *val)
  * - get_phys_to_machine() is to be called by __pfn_to_mfn() only in special
  *   cases needing an extended handling.
  */
+#ifdef CONFIG_XEN_PV
 static inline unsigned long __pfn_to_mfn(unsigned long pfn)
 {
 	unsigned long mfn;
@@ -98,6 +132,12 @@ static inline unsigned long __pfn_to_mfn(unsigned long pfn)
 
 	return mfn;
 }
+#else
+static inline unsigned long __pfn_to_mfn(unsigned long pfn)
+{
+	return pfn;
+}
+#endif
 
 static inline unsigned long pfn_to_mfn(unsigned long pfn)
 {
arch/x86/xen/Makefile +6 -6
index ed6f126..3bf840e 100644
@@ -8,15 +8,15 @@ endif
 # Make sure early boot has no stackprotector
 nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_enlighten_pv.o		:= $(nostackp)
-CFLAGS_mmu.o			:= $(nostackp)
+CFLAGS_mmu_pv.o			:= $(nostackp)
 
-obj-y		:= enlighten.o setup.o multicalls.o \
-			mmu.o irq.o time.o xen-asm.o xen-asm_$(BITS).o \
+obj-y		:= enlighten.o multicalls.o \
+			irq.o time.o xen-asm.o xen-asm_$(BITS).o \
 			grant-table.o suspend.o platform-pci-unplug.o \
-			p2m.o apic.o pmu.o
+			apic.o pmu.o mmu.o
 
-obj-$(CONFIG_XEN_PV)		+= enlighten_pv.o
-obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o
+obj-$(CONFIG_XEN_PV)		+= enlighten_pv.o setup.o mmu_pv.o p2m.o
+obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o
 obj-$(CONFIG_XEN_PVH)		+= enlighten_pvh.o
 
 obj-$(CONFIG_EVENT_TRACING) += trace.o
arch/x86/xen/mmu.c +37 -2741

2,813 lines not on this page · raw message

arch/x86/xen/mmu_hvm.c new file +77 -0

77 lines not on this page · raw message

arch/x86/xen/mmu_pv.c new file +2636 -0

20 lines not on this page · raw message

drivers/xen/balloon.c +20 -10
index db107fa..b11ca75 100644

Lines of this file are not shown. View the raw message.

include/xen/xen-ops.h +13 -0
index 4e562de..f9e0e23 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 7 lines
2.9.3


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

Part of the diff is not shown here. View the raw message.

maintainer
#9 lore raw

Re: [Xen-devel] [PATCH 3/5] x86/xen: put setup.c, mmu.c and p2m.c under CONFIG_XEN_PV

Quoted 8 lines · Vitaly Kuznetsov

These three files (mmu.c, p2m.c, setup.c) are mostly required to support PV guests, in fact p2m.c and setup.c have no code for PVHVM at all. mmu.c has some, split the file into mmu.c, mmu_pv.c and mmu_hvm.c.

Some additional changes are required:
- In the balloon driver we can't use xen_start_info, xen_released_pages and xen_extra_mem it is PV-only. Decorate it with #ifdef CONFIG_XEN_PV

Quoted 5 lines

- Some PV-only functions are used by drivers and for PVHVM guests these functions have 'if (xen_feature(XENFEAT_auto_translated_physmap))' check in the beginning. Create required stubs for PVHVM-only builds.

And again: split the patch up, please.

Juergen

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

#10 lore raw

PATCH 4/5 x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV

In reply to Vitaly Kuznetsov

xen_pmu_init/finish() functions are used in suspend.c and enlighten.c, add stubs for now.

---
 arch/x86/xen/Kconfig  | 2 +-
 arch/x86/xen/Makefile | 5 +++--
 arch/x86/xen/pmu.h    | 5 +++++
 3 files changed, 9 insertions(+), 3 deletions(-)
arch/x86/xen/Kconfig +1 -1
index 9ebfd77..aa8256b 100644
@@ -6,7 +6,6 @@ config XEN
 	bool "Xen guest support"
 	depends on PARAVIRT
 	select PARAVIRT_CLOCK
-	select XEN_HAVE_VPMU
 	depends on X86_64 || (X86_32 && X86_PAE)
 	depends on X86_LOCAL_APIC && X86_TSC
 	help
@@ -18,6 +17,7 @@ config XEN_PV
 	bool "Xen PV guest support"
 	default y
 	depends on XEN
+	select XEN_HAVE_VPMU
 	help
 	  Support running as a Xen PV guest.
 
arch/x86/xen/Makefile +3 -2
index 3bf840e..10264ed 100644
@@ -13,9 +13,10 @@ CFLAGS_mmu_pv.o			:= $(nostackp)
 obj-y		:= enlighten.o multicalls.o \
 			irq.o time.o xen-asm.o xen-asm_$(BITS).o \
 			grant-table.o suspend.o platform-pci-unplug.o \
-			apic.o pmu.o mmu.o
+			mmu.o
 
-obj-$(CONFIG_XEN_PV)		+= enlighten_pv.o setup.o mmu_pv.o p2m.o
+obj-$(CONFIG_XEN_PV)		+= enlighten_pv.o setup.o mmu_pv.o p2m.o \
+					apic.o pmu.o
 obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o
 obj-$(CONFIG_XEN_PVH)		+= enlighten_pvh.o
 
arch/x86/xen/pmu.h +5 -0
index af5f0ad..4be5355 100644
@@ -4,8 +4,13 @@
 #include <xen/interface/xenpmu.h>
 
 irqreturn_t xen_pmu_irq_handler(int irq, void *dev_id);
+#ifdef CONFIG_XEN_HAVE_VPMU
 void xen_pmu_init(int cpu);
 void xen_pmu_finish(int cpu);
+#else
+static inline void xen_pmu_init(int cpu) {}
+static inline void xen_pmu_finish(int cpu) {}
+#endif
 bool is_xen_pmu(int cpu);
 bool pmu_msr_read(unsigned int msr, uint64_t *val, int *err);
 bool pmu_msr_write(unsigned int msr, uint32_t low, uint32_t high, int *err);
Signature · 7 lines
2.9.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#11 lore raw

PATCH 4/5 x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV

In reply to Vitaly Kuznetsov

xen_pmu_init/finish() functions are used in suspend.c and enlighten.c, add stubs for now.

---
 arch/x86/xen/Kconfig  | 2 +-
 arch/x86/xen/Makefile | 5 +++--
 arch/x86/xen/pmu.h    | 5 +++++
 3 files changed, 9 insertions(+), 3 deletions(-)
arch/x86/xen/Kconfig +1 -1
index 9ebfd77..aa8256b 100644
@@ -6,7 +6,6 @@ config XEN
 	bool "Xen guest support"
 	depends on PARAVIRT
 	select PARAVIRT_CLOCK
-	select XEN_HAVE_VPMU
 	depends on X86_64 || (X86_32 && X86_PAE)
 	depends on X86_LOCAL_APIC && X86_TSC
 	help
@@ -18,6 +17,7 @@ config XEN_PV
 	bool "Xen PV guest support"
 	default y
 	depends on XEN
+	select XEN_HAVE_VPMU
 	help
 	  Support running as a Xen PV guest.
 
arch/x86/xen/Makefile +3 -2
index 3bf840e..10264ed 100644
@@ -13,9 +13,10 @@ CFLAGS_mmu_pv.o			:= $(nostackp)
 obj-y		:= enlighten.o multicalls.o \
 			irq.o time.o xen-asm.o xen-asm_$(BITS).o \
 			grant-table.o suspend.o platform-pci-unplug.o \
-			apic.o pmu.o mmu.o
+			mmu.o
 
-obj-$(CONFIG_XEN_PV)		+= enlighten_pv.o setup.o mmu_pv.o p2m.o
+obj-$(CONFIG_XEN_PV)		+= enlighten_pv.o setup.o mmu_pv.o p2m.o \
+					apic.o pmu.o
 obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o
 obj-$(CONFIG_XEN_PVH)		+= enlighten_pvh.o
 
arch/x86/xen/pmu.h +5 -0
index af5f0ad..4be5355 100644
@@ -4,8 +4,13 @@
 #include <xen/interface/xenpmu.h>
 
 irqreturn_t xen_pmu_irq_handler(int irq, void *dev_id);
+#ifdef CONFIG_XEN_HAVE_VPMU
 void xen_pmu_init(int cpu);
 void xen_pmu_finish(int cpu);
+#else
+static inline void xen_pmu_init(int cpu) {}
+static inline void xen_pmu_finish(int cpu) {}
+#endif
 bool is_xen_pmu(int cpu);
 bool pmu_msr_read(unsigned int msr, uint64_t *val, int *err);
 bool pmu_msr_write(unsigned int msr, uint32_t low, uint32_t high, int *err);
Signature · 1 line
2.9.3
maintainer Reviewed-by on v1 4/5
#12 lore raw

Re: [Xen-devel] [PATCH 4/5] x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV

Quoted 4 lines · Vitaly Kuznetsov

xen_pmu_init/finish() functions are used in suspend.c and enlighten.c, add stubs for now.

Juergen

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

#13 lore raw

PATCH 5/5 x86/xen: split suspend.c for PV and PVHVM guests

In reply to Vitaly Kuznetsov

Get read of #ifdefs in suspend.c by splitting the code into suspend_pv.c and suspend_hvm.c.

---
 arch/x86/xen/Makefile      |  4 ++--
 arch/x86/xen/suspend.c     | 58 ----------------------------------------------
 arch/x86/xen/suspend_hvm.c | 22 ++++++++++++++++++
 arch/x86/xen/suspend_pv.c  | 44 +++++++++++++++++++++++++++++++++++
 arch/x86/xen/xen-ops.h     | 14 +++++++++++
 5 files changed, 82 insertions(+), 60 deletions(-)
 create mode 100644 arch/x86/xen/suspend_hvm.c
 create mode 100644 arch/x86/xen/suspend_pv.c
arch/x86/xen/Makefile +2 -2
index 10264ed..c5291f4 100644
@@ -16,8 +16,8 @@ obj-y		:= enlighten.o multicalls.o \
 			mmu.o
 
 obj-$(CONFIG_XEN_PV)		+= enlighten_pv.o setup.o mmu_pv.o p2m.o \
-					apic.o pmu.o
-obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o
+					apic.o pmu.o suspend_pv.o
+obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o suspend_hvm.o
 obj-$(CONFIG_XEN_PVH)		+= enlighten_pvh.o
 
 obj-$(CONFIG_EVENT_TRACING) += trace.o
arch/x86/xen/suspend.c +0 -58

64 lines not on this page · raw message

arch/x86/xen/suspend_hvm.c new file +22 -0
new file mode 100644
index 0000000..01afcad
@@ -0,0 +1,22 @@
+#include <linux/types.h>
+
+#include <xen/xen.h>
+#include <xen/features.h>
+#include <xen/interface/features.h>
+
+#include "xen-ops.h"
+
+void xen_hvm_post_suspend(int suspend_cancelled)
+{
+	int cpu;
+
+	if (!suspend_cancelled)
+		xen_hvm_init_shared_info();
+	xen_callback_vector();
+	xen_unplug_emulated_devices();
+	if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
+		for_each_online_cpu(cpu) {
+			xen_setup_runstate_info(cpu);
+		}
+	}
+}
arch/x86/xen/suspend_pv.c new file +44 -0

44 lines not on this page · raw message

arch/x86/xen/xen-ops.h +14 -0
index 2b162f6..e904415 100644
@@ -148,4 +148,18 @@ __visible void xen_adjust_exception_frame(void);
 
 extern int xen_panic_handler_init(void);
 
+#ifdef CONFIG_XEN_PV
+extern void xen_pv_pre_suspend(void);
+extern void xen_pv_post_suspend(int suspend_cancelled);
+#else
+static inline void xen_pv_pre_suspend(void) {}
+static inline void xen_pv_post_suspend(int suspend_cancelled) {}
+#endif
+
+#ifdef CONFIG_XEN_PVHVM
+extern void xen_hvm_post_suspend(int suspend_cancelled);
+#else
+static inline void xen_hvm_post_suspend(int suspend_cancelled) {}
+#endif
+
 #endif /* XEN_OPS_H */
Signature · 7 lines
2.9.3


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