]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 6.8
authorSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 18:35:38 +0000 (14:35 -0400)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 18:35:38 +0000 (14:35 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-6.8/printk-adjust-mapping-for-32bit-seq-macros.patch [new file with mode: 0644]
queue-6.8/printk-use-prb_first_seq-as-base-for-32bit-seq-macro.patch [new file with mode: 0644]
queue-6.8/series

diff --git a/queue-6.8/printk-adjust-mapping-for-32bit-seq-macros.patch b/queue-6.8/printk-adjust-mapping-for-32bit-seq-macros.patch
new file mode 100644 (file)
index 0000000..e576da9
--- /dev/null
@@ -0,0 +1,84 @@
+From 0b837f3e9fa1631271232a9ce147c8b3b8de9756 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 7 Feb 2024 14:46:51 +0106
+Subject: printk: Adjust mapping for 32bit seq macros
+
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+
+[ Upstream commit 418ec1961c07d84293cc3cd54d67b90bbeba7feb ]
+
+Note: This change only applies to 32bit architectures. On 64bit
+      architectures the macros are NOPs.
+
+__ulseq_to_u64seq() computes the upper 32 bits of the passed
+argument value (@ulseq). The upper bits are derived from a base
+value (@rb_next_seq) in a way that assumes @ulseq represents a
+64bit number that is less than or equal to @rb_next_seq.
+
+Until now this mapping has been correct for all call sites. However,
+in a follow-up commit, values of @ulseq will be passed in that are
+higher than the base value. This requires a change to how the 32bit
+value is mapped to a 64bit sequence number.
+
+Rather than mapping @ulseq such that the base value is the end of a
+32bit block, map @ulseq such that the base value is in the middle of
+a 32bit block. This allows supporting 31 bits before and after the
+base value, which is deemed acceptable for the console sequence
+number during runtime.
+
+Here is an example to illustrate the previous and new mappings.
+
+For a base value (@rb_next_seq) of 2 2000 0000...
+
+Before this change the range of possible return values was:
+
+1 2000 0001 to 2 2000 0000
+
+__ulseq_to_u64seq(1fff ffff) => 2 1fff ffff
+__ulseq_to_u64seq(2000 0000) => 2 2000 0000
+__ulseq_to_u64seq(2000 0001) => 1 2000 0001
+__ulseq_to_u64seq(9fff ffff) => 1 9fff ffff
+__ulseq_to_u64seq(a000 0000) => 1 a000 0000
+__ulseq_to_u64seq(a000 0001) => 1 a000 0001
+
+After this change the range of possible return values are:
+
+1 a000 0001 to 2 a000 0000
+
+__ulseq_to_u64seq(1fff ffff) => 2 1fff ffff
+__ulseq_to_u64seq(2000 0000) => 2 2000 0000
+__ulseq_to_u64seq(2000 0001) => 2 2000 0001
+__ulseq_to_u64seq(9fff ffff) => 2 9fff ffff
+__ulseq_to_u64seq(a000 0000) => 2 a000 0000
+__ulseq_to_u64seq(a000 0001) => 1 a000 0001
+
+[ john.ogness: Rewrite commit message. ]
+
+Reported-by: Francesco Dolcini <francesco@dolcini.it>
+Reported-by: kernel test robot <oliver.sang@intel.com>
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Signed-off-by: John Ogness <john.ogness@linutronix.de>
+Reviewed-by: Petr Mladek <pmladek@suse.com>
+Link: https://lore.kernel.org/r/20240207134103.1357162-3-john.ogness@linutronix.de
+Signed-off-by: Petr Mladek <pmladek@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/printk/printk_ringbuffer.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kernel/printk/printk_ringbuffer.h b/kernel/printk/printk_ringbuffer.h
+index 5aebe97bd4afc..d729387726900 100644
+--- a/kernel/printk/printk_ringbuffer.h
++++ b/kernel/printk/printk_ringbuffer.h
+@@ -408,7 +408,7 @@ static inline u64 __ulseq_to_u64seq(struct printk_ringbuffer *rb, u32 ulseq)
+        * Also the access to the ring buffer is always safe.
+        */
+       rb_next_seq = prb_next_seq(rb);
+-      seq = rb_next_seq - ((u32)rb_next_seq - ulseq);
++      seq = rb_next_seq - (s32)((u32)rb_next_seq - ulseq);
+       return seq;
+ }
+-- 
+2.43.0
+
diff --git a/queue-6.8/printk-use-prb_first_seq-as-base-for-32bit-seq-macro.patch b/queue-6.8/printk-use-prb_first_seq-as-base-for-32bit-seq-macro.patch
new file mode 100644 (file)
index 0000000..202668f
--- /dev/null
@@ -0,0 +1,84 @@
+From ee5d170bb8a0be2ff1776ba8c9d004eb750b9616 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 7 Feb 2024 14:46:52 +0106
+Subject: printk: Use prb_first_seq() as base for 32bit seq macros
+
+From: John Ogness <john.ogness@linutronix.de>
+
+[ Upstream commit 90ad525c2d9a8a6591ab822234a94b82871ef8e0 ]
+
+Note: This change only applies to 32bit architectures. On 64bit
+      architectures the macros are NOPs.
+
+Currently prb_next_seq() is used as the base for the 32bit seq
+macros __u64seq_to_ulseq() and __ulseq_to_u64seq(). However, in
+a follow-up commit, prb_next_seq() will need to make use of the
+32bit seq macros.
+
+Use prb_first_seq() as the base for the 32bit seq macros instead
+because it is guaranteed to return 64bit sequence numbers without
+relying on any 32bit seq macros.
+
+Signed-off-by: John Ogness <john.ogness@linutronix.de>
+Reviewed-by: Petr Mladek <pmladek@suse.com>
+Link: https://lore.kernel.org/r/20240207134103.1357162-4-john.ogness@linutronix.de
+Signed-off-by: Petr Mladek <pmladek@suse.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ kernel/printk/printk_ringbuffer.c | 2 +-
+ kernel/printk/printk_ringbuffer.h | 8 ++++----
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/kernel/printk/printk_ringbuffer.c b/kernel/printk/printk_ringbuffer.c
+index 3d98232902cfd..f5a8bb606fe50 100644
+--- a/kernel/printk/printk_ringbuffer.c
++++ b/kernel/printk/printk_ringbuffer.c
+@@ -1931,7 +1931,7 @@ static int prb_read(struct printk_ringbuffer *rb, u64 seq,
+ }
+ /* Get the sequence number of the tail descriptor. */
+-static u64 prb_first_seq(struct printk_ringbuffer *rb)
++u64 prb_first_seq(struct printk_ringbuffer *rb)
+ {
+       struct prb_desc_ring *desc_ring = &rb->desc_ring;
+       enum desc_state d_state;
+diff --git a/kernel/printk/printk_ringbuffer.h b/kernel/printk/printk_ringbuffer.h
+index d729387726900..cb887489d00f0 100644
+--- a/kernel/printk/printk_ringbuffer.h
++++ b/kernel/printk/printk_ringbuffer.h
+@@ -378,6 +378,7 @@ bool prb_read_valid(struct printk_ringbuffer *rb, u64 seq,
+ bool prb_read_valid_info(struct printk_ringbuffer *rb, u64 seq,
+                        struct printk_info *info, unsigned int *line_count);
++u64 prb_first_seq(struct printk_ringbuffer *rb);
+ u64 prb_first_valid_seq(struct printk_ringbuffer *rb);
+ u64 prb_next_seq(struct printk_ringbuffer *rb);
+ u64 prb_next_reserve_seq(struct printk_ringbuffer *rb);
+@@ -393,12 +394,12 @@ u64 prb_next_reserve_seq(struct printk_ringbuffer *rb);
+ static inline u64 __ulseq_to_u64seq(struct printk_ringbuffer *rb, u32 ulseq)
+ {
++      u64 rb_first_seq = prb_first_seq(rb);
+       u64 seq;
+-      u64 rb_next_seq;
+       /*
+        * The provided sequence is only the lower 32 bits of the ringbuffer
+-       * sequence. It needs to be expanded to 64bit. Get the next sequence
++       * sequence. It needs to be expanded to 64bit. Get the first sequence
+        * number from the ringbuffer and fold it.
+        *
+        * Having a 32bit representation in the console is sufficient.
+@@ -407,8 +408,7 @@ static inline u64 __ulseq_to_u64seq(struct printk_ringbuffer *rb, u32 ulseq)
+        *
+        * Also the access to the ring buffer is always safe.
+        */
+-      rb_next_seq = prb_next_seq(rb);
+-      seq = rb_next_seq - (s32)((u32)rb_next_seq - ulseq);
++      seq = rb_first_seq - (s32)((u32)rb_first_seq - ulseq);
+       return seq;
+ }
+-- 
+2.43.0
+
index 71cf8611506302c34230ab008591b84bccff7576..870d938137fe26efa0458f1e5a73504bba5fe50d 100644 (file)
@@ -703,3 +703,5 @@ dm-io-support-io-priority.patch
 dm-integrity-align-the-outgoing-bio-in-integrity_rec.patch
 x86-efistub-clear-decompressor-bss-in-native-efi-ent.patch
 x86-efistub-don-t-clear-bss-twice-in-mixed-mode.patch
+printk-adjust-mapping-for-32bit-seq-macros.patch
+printk-use-prb_first_seq-as-base-for-32bit-seq-macro.patch