Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1591396

[PATCH v2 12/21] x86/xen: split off mmu_hvm.c

From Vitaly Kuznetsov <vkuznets@redhat.com>
Newsgroups linux.kernel
Subject [PATCH v2 12/21] x86/xen: split off mmu_hvm.c
Date 2017-03-02 20:00 +0100
Message-ID <tgE7f-6oo-5@gated-at.bofh.it> (permalink)
References <tgDbb-5KR-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Move PVHVM related code to mmu_hvm.c.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 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

diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index ebf3522..6a95a8b 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -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
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index f6740b5..4dfcb06 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2689,80 +2689,6 @@ void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
 }
 EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
 
-#ifdef CONFIG_XEN_PVHVM
-#ifdef CONFIG_PROC_VMCORE
-/*
- * This function is used in two contexts:
- * - the kdump kernel has to check whether a pfn of the crashed kernel
- *   was a ballooned page. vmcore is using this function to decide
- *   whether to access a pfn of the crashed kernel.
- * - the kexec kernel has to check whether a pfn was ballooned by the
- *   previous kernel. If the pfn is ballooned, handle it properly.
- * Returns 0 if the pfn is not backed by a RAM page, the caller may
- * handle the pfn special in this case.
- */
-static int xen_oldmem_pfn_is_ram(unsigned long pfn)
-{
-	struct xen_hvm_get_mem_type a = {
-		.domid = DOMID_SELF,
-		.pfn = pfn,
-	};
-	int ram;
-
-	if (HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a))
-		return -ENXIO;
-
-	switch (a.mem_type) {
-		case HVMMEM_mmio_dm:
-			ram = 0;
-			break;
-		case HVMMEM_ram_rw:
-		case HVMMEM_ram_ro:
-		default:
-			ram = 1;
-			break;
-	}
-
-	return ram;
-}
-#endif
-
-static void xen_hvm_exit_mmap(struct mm_struct *mm)
-{
-	struct xen_hvm_pagetable_dying a;
-	int rc;
-
-	a.domid = DOMID_SELF;
-	a.gpa = __pa(mm->pgd);
-	rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a);
-	WARN_ON_ONCE(rc < 0);
-}
-
-static int is_pagetable_dying_supported(void)
-{
-	struct xen_hvm_pagetable_dying a;
-	int rc = 0;
-
-	a.domid = DOMID_SELF;
-	a.gpa = 0x00;
-	rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a);
-	if (rc < 0) {
-		printk(KERN_DEBUG "HVMOP_pagetable_dying not supported\n");
-		return 0;
-	}
-	return 1;
-}
-
-void __init xen_hvm_init_mmu_ops(void)
-{
-	if (is_pagetable_dying_supported())
-		pv_mmu_ops.exit_mmap = xen_hvm_exit_mmap;
-#ifdef CONFIG_PROC_VMCORE
-	register_oldmem_pfn_is_ram(&xen_oldmem_pfn_is_ram);
-#endif
-}
-#endif
-
 #define REMAP_BATCH_SIZE 16
 
 struct remap_data {
diff --git a/arch/x86/xen/mmu_hvm.c b/arch/x86/xen/mmu_hvm.c
new file mode 100644
index 0000000..1c57f1c
--- /dev/null
+++ b/arch/x86/xen/mmu_hvm.c
@@ -0,0 +1,79 @@
+#include <linux/types.h>
+#include <linux/crash_dump.h>
+
+#include <xen/interface/xen.h>
+#include <xen/hvm.h>
+
+#include "mmu.h"
+
+#ifdef CONFIG_PROC_VMCORE
+/*
+ * This function is used in two contexts:
+ * - the kdump kernel has to check whether a pfn of the crashed kernel
+ *   was a ballooned page. vmcore is using this function to decide
+ *   whether to access a pfn of the crashed kernel.
+ * - the kexec kernel has to check whether a pfn was ballooned by the
+ *   previous kernel. If the pfn is ballooned, handle it properly.
+ * Returns 0 if the pfn is not backed by a RAM page, the caller may
+ * handle the pfn special in this case.
+ */
+static int xen_oldmem_pfn_is_ram(unsigned long pfn)
+{
+	struct xen_hvm_get_mem_type a = {
+		.domid = DOMID_SELF,
+		.pfn = pfn,
+	};
+	int ram;
+
+	if (HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a))
+		return -ENXIO;
+
+	switch (a.mem_type) {
+	case HVMMEM_mmio_dm:
+		ram = 0;
+		break;
+	case HVMMEM_ram_rw:
+	case HVMMEM_ram_ro:
+	default:
+		ram = 1;
+		break;
+	}
+
+	return ram;
+}
+#endif
+
+static void xen_hvm_exit_mmap(struct mm_struct *mm)
+{
+	struct xen_hvm_pagetable_dying a;
+	int rc;
+
+	a.domid = DOMID_SELF;
+	a.gpa = __pa(mm->pgd);
+	rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a);
+	WARN_ON_ONCE(rc < 0);
+}
+
+static int is_pagetable_dying_supported(void)
+{
+	struct xen_hvm_pagetable_dying a;
+	int rc = 0;
+
+	a.domid = DOMID_SELF;
+	a.gpa = 0x00;
+	rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a);
+	if (rc < 0) {
+		printk(KERN_DEBUG "HVMOP_pagetable_dying not supported\n");
+		return 0;
+	}
+	return 1;
+}
+
+void __init xen_hvm_init_mmu_ops(void)
+{
+	if (is_pagetable_dying_supported())
+		pv_mmu_ops.exit_mmap = xen_hvm_exit_mmap;
+#ifdef CONFIG_PROC_VMCORE
+	register_oldmem_pfn_is_ram(&xen_oldmem_pfn_is_ram);
+#endif
+}
-- 
2.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 00/21] x86/xen: untangle PV and PVHVM guest support code Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-03-02 19:20 +0100
  [PATCH v2 11/21] x86/xen: split off smp_pv.c Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-03-02 19:20 +0100
    Re: [PATCH v2 11/21] x86/xen: split off smp_pv.c Juergen Gross <jgross@suse.com> - 2017-03-13 10:40 +0100
  [PATCH v2 12/21] x86/xen: split off mmu_hvm.c Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-03-02 20:00 +0100
  [PATCH v2 09/21] x86/xen: split xen_cpu_die() Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-03-02 20:00 +0100
    Re: [PATCH v2 09/21] x86/xen: split xen_cpu_die() Juergen Gross <jgross@suse.com> - 2017-03-13 08:40 +0100
  [PATCH v2 02/21] x86/xen: globalize have_vcpu_info_placement Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-03-02 23:10 +0100
    Re: [PATCH v2 02/21] x86/xen: globalize have_vcpu_info_placement Juergen Gross <jgross@suse.com> - 2017-03-08 16:10 +0100
  [PATCH v2 01/21] x86/xen: separate PV and HVM hypervisors Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-03-02 23:10 +0100
    Re: [PATCH v2 01/21] x86/xen: separate PV and HVM hypervisors Juergen Gross <jgross@suse.com> - 2017-03-08 16:10 +0100
  [PATCH v2 05/21] x86/xen: split off enlighten_hvm.c Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-03-02 23:10 +0100
    Re: [PATCH v2 05/21] x86/xen: split off enlighten_hvm.c Juergen Gross <jgross@suse.com> - 2017-03-08 16:40 +0100
  [PATCH v2 10/21] x86/xen: split off smp_hvm.c Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-03-02 23:10 +0100
    Re: [PATCH v2 10/21] x86/xen: split off smp_hvm.c Juergen Gross <jgross@suse.com> - 2017-03-13 08:40 +0100
  [PATCH v2 03/21] x86/xen: add CONFIG_XEN_PV to Kconfig Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-03-02 23:20 +0100
    Re: [PATCH v2 03/21] x86/xen: add CONFIG_XEN_PV to Kconfig Juergen Gross <jgross@suse.com> - 2017-03-08 16:20 +0100
  Re: [Xen-devel] [PATCH v2 00/21] x86/xen: untangle PV and PVHVM guest  support code Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-03-05 19:10 +0100
    Re: [Xen-devel] [PATCH v2 00/21] x86/xen: untangle PV and PVHVM guest support code Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-03-13 14:10 +0100
  Re: [PATCH v2 06/21] x86/xen: split off enlighten_pv.c Juergen Gross <jgross@suse.com> - 2017-03-08 16:20 +0100
  Re: [PATCH v2 13/21] x86/xen: split off mmu_pv.c Juergen Gross <jgross@suse.com> - 2017-03-13 10:40 +0100

csiph-web