backport extended amd spectre mitigations

Bug #1840745 reported by Christian Ehrhardt 
260
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libvirt (Ubuntu)
Fix Released
Undecided
Unassigned
Bionic
Fix Released
Medium
Christian Ehrhardt 
qemu (Ubuntu)
Fix Released
Undecided
Unassigned
Bionic
Fix Released
Medium
Christian Ehrhardt 

Bug Description

[Impact]

  * After the initial fixes relates to Spectre were urgent and sometimes
    crude there are more and more refined/improved fixes available now.
    For details see
    124441_AMD64_SpeculativeStoreBypassDisable_Whitepaper_final.pdf
    attached to https://bugzilla.kernel.org/show_bug.cgi?id=199889

  * This small change makes those new CPU flags known to libvirt/qemu to
    pass them to the guests if wanted.

[Test Case]

 * On a system with those flags (newer AMD chips + Firmware updates)
   - "virsh capabilities" should report the amd[-no]-ssbd flag
   - if also the qemu update is available "virsh domcapabilities" should
     list it.
   - A guest started as host-model should add the feature to the guest
     definition
   - The guest should receive the flags (that is hard to see as they are
     not in e.g. /proc/cpuinfo, might need some kernel poking)

[Regression Potential]

 * This makes flags known and some modes will detect and pass all flags to
   the guest (e.g. host-model). Due to that a non patched target might not
   know about (that is common and ok through those upgrades).
 * More interesting (but still preferred to not patching it) is a guest
   that handles the use of the mitigation "wrong". Imagine a guest had not
   got the flag passed before the fix, now gets it and enables whatever
   mitigation that implies. If this mitigation is broken a formerly
   working guest would fail. Again this is a common concept through
   upgrades of the virt stack which is the reason why usually higher level
   apps check the capabilities initially and then model the features.
   Those will not change through an upgrade, only new e.g. host-model
   guest starts will model it with the new code which then will contain
   the new flags.

[Other Info]

 * n/a

---

Newer AMD FW/Chips can provide better ssbd mitigations than the initial virt-ssbd which was already backports as part of the security CVEs back when spectre appeared.

The faster mode is described in a document attached to:
  https://bugzilla.kernel.org/show_bug.cgi?id=199889

In addition via the amd-no-ssb flag chips can declare that they are unaffected and no mitigationas are needed.

libvirt
commit ver subject
2625722c 4.6 cpu: add 'amd-ssbd' and 'amd-no-ssb' CPU features (CVE-2018-3639)

Qemu:
a764f3f7 3.0 i386: define the AMD 'amd-ssbd' CPUID feature bit
254790a9 3.0 i386: Define AMD's no SSB mitigation needed.

Given that I'd expect Rome chips usage to rise and those have some of them set it makes sense to backport that to the latest LTS at least. Users are already "secure" without that but it will help to get less of a performance hit due to better (or not needed) mitigations.

Since the code already is in libvirt 4.6 and qemu 3.0 this is already in recent Ubuntu releases (>=Disco) and only about the SRU.

To be combined with the libvirt backports for the intel counterpart in bug 1828495 which needs some pre-work in Eoan at first.

Changed in libvirt (Ubuntu):
status: New → Fix Released
Changed in qemu (Ubuntu):
status: New → Fix Released
Changed in libvirt (Ubuntu Bionic):
status: New → Triaged
importance: Undecided → Medium
Changed in qemu (Ubuntu Bionic):
importance: Undecided → Medium
status: New → Triaged
assignee: nobody → Christian Ehrhardt  (paelzer)
Changed in libvirt (Ubuntu Bionic):
assignee: nobody → Christian Ehrhardt  (paelzer)
description: updated
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Changes reviewed and tested in the regression test set over night (combined with the other changes I intend to group on the SRU). Uploaded (qmeu&libvirt) to -unapproved for the SRU team to consider.

Changed in qemu (Ubuntu Bionic):
status: Triaged → In Progress
Changed in libvirt (Ubuntu Bionic):
status: Triaged → In Progress
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Pre Post capabilities on a new AMD system

ubuntu@riccioli:~$ diff -Naur old.c.xml new.c.xml
--- old.c.xml 2019-08-22 12:51:25.065200903 +0000
+++ new.c.xml 2019-08-22 12:52:08.042076692 +0000
@@ -26,6 +26,7 @@
       <feature name='perfctr_core'/>
       <feature name='perfctr_nb'/>
       <feature name='invtsc'/>
+ <feature name='amd-ssbd'/>
       <pages unit='KiB' size='4'/>
       <pages unit='KiB' size='2048'/>
       <pages unit='KiB' size='1048576'/>

domcapabilities
@@ -28,6 +28,7 @@
       <feature policy='require' name='clwb'/>
       <feature policy='require' name='cmp_legacy'/>
       <feature policy='require' name='invtsc'/>
+ <feature policy='require' name='amd-ssbd'/>
       <feature policy='disable' name='monitor'/>
     </mode>
     <mode name='custom' supported='yes'>

With that feature set I see
    <feature policy='require' name='amd-ssbd'/>
converted to
-cpu EPYC-IBPB,...,amd-ssbd=on
And the guest starts fine with it.

And the same way
    <feature policy='disable' name='amd-ssbd'/>
becomes
,amd-ssbd=off

Things seem fine, but as I got access I wanted to pre check this for the SRU.

Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello Christian, or anyone else affected,

Accepted qemu into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/qemu/1:2.11+dfsg-1ubuntu7.18 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in qemu (Ubuntu Bionic):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-bionic
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Bionic as-is:
qemu-system-x86_64 -cpu ? | grep ssb
  avx512-4vnniw avx512-4fmaps md-clear spec-ctrl arch-capabilities ssbd
  wbnoinvd ibpb virt-ssbd
  rdctl-no ibrs-all rsba skip-l1dfl-vmentry ssb-no mds-no

Upgrade to proposed:
root@b-testkvm:~# apt install qemu-utils qemu-system-x86 qemu-system-common qemu-block-extra
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  samba vde2 sgabios ovmf debootstrap
The following packages will be upgraded:
  qemu-block-extra qemu-system-common qemu-system-x86 qemu-utils
4 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.
Need to get 6782 kB of archives.
After this operation, 4096 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 qemu-utils amd64 1:2.11+dfsg-1ubuntu7.18 [866 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 qemu-system-common amd64 1:2.11+dfsg-1ubuntu7.18 [672 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 qemu-block-extra amd64 1:2.11+dfsg-1ubuntu7.18 [40.1 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 qemu-system-x86 amd64 1:2.11+dfsg-1ubuntu7.18 [5203 kB]
Fetched 6782 kB in 1s (8675 kB/s)
(Reading database ... 30081 files and directories currently installed.)
Preparing to unpack .../qemu-utils_1%3a2.11+dfsg-1ubuntu7.18_amd64.deb ...
Unpacking qemu-utils (1:2.11+dfsg-1ubuntu7.18) over (1:2.11+dfsg-1ubuntu7.17) ...
Preparing to unpack .../qemu-system-common_1%3a2.11+dfsg-1ubuntu7.18_amd64.deb ...
Unpacking qemu-system-common (1:2.11+dfsg-1ubuntu7.18) over (1:2.11+dfsg-1ubuntu7.17) ...
Preparing to unpack .../qemu-block-extra_1%3a2.11+dfsg-1ubuntu7.18_amd64.deb ...
Unpacking qemu-block-extra:amd64 (1:2.11+dfsg-1ubuntu7.18) over (1:2.11+dfsg-1ubuntu7.17) ...
Preparing to unpack .../qemu-system-x86_1%3a2.11+dfsg-1ubuntu7.18_amd64.deb ...
Unpacking qemu-system-x86 (1:2.11+dfsg-1ubuntu7.18) over (1:2.11+dfsg-1ubuntu7.17) ...
Setting up qemu-block-extra:amd64 (1:2.11+dfsg-1ubuntu7.18) ...
Setting up qemu-utils (1:2.11+dfsg-1ubuntu7.18) ...
Setting up qemu-system-common (1:2.11+dfsg-1ubuntu7.18) ...
Setting up qemu-system-x86 (1:2.11+dfsg-1ubuntu7.18) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

With the new code:
root@b-testkvm:~# qemu-system-x86_64 -cpu ? | grep ssb
  avx512-4vnniw avx512-4fmaps md-clear spec-ctrl arch-capabilities ssbd
  wbnoinvd ibpb amd-ssbd virt-ssbd amd-no-ssb
  rdctl-no ibrs-all rsba skip-l1dfl-vmentry ssb-no mds-no

We see the new features amd-ssbd and amd-no-ssb
verified for qemu - libvirt isn't accepted in proposed yet.

tags: added: verification-done verification-done-bionic
removed: verification-needed verification-needed-bionic
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (qemu/1:2.11+dfsg-1ubuntu7.18)

All autopkgtests for the newly accepted qemu (1:2.11+dfsg-1ubuntu7.18) for bionic have finished running.
The following regressions have been reported in tests triggered by the package:

ubuntu-image/1.7+18.04ubuntu1 (ppc64el, s390x)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/bionic/update_excuses.html#qemu

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qemu - 1:2.11+dfsg-1ubuntu7.18

---------------
qemu (1:2.11+dfsg-1ubuntu7.18) bionic; urgency=medium

  * d/p/ubuntu/lp-1832622-*: count cache flush Spectre v2 mitigation for ppc64
    (LP: #1832622)
  * d/p/ubuntu/lp-1840745-*: add amd ssbd / no-ssbd features (LP: #1840745)
  * d/p/ubuntu/lp-1836154-*: add HW CPU model for newer s390x machines
    (LP: #1836154)

 -- Christian Ehrhardt <email address hidden> Thu, 13 Jun 2019 08:08:33 +0200

Changed in qemu (Ubuntu Bionic):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for qemu has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Robie Basak (racb) wrote : Please test proposed package

Hello Christian, or anyone else affected,

Accepted libvirt into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/libvirt/4.0.0-1ubuntu8.13 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in libvirt (Ubuntu Bionic):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-bionic
removed: verification-done verification-done-bionic
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Download full text (5.7 KiB)

Testing Bionic:

Diff pre/post output:
virsh capabilities:
--- cap.old 2019-09-13 07:47:39.904489440 +0000
+++ cap.new 2019-09-13 07:54:17.141044569 +0000
@@ -26,6 +26,7 @@
       <feature name='perfctr_core'/>
       <feature name='perfctr_nb'/>
       <feature name='invtsc'/>
+ <feature name='amd-ssbd'/>
       <pages unit='KiB' size='4'/>
       <pages unit='KiB' size='2048'/>
       <pages unit='KiB' size='1048576'/>

virsh domcapabilities (
--- dcap.old 2019-09-13 07:47:45.944614794 +0000
+++ dcap.new 2019-09-13 07:54:09.708864451 +0000
@@ -30,6 +30,7 @@
       <feature policy='require' name='topoext'/>
       <feature policy='require' name='perfctr_core'/>
       <feature policy='require' name='invtsc'/>
+ <feature policy='require' name='amd-ssbd'/>
       <feature policy='disable' name='monitor'/>
     </mode>
     <mode name='custom' supported='yes'>

Upgrade:
$ sudo apt install libvirt-daemon-system
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libvirt-clients libvirt-daemon libvirt-daemon-driver-storage-rbd libvirt0
Suggested packages:
  libvirt-daemon-driver-storage-gluster libvirt-daemon-driver-storage-sheepdog libvirt-daemon-driver-storage-zfs numad radvd auditd systemtap nfs-common zfsutils pm-utils
The following packages will be upgraded:
  libvirt-clients libvirt-daemon libvirt-daemon-driver-storage-rbd libvirt-daemon-system libvirt0
5 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
Need to get 4116 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 libvirt-daemon-driver-storage-rbd amd64 4.0.0-1ubuntu8.13 [15.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 libvirt-daemon-system amd64 4.0.0-1ubuntu8.13 [80.7 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 libvirt-daemon amd64 4.0.0-1ubuntu8.13 [2176 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 libvirt-clients amd64 4.0.0-1ubuntu8.13 [596 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 libvirt0 amd64 4.0.0-1ubuntu8.13 [1248 kB]
Fetched 4116 kB in 1s (4660 kB/s)
Preconfiguring packages ...
(Reading database ... 71127 files and directories currently installed.)
Preparing to unpack .../libvirt-daemon-driver-storage-rbd_4.0.0-1ubuntu8.13_amd64.deb ...
Unpacking libvirt-daemon-driver-storage-rbd (4.0.0-1ubuntu8.13) over (4.0.0-1ubuntu8.12) ...
Preparing to unpack .../libvirt-daemon-system_4.0.0-1ubuntu8.13_amd64.deb ...
Unpacking libvirt-daemon-system (4.0.0-1ubuntu8.13) over (4.0.0-1ubuntu8.12) ...
Preparing to unpack .../libvirt-daemon_4.0.0-1ubuntu8.13_amd64.deb ...
Unpacking libvirt-daemon (4.0.0-1ubuntu8.13) over (4.0.0-1ubuntu8.12) ...
Preparing to unpack .../libvirt-clients_4.0.0-1ubuntu8.13_amd64.deb ...
Unpacking libvirt-clients (4.0.0-1ubuntu8.13) over (4.0.0-1ubuntu8.12) ...
Preparing to unpack .../libvirt0_4.0.0-1ubuntu8.13_amd64.deb ...
Unpacking libvirt0:amd64 (4.0.0-1ubuntu8.13) over (4.0.0-1ubuntu8.12) ...
...

Read more...

tags: added: verification-done verification-done-bionic
removed: verification-needed verification-needed-bionic
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libvirt - 4.0.0-1ubuntu8.13

---------------
libvirt (4.0.0-1ubuntu8.13) bionic; urgency=medium

  * d/p/ubuntu/lp-1840872-*: avoid hotplug issues with duplicate device
    addresses (LP: #1840872)
  * d/p/ubuntu/lp-1840745-*: add amd ssbd / no-ssbd features (LP: #1840745)

 -- Christian Ehrhardt <email address hidden> Wed, 21 Aug 2019 11:08:29 +0200

Changed in libvirt (Ubuntu Bionic):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.