]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Jan 2023 12:11:29 +0000 (13:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Jan 2023 12:11:29 +0000 (13:11 +0100)
added patches:
parisc-align-parisc-madv_xxx-constants-with-all-other-architectures.patch

queue-4.19/parisc-align-parisc-madv_xxx-constants-with-all-other-architectures.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/parisc-align-parisc-madv_xxx-constants-with-all-other-architectures.patch b/queue-4.19/parisc-align-parisc-madv_xxx-constants-with-all-other-architectures.patch
new file mode 100644 (file)
index 0000000..5048cc8
--- /dev/null
@@ -0,0 +1,166 @@
+From 71bdea6f798b425bc0003780b13e3fdecb16a010 Mon Sep 17 00:00:00 2001
+From: Helge Deller <deller@gmx.de>
+Date: Sun, 11 Dec 2022 19:50:20 +0100
+Subject: parisc: Align parisc MADV_XXX constants with all other architectures
+
+From: Helge Deller <deller@gmx.de>
+
+commit 71bdea6f798b425bc0003780b13e3fdecb16a010 upstream.
+
+Adjust some MADV_XXX constants to be in sync what their values are on
+all other platforms. There is currently no reason to have an own
+numbering on parisc, but it requires workarounds in many userspace
+sources (e.g. glibc, qemu, ...) - which are often forgotten and thus
+introduce bugs and different behaviour on parisc.
+
+A wrapper avoids an ABI breakage for existing userspace applications by
+translating any old values to the new ones, so this change allows us to
+move over all programs to the new ABI over time.
+
+Signed-off-by: Helge Deller <deller@gmx.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/parisc/include/uapi/asm/mman.h       |   17 ++++++++---------
+ arch/parisc/kernel/sys_parisc.c           |   27 +++++++++++++++++++++++++++
+ arch/parisc/kernel/syscall_table.S        |    2 +-
+ tools/arch/parisc/include/uapi/asm/mman.h |   12 ++++++------
+ tools/perf/bench/bench.h                  |   12 ------------
+ 5 files changed, 42 insertions(+), 28 deletions(-)
+
+--- a/arch/parisc/include/uapi/asm/mman.h
++++ b/arch/parisc/include/uapi/asm/mman.h
+@@ -50,25 +50,24 @@
+ #define MADV_DONTFORK 10              /* don't inherit across fork */
+ #define MADV_DOFORK   11              /* do inherit across fork */
+-#define MADV_MERGEABLE   65           /* KSM may merge identical pages */
+-#define MADV_UNMERGEABLE 66           /* KSM may not merge identical pages */
++#define MADV_MERGEABLE   12           /* KSM may merge identical pages */
++#define MADV_UNMERGEABLE 13           /* KSM may not merge identical pages */
+-#define MADV_HUGEPAGE 67              /* Worth backing with hugepages */
+-#define MADV_NOHUGEPAGE       68              /* Not worth backing with hugepages */
++#define MADV_HUGEPAGE 14              /* Worth backing with hugepages */
++#define MADV_NOHUGEPAGE 15            /* Not worth backing with hugepages */
+-#define MADV_DONTDUMP   69            /* Explicity exclude from the core dump,
++#define MADV_DONTDUMP   16            /* Explicity exclude from the core dump,
+                                          overrides the coredump filter bits */
+-#define MADV_DODUMP   70              /* Clear the MADV_NODUMP flag */
++#define MADV_DODUMP   17              /* Clear the MADV_NODUMP flag */
+-#define MADV_WIPEONFORK 71            /* Zero memory on fork, child only */
+-#define MADV_KEEPONFORK 72            /* Undo MADV_WIPEONFORK */
++#define MADV_WIPEONFORK 18            /* Zero memory on fork, child only */
++#define MADV_KEEPONFORK 19            /* Undo MADV_WIPEONFORK */
+ #define MADV_HWPOISON     100         /* poison a page for testing */
+ #define MADV_SOFT_OFFLINE 101         /* soft offline page for testing */
+ /* compatibility flags */
+ #define MAP_FILE      0
+-#define MAP_VARIABLE  0
+ #define PKEY_DISABLE_ACCESS   0x1
+ #define PKEY_DISABLE_WRITE    0x2
+--- a/arch/parisc/kernel/sys_parisc.c
++++ b/arch/parisc/kernel/sys_parisc.c
+@@ -386,3 +386,30 @@ long parisc_personality(unsigned long pe
+       return err;
+ }
++
++/*
++ * madvise() wrapper
++ *
++ * Up to kernel v6.1 parisc has different values than all other
++ * platforms for the MADV_xxx flags listed below.
++ * To keep binary compatibility with existing userspace programs
++ * translate the former values to the new values.
++ *
++ * XXX: Remove this wrapper in year 2025 (or later)
++ */
++
++asmlinkage notrace long parisc_madvise(unsigned long start, size_t len_in, int behavior)
++{
++      switch (behavior) {
++      case 65: behavior = MADV_MERGEABLE;     break;
++      case 66: behavior = MADV_UNMERGEABLE;   break;
++      case 67: behavior = MADV_HUGEPAGE;      break;
++      case 68: behavior = MADV_NOHUGEPAGE;    break;
++      case 69: behavior = MADV_DONTDUMP;      break;
++      case 70: behavior = MADV_DODUMP;        break;
++      case 71: behavior = MADV_WIPEONFORK;    break;
++      case 72: behavior = MADV_KEEPONFORK;    break;
++      }
++
++      return sys_madvise(start, len_in, behavior);
++}
+--- a/arch/parisc/kernel/syscall_table.S
++++ b/arch/parisc/kernel/syscall_table.S
+@@ -195,7 +195,7 @@
+       ENTRY_COMP(sysinfo)
+       ENTRY_SAME(shutdown)
+       ENTRY_SAME(fsync)
+-      ENTRY_SAME(madvise)
++      ENTRY_OURS(madvise)
+       ENTRY_SAME(clone_wrapper)       /* 120 */
+       ENTRY_SAME(setdomainname)
+       ENTRY_COMP(sendfile)
+--- a/tools/arch/parisc/include/uapi/asm/mman.h
++++ b/tools/arch/parisc/include/uapi/asm/mman.h
+@@ -1,20 +1,20 @@
+ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+ #ifndef TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H
+ #define TOOLS_ARCH_PARISC_UAPI_ASM_MMAN_FIX_H
+-#define MADV_DODUMP   70
++#define MADV_DODUMP   17
+ #define MADV_DOFORK   11
+-#define MADV_DONTDUMP   69
++#define MADV_DONTDUMP   16
+ #define MADV_DONTFORK 10
+ #define MADV_DONTNEED   4
+ #define MADV_FREE     8
+-#define MADV_HUGEPAGE 67
+-#define MADV_MERGEABLE   65
+-#define MADV_NOHUGEPAGE       68
++#define MADV_HUGEPAGE 14
++#define MADV_MERGEABLE  12
++#define MADV_NOHUGEPAGE 15
+ #define MADV_NORMAL     0
+ #define MADV_RANDOM     1
+ #define MADV_REMOVE   9
+ #define MADV_SEQUENTIAL 2
+-#define MADV_UNMERGEABLE 66
++#define MADV_UNMERGEABLE 13
+ #define MADV_WILLNEED   3
+ #define MAP_ANONYMOUS 0x10
+ #define MAP_DENYWRITE 0x0800
+--- a/tools/perf/bench/bench.h
++++ b/tools/perf/bench/bench.h
+@@ -10,25 +10,13 @@ extern struct timeval bench__start, benc
+  * The madvise transparent hugepage constants were added in glibc
+  * 2.13. For compatibility with older versions of glibc, define these
+  * tokens if they are not already defined.
+- *
+- * PA-RISC uses different madvise values from other architectures and
+- * needs to be special-cased.
+  */
+-#ifdef __hppa__
+-# ifndef MADV_HUGEPAGE
+-#  define MADV_HUGEPAGE               67
+-# endif
+-# ifndef MADV_NOHUGEPAGE
+-#  define MADV_NOHUGEPAGE     68
+-# endif
+-#else
+ # ifndef MADV_HUGEPAGE
+ #  define MADV_HUGEPAGE               14
+ # endif
+ # ifndef MADV_NOHUGEPAGE
+ #  define MADV_NOHUGEPAGE     15
+ # endif
+-#endif
+ int bench_numa(int argc, const char **argv);
+ int bench_sched_messaging(int argc, const char **argv);
index 4019e034c08ed6a388b05f79c1b01625c6bb16a9..a2d60cbbc091335c6055380284dc9cec9ae2cd6e 100644 (file)
@@ -460,3 +460,4 @@ ext4-don-t-allow-journal-inode-to-have-encrypt-flag.patch
 hfs-hfsplus-use-warn_on-for-sanity-check.patch
 hfs-hfsplus-avoid-warn_on-for-sanity-check-use-proper-error-handling.patch
 mbcache-avoid-nesting-of-cache-c_list_lock-under-bit-locks.patch
+parisc-align-parisc-madv_xxx-constants-with-all-other-architectures.patch