From 7b5f64dc3b50b308ea83a73b440eb83ccdd621c5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 8 Sep 2024 13:26:55 +0200 Subject: [PATCH] 6.6-stable patches 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 --- ...-add-sleep-quirk-for-samsung-990-evo.patch | 44 ++++++++++++++ ...enance-when-constructing-this_module.patch | 57 +++++++++++++++++++ .../rust-types-make-opaque-get-const.patch | 47 +++++++++++++++ queue-6.6/series | 3 + 4 files changed, 151 insertions(+) create mode 100644 queue-6.6/nvme-pci-add-sleep-quirk-for-samsung-990-evo.patch create mode 100644 queue-6.6/rust-macros-provide-correct-provenance-when-constructing-this_module.patch create mode 100644 queue-6.6/rust-types-make-opaque-get-const.patch 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 index 00000000000..e226f2e8f5c --- /dev/null +++ b/queue-6.6/nvme-pci-add-sleep-quirk-for-samsung-990-evo.patch @@ -0,0 +1,44 @@ +From 61aa894e7a2fda4ee026523b01d07e83ce2abb72 Mon Sep 17 00:00:00 2001 +From: Georg Gottleuber +Date: Tue, 27 Aug 2024 12:41:33 +0200 +Subject: nvme-pci: Add sleep quirk for Samsung 990 Evo + +From: Georg Gottleuber + +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 +Signed-off-by: Werner Sembach +Cc: +Signed-off-by: Keith Busch +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 00000000000..bbac8507e20 --- /dev/null +++ b/queue-6.6/rust-macros-provide-correct-provenance-when-constructing-this_module.patch @@ -0,0 +1,57 @@ +From a5a3c952e82c1ada12bf8c55b73af26f1a454bd2 Mon Sep 17 00:00:00 2001 +From: Boqun Feng +Date: Wed, 28 Aug 2024 11:01:29 -0700 +Subject: rust: macros: provide correct provenance when constructing THIS_MODULE + +From: Boqun Feng + +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` 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 +Signed-off-by: Boqun Feng +Reviewed-by: Alice Ryhl +Reviewed-by: Trevor Gross +Reviewed-by: Benno Lossin +Reviewed-by: Gary Guo +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 +Signed-off-by: Greg Kroah-Hartman +--- + 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::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 index 00000000000..9254b9a4604 --- /dev/null +++ b/queue-6.6/rust-types-make-opaque-get-const.patch @@ -0,0 +1,47 @@ +From be2ca1e03965ffb214b6cbda0ffd84daeeb5f214 Mon Sep 17 00:00:00 2001 +From: Boqun Feng +Date: Mon, 1 Apr 2024 14:45:36 -0700 +Subject: rust: types: Make Opaque::get const + +From: Boqun Feng + +commit be2ca1e03965ffb214b6cbda0ffd84daeeb5f214 upstream. + +To support a potential usage: + + static foo: Opaque = ..; // 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 +Reviewed-by: Alice Ryhl +Reviewed-by: Wedson Almeida Filho +Reviewed-by: Benno Lossin +Link: https://lore.kernel.org/r/20240401214543.1242286-1-boqun.feng@gmail.com +Signed-off-by: Miguel Ojeda +Signed-off-by: Greg Kroah-Hartman +--- + 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 Opaque { + } + + /// 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::() + } + diff --git a/queue-6.6/series b/queue-6.6/series index f132b26d00c..1d55df055db 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -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 -- 2.47.3