Skip to content

Commit feef87e

Browse files
vittyvkjgross1
authored andcommitted
x86/xen: split off mmu_hvm.c
Move PVHVM related code to mmu_hvm.c. Signed-off-by: Vitaly Kuznetsov <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 83b9679 commit feef87e

File tree

3 files changed

+80
-75
lines changed

3 files changed

+80
-75
lines changed

arch/x86/xen/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \
1515
grant-table.o suspend.o platform-pci-unplug.o \
1616
p2m.o apic.o pmu.o enlighten_pv.o
1717

18-
obj-$(CONFIG_XEN_PVHVM) += enlighten_hvm.o
18+
obj-$(CONFIG_XEN_PVHVM) += enlighten_hvm.o mmu_hvm.o
1919
obj-$(CONFIG_XEN_PVH) += enlighten_pvh.o
2020

2121
obj-$(CONFIG_EVENT_TRACING) += trace.o

arch/x86/xen/mmu.c

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,80 +2771,6 @@ void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
27712771
}
27722772
EXPORT_SYMBOL_GPL(xen_destroy_contiguous_region);
27732773

2774-
#ifdef CONFIG_XEN_PVHVM
2775-
#ifdef CONFIG_PROC_VMCORE
2776-
/*
2777-
* This function is used in two contexts:
2778-
* - the kdump kernel has to check whether a pfn of the crashed kernel
2779-
* was a ballooned page. vmcore is using this function to decide
2780-
* whether to access a pfn of the crashed kernel.
2781-
* - the kexec kernel has to check whether a pfn was ballooned by the
2782-
* previous kernel. If the pfn is ballooned, handle it properly.
2783-
* Returns 0 if the pfn is not backed by a RAM page, the caller may
2784-
* handle the pfn special in this case.
2785-
*/
2786-
static int xen_oldmem_pfn_is_ram(unsigned long pfn)
2787-
{
2788-
struct xen_hvm_get_mem_type a = {
2789-
.domid = DOMID_SELF,
2790-
.pfn = pfn,
2791-
};
2792-
int ram;
2793-
2794-
if (HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a))
2795-
return -ENXIO;
2796-
2797-
switch (a.mem_type) {
2798-
case HVMMEM_mmio_dm:
2799-
ram = 0;
2800-
break;
2801-
case HVMMEM_ram_rw:
2802-
case HVMMEM_ram_ro:
2803-
default:
2804-
ram = 1;
2805-
break;
2806-
}
2807-
2808-
return ram;
2809-
}
2810-
#endif
2811-
2812-
static void xen_hvm_exit_mmap(struct mm_struct *mm)
2813-
{
2814-
struct xen_hvm_pagetable_dying a;
2815-
int rc;
2816-
2817-
a.domid = DOMID_SELF;
2818-
a.gpa = __pa(mm->pgd);
2819-
rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a);
2820-
WARN_ON_ONCE(rc < 0);
2821-
}
2822-
2823-
static int is_pagetable_dying_supported(void)
2824-
{
2825-
struct xen_hvm_pagetable_dying a;
2826-
int rc = 0;
2827-
2828-
a.domid = DOMID_SELF;
2829-
a.gpa = 0x00;
2830-
rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a);
2831-
if (rc < 0) {
2832-
printk(KERN_DEBUG "HVMOP_pagetable_dying not supported\n");
2833-
return 0;
2834-
}
2835-
return 1;
2836-
}
2837-
2838-
void __init xen_hvm_init_mmu_ops(void)
2839-
{
2840-
if (is_pagetable_dying_supported())
2841-
pv_mmu_ops.exit_mmap = xen_hvm_exit_mmap;
2842-
#ifdef CONFIG_PROC_VMCORE
2843-
register_oldmem_pfn_is_ram(&xen_oldmem_pfn_is_ram);
2844-
#endif
2845-
}
2846-
#endif
2847-
28482774
#define REMAP_BATCH_SIZE 16
28492775

28502776
struct remap_data {

arch/x86/xen/mmu_hvm.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#include <linux/types.h>
2+
#include <linux/crash_dump.h>
3+
4+
#include <xen/interface/xen.h>
5+
#include <xen/hvm.h>
6+
7+
#include "mmu.h"
8+
9+
#ifdef CONFIG_PROC_VMCORE
10+
/*
11+
* This function is used in two contexts:
12+
* - the kdump kernel has to check whether a pfn of the crashed kernel
13+
* was a ballooned page. vmcore is using this function to decide
14+
* whether to access a pfn of the crashed kernel.
15+
* - the kexec kernel has to check whether a pfn was ballooned by the
16+
* previous kernel. If the pfn is ballooned, handle it properly.
17+
* Returns 0 if the pfn is not backed by a RAM page, the caller may
18+
* handle the pfn special in this case.
19+
*/
20+
static int xen_oldmem_pfn_is_ram(unsigned long pfn)
21+
{
22+
struct xen_hvm_get_mem_type a = {
23+
.domid = DOMID_SELF,
24+
.pfn = pfn,
25+
};
26+
int ram;
27+
28+
if (HYPERVISOR_hvm_op(HVMOP_get_mem_type, &a))
29+
return -ENXIO;
30+
31+
switch (a.mem_type) {
32+
case HVMMEM_mmio_dm:
33+
ram = 0;
34+
break;
35+
case HVMMEM_ram_rw:
36+
case HVMMEM_ram_ro:
37+
default:
38+
ram = 1;
39+
break;
40+
}
41+
42+
return ram;
43+
}
44+
#endif
45+
46+
static void xen_hvm_exit_mmap(struct mm_struct *mm)
47+
{
48+
struct xen_hvm_pagetable_dying a;
49+
int rc;
50+
51+
a.domid = DOMID_SELF;
52+
a.gpa = __pa(mm->pgd);
53+
rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a);
54+
WARN_ON_ONCE(rc < 0);
55+
}
56+
57+
static int is_pagetable_dying_supported(void)
58+
{
59+
struct xen_hvm_pagetable_dying a;
60+
int rc = 0;
61+
62+
a.domid = DOMID_SELF;
63+
a.gpa = 0x00;
64+
rc = HYPERVISOR_hvm_op(HVMOP_pagetable_dying, &a);
65+
if (rc < 0) {
66+
printk(KERN_DEBUG "HVMOP_pagetable_dying not supported\n");
67+
return 0;
68+
}
69+
return 1;
70+
}
71+
72+
void __init xen_hvm_init_mmu_ops(void)
73+
{
74+
if (is_pagetable_dying_supported())
75+
pv_mmu_ops.exit_mmap = xen_hvm_exit_mmap;
76+
#ifdef CONFIG_PROC_VMCORE
77+
register_oldmem_pfn_is_ram(&xen_oldmem_pfn_is_ram);
78+
#endif
79+
}

0 commit comments

Comments
 (0)