Merge ~paelzer/ubuntu/+source/qemu:fix-1832622-ppc-spectre-disco into ubuntu/+source/qemu:ubuntu/disco-devel
- Git
- lp:~paelzer/ubuntu/+source/qemu
- fix-1832622-ppc-spectre-disco
- Merge into ubuntu/disco-devel
Proposed by
Christian Ehrhardt
Status: | Merged |
---|---|
Approved by: | Christian Ehrhardt |
Approved revision: | f5ccfa81ec89a89e7f7f3f7d5fe41a4f02b32c38 |
Merge reported by: | Christian Ehrhardt |
Merged at revision: | fac417ed7d848ba91926c7421c8c4621c32fccab |
Proposed branch: | ~paelzer/ubuntu/+source/qemu:fix-1832622-ppc-spectre-disco |
Merge into: | ubuntu/+source/qemu:ubuntu/disco-devel |
Diff against target: |
412 lines (+384/-0) 4 files modified
debian/changelog (+7/-0) debian/patches/series (+2/-0) debian/patches/ubuntu/lp-1832622-0002-target-ppc-spapr-Add-workaround-option-to-SPAPR_CAP_.patch (+159/-0) debian/patches/ubuntu/lp-1832622-0004-target-ppc-spapr-Add-SPAPR_CAP_CCF_ASSIST.patch (+216/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Rafael David Tinoco (community) | Approve | ||
Canonical Server packageset reviewers | Pending | ||
git-ubuntu developers | Pending | ||
Review via email: mp+368749@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt (paelzer) wrote : | # |
Revision history for this message
Paride Legovini (paride) wrote : | # |
Looks good from a formal point view; the packages in the PPA seem to be working as expected, however I don't think I can test the specific fix.
Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote : | # |
I did a full bionic review into eoan merge request:
https:/
All others are a subset of that, I did a quick look and compilation tests only.
+1 from me.
review:
Approve
Revision history for this message
Christian Ehrhardt (paelzer) wrote : | # |
This migrated, closing forgotten MP
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/debian/changelog b/debian/changelog | |||
2 | index bb2e787..4006062 100644 | |||
3 | --- a/debian/changelog | |||
4 | +++ b/debian/changelog | |||
5 | @@ -1,3 +1,10 @@ | |||
6 | 1 | qemu (1:3.1+dfsg-2ubuntu3.4) disco; urgency=medium | ||
7 | 2 | |||
8 | 3 | * d/p/ubuntu/lp-1832622-*: count cache flush Spectre v2 mitigation for ppc64 | ||
9 | 4 | (LP: #1832622) | ||
10 | 5 | |||
11 | 6 | -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Thu, 13 Jun 2019 08:40:55 +0200 | ||
12 | 7 | |||
13 | 1 | qemu (1:3.1+dfsg-2ubuntu3.3) disco; urgency=medium | 8 | qemu (1:3.1+dfsg-2ubuntu3.3) disco; urgency=medium |
14 | 2 | 9 | ||
15 | 3 | [ Christian Ehrhardt ] | 10 | [ Christian Ehrhardt ] |
16 | diff --git a/debian/patches/series b/debian/patches/series | |||
17 | index f8a7ef6..bbbd749 100644 | |||
18 | --- a/debian/patches/series | |||
19 | +++ b/debian/patches/series | |||
20 | @@ -31,3 +31,5 @@ ubuntu/lp1828495-0012-arch-capabilities-migratable.patch | |||
21 | 31 | ubuntu/lp1828495-0014-remove-cpuid-pconfig.patch | 31 | ubuntu/lp1828495-0014-remove-cpuid-pconfig.patch |
22 | 32 | ubuntu/lp1828495-0015-remove-cpuid-intel_pt.patch | 32 | ubuntu/lp1828495-0015-remove-cpuid-intel_pt.patch |
23 | 33 | ubuntu/lp1828495-0016-no-ospke-on-some.patch | 33 | ubuntu/lp1828495-0016-no-ospke-on-some.patch |
24 | 34 | ubuntu/lp-1832622-0002-target-ppc-spapr-Add-workaround-option-to-SPAPR_CAP_.patch | ||
25 | 35 | ubuntu/lp-1832622-0004-target-ppc-spapr-Add-SPAPR_CAP_CCF_ASSIST.patch | ||
26 | diff --git a/debian/patches/ubuntu/lp-1832622-0002-target-ppc-spapr-Add-workaround-option-to-SPAPR_CAP_.patch b/debian/patches/ubuntu/lp-1832622-0002-target-ppc-spapr-Add-workaround-option-to-SPAPR_CAP_.patch | |||
27 | 34 | new file mode 100644 | 36 | new file mode 100644 |
28 | index 0000000..58b3e88 | |||
29 | --- /dev/null | |||
30 | +++ b/debian/patches/ubuntu/lp-1832622-0002-target-ppc-spapr-Add-workaround-option-to-SPAPR_CAP_.patch | |||
31 | @@ -0,0 +1,159 @@ | |||
32 | 1 | From 399b2896d4948a1ec0278d896ea3a561df768d64 Mon Sep 17 00:00:00 2001 | ||
33 | 2 | From: Suraj Jitindar Singh <sjitindarsingh@gmail.com> | ||
34 | 3 | Date: Fri, 1 Mar 2019 14:19:11 +1100 | ||
35 | 4 | Subject: [PATCH 1/2] target/ppc/spapr: Add workaround option to SPAPR_CAP_IBS | ||
36 | 5 | |||
37 | 6 | The spapr_cap SPAPR_CAP_IBS is used to indicate the level of capability | ||
38 | 7 | for mitigations for indirect branch speculation. Currently the available | ||
39 | 8 | values are broken (default), fixed-ibs (fixed by serialising indirect | ||
40 | 9 | branches) and fixed-ccd (fixed by diabling the count cache). | ||
41 | 10 | |||
42 | 11 | Introduce a new value for this capability denoted workaround, meaning that | ||
43 | 12 | software can work around the issue by flushing the count cache on | ||
44 | 13 | context switch. This option is available if the hypervisor sets the | ||
45 | 14 | H_CPU_BEHAV_FLUSH_COUNT_CACHE flag in the cpu behaviours returned from | ||
46 | 15 | the KVM_PPC_GET_CPU_CHAR ioctl. | ||
47 | 16 | |||
48 | 17 | Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> | ||
49 | 18 | Message-Id: <20190301031912.28809-1-sjitindarsingh@gmail.com> | ||
50 | 19 | Signed-off-by: David Gibson <david@gibson.dropbear.id.au> | ||
51 | 20 | |||
52 | 21 | Origin: upstream, https://git.qemu.org/?p=qemu.git;a=commit;h=399b2896d4948a1ec0278d896ea3a561df768d64 | ||
53 | 22 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/1832622 | ||
54 | 23 | Last-Update: 2019-06-13 | ||
55 | 24 | |||
56 | 25 | --- | ||
57 | 26 | hw/ppc/spapr_caps.c | 21 ++++++++++----------- | ||
58 | 27 | hw/ppc/spapr_hcall.c | 5 +++++ | ||
59 | 28 | include/hw/ppc/spapr.h | 7 +++++++ | ||
60 | 29 | target/ppc/kvm.c | 8 +++++++- | ||
61 | 30 | 4 files changed, 29 insertions(+), 12 deletions(-) | ||
62 | 31 | |||
63 | 32 | diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c | ||
64 | 33 | index faab472d06..ca35b5153d 100644 | ||
65 | 34 | --- a/hw/ppc/spapr_caps.c | ||
66 | 35 | +++ b/hw/ppc/spapr_caps.c | ||
67 | 36 | @@ -276,11 +276,13 @@ static void cap_safe_bounds_check_apply(sPAPRMachineState *spapr, uint8_t val, | ||
68 | 37 | } | ||
69 | 38 | |||
70 | 39 | sPAPRCapPossible cap_ibs_possible = { | ||
71 | 40 | - .num = 4, | ||
72 | 41 | + .num = 5, | ||
73 | 42 | /* Note workaround only maintained for compatibility */ | ||
74 | 43 | - .vals = {"broken", "workaround", "fixed-ibs", "fixed-ccd"}, | ||
75 | 44 | - .help = "broken - no protection, fixed-ibs - indirect branch serialisation," | ||
76 | 45 | - " fixed-ccd - cache count disabled", | ||
77 | 46 | + .vals = {"broken", "workaround", "fixed-ibs", "fixed-ccd", "fixed-na"}, | ||
78 | 47 | + .help = "broken - no protection, workaround - count cache flush" | ||
79 | 48 | + ", fixed-ibs - indirect branch serialisation," | ||
80 | 49 | + " fixed-ccd - cache count disabled," | ||
81 | 50 | + " fixed-na - fixed in hardware (no longer applicable)", | ||
82 | 51 | }; | ||
83 | 52 | |||
84 | 53 | static void cap_safe_indirect_branch_apply(sPAPRMachineState *spapr, | ||
85 | 54 | @@ -288,15 +290,11 @@ static void cap_safe_indirect_branch_apply(sPAPRMachineState *spapr, | ||
86 | 55 | { | ||
87 | 56 | uint8_t kvm_val = kvmppc_get_cap_safe_indirect_branch(); | ||
88 | 57 | |||
89 | 58 | - if (val == SPAPR_CAP_WORKAROUND) { /* Can only be Broken or Fixed */ | ||
90 | 59 | - error_setg(errp, | ||
91 | 60 | -"Requested safe indirect branch capability level \"workaround\" not valid, try cap-ibs=%s", | ||
92 | 61 | - cap_ibs_possible.vals[kvm_val]); | ||
93 | 62 | - } else if (tcg_enabled() && val) { | ||
94 | 63 | + if (tcg_enabled() && val) { | ||
95 | 64 | /* TODO - for now only allow broken for TCG */ | ||
96 | 65 | error_setg(errp, | ||
97 | 66 | "Requested safe indirect branch capability level not supported by tcg, try a different value for cap-ibs"); | ||
98 | 67 | - } else if (kvm_enabled() && val && (val != kvm_val)) { | ||
99 | 68 | + } else if (kvm_enabled() && (val > kvm_val)) { | ||
100 | 69 | error_setg(errp, | ||
101 | 70 | "Requested safe indirect branch capability level not supported by kvm, try cap-ibs=%s", | ||
102 | 71 | cap_ibs_possible.vals[kvm_val]); | ||
103 | 72 | @@ -494,7 +492,8 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { | ||
104 | 73 | [SPAPR_CAP_IBS] = { | ||
105 | 74 | .name = "ibs", | ||
106 | 75 | .description = | ||
107 | 76 | - "Indirect Branch Speculation (broken, fixed-ibs, fixed-ccd)", | ||
108 | 77 | + "Indirect Branch Speculation (broken, workaround, fixed-ibs," | ||
109 | 78 | + "fixed-ccd, fixed-na)", | ||
110 | 79 | .index = SPAPR_CAP_IBS, | ||
111 | 80 | .get = spapr_cap_get_string, | ||
112 | 81 | .set = spapr_cap_set_string, | ||
113 | 82 | diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c | ||
114 | 83 | index 476bad6271..4aa8036fc0 100644 | ||
115 | 84 | --- a/hw/ppc/spapr_hcall.c | ||
116 | 85 | +++ b/hw/ppc/spapr_hcall.c | ||
117 | 86 | @@ -1723,12 +1723,17 @@ static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu, | ||
118 | 87 | } | ||
119 | 88 | |||
120 | 89 | switch (safe_indirect_branch) { | ||
121 | 90 | + case SPAPR_CAP_FIXED_NA: | ||
122 | 91 | + break; | ||
123 | 92 | case SPAPR_CAP_FIXED_CCD: | ||
124 | 93 | characteristics |= H_CPU_CHAR_CACHE_COUNT_DIS; | ||
125 | 94 | break; | ||
126 | 95 | case SPAPR_CAP_FIXED_IBS: | ||
127 | 96 | characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED; | ||
128 | 97 | break; | ||
129 | 98 | + case SPAPR_CAP_WORKAROUND: | ||
130 | 99 | + behaviour |= H_CPU_BEHAV_FLUSH_COUNT_CACHE; | ||
131 | 100 | + break; | ||
132 | 101 | default: /* broken */ | ||
133 | 102 | assert(safe_indirect_branch == SPAPR_CAP_BROKEN); | ||
134 | 103 | break; | ||
135 | 104 | diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h | ||
136 | 105 | index 8efc5e0779..a7f3b1bfdd 100644 | ||
137 | 106 | --- a/include/hw/ppc/spapr.h | ||
138 | 107 | +++ b/include/hw/ppc/spapr.h | ||
139 | 108 | @@ -85,12 +85,17 @@ typedef enum { | ||
140 | 109 | /* Bool Caps */ | ||
141 | 110 | #define SPAPR_CAP_OFF 0x00 | ||
142 | 111 | #define SPAPR_CAP_ON 0x01 | ||
143 | 112 | + | ||
144 | 113 | /* Custom Caps */ | ||
145 | 114 | + | ||
146 | 115 | +/* Generic */ | ||
147 | 116 | #define SPAPR_CAP_BROKEN 0x00 | ||
148 | 117 | #define SPAPR_CAP_WORKAROUND 0x01 | ||
149 | 118 | #define SPAPR_CAP_FIXED 0x02 | ||
150 | 119 | +/* SPAPR_CAP_IBS (cap-ibs) */ | ||
151 | 120 | #define SPAPR_CAP_FIXED_IBS 0x02 | ||
152 | 121 | #define SPAPR_CAP_FIXED_CCD 0x03 | ||
153 | 122 | +#define SPAPR_CAP_FIXED_NA 0x10 /* Lets leave a bit of a gap... */ | ||
154 | 123 | |||
155 | 124 | typedef struct sPAPRCapabilities sPAPRCapabilities; | ||
156 | 125 | struct sPAPRCapabilities { | ||
157 | 126 | @@ -339,9 +344,11 @@ struct sPAPRMachineState { | ||
158 | 127 | #define H_CPU_CHAR_HON_BRANCH_HINTS PPC_BIT(5) | ||
159 | 128 | #define H_CPU_CHAR_THR_RECONF_TRIG PPC_BIT(6) | ||
160 | 129 | #define H_CPU_CHAR_CACHE_COUNT_DIS PPC_BIT(7) | ||
161 | 130 | +#define H_CPU_CHAR_BCCTR_FLUSH_ASSIST PPC_BIT(9) | ||
162 | 131 | #define H_CPU_BEHAV_FAVOUR_SECURITY PPC_BIT(0) | ||
163 | 132 | #define H_CPU_BEHAV_L1D_FLUSH_PR PPC_BIT(1) | ||
164 | 133 | #define H_CPU_BEHAV_BNDS_CHK_SPEC_BAR PPC_BIT(2) | ||
165 | 134 | +#define H_CPU_BEHAV_FLUSH_COUNT_CACHE PPC_BIT(5) | ||
166 | 135 | |||
167 | 136 | /* Each control block has to be on a 4K boundary */ | ||
168 | 137 | #define H_CB_ALIGNMENT 4096 | ||
169 | 138 | diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c | ||
170 | 139 | index f0f5bf9391..4d46314276 100644 | ||
171 | 140 | --- a/target/ppc/kvm.c | ||
172 | 141 | +++ b/target/ppc/kvm.c | ||
173 | 142 | @@ -2392,7 +2392,13 @@ static int parse_cap_ppc_safe_bounds_check(struct kvm_ppc_cpu_char c) | ||
174 | 143 | |||
175 | 144 | static int parse_cap_ppc_safe_indirect_branch(struct kvm_ppc_cpu_char c) | ||
176 | 145 | { | ||
177 | 146 | - if (c.character & c.character_mask & H_CPU_CHAR_CACHE_COUNT_DIS) { | ||
178 | 147 | + if ((~c.behaviour & c.behaviour_mask & H_CPU_BEHAV_FLUSH_COUNT_CACHE) && | ||
179 | 148 | + (~c.character & c.character_mask & H_CPU_CHAR_CACHE_COUNT_DIS) && | ||
180 | 149 | + (~c.character & c.character_mask & H_CPU_CHAR_BCCTRL_SERIALISED)) { | ||
181 | 150 | + return SPAPR_CAP_FIXED_NA; | ||
182 | 151 | + } else if (c.behaviour & c.behaviour_mask & H_CPU_BEHAV_FLUSH_COUNT_CACHE) { | ||
183 | 152 | + return SPAPR_CAP_WORKAROUND; | ||
184 | 153 | + } else if (c.character & c.character_mask & H_CPU_CHAR_CACHE_COUNT_DIS) { | ||
185 | 154 | return SPAPR_CAP_FIXED_CCD; | ||
186 | 155 | } else if (c.character & c.character_mask & H_CPU_CHAR_BCCTRL_SERIALISED) { | ||
187 | 156 | return SPAPR_CAP_FIXED_IBS; | ||
188 | 157 | -- | ||
189 | 158 | 2.21.0 | ||
190 | 159 | |||
191 | diff --git a/debian/patches/ubuntu/lp-1832622-0004-target-ppc-spapr-Add-SPAPR_CAP_CCF_ASSIST.patch b/debian/patches/ubuntu/lp-1832622-0004-target-ppc-spapr-Add-SPAPR_CAP_CCF_ASSIST.patch | |||
192 | 0 | new file mode 100644 | 160 | new file mode 100644 |
193 | index 0000000..3bc9541 | |||
194 | --- /dev/null | |||
195 | +++ b/debian/patches/ubuntu/lp-1832622-0004-target-ppc-spapr-Add-SPAPR_CAP_CCF_ASSIST.patch | |||
196 | @@ -0,0 +1,216 @@ | |||
197 | 1 | From 77012c6029ae15328f04ddcb713f459cdacffef9 Mon Sep 17 00:00:00 2001 | ||
198 | 2 | From: Suraj Jitindar Singh <sjitindarsingh@gmail.com> | ||
199 | 3 | Date: Fri, 1 Mar 2019 14:19:12 +1100 | ||
200 | 4 | Subject: [PATCH] target/ppc/spapr: Add SPAPR_CAP_CCF_ASSIST | ||
201 | 5 | |||
202 | 6 | Introduce a new spapr_cap SPAPR_CAP_CCF_ASSIST to be used to indicate | ||
203 | 7 | the requirement for a hw-assisted version of the count cache flush | ||
204 | 8 | workaround. | ||
205 | 9 | |||
206 | 10 | The count cache flush workaround is a software workaround which can be | ||
207 | 11 | used to flush the count cache on context switch. Some revisions of | ||
208 | 12 | hardware may have a hardware accelerated flush, in which case the | ||
209 | 13 | software flush can be shortened. This cap is used to set the | ||
210 | 14 | availability of such hardware acceleration for the count cache flush | ||
211 | 15 | routine. | ||
212 | 16 | |||
213 | 17 | The availability of such hardware acceleration is indicated by the | ||
214 | 18 | H_CPU_CHAR_BCCTR_FLUSH_ASSIST flag being set in the characteristics | ||
215 | 19 | returned from the KVM_PPC_GET_CPU_CHAR ioctl. | ||
216 | 20 | |||
217 | 21 | Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com> | ||
218 | 22 | Message-Id: <20190301031912.28809-2-sjitindarsingh@gmail.com> | ||
219 | 23 | [dwg: Small style fixes] | ||
220 | 24 | |||
221 | 25 | Origin: backport, https://git.qemu.org/?p=qemu.git;a=commit;h=8ff43ee404d3e295839d1fd4e9e6571ca7a62a66 | ||
222 | 26 | Author: Christian Ehrhardt <christian.ehrhardt@canonical.com> | ||
223 | 27 | Original-Author: Suraj Jitindar Singh <sjitindarsingh@gmail.com> | ||
224 | 28 | Bug-Ubuntu: https://bugs.launchpad.net/bugs/1832622 | ||
225 | 29 | Last-Update: 2019-06-13 | ||
226 | 30 | |||
227 | 31 | --- | ||
228 | 32 | hw/ppc/spapr.c | 2 ++ | ||
229 | 33 | hw/ppc/spapr_caps.c | 25 +++++++++++++++++++++++++ | ||
230 | 34 | hw/ppc/spapr_hcall.c | 5 +++++ | ||
231 | 35 | include/hw/ppc/spapr.h | 5 ++++- | ||
232 | 36 | target/ppc/kvm.c | 16 ++++++++++++++++ | ||
233 | 37 | target/ppc/kvm_ppc.h | 6 ++++++ | ||
234 | 38 | 6 files changed, 58 insertions(+), 1 deletion(-) | ||
235 | 39 | |||
236 | 40 | --- a/hw/ppc/spapr.c | ||
237 | 41 | +++ b/hw/ppc/spapr.c | ||
238 | 42 | @@ -1939,6 +1939,7 @@ static const VMStateDescription vmstate_ | ||
239 | 43 | &vmstate_spapr_cap_ibs, | ||
240 | 44 | &vmstate_spapr_irq_map, | ||
241 | 45 | &vmstate_spapr_cap_nested_kvm_hv, | ||
242 | 46 | + &vmstate_spapr_cap_ccf_assist, | ||
243 | 47 | NULL | ||
244 | 48 | } | ||
245 | 49 | }; | ||
246 | 50 | @@ -3904,6 +3905,7 @@ static void spapr_machine_class_init(Obj | ||
247 | 51 | smc->default_caps.caps[SPAPR_CAP_IBS] = SPAPR_CAP_BROKEN; | ||
248 | 52 | smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] = 16; /* 64kiB */ | ||
249 | 53 | smc->default_caps.caps[SPAPR_CAP_NESTED_KVM_HV] = SPAPR_CAP_OFF; | ||
250 | 54 | + smc->default_caps.caps[SPAPR_CAP_CCF_ASSIST] = SPAPR_CAP_OFF; | ||
251 | 55 | spapr_caps_add_properties(smc, &error_abort); | ||
252 | 56 | smc->irq = &spapr_irq_xics; | ||
253 | 57 | } | ||
254 | 58 | --- a/hw/ppc/spapr_caps.c | ||
255 | 59 | +++ b/hw/ppc/spapr_caps.c | ||
256 | 60 | @@ -388,6 +388,21 @@ static void cap_nested_kvm_hv_apply(sPAP | ||
257 | 61 | } | ||
258 | 62 | } | ||
259 | 63 | |||
260 | 64 | +static void cap_ccf_assist_apply(sPAPRMachineState *spapr, uint8_t val, | ||
261 | 65 | + Error **errp) | ||
262 | 66 | +{ | ||
263 | 67 | + uint8_t kvm_val = kvmppc_get_cap_count_cache_flush_assist(); | ||
264 | 68 | + | ||
265 | 69 | + if (tcg_enabled() && val) { | ||
266 | 70 | + /* TODO - for now only allow broken for TCG */ | ||
267 | 71 | + error_setg(errp, | ||
268 | 72 | +"Requested count cache flush assist capability level not supported by tcg, try cap-ccf-assist=off"); | ||
269 | 73 | + } else if (kvm_enabled() && (val > kvm_val)) { | ||
270 | 74 | + error_setg(errp, | ||
271 | 75 | +"Requested count cache flush assist capability level not supported by kvm, try cap-ccf-assist=off"); | ||
272 | 76 | + } | ||
273 | 77 | +} | ||
274 | 78 | + | ||
275 | 79 | sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] = { | ||
276 | 80 | [SPAPR_CAP_HTM] = { | ||
277 | 81 | .name = "htm", | ||
278 | 82 | @@ -467,6 +482,15 @@ sPAPRCapabilityInfo capability_table[SPA | ||
279 | 83 | .type = "bool", | ||
280 | 84 | .apply = cap_nested_kvm_hv_apply, | ||
281 | 85 | }, | ||
282 | 86 | + [SPAPR_CAP_CCF_ASSIST] = { | ||
283 | 87 | + .name = "ccf-assist", | ||
284 | 88 | + .description = "Count Cache Flush Assist via HW Instruction", | ||
285 | 89 | + .index = SPAPR_CAP_CCF_ASSIST, | ||
286 | 90 | + .get = spapr_cap_get_bool, | ||
287 | 91 | + .set = spapr_cap_set_bool, | ||
288 | 92 | + .type = "bool", | ||
289 | 93 | + .apply = cap_ccf_assist_apply, | ||
290 | 94 | + }, | ||
291 | 95 | }; | ||
292 | 96 | |||
293 | 97 | static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, | ||
294 | 98 | @@ -595,6 +619,7 @@ SPAPR_CAP_MIG_STATE(cfpc, SPAPR_CAP_CFPC | ||
295 | 99 | SPAPR_CAP_MIG_STATE(sbbc, SPAPR_CAP_SBBC); | ||
296 | 100 | SPAPR_CAP_MIG_STATE(ibs, SPAPR_CAP_IBS); | ||
297 | 101 | SPAPR_CAP_MIG_STATE(nested_kvm_hv, SPAPR_CAP_NESTED_KVM_HV); | ||
298 | 102 | +SPAPR_CAP_MIG_STATE(ccf_assist, SPAPR_CAP_CCF_ASSIST); | ||
299 | 103 | |||
300 | 104 | void spapr_caps_init(sPAPRMachineState *spapr) | ||
301 | 105 | { | ||
302 | 106 | --- a/hw/ppc/spapr_hcall.c | ||
303 | 107 | +++ b/hw/ppc/spapr_hcall.c | ||
304 | 108 | @@ -1674,6 +1674,8 @@ static target_ulong h_get_cpu_characteri | ||
305 | 109 | uint8_t safe_cache = spapr_get_cap(spapr, SPAPR_CAP_CFPC); | ||
306 | 110 | uint8_t safe_bounds_check = spapr_get_cap(spapr, SPAPR_CAP_SBBC); | ||
307 | 111 | uint8_t safe_indirect_branch = spapr_get_cap(spapr, SPAPR_CAP_IBS); | ||
308 | 112 | + uint8_t count_cache_flush_assist = spapr_get_cap(spapr, | ||
309 | 113 | + SPAPR_CAP_CCF_ASSIST); | ||
310 | 114 | |||
311 | 115 | switch (safe_cache) { | ||
312 | 116 | case SPAPR_CAP_WORKAROUND: | ||
313 | 117 | @@ -1714,6 +1716,9 @@ static target_ulong h_get_cpu_characteri | ||
314 | 118 | break; | ||
315 | 119 | case SPAPR_CAP_WORKAROUND: | ||
316 | 120 | behaviour |= H_CPU_BEHAV_FLUSH_COUNT_CACHE; | ||
317 | 121 | + if (count_cache_flush_assist) { | ||
318 | 122 | + characteristics |= H_CPU_CHAR_BCCTR_FLUSH_ASSIST; | ||
319 | 123 | + } | ||
320 | 124 | break; | ||
321 | 125 | default: /* broken */ | ||
322 | 126 | assert(safe_indirect_branch == SPAPR_CAP_BROKEN); | ||
323 | 127 | --- a/include/hw/ppc/spapr.h | ||
324 | 128 | +++ b/include/hw/ppc/spapr.h | ||
325 | 129 | @@ -72,8 +72,10 @@ typedef enum { | ||
326 | 130 | #define SPAPR_CAP_HPT_MAXPAGESIZE 0x06 | ||
327 | 131 | /* Nested KVM-HV */ | ||
328 | 132 | #define SPAPR_CAP_NESTED_KVM_HV 0x07 | ||
329 | 133 | +/* Count Cache Flush Assist HW Instruction */ | ||
330 | 134 | +#define SPAPR_CAP_CCF_ASSIST 0x08 | ||
331 | 135 | /* Num Caps */ | ||
332 | 136 | -#define SPAPR_CAP_NUM (SPAPR_CAP_NESTED_KVM_HV + 1) | ||
333 | 137 | +#define SPAPR_CAP_NUM (SPAPR_CAP_CCF_ASSIST + 1) | ||
334 | 138 | |||
335 | 139 | /* | ||
336 | 140 | * Capability Values | ||
337 | 141 | @@ -801,6 +803,7 @@ extern const VMStateDescription vmstate_ | ||
338 | 142 | extern const VMStateDescription vmstate_spapr_cap_sbbc; | ||
339 | 143 | extern const VMStateDescription vmstate_spapr_cap_ibs; | ||
340 | 144 | extern const VMStateDescription vmstate_spapr_cap_nested_kvm_hv; | ||
341 | 145 | +extern const VMStateDescription vmstate_spapr_cap_ccf_assist; | ||
342 | 146 | |||
343 | 147 | static inline uint8_t spapr_get_cap(sPAPRMachineState *spapr, int cap) | ||
344 | 148 | { | ||
345 | 149 | --- a/target/ppc/kvm.c | ||
346 | 150 | +++ b/target/ppc/kvm.c | ||
347 | 151 | @@ -91,6 +91,7 @@ static int cap_ppc_pvr_compat; | ||
348 | 152 | static int cap_ppc_safe_cache; | ||
349 | 153 | static int cap_ppc_safe_bounds_check; | ||
350 | 154 | static int cap_ppc_safe_indirect_branch; | ||
351 | 155 | +static int cap_ppc_count_cache_flush_assist; | ||
352 | 156 | static int cap_ppc_nested_kvm_hv; | ||
353 | 157 | |||
354 | 158 | static uint32_t debug_inst_opcode; | ||
355 | 159 | @@ -2391,6 +2392,14 @@ static int parse_cap_ppc_safe_indirect_b | ||
356 | 160 | return 0; | ||
357 | 161 | } | ||
358 | 162 | |||
359 | 163 | +static int parse_cap_ppc_count_cache_flush_assist(struct kvm_ppc_cpu_char c) | ||
360 | 164 | +{ | ||
361 | 165 | + if (c.character & c.character_mask & H_CPU_CHAR_BCCTR_FLUSH_ASSIST) { | ||
362 | 166 | + return 1; | ||
363 | 167 | + } | ||
364 | 168 | + return 0; | ||
365 | 169 | +} | ||
366 | 170 | + | ||
367 | 171 | static void kvmppc_get_cpu_characteristics(KVMState *s) | ||
368 | 172 | { | ||
369 | 173 | struct kvm_ppc_cpu_char c; | ||
370 | 174 | @@ -2413,6 +2422,8 @@ static void kvmppc_get_cpu_characteristi | ||
371 | 175 | cap_ppc_safe_cache = parse_cap_ppc_safe_cache(c); | ||
372 | 176 | cap_ppc_safe_bounds_check = parse_cap_ppc_safe_bounds_check(c); | ||
373 | 177 | cap_ppc_safe_indirect_branch = parse_cap_ppc_safe_indirect_branch(c); | ||
374 | 178 | + cap_ppc_count_cache_flush_assist = | ||
375 | 179 | + parse_cap_ppc_count_cache_flush_assist(c); | ||
376 | 180 | } | ||
377 | 181 | |||
378 | 182 | int kvmppc_get_cap_safe_cache(void) | ||
379 | 183 | @@ -2430,6 +2441,11 @@ int kvmppc_get_cap_safe_indirect_branch( | ||
380 | 184 | return cap_ppc_safe_indirect_branch; | ||
381 | 185 | } | ||
382 | 186 | |||
383 | 187 | +int kvmppc_get_cap_count_cache_flush_assist(void) | ||
384 | 188 | +{ | ||
385 | 189 | + return cap_ppc_count_cache_flush_assist; | ||
386 | 190 | +} | ||
387 | 191 | + | ||
388 | 192 | bool kvmppc_has_cap_nested_kvm_hv(void) | ||
389 | 193 | { | ||
390 | 194 | return !!cap_ppc_nested_kvm_hv; | ||
391 | 195 | --- a/target/ppc/kvm_ppc.h | ||
392 | 196 | +++ b/target/ppc/kvm_ppc.h | ||
393 | 197 | @@ -62,6 +62,7 @@ bool kvmppc_has_cap_mmu_hash_v3(void); | ||
394 | 198 | int kvmppc_get_cap_safe_cache(void); | ||
395 | 199 | int kvmppc_get_cap_safe_bounds_check(void); | ||
396 | 200 | int kvmppc_get_cap_safe_indirect_branch(void); | ||
397 | 201 | +int kvmppc_get_cap_count_cache_flush_assist(void); | ||
398 | 202 | bool kvmppc_has_cap_nested_kvm_hv(void); | ||
399 | 203 | int kvmppc_set_cap_nested_kvm_hv(int enable); | ||
400 | 204 | int kvmppc_enable_hwrng(void); | ||
401 | 205 | @@ -321,6 +322,11 @@ static inline int kvmppc_get_cap_safe_in | ||
402 | 206 | { | ||
403 | 207 | return 0; | ||
404 | 208 | } | ||
405 | 209 | + | ||
406 | 210 | +static inline int kvmppc_get_cap_count_cache_flush_assist(void) | ||
407 | 211 | +{ | ||
408 | 212 | + return 0; | ||
409 | 213 | +} | ||
410 | 214 | |||
411 | 215 | static inline bool kvmppc_has_cap_nested_kvm_hv(void) | ||
412 | 216 | { |
Related test PPA at [1].
This started with the provided backports for 2.11 and then one by one taking away changes no more needed on the backports. The commits that "undo some backports" are intentionally not squashed so one can see what changes in between the versions and what is the same.
[1]: https:/ /launchpad. net/~paelzer/ +archive/ ubuntu/ bug-1832622- qemu-spectre- ppc