File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,6 +82,8 @@ def apply_defaults(self):
8282 if self .machine_is ('pseries' ):
8383 if self .accel == 'tcg' :
8484 self .machine_caps += ['cap-htm=off' ]
85+ else :
86+ self .__set_spectre_v2_caps ()
8587
8688 if self .cpu and self .accel == 'kvm' :
8789 if self .cpu != 'host' :
@@ -243,6 +245,19 @@ def prepare_cloud_image(self):
243245 self .cmdline .insert (0 , 'systemd.mask=hcn-init.service systemd.hostname=fedora' )
244246 self .cmdline .insert (0 , f'root=/dev/vd{ cloud_drive } 5 rootfstype=btrfs rootflags=subvol=root' )
245247
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+
246261 def cmd (self ):
247262 logging .info ('Using qemu version %s.%s "%s"' % get_qemu_version (self .qemu_path ))
248263
You can’t perform that action at this time.
0 commit comments