@@ -40,12 +40,14 @@ int main(void)
printf("starting sieve\n");
test_sieve("static", static_data, STATIC_SIZE);
- setup_vm();
- test_sieve("mapped", static_data, STATIC_SIZE);
- for (i = 0; i < 3; ++i) {
- v = malloc(VSIZE);
- test_sieve("virtual", v, VSIZE);
- free(v);
+ if (vm_available()) {
+ setup_vm();
+ test_sieve("mapped", static_data, STATIC_SIZE);
+ for (i = 0; i < 3; ++i) {
+ v = malloc(VSIZE);
+ test_sieve("virtual", v, VSIZE);
+ free(v);
+ }
}
return 0;
@@ -3,7 +3,6 @@
#include <asm/pgtable.h>
-bool vm_available(void);
bool mmu_enabled(void);
void mmu_enable(pgd_t *pgtable);
void mmu_disable(void);
@@ -24,7 +24,7 @@
static pgd_t *identity_pgd;
-bool vm_available(void)
+bool vm_available(void) /* weak override */
{
return cpu_has_radix;
}
@@ -206,10 +206,17 @@ void init_alloc_vpage(void *top)
spin_unlock(&lock);
}
+bool __attribute__((__weak__)) vm_available(void)
+{
+ return true;
+}
+
void __setup_vm(void *opaque)
{
phys_addr_t base, top;
+ assert_msg(vm_available(), "Virtual memory not available. Must check vm_available() before calling setup_vm()");
+
if (alloc_ops == &vmalloc_ops)
return;
@@ -17,6 +17,8 @@ extern void setup_vm(void);
/* As above, plus passes an opaque value to setup_mmu(). */
extern void __setup_vm(void *opaque);
+/* common/ tests must check availability before calling setup_vm() */
+extern bool vm_available(void);
/* Set up paging */
extern void *setup_mmu(phys_addr_t top, void *opaque);
/* Walk the page table and resolve the virtual address to a physical address */
Not all powerpc CPUs provide MMU support. Define vm_available() that is true by default but archs can override it. Use this to run VM tests. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Thomas Huth <thuth@redhat.com> Cc: Andrew Jones <andrew.jones@linux.dev> Cc: kvm@vger.kernel.org Signed-off-by: Nicholas Piggin <npiggin@gmail.com> --- common/sieve.c | 14 ++++++++------ lib/ppc64/asm/mmu.h | 1 - lib/ppc64/mmu.c | 2 +- lib/vmalloc.c | 7 +++++++ lib/vmalloc.h | 2 ++ 5 files changed, 18 insertions(+), 8 deletions(-)