Skip to contentSkip to conversation

x86/xen: untangle PV and PVHVM guest support code

PATCH Superseded Vitaly Kuznetsov 3 participants 40 messages Mar 14, 2017 – Mar 28, 2017

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

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

Changes since v2:
- Rebase to 4.11.0-rc1+
- XEN_HAVE_PVMMU moved to config XEN_PV [Juergen Gross]
- .pin_vcpu kept for x86_hyper_xen_hvm to support PVH Dom0 in future [Juergen Gross]
- 'extern' qualifiers dropped from newly introduced function prototypes in headers [Juergen Gross]
- A couple of #includes added to address build issues with different configs [kbuild test robot].
- Juergen reviewed-bys added (hope they stand with the above mentioned changes).

The series can also be pulled from https://github.com/vittyvk/linux.git
(xen_pv_hvm_split_v3 branch).

Some 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.

Some 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 (21):
x86/xen: separate PV and HVM hypervisors
x86/xen: globalize have_vcpu_info_placement
x86/xen: add CONFIG_XEN_PV to Kconfig
x86/xen: split off enlighten_pvh.c
x86/xen: split off enlighten_hvm.c
x86/xen: split off enlighten_pv.c
x86/xen: split xen_smp_intr_init()/xen_smp_intr_free() x86/xen: split xen_smp_prepare_boot_cpu()
x86/xen: split xen_cpu_die()
x86/xen: split off smp_hvm.c
x86/xen: split off smp_pv.c
x86/xen: split off mmu_hvm.c
x86/xen: split off mmu_pv.c
x86/xen: split suspend.c for PV and PVHVM guests x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV x86/xen: define startup_xen for XEN PV only
x86/xen: create stubs for HVM-only builds in page.h xen/balloon: decorate PV-only parts with #ifdef CONFIG_XEN_PV
xen: create xen_create/destroy_contiguous_region() stubs for PVHVM
only builds
x86/xen: enable PVHVM-only builds
x86/xen: rename some PV-only functions in smp_pv.c

 arch/x86/include/asm/hypervisor.h |    3 +-
 arch/x86/include/asm/xen/page.h   |   25 +
 arch/x86/kernel/cpu/hypervisor.c  |    7 +-
 arch/x86/kernel/process_64.c      |    2 +-
 arch/x86/xen/Kconfig              |   33 +-
 arch/x86/xen/Makefile             |   16 +-
 arch/x86/xen/enlighten.c          | 1925 +------------------------
 arch/x86/xen/enlighten_hvm.c      |  213 +++
 arch/x86/xen/enlighten_pv.c       | 1522 ++++++++++++++++++++
 arch/x86/xen/enlighten_pvh.c      |  115 ++
 arch/x86/xen/mmu.c                | 2776 +------------------------------------
 arch/x86/xen/mmu_hvm.c            |   79 ++
 arch/x86/xen/mmu_pv.c             | 2635 +++++++++++++++++++++++++++++++++++
 arch/x86/xen/pmu.h                |    5 +
 arch/x86/xen/smp.c                |  517 +------
 arch/x86/xen/smp.h                |   16 +
 arch/x86/xen/smp_hvm.c            |   58 +
 arch/x86/xen/smp_pv.c             |  500 +++++++
 arch/x86/xen/suspend.c            |   54 -
 arch/x86/xen/suspend_hvm.c        |   22 +
 arch/x86/xen/suspend_pv.c         |   46 +
 arch/x86/xen/xen-head.S           |    4 +
 arch/x86/xen/xen-ops.h            |   23 +
 drivers/xen/balloon.c             |   30 +-
 include/xen/xen-ops.h             |   14 +
 25 files changed, 5461 insertions(+), 5179 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 v3 1/21 x86/xen: separate PV and HVM hypervisors

As a preparation to splitting the code we need to untangle it:

x86_hyper_xen -> x86_hyper_xen_hvm and x86_hyper_xen_pv xen_platform() -> xen_platform_hvm() and xen_platform_pv() xen_cpu_up_prepare() -> xen_cpu_up_prepare_pv() and xen_cpu_up_prepare_hvm() xen_cpu_dead() -> xen_cpu_dead_pv() and xen_cpu_dead_pv_hvm()

Add two parameters to xen_cpuhp_setup() to pass proper cpu_up_prepare and cpu_dead hooks. xen_set_cpu_features() is now PV-only so the redundant xen_pv_domain() check can be dropped.

---
Changes since v2:
.pin_vcpu kept for x86_hyper_xen_hvm to support PVH Dom0 in future [Juergen Gross]

---
 arch/x86/include/asm/hypervisor.h |   3 +-
 arch/x86/kernel/cpu/hypervisor.c  |   3 +-
 arch/x86/xen/enlighten.c          | 114 +++++++++++++++++++++++++-------------
 3 files changed, 79 insertions(+), 41 deletions(-)
arch/x86/include/asm/hypervisor.h +2 -1
index 67942b6..6f7545c6 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_hvm;
 extern const struct hypervisor_x86 x86_hyper_kvm;
 
 extern void init_hypervisor(struct cpuinfo_x86 *c);
arch/x86/kernel/cpu/hypervisor.c +2 -1
index 35691a6..a77f18d 100644
@@ -29,7 +29,8 @@
 static const __initconst struct hypervisor_x86 * const hypervisors[] =
 {
 #ifdef CONFIG_XEN
-	&x86_hyper_xen,
+	&x86_hyper_xen_pv,
+	&x86_hyper_xen_hvm,
 #endif
 	&x86_hyper_vmware,
 	&x86_hyper_ms_hyperv,
arch/x86/xen/enlighten.c +75 -39

191 lines not on this page · raw message

Signature · 1 line
2.9.3
maintainer Reviewed-by on v3 1/21
#2 lore raw

Re: [PATCH v3 01/21] x86/xen: separate PV and HVM hypervisors

Quoted 11 lines · Vitaly Kuznetsov

As a preparation to splitting the code we need to untangle it:

x86_hyper_xen -> x86_hyper_xen_hvm and x86_hyper_xen_pv xen_platform() -> xen_platform_hvm() and xen_platform_pv() xen_cpu_up_prepare() -> xen_cpu_up_prepare_pv() and xen_cpu_up_prepare_hvm() xen_cpu_dead() -> xen_cpu_dead_pv() and xen_cpu_dead_pv_hvm()

Add two parameters to xen_cpuhp_setup() to pass proper cpu_up_prepare and cpu_dead hooks. xen_set_cpu_features() is now PV-only so the redundant xen_pv_domain() check can be dropped.

Quoted 6 lines

---
Changes since v2:
.pin_vcpu kept for x86_hyper_xen_hvm to support PVH Dom0 in future [Juergen Gross]
---

Juergen

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

maintainer Reviewed-by on v3 1/21
#3 lore raw

Re: [PATCH v3 01/21] x86/xen: separate PV and HVM hypervisors

In reply to Vitaly Kuznetsov
Quoted 11 lines · Vitaly Kuznetsov

As a preparation to splitting the code we need to untangle it:

x86_hyper_xen -> x86_hyper_xen_hvm and x86_hyper_xen_pv xen_platform() -> xen_platform_hvm() and xen_platform_pv() xen_cpu_up_prepare() -> xen_cpu_up_prepare_pv() and xen_cpu_up_prepare_hvm() xen_cpu_dead() -> xen_cpu_dead_pv() and xen_cpu_dead_pv_hvm()

Add two parameters to xen_cpuhp_setup() to pass proper cpu_up_prepare and cpu_dead hooks. xen_set_cpu_features() is now PV-only so the redundant xen_pv_domain() check can be dropped.

Quoted 6 lines

---
Changes since v2:
.pin_vcpu kept for x86_hyper_xen_hvm to support PVH Dom0 in future [Juergen Gross]
---

Juergen

#4 lore raw

PATCH v3 1/21 x86/xen: separate PV and HVM hypervisors

In reply to Vitaly Kuznetsov

As a preparation to splitting the code we need to untangle it:

x86_hyper_xen -> x86_hyper_xen_hvm and x86_hyper_xen_pv xen_platform() -> xen_platform_hvm() and xen_platform_pv() xen_cpu_up_prepare() -> xen_cpu_up_prepare_pv() and xen_cpu_up_prepare_hvm() xen_cpu_dead() -> xen_cpu_dead_pv() and xen_cpu_dead_pv_hvm()

Add two parameters to xen_cpuhp_setup() to pass proper cpu_up_prepare and cpu_dead hooks. xen_set_cpu_features() is now PV-only so the redundant xen_pv_domain() check can be dropped.

---
Changes since v2:
.pin_vcpu kept for x86_hyper_xen_hvm to support PVH Dom0 in future [Juergen Gross]

---
 arch/x86/include/asm/hypervisor.h |   3 +-
 arch/x86/kernel/cpu/hypervisor.c  |   3 +-
 arch/x86/xen/enlighten.c          | 114 +++++++++++++++++++++++++-------------
 3 files changed, 79 insertions(+), 41 deletions(-)
arch/x86/include/asm/hypervisor.h +2 -1
index 67942b6..6f7545c6 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_hvm;
 extern const struct hypervisor_x86 x86_hyper_kvm;
 
 extern void init_hypervisor(struct cpuinfo_x86 *c);
arch/x86/kernel/cpu/hypervisor.c +2 -1
index 35691a6..a77f18d 100644
@@ -29,7 +29,8 @@
 static const __initconst struct hypervisor_x86 * const hypervisors[] =
 {
 #ifdef CONFIG_XEN
-	&x86_hyper_xen,
+	&x86_hyper_xen_pv,
+	&x86_hyper_xen_hvm,
 #endif
 	&x86_hyper_vmware,
 	&x86_hyper_ms_hyperv,
arch/x86/xen/enlighten.c +75 -39

191 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
#5 lore raw

PATCH v3 2/21 x86/xen: globalize have_vcpu_info_placement

In reply to Vitaly Kuznetsov

have_vcpu_info_placement applies to both PV and HVM and as we're going to split the code we need to make it global.

Rename to xen_have_vcpu_info_placement.

---
 arch/x86/xen/enlighten.c | 12 ++++++------
 arch/x86/xen/xen-ops.h   |  2 ++
 2 files changed, 8 insertions(+), 6 deletions(-)
arch/x86/xen/enlighten.c +6 -6
index 999ba13..f0784a6 100644
@@ -164,7 +164,7 @@ struct shared_info *HYPERVISOR_shared_info = &xen_dummy_shared_info;
  *
  * 0: not available, 1: available
  */
-static int have_vcpu_info_placement = 1;
+int xen_have_vcpu_info_placement = 1;
 
 struct tls_descs {
 	struct desc_struct desc[3];
@@ -228,7 +228,7 @@ void xen_vcpu_setup(int cpu)
 		per_cpu(xen_vcpu, cpu) =
 			&HYPERVISOR_shared_info->vcpu_info[xen_vcpu_nr(cpu)];
 
-	if (!have_vcpu_info_placement) {
+	if (!xen_have_vcpu_info_placement) {
 		if (cpu >= MAX_VIRT_CPUS)
 			clamp_max_cpus();
 		return;
@@ -251,7 +251,7 @@ void xen_vcpu_setup(int cpu)
 
 	if (err) {
 		printk(KERN_DEBUG "register_vcpu_info failed: err=%d\n", err);
-		have_vcpu_info_placement = 0;
+		xen_have_vcpu_info_placement = 0;
 		clamp_max_cpus();
 	} else {
 		/* This cpu is using the registered vcpu info, even if
@@ -280,7 +280,7 @@ void xen_vcpu_restore(void)
 
 		xen_setup_runstate_info(cpu);
 
-		if (have_vcpu_info_placement)
+		if (xen_have_vcpu_info_placement)
 			xen_vcpu_setup(cpu);
 
 		if (other_cpu && is_up &&
@@ -1159,7 +1159,7 @@ void xen_setup_vcpu_info_placement(void)
 	 * xen_vcpu_setup managed to place the vcpu_info within the
 	 * percpu area for all cpus, so make use of it.
 	 */
-	if (have_vcpu_info_placement) {
+	if (xen_have_vcpu_info_placement) {
 		pv_irq_ops.save_fl = __PV_IS_CALLEE_SAVE(xen_save_fl_direct);
 		pv_irq_ops.restore_fl = __PV_IS_CALLEE_SAVE(xen_restore_fl_direct);
 		pv_irq_ops.irq_disable = __PV_IS_CALLEE_SAVE(xen_irq_disable_direct);
@@ -1178,7 +1178,7 @@ static unsigned xen_patch(u8 type, u16 clobbers, void *insnbuf,
 
 #define SITE(op, x)							\
 	case PARAVIRT_PATCH(op.x):					\
-	if (have_vcpu_info_placement) {					\
+	if (xen_have_vcpu_info_placement) {				\
 		start = (char *)xen_##x##_direct;			\
 		end = xen_##x##_direct_end;				\
 		reloc = xen_##x##_direct_reloc;				\
arch/x86/xen/xen-ops.h +2 -0
index f6a41c4..2b162f6 100644
@@ -76,6 +76,8 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id);
 
 bool xen_vcpu_stolen(int vcpu);
 
+extern int xen_have_vcpu_info_placement;
+
 void xen_vcpu_setup(int cpu);
 void xen_setup_vcpu_info_placement(void);
 
Signature · 7 lines
2.9.3


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

PATCH v3 3/21 x86/xen: add CONFIG_XEN_PV to Kconfig

In reply to Vitaly Kuznetsov

All code to support Xen PV will get under this new option. For the beginning, check for it in the common code.

---
Changes since v2:
select XEN_HAVE_PVMMU moved to config XEN_PV [Juergen Gross]

---
 arch/x86/kernel/cpu/hypervisor.c |  4 +++-
 arch/x86/kernel/process_64.c     |  2 +-
 arch/x86/xen/Kconfig             | 23 ++++++++++++++++++-----
 3 files changed, 22 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/hypervisor.c +3 -1
index a77f18d..ce6fcc3 100644
@@ -28,8 +28,10 @@
 
 static const __initconst struct hypervisor_x86 * const hypervisors[] =
 {
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PV
 	&x86_hyper_xen_pv,
+#endif
+#ifdef CONFIG_XEN_PVHVM
 	&x86_hyper_xen_hvm,
 #endif
 	&x86_hyper_vmware,
arch/x86/kernel/process_64.c +1 -1
index d6b784a..338ed9a 100644
@@ -440,7 +440,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..5bb1434 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
+	select XEN_HAVE_PVMMU
+	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
+	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.
Signature · 7 lines
2.9.3


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

PATCH v3 3/21 x86/xen: add CONFIG_XEN_PV to Kconfig

In reply to Vitaly Kuznetsov

All code to support Xen PV will get under this new option. For the beginning, check for it in the common code.

---
Changes since v2:
select XEN_HAVE_PVMMU moved to config XEN_PV [Juergen Gross]

---
 arch/x86/kernel/cpu/hypervisor.c |  4 +++-
 arch/x86/kernel/process_64.c     |  2 +-
 arch/x86/xen/Kconfig             | 23 ++++++++++++++++++-----
 3 files changed, 22 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/hypervisor.c +3 -1
index a77f18d..ce6fcc3 100644
@@ -28,8 +28,10 @@
 
 static const __initconst struct hypervisor_x86 * const hypervisors[] =
 {
-#ifdef CONFIG_XEN
+#ifdef CONFIG_XEN_PV
 	&x86_hyper_xen_pv,
+#endif
+#ifdef CONFIG_XEN_PVHVM
 	&x86_hyper_xen_hvm,
 #endif
 	&x86_hyper_vmware,
arch/x86/kernel/process_64.c +1 -1
index d6b784a..338ed9a 100644
@@ -440,7 +440,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..5bb1434 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
+	select XEN_HAVE_PVMMU
+	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
+	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.
Signature · 1 line
2.9.3
maintainer Reviewed-by on v3 3/21
#8 lore raw

Re: [PATCH v3 03/21] x86/xen: add CONFIG_XEN_PV to Kconfig

Quoted 8 lines · Vitaly Kuznetsov

All code to support Xen PV will get under this new option. For the beginning, check for it in the common code.

---
Changes since v2:
select XEN_HAVE_PVMMU moved to config XEN_PV [Juergen Gross]
---

Juergen

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

maintainer Reviewed-by on v3 3/21
#9 lore raw

Re: [PATCH v3 03/21] x86/xen: add CONFIG_XEN_PV to Kconfig

In reply to Vitaly Kuznetsov
Quoted 8 lines · Vitaly Kuznetsov

All code to support Xen PV will get under this new option. For the beginning, check for it in the common code.

---
Changes since v2:
select XEN_HAVE_PVMMU moved to config XEN_PV [Juergen Gross]
---

Juergen

#10 lore raw

PATCH v3 4/21 x86/xen: split off enlighten_pvh.c

In reply to Vitaly Kuznetsov

Create enlighten_pvh.c by splitting off PVH related code from enlighten.c, put it under CONFIG_XEN_PVH.

---
Changes since v2:

    #include <asm/io_apic.h> added [kbuild test robot]
---
 arch/x86/xen/Makefile        |   2 +
 arch/x86/xen/enlighten.c     | 110 -----------------------------------------
 arch/x86/xen/enlighten_pvh.c | 115 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 117 insertions(+), 110 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_pvh.c
arch/x86/xen/Makefile +2 -0
index cb0164a..348128b 100644
@@ -15,6 +15,8 @@ obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
 			grant-table.o suspend.o platform-pci-unplug.o \
 			p2m.o apic.o pmu.o
 
+obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
+
 obj-$(CONFIG_EVENT_TRACING) += trace.o
 
 obj-$(CONFIG_SMP)		+= smp.o
arch/x86/xen/enlighten.c +0 -110

122 lines not on this page · raw message

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

115 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
#11 lore raw

PATCH v3 4/21 x86/xen: split off enlighten_pvh.c

In reply to Vitaly Kuznetsov

Create enlighten_pvh.c by splitting off PVH related code from enlighten.c, put it under CONFIG_XEN_PVH.

---
Changes since v2:

    #include <asm/io_apic.h> added [kbuild test robot]
---
 arch/x86/xen/Makefile        |   2 +
 arch/x86/xen/enlighten.c     | 110 -----------------------------------------
 arch/x86/xen/enlighten_pvh.c | 115 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 117 insertions(+), 110 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_pvh.c
arch/x86/xen/Makefile +2 -0
index cb0164a..348128b 100644
@@ -15,6 +15,8 @@ obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
 			grant-table.o suspend.o platform-pci-unplug.o \
 			p2m.o apic.o pmu.o
 
+obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
+
 obj-$(CONFIG_EVENT_TRACING) += trace.o
 
 obj-$(CONFIG_SMP)		+= smp.o
arch/x86/xen/enlighten.c +0 -110

122 lines not on this page · raw message

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

115 lines not on this page · raw message

Signature · 1 line
2.9.3
#12 lore raw

PATCH v3 5/21 x86/xen: split off enlighten_hvm.c

In reply to Vitaly Kuznetsov

Move PVHVM related code to enlighten_hvm.c. Three functions:
xen_cpuhp_setup(), xen_reboot(), xen_emergency_restart() are shared, drop static qualifier from them. These functions will go to common code once it is split from enlighten.c.

---
Changes since v2:
xen_pin_vcpu() exported as we use it for HVM too. #include <asm/cpu.h>/#include <asm/smp.h> added [kbuild test robot]

---
 arch/x86/xen/Makefile        |   1 +
 arch/x86/xen/enlighten.c     | 212 +-----------------------------------------
 arch/x86/xen/enlighten_hvm.c | 213 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/xen/xen-ops.h       |   8 ++
 4 files changed, 227 insertions(+), 207 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_hvm.c
arch/x86/xen/Makefile +1 -0
index 348128b..1bca75b 100644
@@ -15,6 +15,7 @@ obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
 			grant-table.o suspend.o platform-pci-unplug.o \
 			p2m.o apic.o pmu.o
 
+obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o
 obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
 
 obj-$(CONFIG_EVENT_TRACING) += trace.o
arch/x86/xen/enlighten.c +5 -207

288 lines not on this page · raw message

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

213 lines not on this page · raw message

arch/x86/xen/xen-ops.h +8 -0
index 2b162f6..0dd8dd2 100644
@@ -148,4 +148,12 @@ __visible void xen_adjust_exception_frame(void);
 
 extern int xen_panic_handler_init(void);
 
+int xen_cpuhp_setup(int (*cpu_up_prepare_cb)(unsigned int),
+		    int (*cpu_dead_cb)(unsigned int));
+
+void xen_pin_vcpu(int cpu);
+
+void xen_reboot(int reason);
+void xen_emergency_restart(void);
+
 #endif /* XEN_OPS_H */
Signature · 7 lines
2.9.3


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

PATCH v3 5/21 x86/xen: split off enlighten_hvm.c

In reply to Vitaly Kuznetsov

Move PVHVM related code to enlighten_hvm.c. Three functions:
xen_cpuhp_setup(), xen_reboot(), xen_emergency_restart() are shared, drop static qualifier from them. These functions will go to common code once it is split from enlighten.c.

---
Changes since v2:
xen_pin_vcpu() exported as we use it for HVM too. #include <asm/cpu.h>/#include <asm/smp.h> added [kbuild test robot]

---
 arch/x86/xen/Makefile        |   1 +
 arch/x86/xen/enlighten.c     | 212 +-----------------------------------------
 arch/x86/xen/enlighten_hvm.c | 213 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/xen/xen-ops.h       |   8 ++
 4 files changed, 227 insertions(+), 207 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_hvm.c
arch/x86/xen/Makefile +1 -0
index 348128b..1bca75b 100644
@@ -15,6 +15,7 @@ obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
 			grant-table.o suspend.o platform-pci-unplug.o \
 			p2m.o apic.o pmu.o
 
+obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o
 obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
 
 obj-$(CONFIG_EVENT_TRACING) += trace.o
arch/x86/xen/enlighten.c +5 -207

288 lines not on this page · raw message

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

213 lines not on this page · raw message

arch/x86/xen/xen-ops.h +8 -0
index 2b162f6..0dd8dd2 100644
@@ -148,4 +148,12 @@ __visible void xen_adjust_exception_frame(void);
 
 extern int xen_panic_handler_init(void);
 
+int xen_cpuhp_setup(int (*cpu_up_prepare_cb)(unsigned int),
+		    int (*cpu_dead_cb)(unsigned int));
+
+void xen_pin_vcpu(int cpu);
+
+void xen_reboot(int reason);
+void xen_emergency_restart(void);
+
 #endif /* XEN_OPS_H */
Signature · 1 line
2.9.3
#14 lore raw

PATCH v3 6/21 x86/xen: split off enlighten_pv.c

In reply to Vitaly Kuznetsov

Basically, enlighten.c is renamed to enlighten_pv.c and some code moved out to common enlighten.c.

---
Changes since v2:
xen_pin_vcpu() left in enlighten.c

---
 arch/x86/xen/Makefile       |    4 +-
 arch/x86/xen/enlighten.c    | 1647 ++-----------------------------------------
 arch/x86/xen/enlighten_pv.c | 1513 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 1587 insertions(+), 1577 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_pv.c
arch/x86/xen/Makefile +2 -2
index 1bca75b..5ca8d3eb 100644
@@ -7,13 +7,13 @@ 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 \
 			grant-table.o suspend.o platform-pci-unplug.o \
-			p2m.o apic.o pmu.o
+			p2m.o apic.o pmu.o enlighten_pv.o
 
 obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o
 obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
arch/x86/xen/enlighten.c +72 -1575

1,707 lines not on this page · raw message

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

1,278 lines not on this page · 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.

#15 lore raw

PATCH v3 7/21 x86/xen: split xen_smp_intr_init()/xen_smp_intr_free()

In reply to Vitaly Kuznetsov

xen_smp_intr_init() and xen_smp_intr_free() have PV-specific code and as a praparatory change to splitting smp.c we need to split these fucntions. Create xen_smp_intr_init_pv()/xen_smp_intr_free_pv().

---
Changes since v2:
'extern' qualifier dropped from xen_smp_intr_init/free() prototypes.

---
 arch/x86/xen/enlighten_pv.c |  9 +++++++++
 arch/x86/xen/smp.c          | 29 ++++++++++++++++++-----------
 arch/x86/xen/smp.h          |  8 ++++++++
 3 files changed, 35 insertions(+), 11 deletions(-)
arch/x86/xen/enlighten_pv.c +9 -0
index 11443cc..cae1551 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 +18 -11
index 7ff2f1b..9be801e 100644
@@ -133,9 +133,10 @@ void xen_smp_intr_free(unsigned int cpu)
 		kfree(per_cpu(xen_callfuncsingle_irq, cpu).name);
 		per_cpu(xen_callfuncsingle_irq, cpu).name = NULL;
 	}
-	if (xen_hvm_domain())
-		return;
+}
 
+void xen_smp_intr_free_pv(unsigned int cpu)
+{
 	if (per_cpu(xen_irq_work, cpu).irq >= 0) {
 		unbind_from_irqhandler(per_cpu(xen_irq_work, cpu).irq, NULL);
 		per_cpu(xen_irq_work, cpu).irq = -1;
@@ -149,11 +150,12 @@ void xen_smp_intr_free(unsigned int cpu)
 		kfree(per_cpu(xen_pmu_irq, cpu).name);
 		per_cpu(xen_pmu_irq, cpu).name = NULL;
 	}
-};
+}
+
 int xen_smp_intr_init(unsigned int cpu)
 {
 	int rc;
-	char *resched_name, *callfunc_name, *debug_name, *pmu_name;
+	char *resched_name, *callfunc_name, *debug_name;
 
 	resched_name = kasprintf(GFP_KERNEL, "resched%d", cpu);
 	rc = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR,
@@ -200,12 +202,17 @@ int xen_smp_intr_init(unsigned int cpu)
 	per_cpu(xen_callfuncsingle_irq, cpu).irq = rc;
 	per_cpu(xen_callfuncsingle_irq, cpu).name = callfunc_name;
 
-	/*
-	 * The IRQ worker on PVHVM goes through the native path and uses the
-	 * IPI mechanism.
-	 */
-	if (xen_hvm_domain())
-		return 0;
+	return 0;
+
+ fail:
+	xen_smp_intr_free(cpu);
+	return rc;
+}
+
+int xen_smp_intr_init_pv(unsigned int cpu)
+{
+	int rc;
+	char *callfunc_name, *pmu_name;
 
 	callfunc_name = kasprintf(GFP_KERNEL, "irqwork%d", cpu);
 	rc = bind_ipi_to_irqhandler(XEN_IRQ_WORK_VECTOR,
@@ -234,7 +241,7 @@ int xen_smp_intr_init(unsigned int cpu)
 	return 0;
 
  fail:
-	xen_smp_intr_free(cpu);
+	xen_smp_intr_free_pv(cpu);
 	return rc;
 }
 
arch/x86/xen/smp.h +8 -0
index 9beef33..33320ce 100644
@@ -11,6 +11,8 @@ extern void xen_send_IPI_self(int vector);
 
 extern int xen_smp_intr_init(unsigned int cpu);
 extern void xen_smp_intr_free(unsigned int cpu);
+int xen_smp_intr_init_pv(unsigned int cpu);
+void xen_smp_intr_free_pv(unsigned int cpu);
 
 #else /* CONFIG_SMP */
 
@@ -19,6 +21,12 @@ static inline int xen_smp_intr_init(unsigned int cpu)
 	return 0;
 }
 static inline void xen_smp_intr_free(unsigned int cpu) {}
+
+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 /* CONFIG_SMP */
 
 #endif
Signature · 7 lines
2.9.3


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

PATCH v3 8/21 x86/xen: split xen_smp_prepare_boot_cpu()

In reply to Vitaly Kuznetsov

Split xen_smp_prepare_boot_cpu() into xen_pv_smp_prepare_boot_cpu() and xen_hvm_smp_prepare_boot_cpu() to support further splitting of smp.c.

---
 arch/x86/xen/smp.c | 49 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 30 insertions(+), 19 deletions(-)
arch/x86/xen/smp.c +30 -19
index 9be801e..d068b14 100644
@@ -297,35 +297,46 @@ static void __init xen_filter_cpu_maps(void)
 
 }
 
-static void __init xen_smp_prepare_boot_cpu(void)
+static void __init xen_pv_smp_prepare_boot_cpu(void)
 {
 	BUG_ON(smp_processor_id() != 0);
 	native_smp_prepare_boot_cpu();
 
-	if (xen_pv_domain()) {
-		if (!xen_feature(XENFEAT_writable_page_tables))
-			/* We've switched to the "real" per-cpu gdt, so make
-			 * sure the old memory can be recycled. */
-			make_lowmem_page_readwrite(xen_initial_gdt);
+	if (!xen_feature(XENFEAT_writable_page_tables))
+		/* We've switched to the "real" per-cpu gdt, so make
+		 * sure the old memory can be recycled. */
+		make_lowmem_page_readwrite(xen_initial_gdt);
 
 #ifdef CONFIG_X86_32
-		/*
-		 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
-		 * expects __USER_DS
-		 */
-		loadsegment(ds, __USER_DS);
-		loadsegment(es, __USER_DS);
+	/*
+	 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
+	 * expects __USER_DS
+	 */
+	loadsegment(ds, __USER_DS);
+	loadsegment(es, __USER_DS);
 #endif
 
-		xen_filter_cpu_maps();
-		xen_setup_vcpu_info_placement();
-	}
+	xen_filter_cpu_maps();
+	xen_setup_vcpu_info_placement();
+
+	/*
+	 * The alternative logic (which patches the unlock/lock) runs before
+	 * the smp bootup up code is activated. Hence we need to set this up
+	 * the core kernel is being patched. Otherwise we will have only
+	 * modules patched but not core code.
+	 */
+	xen_init_spinlocks();
+}
+
+static void __init xen_hvm_smp_prepare_boot_cpu(void)
+{
+	BUG_ON(smp_processor_id() != 0);
+	native_smp_prepare_boot_cpu();
 
 	/*
 	 * Setup vcpu_info for boot CPU.
 	 */
-	if (xen_hvm_domain())
-		xen_vcpu_setup(0);
+	xen_vcpu_setup(0);
 
 	/*
 	 * The alternative logic (which patches the unlock/lock) runs before
@@ -717,7 +728,7 @@ static irqreturn_t xen_irq_work_interrupt(int irq, void *dev_id)
 }
 
 static const struct smp_ops xen_smp_ops __initconst = {
-	.smp_prepare_boot_cpu = xen_smp_prepare_boot_cpu,
+	.smp_prepare_boot_cpu = xen_pv_smp_prepare_boot_cpu,
 	.smp_prepare_cpus = xen_smp_prepare_cpus,
 	.smp_cpus_done = xen_smp_cpus_done,
 
@@ -754,5 +765,5 @@ void __init xen_hvm_smp_init(void)
 	smp_ops.cpu_die = xen_cpu_die;
 	smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
 	smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
-	smp_ops.smp_prepare_boot_cpu = xen_smp_prepare_boot_cpu;
+	smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
 }
Signature · 7 lines
2.9.3


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

PATCH v3 9/21 x86/xen: split xen_cpu_die()

In reply to Vitaly Kuznetsov

Split xen_cpu_die() into xen_pv_cpu_die() and xen_hvm_cpu_die() to support further splitting of smp.c.

---
 arch/x86/xen/smp.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
arch/x86/xen/smp.c +20 -6
index d068b14..53bf0a4 100644
@@ -514,10 +514,10 @@ static int xen_cpu_disable(void)
 	return 0;
 }
 
-static void xen_cpu_die(unsigned int cpu)
+static void xen_pv_cpu_die(unsigned int cpu)
 {
-	while (xen_pv_domain() && HYPERVISOR_vcpu_op(VCPUOP_is_up,
-						     xen_vcpu_nr(cpu), NULL)) {
+	while (HYPERVISOR_vcpu_op(VCPUOP_is_up,
+				  xen_vcpu_nr(cpu), NULL)) {
 		__set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(HZ/10);
 	}
@@ -530,6 +530,15 @@ static void xen_cpu_die(unsigned int cpu)
 	}
 }
 
+static void xen_hvm_cpu_die(unsigned int cpu)
+{
+	if (common_cpu_die(cpu) == 0) {
+		xen_smp_intr_free(cpu);
+		xen_uninit_lock_cpu(cpu);
+		xen_teardown_timer(cpu);
+	}
+}
+
 static void xen_play_dead(void) /* used only with HOTPLUG_CPU */
 {
 	play_dead_common();
@@ -552,7 +561,12 @@ static int xen_cpu_disable(void)
 	return -ENOSYS;
 }
 
-static void xen_cpu_die(unsigned int cpu)
+static void xen_pv_cpu_die(unsigned int cpu)
+{
+	BUG();
+}
+
+static void xen_hvm_cpu_die(unsigned int cpu)
 {
 	BUG();
 }
@@ -733,7 +747,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
 	.smp_cpus_done = xen_smp_cpus_done,
 
 	.cpu_up = xen_cpu_up,
-	.cpu_die = xen_cpu_die,
+	.cpu_die = xen_pv_cpu_die,
 	.cpu_disable = xen_cpu_disable,
 	.play_dead = xen_play_dead,
 
@@ -762,7 +776,7 @@ void __init xen_hvm_smp_init(void)
 {
 	smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
 	smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
-	smp_ops.cpu_die = xen_cpu_die;
+	smp_ops.cpu_die = xen_hvm_cpu_die;
 	smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
 	smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
 	smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
Signature · 7 lines
2.9.3


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

PATCH v3 9/21 x86/xen: split xen_cpu_die()

In reply to Vitaly Kuznetsov

Split xen_cpu_die() into xen_pv_cpu_die() and xen_hvm_cpu_die() to support further splitting of smp.c.

---
 arch/x86/xen/smp.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
arch/x86/xen/smp.c +20 -6
index d068b14..53bf0a4 100644
@@ -514,10 +514,10 @@ static int xen_cpu_disable(void)
 	return 0;
 }
 
-static void xen_cpu_die(unsigned int cpu)
+static void xen_pv_cpu_die(unsigned int cpu)
 {
-	while (xen_pv_domain() && HYPERVISOR_vcpu_op(VCPUOP_is_up,
-						     xen_vcpu_nr(cpu), NULL)) {
+	while (HYPERVISOR_vcpu_op(VCPUOP_is_up,
+				  xen_vcpu_nr(cpu), NULL)) {
 		__set_current_state(TASK_UNINTERRUPTIBLE);
 		schedule_timeout(HZ/10);
 	}
@@ -530,6 +530,15 @@ static void xen_cpu_die(unsigned int cpu)
 	}
 }
 
+static void xen_hvm_cpu_die(unsigned int cpu)
+{
+	if (common_cpu_die(cpu) == 0) {
+		xen_smp_intr_free(cpu);
+		xen_uninit_lock_cpu(cpu);
+		xen_teardown_timer(cpu);
+	}
+}
+
 static void xen_play_dead(void) /* used only with HOTPLUG_CPU */
 {
 	play_dead_common();
@@ -552,7 +561,12 @@ static int xen_cpu_disable(void)
 	return -ENOSYS;
 }
 
-static void xen_cpu_die(unsigned int cpu)
+static void xen_pv_cpu_die(unsigned int cpu)
+{
+	BUG();
+}
+
+static void xen_hvm_cpu_die(unsigned int cpu)
 {
 	BUG();
 }
@@ -733,7 +747,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
 	.smp_cpus_done = xen_smp_cpus_done,
 
 	.cpu_up = xen_cpu_up,
-	.cpu_die = xen_cpu_die,
+	.cpu_die = xen_pv_cpu_die,
 	.cpu_disable = xen_cpu_disable,
 	.play_dead = xen_play_dead,
 
@@ -762,7 +776,7 @@ void __init xen_hvm_smp_init(void)
 {
 	smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
 	smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
-	smp_ops.cpu_die = xen_cpu_die;
+	smp_ops.cpu_die = xen_hvm_cpu_die;
 	smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
 	smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
 	smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
Signature · 1 line
2.9.3
#19 lore raw

PATCH v3 10/21 x86/xen: split off smp_hvm.c

In reply to Vitaly Kuznetsov

Move PVHVM related code to smp_hvm.c. Drop 'static' qualifier from xen_smp_send_reschedule(), xen_smp_send_call_function_ipi(), xen_smp_send_call_function_single_ipi(), these functions will be moved to common smp code when smp_pv.c is split.

---
Changes since v2:
drop 'extern' qualifier newly added prototypes to smp.h [Juergen Gross]

---
 arch/x86/xen/Kconfig   |  4 ++++
 arch/x86/xen/Makefile  |  1 +
 arch/x86/xen/smp.c     | 57 +++----------------------------------------------
 arch/x86/xen/smp.h     |  3 +++
 arch/x86/xen/smp_hvm.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 69 insertions(+), 54 deletions(-)
 create mode 100644 arch/x86/xen/smp_hvm.c
arch/x86/xen/Kconfig +4 -0
index 5bb1434..6d15c34 100644
@@ -37,6 +37,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 +1 -0
index 5ca8d3eb..bc7df8c 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
 obj-$(CONFIG_EVENT_TRACING) += trace.o
 
 obj-$(CONFIG_SMP)		+= smp.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/smp.c +3 -54

96 lines not on this page · raw message

arch/x86/xen/smp.h +3 -0
index 33320ce..2e8cd56 100644
@@ -14,6 +14,9 @@ extern void xen_smp_intr_free(unsigned int cpu);
 int xen_smp_intr_init_pv(unsigned int cpu);
 void xen_smp_intr_free_pv(unsigned int cpu);
 
+void xen_smp_send_reschedule(int cpu);
+void xen_smp_send_call_function_ipi(const struct cpumask *mask);
+void xen_smp_send_call_function_single_ipi(int cpu);
 #else /* CONFIG_SMP */
 
 static inline int xen_smp_intr_init(unsigned int cpu)
arch/x86/xen/smp_hvm.c new file +58 -0

58 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
#20 lore raw

PATCH v3 11/21 x86/xen: split off smp_pv.c

In reply to Vitaly Kuznetsov

Basically, smp.c is renamed to smp_pv.c and some code moved out to common smp.c. struct xen_common_irq delcaration ended up in smp.h.

---
 arch/x86/xen/Makefile |   2 +-
 arch/x86/xen/smp.c    | 488 +-----------------------------------------------
 arch/x86/xen/smp.h    |   5 +
 arch/x86/xen/smp_pv.c | 500 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 509 insertions(+), 486 deletions(-)
 create mode 100644 arch/x86/xen/smp_pv.c
arch/x86/xen/Makefile +1 -1
index bc7df8c..ebf3522 100644
@@ -20,7 +20,7 @@ obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
 
 obj-$(CONFIG_EVENT_TRACING) += trace.o
 
-obj-$(CONFIG_SMP)		+= smp.o
+obj-$(CONFIG_SMP)		+= smp.o smp_pv.o
 obj-$(CONFIG_XEN_PVHVM_SMP)  	+= smp_hvm.o
 obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o
 obj-$(CONFIG_XEN_DEBUG_FS)	+= debugfs.o
arch/x86/xen/smp.c +3 -485

527 lines not on this page · raw message

arch/x86/xen/smp.h +5 -0
index 2e8cd56..8ebb6ac 100644
@@ -17,6 +17,11 @@ void xen_smp_intr_free_pv(unsigned int cpu);
 void xen_smp_send_reschedule(int cpu);
 void xen_smp_send_call_function_ipi(const struct cpumask *mask);
 void xen_smp_send_call_function_single_ipi(int cpu);
+
+struct xen_common_irq {
+	int irq;
+	char *name;
+};
 #else /* CONFIG_SMP */
 
 static inline int xen_smp_intr_init(unsigned int cpu)
arch/x86/xen/smp_pv.c new file +500 -0

500 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
#21 lore raw

PATCH v3 12/21 x86/xen: split off mmu_hvm.c

In reply to Vitaly Kuznetsov

Move PVHVM related code to mmu_hvm.c.

---
 arch/x86/xen/Makefile  |  2 +-
 arch/x86/xen/mmu.c     | 74 ----------------------------------------------
 arch/x86/xen/mmu_hvm.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+), 75 deletions(-)
 create mode 100644 arch/x86/xen/mmu_hvm.c
arch/x86/xen/Makefile +1 -1
index ebf3522..6a95a8b 100644
@@ -15,7 +15,7 @@ obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
 			grant-table.o suspend.o platform-pci-unplug.o \
 			p2m.o apic.o pmu.o enlighten_pv.o
 
-obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.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 +0 -74

80 lines not on this page · raw message

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

79 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
#22 lore raw

PATCH v3 13/21 x86/xen: split off mmu_pv.c

In reply to Vitaly Kuznetsov

Basically, mmu.c is renamed to mmu_pv.c and some code moved out to common mmu.c.

---
 arch/x86/xen/Makefile |    4 +-
 arch/x86/xen/mmu.c    | 2702 +------------------------------------------------
 arch/x86/xen/mmu_pv.c | 2635 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 2674 insertions(+), 2667 deletions(-)
 create mode 100644 arch/x86/xen/mmu_pv.c
arch/x86/xen/Makefile +2 -2
index 6a95a8b..8da1ca9 100644
@@ -8,12 +8,12 @@ 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 \
 			grant-table.o suspend.o platform-pci-unplug.o \
-			p2m.o apic.o pmu.o enlighten_pv.o
+			p2m.o apic.o pmu.o enlighten_pv.o mmu_pv.o
 
 obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o
 obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
arch/x86/xen/mmu.c +37 -2665

2,737 lines not on this page · raw message

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

249 lines not on this page · 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.

#23 lore raw

PATCH v3 14/21 x86/xen: split suspend.c for PV and PVHVM guests

In reply to Vitaly Kuznetsov

Slit the code in suspend.c into suspend_pv.c and suspend_hvm.c.

---
Changes since v2:
#include <asm/fixmap.h> added to suspend_pv.c [kbuild test robot]

---
 arch/x86/xen/Makefile      |  3 ++-
 arch/x86/xen/suspend.c     | 54 ----------------------------------------------
 arch/x86/xen/suspend_hvm.c | 22 +++++++++++++++++++
 arch/x86/xen/suspend_pv.c  | 46 +++++++++++++++++++++++++++++++++++++++
 arch/x86/xen/xen-ops.h     | 13 +++++++++++
 5 files changed, 83 insertions(+), 55 deletions(-)
 create mode 100644 arch/x86/xen/suspend_hvm.c
 create mode 100644 arch/x86/xen/suspend_pv.c
arch/x86/xen/Makefile +2 -1
index 8da1ca9..cf8d6c5 100644
@@ -15,7 +15,8 @@ obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
 			grant-table.o suspend.o platform-pci-unplug.o \
 			p2m.o apic.o pmu.o enlighten_pv.o mmu_pv.o
 
-obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o
+obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o suspend_hvm.o
+obj-$(CONFIG_XEN_PV)			+= suspend_pv.o
 obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
 
 obj-$(CONFIG_EVENT_TRACING) += trace.o
arch/x86/xen/suspend.c +0 -54

60 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 +46 -0

46 lines not on this page · raw message

arch/x86/xen/xen-ops.h +13 -0
index 0dd8dd2..d939e3e 100644
@@ -155,5 +155,18 @@ void xen_pin_vcpu(int cpu);
 
 void xen_reboot(int reason);
 void xen_emergency_restart(void);
+#ifdef CONFIG_XEN_PV
+void xen_pv_pre_suspend(void);
+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
+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
#24 lore raw

PATCH v3 14/21 x86/xen: split suspend.c for PV and PVHVM guests

In reply to Vitaly Kuznetsov

Slit the code in suspend.c into suspend_pv.c and suspend_hvm.c.

---
Changes since v2:
#include <asm/fixmap.h> added to suspend_pv.c [kbuild test robot]

---
 arch/x86/xen/Makefile      |  3 ++-
 arch/x86/xen/suspend.c     | 54 ----------------------------------------------
 arch/x86/xen/suspend_hvm.c | 22 +++++++++++++++++++
 arch/x86/xen/suspend_pv.c  | 46 +++++++++++++++++++++++++++++++++++++++
 arch/x86/xen/xen-ops.h     | 13 +++++++++++
 5 files changed, 83 insertions(+), 55 deletions(-)
 create mode 100644 arch/x86/xen/suspend_hvm.c
 create mode 100644 arch/x86/xen/suspend_pv.c
arch/x86/xen/Makefile +2 -1
index 8da1ca9..cf8d6c5 100644
@@ -15,7 +15,8 @@ obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
 			grant-table.o suspend.o platform-pci-unplug.o \
 			p2m.o apic.o pmu.o enlighten_pv.o mmu_pv.o
 
-obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o
+obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o suspend_hvm.o
+obj-$(CONFIG_XEN_PV)			+= suspend_pv.o
 obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
 
 obj-$(CONFIG_EVENT_TRACING) += trace.o
arch/x86/xen/suspend.c +0 -54

60 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 +46 -0

46 lines not on this page · raw message

arch/x86/xen/xen-ops.h +13 -0
index 0dd8dd2..d939e3e 100644
@@ -155,5 +155,18 @@ void xen_pin_vcpu(int cpu);
 
 void xen_reboot(int reason);
 void xen_emergency_restart(void);
+#ifdef CONFIG_XEN_PV
+void xen_pv_pre_suspend(void);
+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
+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 · 1 line
2.9.3
#25 lore raw

PATCH v3 15/21 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 | 6 +++---
 arch/x86/xen/pmu.h    | 5 +++++
 3 files changed, 9 insertions(+), 4 deletions(-)
arch/x86/xen/Kconfig +1 -1
index 6d15c34..3bcb091 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
@@ -19,6 +18,7 @@ config XEN_PV
 	default y
 	depends on XEN
 	select XEN_HAVE_PVMMU
+	select XEN_HAVE_VPMU
 	help
 	  Support running as a Xen PV guest.
 
arch/x86/xen/Makefile +3 -3
index cf8d6c5..f610651 100644
@@ -10,13 +10,13 @@ nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_enlighten_pv.o		:= $(nostackp)
 CFLAGS_mmu_pv.o		:= $(nostackp)
 
-obj-y		:= enlighten.o setup.o multicalls.o mmu.o irq.o \
+obj-y		:= enlighten.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 enlighten_pv.o mmu_pv.o
+			p2m.o enlighten_pv.o mmu_pv.o
 
 obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o suspend_hvm.o
-obj-$(CONFIG_XEN_PV)			+= suspend_pv.o
+obj-$(CONFIG_XEN_PV)			+= setup.o apic.o pmu.o suspend_pv.o
 obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
 
 obj-$(CONFIG_EVENT_TRACING) += trace.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
#26 lore raw

PATCH v3 16/21 x86/xen: define startup_xen for XEN PV only

In reply to Vitaly Kuznetsov

startup_xen references PV-only code, decorate it with #ifdef CONFIG_XEN_PV to make PV-free builds possible.

---
 arch/x86/xen/xen-head.S | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/xen/xen-head.S +4 -0
index 37794e4..72a8e6a 100644
@@ -16,6 +16,7 @@
 #include <xen/interface/xen-mca.h>
 #include <asm/xen/interface.h>
 
+#ifdef CONFIG_XEN_PV
 	__INIT
 ENTRY(startup_xen)
 	cld
@@ -34,6 +35,7 @@ ENTRY(startup_xen)
 	jmp xen_start_kernel
 
 	__FINIT
+#endif
 
 .pushsection .text
 	.balign PAGE_SIZE
@@ -58,7 +60,9 @@ ENTRY(hypercall_page)
 	/* Map the p2m table to a 512GB-aligned user address. */
 	ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M,       .quad PGDIR_SIZE)
 #endif
+#ifdef CONFIG_XEN_PV
 	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          _ASM_PTR startup_xen)
+#endif
 	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
 	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,
 		.ascii "!writable_page_tables|pae_pgdir_above_4gb")
Signature · 7 lines
2.9.3


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

PATCH v3 17/21 x86/xen: create stubs for HVM-only builds in page.h

In reply to Vitaly Kuznetsov

__pfn_to_mfn() is only used from PV code (mmu_pv.c, p2m.c) and from page.h where all functions calling it check for xen_feature(XENFEAT_auto_translated_physmap) first so we can replace it with any stub to make build happy.

set_foreign_p2m_mapping()/clear_foreign_p2m_mapping() are used from grant-table.c but only if !xen_feature(XENFEAT_auto_translated_physmap).

---
 arch/x86/include/asm/xen/page.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
arch/x86/include/asm/xen/page.h +25 -0
index 33cbd3d..0bf4bb34 100644
@@ -51,12 +51,30 @@ extern bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
 extern unsigned long __init set_phys_range_identity(unsigned long pfn_s,
 						    unsigned long pfn_e);
 
+#ifdef CONFIG_XEN_PV
 extern 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);
 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
+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
 
 /*
  * Helper functions to write or read unsigned long values to/from
@@ -72,6 +90,7 @@ static inline int xen_safe_read_ulong(unsigned long *addr, unsigned long *val)
 	return __get_user(*val, (unsigned long __user *)addr);
 }
 
+#ifdef CONFIG_XEN_PV
 /*
  * When to use pfn_to_mfn(), __pfn_to_mfn() or get_phys_to_machine():
  * - pfn_to_mfn() returns either INVALID_P2M_ENTRY or the mfn. No indicator
@@ -98,6 +117,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)
 {
Signature · 7 lines
2.9.3


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

PATCH v3 18/21 xen/balloon: decorate PV-only parts with #ifdef CONFIG_XEN_PV

In reply to Vitaly Kuznetsov

Balloon driver uses several PV-only concepts (xen_start_info, xen_extra_mem,..) and it seems the simpliest solution to make HVM-only build happy is to decorate these parts with #ifdefs.

---
 drivers/xen/balloon.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/xen/balloon.c +20 -10
index a6d4378..50dcb68 100644
@@ -709,6 +709,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
 }
 EXPORT_SYMBOL(free_xenballooned_pages);
 
+#ifdef CONFIG_XEN_PV
 static void __init balloon_add_region(unsigned long start_pfn,
 				      unsigned long pages)
 {
@@ -732,19 +733,22 @@ static void __init balloon_add_region(unsigned long start_pfn,
 
 	balloon_stats.total_pages += extra_pfn_end - start_pfn;
 }
+#endif
 
 static int __init balloon_init(void)
 {
-	int i;
-
 	if (!xen_domain())
 		return -ENODEV;
 
 	pr_info("Initialising balloon driver\n");
 
+#ifdef CONFIG_XEN_PV
 	balloon_stats.current_pages = xen_pv_domain()
 		? min(xen_start_info->nr_pages - xen_released_pages, max_pfn)
 		: get_num_physpages();
+#else
+	balloon_stats.current_pages = get_num_physpages();
+#endif
 	balloon_stats.target_pages  = balloon_stats.current_pages;
 	balloon_stats.balloon_low   = 0;
 	balloon_stats.balloon_high  = 0;
@@ -761,14 +765,20 @@ static int __init balloon_init(void)
 	register_sysctl_table(xen_root);
 #endif
 
-	/*
-	 * Initialize the balloon with pages from the extra memory
-	 * regions (see arch/x86/xen/setup.c).
-	 */
-	for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++)
-		if (xen_extra_mem[i].n_pfns)
-			balloon_add_region(xen_extra_mem[i].start_pfn,
-					   xen_extra_mem[i].n_pfns);
+#ifdef CONFIG_XEN_PV
+	{
+		int i;
+
+		/*
+		 * Initialize the balloon with pages from the extra memory
+		 * regions (see arch/x86/xen/setup.c).
+		 */
+		for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++)
+			if (xen_extra_mem[i].n_pfns)
+				balloon_add_region(xen_extra_mem[i].start_pfn,
+						   xen_extra_mem[i].n_pfns);
+	}
+#endif
 
 	return 0;
 }
Signature · 7 lines
2.9.3


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

PATCH v3 18/21 xen/balloon: decorate PV-only parts with #ifdef CONFIG_XEN_PV

In reply to Vitaly Kuznetsov

Balloon driver uses several PV-only concepts (xen_start_info, xen_extra_mem,..) and it seems the simpliest solution to make HVM-only build happy is to decorate these parts with #ifdefs.

---
 drivers/xen/balloon.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/xen/balloon.c +20 -10
index a6d4378..50dcb68 100644
@@ -709,6 +709,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
 }
 EXPORT_SYMBOL(free_xenballooned_pages);
 
+#ifdef CONFIG_XEN_PV
 static void __init balloon_add_region(unsigned long start_pfn,
 				      unsigned long pages)
 {
@@ -732,19 +733,22 @@ static void __init balloon_add_region(unsigned long start_pfn,
 
 	balloon_stats.total_pages += extra_pfn_end - start_pfn;
 }
+#endif
 
 static int __init balloon_init(void)
 {
-	int i;
-
 	if (!xen_domain())
 		return -ENODEV;
 
 	pr_info("Initialising balloon driver\n");
 
+#ifdef CONFIG_XEN_PV
 	balloon_stats.current_pages = xen_pv_domain()
 		? min(xen_start_info->nr_pages - xen_released_pages, max_pfn)
 		: get_num_physpages();
+#else
+	balloon_stats.current_pages = get_num_physpages();
+#endif
 	balloon_stats.target_pages  = balloon_stats.current_pages;
 	balloon_stats.balloon_low   = 0;
 	balloon_stats.balloon_high  = 0;
@@ -761,14 +765,20 @@ static int __init balloon_init(void)
 	register_sysctl_table(xen_root);
 #endif
 
-	/*
-	 * Initialize the balloon with pages from the extra memory
-	 * regions (see arch/x86/xen/setup.c).
-	 */
-	for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++)
-		if (xen_extra_mem[i].n_pfns)
-			balloon_add_region(xen_extra_mem[i].start_pfn,
-					   xen_extra_mem[i].n_pfns);
+#ifdef CONFIG_XEN_PV
+	{
+		int i;
+
+		/*
+		 * Initialize the balloon with pages from the extra memory
+		 * regions (see arch/x86/xen/setup.c).
+		 */
+		for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++)
+			if (xen_extra_mem[i].n_pfns)
+				balloon_add_region(xen_extra_mem[i].start_pfn,
+						   xen_extra_mem[i].n_pfns);
+	}
+#endif
 
 	return 0;
 }
Signature · 1 line
2.9.3
#30 lore raw

PATCH v3 19/21 xen: create xen_create/destroy_contiguous_region() stubs for PVHVM only builds

In reply to Vitaly Kuznetsov

xen_create_contiguous_region()/xen_create_contiguous_region() are PV-only, they both contain xen_feature(XENFEAT_auto_translated_physmap) check and bail in the very beginning.

---
 include/xen/xen-ops.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
include/xen/xen-ops.h +14 -0
index b5486e6..f939114 100644
@@ -34,11 +34,25 @@ u64 xen_steal_clock(int cpu);
 int xen_setup_shutdown_event(void);
 
 extern unsigned long *xen_contiguous_bitmap;
+
+#ifdef CONFIG_XEN_PV
 int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
 				unsigned int address_bits,
 				dma_addr_t *dma_handle);
 
 void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order);
+#else
+static inline int xen_create_contiguous_region(phys_addr_t pstart,
+					       unsigned int order,
+					       unsigned int address_bits,
+					       dma_addr_t *dma_handle)
+{
+	return 0;
+}
+
+static inline void xen_destroy_contiguous_region(phys_addr_t pstart,
+						 unsigned int order) { }
+#endif
 
 struct vm_area_struct;
 
Signature · 7 lines
2.9.3


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

PATCH v3 19/21 xen: create xen_create/destroy_contiguous_region() stubs for PVHVM only builds

In reply to Vitaly Kuznetsov

xen_create_contiguous_region()/xen_create_contiguous_region() are PV-only, they both contain xen_feature(XENFEAT_auto_translated_physmap) check and bail in the very beginning.

---
 include/xen/xen-ops.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
include/xen/xen-ops.h +14 -0
index b5486e6..f939114 100644
@@ -34,11 +34,25 @@ u64 xen_steal_clock(int cpu);
 int xen_setup_shutdown_event(void);
 
 extern unsigned long *xen_contiguous_bitmap;
+
+#ifdef CONFIG_XEN_PV
 int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
 				unsigned int address_bits,
 				dma_addr_t *dma_handle);
 
 void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order);
+#else
+static inline int xen_create_contiguous_region(phys_addr_t pstart,
+					       unsigned int order,
+					       unsigned int address_bits,
+					       dma_addr_t *dma_handle)
+{
+	return 0;
+}
+
+static inline void xen_destroy_contiguous_region(phys_addr_t pstart,
+						 unsigned int order) { }
+#endif
 
 struct vm_area_struct;
 
Signature · 1 line
2.9.3
#32 lore raw

PATCH v3 20/21 x86/xen: enable PVHVM-only builds

In reply to Vitaly Kuznetsov

Now everything is in place and we can move PV-only code under CONFIG_XEN_PV. CONFIG_XEN_PV_SMP is created to support the change.

---
 arch/x86/xen/Kconfig  | 4 ++++
 arch/x86/xen/Makefile | 9 +++++----
 2 files changed, 9 insertions(+), 4 deletions(-)
arch/x86/xen/Kconfig +4 -0
index 3bcb091..0279876 100644
@@ -22,6 +22,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
arch/x86/xen/Makefile +5 -4
index f610651..fffb0a1 100644
@@ -12,16 +12,17 @@ CFLAGS_mmu_pv.o		:= $(nostackp)
 
 obj-y		:= enlighten.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 enlighten_pv.o mmu_pv.o
+			grant-table.o suspend.o platform-pci-unplug.o
 
 obj-$(CONFIG_XEN_PVHVM)		+= enlighten_hvm.o mmu_hvm.o suspend_hvm.o
-obj-$(CONFIG_XEN_PV)			+= setup.o apic.o pmu.o suspend_pv.o
+obj-$(CONFIG_XEN_PV)			+= setup.o apic.o pmu.o suspend_pv.o \
+						p2m.o enlighten_pv.o mmu_pv.o
 obj-$(CONFIG_XEN_PVH)			+= enlighten_pvh.o
 
 obj-$(CONFIG_EVENT_TRACING) += trace.o
 
-obj-$(CONFIG_SMP)		+= smp.o smp_pv.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
Signature · 7 lines
2.9.3


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

PATCH v3 21/21 x86/xen: rename some PV-only functions in smp_pv.c

In reply to Vitaly Kuznetsov

After code split between PV and HVM some functions in xen_smp_ops have xen_pv_ prefix and some only xen_ which makes them look like they're common for both PV and HVM while they're not. Rename all the rest to have xen_pv_ prefix.

---
 arch/x86/xen/smp_pv.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
arch/x86/xen/smp_pv.c +14 -14
index 3a61e0e..39b130f 100644
@@ -221,7 +221,7 @@ static void __init xen_pv_smp_prepare_boot_cpu(void)
 	xen_init_spinlocks();
 }
 
-static void __init xen_smp_prepare_cpus(unsigned int max_cpus)
+static void __init xen_pv_smp_prepare_cpus(unsigned int max_cpus)
 {
 	unsigned cpu;
 	unsigned int i;
@@ -337,7 +337,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 	return 0;
 }
 
-static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
+static int xen_pv_cpu_up(unsigned int cpu, struct task_struct *idle)
 {
 	int rc;
 
@@ -371,12 +371,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
 	return 0;
 }
 
-static void xen_smp_cpus_done(unsigned int max_cpus)
+static void xen_pv_smp_cpus_done(unsigned int max_cpus)
 {
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-static int xen_cpu_disable(void)
+static int xen_pv_cpu_disable(void)
 {
 	unsigned int cpu = smp_processor_id();
 	if (cpu == 0)
@@ -404,7 +404,7 @@ static void xen_pv_cpu_die(unsigned int cpu)
 	}
 }
 
-static void xen_play_dead(void) /* used only with HOTPLUG_CPU */
+static void xen_pv_play_dead(void) /* used only with HOTPLUG_CPU */
 {
 	play_dead_common();
 	HYPERVISOR_vcpu_op(VCPUOP_down, xen_vcpu_nr(smp_processor_id()), NULL);
@@ -421,7 +421,7 @@ static void xen_play_dead(void) /* used only with HOTPLUG_CPU */
 }
 
 #else /* !CONFIG_HOTPLUG_CPU */
-static int xen_cpu_disable(void)
+static int xen_pv_cpu_disable(void)
 {
 	return -ENOSYS;
 }
@@ -431,7 +431,7 @@ static void xen_pv_cpu_die(unsigned int cpu)
 	BUG();
 }
 
-static void xen_play_dead(void)
+static void xen_pv_play_dead(void)
 {
 	BUG();
 }
@@ -451,7 +451,7 @@ static void stop_self(void *v)
 	BUG();
 }
 
-static void xen_stop_other_cpus(int wait)
+static void xen_pv_stop_other_cpus(int wait)
 {
 	smp_call_function(stop_self, NULL, wait);
 }
@@ -478,15 +478,15 @@ static irqreturn_t xen_irq_work_interrupt(int irq, void *dev_id)
 
 static const struct smp_ops xen_smp_ops __initconst = {
 	.smp_prepare_boot_cpu = xen_pv_smp_prepare_boot_cpu,
-	.smp_prepare_cpus = xen_smp_prepare_cpus,
-	.smp_cpus_done = xen_smp_cpus_done,
+	.smp_prepare_cpus = xen_pv_smp_prepare_cpus,
+	.smp_cpus_done = xen_pv_smp_cpus_done,
 
-	.cpu_up = xen_cpu_up,
+	.cpu_up = xen_pv_cpu_up,
 	.cpu_die = xen_pv_cpu_die,
-	.cpu_disable = xen_cpu_disable,
-	.play_dead = xen_play_dead,
+	.cpu_disable = xen_pv_cpu_disable,
+	.play_dead = xen_pv_play_dead,
 
-	.stop_other_cpus = xen_stop_other_cpus,
+	.stop_other_cpus = xen_pv_stop_other_cpus,
 	.smp_send_reschedule = xen_smp_send_reschedule,
 
 	.send_call_func_ipi = xen_smp_send_call_function_ipi,
Signature · 7 lines
2.9.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
maintainer
#34 lore raw
In reply to Vitaly Kuznetsov
Quoted 11 lines · Vitaly Kuznetsov

Changes since v2:
- Rebase to 4.11.0-rc1+
- XEN_HAVE_PVMMU moved to config XEN_PV [Juergen Gross]
- .pin_vcpu kept for x86_hyper_xen_hvm to support PVH Dom0 in future [Juergen Gross]
- 'extern' qualifiers dropped from newly introduced function prototypes in headers [Juergen Gross]
- A couple of #includes added to address build issues with different configs [kbuild test robot].
- Juergen reviewed-bys added (hope they stand with the above mentioned changes).

They do.

In case nobody objects I'll take this series for 4.12.

Juergen

Quoted 87 lines

The series can also be pulled from https://github.com/vittyvk/linux.git
(xen_pv_hvm_split_v3 branch).

Some 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.

Some 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 (21):
x86/xen: separate PV and HVM hypervisors
x86/xen: globalize have_vcpu_info_placement
x86/xen: add CONFIG_XEN_PV to Kconfig
x86/xen: split off enlighten_pvh.c
x86/xen: split off enlighten_hvm.c
x86/xen: split off enlighten_pv.c
x86/xen: split xen_smp_intr_init()/xen_smp_intr_free() x86/xen: split xen_smp_prepare_boot_cpu()
x86/xen: split xen_cpu_die()
x86/xen: split off smp_hvm.c
x86/xen: split off smp_pv.c
x86/xen: split off mmu_hvm.c
x86/xen: split off mmu_pv.c
x86/xen: split suspend.c for PV and PVHVM guests x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV x86/xen: define startup_xen for XEN PV only
x86/xen: create stubs for HVM-only builds in page.h xen/balloon: decorate PV-only parts with #ifdef CONFIG_XEN_PV
xen: create xen_create/destroy_contiguous_region() stubs for PVHVM
only builds
x86/xen: enable PVHVM-only builds
x86/xen: rename some PV-only functions in smp_pv.c

 arch/x86/include/asm/hypervisor.h |    3 +-
 arch/x86/include/asm/xen/page.h   |   25 +
 arch/x86/kernel/cpu/hypervisor.c  |    7 +-
 arch/x86/kernel/process_64.c      |    2 +-
 arch/x86/xen/Kconfig              |   33 +-
 arch/x86/xen/Makefile             |   16 +-
 arch/x86/xen/enlighten.c          | 1925 +------------------------
 arch/x86/xen/enlighten_hvm.c      |  213 +++
 arch/x86/xen/enlighten_pv.c       | 1522 ++++++++++++++++++++
 arch/x86/xen/enlighten_pvh.c      |  115 ++
 arch/x86/xen/mmu.c                | 2776 +------------------------------------
 arch/x86/xen/mmu_hvm.c            |   79 ++
 arch/x86/xen/mmu_pv.c             | 2635 +++++++++++++++++++++++++++++++++++
 arch/x86/xen/pmu.h                |    5 +
 arch/x86/xen/smp.c                |  517 +------
 arch/x86/xen/smp.h                |   16 +
 arch/x86/xen/smp_hvm.c            |   58 +
 arch/x86/xen/smp_pv.c             |  500 +++++++
 arch/x86/xen/suspend.c            |   54 -
 arch/x86/xen/suspend_hvm.c        |   22 +
 arch/x86/xen/suspend_pv.c         |   46 +
 arch/x86/xen/xen-head.S           |    4 +
 arch/x86/xen/xen-ops.h            |   23 +
 drivers/xen/balloon.c             |   30 +-
 include/xen/xen-ops.h             |   14 +
 25 files changed, 5461 insertions(+), 5179 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_hvm.c
Quoted 9 lines
 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

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

maintainer
#35 lore raw
In reply to Vitaly Kuznetsov
Quoted 11 lines · Vitaly Kuznetsov

Changes since v2:
- Rebase to 4.11.0-rc1+
- XEN_HAVE_PVMMU moved to config XEN_PV [Juergen Gross]
- .pin_vcpu kept for x86_hyper_xen_hvm to support PVH Dom0 in future [Juergen Gross]
- 'extern' qualifiers dropped from newly introduced function prototypes in headers [Juergen Gross]
- A couple of #includes added to address build issues with different configs [kbuild test robot].
- Juergen reviewed-bys added (hope they stand with the above mentioned changes).

They do.

In case nobody objects I'll take this series for 4.12.

Juergen

Quoted 96 lines

The series can also be pulled from https://github.com/vittyvk/linux.git
(xen_pv_hvm_split_v3 branch).

Some 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.

Some 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 (21):
x86/xen: separate PV and HVM hypervisors
x86/xen: globalize have_vcpu_info_placement
x86/xen: add CONFIG_XEN_PV to Kconfig
x86/xen: split off enlighten_pvh.c
x86/xen: split off enlighten_hvm.c
x86/xen: split off enlighten_pv.c
x86/xen: split xen_smp_intr_init()/xen_smp_intr_free() x86/xen: split xen_smp_prepare_boot_cpu()
x86/xen: split xen_cpu_die()
x86/xen: split off smp_hvm.c
x86/xen: split off smp_pv.c
x86/xen: split off mmu_hvm.c
x86/xen: split off mmu_pv.c
x86/xen: split suspend.c for PV and PVHVM guests x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV x86/xen: define startup_xen for XEN PV only
x86/xen: create stubs for HVM-only builds in page.h xen/balloon: decorate PV-only parts with #ifdef CONFIG_XEN_PV
xen: create xen_create/destroy_contiguous_region() stubs for PVHVM
only builds
x86/xen: enable PVHVM-only builds
x86/xen: rename some PV-only functions in smp_pv.c

 arch/x86/include/asm/hypervisor.h |    3 +-
 arch/x86/include/asm/xen/page.h   |   25 +
 arch/x86/kernel/cpu/hypervisor.c  |    7 +-
 arch/x86/kernel/process_64.c      |    2 +-
 arch/x86/xen/Kconfig              |   33 +-
 arch/x86/xen/Makefile             |   16 +-
 arch/x86/xen/enlighten.c          | 1925 +------------------------
 arch/x86/xen/enlighten_hvm.c      |  213 +++
 arch/x86/xen/enlighten_pv.c       | 1522 ++++++++++++++++++++
 arch/x86/xen/enlighten_pvh.c      |  115 ++
 arch/x86/xen/mmu.c                | 2776 +------------------------------------
 arch/x86/xen/mmu_hvm.c            |   79 ++
 arch/x86/xen/mmu_pv.c             | 2635 +++++++++++++++++++++++++++++++++++
 arch/x86/xen/pmu.h                |    5 +
 arch/x86/xen/smp.c                |  517 +------
 arch/x86/xen/smp.h                |   16 +
 arch/x86/xen/smp_hvm.c            |   58 +
 arch/x86/xen/smp_pv.c             |  500 +++++++
 arch/x86/xen/suspend.c            |   54 -
 arch/x86/xen/suspend_hvm.c        |   22 +
 arch/x86/xen/suspend_pv.c         |   46 +
 arch/x86/xen/xen-head.S           |    4 +
 arch/x86/xen/xen-ops.h            |   23 +
 drivers/xen/balloon.c             |   30 +-
 include/xen/xen-ops.h             |   14 +
 25 files changed, 5461 insertions(+), 5179 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
#36 lore raw
Quoted 12 lines · Juergen Gross
Quoted 11 lines · Vitaly Kuznetsov

Changes since v2:
- Rebase to 4.11.0-rc1+
- XEN_HAVE_PVMMU moved to config XEN_PV [Juergen Gross]
- .pin_vcpu kept for x86_hyper_xen_hvm to support PVH Dom0 in future [Juergen Gross]
- 'extern' qualifiers dropped from newly introduced function prototypes in headers [Juergen Gross]
- A couple of #includes added to address build issues with different configs [kbuild test robot].
- Juergen reviewed-bys added (hope they stand with the above mentioned changes).

Quoted 3 lines

They do.

In case nobody objects I'll take this series for 4.12.

I haven't tried different combinations but the default set (all yes) passed my tests.

In the light of 5-level page tables patches the most interesting, I think, would be !CONFIG_XEN_PV.

-boris

Quoted 99 lines

Juergen

Quoted 95 lines

The series can also be pulled from https://github.com/vittyvk/linux.git
(xen_pv_hvm_split_v3 branch).

Some 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.

Some 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 (21):
x86/xen: separate PV and HVM hypervisors
x86/xen: globalize have_vcpu_info_placement
x86/xen: add CONFIG_XEN_PV to Kconfig
x86/xen: split off enlighten_pvh.c
x86/xen: split off enlighten_hvm.c
x86/xen: split off enlighten_pv.c
x86/xen: split xen_smp_intr_init()/xen_smp_intr_free() x86/xen: split xen_smp_prepare_boot_cpu()
x86/xen: split xen_cpu_die()
x86/xen: split off smp_hvm.c
x86/xen: split off smp_pv.c
x86/xen: split off mmu_hvm.c
x86/xen: split off mmu_pv.c
x86/xen: split suspend.c for PV and PVHVM guests x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV x86/xen: define startup_xen for XEN PV only
x86/xen: create stubs for HVM-only builds in page.h xen/balloon: decorate PV-only parts with #ifdef CONFIG_XEN_PV
xen: create xen_create/destroy_contiguous_region() stubs for PVHVM
only builds
x86/xen: enable PVHVM-only builds
x86/xen: rename some PV-only functions in smp_pv.c

 arch/x86/include/asm/hypervisor.h |    3 +-
 arch/x86/include/asm/xen/page.h   |   25 +
 arch/x86/kernel/cpu/hypervisor.c  |    7 +-
 arch/x86/kernel/process_64.c      |    2 +-
 arch/x86/xen/Kconfig              |   33 +-
 arch/x86/xen/Makefile             |   16 +-
 arch/x86/xen/enlighten.c          | 1925 +------------------------
 arch/x86/xen/enlighten_hvm.c      |  213 +++
 arch/x86/xen/enlighten_pv.c       | 1522 ++++++++++++++++++++
 arch/x86/xen/enlighten_pvh.c      |  115 ++
 arch/x86/xen/mmu.c                | 2776 +------------------------------------
 arch/x86/xen/mmu_hvm.c            |   79 ++
 arch/x86/xen/mmu_pv.c             | 2635 +++++++++++++++++++++++++++++++++++
 arch/x86/xen/pmu.h                |    5 +
 arch/x86/xen/smp.c                |  517 +------
 arch/x86/xen/smp.h                |   16 +
 arch/x86/xen/smp_hvm.c            |   58 +
 arch/x86/xen/smp_pv.c             |  500 +++++++
 arch/x86/xen/suspend.c            |   54 -
 arch/x86/xen/suspend_hvm.c        |   22 +
 arch/x86/xen/suspend_pv.c         |   46 +
 arch/x86/xen/xen-head.S           |    4 +
 arch/x86/xen/xen-ops.h            |   23 +
 drivers/xen/balloon.c             |   30 +-
 include/xen/xen-ops.h             |   14 +
 25 files changed, 5461 insertions(+), 5179 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

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

maintainer
#37 lore raw
In reply to Vitaly Kuznetsov
Quoted 98 lines · Vitaly Kuznetsov

Changes since v2:
- Rebase to 4.11.0-rc1+
- XEN_HAVE_PVMMU moved to config XEN_PV [Juergen Gross]
- .pin_vcpu kept for x86_hyper_xen_hvm to support PVH Dom0 in future [Juergen Gross]
- 'extern' qualifiers dropped from newly introduced function prototypes in headers [Juergen Gross]
- A couple of #includes added to address build issues with different configs [kbuild test robot].
- Juergen reviewed-bys added (hope they stand with the above mentioned changes).

The series can also be pulled from https://github.com/vittyvk/linux.git
(xen_pv_hvm_split_v3 branch).

Some 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.

Some 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 (21):
x86/xen: separate PV and HVM hypervisors
x86/xen: globalize have_vcpu_info_placement
x86/xen: add CONFIG_XEN_PV to Kconfig
x86/xen: split off enlighten_pvh.c
x86/xen: split off enlighten_hvm.c
x86/xen: split off enlighten_pv.c
x86/xen: split xen_smp_intr_init()/xen_smp_intr_free() x86/xen: split xen_smp_prepare_boot_cpu()
x86/xen: split xen_cpu_die()
x86/xen: split off smp_hvm.c
x86/xen: split off smp_pv.c
x86/xen: split off mmu_hvm.c
x86/xen: split off mmu_pv.c
x86/xen: split suspend.c for PV and PVHVM guests x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV x86/xen: define startup_xen for XEN PV only
x86/xen: create stubs for HVM-only builds in page.h xen/balloon: decorate PV-only parts with #ifdef CONFIG_XEN_PV
xen: create xen_create/destroy_contiguous_region() stubs for PVHVM
only builds
x86/xen: enable PVHVM-only builds
x86/xen: rename some PV-only functions in smp_pv.c

 arch/x86/include/asm/hypervisor.h |    3 +-
 arch/x86/include/asm/xen/page.h   |   25 +
 arch/x86/kernel/cpu/hypervisor.c  |    7 +-
 arch/x86/kernel/process_64.c      |    2 +-
 arch/x86/xen/Kconfig              |   33 +-
 arch/x86/xen/Makefile             |   16 +-
 arch/x86/xen/enlighten.c          | 1925 +------------------------
 arch/x86/xen/enlighten_hvm.c      |  213 +++
 arch/x86/xen/enlighten_pv.c       | 1522 ++++++++++++++++++++
 arch/x86/xen/enlighten_pvh.c      |  115 ++
 arch/x86/xen/mmu.c                | 2776 +------------------------------------
 arch/x86/xen/mmu_hvm.c            |   79 ++
 arch/x86/xen/mmu_pv.c             | 2635 +++++++++++++++++++++++++++++++++++
 arch/x86/xen/pmu.h                |    5 +
 arch/x86/xen/smp.c                |  517 +------
 arch/x86/xen/smp.h                |   16 +
 arch/x86/xen/smp_hvm.c            |   58 +
 arch/x86/xen/smp_pv.c             |  500 +++++++
 arch/x86/xen/suspend.c            |   54 -
 arch/x86/xen/suspend_hvm.c        |   22 +
 arch/x86/xen/suspend_pv.c         |   46 +
 arch/x86/xen/xen-head.S           |    4 +
 arch/x86/xen/xen-ops.h            |   23 +
 drivers/xen/balloon.c             |   30 +-
 include/xen/xen-ops.h             |   14 +
 25 files changed, 5461 insertions(+), 5179 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_hvm.c
Quoted 9 lines
 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

Series pushed to kernel/git/xen/tip.git for-linus-4.12 with one fixup patch added: smp_pv.c had a duplicate xen_call_function_interrupt() defined but not used. I removed it again.

Juergen

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

maintainer
#38 lore raw
In reply to Vitaly Kuznetsov
Quoted 98 lines · Vitaly Kuznetsov

Changes since v2:
- Rebase to 4.11.0-rc1+
- XEN_HAVE_PVMMU moved to config XEN_PV [Juergen Gross]
- .pin_vcpu kept for x86_hyper_xen_hvm to support PVH Dom0 in future [Juergen Gross]
- 'extern' qualifiers dropped from newly introduced function prototypes in headers [Juergen Gross]
- A couple of #includes added to address build issues with different configs [kbuild test robot].
- Juergen reviewed-bys added (hope they stand with the above mentioned changes).

The series can also be pulled from https://github.com/vittyvk/linux.git
(xen_pv_hvm_split_v3 branch).

Some 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.

Some 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 (21):
x86/xen: separate PV and HVM hypervisors
x86/xen: globalize have_vcpu_info_placement
x86/xen: add CONFIG_XEN_PV to Kconfig
x86/xen: split off enlighten_pvh.c
x86/xen: split off enlighten_hvm.c
x86/xen: split off enlighten_pv.c
x86/xen: split xen_smp_intr_init()/xen_smp_intr_free() x86/xen: split xen_smp_prepare_boot_cpu()
x86/xen: split xen_cpu_die()
x86/xen: split off smp_hvm.c
x86/xen: split off smp_pv.c
x86/xen: split off mmu_hvm.c
x86/xen: split off mmu_pv.c
x86/xen: split suspend.c for PV and PVHVM guests x86/xen: put setup.c, pmu.c and apic.c under CONFIG_XEN_PV x86/xen: define startup_xen for XEN PV only
x86/xen: create stubs for HVM-only builds in page.h xen/balloon: decorate PV-only parts with #ifdef CONFIG_XEN_PV
xen: create xen_create/destroy_contiguous_region() stubs for PVHVM
only builds
x86/xen: enable PVHVM-only builds
x86/xen: rename some PV-only functions in smp_pv.c

 arch/x86/include/asm/hypervisor.h |    3 +-
 arch/x86/include/asm/xen/page.h   |   25 +
 arch/x86/kernel/cpu/hypervisor.c  |    7 +-
 arch/x86/kernel/process_64.c      |    2 +-
 arch/x86/xen/Kconfig              |   33 +-
 arch/x86/xen/Makefile             |   16 +-
 arch/x86/xen/enlighten.c          | 1925 +------------------------
 arch/x86/xen/enlighten_hvm.c      |  213 +++
 arch/x86/xen/enlighten_pv.c       | 1522 ++++++++++++++++++++
 arch/x86/xen/enlighten_pvh.c      |  115 ++
 arch/x86/xen/mmu.c                | 2776 +------------------------------------
 arch/x86/xen/mmu_hvm.c            |   79 ++
 arch/x86/xen/mmu_pv.c             | 2635 +++++++++++++++++++++++++++++++++++
 arch/x86/xen/pmu.h                |    5 +
 arch/x86/xen/smp.c                |  517 +------
 arch/x86/xen/smp.h                |   16 +
 arch/x86/xen/smp_hvm.c            |   58 +
 arch/x86/xen/smp_pv.c             |  500 +++++++
 arch/x86/xen/suspend.c            |   54 -
 arch/x86/xen/suspend_hvm.c        |   22 +
 arch/x86/xen/suspend_pv.c         |   46 +
 arch/x86/xen/xen-head.S           |    4 +
 arch/x86/xen/xen-ops.h            |   23 +
 drivers/xen/balloon.c             |   30 +-
 include/xen/xen-ops.h             |   14 +
 25 files changed, 5461 insertions(+), 5179 deletions(-)
 create mode 100644 arch/x86/xen/enlighten_hvm.c
Quoted 9 lines
 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

Series pushed to kernel/git/xen/tip.git for-linus-4.12 with one fixup patch added: smp_pv.c had a duplicate xen_call_function_interrupt() defined but not used. I removed it again.

Juergen

#39 lore raw
Quoted 2 lines · Juergen Gross
Quoted 1 line · Vitaly Kuznetsov

Changes since v2:

...

Quoted 4 lines

Series pushed to kernel/git/xen/tip.git for-linus-4.12 with one fixup patch added: smp_pv.c had a duplicate xen_call_function_interrupt() defined but not used. I removed it again.

Thanks!

Signature · 6 lines
  Vitaly

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