Skip to contentSkip to conversation

l1tf: drop the swap storage limit restriction when l1tf=off

PATCH In review Michal Hocko 7 participants 15 messages Nov 13, 2018 – Dec 11, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 l1tf: drop the swap storage limit restriction when l1tf=off

From: Michal Hocko <[email protected]>

Swap storage is restricted to max_swapfile_size (~16TB on x86_64) whenever the system is deemed affected by L1TF vulnerability. Even though the limit is quite high for most deployments it seems to be too restrictive for deployments which are willing to live with the mitigation disabled.

We have a customer to deploy 8x 6,4TB PCIe/NVMe SSD swap devices which is clearly out of the limit.

Drop the swap restriction when l1tf=off is specified. It also doesn't make much sense to warn about too much memory for the l1tf mitigation when it is forcefully disabled by the administrator.

---
 Documentation/admin-guide/kernel-parameters.txt | 2 ++
 Documentation/admin-guide/l1tf.rst              | 5 ++++-
 arch/x86/kernel/cpu/bugs.c                      | 3 ++-
 arch/x86/mm/init.c                              | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +2 -0
index 81d1d5a74728..a54f2bd39e77 100644
@@ -2095,6 +2095,8 @@
 			off
 				Disables hypervisor mitigations and doesn't
 				emit any warnings.
+				It also drops the swap size and available
+				RAM limit restriction.
 
 			Default is 'flush'.
 
Documentation/admin-guide/l1tf.rst +4 -1
index b85dd80510b0..b00464a9c09c 100644
@@ -405,6 +405,8 @@ The kernel command line allows to control the L1TF mitigations at boot
 
   off		Disables hypervisor mitigations and doesn't emit any
 		warnings.
+		It also drops the swap size and available RAM limit restrictions.
+
   ============  =============================================================
 
 The default is 'flush'. For details about L1D flushing see :ref:`l1d_flush`.
@@ -576,7 +578,8 @@ Default mitigations
   The kernel default mitigations for vulnerable processors are:
 
   - PTE inversion to protect against malicious user space. This is done
-    unconditionally and cannot be controlled.
+    unconditionally and cannot be controlled. The swap storage is limited
+    to ~16TB.
 
   - L1D conditional flushing on VMENTER when EPT is enabled for
     a guest.
arch/x86/kernel/cpu/bugs.c +2 -1
index c37e66e493bf..761100cd3eab 100644
@@ -779,7 +779,8 @@ static void __init l1tf_select_mitigation(void)
 #endif
 
 	half_pa = (u64)l1tf_pfn_limit() << PAGE_SHIFT;
-	if (e820__mapped_any(half_pa, ULLONG_MAX - half_pa, E820_TYPE_RAM)) {
+	if (l1tf_mitigation != L1TF_MITIGATION_OFF &&
+			e820__mapped_any(half_pa, ULLONG_MAX - half_pa, E820_TYPE_RAM)) {
 		pr_warn("System has more than MAX_PA/2 memory. L1TF mitigation not effective.\n");
 		pr_info("You may make it effective by booting the kernel with mem=%llu parameter.\n",
 				half_pa);
arch/x86/mm/init.c +1 -1
index ef99f3892e1f..427a955a2cf2 100644
@@ -931,7 +931,7 @@ unsigned long max_swapfile_size(void)
 
 	pages = generic_max_swapfile_size();
 
-	if (boot_cpu_has_bug(X86_BUG_L1TF)) {
+	if (boot_cpu_has_bug(X86_BUG_L1TF) && l1tf_mitigation != L1TF_MITIGATION_OFF) {
 		/* Limit the swap file size to MAX_PA/2 for L1TF workaround */
 		unsigned long long l1tf_limit = l1tf_pfn_limit();
 		/*
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Michal Hocko

From: Michal Hocko <[email protected]>

Swap storage is restricted to max_swapfile_size (~16TB on x86_64) whenever the system is deemed affected by L1TF vulnerability. Even though the limit is quite high for most deployments it seems to be too restrictive for deployments which are willing to live with the mitigation disabled.

Quoted 8 lines

We have a customer to deploy 8x 6,4TB PCIe/NVMe SSD swap devices which is clearly out of the limit.

Drop the swap restriction when l1tf=off is specified. It also doesn't make much sense to warn about too much memory for the l1tf mitigation when it is forcefully disabled by the administrator.

Acked-by on v1 1/1
#2 lore raw
In reply to Michal Hocko
Quoted 28 lines · Michal Hocko

From: Michal Hocko <[email protected]>

Swap storage is restricted to max_swapfile_size (~16TB on x86_64) whenever the system is deemed affected by L1TF vulnerability. Even though the limit is quite high for most deployments it seems to be too restrictive for deployments which are willing to live with the mitigation disabled.

We have a customer to deploy 8x 6,4TB PCIe/NVMe SSD swap devices which is clearly out of the limit.

Drop the swap restriction when l1tf=off is specified. It also doesn't make much sense to warn about too much memory for the l1tf mitigation when it is forcefully disabled by the administrator.

---
 Documentation/admin-guide/kernel-parameters.txt | 2 ++
 Documentation/admin-guide/l1tf.rst              | 5 ++++-
 arch/x86/kernel/cpu/bugs.c                      | 3 ++-
 arch/x86/mm/init.c                              | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index 81d1d5a74728..a54f2bd39e77 100644

Documentation/admin-guide/kernel-parameters.txt line 2099

Quoted 5 lines
Documentation/admin-guide/kernel-parameters.txt +2 -0
@@ -2095,6 +2095,8 @@
 			off
 				Disables hypervisor mitigations and doesn't
 				emit any warnings.
+				It also drops the swap size and available
+				RAM limit restriction.

Minor nit: I think this should explicitly mention that those two things are related to bare metal mitigation, to avoid any confusion (as otherwise the l1tf cmdline parameter is purely about hypervisor mitigations).

With that

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#3 lore raw
Quoted 25 lines · Jiri Kosina
Quoted 23 lines · Michal Hocko

From: Michal Hocko <[email protected]>

Swap storage is restricted to max_swapfile_size (~16TB on x86_64) whenever the system is deemed affected by L1TF vulnerability. Even though the limit is quite high for most deployments it seems to be too restrictive for deployments which are willing to live with the mitigation disabled.

We have a customer to deploy 8x 6,4TB PCIe/NVMe SSD swap devices which is clearly out of the limit.

Drop the swap restriction when l1tf=off is specified. It also doesn't make much sense to warn about too much memory for the l1tf mitigation when it is forcefully disabled by the administrator.

---
 Documentation/admin-guide/kernel-parameters.txt | 2 ++
 Documentation/admin-guide/l1tf.rst              | 5 ++++-
 arch/x86/kernel/cpu/bugs.c                      | 3 ++-
 arch/x86/mm/init.c                              | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)
Quoted 14 lines

Documentation/admin-guide/kernel-parameters.txt line 2099

Quoted 10 lines
Documentation/admin-guide/kernel-parameters.txt +2 -0
index 81d1d5a74728..a54f2bd39e77 100644
@@ -2095,6 +2095,8 @@
 			off
 				Disables hypervisor mitigations and doesn't
 				emit any warnings.
+				It also drops the swap size and available
+				RAM limit restriction.

Minor nit: I think this should explicitly mention that those two things are related to bare metal mitigation, to avoid any confusion (as otherwise the l1tf cmdline parameter is purely about hypervisor mitigations).

Do you have any specific wording in mind?

It also drops the swap size and available RAM limit restrictions on both hypervisor and bare metal.

Sounds better?

Quoted 3 lines

With that

Thanks!

Signature · 2 lines
Michal Hocko
SUSE Labs
#4 lore raw
Quoted 12 lines · Michal Hocko
Quoted 6 lines

Documentation/admin-guide/kernel-parameters.txt line 2099

Quoted 2 lines
Documentation/admin-guide/kernel-parameters.txt +2 -0
+				It also drops the swap size and available
+				RAM limit restriction.

Minor nit: I think this should explicitly mention that those two things are related to bare metal mitigation, to avoid any confusion (as otherwise the l1tf cmdline parameter is purely about hypervisor mitigations).

Do you have any specific wording in mind?

It also drops the swap size and available RAM limit restrictions on both hypervisor and bare metal.

Quoted 7 lines

Sounds better?

Quoted 3 lines

With that

Thanks!

Yes, I think that makes it absolutely clear. Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#5 lore raw
Quoted 16 lines · Jiri Kosina
Quoted 14 lines · Michal Hocko
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+				It also drops the swap size and available
+				RAM limit restriction.

Minor nit: I think this should explicitly mention that those two things are related to bare metal mitigation, to avoid any confusion (as otherwise the l1tf cmdline parameter is purely about hypervisor mitigations).

Do you have any specific wording in mind?

It also drops the swap size and available RAM limit restrictions on both hypervisor and bare metal.

Sounds better?

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

With that

Thanks!

Yes, I think that makes it absolutely clear. Thanks,

OK. Here is the incremental diff on top of the patch. I will fold and repost later this week. I assume people are still catching up after LPC and I do not want to spam them even more.

Documentation/admin-guide/kernel-parameters.txt +2 -1
index a54f2bd39e77..c5aa4b4a797d 100644
@@ -2096,7 +2096,8 @@
 				Disables hypervisor mitigations and doesn't
 				emit any warnings.
 				It also drops the swap size and available
-				RAM limit restriction.
+				RAM limit restriction on both hypervisor and
+				bare metal.
 
 			Default is 'flush'.
 
Documentation/admin-guide/l1tf.rst +2 -1
index b00464a9c09c..2e65e6cb033e 100644
@@ -405,7 +405,8 @@ The kernel command line allows to control the L1TF mitigations at boot
 
   off		Disables hypervisor mitigations and doesn't emit any
 		warnings.
-		It also drops the swap size and available RAM limit restrictions.
+		It also drops the swap size and available RAM limit restrictions
+                on both hypervisor and bare metal.
 
   ============  =============================================================
 
Signature · 2 lines
Michal Hocko
SUSE Labs
#6 lore raw
Quoted 18 lines · Michal Hocko
Quoted 18 lines
Quoted 18 lines
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+				It also drops the swap size and available
+				RAM limit restriction.

Minor nit: I think this should explicitly mention that those two things are related to bare metal mitigation, to avoid any confusion (as otherwise the l1tf cmdline parameter is purely about hypervisor mitigations).

Do you have any specific wording in mind?

It also drops the swap size and available RAM limit restrictions on both hypervisor and bare metal.

Sounds better?

Quoted 3 lines

With that

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thanks!

Yes, I think that makes it absolutely clear. Thanks,

OK. Here is the incremental diff on top of the patch. I will fold and repost later this week. I assume people are still catching up after LPC and I do not want to spam them even more.

Is this queued anywhere in the meantime please?

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
#7 lore raw
Quoted 22 lines · Jiri Kosina
Quoted 20 lines · Michal Hocko
Quoted 20 lines
Quoted 19 lines
Quoted 6 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+				It also drops the swap size and available
+				RAM limit restriction.

Minor nit: I think this should explicitly mention that those two things are related to bare metal mitigation, to avoid any confusion (as otherwise the l1tf cmdline parameter is purely about hypervisor mitigations).

Do you have any specific wording in mind?

It also drops the swap size and available RAM limit restrictions on both hypervisor and bare metal.

Sounds better?

Quoted 3 lines

With that

Thanks!

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Yes, I think that makes it absolutely clear. Thanks,

OK. Here is the incremental diff on top of the patch. I will fold and repost later this week. I assume people are still catching up after LPC and I do not want to spam them even more.

Is this queued anywhere in the meantime please?

Not yet. Thanks for the reminder. It completely fall of my radar.

Thomas, do you want me to resubmit or there are some other changes you would like to see?

Signature · 2 lines
Michal Hocko
SUSE Labs
Reviewed-by on v1 1/1
#8 lore raw
In reply to Michal Hocko
Quoted 8 lines · Michal Hocko

From: Michal Hocko <[email protected]>

Swap storage is restricted to max_swapfile_size (~16TB on x86_64) whenever the system is deemed affected by L1TF vulnerability. Even though the limit is quite high for most deployments it seems to be too restrictive for deployments which are willing to live with the mitigation disabled.

Quoted 6 lines

We have a customer to deploy 8x 6,4TB PCIe/NVMe SSD swap devices which is clearly out of the limit.

Drop the swap restriction when l1tf=off is specified. It also doesn't make much sense to warn about too much memory for the l1tf mitigation when it is forcefully disabled by the administrator.

-Andi

#9 lore raw

[tip:x86/pti] x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off

In reply to Michal Hocko
x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off
Commit-ID:  f4abaa98c4575cc06ea5e1a593e3bc2c8de8ef48
Gitweb:     https://git.kernel.org/tip/f4abaa98c4575cc06ea5e1a593e3bc2c8de8ef48
Author:     Michal Hocko <[email protected]>
AuthorDate: Tue, 13 Nov 2018 19:49:10 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Mon, 10 Dec 2018 22:07:02 +0100

x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off

Swap storage is restricted to max_swapfile_size (~16TB on x86_64) whenever the system is deemed affected by L1TF vulnerability. Even though the limit is quite high for most deployments it seems to be too restrictive for deployments which are willing to live with the mitigation disabled.

We have a customer to deploy 8x 6,4TB PCIe/NVMe SSD swap devices which is clearly out of the limit.

Drop the swap restriction when l1tf=off is specified. It also doesn't make much sense to warn about too much memory for the l1tf mitigation when it is forcefully disabled by the administrator.

[ tglx: Folded the documentation delta change ]

Fixes 377eeaa8e11f ("x86/speculation/l1tf: Limit swap file size to MAX_PA/2")
Cc Linus Torvalds <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Borislav Petkov <[email protected]>
---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 Documentation/admin-guide/l1tf.rst              | 6 +++++-
 arch/x86/kernel/cpu/bugs.c                      | 3 ++-
 arch/x86/mm/init.c                              | 2 +-
 4 files changed, 11 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
index 05a252e5178d..835e422572eb 100644
@@ -2095,6 +2095,9 @@
 			off
 				Disables hypervisor mitigations and doesn't
 				emit any warnings.
+				It also drops the swap size and available
+				RAM limit restriction on both hypervisor and
+				bare metal.
 
 			Default is 'flush'.
 
Documentation/admin-guide/l1tf.rst +5 -1
index b85dd80510b0..2e65e6cb033e 100644
@@ -405,6 +405,9 @@ time with the option "l1tf=". The valid arguments for this option are:
 
   off		Disables hypervisor mitigations and doesn't emit any
 		warnings.
+		It also drops the swap size and available RAM limit restrictions
+                on both hypervisor and bare metal.
+
   ============  =============================================================
 
 The default is 'flush'. For details about L1D flushing see :ref:`l1d_flush`.
@@ -576,7 +579,8 @@ Default mitigations
   The kernel default mitigations for vulnerable processors are:
 
   - PTE inversion to protect against malicious user space. This is done
-    unconditionally and cannot be controlled.
+    unconditionally and cannot be controlled. The swap storage is limited
+    to ~16TB.
 
   - L1D conditional flushing on VMENTER when EPT is enabled for
     a guest.
arch/x86/kernel/cpu/bugs.c +2 -1
index a68b32cb845a..58689ac64440 100644
@@ -1002,7 +1002,8 @@ static void __init l1tf_select_mitigation(void)
 #endif
 
 	half_pa = (u64)l1tf_pfn_limit() << PAGE_SHIFT;
-	if (e820__mapped_any(half_pa, ULLONG_MAX - half_pa, E820_TYPE_RAM)) {
+	if (l1tf_mitigation != L1TF_MITIGATION_OFF &&
+			e820__mapped_any(half_pa, ULLONG_MAX - half_pa, E820_TYPE_RAM)) {
 		pr_warn("System has more than MAX_PA/2 memory. L1TF mitigation not effective.\n");
 		pr_info("You may make it effective by booting the kernel with mem=%llu parameter.\n",
 				half_pa);
arch/x86/mm/init.c +1 -1
index ef99f3892e1f..427a955a2cf2 100644
@@ -931,7 +931,7 @@ unsigned long max_swapfile_size(void)
 
 	pages = generic_max_swapfile_size();
 
-	if (boot_cpu_has_bug(X86_BUG_L1TF)) {
+	if (boot_cpu_has_bug(X86_BUG_L1TF) && l1tf_mitigation != L1TF_MITIGATION_OFF) {
 		/* Limit the swap file size to MAX_PA/2 for L1TF workaround */
 		unsigned long long l1tf_limit = l1tf_pfn_limit();
 		/*
#10 lore raw

Re: [tip:x86/pti] x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off

Quoted 29 lines · tip-bot for Michal Hocko
Commit-ID:  f4abaa98c4575cc06ea5e1a593e3bc2c8de8ef48
Gitweb:     https://git.kernel.org/tip/f4abaa98c4575cc06ea5e1a593e3bc2c8de8ef48
Author:     Michal Hocko <[email protected]>
AuthorDate: Tue, 13 Nov 2018 19:49:10 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Mon, 10 Dec 2018 22:07:02 +0100

x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off

[ tglx: Folded the documentation delta change ]

Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -2095,6 +2095,9 @@
 			off
 				Disables hypervisor mitigations and doesn't
 				emit any warnings.
+				It also drops the swap size and available
+				RAM limit restriction on both hypervisor and
+				bare metal.
 
 
 			Default is 'flush'.
Documentation/admin-guide/l1tf.rst +0 -0
index b85dd80510b0..2e65e6cb033e 100644

Documentation/admin-guide/l1tf.rst time with the option "l1tf=". The valid arguments for this option are: · line 410

Quoted 6 lines
Documentation/admin-guide/l1tf.rst +3 -0
@@ -405,6 +405,9 @@ time with the option "l1tf=". The valid arguments for this option are:
 
   off		Disables hypervisor mitigations and doesn't emit any
 		warnings.
+		It also drops the swap size and available RAM limit restrictions
+                on both hypervisor and bare metal.
+

Note tha there's also some whitespace damage here: all other similar lines in this RST file start with two tabs, this one starts with 8 spaces.

Thanks,

Ingo

#11 lore raw

Re: [tip:x86/pti] x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off

Quoted 9 lines · Ingo Molnar

Documentation/admin-guide/l1tf.rst time with the option "l1tf=". The valid arguments for this option are: · line 410

Quoted 5 lines

off Disables hypervisor mitigations and doesn't emit any

Documentation/admin-guide/l1tf.rst +3 -0
 		warnings.
+		It also drops the swap size and available RAM limit restrictions
+                on both hypervisor and bare metal.
+

Note tha there's also some whitespace damage here: all other similar lines in this RST file start with two tabs, this one starts with 8 spaces.

Fixed...

#12 lore raw

Re: [tip:x86/pti] x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off

Quoted 11 lines · Thomas Gleixner
Quoted 9 lines · Ingo Molnar

Documentation/admin-guide/l1tf.rst time with the option "l1tf=". The valid arguments for this option are: · line 410

Quoted 5 lines

off Disables hypervisor mitigations and doesn't emit any

Documentation/admin-guide/l1tf.rst +3 -0
 		warnings.
+		It also drops the swap size and available RAM limit restrictions
+                on both hypervisor and bare metal.
+

Note tha there's also some whitespace damage here: all other similar lines in this RST file start with two tabs, this one starts with 8 spaces.

Quoted 1 line

Fixed...

Thanks Thomas! I haven't noticed a different whitespaces and relied on whatever vim decided to do.

Signature · 2 lines
Michal Hocko
SUSE Labs
#13 lore raw

[tip:x86/pti] x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off

In reply to Michal Hocko
x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off
Commit-ID:  d7409e79dbec2d2834fb6ccca53664197ab65505
Gitweb:     https://git.kernel.org/tip/d7409e79dbec2d2834fb6ccca53664197ab65505
Author:     Michal Hocko <[email protected]>
AuthorDate: Tue, 13 Nov 2018 19:49:10 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 11 Dec 2018 11:13:32 +0100

x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off

Swap storage is restricted to max_swapfile_size (~16TB on x86_64) whenever the system is deemed affected by L1TF vulnerability. Even though the limit is quite high for most deployments it seems to be too restrictive for deployments which are willing to live with the mitigation disabled.

We have a customer to deploy 8x 6,4TB PCIe/NVMe SSD swap devices which is clearly out of the limit.

Drop the swap restriction when l1tf=off is specified. It also doesn't make much sense to warn about too much memory for the l1tf mitigation when it is forcefully disabled by the administrator.

[ tglx: Folded the documentation delta change ]

Fixes 377eeaa8e11f ("x86/speculation/l1tf: Limit swap file size to MAX_PA/2")
Cc Linus Torvalds <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Borislav Petkov <[email protected]>
---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 Documentation/admin-guide/l1tf.rst              | 6 +++++-
 arch/x86/kernel/cpu/bugs.c                      | 3 ++-
 arch/x86/mm/init.c                              | 2 +-
 4 files changed, 11 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
index 05a252e5178d..835e422572eb 100644
@@ -2095,6 +2095,9 @@
 			off
 				Disables hypervisor mitigations and doesn't
 				emit any warnings.
+				It also drops the swap size and available
+				RAM limit restriction on both hypervisor and
+				bare metal.
 
 			Default is 'flush'.
 
Documentation/admin-guide/l1tf.rst +5 -1
index b85dd80510b0..2e65e6cb033e 100644
@@ -405,6 +405,9 @@ time with the option "l1tf=". The valid arguments for this option are:
 
   off		Disables hypervisor mitigations and doesn't emit any
 		warnings.
+		It also drops the swap size and available RAM limit restrictions
+                on both hypervisor and bare metal.
+
   ============  =============================================================
 
 The default is 'flush'. For details about L1D flushing see :ref:`l1d_flush`.
@@ -576,7 +579,8 @@ Default mitigations
   The kernel default mitigations for vulnerable processors are:
 
   - PTE inversion to protect against malicious user space. This is done
-    unconditionally and cannot be controlled.
+    unconditionally and cannot be controlled. The swap storage is limited
+    to ~16TB.
 
   - L1D conditional flushing on VMENTER when EPT is enabled for
     a guest.
arch/x86/kernel/cpu/bugs.c +2 -1
index a68b32cb845a..58689ac64440 100644
@@ -1002,7 +1002,8 @@ static void __init l1tf_select_mitigation(void)
 #endif
 
 	half_pa = (u64)l1tf_pfn_limit() << PAGE_SHIFT;
-	if (e820__mapped_any(half_pa, ULLONG_MAX - half_pa, E820_TYPE_RAM)) {
+	if (l1tf_mitigation != L1TF_MITIGATION_OFF &&
+			e820__mapped_any(half_pa, ULLONG_MAX - half_pa, E820_TYPE_RAM)) {
 		pr_warn("System has more than MAX_PA/2 memory. L1TF mitigation not effective.\n");
 		pr_info("You may make it effective by booting the kernel with mem=%llu parameter.\n",
 				half_pa);
arch/x86/mm/init.c +1 -1
index ef99f3892e1f..427a955a2cf2 100644
@@ -931,7 +931,7 @@ unsigned long max_swapfile_size(void)
 
 	pages = generic_max_swapfile_size();
 
-	if (boot_cpu_has_bug(X86_BUG_L1TF)) {
+	if (boot_cpu_has_bug(X86_BUG_L1TF) && l1tf_mitigation != L1TF_MITIGATION_OFF) {
 		/* Limit the swap file size to MAX_PA/2 for L1TF workaround */
 		unsigned long long l1tf_limit = l1tf_pfn_limit();
 		/*
#14 lore raw

[tip:x86/pti] x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off

In reply to Michal Hocko
x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off
Commit-ID:  5b5e4d623ec8a34689df98e42d038a3b594d2ff9
Gitweb:     https://git.kernel.org/tip/5b5e4d623ec8a34689df98e42d038a3b594d2ff9
Author:     Michal Hocko <[email protected]>
AuthorDate: Tue, 13 Nov 2018 19:49:10 +0100
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Tue, 11 Dec 2018 11:46:13 +0100

x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off

Swap storage is restricted to max_swapfile_size (~16TB on x86_64) whenever the system is deemed affected by L1TF vulnerability. Even though the limit is quite high for most deployments it seems to be too restrictive for deployments which are willing to live with the mitigation disabled.

We have a customer to deploy 8x 6,4TB PCIe/NVMe SSD swap devices which is clearly out of the limit.

Drop the swap restriction when l1tf=off is specified. It also doesn't make much sense to warn about too much memory for the l1tf mitigation when it is forcefully disabled by the administrator.

[ tglx: Folded the documentation delta change ]

Fixes 377eeaa8e11f ("x86/speculation/l1tf: Limit swap file size to MAX_PA/2")
Cc Linus Torvalds <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Borislav Petkov <[email protected]>
---
 Documentation/admin-guide/kernel-parameters.txt | 3 +++
 Documentation/admin-guide/l1tf.rst              | 6 +++++-
 arch/x86/kernel/cpu/bugs.c                      | 3 ++-
 arch/x86/mm/init.c                              | 2 +-
 4 files changed, 11 insertions(+), 3 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +3 -0
index 05a252e5178d..835e422572eb 100644
@@ -2095,6 +2095,9 @@
 			off
 				Disables hypervisor mitigations and doesn't
 				emit any warnings.
+				It also drops the swap size and available
+				RAM limit restriction on both hypervisor and
+				bare metal.
 
 			Default is 'flush'.
 
Documentation/admin-guide/l1tf.rst +5 -1
index b85dd80510b0..9af977384168 100644
@@ -405,6 +405,9 @@ time with the option "l1tf=". The valid arguments for this option are:
 
   off		Disables hypervisor mitigations and doesn't emit any
 		warnings.
+		It also drops the swap size and available RAM limit restrictions
+		on both hypervisor and bare metal.
+
   ============  =============================================================
 
 The default is 'flush'. For details about L1D flushing see :ref:`l1d_flush`.
@@ -576,7 +579,8 @@ Default mitigations
   The kernel default mitigations for vulnerable processors are:
 
   - PTE inversion to protect against malicious user space. This is done
-    unconditionally and cannot be controlled.
+    unconditionally and cannot be controlled. The swap storage is limited
+    to ~16TB.
 
   - L1D conditional flushing on VMENTER when EPT is enabled for
     a guest.
arch/x86/kernel/cpu/bugs.c +2 -1
index a68b32cb845a..58689ac64440 100644
@@ -1002,7 +1002,8 @@ static void __init l1tf_select_mitigation(void)
 #endif
 
 	half_pa = (u64)l1tf_pfn_limit() << PAGE_SHIFT;
-	if (e820__mapped_any(half_pa, ULLONG_MAX - half_pa, E820_TYPE_RAM)) {
+	if (l1tf_mitigation != L1TF_MITIGATION_OFF &&
+			e820__mapped_any(half_pa, ULLONG_MAX - half_pa, E820_TYPE_RAM)) {
 		pr_warn("System has more than MAX_PA/2 memory. L1TF mitigation not effective.\n");
 		pr_info("You may make it effective by booting the kernel with mem=%llu parameter.\n",
 				half_pa);
arch/x86/mm/init.c +1 -1
index ef99f3892e1f..427a955a2cf2 100644
@@ -931,7 +931,7 @@ unsigned long max_swapfile_size(void)
 
 	pages = generic_max_swapfile_size();
 
-	if (boot_cpu_has_bug(X86_BUG_L1TF)) {
+	if (boot_cpu_has_bug(X86_BUG_L1TF) && l1tf_mitigation != L1TF_MITIGATION_OFF) {
 		/* Limit the swap file size to MAX_PA/2 for L1TF workaround */
 		unsigned long long l1tf_limit = l1tf_pfn_limit();
 		/*