]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.6-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 8 Sep 2024 11:26:55 +0000 (13:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 8 Sep 2024 11:26:55 +0000 (13:26 +0200)
added patches:
nvme-pci-add-sleep-quirk-for-samsung-990-evo.patch
rust-macros-provide-correct-provenance-when-constructing-this_module.patch
rust-types-make-opaque-get-const.patch

queue-6.6/nvme-pci-add-sleep-quirk-for-samsung-990-evo.patch [new file with mode: 0644]
queue-6.6/rust-macros-provide-correct-provenance-when-constructing-this_module.patch [new file with mode: 0644]
queue-6.6/rust-types-make-opaque-get-const.patch [new file with mode: 0644]
queue-6.6/series

diff --git a/queue-6.6/nvme-pci-add-sleep-quirk-for-samsung-990-evo.patch b/queue-6.6/nvme-pci-add-sleep-quirk-for-samsung-990-evo.patch
new file mode 100644 (file)
index 0000000..e226f2e
--- /dev/null
@@ -0,0 +1,44 @@
+From 61aa894e7a2fda4ee026523b01d07e83ce2abb72 Mon Sep 17 00:00:00 2001
+From: Georg Gottleuber <ggo@tuxedocomputers.com>
+Date: Tue, 27 Aug 2024 12:41:33 +0200
+Subject: nvme-pci: Add sleep quirk for Samsung 990 Evo
+
+From: Georg Gottleuber <ggo@tuxedocomputers.com>
+
+commit 61aa894e7a2fda4ee026523b01d07e83ce2abb72 upstream.
+
+On some TUXEDO platforms, a Samsung 990 Evo NVMe leads to a high
+power consumption in s2idle sleep (2-3 watts).
+
+This patch applies 'Force No Simple Suspend' quirk to achieve a
+sleep with a lower power consumption, typically around 0.5 watts.
+
+Signed-off-by: Georg Gottleuber <ggo@tuxedocomputers.com>
+Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Keith Busch <kbusch@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/nvme/host/pci.c |   11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+--- a/drivers/nvme/host/pci.c
++++ b/drivers/nvme/host/pci.c
+@@ -2929,6 +2929,17 @@ static unsigned long check_vendor_combin
+                   dmi_match(DMI_BOARD_NAME, "NS5x_7xPU") ||
+                   dmi_match(DMI_BOARD_NAME, "PH4PRX1_PH6PRX1"))
+                       return NVME_QUIRK_FORCE_NO_SIMPLE_SUSPEND;
++      } else if (pdev->vendor == 0x144d && pdev->device == 0xa80d) {
++              /*
++               * Exclude Samsung 990 Evo from NVME_QUIRK_SIMPLE_SUSPEND
++               * because of high power consumption (> 2 Watt) in s2idle
++               * sleep. Only some boards with Intel CPU are affected.
++               */
++              if (dmi_match(DMI_BOARD_NAME, "GMxPXxx") ||
++                  dmi_match(DMI_BOARD_NAME, "PH4PG31") ||
++                  dmi_match(DMI_BOARD_NAME, "PH4PRX1_PH6PRX1") ||
++                  dmi_match(DMI_BOARD_NAME, "PH6PG01_PH6PG71"))
++                      return NVME_QUIRK_FORCE_NO_SIMPLE_SUSPEND;
+       }
+       /*
diff --git a/queue-6.6/rust-macros-provide-correct-provenance-when-constructing-this_module.patch b/queue-6.6/rust-macros-provide-correct-provenance-when-constructing-this_module.patch
new file mode 100644 (file)
index 0000000..bbac850
--- /dev/null
@@ -0,0 +1,57 @@
+From a5a3c952e82c1ada12bf8c55b73af26f1a454bd2 Mon Sep 17 00:00:00 2001
+From: Boqun Feng <boqun.feng@gmail.com>
+Date: Wed, 28 Aug 2024 11:01:29 -0700
+Subject: rust: macros: provide correct provenance when constructing THIS_MODULE
+
+From: Boqun Feng <boqun.feng@gmail.com>
+
+commit a5a3c952e82c1ada12bf8c55b73af26f1a454bd2 upstream.
+
+Currently while defining `THIS_MODULE` symbol in `module!()`, the
+pointer used to construct `ThisModule` is derived from an immutable
+reference of `__this_module`, which means the pointer doesn't have
+the provenance for writing, and that means any write to that pointer
+is UB regardless of data races or not. However, the usage of
+`THIS_MODULE` includes passing this pointer to functions that may write
+to it (probably in unsafe code), and this will create soundness issues.
+
+One way to fix this is using `addr_of_mut!()` but that requires the
+unstable feature "const_mut_refs". So instead of `addr_of_mut()!`,
+an extern static `Opaque` is used here: since `Opaque<T>` is transparent
+to `T`, an extern static `Opaque` will just wrap the C symbol (defined
+in a C compile unit) in an `Opaque`, which provides a pointer with
+writable provenance via `Opaque::get()`. This fix the potential UBs
+because of pointer provenance unmatched.
+
+Reported-by: Alice Ryhl <aliceryhl@google.com>
+Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
+Reviewed-by: Alice Ryhl <aliceryhl@google.com>
+Reviewed-by: Trevor Gross <tmgross@umich.edu>
+Reviewed-by: Benno Lossin <benno.lossin@proton.me>
+Reviewed-by: Gary Guo <gary@garyguo.net>
+Closes: https://rust-for-linux.zulipchat.com/#narrow/stream/x/topic/x/near/465412664
+Fixes: 1fbde52bde73 ("rust: add `macros` crate")
+Cc: stable@vger.kernel.org # 6.6.x: be2ca1e03965: ("rust: types: Make Opaque::get const")
+Link: https://lore.kernel.org/r/20240828180129.4046355-1-boqun.feng@gmail.com
+[ Fixed two typos, reworded title. - Miguel ]
+Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ rust/macros/module.rs |    6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+--- a/rust/macros/module.rs
++++ b/rust/macros/module.rs
+@@ -203,7 +203,11 @@ pub(crate) fn module(ts: TokenStream) ->
+             // freed until the module is unloaded.
+             #[cfg(MODULE)]
+             static THIS_MODULE: kernel::ThisModule = unsafe {{
+-                kernel::ThisModule::from_ptr(&kernel::bindings::__this_module as *const _ as *mut _)
++                extern \"C\" {{
++                    static __this_module: kernel::types::Opaque<kernel::bindings::module>;
++                }}
++
++                kernel::ThisModule::from_ptr(__this_module.get())
+             }};
+             #[cfg(not(MODULE))]
+             static THIS_MODULE: kernel::ThisModule = unsafe {{
diff --git a/queue-6.6/rust-types-make-opaque-get-const.patch b/queue-6.6/rust-types-make-opaque-get-const.patch
new file mode 100644 (file)
index 0000000..9254b9a
--- /dev/null
@@ -0,0 +1,47 @@
+From be2ca1e03965ffb214b6cbda0ffd84daeeb5f214 Mon Sep 17 00:00:00 2001
+From: Boqun Feng <boqun.feng@gmail.com>
+Date: Mon, 1 Apr 2024 14:45:36 -0700
+Subject: rust: types: Make Opaque::get const
+
+From: Boqun Feng <boqun.feng@gmail.com>
+
+commit be2ca1e03965ffb214b6cbda0ffd84daeeb5f214 upstream.
+
+To support a potential usage:
+
+    static foo: Opaque<Foo> = ..; // Or defined in an extern block.
+
+    ...
+
+    fn bar() {
+        let ptr = foo.get();
+    }
+
+`Opaque::get` need to be `const`, otherwise compiler will complain
+because calls on statics are limited to const functions.
+
+Also `Opaque::get` should be naturally `const` since it's a composition
+of two `const` functions: `UnsafeCell::get` and `ptr::cast`.
+
+Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
+Reviewed-by: Alice Ryhl <aliceryhl@google.com>
+Reviewed-by: Wedson Almeida Filho <walmeida@microsoft.com>
+Reviewed-by: Benno Lossin <benno.lossin@proton.me>
+Link: https://lore.kernel.org/r/20240401214543.1242286-1-boqun.feng@gmail.com
+Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ rust/kernel/types.rs |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/rust/kernel/types.rs
++++ b/rust/kernel/types.rs
+@@ -248,7 +248,7 @@ impl<T> Opaque<T> {
+     }
+     /// Returns a raw pointer to the opaque data.
+-    pub fn get(&self) -> *mut T {
++    pub const fn get(&self) -> *mut T {
+         UnsafeCell::get(&self.value).cast::<T>()
+     }
index f132b26d00cbd19085a9fa7e0ae50340a364e32c..1d55df055dbe4b4a7b898432de263a9667e46cd1 100644 (file)
@@ -17,3 +17,6 @@ perf-x86-intel-limit-the-period-on-haswell.patch
 irqchip-gic-v2m-fix-refcount-leak-in-gicv2m_of_init.patch
 x86-kaslr-expose-and-use-the-end-of-the-physical-memory-address-space.patch
 rtmutex-drop-rt_mutex-wait_lock-before-scheduling.patch
+nvme-pci-add-sleep-quirk-for-samsung-990-evo.patch
+rust-types-make-opaque-get-const.patch
+rust-macros-provide-correct-provenance-when-constructing-this_module.patch