Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1590766 > unrolled thread
| Started by | Laura Abbott <labbott@redhat.com> |
|---|---|
| First post | 2017-03-02 02:20 +0100 |
| Last post | 2017-03-02 14:10 +0100 |
| Articles | 9 — 6 participants |
Back to article view | Back to linux.kernel
[PATCHv2 00/14] set_memory_* functions header refactor Laura Abbott <labbott@redhat.com> - 2017-03-02 02:20 +0100
[PATCHv2 05/14] x86: Use set_memory.h header Laura Abbott <labbott@redhat.com> - 2017-03-02 03:10 +0100
Re: [PATCHv2 05/14] x86: Use set_memory.h header Ingo Molnar <mingo@kernel.org> - 2017-03-02 12:00 +0100
[PATCHv2 01/14] treewide: Move set_memory_* functions away from cacheflush.h Laura Abbott <labbott@redhat.com> - 2017-03-02 03:20 +0100
Re: [PATCHv2 01/14] treewide: Move set_memory_* functions away from cacheflush.h Russell King - ARM Linux <linux@armlinux.org.uk> - 2017-03-02 13:30 +0100
Re: [PATCHv2 01/14] treewide: Move set_memory_* functions away from cacheflush.h Mark Rutland <mark.rutland@arm.com> - 2017-03-02 16:30 +0100
[PATCHv2 08/14] intel_th: Use set_memory.h header Laura Abbott <labbott@redhat.com> - 2017-03-02 08:30 +0100
Re: [PATCHv2 08/14] intel_th: Use set_memory.h header Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2017-03-02 12:10 +0100
Re: [PATCHv2 00/14] set_memory_* functions header refactor Heiko Carstens <heiko.carstens@de.ibm.com> - 2017-03-02 14:10 +0100
| From | Laura Abbott <labbott@redhat.com> |
|---|---|
| Date | 2017-03-02 02:20 +0100 |
| Subject | [PATCHv2 00/14] set_memory_* functions header refactor |
| Message-ID | <tgmDn-2sk-3@gated-at.bofh.it> |
Hi, This is v2 of my proposal to move set_memory_* function prototypes out of cacheflush.h and into their own header file. This came out of a comment Russell made while reviewing RODATA test cases http://lists.infradead.org/pipermail/linux-arm-kernel/2017-January/480855.html While the final result of that series was the rodata code was refactored into its own header file, the set_memory_* APIs are still out of place. This version refactored the common set_memory_* functions into an asm-generic header. s390x added some features so it can't just use the asm-generic header. I debated how much more to try and shove into the asm-generic version (e.g. stub prototypes for the ARM nommu case, set_kernel_text_*) but decided to stick with just the basics for this version. I split out the cacheflush.h -> set_memory.h conversions into separate patches to hopefully make merging easier. Worst case, the final patch to completely separate the two can be delayed if there are more problems found. I'd like for this to eventually go through the -mm tree so I'd like Acks where appropriate. As always, feedback appreciated. Thanks, Laura Laura Abbott (14): treewide: Move set_memory_* functions away from cacheflush.h arm: Use set_memory.h header arm64: Use set_memory.h header s390: Use set_memory.h header x86: Use set_memory.h header agp: Use set_memory.h header drm: Use set_memory.h header intel_th: Use set_memory.h header watchdog: hpwdt: Use set_memory.h header bpf: Use set_memory.h header module: Use set_memory.h header PM / hibernate: Use set_memory.h header ALSA: hda: Use set_memory.h header treewide: Decouple cacheflush.h and set_memory.h arch/arm/include/asm/cacheflush.h | 20 -------- arch/arm/include/asm/set_memory.h | 32 ++++++++++++ arch/arm/mm/pageattr.c | 1 + arch/arm/net/bpf_jit_32.c | 2 +- arch/arm64/include/asm/Kbuild | 1 + arch/arm64/include/asm/cacheflush.h | 5 -- arch/arm64/mm/pageattr.c | 1 + arch/arm64/net/bpf_jit_comp.c | 1 + arch/s390/include/asm/Kbuild | 1 + arch/s390/include/asm/cacheflush.h | 34 ------------- arch/s390/include/asm/set_memory.h | 31 ++++++++++++ arch/s390/kernel/ftrace.c | 1 + arch/s390/kernel/kprobes.c | 2 +- arch/s390/kernel/machine_kexec.c | 1 + arch/s390/mm/init.c | 1 + arch/s390/mm/pageattr.c | 1 + arch/s390/mm/vmem.c | 1 + arch/s390/net/bpf_jit_comp.c | 1 + arch/x86/include/asm/cacheflush.h | 85 ------------------------------- arch/x86/include/asm/set_memory.h | 87 ++++++++++++++++++++++++++++++++ arch/x86/kernel/amd_gart_64.c | 2 +- arch/x86/kernel/cpu/amd.c | 2 +- arch/x86/kernel/cpu/bugs.c | 2 +- arch/x86/kernel/ftrace.c | 2 +- arch/x86/kernel/machine_kexec_64.c | 1 + arch/x86/mm/init.c | 2 +- arch/x86/mm/init_64.c | 2 +- arch/x86/mm/ioremap.c | 2 +- arch/x86/mm/pageattr.c | 1 + arch/x86/net/bpf_jit_comp.c | 1 + arch/x86/pci/pcbios.c | 2 +- arch/x86/platform/efi/efi.c | 2 +- arch/x86/realmode/init.c | 2 +- drivers/char/agp/amd-k7-agp.c | 1 + drivers/char/agp/ati-agp.c | 1 + drivers/char/agp/generic.c | 2 +- drivers/char/agp/intel-gtt.c | 1 + drivers/char/agp/sworks-agp.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 1 + drivers/gpu/drm/gma500/gtt.c | 1 + drivers/gpu/drm/gma500/psb_drv.c | 1 + drivers/gpu/drm/radeon/radeon_gart.c | 1 + drivers/gpu/drm/ttm/ttm_page_alloc.c | 1 + drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 1 + drivers/gpu/drm/ttm/ttm_tt.c | 1 + drivers/hwtracing/intel_th/msu.c | 2 +- drivers/watchdog/hpwdt.c | 2 +- include/asm-generic/set_memory.h | 12 +++++ include/linux/filter.h | 2 +- kernel/module.c | 1 + kernel/power/snapshot.c | 1 + sound/pci/hda/hda_intel.c | 2 +- 52 files changed, 206 insertions(+), 161 deletions(-) create mode 100644 arch/arm/include/asm/set_memory.h delete mode 100644 arch/s390/include/asm/cacheflush.h create mode 100644 arch/s390/include/asm/set_memory.h create mode 100644 arch/x86/include/asm/set_memory.h create mode 100644 include/asm-generic/set_memory.h -- 2.7.4
[toc] | [next] | [standalone]
| From | Laura Abbott <labbott@redhat.com> |
|---|---|
| Date | 2017-03-02 03:10 +0100 |
| Subject | [PATCHv2 05/14] x86: Use set_memory.h header |
| Message-ID | <tgolP-3FJ-3@gated-at.bofh.it> |
| In reply to | #1590766 |
set_memory_* functions have moved to set_memory.h. Switch to this
explicitly.
Signed-off-by: Laura Abbott <labbott@redhat.com>
---
arch/x86/kernel/amd_gart_64.c | 2 +-
arch/x86/kernel/cpu/amd.c | 2 +-
arch/x86/kernel/cpu/bugs.c | 2 +-
arch/x86/kernel/ftrace.c | 2 +-
arch/x86/kernel/machine_kexec_64.c | 1 +
arch/x86/mm/init.c | 2 +-
arch/x86/mm/init_64.c | 2 +-
arch/x86/mm/ioremap.c | 2 +-
arch/x86/mm/pageattr.c | 1 +
arch/x86/net/bpf_jit_comp.c | 1 +
arch/x86/pci/pcbios.c | 2 +-
arch/x86/platform/efi/efi.c | 2 +-
arch/x86/realmode/init.c | 2 +-
13 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/arch/x86/kernel/amd_gart_64.c b/arch/x86/kernel/amd_gart_64.c
index 82dfe32..6c81048 100644
--- a/arch/x86/kernel/amd_gart_64.c
+++ b/arch/x86/kernel/amd_gart_64.c
@@ -35,7 +35,7 @@
#include <asm/proto.h>
#include <asm/iommu.h>
#include <asm/gart.h>
-#include <asm/cacheflush.h>
+#include <asm/set_memory.h>
#include <asm/swiotlb.h>
#include <asm/dma.h>
#include <asm/amd_nb.h>
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 4e95b2e..f77f7f4 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -15,7 +15,7 @@
#ifdef CONFIG_X86_64
# include <asm/mmconfig.h>
-# include <asm/cacheflush.h>
+# include <asm/set_memory.h>
#endif
#include "cpu.h"
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index a44ef52..0af86d9 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -17,7 +17,7 @@
#include <asm/paravirt.h>
#include <asm/alternative.h>
#include <asm/pgtable.h>
-#include <asm/cacheflush.h>
+#include <asm/set_memory.h>
void __init check_bugs(void)
{
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 8639bb2..da9f2b0 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -24,7 +24,7 @@
#include <trace/syscall.h>
-#include <asm/cacheflush.h>
+#include <asm/set_memory.h>
#include <asm/kprobes.h>
#include <asm/ftrace.h>
#include <asm/nops.h>
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 307b1f4..8887311 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -27,6 +27,7 @@
#include <asm/debugreg.h>
#include <asm/kexec-bzimage64.h>
#include <asm/setup.h>
+#include <asm/set_memory.h>
#ifdef CONFIG_KEXEC_FILE
static struct kexec_file_ops *kexec_file_loaders[] = {
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 22af912..adbfb09 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -5,7 +5,7 @@
#include <linux/memblock.h>
#include <linux/bootmem.h> /* for max_low_pfn */
-#include <asm/cacheflush.h>
+#include <asm/set_memory.h>
#include <asm/e820.h>
#include <asm/init.h>
#include <asm/page.h>
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 15173d3..7eef172 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -50,7 +50,7 @@
#include <asm/sections.h>
#include <asm/kdebug.h>
#include <asm/numa.h>
-#include <asm/cacheflush.h>
+#include <asm/set_memory.h>
#include <asm/init.h>
#include <asm/uv/uv.h>
#include <asm/setup.h>
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 7aaa263..8ae010c 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -13,7 +13,7 @@
#include <linux/vmalloc.h>
#include <linux/mmiotrace.h>
-#include <asm/cacheflush.h>
+#include <asm/set_memory.h>
#include <asm/e820.h>
#include <asm/fixmap.h>
#include <asm/pgtable.h>
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 28d4213..bfcdd45 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -24,6 +24,7 @@
#include <asm/pgalloc.h>
#include <asm/proto.h>
#include <asm/pat.h>
+#include <asm/set_memory.h>
/*
* The current flushing context - we pass it instead of 5 arguments:
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 32322ce..a63e6af 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -12,6 +12,7 @@
#include <linux/filter.h>
#include <linux/if_vlan.h>
#include <asm/cacheflush.h>
+#include <asm/set_memory.h>
#include <linux/bpf.h>
int bpf_jit_enable __read_mostly;
diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
index 1d97cea..4d510a6 100644
--- a/arch/x86/pci/pcbios.c
+++ b/arch/x86/pci/pcbios.c
@@ -9,7 +9,7 @@
#include <linux/uaccess.h>
#include <asm/pci_x86.h>
#include <asm/pci-functions.h>
-#include <asm/cacheflush.h>
+#include <asm/set_memory.h>
/* BIOS32 signature: "_32_" */
#define BIOS32_SIGNATURE (('_' << 0) + ('3' << 8) + ('2' << 16) + ('_' << 24))
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 565dff3..6867d88 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -48,7 +48,7 @@
#include <asm/setup.h>
#include <asm/efi.h>
#include <asm/time.h>
-#include <asm/cacheflush.h>
+#include <asm/set_memory.h>
#include <asm/tlbflush.h>
#include <asm/x86_init.h>
#include <asm/uv/uv.h>
diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
index 5db706f1..a163a90 100644
--- a/arch/x86/realmode/init.c
+++ b/arch/x86/realmode/init.c
@@ -2,7 +2,7 @@
#include <linux/slab.h>
#include <linux/memblock.h>
-#include <asm/cacheflush.h>
+#include <asm/set_memory.h>
#include <asm/pgtable.h>
#include <asm/realmode.h>
#include <asm/tlbflush.h>
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2017-03-02 12:00 +0100 |
| Subject | Re: [PATCHv2 05/14] x86: Use set_memory.h header |
| Message-ID | <tgwCK-16L-15@gated-at.bofh.it> |
| In reply to | #1590796 |
* Laura Abbott <labbott@redhat.com> wrote: > > set_memory_* functions have moved to set_memory.h. Switch to this > explicitly. > > Signed-off-by: Laura Abbott <labbott@redhat.com> > --- > arch/x86/kernel/amd_gart_64.c | 2 +- > arch/x86/kernel/cpu/amd.c | 2 +- > arch/x86/kernel/cpu/bugs.c | 2 +- > arch/x86/kernel/ftrace.c | 2 +- > arch/x86/kernel/machine_kexec_64.c | 1 + > arch/x86/mm/init.c | 2 +- > arch/x86/mm/init_64.c | 2 +- > arch/x86/mm/ioremap.c | 2 +- > arch/x86/mm/pageattr.c | 1 + > arch/x86/net/bpf_jit_comp.c | 1 + > arch/x86/pci/pcbios.c | 2 +- > arch/x86/platform/efi/efi.c | 2 +- > arch/x86/realmode/init.c | 2 +- > 13 files changed, 13 insertions(+), 10 deletions(-) Acked-by: Ingo Molnar <mingo@kernel.org> Thanks, Ingo
[toc] | [prev] | [next] | [standalone]
| From | Laura Abbott <labbott@redhat.com> |
|---|---|
| Date | 2017-03-02 03:20 +0100 |
| Subject | [PATCHv2 01/14] treewide: Move set_memory_* functions away from cacheflush.h |
| Message-ID | <tgovw-3Ky-17@gated-at.bofh.it> |
| In reply to | #1590766 |
The set_memory_* APIs came out of a desire to have a better way to
change memory attributes. Many of these attributes were linked to cache
functionality so the prototypes were put in cacheflush.h. These days,
the APIs have grown and have a much wider use than just cache APIs. To
support this growth, split off set_memory_* and friends into a separate
header file to avoid growing cacheflush.h for APIs that have nothing to
do with caches.
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Laura Abbott <labbott@redhat.com>
---
arch/arm/include/asm/cacheflush.h | 21 +--------
arch/arm/include/asm/set_memory.h | 32 ++++++++++++++
arch/arm64/include/asm/Kbuild | 1 +
arch/arm64/include/asm/cacheflush.h | 6 +--
arch/s390/include/asm/cacheflush.h | 28 +-----------
arch/s390/include/asm/set_memory.h | 31 +++++++++++++
arch/x86/include/asm/cacheflush.h | 86 +-----------------------------------
arch/x86/include/asm/set_memory.h | 87 +++++++++++++++++++++++++++++++++++++
include/asm-generic/set_memory.h | 12 +++++
9 files changed, 167 insertions(+), 137 deletions(-)
create mode 100644 arch/arm/include/asm/set_memory.h
create mode 100644 arch/s390/include/asm/set_memory.h
create mode 100644 arch/x86/include/asm/set_memory.h
create mode 100644 include/asm-generic/set_memory.h
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index 02454fa..1cb9d11 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -16,6 +16,7 @@
#include <asm/shmparam.h>
#include <asm/cachetype.h>
#include <asm/outercache.h>
+#include <asm/set_memory.h>
#define CACHE_COLOUR(vaddr) ((vaddr & (SHMLBA - 1)) >> PAGE_SHIFT)
@@ -478,26 +479,6 @@ static inline void __sync_cache_range_r(volatile void *p, size_t size)
: : : "r0","r1","r2","r3","r4","r5","r6","r7", \
"r9","r10","lr","memory" )
-#ifdef CONFIG_MMU
-int set_memory_ro(unsigned long addr, int numpages);
-int set_memory_rw(unsigned long addr, int numpages);
-int set_memory_x(unsigned long addr, int numpages);
-int set_memory_nx(unsigned long addr, int numpages);
-#else
-static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; }
-static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; }
-static inline int set_memory_x(unsigned long addr, int numpages) { return 0; }
-static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; }
-#endif
-
-#ifdef CONFIG_STRICT_KERNEL_RWX
-void set_kernel_text_rw(void);
-void set_kernel_text_ro(void);
-#else
-static inline void set_kernel_text_rw(void) { }
-static inline void set_kernel_text_ro(void) { }
-#endif
-
void flush_uprobe_xol_access(struct page *page, unsigned long uaddr,
void *kaddr, unsigned long len);
diff --git a/arch/arm/include/asm/set_memory.h b/arch/arm/include/asm/set_memory.h
new file mode 100644
index 0000000..5aa4315
--- /dev/null
+++ b/arch/arm/include/asm/set_memory.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 1999-2002 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef _ASMARM_SET_MEMORY_H
+#define _ASMARM_SET_MEMORY_H
+
+#ifdef CONFIG_MMU
+int set_memory_ro(unsigned long addr, int numpages);
+int set_memory_rw(unsigned long addr, int numpages);
+int set_memory_x(unsigned long addr, int numpages);
+int set_memory_nx(unsigned long addr, int numpages);
+#else
+static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; }
+static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; }
+static inline int set_memory_x(unsigned long addr, int numpages) { return 0; }
+static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; }
+#endif
+
+#ifdef CONFIG_STRICT_KERNEL_RWX
+void set_kernel_text_rw(void);
+void set_kernel_text_ro(void);
+#else
+static inline void set_kernel_text_rw(void) { }
+static inline void set_kernel_text_ro(void) { }
+#endif
+
+#endif
diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index a12f1af..e419965 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -27,6 +27,7 @@ generic-y += preempt.h
generic-y += resource.h
generic-y += rwsem.h
generic-y += segment.h
+generic-y += set_memory.h
generic-y += sembuf.h
generic-y += serial.h
generic-y += shmbuf.h
diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h
index 5a2a6ee..7db6962 100644
--- a/arch/arm64/include/asm/cacheflush.h
+++ b/arch/arm64/include/asm/cacheflush.h
@@ -20,6 +20,7 @@
#define __ASM_CACHEFLUSH_H
#include <linux/mm.h>
+#include <asm/set_memory.h>
/*
* This flag is used to indicate that the page pointed to by a pte is clean
@@ -150,9 +151,4 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end)
{
}
-int set_memory_ro(unsigned long addr, int numpages);
-int set_memory_rw(unsigned long addr, int numpages);
-int set_memory_x(unsigned long addr, int numpages);
-int set_memory_nx(unsigned long addr, int numpages);
-
#endif
diff --git a/arch/s390/include/asm/cacheflush.h b/arch/s390/include/asm/cacheflush.h
index 0499334..afe2965 100644
--- a/arch/s390/include/asm/cacheflush.h
+++ b/arch/s390/include/asm/cacheflush.h
@@ -3,32 +3,6 @@
/* Caches aren't brain-dead on the s390. */
#include <asm-generic/cacheflush.h>
-
-#define SET_MEMORY_RO 1UL
-#define SET_MEMORY_RW 2UL
-#define SET_MEMORY_NX 4UL
-#define SET_MEMORY_X 8UL
-
-int __set_memory(unsigned long addr, int numpages, unsigned long flags);
-
-static inline int set_memory_ro(unsigned long addr, int numpages)
-{
- return __set_memory(addr, numpages, SET_MEMORY_RO);
-}
-
-static inline int set_memory_rw(unsigned long addr, int numpages)
-{
- return __set_memory(addr, numpages, SET_MEMORY_RW);
-}
-
-static inline int set_memory_nx(unsigned long addr, int numpages)
-{
- return __set_memory(addr, numpages, SET_MEMORY_NX);
-}
-
-static inline int set_memory_x(unsigned long addr, int numpages)
-{
- return __set_memory(addr, numpages, SET_MEMORY_X);
-}
+#include <asm/set_memory.h>
#endif /* _S390_CACHEFLUSH_H */
diff --git a/arch/s390/include/asm/set_memory.h b/arch/s390/include/asm/set_memory.h
new file mode 100644
index 0000000..46a4db4
--- /dev/null
+++ b/arch/s390/include/asm/set_memory.h
@@ -0,0 +1,31 @@
+#ifndef _ASMS390_SET_MEMORY_H
+#define _ASMS390_SET_MEMORY_H
+
+#define SET_MEMORY_RO 1UL
+#define SET_MEMORY_RW 2UL
+#define SET_MEMORY_NX 4UL
+#define SET_MEMORY_X 8UL
+
+int __set_memory(unsigned long addr, int numpages, unsigned long flags);
+
+static inline int set_memory_ro(unsigned long addr, int numpages)
+{
+ return __set_memory(addr, numpages, SET_MEMORY_RO);
+}
+
+static inline int set_memory_rw(unsigned long addr, int numpages)
+{
+ return __set_memory(addr, numpages, SET_MEMORY_RW);
+}
+
+static inline int set_memory_nx(unsigned long addr, int numpages)
+{
+ return __set_memory(addr, numpages, SET_MEMORY_NX);
+}
+
+static inline int set_memory_x(unsigned long addr, int numpages)
+{
+ return __set_memory(addr, numpages, SET_MEMORY_X);
+}
+
+#endif
diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
index e7e1942..3d7db6f 100644
--- a/arch/x86/include/asm/cacheflush.h
+++ b/arch/x86/include/asm/cacheflush.h
@@ -4,94 +4,10 @@
/* Caches aren't brain-dead on the intel. */
#include <asm-generic/cacheflush.h>
#include <asm/special_insns.h>
-
-/*
- * The set_memory_* API can be used to change various attributes of a virtual
- * address range. The attributes include:
- * Cachability : UnCached, WriteCombining, WriteThrough, WriteBack
- * Executability : eXeutable, NoteXecutable
- * Read/Write : ReadOnly, ReadWrite
- * Presence : NotPresent
- *
- * Within a category, the attributes are mutually exclusive.
- *
- * The implementation of this API will take care of various aspects that
- * are associated with changing such attributes, such as:
- * - Flushing TLBs
- * - Flushing CPU caches
- * - Making sure aliases of the memory behind the mapping don't violate
- * coherency rules as defined by the CPU in the system.
- *
- * What this API does not do:
- * - Provide exclusion between various callers - including callers that
- * operation on other mappings of the same physical page
- * - Restore default attributes when a page is freed
- * - Guarantee that mappings other than the requested one are
- * in any state, other than that these do not violate rules for
- * the CPU you have. Do not depend on any effects on other mappings,
- * CPUs other than the one you have may have more relaxed rules.
- * The caller is required to take care of these.
- */
-
-int _set_memory_uc(unsigned long addr, int numpages);
-int _set_memory_wc(unsigned long addr, int numpages);
-int _set_memory_wt(unsigned long addr, int numpages);
-int _set_memory_wb(unsigned long addr, int numpages);
-int set_memory_uc(unsigned long addr, int numpages);
-int set_memory_wc(unsigned long addr, int numpages);
-int set_memory_wt(unsigned long addr, int numpages);
-int set_memory_wb(unsigned long addr, int numpages);
-int set_memory_x(unsigned long addr, int numpages);
-int set_memory_nx(unsigned long addr, int numpages);
-int set_memory_ro(unsigned long addr, int numpages);
-int set_memory_rw(unsigned long addr, int numpages);
-int set_memory_np(unsigned long addr, int numpages);
-int set_memory_4k(unsigned long addr, int numpages);
-
-int set_memory_array_uc(unsigned long *addr, int addrinarray);
-int set_memory_array_wc(unsigned long *addr, int addrinarray);
-int set_memory_array_wt(unsigned long *addr, int addrinarray);
-int set_memory_array_wb(unsigned long *addr, int addrinarray);
-
-int set_pages_array_uc(struct page **pages, int addrinarray);
-int set_pages_array_wc(struct page **pages, int addrinarray);
-int set_pages_array_wt(struct page **pages, int addrinarray);
-int set_pages_array_wb(struct page **pages, int addrinarray);
-
-/*
- * For legacy compatibility with the old APIs, a few functions
- * are provided that work on a "struct page".
- * These functions operate ONLY on the 1:1 kernel mapping of the
- * memory that the struct page represents, and internally just
- * call the set_memory_* function. See the description of the
- * set_memory_* function for more details on conventions.
- *
- * These APIs should be considered *deprecated* and are likely going to
- * be removed in the future.
- * The reason for this is the implicit operation on the 1:1 mapping only,
- * making this not a generally useful API.
- *
- * Specifically, many users of the old APIs had a virtual address,
- * called virt_to_page() or vmalloc_to_page() on that address to
- * get a struct page* that the old API required.
- * To convert these cases, use set_memory_*() on the original
- * virtual address, do not use these functions.
- */
-
-int set_pages_uc(struct page *page, int numpages);
-int set_pages_wb(struct page *page, int numpages);
-int set_pages_x(struct page *page, int numpages);
-int set_pages_nx(struct page *page, int numpages);
-int set_pages_ro(struct page *page, int numpages);
-int set_pages_rw(struct page *page, int numpages);
-
+#include <asm/set_memory.h>
void clflush_cache_range(void *addr, unsigned int size);
#define mmio_flush_range(addr, size) clflush_cache_range(addr, size)
-extern int kernel_set_to_readonly;
-void set_kernel_text_rw(void);
-void set_kernel_text_ro(void);
-
#endif /* _ASM_X86_CACHEFLUSH_H */
diff --git a/arch/x86/include/asm/set_memory.h b/arch/x86/include/asm/set_memory.h
new file mode 100644
index 0000000..eaec6c3
--- /dev/null
+++ b/arch/x86/include/asm/set_memory.h
@@ -0,0 +1,87 @@
+#ifndef _ASM_X86_SET_MEMORY_H
+#define _ASM_X86_SET_MEMORY_H
+
+#include <asm/page.h>
+#include <asm-generic/set_memory.h>
+
+/*
+ * The set_memory_* API can be used to change various attributes of a virtual
+ * address range. The attributes include:
+ * Cachability : UnCached, WriteCombining, WriteThrough, WriteBack
+ * Executability : eXeutable, NoteXecutable
+ * Read/Write : ReadOnly, ReadWrite
+ * Presence : NotPresent
+ *
+ * Within a category, the attributes are mutually exclusive.
+ *
+ * The implementation of this API will take care of various aspects that
+ * are associated with changing such attributes, such as:
+ * - Flushing TLBs
+ * - Flushing CPU caches
+ * - Making sure aliases of the memory behind the mapping don't violate
+ * coherency rules as defined by the CPU in the system.
+ *
+ * What this API does not do:
+ * - Provide exclusion between various callers - including callers that
+ * operation on other mappings of the same physical page
+ * - Restore default attributes when a page is freed
+ * - Guarantee that mappings other than the requested one are
+ * in any state, other than that these do not violate rules for
+ * the CPU you have. Do not depend on any effects on other mappings,
+ * CPUs other than the one you have may have more relaxed rules.
+ * The caller is required to take care of these.
+ */
+
+int _set_memory_uc(unsigned long addr, int numpages);
+int _set_memory_wc(unsigned long addr, int numpages);
+int _set_memory_wt(unsigned long addr, int numpages);
+int _set_memory_wb(unsigned long addr, int numpages);
+int set_memory_uc(unsigned long addr, int numpages);
+int set_memory_wc(unsigned long addr, int numpages);
+int set_memory_wt(unsigned long addr, int numpages);
+int set_memory_wb(unsigned long addr, int numpages);
+int set_memory_np(unsigned long addr, int numpages);
+int set_memory_4k(unsigned long addr, int numpages);
+
+int set_memory_array_uc(unsigned long *addr, int addrinarray);
+int set_memory_array_wc(unsigned long *addr, int addrinarray);
+int set_memory_array_wt(unsigned long *addr, int addrinarray);
+int set_memory_array_wb(unsigned long *addr, int addrinarray);
+
+int set_pages_array_uc(struct page **pages, int addrinarray);
+int set_pages_array_wc(struct page **pages, int addrinarray);
+int set_pages_array_wt(struct page **pages, int addrinarray);
+int set_pages_array_wb(struct page **pages, int addrinarray);
+
+/*
+ * For legacy compatibility with the old APIs, a few functions
+ * are provided that work on a "struct page".
+ * These functions operate ONLY on the 1:1 kernel mapping of the
+ * memory that the struct page represents, and internally just
+ * call the set_memory_* function. See the description of the
+ * set_memory_* function for more details on conventions.
+ *
+ * These APIs should be considered *deprecated* and are likely going to
+ * be removed in the future.
+ * The reason for this is the implicit operation on the 1:1 mapping only,
+ * making this not a generally useful API.
+ *
+ * Specifically, many users of the old APIs had a virtual address,
+ * called virt_to_page() or vmalloc_to_page() on that address to
+ * get a struct page* that the old API required.
+ * To convert these cases, use set_memory_*() on the original
+ * virtual address, do not use these functions.
+ */
+
+int set_pages_uc(struct page *page, int numpages);
+int set_pages_wb(struct page *page, int numpages);
+int set_pages_x(struct page *page, int numpages);
+int set_pages_nx(struct page *page, int numpages);
+int set_pages_ro(struct page *page, int numpages);
+int set_pages_rw(struct page *page, int numpages);
+
+extern int kernel_set_to_readonly;
+void set_kernel_text_rw(void);
+void set_kernel_text_ro(void);
+
+#endif /* _ASM_X86_SET_MEMORY_H */
diff --git a/include/asm-generic/set_memory.h b/include/asm-generic/set_memory.h
new file mode 100644
index 0000000..83e81f8
--- /dev/null
+++ b/include/asm-generic/set_memory.h
@@ -0,0 +1,12 @@
+#ifndef __ASM_SET_MEMORY_H
+#define __ASM_SET_MEMORY_H
+
+/*
+ * Functions to change memory attributes.
+ */
+int set_memory_ro(unsigned long addr, int numpages);
+int set_memory_rw(unsigned long addr, int numpages);
+int set_memory_x(unsigned long addr, int numpages);
+int set_memory_nx(unsigned long addr, int numpages);
+
+#endif
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Russell King - ARM Linux <linux@armlinux.org.uk> |
|---|---|
| Date | 2017-03-02 13:30 +0100 |
| Subject | Re: [PATCHv2 01/14] treewide: Move set_memory_* functions away from cacheflush.h |
| Message-ID | <tgy1Q-2cX-19@gated-at.bofh.it> |
| In reply to | #1590806 |
On Wed, Mar 01, 2017 at 04:14:53PM -0800, Laura Abbott wrote:
> diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
> index 02454fa..1cb9d11 100644
> --- a/arch/arm/include/asm/cacheflush.h
> +++ b/arch/arm/include/asm/cacheflush.h
> @@ -16,6 +16,7 @@
> #include <asm/shmparam.h>
> #include <asm/cachetype.h>
> #include <asm/outercache.h>
> +#include <asm/set_memory.h>
>
> #define CACHE_COLOUR(vaddr) ((vaddr & (SHMLBA - 1)) >> PAGE_SHIFT)
>
> @@ -478,26 +479,6 @@ static inline void __sync_cache_range_r(volatile void *p, size_t size)
> : : : "r0","r1","r2","r3","r4","r5","r6","r7", \
> "r9","r10","lr","memory" )
>
> -#ifdef CONFIG_MMU
> -int set_memory_ro(unsigned long addr, int numpages);
> -int set_memory_rw(unsigned long addr, int numpages);
> -int set_memory_x(unsigned long addr, int numpages);
> -int set_memory_nx(unsigned long addr, int numpages);
> -#else
> -static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; }
> -static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; }
> -static inline int set_memory_x(unsigned long addr, int numpages) { return 0; }
> -static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; }
> -#endif
> -
> -#ifdef CONFIG_STRICT_KERNEL_RWX
> -void set_kernel_text_rw(void);
> -void set_kernel_text_ro(void);
> -#else
> -static inline void set_kernel_text_rw(void) { }
> -static inline void set_kernel_text_ro(void) { }
> -#endif
> -
> void flush_uprobe_xol_access(struct page *page, unsigned long uaddr,
> void *kaddr, unsigned long len);
>
> diff --git a/arch/arm/include/asm/set_memory.h b/arch/arm/include/asm/set_memory.h
> new file mode 100644
> index 0000000..5aa4315
> --- /dev/null
> +++ b/arch/arm/include/asm/set_memory.h
> @@ -0,0 +1,32 @@
> +/*
> + * Copyright (C) 1999-2002 Russell King
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef _ASMARM_SET_MEMORY_H
> +#define _ASMARM_SET_MEMORY_H
> +
> +#ifdef CONFIG_MMU
> +int set_memory_ro(unsigned long addr, int numpages);
> +int set_memory_rw(unsigned long addr, int numpages);
> +int set_memory_x(unsigned long addr, int numpages);
> +int set_memory_nx(unsigned long addr, int numpages);
> +#else
> +static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; }
> +static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; }
> +static inline int set_memory_x(unsigned long addr, int numpages) { return 0; }
> +static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; }
> +#endif
> +
> +#ifdef CONFIG_STRICT_KERNEL_RWX
> +void set_kernel_text_rw(void);
> +void set_kernel_text_ro(void);
> +#else
> +static inline void set_kernel_text_rw(void) { }
> +static inline void set_kernel_text_ro(void) { }
> +#endif
> +
> +#endif
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
Thanks.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
[toc] | [prev] | [next] | [standalone]
| From | Mark Rutland <mark.rutland@arm.com> |
|---|---|
| Date | 2017-03-02 16:30 +0100 |
| Subject | Re: [PATCHv2 01/14] treewide: Move set_memory_* functions away from cacheflush.h |
| Message-ID | <tgAQ1-4iq-7@gated-at.bofh.it> |
| In reply to | #1590806 |
On Wed, Mar 01, 2017 at 04:14:53PM -0800, Laura Abbott wrote:
> diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
> index a12f1af..e419965 100644
> --- a/arch/arm64/include/asm/Kbuild
> +++ b/arch/arm64/include/asm/Kbuild
> @@ -27,6 +27,7 @@ generic-y += preempt.h
> generic-y += resource.h
> generic-y += rwsem.h
> generic-y += segment.h
> +generic-y += set_memory.h
> generic-y += sembuf.h
> generic-y += serial.h
Nit: alphabetical order, please.
> generic-y += shmbuf.h
> diff --git a/arch/arm64/include/asm/cacheflush.h b/arch/arm64/include/asm/cacheflush.h
> index 5a2a6ee..7db6962 100644
> --- a/arch/arm64/include/asm/cacheflush.h
> +++ b/arch/arm64/include/asm/cacheflush.h
> @@ -20,6 +20,7 @@
> #define __ASM_CACHEFLUSH_H
>
> #include <linux/mm.h>
> +#include <asm/set_memory.h>
>
> /*
> * This flag is used to indicate that the page pointed to by a pte is clean
> @@ -150,9 +151,4 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end)
> {
> }
>
> -int set_memory_ro(unsigned long addr, int numpages);
> -int set_memory_rw(unsigned long addr, int numpages);
> -int set_memory_x(unsigned long addr, int numpages);
> -int set_memory_nx(unsigned long addr, int numpages);
> -
> #endif
> diff --git a/include/asm-generic/set_memory.h b/include/asm-generic/set_memory.h
> new file mode 100644
> index 0000000..83e81f8
> --- /dev/null
> +++ b/include/asm-generic/set_memory.h
> @@ -0,0 +1,12 @@
> +#ifndef __ASM_SET_MEMORY_H
> +#define __ASM_SET_MEMORY_H
> +
> +/*
> + * Functions to change memory attributes.
> + */
> +int set_memory_ro(unsigned long addr, int numpages);
> +int set_memory_rw(unsigned long addr, int numpages);
> +int set_memory_x(unsigned long addr, int numpages);
> +int set_memory_nx(unsigned long addr, int numpages);
> +
> +#endif
Otherwise, this looks fine to me. FWIW:
Acked-by: Mark Rutland <mark.rutland@arm.com>
Thanks,
Mark.
[toc] | [prev] | [next] | [standalone]
| From | Laura Abbott <labbott@redhat.com> |
|---|---|
| Date | 2017-03-02 08:30 +0100 |
| Subject | [PATCHv2 08/14] intel_th: Use set_memory.h header |
| Message-ID | <tgtlv-7kX-3@gated-at.bofh.it> |
| In reply to | #1590766 |
set_memory_* functions have moved to set_memory.h. Switch to this explicitly. Signed-off-by: Laura Abbott <labbott@redhat.com> --- drivers/hwtracing/intel_th/msu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c index e88afe1..f0e36c8 100644 --- a/drivers/hwtracing/intel_th/msu.c +++ b/drivers/hwtracing/intel_th/msu.c @@ -27,7 +27,7 @@ #include <linux/io.h> #include <linux/dma-mapping.h> -#include <asm/cacheflush.h> +#include <asm/set_memory.h> #include "intel_th.h" #include "msu.h" -- 2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Alexander Shishkin <alexander.shishkin@linux.intel.com> |
|---|---|
| Date | 2017-03-02 12:10 +0100 |
| Subject | Re: [PATCHv2 08/14] intel_th: Use set_memory.h header |
| Message-ID | <tgwMp-1oY-13@gated-at.bofh.it> |
| In reply to | #1590893 |
Laura Abbott <labbott@redhat.com> writes: > set_memory_* functions have moved to set_memory.h. Switch to this > explicitly. > > Signed-off-by: Laura Abbott <labbott@redhat.com> Acked-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Thanks, -- Alex
[toc] | [prev] | [next] | [standalone]
| From | Heiko Carstens <heiko.carstens@de.ibm.com> |
|---|---|
| Date | 2017-03-02 14:10 +0100 |
| Message-ID | <tgyEy-2Jl-15@gated-at.bofh.it> |
| In reply to | #1590766 |
On Wed, Mar 01, 2017 at 04:14:52PM -0800, Laura Abbott wrote: > Hi, > > This is v2 of my proposal to move set_memory_* function prototypes out of > cacheflush.h and into their own header file. This came out of a comment > Russell made while reviewing RODATA test cases > http://lists.infradead.org/pipermail/linux-arm-kernel/2017-January/480855.html > While the final result of that series was the rodata code was refactored into > its own header file, the set_memory_* APIs are still out of place. > > This version refactored the common set_memory_* functions into an asm-generic > header. s390x added some features so it can't just use the asm-generic header. > I debated how much more to try and shove into the asm-generic version (e.g. > stub prototypes for the ARM nommu case, set_kernel_text_*) but decided to stick > with just the basics for this version. > > I split out the cacheflush.h -> set_memory.h conversions into separate patches > to hopefully make merging easier. Worst case, the final patch to completely > separate the two can be delayed if there are more problems found. I'd like > for this to eventually go through the -mm tree so I'd like Acks where > appropriate. > > As always, feedback appreciated. For the s390 bits: Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web