]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.18-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Jun 2022 07:18:31 +0000 (09:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Jun 2022 07:18:31 +0000 (09:18 +0200)
added patches:
binfmt_flat-do-not-stop-relocating-got-entries-prematurely-on-riscv.patch
parisc-fix-a-crash-with-multicore-scheduler.patch
parisc-stifb-implement-fb_is_primary_device.patch
parisc-stifb-keep-track-of-hardware-path-of-graphics-card.patch

queue-5.18/binfmt_flat-do-not-stop-relocating-got-entries-prematurely-on-riscv.patch [new file with mode: 0644]
queue-5.18/parisc-fix-a-crash-with-multicore-scheduler.patch [new file with mode: 0644]
queue-5.18/parisc-stifb-implement-fb_is_primary_device.patch [new file with mode: 0644]
queue-5.18/parisc-stifb-keep-track-of-hardware-path-of-graphics-card.patch [new file with mode: 0644]
queue-5.18/series

diff --git a/queue-5.18/binfmt_flat-do-not-stop-relocating-got-entries-prematurely-on-riscv.patch b/queue-5.18/binfmt_flat-do-not-stop-relocating-got-entries-prematurely-on-riscv.patch
new file mode 100644 (file)
index 0000000..6ef6a7b
--- /dev/null
@@ -0,0 +1,108 @@
+From 6045ab5fea4c849153ebeb0acb532da5f29d69c4 Mon Sep 17 00:00:00 2001
+From: Niklas Cassel <niklas.cassel@wdc.com>
+Date: Thu, 14 Apr 2022 11:10:18 +0200
+Subject: binfmt_flat: do not stop relocating GOT entries prematurely on riscv
+
+From: Niklas Cassel <niklas.cassel@wdc.com>
+
+commit 6045ab5fea4c849153ebeb0acb532da5f29d69c4 upstream.
+
+bFLT binaries are usually created using elf2flt.
+
+The linker script used by elf2flt has defined the .data section like the
+following for the last 19 years:
+
+.data : {
+       _sdata = . ;
+       __data_start = . ;
+       data_start = . ;
+       *(.got.plt)
+       *(.got)
+       FILL(0) ;
+       . = ALIGN(0x20) ;
+       LONG(-1)
+       . = ALIGN(0x20) ;
+       ...
+}
+
+It places the .got.plt input section before the .got input section.
+The same is true for the default linker script (ld --verbose) on most
+architectures except x86/x86-64.
+
+The binfmt_flat loader should relocate all GOT entries until it encounters
+a -1 (the LONG(-1) in the linker script).
+
+The problem is that the .got.plt input section starts with a GOTPLT header
+(which has size 16 bytes on elf64-riscv and 8 bytes on elf32-riscv), where
+the first word is set to -1. See the binutils implementation for riscv [1].
+
+This causes the binfmt_flat loader to stop relocating GOT entries
+prematurely and thus causes the application to crash when running.
+
+Fix this by skipping the whole GOTPLT header, since the whole GOTPLT header
+is reserved for the dynamic linker.
+
+The GOTPLT header will only be skipped for bFLT binaries with flag
+FLAT_FLAG_GOTPIC set. This flag is unconditionally set by elf2flt if the
+supplied ELF binary has the symbol _GLOBAL_OFFSET_TABLE_ defined.
+ELF binaries without a .got input section should thus remain unaffected.
+
+Tested on RISC-V Canaan Kendryte K210 and RISC-V QEMU nommu_virt_defconfig.
+
+[1] https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/elfnn-riscv.c;hb=binutils-2_38#l3275
+
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
+Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
+Link: https://lore.kernel.org/r/20220414091018.896737-1-niklas.cassel@wdc.com
+Fixed-by: kernel test robot <lkp@intel.com>
+Link: https://lore.kernel.org/lkml/202204182333.OIUOotK8-lkp@intel.com
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/binfmt_flat.c |   27 ++++++++++++++++++++++++++-
+ 1 file changed, 26 insertions(+), 1 deletion(-)
+
+--- a/fs/binfmt_flat.c
++++ b/fs/binfmt_flat.c
+@@ -440,6 +440,30 @@ static void old_reloc(unsigned long rl)
+ /****************************************************************************/
++static inline u32 __user *skip_got_header(u32 __user *rp)
++{
++      if (IS_ENABLED(CONFIG_RISCV)) {
++              /*
++               * RISC-V has a 16 byte GOT PLT header for elf64-riscv
++               * and 8 byte GOT PLT header for elf32-riscv.
++               * Skip the whole GOT PLT header, since it is reserved
++               * for the dynamic linker (ld.so).
++               */
++              u32 rp_val0, rp_val1;
++
++              if (get_user(rp_val0, rp))
++                      return rp;
++              if (get_user(rp_val1, rp + 1))
++                      return rp;
++
++              if (rp_val0 == 0xffffffff && rp_val1 == 0xffffffff)
++                      rp += 4;
++              else if (rp_val0 == 0xffffffff)
++                      rp += 2;
++      }
++      return rp;
++}
++
+ static int load_flat_file(struct linux_binprm *bprm,
+               struct lib_info *libinfo, int id, unsigned long *extra_stack)
+ {
+@@ -789,7 +813,8 @@ static int load_flat_file(struct linux_b
+        * image.
+        */
+       if (flags & FLAT_FLAG_GOTPIC) {
+-              for (rp = (u32 __user *)datapos; ; rp++) {
++              rp = skip_got_header((u32 __user *) datapos);
++              for (; ; rp++) {
+                       u32 addr, rp_val;
+                       if (get_user(rp_val, rp))
+                               return -EFAULT;
diff --git a/queue-5.18/parisc-fix-a-crash-with-multicore-scheduler.patch b/queue-5.18/parisc-fix-a-crash-with-multicore-scheduler.patch
new file mode 100644 (file)
index 0000000..89b4070
--- /dev/null
@@ -0,0 +1,107 @@
+From 6ba688364856ad083be537f08e86ba97f433d405 Mon Sep 17 00:00:00 2001
+From: Mikulas Patocka <mpatocka@redhat.com>
+Date: Wed, 1 Jun 2022 13:18:22 -0400
+Subject: parisc: fix a crash with multicore scheduler
+
+From: Mikulas Patocka <mpatocka@redhat.com>
+
+commit 6ba688364856ad083be537f08e86ba97f433d405 upstream.
+
+With the kernel 5.18, the system will hang on boot if it is compiled with
+CONFIG_SCHED_MC. The last printed message is "Brought up 1 node, 1 CPU".
+
+The crash happens in sd_init
+tl->mask (which is cpu_coregroup_mask) returns an empty mask. This happens
+       because cpu_topology[0].core_sibling is empty.
+Consequently, sd_span is set to an empty mask
+sd_id = cpumask_first(sd_span) sets sd_id == NR_CPUS (because the mask is
+       empty)
+sd->shared = *per_cpu_ptr(sdd->sds, sd_id); sets sd->shared to NULL
+       because sd_id is out of range
+atomic_inc(&sd->shared->ref); crashes without printing anything
+
+We can fix it by calling reset_cpu_topology() from init_cpu_topology() -
+this will initialize the sibling masks on CPUs, so that they're not empty.
+
+This patch also removes the variable "dualcores_found", it is useless,
+because during boot, init_cpu_topology is called before
+store_cpu_topology. Thus, set_sched_topology(parisc_mc_topology) is never
+called. We don't need to call it at all because default_topology in
+kernel/sched/topology.c contains the same items as parisc_mc_topology.
+
+Note that we should not call store_cpu_topology() from init_per_cpu()
+because it is called too early in the kernel initialization process and it
+results in the message "Failure to register CPU0 device". Before this
+patch, store_cpu_topology() would exit immediatelly because
+cpuid_topo->core id was uninitialized and it was 0.
+
+Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
+Cc: stable@vger.kernel.org     # v5.18
+Signed-off-by: Helge Deller <deller@gmx.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/parisc/kernel/processor.c |  2 --
+ arch/parisc/kernel/topology.c  | 16 +---------------
+ 2 files changed, 1 insertion(+), 17 deletions(-)
+
+diff --git a/arch/parisc/kernel/processor.c b/arch/parisc/kernel/processor.c
+index 26eb568f8b96..dddaaa6e7a82 100644
+--- a/arch/parisc/kernel/processor.c
++++ b/arch/parisc/kernel/processor.c
+@@ -327,8 +327,6 @@ int init_per_cpu(int cpunum)
+       set_firmware_width();
+       ret = pdc_coproc_cfg(&coproc_cfg);
+-      store_cpu_topology(cpunum);
+-
+       if(ret >= 0 && coproc_cfg.ccr_functional) {
+               mtctl(coproc_cfg.ccr_functional, 10);  /* 10 == Coprocessor Control Reg */
+diff --git a/arch/parisc/kernel/topology.c b/arch/parisc/kernel/topology.c
+index 9696e3cb6a2a..b9d845e314f8 100644
+--- a/arch/parisc/kernel/topology.c
++++ b/arch/parisc/kernel/topology.c
+@@ -20,8 +20,6 @@
+ static DEFINE_PER_CPU(struct cpu, cpu_devices);
+-static int dualcores_found;
+-
+ /*
+  * store_cpu_topology is called at boot when only one cpu is running
+  * and with the mutex cpu_hotplug.lock locked, when several cpus have booted,
+@@ -60,7 +58,6 @@ void store_cpu_topology(unsigned int cpuid)
+                       if (p->cpu_loc) {
+                               cpuid_topo->core_id++;
+                               cpuid_topo->package_id = cpu_topology[cpu].package_id;
+-                              dualcores_found = 1;
+                               continue;
+                       }
+               }
+@@ -80,22 +77,11 @@ void store_cpu_topology(unsigned int cpuid)
+               cpu_topology[cpuid].package_id);
+ }
+-static struct sched_domain_topology_level parisc_mc_topology[] = {
+-#ifdef CONFIG_SCHED_MC
+-      { cpu_coregroup_mask, cpu_core_flags, SD_INIT_NAME(MC) },
+-#endif
+-
+-      { cpu_cpu_mask, SD_INIT_NAME(DIE) },
+-      { NULL, },
+-};
+-
+ /*
+  * init_cpu_topology is called at boot when only one cpu is running
+  * which prevent simultaneous write access to cpu_topology array
+  */
+ void __init init_cpu_topology(void)
+ {
+-      /* Set scheduler topology descriptor */
+-      if (dualcores_found)
+-              set_sched_topology(parisc_mc_topology);
++      reset_cpu_topology();
+ }
+-- 
+2.36.1
+
diff --git a/queue-5.18/parisc-stifb-implement-fb_is_primary_device.patch b/queue-5.18/parisc-stifb-implement-fb_is_primary_device.patch
new file mode 100644 (file)
index 0000000..1b033ec
--- /dev/null
@@ -0,0 +1,87 @@
+From cf936af790a3ef5f41ff687ec91bfbffee141278 Mon Sep 17 00:00:00 2001
+From: Helge Deller <deller@gmx.de>
+Date: Thu, 2 Jun 2022 13:50:44 +0200
+Subject: parisc/stifb: Implement fb_is_primary_device()
+
+From: Helge Deller <deller@gmx.de>
+
+commit cf936af790a3ef5f41ff687ec91bfbffee141278 upstream.
+
+Implement fb_is_primary_device() function, so that fbcon detects if this
+framebuffer belongs to the default graphics card which was used to start
+the system.
+
+Signed-off-by: Helge Deller <deller@gmx.de>
+Cc: stable@vger.kernel.org   # v5.10+
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/parisc/include/asm/fb.h    |    4 ++++
+ drivers/video/console/sticore.c |   17 +++++++++++++++++
+ drivers/video/fbdev/stifb.c     |    4 ++--
+ 3 files changed, 23 insertions(+), 2 deletions(-)
+
+--- a/arch/parisc/include/asm/fb.h
++++ b/arch/parisc/include/asm/fb.h
+@@ -12,9 +12,13 @@ static inline void fb_pgprotect(struct f
+       pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
+ }
++#if defined(CONFIG_STI_CONSOLE) || defined(CONFIG_FB_STI)
++int fb_is_primary_device(struct fb_info *info);
++#else
+ static inline int fb_is_primary_device(struct fb_info *info)
+ {
+       return 0;
+ }
++#endif
+ #endif /* _ASM_FB_H_ */
+--- a/drivers/video/console/sticore.c
++++ b/drivers/video/console/sticore.c
+@@ -30,6 +30,7 @@
+ #include <asm/pdc.h>
+ #include <asm/cacheflush.h>
+ #include <asm/grfioctl.h>
++#include <asm/fb.h>
+ #include "../fbdev/sticore.h"
+@@ -1127,6 +1128,22 @@ int sti_call(const struct sti_struct *st
+       return ret;
+ }
++/* check if given fb_info is the primary device */
++int fb_is_primary_device(struct fb_info *info)
++{
++      struct sti_struct *sti;
++
++      sti = sti_get_rom(0);
++
++      /* if no built-in graphics card found, allow any fb driver as default */
++      if (!sti)
++              return true;
++
++      /* return true if it's the default built-in framebuffer driver */
++      return (sti->info == info);
++}
++EXPORT_SYMBOL(fb_is_primary_device);
++
+ MODULE_AUTHOR("Philipp Rumpf, Helge Deller, Thomas Bogendoerfer");
+ MODULE_DESCRIPTION("Core STI driver for HP's NGLE series graphics cards in HP PARISC machines");
+ MODULE_LICENSE("GPL v2");
+--- a/drivers/video/fbdev/stifb.c
++++ b/drivers/video/fbdev/stifb.c
+@@ -1358,11 +1358,11 @@ static int __init stifb_init_fb(struct s
+               goto out_err3;
+       }
++      /* save for primary gfx device detection & unregister_framebuffer() */
++      sti->info = info;
+       if (register_framebuffer(&fb->info) < 0)
+               goto out_err4;
+-      sti->info = info; /* save for unregister_framebuffer() */
+-
+       fb_info(&fb->info, "%s %dx%d-%d frame buffer device, %s, id: %04x, mmio: 0x%04lx\n",
+               fix->id,
+               var->xres, 
diff --git a/queue-5.18/parisc-stifb-keep-track-of-hardware-path-of-graphics-card.patch b/queue-5.18/parisc-stifb-keep-track-of-hardware-path-of-graphics-card.patch
new file mode 100644 (file)
index 0000000..eb842c5
--- /dev/null
@@ -0,0 +1,113 @@
+From b046f984814af7985f444150ec28716d42d00d9a Mon Sep 17 00:00:00 2001
+From: Helge Deller <deller@gmx.de>
+Date: Thu, 2 Jun 2022 13:55:26 +0200
+Subject: parisc/stifb: Keep track of hardware path of graphics card
+
+From: Helge Deller <deller@gmx.de>
+
+commit b046f984814af7985f444150ec28716d42d00d9a upstream.
+
+Keep the pa_path (hardware path) of the graphics card in sti_struct and use
+this info to give more useful info which card is currently being used.
+
+Signed-off-by: Helge Deller <deller@gmx.de>
+Cc: stable@vger.kernel.org   # v5.10+
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/video/console/sticon.c  |    5 ++++-
+ drivers/video/console/sticore.c |   15 +++++++--------
+ drivers/video/fbdev/sticore.h   |    3 +++
+ 3 files changed, 14 insertions(+), 9 deletions(-)
+
+--- a/drivers/video/console/sticon.c
++++ b/drivers/video/console/sticon.c
+@@ -46,6 +46,7 @@
+ #include <linux/slab.h>
+ #include <linux/font.h>
+ #include <linux/crc32.h>
++#include <linux/fb.h>
+ #include <asm/io.h>
+@@ -392,7 +393,9 @@ static int __init sticonsole_init(void)
+     for (i = 0; i < MAX_NR_CONSOLES; i++)
+       font_data[i] = STI_DEF_FONT;
+-    pr_info("sticon: Initializing STI text console.\n");
++    pr_info("sticon: Initializing STI text console on %s at [%s]\n",
++      sticon_sti->sti_data->inq_outptr.dev_name,
++      sticon_sti->pa_path);
+     console_lock();
+     err = do_take_over_console(&sti_con, 0, MAX_NR_CONSOLES - 1,
+               PAGE0->mem_cons.cl_class != CL_DUPLEX);
+--- a/drivers/video/console/sticore.c
++++ b/drivers/video/console/sticore.c
+@@ -34,7 +34,7 @@
+ #include "../fbdev/sticore.h"
+-#define STI_DRIVERVERSION "Version 0.9b"
++#define STI_DRIVERVERSION "Version 0.9c"
+ static struct sti_struct *default_sti __read_mostly;
+@@ -503,7 +503,7 @@ sti_select_fbfont(struct sti_cooked_rom
+       if (!fbfont)
+               return NULL;
+-      pr_info("STI selected %ux%u framebuffer font %s for sticon\n",
++      pr_info("    using %ux%u framebuffer font %s\n",
+                       fbfont->width, fbfont->height, fbfont->name);
+                       
+       bpc = ((fbfont->width+7)/8) * fbfont->height; 
+@@ -947,6 +947,7 @@ out_err:
+ static void sticore_check_for_default_sti(struct sti_struct *sti, char *path)
+ {
++      pr_info("    located at [%s]\n", sti->pa_path);
+       if (strcmp (path, default_sti_path) == 0)
+               default_sti = sti;
+ }
+@@ -958,7 +959,6 @@ static void sticore_check_for_default_st
+  */
+ static int __init sticore_pa_init(struct parisc_device *dev)
+ {
+-      char pa_path[21];
+       struct sti_struct *sti = NULL;
+       int hpa = dev->hpa.start;
+@@ -971,8 +971,8 @@ static int __init sticore_pa_init(struct
+       if (!sti)
+               return 1;
+-      print_pa_hwpath(dev, pa_path);
+-      sticore_check_for_default_sti(sti, pa_path);
++      print_pa_hwpath(dev, sti->pa_path);
++      sticore_check_for_default_sti(sti, sti->pa_path);
+       return 0;
+ }
+@@ -1008,9 +1008,8 @@ static int sticore_pci_init(struct pci_d
+       sti = sti_try_rom_generic(rom_base, fb_base, pd);
+       if (sti) {
+-              char pa_path[30];
+-              print_pci_hwpath(pd, pa_path);
+-              sticore_check_for_default_sti(sti, pa_path);
++              print_pci_hwpath(pd, sti->pa_path);
++              sticore_check_for_default_sti(sti, sti->pa_path);
+       }
+       
+       if (!sti) {
+--- a/drivers/video/fbdev/sticore.h
++++ b/drivers/video/fbdev/sticore.h
+@@ -370,6 +370,9 @@ struct sti_struct {
+       /* pointer to all internal data */
+       struct sti_all_data *sti_data;
++
++      /* pa_path of this device */
++      char pa_path[24];
+ };
index a1889584ccafde38d48f3bd11a12a26e759b696e..038761f76dfc22d96ba5e4b189bf956a835f7caf 100644 (file)
@@ -1 +1,5 @@
 arm64-initialize-jump-labels-before-setup_machine_fdt.patch
+binfmt_flat-do-not-stop-relocating-got-entries-prematurely-on-riscv.patch
+parisc-fix-a-crash-with-multicore-scheduler.patch
+parisc-stifb-implement-fb_is_primary_device.patch
+parisc-stifb-keep-track-of-hardware-path-of-graphics-card.patch