Skip to content

Commit 9963236

Browse files
vittyvkjgross1
authored andcommitted
x86/xen: split suspend.c for PV and PVHVM guests
Slit the code in suspend.c into suspend_pv.c and suspend_hvm.c. Signed-off-by: Vitaly Kuznetsov <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 7e0563d commit 9963236

File tree

5 files changed

+83
-55
lines changed

5 files changed

+83
-55
lines changed

arch/x86/xen/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ 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 mmu_pv.o
1717

18-
obj-$(CONFIG_XEN_PVHVM) += enlighten_hvm.o mmu_hvm.o
18+
obj-$(CONFIG_XEN_PVHVM) += enlighten_hvm.o mmu_hvm.o suspend_hvm.o
19+
obj-$(CONFIG_XEN_PV) += suspend_pv.o
1920
obj-$(CONFIG_XEN_PVH) += enlighten_pvh.o
2021

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

arch/x86/xen/suspend.c

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,6 @@
1414
#include "mmu.h"
1515
#include "pmu.h"
1616

17-
static void xen_pv_pre_suspend(void)
18-
{
19-
xen_mm_pin_all();
20-
21-
xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
22-
xen_start_info->console.domU.mfn =
23-
mfn_to_pfn(xen_start_info->console.domU.mfn);
24-
25-
BUG_ON(!irqs_disabled());
26-
27-
HYPERVISOR_shared_info = &xen_dummy_shared_info;
28-
if (HYPERVISOR_update_va_mapping(fix_to_virt(FIX_PARAVIRT_BOOTMAP),
29-
__pte_ma(0), 0))
30-
BUG();
31-
}
32-
33-
static void xen_hvm_post_suspend(int suspend_cancelled)
34-
{
35-
#ifdef CONFIG_XEN_PVHVM
36-
int cpu;
37-
if (!suspend_cancelled)
38-
xen_hvm_init_shared_info();
39-
xen_callback_vector();
40-
xen_unplug_emulated_devices();
41-
if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
42-
for_each_online_cpu(cpu) {
43-
xen_setup_runstate_info(cpu);
44-
}
45-
}
46-
#endif
47-
}
48-
49-
static void xen_pv_post_suspend(int suspend_cancelled)
50-
{
51-
xen_build_mfn_list_list();
52-
53-
xen_setup_shared_info();
54-
55-
if (suspend_cancelled) {
56-
xen_start_info->store_mfn =
57-
pfn_to_mfn(xen_start_info->store_mfn);
58-
xen_start_info->console.domU.mfn =
59-
pfn_to_mfn(xen_start_info->console.domU.mfn);
60-
} else {
61-
#ifdef CONFIG_SMP
62-
BUG_ON(xen_cpu_initialized_map == NULL);
63-
cpumask_copy(xen_cpu_initialized_map, cpu_online_mask);
64-
#endif
65-
xen_vcpu_restore();
66-
}
67-
68-
xen_mm_unpin_all();
69-
}
70-
7117
void xen_arch_pre_suspend(void)
7218
{
7319
if (xen_pv_domain())

arch/x86/xen/suspend_hvm.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <linux/types.h>
2+
3+
#include <xen/xen.h>
4+
#include <xen/features.h>
5+
#include <xen/interface/features.h>
6+
7+
#include "xen-ops.h"
8+
9+
void xen_hvm_post_suspend(int suspend_cancelled)
10+
{
11+
int cpu;
12+
13+
if (!suspend_cancelled)
14+
xen_hvm_init_shared_info();
15+
xen_callback_vector();
16+
xen_unplug_emulated_devices();
17+
if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
18+
for_each_online_cpu(cpu) {
19+
xen_setup_runstate_info(cpu);
20+
}
21+
}
22+
}

arch/x86/xen/suspend_pv.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include <linux/types.h>
2+
3+
#include <asm/fixmap.h>
4+
5+
#include <asm/xen/hypercall.h>
6+
#include <asm/xen/page.h>
7+
8+
#include "xen-ops.h"
9+
10+
void xen_pv_pre_suspend(void)
11+
{
12+
xen_mm_pin_all();
13+
14+
xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
15+
xen_start_info->console.domU.mfn =
16+
mfn_to_pfn(xen_start_info->console.domU.mfn);
17+
18+
BUG_ON(!irqs_disabled());
19+
20+
HYPERVISOR_shared_info = &xen_dummy_shared_info;
21+
if (HYPERVISOR_update_va_mapping(fix_to_virt(FIX_PARAVIRT_BOOTMAP),
22+
__pte_ma(0), 0))
23+
BUG();
24+
}
25+
26+
void xen_pv_post_suspend(int suspend_cancelled)
27+
{
28+
xen_build_mfn_list_list();
29+
30+
xen_setup_shared_info();
31+
32+
if (suspend_cancelled) {
33+
xen_start_info->store_mfn =
34+
pfn_to_mfn(xen_start_info->store_mfn);
35+
xen_start_info->console.domU.mfn =
36+
pfn_to_mfn(xen_start_info->console.domU.mfn);
37+
} else {
38+
#ifdef CONFIG_SMP
39+
BUG_ON(xen_cpu_initialized_map == NULL);
40+
cpumask_copy(xen_cpu_initialized_map, cpu_online_mask);
41+
#endif
42+
xen_vcpu_restore();
43+
}
44+
45+
xen_mm_unpin_all();
46+
}

arch/x86/xen/xen-ops.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,18 @@ void xen_pin_vcpu(int cpu);
155155

156156
void xen_reboot(int reason);
157157
void xen_emergency_restart(void);
158+
#ifdef CONFIG_XEN_PV
159+
void xen_pv_pre_suspend(void);
160+
void xen_pv_post_suspend(int suspend_cancelled);
161+
#else
162+
static inline void xen_pv_pre_suspend(void) {}
163+
static inline void xen_pv_post_suspend(int suspend_cancelled) {}
164+
#endif
165+
166+
#ifdef CONFIG_XEN_PVHVM
167+
void xen_hvm_post_suspend(int suspend_cancelled);
168+
#else
169+
static inline void xen_hvm_post_suspend(int suspend_cancelled) {}
170+
#endif
158171

159172
#endif /* XEN_OPS_H */

0 commit comments

Comments
 (0)