History log of /kvm-unit-tests/lib/alloc.c (Results 1 – 18 of 18)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: v2025-06-05, v2024-01-08, v2023-01-05, v2022-03-08
# 882825e6 14-Feb-2022 Andrew Jones <drjones@redhat.com>

Merge branch 'misc/queue' into 'master'

Misc fixes

See merge request kvm-unit-tests/kvm-unit-tests!24


# 10b721fb 03-Feb-2022 Andrew Jones <drjones@redhat.com>

arm64: Fix compiling with ancient compiler

When compiling with an ancient compiler (gcc-4.8.5-36.el7_6.2.aarch64)
the build fails with

lib/libcflat.a(alloc.o): In function `mult_overflow':
/hom

arm64: Fix compiling with ancient compiler

When compiling with an ancient compiler (gcc-4.8.5-36.el7_6.2.aarch64)
the build fails with

lib/libcflat.a(alloc.o): In function `mult_overflow':
/home/drjones/kvm-unit-tests/lib/alloc.c:19: undefined reference to `__multi3'

According to kernel commit fb8722735f50 ("arm64: support __int128 on
gcc 5+") gcc older than 5 will emit __multi3 for __int128 multiplication.
To fix this, let's just use check_mul_overflow(), which does overflow
checking with GCC7.1+ and nothing for older gcc. We lose the fallback
for older gcc, but oh, well, the heavily negative diffstat is just too
tempting to go for another solution.

While we're cleaning up lib/alloc.c with the function deletion also take
the opportunity to clean up the include style and add an SPDX header.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>

show more ...


# df362bf7 27-May-2021 Steffen Eiden <seiden@linux.ibm.com>

lib/alloc: remove double include

One bitops.h include should be enough.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Message-Id: <20210527124551.38299-1-seiden@linux.ibm.com>
Signed-off-by:

lib/alloc: remove double include

One bitops.h include should be enough.

Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Message-Id: <20210527124551.38299-1-seiden@linux.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# f90ddba3 02-Oct-2020 Claudio Imbrenda <imbrenda@linux.ibm.com>

lib/alloc: simplify free and malloc

Remove the size parameter from the various free functions

Since the backends can handle the allocation sizes on their own,
simplify the generic malloc wrappers.

lib/alloc: simplify free and malloc

Remove the size parameter from the various free functions

Since the backends can handle the allocation sizes on their own,
simplify the generic malloc wrappers.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Message-Id: <20201002154420.292134-6-imbrenda@linux.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 9e801bd9 06-Jul-2020 Claudio Imbrenda <imbrenda@linux.ibm.com>

lib/alloc_page: move get_order and is_power_of_2 to a bitops.h

The functions get_order and is_power_of_2 are simple and should
probably be in a header, like similar simple functions in bitops.h

Sin

lib/alloc_page: move get_order and is_power_of_2 to a bitops.h

The functions get_order and is_power_of_2 are simple and should
probably be in a header, like similar simple functions in bitops.h

Since they concern bit manipulation, the logical place for them is in
bitops.h

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Message-Id: <20200706164324.81123-4-imbrenda@linux.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# c88b7bea 23-Jun-2020 Paolo Bonzini <pbonzini@redhat.com>

lib/alloc.c: fix missing include

Include bitops.h to get BITS_PER_LONG and avoid errors such as

lib/alloc.c: In function mult_overflow:
lib/alloc.c:24:9: error: right shift count >= width of type
[

lib/alloc.c: fix missing include

Include bitops.h to get BITS_PER_LONG and avoid errors such as

lib/alloc.c: In function mult_overflow:
lib/alloc.c:24:9: error: right shift count >= width of type
[-Werror=shift-count-overflow]
24 | if ((a >> 32) && (b >> 32))
| ^~

Fixes: cde8415e1 ("lib/alloc.c: add overflow check for calloc")
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# cde8415e 22-Jun-2020 Claudio Imbrenda <imbrenda@linux.ibm.com>

lib/alloc.c: add overflow check for calloc

Add an overflow check for calloc to prevent potential multiplication overflow.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Message-Id: <20200

lib/alloc.c: add overflow check for calloc

Add an overflow check for calloc to prevent potential multiplication overflow.

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Message-Id: <20200622162141.279716-5-imbrenda@linux.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 9390b55b 04-Nov-2019 Janosch Frank <frankja@linux.ibm.com>

alloc: Add memalign error checks

Let's test for size and alignment in memalign to catch invalid input
data. Also it's good to test for NULL after calling the memalign
function of the registered allo

alloc: Add memalign error checks

Let's test for size and alignment in memalign to catch invalid input
data. Also it's good to test for NULL after calling the memalign
function of the registered alloc operations, since kvm-unit-tests
doesn't necessarily run in an environment where NULL pointer accesses
fail.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# dcda215b 23-Oct-2017 Paolo Bonzini <pbonzini@redhat.com>

vmalloc: convert to alloc_ops

The final step moves the vmalloc and vmap implementation to generic code,
rewriting vmalloc and vfree as an alloc_ops implementation that is
installed by setup_vm.

Thi

vmalloc: convert to alloc_ops

The final step moves the vmalloc and vmap implementation to generic code,
rewriting vmalloc and vfree as an alloc_ops implementation that is
installed by setup_vm.

This way all architectures can benefit from it just by calling setup_vm
and providing the implementation of install_page.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 11c4715f 23-Oct-2017 Paolo Bonzini <pbonzini@redhat.com>

alloc: implement free

Track block size in lib/alloc.c and not in alloc_ops. alloc_ops->free
gets the size from the malloc implementation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>


# fd6aada0 17-May-2017 Radim Krčmář <rkrcmar@redhat.com>

use %# instead of 0x% in all format strings

It's one character shorter, properly prefixed, and also provides error
detection: %#d triggers a warning.

Done with `sed -i 's/0x%/%#/g' **/*.[ch]` to mo

use %# instead of 0x% in all format strings

It's one character shorter, properly prefixed, and also provides error
detection: %#d triggers a warning.

Done with `sed -i 's/0x%/%#/g' **/*.[ch]` to motivate the use of %#,
existing padding was raised by 2 to account for the counted "0x" (output
should be the same).

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>

show more ...


# 633e2198 12-Dec-2016 Peter Xu <peterx@redhat.com>

libcflat: moving MIN/MAX here

That's something can be used outside alloc.c.

Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Paolo Bonzini <

libcflat: moving MIN/MAX here

That's something can be used outside alloc.c.

Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 8d2ff97f 03-Mar-2016 Andrew Jones <drjones@redhat.com>

lib/alloc: fix format warnings, add/use PRIx64

Also add casts, in case phys_addr_t is only a u32.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Message-Id: <1457008388-12749-3-git-send-email-drj

lib/alloc: fix format warnings, add/use PRIx64

Also add casts, in case phys_addr_t is only a u32.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Message-Id: <1457008388-12749-3-git-send-email-drjones@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# c1049d56 06-Nov-2015 Andrew Jones <drjones@redhat.com>

trivial: alloc: don't use 'top' outside spinlock

This is a fix just due to being too much of a type-A person.
I noticed the issue while reading over the function, and
decided to fix it, even though

trivial: alloc: don't use 'top' outside spinlock

This is a fix just due to being too much of a type-A person.
I noticed the issue while reading over the function, and
decided to fix it, even though it's unlikely to be a problem
ever because top is read-mostly (like written once, then only
read, type of mostly).

Signed-off-by: Andrew Jones <drjones@redhat.com>
Message-Id: <1446769483-21586-4-git-send-email-drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 15e51681 29-Jul-2015 Andrew Jones <drjones@redhat.com>

alloc: only warn once if we run out of log entries

Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>


# d1da56b4 30-Oct-2014 Andrew Jones <drjones@redhat.com>

lib: add ALIGN() macro

Add a type-considerate ALIGN[_UP] macro to libcflat, and apply
it to /lib code that can make use of it. This will be used to
fix PAGE_ALIGN on arm, which can be used on phys_a

lib: add ALIGN() macro

Add a type-considerate ALIGN[_UP] macro to libcflat, and apply
it to /lib code that can make use of it. This will be used to
fix PAGE_ALIGN on arm, which can be used on phys_addr_t
addresses, which may exceed 32 bits.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

show more ...


# 901c1c8d 22-Aug-2014 Paolo Bonzini <pbonzini@redhat.com>

Merge remote-tracking branch 'drjones/arm/v7-initial-drop'


# 417d4762 10-Jul-2014 Andrew Jones <drjones@redhat.com>

Introduce lib/alloc

alloc supplies three ingredients to the test framework that are all
related to the support of dynamic memory allocation.

The first is a set of alloc function wrappers for malloc

Introduce lib/alloc

alloc supplies three ingredients to the test framework that are all
related to the support of dynamic memory allocation.

The first is a set of alloc function wrappers for malloc and its
friends. Using wrappers allows test code and common code to use the
same interface for memory allocation at all stages, even though the
implementations may change with the stage, e.g. pre/post paging.

The second is a set of implementations for the alloc function
interfaces. These implementations are named early_*, as they can be
used almost immediately by the test framework.

The third is a very simple physical memory allocator, which the
early_* alloc functions build on.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
v7: expanded from only supplying the alloc function wrappers to
including early_* and phys_alloc [Paolo Bonzini]

show more ...