Commit 384bb63
Tobias Huschle
KVM: s390: pv: don't allow userspace to set the clock under PV
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2154283
Upstream status: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Tested: by IBM
Build-Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=49687044
Conflicts: N
commit 6973091
Author: Nico Boehr <nrb@linux.ibm.com>
Date: Tue Oct 11 18:07:12 2022 +0200
KVM: s390: pv: don't allow userspace to set the clock under PV
When running under PV, the guest's TOD clock is under control of the
ultravisor and the hypervisor isn't allowed to change it. Hence, don't
allow userspace to change the guest's TOD clock by returning
-EOPNOTSUPP.
When userspace changes the guest's TOD clock, KVM updates its
kvm.arch.epoch field and, in addition, the epoch field in all state
descriptions of all VCPUs.
But, under PV, the ultravisor will ignore the epoch field in the state
description and simply overwrite it on next SIE exit with the actual
guest epoch. This leads to KVM having an incorrect view of the guest's
TOD clock: it has updated its internal kvm.arch.epoch field, but the
ultravisor ignores the field in the state description.
Whenever a guest is now waiting for a clock comparator, KVM will
incorrectly calculate the time when the guest should wake up, possibly
causing the guest to sleep for much longer than expected.
With this change, kvm_s390_set_tod() will now take the kvm->lock to be
able to call kvm_s390_pv_is_protected(). Since kvm_s390_set_tod_clock()
also takes kvm->lock, use __kvm_s390_set_tod_clock() instead.
The function kvm_s390_set_tod_clock is now unused, hence remove it.
Update the documentation to indicate the TOD clock attr calls can now
return -EOPNOTSUPP.
Fixes: 0f30350 ("KVM: s390: protvirt: Do only reset registers that are accessible")
Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
Link: https://lore.kernel.org/r/20221011160712.928239-2-nrb@linux.ibm.com
Message-Id: <20221011160712.928239-2-nrb@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Tobias Huschle <thuschle@redhat.com>1 parent 616a974 commit 384bb63
File tree
3 files changed
+20
-10
lines changed- Documentation/virt/kvm/devices
- arch/s390/kvm
3 files changed
+20
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| |||
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
| 228 | + | |
227 | 229 | | |
228 | 230 | | |
229 | 231 | | |
| |||
237 | 239 | | |
238 | 240 | | |
239 | 241 | | |
| 242 | + | |
240 | 243 | | |
241 | 244 | | |
242 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1205 | 1205 | | |
1206 | 1206 | | |
1207 | 1207 | | |
| 1208 | + | |
| 1209 | + | |
1208 | 1210 | | |
1209 | 1211 | | |
1210 | 1212 | | |
| |||
1214 | 1216 | | |
1215 | 1217 | | |
1216 | 1218 | | |
1217 | | - | |
| 1219 | + | |
1218 | 1220 | | |
1219 | 1221 | | |
1220 | 1222 | | |
| |||
1245 | 1247 | | |
1246 | 1248 | | |
1247 | 1249 | | |
1248 | | - | |
| 1250 | + | |
1249 | 1251 | | |
1250 | 1252 | | |
1251 | 1253 | | |
| |||
1257 | 1259 | | |
1258 | 1260 | | |
1259 | 1261 | | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
1260 | 1272 | | |
1261 | 1273 | | |
1262 | 1274 | | |
| |||
1271 | 1283 | | |
1272 | 1284 | | |
1273 | 1285 | | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
1274 | 1289 | | |
1275 | 1290 | | |
1276 | 1291 | | |
| |||
4381 | 4396 | | |
4382 | 4397 | | |
4383 | 4398 | | |
4384 | | - | |
4385 | | - | |
4386 | | - | |
4387 | | - | |
4388 | | - | |
4389 | | - | |
4390 | | - | |
4391 | 4399 | | |
4392 | 4400 | | |
4393 | 4401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
367 | 366 | | |
368 | 367 | | |
369 | 368 | | |
| |||
0 commit comments