lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 16 Dec 2006 17:34:32 +0900
From:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc:	linux-kernel@...r.kernel.org, akpm@...l.org, clameter@...r.sgi.com,
	apw@...dowen.org, heiko.carstens@...ibm.com, bob.picco@...com
Subject: [PATCH][2.6.20-rc1-mm1] sparsemem vmem_map optimzed pfn_valid()
 [1/2] generic arch.

This patch is for implementing optimized pfn_valid() for sparsemem_vmemmap.
By this, we can avoid accessing mem_section[] in usual codes.
(memory hotplug will access it.)

This patch checks vmem_map is mapped or not by get_user().
If fault, pfn is not valid.

Because sparsemem_vmemmap's virtual mem_map per section is always aligned to
PAGE_SIZE, pfn_valid(pfn) can assume a whole struct page is fully mapped.
So it only access the first byte.

How to use:
 1. set ARCH_SPARSEMEM_VMEMMAP_OPT_PFNVALID config in arch/Kconfig
 2. modify page fault handler in each arch to handle fault in mem_map range.

Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>

 include/linux/mmzone.h |   10 ++++++++++
 mm/Kconfig             |    4 ++++
 mm/sparse.c            |    7 +++++++
 3 files changed, 21 insertions(+)

Index: devel-2.6.20-rc1-mm1/include/linux/mmzone.h
===================================================================
--- devel-2.6.20-rc1-mm1.orig/include/linux/mmzone.h	2006-12-16 13:48:52.000000000 +0900
+++ devel-2.6.20-rc1-mm1/include/linux/mmzone.h	2006-12-16 14:43:08.000000000 +0900
@@ -752,12 +752,22 @@
 	return __nr_to_section(pfn_to_section_nr(pfn));
 }
 
+#ifdef CONFIG_SPARSEMEM_VMEMMAP_OPT_PFNVALID
+extern int vmemmap_test_valid(struct page *pg);
+static inline int pfn_valid(unsigned long pfn)
+{
+	if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
+		return 0;
+	return vmemmap_test_valid(pfn_to_page(pfn));
+}
+#else
 static inline int pfn_valid(unsigned long pfn)
 {
 	if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
 		return 0;
 	return valid_section(__nr_to_section(pfn_to_section_nr(pfn)));
 }
+#endif
 
 /*
  * These are _only_ used during initialisation, therefore they
Index: devel-2.6.20-rc1-mm1/mm/Kconfig
===================================================================
--- devel-2.6.20-rc1-mm1.orig/mm/Kconfig	2006-12-16 13:48:53.000000000 +0900
+++ devel-2.6.20-rc1-mm1/mm/Kconfig	2006-12-16 13:52:06.000000000 +0900
@@ -125,6 +125,10 @@
 	def_bool y
 	depends on ARCH_SPARSEMEM_VMEMMAP_STATIC
 
+config SPARSEMEM_VMEMMAP_OPT_PFNVALID
+	def_bool y
+	depends on SPARSEMEM_VMEMMAP && ARCH_SPARSEMEM_VMEMMAP_OPT_PFN_VALID
+
 # eventually, we can have this option just 'select SPARSEMEM'
 config MEMORY_HOTPLUG
 	bool "Allow for memory hot-add"
Index: devel-2.6.20-rc1-mm1/mm/sparse.c
===================================================================
--- devel-2.6.20-rc1-mm1.orig/mm/sparse.c	2006-12-16 13:48:53.000000000 +0900
+++ devel-2.6.20-rc1-mm1/mm/sparse.c	2006-12-16 14:03:41.000000000 +0900
@@ -108,6 +108,13 @@
 	int nid;
 };
 
+int vmemmap_test_valid(struct page *pg)
+{
+	char byte;
+	/* vmemmap per section is always aligned to PAGE_SIZE */
+	return (__get_user(byte, (char __user *)pg) == 0);
+}
+
 /* call backs for memory map */
 static int
 __init pte_alloc_vmemmap_boot(pmd_t *pmd, unsigned long addr, void *data)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ