From: Andrew Jones <drjones@redhat.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, cdall@linaro.org,
david@redhat.com, lvivier@redhat.com, thuth@redhat.com
Subject: [PATCH kvm-unit-tests v2 07/12] page_alloc: allow initialization before setup_vm call
Date: Wed, 17 Jan 2018 11:40:00 +0100 [thread overview]
Message-ID: <20180117104005.29211-8-drjones@redhat.com> (raw)
In-Reply-To: <20180117104005.29211-1-drjones@redhat.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
lib/alloc_page.c | 5 +++++
lib/alloc_page.h | 1 +
lib/vmalloc.c | 9 ++++++---
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/alloc_page.c b/lib/alloc_page.c
index f0d46d7ac201..ca11496829a0 100644
--- a/lib/alloc_page.c
+++ b/lib/alloc_page.c
@@ -13,6 +13,11 @@
static struct spinlock lock;
static void *freelist = 0;
+bool page_alloc_initialized(void)
+{
+ return freelist != 0;
+}
+
void free_pages(void *mem, unsigned long size)
{
void *old_freelist;
diff --git a/lib/alloc_page.h b/lib/alloc_page.h
index 1884c7a34ffc..1c2b3ec9add6 100644
--- a/lib/alloc_page.h
+++ b/lib/alloc_page.h
@@ -8,6 +8,7 @@
#ifndef ALLOC_PAGE_H
#define ALLOC_PAGE_H 1
+bool page_alloc_initialized(void);
void *alloc_page();
void *alloc_pages(unsigned long order);
void free_page(void *page);
diff --git a/lib/vmalloc.c b/lib/vmalloc.c
index ca36bf87579a..b583786e2647 100644
--- a/lib/vmalloc.c
+++ b/lib/vmalloc.c
@@ -94,9 +94,12 @@ void setup_vm()
return;
phys_alloc_get_unused(&base, &top);
- base = (base + PAGE_SIZE - 1) & -PAGE_SIZE;
- top = top & -PAGE_SIZE;
- free_pages(phys_to_virt(base), top - base);
+ assert(base != top || page_alloc_initialized());
+ if (!page_alloc_initialized()) {
+ base = (base + PAGE_SIZE - 1) & -PAGE_SIZE;
+ top = top & -PAGE_SIZE;
+ free_pages(phys_to_virt(base), top - base);
+ }
page_root = setup_mmu(top);
alloc_ops = &vmalloc_ops;
}
--
2.13.6
next prev parent reply other threads:[~2018-01-17 10:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-17 10:39 [PATCH kvm-unit-tests v2 00/12] arm/arm64: mmu fixes and feature Andrew Jones
2018-01-17 10:39 ` [PATCH kvm-unit-tests v2 01/12] arm/arm64: cleanup alloc.h includes Andrew Jones
2018-01-17 10:39 ` [PATCH kvm-unit-tests v2 02/12] arm/arm64: add pgtable to thread_info Andrew Jones
2018-01-17 10:39 ` [PATCH kvm-unit-tests v2 03/12] arm/arm64: fix virt_to_phys Andrew Jones
2018-01-17 10:39 ` [PATCH kvm-unit-tests v2 04/12] arm/arm64: flush page table cache when installing entries Andrew Jones
2018-01-17 10:39 ` [PATCH kvm-unit-tests v2 05/12] arm/arm64: setup: don't allow gaps in phys range Andrew Jones
2018-01-17 10:39 ` [PATCH kvm-unit-tests v2 06/12] phys_alloc: ensure we account all allocations Andrew Jones
2018-01-17 12:15 ` David Hildenbrand
2018-01-17 10:40 ` Andrew Jones [this message]
2018-01-17 10:40 ` [PATCH kvm-unit-tests v2 08/12] bitops: add fls Andrew Jones
2018-01-17 10:40 ` [PATCH kvm-unit-tests v2 09/12] page_alloc: add yet another memalign Andrew Jones
2018-01-17 10:40 ` [PATCH kvm-unit-tests v2 10/12] lib/auxinfo: add flags field Andrew Jones
2018-01-17 10:40 ` [PATCH kvm-unit-tests v2 11/12] arm/arm64: allow setup_vm to be skipped Andrew Jones
2018-01-17 10:40 ` [PATCH kvm-unit-tests v2 12/12] arm/arm64: sieve should start with the mmu off Andrew Jones
2018-01-17 11:17 ` [PATCH kvm-unit-tests v2 00/12] arm/arm64: mmu fixes and feature David Hildenbrand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180117104005.29211-8-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=cdall@linaro.org \
--cc=david@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox