-
Notifications
You must be signed in to change notification settings - Fork 4
/
linux-uek5-v4.14.35-2047.515.0-kvm.patch
124 lines (111 loc) · 4.35 KB
/
linux-uek5-v4.14.35-2047.515.0-kvm.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
From 134307954a497c361ecdb2a0b9ff41a2f2ad637e Mon Sep 17 00:00:00 2001
From: Dongli Zhang <[email protected]>
Date: Sun, 10 Jul 2022 17:40:35 -0700
Subject: [PATCH 1/1] linux-uek5-v4.14.35-2047.515.0-kvm
Signed-off-by: Dongli Zhang <[email protected]>
---
arch/x86/kvm/x86.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0b443b9bf562..95744c5df70a 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1428,12 +1428,22 @@ struct pvclock_gtod_data {
} clock;
u64 boot_ns;
+ /*
+ * 在以下使用pvclock_gtod_data->nsec_base:
+ * - arch/x86/kvm/x86.c|1454| <<update_pvclock_gtod>> vdata->nsec_base = tk->tkr_mono.xtime_nsec;
+ * - arch/x86/kvm/x86.c|1937| <<do_monotonic_boot>> ns = gtod->nsec_base;
+ * - arch/x86/kvm/x86.c|1957| <<do_realtime>> ns = gtod->nsec_base;
+ */
u64 nsec_base;
u64 wall_time_sec;
};
static struct pvclock_gtod_data pvclock_gtod_data;
+/*
+ * called by:
+ * - arch/x86/kvm/x86.c|6948| <<pvclock_gtod_notify>> update_pvclock_gtod(tk);
+ */
static void update_pvclock_gtod(struct timekeeper *tk)
{
struct pvclock_gtod_data *vdata = &pvclock_gtod_data;
@@ -1444,6 +1454,11 @@ static void update_pvclock_gtod(struct timekeeper *tk)
write_seqcount_begin(&vdata->seq);
/* copy pvclock gtod data */
+ /*
+ * struct timekeeper *tk:
+ * -> struct tk_read_base tkr_mono; --> CLOCK_MONOTONIC
+ * -> struct tk_read_base tkr_raw; --> CLOCK_MONOTONIC_RAW
+ */
vdata->clock.vclock_mode = tk->tkr_mono.clock->archdata.vclock_mode;
vdata->clock.cycle_last = tk->tkr_mono.cycle_last;
vdata->clock.mask = tk->tkr_mono.mask;
@@ -1743,6 +1758,11 @@ static inline bool kvm_check_tsc_unstable(void)
return check_tsc_unstable();
}
+/*
+ * called by:
+ * - arch/x86/kvm/x86.c|2571| <<kvm_set_msr_common(MSR_IA32_TSC)>> kvm_write_tsc(vcpu, msr_info);
+ * - arch/x86/kvm/x86.c|8852| <<kvm_arch_vcpu_postcreate>> kvm_write_tsc(vcpu, &msr);
+ */
void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr)
{
struct kvm *kvm = vcpu->kvm;
@@ -1925,6 +1945,10 @@ static inline u64 vgettsc(u64 *tsc_timestamp, int *mode)
return v * gtod->clock.mult;
}
+/*
+ * called by:
+ * - arch/x86/kvm/x86.c|1975| <<kvm_get_time_and_clockread>> return gtod_is_based_on_tsc(do_monotonic_boot(kernel_ns,
+ */
static int do_monotonic_boot(s64 *t, u64 *tsc_timestamp)
{
struct pvclock_gtod_data *gtod = &pvclock_gtod_data;
@@ -1934,6 +1958,12 @@ static int do_monotonic_boot(s64 *t, u64 *tsc_timestamp)
do {
seq = read_seqcount_begin(>od->seq);
+ /*
+ * 在以下使用pvclock_gtod_data->nsec_base:
+ * - arch/x86/kvm/x86.c|1454| <<update_pvclock_gtod>> vdata->nsec_base = tk->tkr_mono.xtime_nsec;
+ * - arch/x86/kvm/x86.c|1937| <<do_monotonic_boot>> ns = gtod->nsec_base;
+ * - arch/x86/kvm/x86.c|1957| <<do_realtime>> ns = gtod->nsec_base;
+ */
ns = gtod->nsec_base;
ns += vgettsc(tsc_timestamp, &mode);
ns >>= gtod->clock.shift;
@@ -1966,6 +1996,10 @@ static int do_realtime(struct timespec64 *ts, u64 *tsc_timestamp)
}
/* returns true if host is using TSC based clocksource */
+/*
+ * called by:
+ * - arch/x86/kvm/x86.c|2046| <<pvclock_update_vm_gtod_copy>> host_tsc_clocksource = kvm_get_time_and_clockread(
+ */
static bool kvm_get_time_and_clockread(s64 *kernel_ns, u64 *tsc_timestamp)
{
/* checked again under seqlock below */
@@ -2029,6 +2063,12 @@ static bool kvm_get_walltime_and_clockread(struct timespec64 *ts,
*
*/
+/*
+ * called by:
+ * - arch/x86/kvm/x86.c|2078| <<kvm_gen_update_masterclock>> pvclock_update_vm_gtod_copy(kvm);
+ * - arch/x86/kvm/x86.c|6754| <<kvm_hyperv_tsc_notifier>> pvclock_update_vm_gtod_copy(kvm);
+ * - arch/x86/kvm/x86.c|9229| <<kvm_arch_init_vm>> pvclock_update_vm_gtod_copy(kvm);
+ */
static void pvclock_update_vm_gtod_copy(struct kvm *kvm)
{
#ifdef CONFIG_X86_64
@@ -2065,6 +2105,11 @@ void kvm_make_mclock_inprogress_request(struct kvm *kvm)
kvm_make_all_cpus_request(kvm, KVM_REQ_MCLOCK_INPROGRESS);
}
+/*
+ * called by:
+ * - arch/x86/kvm/x86.c|4913| <<kvm_arch_vm_ioctl(KVM_SET_CLOCK)>> kvm_gen_update_masterclock(kvm);
+ * - arch/x86/kvm/x86.c|7747| <<vcpu_enter_guest(KVM_REQ_MASTERCLOCK_UPDATE)>> kvm_gen_update_masterclock(vcpu->kvm);
+ */
static void kvm_gen_update_masterclock(struct kvm *kvm)
{
#ifdef CONFIG_X86_64
--
2.17.1