david/ipxe
david
/
ipxe
Archived
1
0
Fork 0
Commit Graph

42 Commits

Author SHA1 Message Date
Michael Brown 42eedb04c1 [malloc] Avoid false positive warnings from valgrind
Calling discard_cache() is likely to result in a call to
free_memblock(), which will call valgrind_make_blocks_noaccess()
before returning.  This causes valgrind to report an invalid read on
the next iteration through the loop in alloc_memblock().

Fix by explicitly calling valgrind_make_blocks_defined() after
discard_cache() returns.  Also call valgrind_make_blocks_noaccess()
before calling discard_cache(), to guard against free list corruption
while executing cache discarders.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-09-04 14:09:17 +01:00
Michael Brown c90b4d82b7 [malloc] Track maximum heap usage
Track the current and maximum heap usage, and display the maximum
during shutdown when DEBUG=malloc is enabled.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2017-03-22 20:01:25 +02:00
Michael Brown e2b1140486 [malloc] Guard against unsigned integer overflow
Commit f3fbb5f ("[malloc] Avoid integer overflow for excessively large
memory allocations") fixed signed integer overflow issues caused by
the use of ssize_t, but did not guard against unsigned integer
overflow.

Add explicit checks for unsigned integer overflow where needed.  As a
side bonus, erroneous calls to malloc_dma() with an (illegal) size of
zero will now fail cleanly.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2016-02-06 10:47:45 +00:00
Michael Brown f3fbb5ff1c [malloc] Avoid integer overflow for excessively large memory allocations
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-29 01:07:08 +01:00
Michael Brown b2f38da888 [malloc] Rewrite unrelicensable portions of malloc.c
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-03-03 15:24:15 +00:00
Michael Brown 35c5379760 [malloc] Report caller address as soon as memory corruption is detected
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-15 14:48:02 +00:00
Michael Brown 7871666740 [malloc] Check integrity of free list
Check the integrity of the free memory block list before and after any
modifications to the list.  We check that certain invariants are
preserved:

 - the list is a well-formed doubly linked list

 - all blocks are at least MIN_MEMBLOCK_SIZE

 - no block extends beyond the end of our address space

 - blocks remain sorted in ascending order of address

 - no blocks are adjacent (i.e. any adjacent blocks have been merged)

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-15 14:45:05 +00:00
Michael Brown 9154f2aef3 [malloc] Sanity check parameters to alloc_memblock() and free_memblock()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-15 14:42:26 +00:00
Michael Brown 998e69ae14 [malloc] Tidy up debug output
Colourise debug output and move per-allocation messages to DBGLVL_EXTRA.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2014-12-15 14:39:55 +00:00
Michael Brown e2becce186 [malloc] Allow allocation of memory with a specified alignment offset
Allow for allocation of memory blocks having a specified offset from a
specified physical alignment, such as being 12 bytes before a 2kB
boundary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-08-31 21:22:45 +01:00
Michael Brown c3b4860ce3 [legal] Update FSF mailing address in GPL licence texts
Suggested-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-20 19:55:45 +01:00
Michael Brown 6825b2e7bf [malloc] Increase heap size to 512kB
The maximum TCP throughput is fundamentally limited by the amount of
available receive buffer space.  Increase the heap size from 128kB to
512kB to allow the use of larger TCP windows.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-09 10:13:47 +01:00
Michael Brown 8d95e1d6ff [malloc] Discard cached items less aggressively
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-07-09 10:08:37 +01:00
Michael Brown 6f3e7e90fc [malloc] Allow Valgrind to be used when all assertions are enabled
The free-memory-block traversal code triggers multiple warnings from
Valgrind when assertions are enabled, since the list consistency
checks performed by list_check() end up accessing areas that have been
marked as inaccessible.

Fix by ensuring that any memory areas that will be accessed by
list_check() are marked as defined when necessary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-04 17:16:35 +01:00
Michael Brown df2773193e [malloc] Discard all cached data on shutdown
Allow detection of genuine memory leaks by ensuring that all cached
data is freed on shutdown.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2012-05-04 15:15:34 +01:00
Piotr Jaroszyński b604e8a388 [linux] Make malloc and linux_umalloc valgrindable
Make the allocators used by malloc and linux_umalloc valgrindable.
Include valgrind headers in the codebase to avoid a build dependency
on valgrind.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2011-03-27 21:03:05 +01:00
Michael Brown 13e4b9ec49 [malloc] Avoid immediately clobbering reference count when freeing memory
Rearrange the fields in struct memory_block (without altering
MIN_MEMBLOCK_SIZE) so that the "count" field of a reference-counted
object is left intact when the memory containing the object is freed.
This allows for the possibility of detecting reference-counting errors
such as double-freeing.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-08 03:35:35 +00:00
Michael Brown fc69ab94d9 [malloc] Use list_for_each_entry_safe() when we may delete a list entry
free_memblock() currently uses list_for_each_entry() to iterate over
the free list, and may delete an entry over which it iterates.  While
there is no way that the deleted list entry could be overwritten
before we reference it, this does rely upon list_del() leaving the
"next" pointer intact, which is not guaranteed.  Discovered while
tracking down a list-corruption bug (as a result of having modified
list_del() to sanitise the deleted list entry).

Fix by using list_for_each_entry_safe().

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-11-08 03:15:56 +00:00
Michael Brown 9dc51afa2c [malloc] Add cache discard mechanism
Add a facility allowing cached data to be discarded in order to
satisfy memory allocations that would otherwise fail.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-07-21 11:58:50 +01:00
Michael Brown 8406115834 [build] Rename gPXE to iPXE
Access to the gpxe.org and etherboot.org domains and associated
resources has been revoked by the registrant of the domain.  Work
around this problem by renaming project from gPXE to iPXE, and
updating URLs to match.

Also update README, LOG and COPYRIGHTS to remove obsolete information.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-04-19 23:43:39 +01:00
Michael Brown c44a193d0d [legal] Add a selection of FILE_LICENCE declarations
Add FILE_LICENCE declarations to almost all files that make up the
various standard builds of gPXE.
2009-05-18 08:33:25 +01:00
Michael Brown ee2df1d6d6 [ioapi] Remove old io.h file and switch all users over to <gpxe/io.h> 2008-10-12 01:06:27 +01:00
Holger Lubitz 7815474495 Revert "malloc attribute changes"
wasn't meant for my local "master" branch ;)
This reverts commit 373022108b.
2007-08-06 03:36:35 +02:00
Holger Lubitz 373022108b malloc attribute changes 2007-08-02 22:42:45 +02:00
Michael Brown 89349d7fad Separated out initialisation functions from startup/shutdown functions. 2007-07-03 23:09:56 +01:00
Michael Brown 058b200529 Renamed _calloc() to zalloc(), ready to be used as a standalone function. 2007-06-11 21:36:10 +01:00
Michael Brown 73b09ecba6 Use stdio.h instead of vsprintf.h 2007-01-19 01:13:12 +00:00
Michael Brown 6d4e37cf42 Move include/malloc.h to include/gpxe/malloc.h, since everything in there
is now gPXE-specific.  (The standard malloc() et al have been in stdlib.h
for a while).

Add free memory counter.
2007-01-18 20:11:04 +00:00
Michael Brown 35776f481c Don't always zero memory in malloc(). This saves around 2us on a
full-length PKB allocation.
2007-01-18 12:54:18 +00:00
Michael Brown 6c894c2a2e Fix typo 2007-01-12 01:37:38 +00:00
Michael Brown c4677c7e73 Implemented realloc(), and changed the semantics of malloc(0) to allow
for realloc(0) being a valid way to free memory.
2006-11-24 16:51:18 +00:00
Michael Brown 88e38fa148 We don't actually have a stdio.h header file. Our printf() functions are
defined in vsprintf.h.  (This may change, since vsprintf.h is a
non-standard name, but for now it's the one to use.)

There should be no need to include vsprintf.h just for DBG() statements,
since include/compiler.h forces it in for a debug build anyway.
2006-09-27 10:58:14 +00:00
Marty Connor 1da4faa896 include stdio.h to suppress printf warning, general warnings fixups 2006-09-27 04:04:55 +00:00
Michael Brown 1dbafa8950 Tidied up debugging messages 2006-05-27 13:38:49 +00:00
Michael Brown 689218618f Fix typo 2006-05-16 14:42:43 +00:00
Michael Brown 51feeab445 Add an explicit failure debug message 2006-04-28 14:07:41 +00:00
Michael Brown cfae86f6c8 Glenn managed to shrink .text by 5 more bytes. 2006-04-25 21:48:16 +00:00
Michael Brown face774c4c Fixed erroneous comparison 2006-04-25 11:54:58 +00:00
Michael Brown 95f8a42930 Removed incorrect comment; malloc() is inefficient only when the
alignment and size are both powers of two, and there's no way to
specify an alignment through the malloc() interface anyway.
2006-04-25 10:41:49 +00:00
Michael Brown 4e92f29c9e Now passes trivial tests. free_memblock() needs neatening up. 2006-04-25 04:01:58 +00:00
Michael Brown b601a7d355 Updated memory allocator to improve support for unaligned or partially
aligned blocks.

Moved header to include/malloc.h, since we now also provide the
POSIX-like malloc()/free() pair.

Not yet tested.
2006-04-25 03:30:46 +00:00
Michael Brown b6b6a0b5fe First draft of a dynamic memory allocator 2006-04-24 15:21:18 +00:00