File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,8 @@ def apply_defaults(self):
82
82
if self .machine_is ('pseries' ):
83
83
if self .accel == 'tcg' :
84
84
self .machine_caps += ['cap-htm=off' ]
85
+ else :
86
+ self .__set_spectre_v2_caps ()
85
87
86
88
if self .cpu and self .accel == 'kvm' :
87
89
if self .cpu != 'host' :
@@ -243,6 +245,19 @@ def prepare_cloud_image(self):
243
245
self .cmdline .insert (0 , 'systemd.mask=hcn-init.service systemd.hostname=fedora' )
244
246
self .cmdline .insert (0 , f'root=/dev/vd{ cloud_drive } 5 rootfstype=btrfs rootflags=subvol=root' )
245
247
248
+ def __set_spectre_v2_caps (self ):
249
+ try :
250
+ body = open ('/sys/devices/system/cpu/vulnerabilities/spectre_v2' , 'r' ).read ()
251
+ except (FileNotFoundError , PermissionError ):
252
+ # Should be readable, but continue anyway and cross fingers
253
+ return
254
+
255
+ for s in ['Indirect branch cache disabled' , 'Software count cache flush' ]:
256
+ if s in body :
257
+ return
258
+
259
+ self .machine_caps += ['cap-ccf-assist=off' ]
260
+
246
261
def cmd (self ):
247
262
logging .info ('Using qemu version %s.%s "%s"' % get_qemu_version (self .qemu_path ))
248
263
You can’t perform that action at this time.
0 commit comments