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]
Message-Id: <1331617001-20906-4-git-send-email-apenwarr@gmail.com>
Date:	Tue, 13 Mar 2012 01:36:39 -0400
From:	Avery Pennarun <apenwarr@...il.com>
To:	Andrew Morton <akpm@...ux-foundation.org>,
	Josh Triplett <josh@...htriplett.org>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	Ingo Molnar <mingo@...e.hu>,
	"David S. Miller" <davem@...emloft.net>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	"Fabio M. Di Nitto" <fdinitto@...hat.com>,
	Avery Pennarun <apenwarr@...il.com>,
	Johannes Weiner <hannes@...xchg.org>,
	Olaf Hering <olaf@...fle.de>,
	Paul Gortmaker <paul.gortmaker@...driver.com>,
	Tejun Heo <tj@...nel.org>,
	"H. Peter Anvin" <hpa@...ux.intel.com>,
	Yinghai LU <yinghai@...nel.org>, linux-kernel@...r.kernel.org,
	linux-mm@...ck.org
Subject: [PATCH 3/5] mm: nobootmem: implement reserve_bootmem() in terms of memblock.

There was an implementation for it in mm/bootmem.c, but it was left out of
nobootmem.c, and we can easily write a memblock implementation.  That way
code (eg.  printk) that wants to reserve memory early on can just always
call bootmem on all platforms.

Signed-off-by: Avery Pennarun <apenwarr@...il.com>
---
 mm/nobootmem.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 24f0fc1..2c269da 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -193,6 +193,29 @@ void __init free_bootmem(unsigned long addr, unsigned long size)
 	memblock_free(addr, size);
 }
 
+/**
+ * reserve_bootmem - mark a page range as reserved
+ * @addr: starting address of the range
+ * @size: size of the range in bytes
+ * @flags: reservation flags (see linux/bootmem.h)
+ *
+ * Partial pages will be reserved.
+ *
+ * The range must be contiguous but may span node boundaries.
+ */
+int __init reserve_bootmem(unsigned long addr, unsigned long size,
+			    int flags)
+{
+	if (flags & BOOTMEM_EXCLUSIVE) {
+		phys_addr_t m = memblock_find_in_range(addr, addr + size,
+					size, PAGE_SIZE);
+		if (m != addr)
+			return -EBUSY;
+	}
+	memblock_reserve(addr, size);
+	return 0;
+}
+
 static void * __init ___alloc_bootmem_nopanic(unsigned long size,
 					unsigned long align,
 					unsigned long goal,
-- 
1.7.7.3

--
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