Skip to contentSkip to conversation

remove various unused set_memory_* related functions and exports v2

PATCH Applied Christoph Hellwig 2 participants 10 messages Aug 26, 2019 – Sep 3, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

while looking into implementing a DMA memory allocator for PCIe unsnooped transactions I've started looking at the set_memory_* and related APIs, and it turns out that many of them are unused. Fix for that below.

Changes since v2:
- dropped the already merged arm64 patch
- fix a subject line to not mention the wrong functions

#1 lore raw

PATCH 1/5 x86: unexport set_memory_x and set_memory_nx

No module currently messed with clearing or setting the execute permission of kernel memory, and none really should.

---
 arch/x86/mm/pageattr.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/mm/pageattr.c +0 -2
index 6a9a77a403c9..a02ca8986299 100644
@@ -1967,7 +1967,6 @@ int set_memory_x(unsigned long addr, int numpages)
 
 	return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_NX), 0);
 }
-EXPORT_SYMBOL(set_memory_x);
 
 int set_memory_nx(unsigned long addr, int numpages)
 {
@@ -1976,7 +1975,6 @@ int set_memory_nx(unsigned long addr, int numpages)
 
 	return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_NX), 0);
 }
-EXPORT_SYMBOL(set_memory_nx);
 
 int set_memory_ro(unsigned long addr, int numpages)
 {
Signature · 1 line
2.20.1
#2 lore raw

[tip: x86/mm] x86/mm: Unexport set_memory_x() and set_memory_nx()

The following commit has been merged into the x86/mm branch of tip:

The following commit has been merged into the x86/mm branch of tip:

Commit-ID:     ec46133d3b81053701e2a29047dfb6228ff487bd
Gitweb:        https://git.kernel.org/tip/ec46133d3b81053701e2a29047dfb6228ff487bd
Author:        Christoph Hellwig <[email protected]>
AuthorDate:    Mon, 26 Aug 2019 09:55:54 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 03 Sep 2019 09:26:37 +02:00

x86/mm: Unexport set_memory_x() and set_memory_nx()

No module currently messed with clearing or setting the execute permission of kernel memory, and none really should.

---
 arch/x86/mm/pageattr.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/mm/pageattr.c +0 -2
index e14e95e..08a6f04 100644
@@ -1977,7 +1977,6 @@ int set_memory_x(unsigned long addr, int numpages)
 
 	return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_NX), 0);
 }
-EXPORT_SYMBOL(set_memory_x);
 
 int set_memory_nx(unsigned long addr, int numpages)
 {
@@ -1986,7 +1985,6 @@ int set_memory_nx(unsigned long addr, int numpages)
 
 	return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_NX), 0);
 }
-EXPORT_SYMBOL(set_memory_nx);
 
 int set_memory_ro(unsigned long addr, int numpages)
 {
#3 lore raw

PATCH 2/5 x86: remove the unused set_memory_array_* functions

In reply to Christoph Hellwig
---
 arch/x86/include/asm/set_memory.h |  5 ---
 arch/x86/mm/pageattr.c            | 75 -------------------------------
 2 files changed, 80 deletions(-)
arch/x86/include/asm/set_memory.h +0 -5
index ae7b909dc242..899ec9ae7cff 100644
@@ -48,11 +48,6 @@ int set_memory_encrypted(unsigned long addr, int numpages);
 int set_memory_decrypted(unsigned long addr, int numpages);
 int set_memory_np_noalias(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);
arch/x86/mm/pageattr.c +0 -75

87 lines not on this page · raw message

Signature · 1 line
2.20.1
#4 lore raw

[tip: x86/mm] x86/mm: Remove the unused set_memory_array_*() functions

The following commit has been merged into the x86/mm branch of tip:

The following commit has been merged into the x86/mm branch of tip:

Commit-ID:     a919198b97c85e093c81eaae0b4864206ec2fe02
Gitweb:        https://git.kernel.org/tip/a919198b97c85e093c81eaae0b4864206ec2fe02
Author:        Christoph Hellwig <[email protected]>
AuthorDate:    Mon, 26 Aug 2019 09:55:55 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 03 Sep 2019 09:26:37 +02:00

x86/mm: Remove the unused set_memory_array_*() functions

---
 arch/x86/include/asm/set_memory.h |  5 +--
 arch/x86/mm/pageattr.c            | 75 +------------------------------
 2 files changed, 80 deletions(-)
arch/x86/include/asm/set_memory.h +0 -5
index ae7b909..899ec9a 100644
@@ -48,11 +48,6 @@ int set_memory_encrypted(unsigned long addr, int numpages);
 int set_memory_decrypted(unsigned long addr, int numpages);
 int set_memory_np_noalias(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);
arch/x86/mm/pageattr.c +0 -75

87 lines not on this page · raw message

#5 lore raw

PATCH 3/5 x86: remove set_pages_x and set_pages_nx

In reply to Christoph Hellwig

These wrappers don't provide a real benefit over just using set_memory_x and set_memory_nx.

---
 arch/x86/include/asm/set_memory.h  |  2 --
 arch/x86/kernel/machine_kexec_32.c |  4 ++--
 arch/x86/mm/init_32.c              |  2 +-
 arch/x86/mm/pageattr.c             | 16 ----------------
 4 files changed, 3 insertions(+), 21 deletions(-)
arch/x86/include/asm/set_memory.h +0 -2
index 899ec9ae7cff..fd549c3ebb17 100644
@@ -75,8 +75,6 @@ int set_pages_array_wb(struct page **pages, int addrinarray);
 
 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);
 
arch/x86/kernel/machine_kexec_32.c +2 -2
index 77854b192fef..7b45e8daad22 100644
@@ -148,7 +148,7 @@ int machine_kexec_prepare(struct kimage *image)
 {
 	int error;
 
-	set_pages_x(image->control_code_page, 1);
+	set_memory_x((unsigned long)page_address(image->control_code_page), 1);
 	error = machine_kexec_alloc_page_tables(image);
 	if (error)
 		return error;
@@ -162,7 +162,7 @@ int machine_kexec_prepare(struct kimage *image)
  */
 void machine_kexec_cleanup(struct kimage *image)
 {
-	set_pages_nx(image->control_code_page, 1);
+	set_memory_nx((unsigned long)page_address(image->control_code_page), 1);
 	machine_kexec_free_page_tables(image);
 }
 
arch/x86/mm/init_32.c +1 -1
index 4068abb9427f..930edeb41ec3 100644
@@ -916,7 +916,7 @@ static void mark_nxdata_nx(void)
 
 	if (__supported_pte_mask & _PAGE_NX)
 		printk(KERN_INFO "NX-protecting the kernel data: %luk\n", size >> 10);
-	set_pages_nx(virt_to_page(start), size >> PAGE_SHIFT);
+	set_memory_nx(start, size >> PAGE_SHIFT);
 }
 
 void mark_rodata_ro(void)
arch/x86/mm/pageattr.c +0 -16
index 3be5d22c005a..0e39b344556d 100644
@@ -2103,22 +2103,6 @@ int set_pages_array_wb(struct page **pages, int numpages)
 }
 EXPORT_SYMBOL(set_pages_array_wb);
 
-int set_pages_x(struct page *page, int numpages)
-{
-	unsigned long addr = (unsigned long)page_address(page);
-
-	return set_memory_x(addr, numpages);
-}
-EXPORT_SYMBOL(set_pages_x);
-
-int set_pages_nx(struct page *page, int numpages)
-{
-	unsigned long addr = (unsigned long)page_address(page);
-
-	return set_memory_nx(addr, numpages);
-}
-EXPORT_SYMBOL(set_pages_nx);
-
 int set_pages_ro(struct page *page, int numpages)
 {
 	unsigned long addr = (unsigned long)page_address(page);
Signature · 1 line
2.20.1
#6 lore raw

[tip: x86/mm] x86/mm: Remove set_pages_x() and set_pages_nx()

The following commit has been merged into the x86/mm branch of tip:

The following commit has been merged into the x86/mm branch of tip:

Commit-ID:     185be15143aa308184310df9fde3d409ca9f83bb
Gitweb:        https://git.kernel.org/tip/185be15143aa308184310df9fde3d409ca9f83bb
Author:        Christoph Hellwig <[email protected]>
AuthorDate:    Mon, 26 Aug 2019 09:55:56 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 03 Sep 2019 09:26:37 +02:00

x86/mm: Remove set_pages_x() and set_pages_nx()

These wrappers don't provide a real benefit over just using set_memory_x() and set_memory_nx().

---
 arch/x86/include/asm/set_memory.h  |  2 --
 arch/x86/kernel/machine_kexec_32.c |  4 ++--
 arch/x86/mm/init_32.c              |  2 +-
 arch/x86/mm/pageattr.c             | 16 ----------------
 4 files changed, 3 insertions(+), 21 deletions(-)
arch/x86/include/asm/set_memory.h +0 -2
index 899ec9a..fd549c3 100644
@@ -75,8 +75,6 @@ int set_pages_array_wb(struct page **pages, int addrinarray);
 
 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);
 
arch/x86/kernel/machine_kexec_32.c +2 -2
index 77854b1..7b45e8d 100644
@@ -148,7 +148,7 @@ int machine_kexec_prepare(struct kimage *image)
 {
 	int error;
 
-	set_pages_x(image->control_code_page, 1);
+	set_memory_x((unsigned long)page_address(image->control_code_page), 1);
 	error = machine_kexec_alloc_page_tables(image);
 	if (error)
 		return error;
@@ -162,7 +162,7 @@ int machine_kexec_prepare(struct kimage *image)
  */
 void machine_kexec_cleanup(struct kimage *image)
 {
-	set_pages_nx(image->control_code_page, 1);
+	set_memory_nx((unsigned long)page_address(image->control_code_page), 1);
 	machine_kexec_free_page_tables(image);
 }
 
arch/x86/mm/init_32.c +1 -1
index 4068abb..930edeb 100644
@@ -916,7 +916,7 @@ static void mark_nxdata_nx(void)
 
 	if (__supported_pte_mask & _PAGE_NX)
 		printk(KERN_INFO "NX-protecting the kernel data: %luk\n", size >> 10);
-	set_pages_nx(virt_to_page(start), size >> PAGE_SHIFT);
+	set_memory_nx(start, size >> PAGE_SHIFT);
 }
 
 void mark_rodata_ro(void)
arch/x86/mm/pageattr.c +0 -16
index 1f97a72..d5586a0 100644
@@ -2113,22 +2113,6 @@ int set_pages_array_wb(struct page **pages, int numpages)
 }
 EXPORT_SYMBOL(set_pages_array_wb);
 
-int set_pages_x(struct page *page, int numpages)
-{
-	unsigned long addr = (unsigned long)page_address(page);
-
-	return set_memory_x(addr, numpages);
-}
-EXPORT_SYMBOL(set_pages_x);
-
-int set_pages_nx(struct page *page, int numpages)
-{
-	unsigned long addr = (unsigned long)page_address(page);
-
-	return set_memory_nx(addr, numpages);
-}
-EXPORT_SYMBOL(set_pages_nx);
-
 int set_pages_ro(struct page *page, int numpages)
 {
 	unsigned long addr = (unsigned long)page_address(page);
#7 lore raw

PATCH 4/5 x86: remove the unused set_memory_wt function

In reply to Christoph Hellwig
---
 arch/x86/include/asm/set_memory.h |  1 -
 arch/x86/mm/pageattr.c            | 17 -----------------
 2 files changed, 18 deletions(-)
arch/x86/include/asm/set_memory.h +0 -1
index fd549c3ebb17..2ee8e469dcf5 100644
@@ -40,7 +40,6 @@ 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);
arch/x86/mm/pageattr.c +0 -17
index 0e39b344556d..9acd568c4faa 100644
@@ -1848,23 +1848,6 @@ int _set_memory_wt(unsigned long addr, int numpages)
 				    cachemode2pgprot(_PAGE_CACHE_MODE_WT), 0);
 }
 
-int set_memory_wt(unsigned long addr, int numpages)
-{
-	int ret;
-
-	ret = reserve_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE,
-			      _PAGE_CACHE_MODE_WT, NULL);
-	if (ret)
-		return ret;
-
-	ret = _set_memory_wt(addr, numpages);
-	if (ret)
-		free_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(set_memory_wt);
-
 int _set_memory_wb(unsigned long addr, int numpages)
 {
 	/* WB cache mode is hard wired to all cache attribute bits being 0 */
Signature · 1 line
2.20.1
#8 lore raw

[tip: x86/mm] x86/mm: Remove the unused set_memory_wt() function

The following commit has been merged into the x86/mm branch of tip:

The following commit has been merged into the x86/mm branch of tip:

Commit-ID:     aeb415fbe9f62e6db0fabd2023d39728ccc705fd
Gitweb:        https://git.kernel.org/tip/aeb415fbe9f62e6db0fabd2023d39728ccc705fd
Author:        Christoph Hellwig <[email protected]>
AuthorDate:    Mon, 26 Aug 2019 09:55:57 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 03 Sep 2019 09:26:37 +02:00

x86/mm: Remove the unused set_memory_wt() function

---
 arch/x86/include/asm/set_memory.h |  1 -
 arch/x86/mm/pageattr.c            | 17 -----------------
 2 files changed, 18 deletions(-)
arch/x86/include/asm/set_memory.h +0 -1
index fd549c3..2ee8e46 100644
@@ -40,7 +40,6 @@ 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);
arch/x86/mm/pageattr.c +0 -17
index d5586a0..0d09cc5 100644
@@ -1858,23 +1858,6 @@ int _set_memory_wt(unsigned long addr, int numpages)
 				    cachemode2pgprot(_PAGE_CACHE_MODE_WT), 0);
 }
 
-int set_memory_wt(unsigned long addr, int numpages)
-{
-	int ret;
-
-	ret = reserve_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE,
-			      _PAGE_CACHE_MODE_WT, NULL);
-	if (ret)
-		return ret;
-
-	ret = _set_memory_wt(addr, numpages);
-	if (ret)
-		free_memtype(__pa(addr), __pa(addr) + numpages * PAGE_SIZE);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(set_memory_wt);
-
 int _set_memory_wb(unsigned long addr, int numpages)
 {
 	/* WB cache mode is hard wired to all cache attribute bits being 0 */
#9 lore raw

PATCH 5/5 x86: remove the unused set_pages_array_wt function

In reply to Christoph Hellwig
---
 arch/x86/include/asm/set_memory.h | 1 -
 arch/x86/mm/pageattr.c            | 6 ------
 2 files changed, 7 deletions(-)
arch/x86/include/asm/set_memory.h +0 -1
index 2ee8e469dcf5..cff5e07c1e19 100644
@@ -49,7 +49,6 @@ int set_memory_np_noalias(unsigned long addr, int numpages);
 
 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);
 
 /*
arch/x86/mm/pageattr.c +0 -6
index 9acd568c4faa..255c90d6aaa7 100644
@@ -2047,12 +2047,6 @@ int set_pages_array_wc(struct page **pages, int numpages)
 }
 EXPORT_SYMBOL(set_pages_array_wc);
 
-int set_pages_array_wt(struct page **pages, int numpages)
-{
-	return _set_pages_array(pages, numpages, _PAGE_CACHE_MODE_WT);
-}
-EXPORT_SYMBOL_GPL(set_pages_array_wt);
-
 int set_pages_wb(struct page *page, int numpages)
 {
 	unsigned long addr = (unsigned long)page_address(page);
Signature · 1 line
2.20.1