Linux Audio

Check our new training course

Loading...
v6.2
 1// SPDX-License-Identifier: GPL-2.0
 2#include <linux/types.h>
 3#include <linux/tick.h>
 4#include <linux/percpu-defs.h>
 5
 6#include <xen/xen.h>
 7#include <xen/interface/xen.h>
 8#include <xen/grant_table.h>
 9#include <xen/events.h>
10
11#include <asm/cpufeatures.h>
12#include <asm/msr-index.h>
13#include <asm/xen/hypercall.h>
14#include <asm/xen/page.h>
15#include <asm/fixmap.h>
16
17#include "xen-ops.h"
18#include "mmu.h"
19#include "pmu.h"
20
21static DEFINE_PER_CPU(u64, spec_ctrl);
22
23void xen_arch_pre_suspend(void)
24{
25	xen_save_time_memory_area();
26
27	if (xen_pv_domain())
28		xen_pv_pre_suspend();
29}
30
31void xen_arch_post_suspend(int cancelled)
32{
33	if (xen_pv_domain())
34		xen_pv_post_suspend(cancelled);
35	else
36		xen_hvm_post_suspend(cancelled);
37
38	xen_restore_time_memory_area();
39}
40
41static void xen_vcpu_notify_restore(void *data)
42{
43	if (xen_pv_domain() && boot_cpu_has(X86_FEATURE_SPEC_CTRL))
44		wrmsrl(MSR_IA32_SPEC_CTRL, this_cpu_read(spec_ctrl));
45
46	/* Boot processor notified via generic timekeeping_resume() */
47	if (smp_processor_id() == 0)
48		return;
49
50	tick_resume_local();
51}
52
53static void xen_vcpu_notify_suspend(void *data)
54{
55	u64 tmp;
56
57	tick_suspend_local();
58
59	if (xen_pv_domain() && boot_cpu_has(X86_FEATURE_SPEC_CTRL)) {
60		rdmsrl(MSR_IA32_SPEC_CTRL, tmp);
61		this_cpu_write(spec_ctrl, tmp);
62		wrmsrl(MSR_IA32_SPEC_CTRL, 0);
63	}
64}
65
66void xen_arch_resume(void)
67{
68	int cpu;
69
70	on_each_cpu(xen_vcpu_notify_restore, NULL, 1);
71
72	for_each_online_cpu(cpu)
73		xen_pmu_init(cpu);
74}
75
76void xen_arch_suspend(void)
77{
78	int cpu;
79
80	for_each_online_cpu(cpu)
81		xen_pmu_finish(cpu);
82
83	on_each_cpu(xen_vcpu_notify_suspend, NULL, 1);
84}
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0
 2#include <linux/types.h>
 3#include <linux/tick.h>
 4#include <linux/percpu-defs.h>
 5
 6#include <xen/xen.h>
 7#include <xen/interface/xen.h>
 8#include <xen/grant_table.h>
 9#include <xen/events.h>
10
11#include <asm/cpufeatures.h>
12#include <asm/msr-index.h>
13#include <asm/xen/hypercall.h>
14#include <asm/xen/page.h>
15#include <asm/fixmap.h>
16
17#include "xen-ops.h"
 
 
18
19static DEFINE_PER_CPU(u64, spec_ctrl);
20
21void xen_arch_pre_suspend(void)
22{
23	xen_save_time_memory_area();
24
25	if (xen_pv_domain())
26		xen_pv_pre_suspend();
27}
28
29void xen_arch_post_suspend(int cancelled)
30{
31	if (xen_pv_domain())
32		xen_pv_post_suspend(cancelled);
33	else
34		xen_hvm_post_suspend(cancelled);
35
36	xen_restore_time_memory_area();
37}
38
39static void xen_vcpu_notify_restore(void *data)
40{
41	if (xen_pv_domain() && boot_cpu_has(X86_FEATURE_SPEC_CTRL))
42		wrmsrl(MSR_IA32_SPEC_CTRL, this_cpu_read(spec_ctrl));
43
44	/* Boot processor notified via generic timekeeping_resume() */
45	if (smp_processor_id() == 0)
46		return;
47
48	tick_resume_local();
49}
50
51static void xen_vcpu_notify_suspend(void *data)
52{
53	u64 tmp;
54
55	tick_suspend_local();
56
57	if (xen_pv_domain() && boot_cpu_has(X86_FEATURE_SPEC_CTRL)) {
58		rdmsrl(MSR_IA32_SPEC_CTRL, tmp);
59		this_cpu_write(spec_ctrl, tmp);
60		wrmsrl(MSR_IA32_SPEC_CTRL, 0);
61	}
62}
63
64void xen_arch_resume(void)
65{
66	int cpu;
67
68	on_each_cpu(xen_vcpu_notify_restore, NULL, 1);
69
70	for_each_online_cpu(cpu)
71		xen_pmu_init(cpu);
72}
73
74void xen_arch_suspend(void)
75{
76	int cpu;
77
78	for_each_online_cpu(cpu)
79		xen_pmu_finish(cpu);
80
81	on_each_cpu(xen_vcpu_notify_suspend, NULL, 1);
82}