SMTDOCv2 0
PATCH 1/1 SMTDOCv2 0
Add a document describing when and how to disable L1TF for KVM. The goal is to avoid disabling as much as possible to keep the performance benefits from SMT.
The warning message from KVM when SMT is on can point to this document.
---
An open item is still how to handle interrupts for the "confined cores" case. Right now it describes the sledge hammer of changing the affinity of all interrupts, but that's likely not needed in all cases. I'll send another email on this.
v2: Fix typos, fix SMT on sequence.
--- Documentation/virtual/kvm/l1tf-mitigation.txt | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/virtual/kvm/l1tf-mitigation.txt
Documentation/virtual/kvm/l1tf-mitigation.txt new file +69 -0
@@ -0,0 +1,69 @@ +L1TF mitigation strategies in KVM + +On some Intel CPUs a side channel attack may make it possible to read +arbitrary data in the L1D cache of the CPU core in the guest, potentially allowing +to read data from outside the VM. + +The Linux kernel automatically detects the conditions for this problem +and reports the status in /sys/devices/system/cpu/vulnerabilities/l1tf. + +With HyperThreading (SMT) enabled the L1D cache of a core is shared between the two +CPU threads in a core. + +KVM mitigates this problems transparently when SMT is disabled. With SMT +enabled additional actions may be needed. This document describes +these additional actions. + +- When the system does not support HyperThreading no further +effort is needed. + +This can be determined with + +% lscpu | grep Thread + +If the reported Thread number is 1 then HyperThreading is not +available. + +- When the guest is not running any untrusted code then +no further action is needed. + +- When the guest kernel is controlled by the host owner the only +mitigation needed is to update the guest kernel to a kernel version +with L1TF page table mitigation integrated. + +This will prevent any untrusted user programs running in the guest attacking +the host, other guests, or other processes running inside the guest. + +When this is done no further action is needed. + +- When the guest is already confined to a dedicated core that +does not run any host processes or other guests on either of its threads +no further action is needed. + +The core could still in some cases process interrupts. + +The interrupts can be redirected to other cores using the +/proc/irq/NUMBER/smp_affinity interface. + +- When the guest is not confined it can be confined to dedicated cores +through exclusive cpusets. This does not necessarily need to be dedicated +cores for each guest, but could be also dedicated cores for a group +of VMs controlled by the same entity. + +For more details on cpusets please see Documentation/cgroup-v1/cpusets.txt + +- If this all fails SMT can be disabled on all cores + +SMT improves performance so it should be only disabled when absolutely +needed, and reenabled after the untrusted guest is finished. + +To disable SMT: + +echo off > /sys/devices/system/cpu/smt/control + +To reenable after running untrusted guest + +echo on > /sys/devices/system/cpu/smt/control +for i in /sys/devices/system/cpu/cpu*/online ; do + echo 1 > $i +done
Signature · 1 line
2.14.4
Documentation/virtual/kvm/l1tf-mitigation.txt
Quoted 2 lines · speck for Andi Kleen
Documentation/virtual/kvm/l1tf-mitigation.txt new file +0
-0
I seem to remember that I asked for RST format. Aside of that we really want to start a proper documentation section about all that speculation nonsense and not having a random text file here and there.
Documentation/virtual/kvm/l1tf-mitigation.txt line 2
Quoted 3 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +2
-0@@ -0,0 +1,69 @@ +L1TF mitigation strategies in KVM +On some Intel CPUs a side channel attack may make it possible to read
On some? L1TF affects every fricking Intel CPU with EPT except a few ATOMs.
Documentation/virtual/kvm/l1tf-mitigation.txt line 5
Quoted 2 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +2
-0+arbitrary data in the L1D cache of the CPU core in the guest, potentially allowing +to read data from outside the VM.
This really wants to be explained so that the admin who is supposed to read that understands the mechanims at least at the high level. That 'may/potentially' weasel wording is not at all helpful to make decisions about the mitigations.
Documentation/virtual/kvm/l1tf-mitigation.txt line 11
Quoted 5 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +5
-0+The Linux kernel automatically detects the conditions for this problem +and reports the status in /sys/devices/system/cpu/vulnerabilities/l1tf. + +With HyperThreading (SMT) enabled the L1D cache of a core is shared between the two +CPU threads in a core.
And the consequence of this is? I surely know, but the people who seek advice not necessarily so.
Documentation/virtual/kvm/l1tf-mitigation.txt line 13
Quoted 1 line
Documentation/virtual/kvm/l1tf-mitigation.txt new file +1
-0+KVM mitigates this problems transparently when SMT is disabled. With SMT
Wrong. This depends on L1D Flush and contrary to your believe there are valid reasons to make L1D flushing controllable.
Documentation/virtual/kvm/l1tf-mitigation.txt line 25
Quoted 12 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +12
-0+enabled additional actions may be needed. This document describes +these additional actions. + +- When the system does not support HyperThreading no further +effort is needed. + +This can be determined with + +% lscpu | grep Thread + +If the reported Thread number is 1 then HyperThreading is not +available.
Groan.
/sys/devices/system/cpu/smt/control/sys/devices/system/cpu/smt/active
are there for exactly this.
Quoted 19 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +19
-0+- When the guest is not running any untrusted code then +no further action is needed. + +- When the guest kernel is controlled by the host owner the only +mitigation needed is to update the guest kernel to a kernel version +with L1TF page table mitigation integrated. + +This will prevent any untrusted user programs running in the guest attacking +the host, other guests, or other processes running inside the guest. + +When this is done no further action is needed. + +- When the guest is already confined to a dedicated core that +does not run any host processes or other guests on either of its threads +no further action is needed. + +The core could still in some cases process interrupts. + +The interrupts can be redirected to other cores using the
Documentation/virtual/kvm/l1tf-mitigation.txt line 55
Quoted 10 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +10
-0+/proc/irq/NUMBER/smp_affinity interface. + +- When the guest is not confined it can be confined to dedicated cores +through exclusive cpusets. This does not necessarily need to be dedicated +cores for each guest, but could be also dedicated cores for a group +of VMs controlled by the same entity. + +For more details on cpusets please see Documentation/cgroup-v1/cpusets.txt + +- If this all fails SMT can be disabled on all cores
Fails? How should someone who is not familiar with the deep details of that decided that the above fails?
Documentation/virtual/kvm/l1tf-mitigation.txt line 53
Quoted 2 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +2
-0+ +SMT improves performance so it should be only disabled when absolutely
SMT improves performance depending on the workload. There are workloads which are negatively impacted by SMT.
That said, this all wants to be properly structured and explained in detail. A hastily cobbled together string of syllables does not make a document which is intended to provide guidance to people who do not have a deep technical insight into this.
Thanks,
tglx
Quoted 5 lines · speck for Thomas Gleixner
Documentation/virtual/kvm/l1tf-mitigation.txt
Quoted 2 lines · speck for Andi Kleen
Documentation/virtual/kvm/l1tf-mitigation.txt new file +0
-0I seem to remember that I asked for RST format. Aside of that we really
I probably lost that somewhere in your flood of ad hominems.
Quoted 5 lines
Documentation/virtual/kvm/l1tf-mitigation.txt line 2
Quoted 3 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +2
-0@@ -0,0 +1,69 @@ +L1TF mitigation strategies in KVM +On some Intel CPUs a side channel attack may make it possible to readOn some? L1TF affects every fricking Intel CPU with EPT except a few ATOMs.
Think what will the state be when someone reads this in two years.
Quoted 8 lines
Documentation/virtual/kvm/l1tf-mitigation.txt line 5
Quoted 3 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +2
-0+arbitrary data in the L1D cache of the CPU core in the guest, potentially allowing +to read data from outside the VM.This really wants to be explained so that the admin who is supposed to read that understands the mechanims at least at the high level. That 'may/potentially' weasel wording is not at all helpful to make decisions about the mitigations.
There will be an Intel white paper with details, we can point to that later. I don't think going into micro architectural details here will help any admin.
Quoted 3 lines
Fails? How should someone who is not familiar with the deep details of that decided that the above fails?
It's a list of actions all with preconditions. For each it is clear if you can or cannot do the action.
Quoted 11 lines
Documentation/virtual/kvm/l1tf-mitigation.txt line 6
Quoted 3 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +2
-0+ +SMT improves performance so it should be only disabled when absolutelySMT improves performance depending on the workload. There are workloads which are negatively impacted by SMT.
That said, this all wants to be properly structured and explained in detail. A hastily cobbled together string of syllables does not make a document which is intended to provide guidance to people who do not have a deep technical insight into this.
We can perhaps expand some things slightly.
But I doubt any admin is interested in reading a novel on this here. I certainly wouldn't be. There will be plenty of other material elsewhere for people who want all the gory details.
-Andi
Quoted 4 lines · speck for Andi Kleen
Quoted 1 line · speck for Thomas Gleixner
On some? L1TF affects every fricking Intel CPU with EPT except a few ATOMs.
Think what will the state be when someone reads this in two years.
It's not rocket science to spell it out in a way which is still valid in two years.
Quoted 11 lines
Quoted 7 lines
Documentation/virtual/kvm/l1tf-mitigation.txt line 5
Quoted 2 lines
Documentation/virtual/kvm/l1tf-mitigation.txt new file +2
-0+arbitrary data in the L1D cache of the CPU core in the guest, potentially allowing +to read data from outside the VM.This really wants to be explained so that the admin who is supposed to read that understands the mechanims at least at the high level. That 'may/potentially' weasel wording is not at all helpful to make decisions about the mitigations.
There will be an Intel white paper with details, we can point to that later. I don't think going into micro architectural details here will help any admin.
It's not about micro architectural details, but there needs to be some high level explanation so the administrator can make a judgement about the different mitigation methods.
Quoted 5 lines
Quoted 2 lines
Fails? How should someone who is not familiar with the deep details of that decided that the above fails?
It's a list of actions all with preconditions. For each it is clear if you can or cannot do the action.
Oh well..
Quoted 10 lines
Quoted 9 lines
Quoted 1 line
+SMT improves performance so it should be only disabled when absolutely
SMT improves performance depending on the workload. There are workloads which are negatively impacted by SMT.
That said, this all wants to be properly structured and explained in detail. A hastily cobbled together string of syllables does not make a document which is intended to provide guidance to people who do not have a deep technical insight into this.
Quoted 5 lines
We can perhaps expand some things slightly.
But I doubt any admin is interested in reading a novel on this here. I certainly wouldn't be. There will be plenty of other material elsewhere for people who want all the gory details.
Nobody asks you to write a novel. But a consice documentation is surely due. Aside of that it does not matter how much other material will be available. This is about documentation the kernel provides and I consider it bad practice to throw a few bones into a text file just to claim that we have documentation. You might be content with that scrap paper, but most people prefer and appreciate proper written documentation.
Thanks,
tglx