aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Imbrenda <imbrenda@linux.ibm.com>2020-06-22 18:21:36 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2020-06-22 13:47:43 -0400
commit6ea7326a9de006edca66e342959b78c1fb4b776f (patch)
tree865f74ee72d048d07eed3e2adf2d6837966bc32b
parent5b70cbdb7bc2ea65096b51565c75815cc95945b8 (diff)
downloadkvm-unit-tests-6ea7326a9de006edca66e342959b78c1fb4b776f.tar.gz
lib: use PAGE_ALIGN
Since now PAGE_ALIGN is available in all architectures, start using it in common code to improve readability. Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Message-Id: <20200622162141.279716-4-imbrenda@linux.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--lib/vmalloc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/vmalloc.c b/lib/vmalloc.c
index 5022a31..74b785c 100644
--- a/lib/vmalloc.c
+++ b/lib/vmalloc.c
@@ -41,7 +41,7 @@ void *vmap(phys_addr_t phys, size_t size)
void *mem, *p;
unsigned pages;
- size = (size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+ size = PAGE_ALIGN(size);
pages = size / PAGE_SIZE;
mem = p = alloc_vpages(pages);
@@ -60,7 +60,7 @@ static void *vm_memalign(size_t alignment, size_t size)
unsigned pages;
assert(alignment <= PAGE_SIZE);
- size = (size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+ size = PAGE_ALIGN(size);
pages = size / PAGE_SIZE;
mem = p = alloc_vpages(pages);
while (pages--) {
@@ -104,7 +104,7 @@ void setup_vm()
* so that it can be used to allocate page tables.
*/
if (!page_alloc_initialized()) {
- base = (base + PAGE_SIZE - 1) & -PAGE_SIZE;
+ base = PAGE_ALIGN(base);
top = top & -PAGE_SIZE;
free_pages(phys_to_virt(base), top - base);
}
@@ -113,7 +113,7 @@ void setup_vm()
phys_alloc_get_unused(&base, &top);
page_root = setup_mmu(top);
if (base != top) {
- base = (base + PAGE_SIZE - 1) & -PAGE_SIZE;
+ base = PAGE_ALIGN(base);
top = top & -PAGE_SIZE;
free_pages(phys_to_virt(base), top - base);
}